如果 API 方法通常需要長時間才能完成作業,則可能會向用戶端傳回 Operation。這樣一來,用戶端即可藉由輪詢作業資源,以非同步的方式透過這個介面接收真正的回應;或是傳遞作業資源至其他 API (例如 Google Cloud 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-07-31 (世界標準時間)。"],[[["\u003cp\u003eOperations manages long-running API tasks, allowing clients to receive asynchronous responses.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGetOperation\u003c/code\u003e method allows clients to check the status of an operation by polling at intervals suggested by the API service.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eListOperations\u003c/code\u003e method enables clients to retrieve a list of operations based on specified filters.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eOperation\u003c/code\u003e resource includes fields for tracking an operation's name, metadata, status (\u003ccode\u003edone\u003c/code\u003e), and result (either an \u003ccode\u003eerror\u003c/code\u003e or a \u003ccode\u003eresponse\u003c/code\u003e).\u003c/p\u003e\n"]]],[],null,["# Package google.longrunning\n\nImportant: To access the URL listed within parentheses, you must connect to the internet. The URL is provided to access outside of your air-gapped environment.\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](/distributed-cloud/hosted/docs/latest/gdch/apis/vertex-ai/translation/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 Google Cloud 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\nGetOperationRequest\n-------------------\n\nThe request message for [Operations.GetOperation](/distributed-cloud/hosted/docs/latest/gdch/apis/vertex-ai/translation/rpc/google.longrunning#google.longrunning.Operations.GetOperation).\n\nListOperationsRequest\n---------------------\n\nThe request message for [Operations.ListOperations](/distributed-cloud/hosted/docs/latest/gdch/apis/vertex-ai/translation/rpc/google.longrunning#google.longrunning.Operations.ListOperations).\n\nListOperationsResponse\n----------------------\n\nThe response message for [Operations.ListOperations](/distributed-cloud/hosted/docs/latest/gdch/apis/vertex-ai/translation/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."]]