REST Resource: operations

資源:Operation

這個資源表示屬於網路 API 呼叫結果的長時間執行作業。

JSON 表示法
{
  "name": string,
  "metadata": {
    "@type": string,
    field1: ...,
    ...
  },
  "done": boolean,

  // Union field result can be only one of the following:
  "error": {
    object (Status)
  },
  "response": {
    "@type": string,
    field1: ...,
    ...
  }
  // End of list of possible types for union field result.
}
欄位
name

string

伺服器指派的名稱,而且只在當初傳回這個名稱的服務中是唯一的。如果使用預設的 HTTP 對應,name 應為結尾為 operations/{unique_id} 的資源名稱。

metadata

object

如果作業是由 claimAsyncunclaimAsyncupdateMetadataAsync 建立,這個欄位會包含 DevicesLongRunningOperationMetadata 物件。

包含任意類型欄位的物件。額外的 "@type" 欄位則包含能辨識類型的 URI。例如:{ "id": 1234, "@type": "types.example.com/standard/id" }.

done

boolean

如果值為 false,代表作業仍在執行中。如果為 true,表示作業已完成,且可使用 errorresponse

聯集欄位 result。這是作業的執行結果,可能為 error,或是有效的 response。如果 done == false,系統不會將結果設定為 error,也不會設定為 response。如果 done == true,則可以只設定 errorresponse 其中之一。請注意,部分服務可能無法提供結果。result 只能是下列其中一個設定:
error

object (Status)

如果作業是由 claimAsyncunclaimAsyncupdateMetadataAsync 建立,則一律無法設定此欄位。在此情況下,請在 response.perDeviceStatus.result.status 中設定每部裝置的錯誤資訊。

response

object

如果作業是由 claimAsyncunclaimAsyncupdateMetadataAsync 建立,這個欄位會包含 DevicesLongRunningOperationResponse 物件。

包含任意類型欄位的物件。額外的 "@type" 欄位則包含能辨識類型的 URI。例如:{ "id": 1234, "@type": "types.example.com/standard/id" }.

狀態

Status 類型會定義適用於不同程式設計環境 (包含 REST API 和遠端程序呼叫 (RPC) API) 的邏輯錯誤模型。gRPC 會使用這個模型。每個 Status 訊息包含三部分的資料:錯誤代碼、錯誤訊息和錯誤詳細資料。

如要進一步瞭解這個錯誤模型,以及如何使用這個錯誤模型,請參閱 API 設計指南

JSON 表示法
{
  "code": integer,
  "message": string,
  "details": [
    {
      "@type": string,
      field1: ...,
      ...
    }
  ]
}
欄位
code

integer

狀態碼,應為 google.rpc.Code 的列舉值。

message

string

向開發人員顯示的錯誤訊息,應以英文呈現。所有向使用者顯示的錯誤訊息都必須經過本地化,並以 google.rpc.Status.details 欄位傳送,或由用戶端進行本地化。

details[]

object

包含錯誤詳細資料的訊息清單。這是供 API 使用的一組常用訊息類型。

包含任意類型欄位的物件。額外的 "@type" 欄位則包含能辨識類型的 URI。例如:{ "id": 1234, "@type": "types.example.com/standard/id" }.

方法

get

取得長時間執行的作業的最新狀態。