モデルのトレーニング、データセットへのファイルのインポート、モデルの削除などは長時間実行オペレーションです。これらのタイプのオペレーションをリクエストすると、オペレーション ID を含む JSON が返されます。この ID を使用すると、オペレーションのステータスを取得できます。
たとえば、モデルのトレーニング リクエストは次の JSON を返します。
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/IOD3074819451447672458", "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": {} } }
この場合、IOD3074819451447672458
がオペレーション ID です。次のサンプルでは、この ID のオペレーションのステータスを取得します。
REST
リクエストのデータを使用する前に、次のように置き換えます。
- project-id: GCP プロジェクト ID
- operation-id: オペレーションの IDこの ID は、オペレーションの名前の最後の要素です。例:
- オペレーション名:
projects/project-id/locations/location-id/operations/IOD5281059901324392598
- オペレーション ID:
IOD5281059901324392598
- オペレーション名:
HTTP メソッドと URL:
GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID
リクエストを送信するには、次のいずれかのオプションを選択します。
curl
次のコマンドを実行します。
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
次のコマンドを実行します。
$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" } }
完了したモデル作成オペレーションの場合、出力は次のようになります。
{ "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
このサンプルを試す前に、クライアント ライブラリ ページを参照して、この言語の設定手順を完了してください。
Java
このサンプルを試す前に、クライアント ライブラリ ページを参照して、この言語の設定手順を完了してください。
Node.js
このサンプルを試す前に、クライアント ライブラリ ページを参照して、この言語の設定手順を完了してください。
Python
このサンプルを試す前に、クライアント ライブラリ ページを参照して、この言語の設定手順を完了してください。
その他の言語
C#: クライアント ライブラリ ページの C# の設定手順を行ってから、.NET 用の AutoML Vision Object Detection リファレンス ドキュメントをご覧ください。
PHP: クライアント ライブラリ ページの PHP の設定手順を行ってから、PHP 用の AutoML Vision Object Detection リファレンス ドキュメントをご覧ください。
Ruby: クライアント ライブラリ ページの Ruby の設定手順を行ってから、Ruby 用の AutoML Vision Object Detection リファレンス ドキュメントをご覧ください。