本頁說明如何管理 Live Stream API 長時間執行作業 (LRO) 的生命週期。
如果方法呼叫可能需要很長的時間才能完成,系統會傳回長時間執行的作業。舉例來說,Live Stream API 會在您每次呼叫 projects.locations.inputs.create
時建立 LRO。LRO 會追蹤處理工作的狀態。
您可以使用 Live Stream API 提供的 projects.locations.operations
方法,檢查 LROs 的狀態。您也可以列出、取消或刪除 LRO。
LRO 會在 Google Cloud 專案和位置層級管理。向 API 提出要求時,請一併提供 Google Cloud 專案和 LRO 執行的位置。
LRO 的記錄會在 LRO 結束後約 30 天保留,也就是說,您無法在該時間點之後查看或列出 LRO。
取得長時間執行作業的詳細資料
假設您建立了輸入端點。回應中的 name
值顯示 Live Stream API 建立了名為 projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID
的 LRO。
如要檢查是否已建立輸入端點,請使用 projects.locations.operations.get
方法。如果回應包含 "done": false
,請重複執行指令,直到回應包含 "done": true
為止。這項作業可能需要幾分鐘才能完成。
您也可以列出長時間執行的作業,以擷取 LRO 名稱。
使用任何要求資料之前,請先替換以下項目:
PROJECT_NUMBER
:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位LOCATION
:輸入端點的位置;請使用其中一個支援的地區顯示地區us-central1
us-east1
us-east4
us-west1
us-west2
northamerica-northeast1
southamerica-east1
asia-east1
asia-east2
asia-south1
asia-northeast1
asia-southeast1
australia-southeast1
europe-north1
europe-west1
europe-west2
europe-west3
europe-west4
OPERATION_ID
:作業的 ID
如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.video.livestream.v1.OperationMetadata", "createTime": CREATE_TIME, "endTime": END_TIME, "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.video.livestream.v1.Input", "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID", "createTime": CREATE_TIME, "updateTime": UPDATE_TIME, "type": "RTMP_PUSH", "uri": INPUT_STREAM_URI, # For example, "rtmp://1.2.3.4/live/b8ebdd94-c8d9-4d88-a16e-b963c43a953b", "tier": "HD" } }
列出長時間執行的作業
如要列出特定位置的所有作業,請使用 projects.locations.operations.list
方法。
使用任何要求資料之前,請先替換以下項目:
PROJECT_NUMBER
:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位LOCATION
:作業的位置;請使用其中一個支援的區域顯示地區us-central1
us-east1
us-east4
us-west1
us-west2
northamerica-northeast1
southamerica-east1
asia-east1
asia-east2
asia-south1
asia-northeast1
asia-southeast1
australia-southeast1
europe-north1
europe-west1
europe-west2
europe-west3
europe-west4
如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{ "operations": [ { "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.livestream.v1.OperationMetadata", "createTime": CREATE_TIME, "endTime": END_TIME, "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID, "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }, { "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/my-other-operation", "metadata": { "@type": "type.googleapis.com/google.cloud.livestream.v1.OperationMetadata", "createTime": CREATE_TIME, "endTime": END_TIME, "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/my-other-input", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.livestream.v1.Input", "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/my-other-input", "createTime": CREATE_TIME, "updateTime": UPDATE_TIME, "type": "RTMP_PUSH", "uri": INPUT_STREAM_URI, "tier": "HD" } } ] }
取消長時間執行的作業
如要開始以非同步的方式取消長時間執行的作業,請使用 projects.locations.operations.cancel
方法。伺服器會盡力取消作業,但不保證一定會成功。
使用任何要求資料之前,請先替換以下項目:
PROJECT_NUMBER
:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位LOCATION
:作業的位置;請使用其中一個支援的區域顯示地區us-central1
us-east1
us-east4
us-west1
us-west2
northamerica-northeast1
southamerica-east1
asia-east1
asia-east2
asia-south1
asia-northeast1
asia-southeast1
australia-southeast1
europe-north1
europe-west1
europe-west2
europe-west3
europe-west4
OPERATION_ID
:作業的 ID
如要傳送要求,請展開以下其中一個選項:
您應該會收到空白的 JSON 物件做為回應:{}
刪除長時間執行的作業
如要刪除已完成的長時間執行作業,請使用 projects.locations.operations.delete
方法。這個方法表示用戶端不再對作業結果感興趣。不會取消作業。
使用任何要求資料之前,請先替換以下項目:
PROJECT_NUMBER
:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位LOCATION
:作業的位置;請使用其中一個支援的區域顯示地區us-central1
us-east1
us-east4
us-west1
us-west2
northamerica-northeast1
southamerica-east1
asia-east1
asia-east2
asia-south1
asia-northeast1
asia-southeast1
australia-southeast1
europe-north1
europe-west1
europe-west2
europe-west3
europe-west4
OPERATION_ID
:作業的 ID
如要傳送要求,請展開以下其中一個選項:
您應該會收到空白的 JSON 物件做為回應:{}