gcloud_googleapis/google.longrunning.rs
1// This file is @generated by prost-build.
2/// This resource represents a long-running operation that is the result of a
3/// network API call.
4#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct Operation {
6 /// The server-assigned name, which is only unique within the same service that
7 /// originally returns it. If you use the default HTTP mapping, the
8 /// `name` should be a resource name ending with `operations/{unique_id}`.
9 #[prost(string, tag = "1")]
10 pub name: ::prost::alloc::string::String,
11 /// Service-specific metadata associated with the operation. It typically
12 /// contains progress information and common metadata such as create time.
13 /// Some services might not provide such metadata. Any method that returns a
14 /// long-running operation should document the metadata type, if any.
15 #[prost(message, optional, tag = "2")]
16 pub metadata: ::core::option::Option<::prost_types::Any>,
17 /// If the value is `false`, it means the operation is still in progress.
18 /// If `true`, the operation is completed, and either `error` or `response` is
19 /// available.
20 #[prost(bool, tag = "3")]
21 pub done: bool,
22 /// The operation result, which can be either an `error` or a valid `response`.
23 /// If `done` == `false`, neither `error` nor `response` is set.
24 /// If `done` == `true`, exactly one of `error` or `response` can be set.
25 /// Some services might not provide the result.
26 #[prost(oneof = "operation::Result", tags = "4, 5")]
27 pub result: ::core::option::Option<operation::Result>,
28}
29/// Nested message and enum types in `Operation`.
30pub mod operation {
31 /// The operation result, which can be either an `error` or a valid `response`.
32 /// If `done` == `false`, neither `error` nor `response` is set.
33 /// If `done` == `true`, exactly one of `error` or `response` can be set.
34 /// Some services might not provide the result.
35 #[derive(Clone, PartialEq, ::prost::Oneof)]
36 pub enum Result {
37 /// The error result of the operation in case of failure or cancellation.
38 #[prost(message, tag = "4")]
39 Error(super::super::rpc::Status),
40 /// The normal, successful response of the operation. If the original
41 /// method returns no data on success, such as `Delete`, the response is
42 /// `google.protobuf.Empty`. If the original method is standard
43 /// `Get`/`Create`/`Update`, the response should be the resource. For other
44 /// methods, the response should have the type `XxxResponse`, where `Xxx`
45 /// is the original method name. For example, if the original method name
46 /// is `TakeSnapshot()`, the inferred response type is
47 /// `TakeSnapshotResponse`.
48 #[prost(message, tag = "5")]
49 Response(::prost_types::Any),
50 }
51}
52/// The request message for
53/// [Operations.GetOperation][google.longrunning.Operations.GetOperation].
54#[derive(Clone, PartialEq, ::prost::Message)]
55pub struct GetOperationRequest {
56 /// The name of the operation resource.
57 #[prost(string, tag = "1")]
58 pub name: ::prost::alloc::string::String,
59}
60/// The request message for
61/// [Operations.ListOperations][google.longrunning.Operations.ListOperations].
62#[derive(Clone, PartialEq, ::prost::Message)]
63pub struct ListOperationsRequest {
64 /// The name of the operation's parent resource.
65 #[prost(string, tag = "4")]
66 pub name: ::prost::alloc::string::String,
67 /// The standard list filter.
68 #[prost(string, tag = "1")]
69 pub filter: ::prost::alloc::string::String,
70 /// The standard list page size.
71 #[prost(int32, tag = "2")]
72 pub page_size: i32,
73 /// The standard list page token.
74 #[prost(string, tag = "3")]
75 pub page_token: ::prost::alloc::string::String,
76}
77/// The response message for
78/// [Operations.ListOperations][google.longrunning.Operations.ListOperations].
79#[derive(Clone, PartialEq, ::prost::Message)]
80pub struct ListOperationsResponse {
81 /// A list of operations that matches the specified filter in the request.
82 #[prost(message, repeated, tag = "1")]
83 pub operations: ::prost::alloc::vec::Vec<Operation>,
84 /// The standard List next-page token.
85 #[prost(string, tag = "2")]
86 pub next_page_token: ::prost::alloc::string::String,
87}
88/// The request message for
89/// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
90#[derive(Clone, PartialEq, ::prost::Message)]
91pub struct CancelOperationRequest {
92 /// The name of the operation resource to be cancelled.
93 #[prost(string, tag = "1")]
94 pub name: ::prost::alloc::string::String,
95}
96/// The request message for
97/// [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
98#[derive(Clone, PartialEq, ::prost::Message)]
99pub struct DeleteOperationRequest {
100 /// The name of the operation resource to be deleted.
101 #[prost(string, tag = "1")]
102 pub name: ::prost::alloc::string::String,
103}
104/// The request message for
105/// [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
106#[derive(Clone, PartialEq, ::prost::Message)]
107pub struct WaitOperationRequest {
108 /// The name of the operation resource to wait on.
109 #[prost(string, tag = "1")]
110 pub name: ::prost::alloc::string::String,
111 /// The maximum duration to wait before timing out. If left blank, the wait
112 /// will be at most the time permitted by the underlying HTTP/RPC protocol.
113 /// If RPC context deadline is also specified, the shorter one will be used.
114 #[prost(message, optional, tag = "2")]
115 pub timeout: ::core::option::Option<::prost_types::Duration>,
116}
117/// A message representing the message types used by a long-running operation.
118///
119/// Example:
120///
121/// rpc Export(ExportRequest) returns (google.longrunning.Operation) {
122/// option (google.longrunning.operation_info) = {
123/// response_type: "ExportResponse"
124/// metadata_type: "ExportMetadata"
125/// };
126/// }
127#[derive(Clone, PartialEq, ::prost::Message)]
128pub struct OperationInfo {
129 /// Required. The message name of the primary return type for this
130 /// long-running operation.
131 /// This type will be used to deserialize the LRO's response.
132 ///
133 /// If the response is in a different package from the rpc, a fully-qualified
134 /// message name must be used (e.g. `google.protobuf.Struct`).
135 ///
136 /// Note: Altering this value constitutes a breaking change.
137 #[prost(string, tag = "1")]
138 pub response_type: ::prost::alloc::string::String,
139 /// Required. The message name of the metadata type for this long-running
140 /// operation.
141 ///
142 /// If the response is in a different package from the rpc, a fully-qualified
143 /// message name must be used (e.g. `google.protobuf.Struct`).
144 ///
145 /// Note: Altering this value constitutes a breaking change.
146 #[prost(string, tag = "2")]
147 pub metadata_type: ::prost::alloc::string::String,
148}
149/// Generated client implementations.
150pub mod operations_client {
151 #![allow(
152 unused_variables,
153 dead_code,
154 missing_docs,
155 clippy::wildcard_imports,
156 clippy::let_unit_value
157 )]
158 use tonic::codegen::http::Uri;
159 use tonic::codegen::*;
160 /// Manages long-running operations with an API service.
161 ///
162 /// When an API method normally takes long time to complete, it can be designed
163 /// to return [Operation][google.longrunning.Operation] to the client, and the
164 /// client can use this interface to receive the real response asynchronously by
165 /// polling the operation resource, or pass the operation resource to another API
166 /// (such as Pub/Sub API) to receive the response. Any API service that returns
167 /// long-running operations should implement the `Operations` interface so
168 /// developers can have a consistent client experience.
169 #[derive(Debug, Clone)]
170 pub struct OperationsClient<T> {
171 inner: tonic::client::Grpc<T>,
172 }
173 impl OperationsClient<tonic::transport::Channel> {
174 /// Attempt to create a new client by connecting to a given endpoint.
175 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
176 where
177 D: TryInto<tonic::transport::Endpoint>,
178 D::Error: Into<StdError>,
179 {
180 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
181 Ok(Self::new(conn))
182 }
183 }
184 impl<T> OperationsClient<T>
185 where
186 T: tonic::client::GrpcService<tonic::body::Body>,
187 T::Error: Into<StdError>,
188 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
189 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
190 {
191 pub fn new(inner: T) -> Self {
192 let inner = tonic::client::Grpc::new(inner);
193 Self { inner }
194 }
195 pub fn with_origin(inner: T, origin: Uri) -> Self {
196 let inner = tonic::client::Grpc::with_origin(inner, origin);
197 Self { inner }
198 }
199 pub fn with_interceptor<F>(inner: T, interceptor: F) -> OperationsClient<InterceptedService<T, F>>
200 where
201 F: tonic::service::Interceptor,
202 T::ResponseBody: Default,
203 T: tonic::codegen::Service<
204 http::Request<tonic::body::Body>,
205 Response = http::Response<<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody>,
206 >,
207 <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
208 Into<StdError> + std::marker::Send + std::marker::Sync,
209 {
210 OperationsClient::new(InterceptedService::new(inner, interceptor))
211 }
212 /// Compress requests with the given encoding.
213 ///
214 /// This requires the server to support it otherwise it might respond with an
215 /// error.
216 #[must_use]
217 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
218 self.inner = self.inner.send_compressed(encoding);
219 self
220 }
221 /// Enable decompressing responses.
222 #[must_use]
223 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
224 self.inner = self.inner.accept_compressed(encoding);
225 self
226 }
227 /// Limits the maximum size of a decoded message.
228 ///
229 /// Default: `4MB`
230 #[must_use]
231 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
232 self.inner = self.inner.max_decoding_message_size(limit);
233 self
234 }
235 /// Limits the maximum size of an encoded message.
236 ///
237 /// Default: `usize::MAX`
238 #[must_use]
239 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
240 self.inner = self.inner.max_encoding_message_size(limit);
241 self
242 }
243 /// Lists operations that match the specified filter in the request. If the
244 /// server doesn't support this method, it returns `UNIMPLEMENTED`.
245 pub async fn list_operations(
246 &mut self,
247 request: impl tonic::IntoRequest<super::ListOperationsRequest>,
248 ) -> std::result::Result<tonic::Response<super::ListOperationsResponse>, tonic::Status> {
249 self.inner
250 .ready()
251 .await
252 .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
253 let codec = tonic::codec::ProstCodec::default();
254 let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/ListOperations");
255 let mut req = request.into_request();
256 req.extensions_mut()
257 .insert(GrpcMethod::new("google.longrunning.Operations", "ListOperations"));
258 self.inner.unary(req, path, codec).await
259 }
260 /// Gets the latest state of a long-running operation. Clients can use this
261 /// method to poll the operation result at intervals as recommended by the API
262 /// service.
263 pub async fn get_operation(
264 &mut self,
265 request: impl tonic::IntoRequest<super::GetOperationRequest>,
266 ) -> std::result::Result<tonic::Response<super::Operation>, tonic::Status> {
267 self.inner
268 .ready()
269 .await
270 .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
271 let codec = tonic::codec::ProstCodec::default();
272 let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/GetOperation");
273 let mut req = request.into_request();
274 req.extensions_mut()
275 .insert(GrpcMethod::new("google.longrunning.Operations", "GetOperation"));
276 self.inner.unary(req, path, codec).await
277 }
278 /// Deletes a long-running operation. This method indicates that the client is
279 /// no longer interested in the operation result. It does not cancel the
280 /// operation. If the server doesn't support this method, it returns
281 /// `google.rpc.Code.UNIMPLEMENTED`.
282 pub async fn delete_operation(
283 &mut self,
284 request: impl tonic::IntoRequest<super::DeleteOperationRequest>,
285 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
286 self.inner
287 .ready()
288 .await
289 .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
290 let codec = tonic::codec::ProstCodec::default();
291 let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/DeleteOperation");
292 let mut req = request.into_request();
293 req.extensions_mut()
294 .insert(GrpcMethod::new("google.longrunning.Operations", "DeleteOperation"));
295 self.inner.unary(req, path, codec).await
296 }
297 /// Starts asynchronous cancellation on a long-running operation. The server
298 /// makes a best effort to cancel the operation, but success is not
299 /// guaranteed. If the server doesn't support this method, it returns
300 /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use
301 /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
302 /// other methods to check whether the cancellation succeeded or whether the
303 /// operation completed despite cancellation. On successful cancellation,
304 /// the operation is not deleted; instead, it becomes an operation with
305 /// an [Operation.error][google.longrunning.Operation.error] value with a
306 /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to
307 /// `Code.CANCELLED`.
308 pub async fn cancel_operation(
309 &mut self,
310 request: impl tonic::IntoRequest<super::CancelOperationRequest>,
311 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
312 self.inner
313 .ready()
314 .await
315 .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
316 let codec = tonic::codec::ProstCodec::default();
317 let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/CancelOperation");
318 let mut req = request.into_request();
319 req.extensions_mut()
320 .insert(GrpcMethod::new("google.longrunning.Operations", "CancelOperation"));
321 self.inner.unary(req, path, codec).await
322 }
323 /// Waits until the specified long-running operation is done or reaches at most
324 /// a specified timeout, returning the latest state. If the operation is
325 /// already done, the latest state is immediately returned. If the timeout
326 /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
327 /// timeout is used. If the server does not support this method, it returns
328 /// `google.rpc.Code.UNIMPLEMENTED`.
329 /// Note that this method is on a best-effort basis. It may return the latest
330 /// state before the specified timeout (including immediately), meaning even an
331 /// immediate response is no guarantee that the operation is done.
332 pub async fn wait_operation(
333 &mut self,
334 request: impl tonic::IntoRequest<super::WaitOperationRequest>,
335 ) -> std::result::Result<tonic::Response<super::Operation>, tonic::Status> {
336 self.inner
337 .ready()
338 .await
339 .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
340 let codec = tonic::codec::ProstCodec::default();
341 let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/WaitOperation");
342 let mut req = request.into_request();
343 req.extensions_mut()
344 .insert(GrpcMethod::new("google.longrunning.Operations", "WaitOperation"));
345 self.inner.unary(req, path, codec).await
346 }
347 }
348}