如果 API 方法通常要長時間才能完成,則可設計為向用戶端傳回 Operation,而用戶端可以使用這個介面,透過輪詢作業資源來非同步接收實際回應,或是將作業資源傳遞至其他 API (例如 Pub/Sub API) 來接收回應。凡是傳回長時間執行作業的 API 服務都應實作 Operations 介面,讓開發人員能獲得一致的用戶端體驗。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-05-16 (世界標準時間)。"],[],[],null,["# Package google.longrunning\n\nIndex\n-----\n\n- [Operations](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operations) (interface)\n- [CancelOperationRequest](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.CancelOperationRequest) (message)\n- [GetOperationRequest](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.GetOperationRequest) (message)\n- [ListOperationsRequest](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.ListOperationsRequest) (message)\n- [ListOperationsResponse](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.ListOperationsResponse) (message)\n- [Operation](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operation) (message)\n\nOperations\n----------\n\nManages long-running operations with an API service.\n\nWhen an API method normally takes long time to complete, it can be designed to return [Operation](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operation) to the client, and the client can use this interface to receive the real response asynchronously by polling the operation resource, or pass the operation resource to another API (such as Pub/Sub API) to receive the response. Any API service that returns long-running operations should implement the `Operations` interface so developers can have a consistent client experience.\n\nCancelOperationRequest\n----------------------\n\nThe request message for [Operations.CancelOperation](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operations.CancelOperation).\n\nGetOperationRequest\n-------------------\n\nThe request message for [Operations.GetOperation](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operations.GetOperation).\n\nListOperationsRequest\n---------------------\n\nThe request message for [Operations.ListOperations](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operations.ListOperations).\n\nListOperationsResponse\n----------------------\n\nThe response message for [Operations.ListOperations](/storage-transfer/docs/reference/rpc/google.longrunning#google.longrunning.Operations.ListOperations).\n\nOperation\n---------\n\nThis resource represents a long-running operation that is the result of a network API call."]]