operations.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.longrunning;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/protobuf/any.proto";
  19. import "google/protobuf/duration.proto";
  20. import "google/protobuf/empty.proto";
  21. import "google/rpc/status.proto";
  22. import "google/protobuf/descriptor.proto";
  23. option cc_enable_arenas = true;
  24. option csharp_namespace = "Google.LongRunning";
  25. option go_package = "cloud.google.com/go/longrunning/autogen/longrunningpb;longrunningpb";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "OperationsProto";
  28. option java_package = "com.google.longrunning";
  29. option php_namespace = "Google\\LongRunning";
  30. extend google.protobuf.MethodOptions {
  31. // Additional information regarding long-running operations.
  32. // In particular, this specifies the types that are returned from
  33. // long-running operations.
  34. //
  35. // Required for methods that return `google.longrunning.Operation`; invalid
  36. // otherwise.
  37. google.longrunning.OperationInfo operation_info = 1049;
  38. }
  39. // Manages long-running operations with an API service.
  40. //
  41. // When an API method normally takes long time to complete, it can be designed
  42. // to return [Operation][google.longrunning.Operation] to the client, and the client can use this
  43. // interface to receive the real response asynchronously by polling the
  44. // operation resource, or pass the operation resource to another API (such as
  45. // Google Cloud Pub/Sub API) to receive the response. Any API service that
  46. // returns long-running operations should implement the `Operations` interface
  47. // so developers can have a consistent client experience.
  48. service Operations {
  49. option (google.api.default_host) = "longrunning.googleapis.com";
  50. // Lists operations that match the specified filter in the request. If the
  51. // server doesn't support this method, it returns `UNIMPLEMENTED`.
  52. //
  53. // NOTE: the `name` binding allows API services to override the binding
  54. // to use different resource name schemes, such as `users/*/operations`. To
  55. // override the binding, API services can add a binding such as
  56. // `"/v1/{name=users/*}/operations"` to their service configuration.
  57. // For backwards compatibility, the default name includes the operations
  58. // collection id, however overriding users must ensure the name binding
  59. // is the parent resource, without the operations collection id.
  60. rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) {
  61. option (google.api.http) = {
  62. get: "/v1/{name=operations}"
  63. };
  64. option (google.api.method_signature) = "name,filter";
  65. }
  66. // Gets the latest state of a long-running operation. Clients can use this
  67. // method to poll the operation result at intervals as recommended by the API
  68. // service.
  69. rpc GetOperation(GetOperationRequest) returns (Operation) {
  70. option (google.api.http) = {
  71. get: "/v1/{name=operations/**}"
  72. };
  73. option (google.api.method_signature) = "name";
  74. }
  75. // Deletes a long-running operation. This method indicates that the client is
  76. // no longer interested in the operation result. It does not cancel the
  77. // operation. If the server doesn't support this method, it returns
  78. // `google.rpc.Code.UNIMPLEMENTED`.
  79. rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) {
  80. option (google.api.http) = {
  81. delete: "/v1/{name=operations/**}"
  82. };
  83. option (google.api.method_signature) = "name";
  84. }
  85. // Starts asynchronous cancellation on a long-running operation. The server
  86. // makes a best effort to cancel the operation, but success is not
  87. // guaranteed. If the server doesn't support this method, it returns
  88. // `google.rpc.Code.UNIMPLEMENTED`. Clients can use
  89. // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
  90. // other methods to check whether the cancellation succeeded or whether the
  91. // operation completed despite cancellation. On successful cancellation,
  92. // the operation is not deleted; instead, it becomes an operation with
  93. // an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
  94. // corresponding to `Code.CANCELLED`.
  95. rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) {
  96. option (google.api.http) = {
  97. post: "/v1/{name=operations/**}:cancel"
  98. body: "*"
  99. };
  100. option (google.api.method_signature) = "name";
  101. }
  102. // Waits until the specified long-running operation is done or reaches at most
  103. // a specified timeout, returning the latest state. If the operation is
  104. // already done, the latest state is immediately returned. If the timeout
  105. // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
  106. // timeout is used. If the server does not support this method, it returns
  107. // `google.rpc.Code.UNIMPLEMENTED`.
  108. // Note that this method is on a best-effort basis. It may return the latest
  109. // state before the specified timeout (including immediately), meaning even an
  110. // immediate response is no guarantee that the operation is done.
  111. rpc WaitOperation(WaitOperationRequest) returns (Operation) {
  112. }
  113. }
  114. // This resource represents a long-running operation that is the result of a
  115. // network API call.
  116. message Operation {
  117. // The server-assigned name, which is only unique within the same service that
  118. // originally returns it. If you use the default HTTP mapping, the
  119. // `name` should be a resource name ending with `operations/{unique_id}`.
  120. string name = 1;
  121. // Service-specific metadata associated with the operation. It typically
  122. // contains progress information and common metadata such as create time.
  123. // Some services might not provide such metadata. Any method that returns a
  124. // long-running operation should document the metadata type, if any.
  125. google.protobuf.Any metadata = 2;
  126. // If the value is `false`, it means the operation is still in progress.
  127. // If `true`, the operation is completed, and either `error` or `response` is
  128. // available.
  129. bool done = 3;
  130. // The operation result, which can be either an `error` or a valid `response`.
  131. // If `done` == `false`, neither `error` nor `response` is set.
  132. // If `done` == `true`, exactly one of `error` or `response` is set.
  133. oneof result {
  134. // The error result of the operation in case of failure or cancellation.
  135. google.rpc.Status error = 4;
  136. // The normal response of the operation in case of success. If the original
  137. // method returns no data on success, such as `Delete`, the response is
  138. // `google.protobuf.Empty`. If the original method is standard
  139. // `Get`/`Create`/`Update`, the response should be the resource. For other
  140. // methods, the response should have the type `XxxResponse`, where `Xxx`
  141. // is the original method name. For example, if the original method name
  142. // is `TakeSnapshot()`, the inferred response type is
  143. // `TakeSnapshotResponse`.
  144. google.protobuf.Any response = 5;
  145. }
  146. }
  147. // The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
  148. message GetOperationRequest {
  149. // The name of the operation resource.
  150. string name = 1;
  151. }
  152. // The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
  153. message ListOperationsRequest {
  154. // The name of the operation's parent resource.
  155. string name = 4;
  156. // The standard list filter.
  157. string filter = 1;
  158. // The standard list page size.
  159. int32 page_size = 2;
  160. // The standard list page token.
  161. string page_token = 3;
  162. }
  163. // The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
  164. message ListOperationsResponse {
  165. // A list of operations that matches the specified filter in the request.
  166. repeated Operation operations = 1;
  167. // The standard List next-page token.
  168. string next_page_token = 2;
  169. }
  170. // The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
  171. message CancelOperationRequest {
  172. // The name of the operation resource to be cancelled.
  173. string name = 1;
  174. }
  175. // The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
  176. message DeleteOperationRequest {
  177. // The name of the operation resource to be deleted.
  178. string name = 1;
  179. }
  180. // The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
  181. message WaitOperationRequest {
  182. // The name of the operation resource to wait on.
  183. string name = 1;
  184. // The maximum duration to wait before timing out. If left blank, the wait
  185. // will be at most the time permitted by the underlying HTTP/RPC protocol.
  186. // If RPC context deadline is also specified, the shorter one will be used.
  187. google.protobuf.Duration timeout = 2;
  188. }
  189. // A message representing the message types used by a long-running operation.
  190. //
  191. // Example:
  192. //
  193. // rpc LongRunningRecognize(LongRunningRecognizeRequest)
  194. // returns (google.longrunning.Operation) {
  195. // option (google.longrunning.operation_info) = {
  196. // response_type: "LongRunningRecognizeResponse"
  197. // metadata_type: "LongRunningRecognizeMetadata"
  198. // };
  199. // }
  200. message OperationInfo {
  201. // Required. The message name of the primary return type for this
  202. // long-running operation.
  203. // This type will be used to deserialize the LRO's response.
  204. //
  205. // If the response is in a different package from the rpc, a fully-qualified
  206. // message name must be used (e.g. `google.protobuf.Struct`).
  207. //
  208. // Note: Altering this value constitutes a breaking change.
  209. string response_type = 1;
  210. // Required. The message name of the metadata type for this long-running
  211. // operation.
  212. //
  213. // If the response is in a different package from the rpc, a fully-qualified
  214. // message name must be used (e.g. `google.protobuf.Struct`).
  215. //
  216. // Note: Altering this value constitutes a breaking change.
  217. string metadata_type = 2;
  218. }