Beberapa operasi yang Anda minta berjalan lama, seperti pelatihan model, impor file ke set data, dan penghapusan model. Jenis permintaan ini akan menampilkan JSON dengan ID operasi yang dapat Anda gunakan untuk mendapatkan status operasi.
Misalnya, permintaan pelatihan model menampilkan JSON berikut:
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/ICN3074819451447672458", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2019-07-26T21:10:18.338846Z", "updateTime": "2019-07-26T21:10:18.338846Z", "createModelDetails": {} } }
Dalam hal ini, ID operasinya adalah ICN3074819451447672458
. Contoh berikut
menunjukkan cara mendapatkan status operasi ini dengan ID ini.
Mendapatkan contoh kode operasi
REST
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
- project-id: project ID GCP Anda.
- operation-id: ID operasi Anda. ID tersebut adalah elemen terakhir dari nama
operasi Anda. Contoh:
- nama operasi:
projects/project-id/locations/location-id/operations/IOD5281059901324392598
- ID Operasi:
IOD5281059901324392598
- nama operasi:
Metode HTTP dan URL:
GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Jalankan perintah berikut:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID"
PowerShell
Jalankan perintah berikut:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID" | Select-Object -Expand Content
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2018-10-29T15:56:29.176485Z", "updateTime": "2018-10-29T16:10:41.326614Z", "importDataDetails": {} }, "done": true, "response": { "@type": "type.googleapis.com/google.protobuf.Empty" } }
Anda akan melihat output yang mirip dengan hal berikut ini untuk membuat operasi model yang telah selesai:
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2019-07-22T18:35:06.881193Z", "updateTime": "2019-07-22T19:58:44.972235Z", "createModelDetails": {} }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.automl.v1.Model", "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID" } }
Go
Sebelum mencoba sampel ini, ikuti petunjuk penyiapan untuk bahasa ini di halaman API & Referensi > Library Klien.
Java
Sebelum mencoba sampel ini, ikuti petunjuk penyiapan untuk bahasa ini di halaman API & Referensi > Library Klien.
Node.js
Sebelum mencoba sampel ini, ikuti petunjuk penyiapan untuk bahasa ini di halaman API & Referensi > Library Klien.
Python
Sebelum mencoba sampel ini, ikuti petunjuk penyiapan untuk bahasa ini di halaman API & Referensi > Library Klien.
Bahasa tambahan
C# : Ikuti Petunjuk penyiapan C# di halaman library klien, lalu kunjungi dokumentasi referensi AutoML Vision untuk .NET.
PHP : Ikuti Petunjuk penyiapan PHP di halaman library klien, lalu kunjungi dokumentasi referensi AutoML Vision untuk PHP.
Ruby : Ikuti Petunjuk penyiapan Ruby di halaman library klien, lalu kunjungi dokumentasi referensi AutoML Vision untuk Ruby.