ARCore Cloud Anchor Management API'si

ARCore Cloud Anchor'ı kullanarak ARCore uygulamanızın dışındaki Cloud Anchor'ları yönetme Management API'si.

Başlarken

Örnek işlemler

Yetkilendirme

Şu hizmet hesabı anahtarı oluşturun: Google Cloud Platform konsolunun Cloud Anchor yönetim API'si çağrılarını yetkilendirmek için bir OAuth2 jetonu.

  1. Google Cloud Platform Console'da APIs & Services Credentials.

  2. İstediğiniz projeyi seçip Create Credentials > Service account.

  3. Service account details altında, yeni hesap için bir ad yazın, ardından Create'ı tıklayın.

  4. Service account permissions sayfasında Select a role'ye gidin. açılır. Service Accounts > seçeneğini belirleyin Service Account Token Creator, Continue simgesini tıklayın.

  5. Grant users access to this service account sayfasında Done simgesini tıklayın. Bu işlem sizi şuraya geri götürür: APIs & Services > Credentials.

  6. Credentials sayfasında Service Accounts bölümüne ilerleyin ve yeni oluşturduğunuz hesabın adını tıklayın.

  7. Service account details sayfasında Keys bölümüne ilerleyin Add Key > Create new key.

  8. Anahtar türü olarak JSON'i seçin ve Create'i tıklayın. Bu işlem bir JSON indirir gizli anahtarı içeren bir dosya yükleyin. İndirilen JSON dosyasını depolayın anahtar dosyasını güvenli bir yerde saklamanız gerekir.

OAuth2 jetonu oluşturun

arcore.management, Cloud Anchors Management API'nin OAuth kapsamıdır. Ölçüt oauth2l, varsayılan olarak jeton önbelleğinde çalışır. fetch komutu, aynı URL'yi kullanarak jeton. OAuth2 oluşturmak için oauth2l kullanın yetkilendirme jetonu:

oauth2l fetch --json creds.json arcore.management

Yeni bir jeton oluşturmak için fetch öğesine bir --cache="" seçeneği ekleyin. komutunu kullanın.

oauth2l fetch --cache="" --json creds.json arcore.management

Alternatif olarak, oauth2l reset yöntemini çağırıp fetch komutunu tekrar çağırın.

oauth2l reset
oauth2l fetch --json creds.json arcore.management

Tüm Cloud Anchor'larını listele

Cloud Anchor'ların ilk sayfasını (isteğe bağlı olarak expire_time sütununa göre sıralanmış olarak) görün create_time veya last_localize_time.

İstek:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors?page_size=50&order_by=last_localize_time%20desc"

Yanıt:

{
  "anchors": [
    {
      "name": "anchors/ua-a1cc84e4f11b1287d289646811bf54d1",
      "createTime": "...",
      "expireTime": "...",
      "lastLocalizeTime": "...",
      "maximumExpireTime": "..."
    },
   …
    {
      "name": "anchors/ua-41a3d0233471917875159f6f3c25ea0e",
      "createTime": "...",
      "expireTime": "...",
      "lastLocalizeTime": "...",
      "maximumExpireTime": "..."
    }
  ],
  nextPageToken: "some-long-string"
}

Yanıt nextPageToken ile geri dönerse, daha fazla sabit reklam liste'ye dokunun. Aşağıdaki verileri almak için sonraki istekte next_page_token sorgu parametresini kullanın: ilk adımınızı attınız.

İstek:

curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors?page_size=50&order_by=last_localize_time%20desc&next_page_token=your-next-page-token-here"

next_page_token kullanılırken page_size ve order_by tutarlı olmalıdır dikkat edin. page_size için varsayılan değer 1000, order_by ise varsayılan olarak ayarlandı expire_time_desc.

Bir Cloud Anchor'un geçerlilik süresini, izin verilen maksimum süreye göre güncelleme

lastLocalizeTime öğesini sorgulamak için tek bir Cloud Anchor isteğinde bulunun ve maximumExpireTime.

İstek:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here"

Yanıt:

{
  "name": "anchors/ua-f21be53fd8ea57f0169c69fbf827f6b7",
  "createTime": "2020-06-29T21:00:00Z",
  "expireTime": "2020-08-28T22:00:00Z",
  "lastLocalizeTime": "2020-06-29T21:00:00Z",
  "maximumExpireTime": "2021-06-29T21:00:00Z"
}

Sabitlemeyi oluşturduktan sonra expireTime değerini maximumExpireTime olarak güncelleyin.

İstek:

curl -H "Authorization: Bearer $BEARER_TOKEN" -H "Content-Type: application/json" -X "PATCH" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here?updateMask=expire_time" \
-d '{ expireTime: "2021-06-29T21:00:00Z" }'

Yanıt:

{
  "name": "anchors/ua-f21be53fd8ea57f0169c69fbf827f6b7",
  "createTime": "2020-06-29T21:00:00Z",
  "expireTime": "2021-06-29T21:00:00Z",
  "lastLocalizeTime": "2020-06-29T21:00:00Z",
  "maximumExpireTime": "2021-06-29T21:00:00Z"
}

Cloud Anchor'ları Silin

Tek bir Cloud Anchor'ı silme:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" -X "DELETE" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here"

Bir Cloud Anchor grubunu silin:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" -H "Content-Type: application/json" -X "POST" \
"https://arcore.googleapis.com/v1beta2/management/anchors:batchDelete" \
-d '{ names: [ "anchors/your-anchor-id-here", "anchors/your-anchor-id-here" ]}'