AutoML Video Intelligence の一部のメソッドは、長時間実行オペレーションを返します。これらのメソッドは非同期で、メソッドがレスポンスを返すときにオペレーションが完了していない場合があります。
オペレーションのステータスを取得する
長時間実行タスク(データセットへのアイテムのインポートやモデルのトレーニング)のステータスは、オペレーション名を使用して確認できます。
REST
リクエストのデータを使用する前に、次のように置き換えます。
- project-number: プロジェクトの番号
- location-id: us-central1 などです。
- operation id: オペレーションの開始時にレスポンスで返されます(分類の場合、
VCN123....
など。オブジェクト トラッキングの場合、VOT123....
など)。
HTTP メソッドと URL:
GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id
リクエストを送信するには、次のいずれかのオプションを選択します。
curl
次のコマンドを実行します。
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id"
PowerShell
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id" | Select-Object -Expand Content
- モデル名:
projects/project-number/locations/location-id/models/model-id
- モデル ID:
model-id
オペレーションのキャンセル
オペレーション ID を使用して、長時間実行オペレーションをキャンセルできます。ただし、キャンセルは必ず成功するとは限りません。
REST
リクエストのデータを使用する前に、次のように置き換えます。
- operation id: オペレーションの開始時にレスポンスで返されます
(分類の場合、VCN123....
など。オブジェクト トラッキングの場合、VOT123....
など)。 - 注:
- project-number: GCP プロジェクト ID
- location-id: アノテーションを実行する Cloud リージョン。サポート対象のクラウド リージョンは
us-east1
、us-west1
、europe-west1
、asia-east1
です。リージョンを指定しないと、動画ファイルの場所に基づいてリージョンが決まります。
HTTP メソッドと URL:
POST https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id:cancel
リクエストを送信するには、次のいずれかのオプションを展開します。
成功したことを示すステータス コード(2xx)と空のレスポンスが返されます。