operations.proto 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright (c) 2015, Google Inc.
  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/protobuf/any.proto";
  18. import "google/protobuf/empty.proto";
  19. import "google/rpc/status.proto";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "OperationsProto";
  22. option java_package = "com.google.longrunning";
  23. // Manages long-running operations with an API service.
  24. //
  25. // When an API method normally takes long time to complete, it can be designed
  26. // to return [Operation][google.longrunning.Operation] to the client, and the client can use this
  27. // interface to receive the real response asynchronously by polling the
  28. // operation resource, or using `google.watcher.v1.Watcher` interface to watch
  29. // the response, or pass the operation resource to another API (such as Google
  30. // Cloud Pub/Sub API) to receive the response. Any API service that returns
  31. // long-running operations should implement the `Operations` interface so
  32. // developers can have a consistent client experience.
  33. service Operations {
  34. // Gets the latest state of a long-running operation. Clients may use this
  35. // method to poll the operation result at intervals as recommended by the API
  36. // service.
  37. rpc GetOperation(GetOperationRequest) returns (Operation) {
  38. //option (google.api.http) = { get: "/v1/{name=operations/**}" };
  39. }
  40. // Lists operations that match the specified filter in the request. If the
  41. // server doesn't support this method, it returns
  42. // `google.rpc.Code.UNIMPLEMENTED`.
  43. rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) {
  44. //option (google.api.http) = { get: "/v1/{name=operations}" };
  45. }
  46. // Starts asynchronous cancellation on a long-running operation. The server
  47. // makes a best effort to cancel the operation, but success is not
  48. // guaranteed. If the server doesn't support this method, it returns
  49. // `google.rpc.Code.UNIMPLEMENTED`. Clients may use
  50. // [Operations.GetOperation] or other methods to check whether the
  51. // cancellation succeeded or the operation completed despite cancellation.
  52. rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) {
  53. //option (google.api.http) = { post: "/v1/{name=operations/**}:cancel" body: "*" };
  54. }
  55. // Deletes a long-running operation. It indicates the client is no longer
  56. // interested in the operation result. It does not cancel the operation.
  57. rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) {
  58. //option (google.api.http) = { delete: "/v1/{name=operations/**}" };
  59. }
  60. }
  61. // This resource represents a long-running operation that is the result of a
  62. // network API call.
  63. message Operation {
  64. // The name of the operation resource, which is only unique within the same
  65. // service that originally returns it.
  66. string name = 1;
  67. // Some service-specific metadata associated with the operation. It typically
  68. // contains progress information and common metadata such as create time.
  69. // Some services may not provide such metadata. Any method that returns a
  70. // long-running operation should document the metadata type, if any.
  71. google.protobuf.Any metadata = 2;
  72. // If the value is false, it means the operation is still in progress.
  73. // If true, the operation is completed and the `result` is available.
  74. bool done = 3;
  75. oneof result {
  76. // The error result of the operation in case of failure.
  77. google.rpc.Status error = 4;
  78. // The normal response of the operation in case of success. If the original
  79. // method returns no data on success, such as `Delete`, the response will be
  80. // `google.protobuf.Empty`. If the original method is standard
  81. // `Get`/`Create`/`Update`, the response should be the resource. For other
  82. // methods, the response should have the type `XxxResponse`, where `Xxx`
  83. // is the original method name. For example, if the original method name
  84. // is `TakeSnapshot()`, the inferred response type will be
  85. // `TakeSnapshotResponse`.
  86. google.protobuf.Any response = 5;
  87. }
  88. }
  89. // The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
  90. message GetOperationRequest {
  91. // The name of the operation resource.
  92. string name = 1;
  93. }
  94. // The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
  95. message ListOperationsRequest {
  96. // The name of the operation collection.
  97. string name = 4;
  98. // The standard List filter.
  99. string filter = 1;
  100. // The standard List page size.
  101. int32 page_size = 2;
  102. // The standard List page token.
  103. string page_token = 3;
  104. }
  105. // The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
  106. message ListOperationsResponse {
  107. // A list of operations that match the specified filter in the request.
  108. repeated Operation operations = 1;
  109. // The standard List next-page token.
  110. string next_page_token = 2;
  111. }
  112. // The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
  113. message CancelOperationRequest {
  114. // The name of the operation resource to be cancelled.
  115. string name = 1;
  116. }
  117. // The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
  118. message DeleteOperationRequest {
  119. // The name of the operation resource to be deleted.
  120. string name = 1;
  121. }