1// Copyright 2016 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// https://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 15syntax = "proto3"; 16 17 18package google.longrunning; 19 20import "google/protobuf/any.proto"; 21import "google/protobuf/descriptor.proto"; 22import "google/protobuf/duration.proto"; 23import "google/protobuf/empty.proto"; 24 25option go_package = "go.chromium.org/chromiumos/config/go/api/test/tls/dependencies/longrunning"; 26 27 28// Manages long-running operations with an API service. 29// 30// When an API method normally takes long time to complete, it can be designed 31// to return [Operation][google.longrunning.Operation] to the client, and the client can use this 32// interface to receive the real response asynchronously by polling the 33// operation resource, or pass the operation resource to another API (such as 34// Google Cloud Pub/Sub API) to receive the response. Any API service that 35// returns long-running operations should implement the `Operations` interface 36// so developers can have a consistent client experience. 37service Operations { 38 // Lists operations that match the specified filter in the request. If the 39 // server doesn't support this method, it returns `UNIMPLEMENTED`. 40 // 41 // NOTE: the `name` binding below allows API services to override the binding 42 // to use different resource name schemes, such as `users/*/operations`. 43 rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) { 44 } 45 46 // Gets the latest state of a long-running operation. Clients can use this 47 // method to poll the operation result at intervals as recommended by the API 48 // service. 49 rpc GetOperation(GetOperationRequest) returns (Operation) { 50 } 51 52 // Deletes a long-running operation. This method indicates that the client is 53 // no longer interested in the operation result. It does not cancel the 54 // operation. If the server doesn't support this method, it returns 55 // `google.rpc.Code.UNIMPLEMENTED`. 56 rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) { 57 } 58 59 // Starts asynchronous cancellation on a long-running operation. The server 60 // makes a best effort to cancel the operation, but success is not 61 // guaranteed. If the server doesn't support this method, it returns 62 // `google.rpc.Code.UNIMPLEMENTED`. Clients can use 63 // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 64 // other methods to check whether the cancellation succeeded or whether the 65 // operation completed despite cancellation. On successful cancellation, 66 // the operation is not deleted; instead, it becomes an operation with 67 // an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, 68 // corresponding to `Code.CANCELLED`. 69 rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) { 70 } 71 // Waits for the specified long-running operation until it is done or reaches 72 // at most a specified timeout, returning the latest state. If the operation 73 // is already done, the latest state is immediately returned. If the timeout 74 // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 75 // timeout is used. If the server does not support this method, it returns 76 // `google.rpc.Code.UNIMPLEMENTED`. 77 // Note that this method is on a best-effort basis. It may return the latest 78 // state before the specified timeout (including immediately), meaning even an 79 // immediate response is no guarantee that the operation is done. 80 rpc WaitOperation(WaitOperationRequest) returns (Operation) { 81 } 82} 83 84// This resource represents a long-running operation that is the result of a 85// network API call. 86message Operation { 87 // The server-assigned name, which is only unique within the same service that 88 // originally returns it. If you use the default HTTP mapping, the 89 // `name` should have the format of `operations/some/unique/name`. 90 string name = 1; 91 92 // Service-specific metadata associated with the operation. It typically 93 // contains progress information and common metadata such as create time. 94 // Some services might not provide such metadata. Any method that returns a 95 // long-running operation should document the metadata type, if any. 96 google.protobuf.Any metadata = 2; 97 98 // If the value is `false`, it means the operation is still in progress. 99 // If true, the operation is completed, and either `error` or `response` is 100 // available. 101 bool done = 3; 102 103 // The operation result, which can be either an `error` or a valid `response`. 104 // If `done` == `false`, neither `error` nor `response` is set. 105 // If `done` == `true`, exactly one of `error` or `response` is set. 106 oneof result { 107 // The error result of the operation in case of failure or cancellation. 108 Status error = 4; 109 110 // The normal response of the operation in case of success. If the original 111 // method returns no data on success, such as `Delete`, the response is 112 // `google.protobuf.Empty`. If the original method is standard 113 // `Get`/`Create`/`Update`, the response should be the resource. For other 114 // methods, the response should have the type `XxxResponse`, where `Xxx` 115 // is the original method name. For example, if the original method name 116 // is `TakeSnapshot()`, the inferred response type is 117 // `TakeSnapshotResponse`. 118 google.protobuf.Any response = 5; 119 } 120} 121 122// The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation]. 123message GetOperationRequest { 124 // The name of the operation resource. 125 string name = 1; 126} 127 128// The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. 129message ListOperationsRequest { 130 // The name of the operation collection. 131 string name = 4; 132 133 // The standard list filter. 134 string filter = 1; 135 136 // The standard list page size. 137 int32 page_size = 2; 138 139 // The standard list page token. 140 string page_token = 3; 141} 142 143// The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. 144message ListOperationsResponse { 145 // A list of operations that matches the specified filter in the request. 146 repeated Operation operations = 1; 147 148 // The standard List next-page token. 149 string next_page_token = 2; 150} 151 152// The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. 153message CancelOperationRequest { 154 // The name of the operation resource to be cancelled. 155 string name = 1; 156} 157 158// The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. 159message DeleteOperationRequest { 160 // The name of the operation resource to be deleted. 161 string name = 1; 162} 163 164// The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. 165message WaitOperationRequest { 166 // The name of the operation resource to wait on. 167 string name = 1; 168 169 // The maximum duration to wait before timing out. If left blank, the wait 170 // will be at most the time permitted by the underlying HTTP/RPC protocol. 171 // If RPC context deadline is also specified, the shorter one will be used. 172 google.protobuf.Duration timeout = 2; 173} 174 175// A message representing the message types used by a long-running operation. 176// 177// Example: 178// 179// rpc LongRunningRecognize(LongRunningRecognizeRequest) 180// returns (google.longrunning.Operation) { 181// option (google.longrunning.operation_info) = { 182// response_type: "LongRunningRecognizeResponse" 183// metadata_type: "LongRunningRecognizeMetadata" 184// }; 185// } 186message OperationInfo { 187 // Required. The message name of the primary return type for this 188 // long-running operation. 189 // This type will be used to deserialize the LRO's response. 190 // 191 // If the response is in a different package from the rpc, a fully-qualified 192 // message name must be used (e.g. `google.protobuf.Struct`). 193 // 194 // Note: Altering this value constitutes a breaking change. 195 string response_type = 1; 196 197 // Required. The message name of the metadata type for this long-running 198 // operation. 199 // 200 // If the response is in a different package from the rpc, a fully-qualified 201 // message name must be used (e.g. `google.protobuf.Struct`). 202 // 203 // Note: Altering this value constitutes a breaking change. 204 string metadata_type = 2; 205} 206 207extend google.protobuf.MethodOptions { 208 // Additional information regarding long-running operations. 209 // In particular, this specifies the types that are returned from 210 // long-running operations. 211 // 212 // Required for methods that return `google.longrunning.Operation`; invalid 213 // otherwise. 214 OperationInfo operation_info = 1049; 215} 216 217// The `Status` type defines a logical error model that is suitable for different 218// programming environments, including REST APIs and RPC APIs. It is used by 219// [gRPC](https://github.com/grpc). The error model is designed to be: 220// 221// - Simple to use and understand for most users 222// - Flexible enough to meet unexpected needs 223// 224// # Overview 225// 226// The `Status` message contains three pieces of data: error code, error message, 227// and error details. The error code should be an enum value of 228// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The 229// error message should be a developer-facing English message that helps 230// developers *understand* and *resolve* the error. If a localized user-facing 231// error message is needed, put the localized message in the error details or 232// localize it in the client. The optional error details may contain arbitrary 233// information about the error. There is a predefined set of error detail types 234// in the package `google.rpc` that can be used for common error conditions. 235// 236// # Language mapping 237// 238// The `Status` message is the logical representation of the error model, but it 239// is not necessarily the actual wire format. When the `Status` message is 240// exposed in different client libraries and different wire protocols, it can be 241// mapped differently. For example, it will likely be mapped to some exceptions 242// in Java, but more likely mapped to some error codes in C. 243// 244// # Other uses 245// 246// The error model and the `Status` message can be used in a variety of 247// environments, either with or without APIs, to provide a 248// consistent developer experience across different environments. 249// 250// Example uses of this error model include: 251// 252// - Partial errors. If a service needs to return partial errors to the client, 253// it may embed the `Status` in the normal response to indicate the partial 254// errors. 255// 256// - Workflow errors. A typical workflow has multiple steps. Each step may 257// have a `Status` message for error reporting. 258// 259// - Batch operations. If a client uses batch request and batch response, the 260// `Status` message should be used directly inside batch response, one for 261// each error sub-response. 262// 263// - Asynchronous operations. If an API call embeds asynchronous operation 264// results in its response, the status of those operations should be 265// represented directly using the `Status` message. 266// 267// - Logging. If some API errors are stored in logs, the message `Status` could 268// be used directly after any stripping needed for security/privacy reasons. 269message Status { 270 // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. 271 int32 code = 1; 272 273 // A developer-facing error message, which should be in English. Any 274 // user-facing error message should be localized and sent in the 275 // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. 276 string message = 2; 277 278 // A list of messages that carry the error details. There is a common set of 279 // message types for APIs to use. 280 repeated google.protobuf.Any details = 3; 281} 282