ARCore Cloud Anchor Management API'si

ARCore Cloud Anchor Management API'yi kullanarak Cloud Anchor'ları ARCore uygulamanızın dışında yönetin.

Kullanmaya başlama

Örnek işlemler

Yetkilendirme

Google Cloud Platform Console'da bir hizmet hesabı anahtarı ve Cloud Anchor Management API çağrılarını yetkilendirmek için bir OAuth2 jetonu oluşturun.

  1. Google Cloud Platform Console gezinme menüsünde APIs & Services > Credentials bölümüne gidin.

  2. İstediğiniz projeyi seçin ve Create Credentials > Service account seçeneklerini tıklayın.

  3. Service account details altında, yeni hesap için bir ad yazıp Create düğmesini tıklayın.

  4. Service account permissions sayfasında Select a role açılır menüsüne gidin. Service Accounts > Service Account Token Creator seçeneğini belirleyin ve Continue düğmesini tıklayın.

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

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

  7. Service account details sayfasında, Keys bölümüne gidin ve Add Key > Create new key seçeneğini belirleyin.

  8. Anahtar türü olarak JSON'i seçin ve Create düğmesini tıklayın. Makinenize özel anahtarı içeren bir JSON dosyası indirilir. İndirilen JSON anahtar dosyasını güvenli bir konumda depolayın.

OAuth2 jetonu oluşturma

arcore.management, Cloud Anchors Management API için OAuth kapsamıdır. Oauth2l, varsayılan olarak bir jeton önbelleği üzerinde çalışır. fetch komutu aynı jetonu alır. Yetkilendirme amacıyla OAuth2 jetonu oluşturmak için oauth2l'yi kullanın:

oauth2l fetch --json creds.json arcore.management

Yeni bir jeton oluşturmak için fetch komutuna bir --cache="" seçeneği ekleyin.

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

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

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

Tüm Cloud Anchor'larını listeleme

İsteğe bağlı olarak expire_time, create_time veya last_localize_time ölçütüne göre sıralanmış Cloud Anchor'ların ilk sayfasını görüntüleyin.

İ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 bir nextPageToken ile geri gelirse listelenecek daha çok sabit öğe olur. Bir sonraki sonuç grubunu almak için sonraki istekte next_page_token sorgu parametresini kullanın.

İ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, istekler genelinde tutarlı olmalıdır. page_size varsayılan olarak 1000, order_by varsayılan olarak expire_time_desc değerine ayarlanır.

Cloud Anchor'ın geçerlilik süresini izin verilen maksimum süreye güncelleyin

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

İ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"
}

Bağlayıcıyı 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ını Silme

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"

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" ]}'