google_cloud_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#[allow(clippy::derive_partial_eq_without_eq)]
5#[derive(Clone, PartialEq, ::prost::Message)]
6pub struct Operation {
7    /// The server-assigned name, which is only unique within the same service that
8    /// originally returns it. If you use the default HTTP mapping, the
9    /// `name` should be a resource name ending with `operations/{unique_id}`.
10    #[prost(string, tag = "1")]
11    pub name: ::prost::alloc::string::String,
12    /// Service-specific metadata associated with the operation.  It typically
13    /// contains progress information and common metadata such as create time.
14    /// Some services might not provide such metadata.  Any method that returns a
15    /// long-running operation should document the metadata type, if any.
16    #[prost(message, optional, tag = "2")]
17    pub metadata: ::core::option::Option<::prost_types::Any>,
18    /// If the value is `false`, it means the operation is still in progress.
19    /// If `true`, the operation is completed, and either `error` or `response` is
20    /// available.
21    #[prost(bool, tag = "3")]
22    pub done: bool,
23    /// The operation result, which can be either an `error` or a valid `response`.
24    /// If `done` == `false`, neither `error` nor `response` is set.
25    /// If `done` == `true`, exactly one of `error` or `response` is set.
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` is set.
34    #[allow(clippy::derive_partial_eq_without_eq)]
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 response of the operation in case of success.  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 [Operations.GetOperation][google.longrunning.Operations.GetOperation].
53#[allow(clippy::derive_partial_eq_without_eq)]
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 [Operations.ListOperations][google.longrunning.Operations.ListOperations].
61#[allow(clippy::derive_partial_eq_without_eq)]
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 [Operations.ListOperations][google.longrunning.Operations.ListOperations].
78#[allow(clippy::derive_partial_eq_without_eq)]
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 [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
89#[allow(clippy::derive_partial_eq_without_eq)]
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 [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
97#[allow(clippy::derive_partial_eq_without_eq)]
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 [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
105#[allow(clippy::derive_partial_eq_without_eq)]
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 LongRunningRecognize(LongRunningRecognizeRequest)
122///        returns (google.longrunning.Operation) {
123///      option (google.longrunning.operation_info) = {
124///        response_type: "LongRunningRecognizeResponse"
125///        metadata_type: "LongRunningRecognizeMetadata"
126///      };
127///    }
128#[allow(clippy::derive_partial_eq_without_eq)]
129#[derive(Clone, PartialEq, ::prost::Message)]
130pub struct OperationInfo {
131    /// Required. The message name of the primary return type for this
132    /// long-running operation.
133    /// This type will be used to deserialize the LRO's response.
134    ///
135    /// If the response is in a different package from the rpc, a fully-qualified
136    /// message name must be used (e.g. `google.protobuf.Struct`).
137    ///
138    /// Note: Altering this value constitutes a breaking change.
139    #[prost(string, tag = "1")]
140    pub response_type: ::prost::alloc::string::String,
141    /// Required. The message name of the metadata type for this long-running
142    /// operation.
143    ///
144    /// If the response is in a different package from the rpc, a fully-qualified
145    /// message name must be used (e.g. `google.protobuf.Struct`).
146    ///
147    /// Note: Altering this value constitutes a breaking change.
148    #[prost(string, tag = "2")]
149    pub metadata_type: ::prost::alloc::string::String,
150}
151/// Generated client implementations.
152pub mod operations_client {
153    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
154    use tonic::codegen::http::Uri;
155    use tonic::codegen::*;
156    /// Manages long-running operations with an API service.
157    ///
158    /// When an API method normally takes long time to complete, it can be designed
159    /// to return [Operation][google.longrunning.Operation] to the client, and the client can use this
160    /// interface to receive the real response asynchronously by polling the
161    /// operation resource, or pass the operation resource to another API (such as
162    /// Google Cloud Pub/Sub API) to receive the response.  Any API service that
163    /// returns long-running operations should implement the `Operations` interface
164    /// so developers can have a consistent client experience.
165    #[derive(Debug, Clone)]
166    pub struct OperationsClient<T> {
167        inner: tonic::client::Grpc<T>,
168    }
169    impl OperationsClient<tonic::transport::Channel> {
170        /// Attempt to create a new client by connecting to a given endpoint.
171        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
172        where
173            D: TryInto<tonic::transport::Endpoint>,
174            D::Error: Into<StdError>,
175        {
176            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
177            Ok(Self::new(conn))
178        }
179    }
180    impl<T> OperationsClient<T>
181    where
182        T: tonic::client::GrpcService<tonic::body::BoxBody>,
183        T::Error: Into<StdError>,
184        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
185        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
186    {
187        pub fn new(inner: T) -> Self {
188            let inner = tonic::client::Grpc::new(inner);
189            Self { inner }
190        }
191        pub fn with_origin(inner: T, origin: Uri) -> Self {
192            let inner = tonic::client::Grpc::with_origin(inner, origin);
193            Self { inner }
194        }
195        pub fn with_interceptor<F>(inner: T, interceptor: F) -> OperationsClient<InterceptedService<T, F>>
196        where
197            F: tonic::service::Interceptor,
198            T::ResponseBody: Default,
199            T: tonic::codegen::Service<
200                http::Request<tonic::body::BoxBody>,
201                Response = http::Response<<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody>,
202            >,
203            <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error: Into<StdError> + Send + Sync,
204        {
205            OperationsClient::new(InterceptedService::new(inner, interceptor))
206        }
207        /// Compress requests with the given encoding.
208        ///
209        /// This requires the server to support it otherwise it might respond with an
210        /// error.
211        #[must_use]
212        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
213            self.inner = self.inner.send_compressed(encoding);
214            self
215        }
216        /// Enable decompressing responses.
217        #[must_use]
218        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
219            self.inner = self.inner.accept_compressed(encoding);
220            self
221        }
222        /// Limits the maximum size of a decoded message.
223        ///
224        /// Default: `4MB`
225        #[must_use]
226        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
227            self.inner = self.inner.max_decoding_message_size(limit);
228            self
229        }
230        /// Limits the maximum size of an encoded message.
231        ///
232        /// Default: `usize::MAX`
233        #[must_use]
234        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
235            self.inner = self.inner.max_encoding_message_size(limit);
236            self
237        }
238        /// Lists operations that match the specified filter in the request. If the
239        /// server doesn't support this method, it returns `UNIMPLEMENTED`.
240        ///
241        /// NOTE: the `name` binding allows API services to override the binding
242        /// to use different resource name schemes, such as `users/*/operations`. To
243        /// override the binding, API services can add a binding such as
244        /// `"/v1/{name=users/*}/operations"` to their service configuration.
245        /// For backwards compatibility, the default name includes the operations
246        /// collection id, however overriding users must ensure the name binding
247        /// is the parent resource, without the operations collection id.
248        pub async fn list_operations(
249            &mut self,
250            request: impl tonic::IntoRequest<super::ListOperationsRequest>,
251        ) -> std::result::Result<tonic::Response<super::ListOperationsResponse>, tonic::Status> {
252            self.inner.ready().await.map_err(|e| {
253                tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
254            })?;
255            let codec = tonic::codec::ProstCodec::default();
256            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/ListOperations");
257            let mut req = request.into_request();
258            req.extensions_mut()
259                .insert(GrpcMethod::new("google.longrunning.Operations", "ListOperations"));
260            self.inner.unary(req, path, codec).await
261        }
262        /// Gets the latest state of a long-running operation.  Clients can use this
263        /// method to poll the operation result at intervals as recommended by the API
264        /// service.
265        pub async fn get_operation(
266            &mut self,
267            request: impl tonic::IntoRequest<super::GetOperationRequest>,
268        ) -> std::result::Result<tonic::Response<super::Operation>, tonic::Status> {
269            self.inner.ready().await.map_err(|e| {
270                tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
271            })?;
272            let codec = tonic::codec::ProstCodec::default();
273            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/GetOperation");
274            let mut req = request.into_request();
275            req.extensions_mut()
276                .insert(GrpcMethod::new("google.longrunning.Operations", "GetOperation"));
277            self.inner.unary(req, path, codec).await
278        }
279        /// Deletes a long-running operation. This method indicates that the client is
280        /// no longer interested in the operation result. It does not cancel the
281        /// operation. If the server doesn't support this method, it returns
282        /// `google.rpc.Code.UNIMPLEMENTED`.
283        pub async fn delete_operation(
284            &mut self,
285            request: impl tonic::IntoRequest<super::DeleteOperationRequest>,
286        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
287            self.inner.ready().await.map_err(|e| {
288                tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
289            })?;
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 [google.rpc.Status.code][google.rpc.Status.code] of 1,
306        /// corresponding to `Code.CANCELLED`.
307        pub async fn cancel_operation(
308            &mut self,
309            request: impl tonic::IntoRequest<super::CancelOperationRequest>,
310        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
311            self.inner.ready().await.map_err(|e| {
312                tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
313            })?;
314            let codec = tonic::codec::ProstCodec::default();
315            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/CancelOperation");
316            let mut req = request.into_request();
317            req.extensions_mut()
318                .insert(GrpcMethod::new("google.longrunning.Operations", "CancelOperation"));
319            self.inner.unary(req, path, codec).await
320        }
321        /// Waits until the specified long-running operation is done or reaches at most
322        /// a specified timeout, returning the latest state.  If the operation is
323        /// already done, the latest state is immediately returned.  If the timeout
324        /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
325        /// timeout is used.  If the server does not support this method, it returns
326        /// `google.rpc.Code.UNIMPLEMENTED`.
327        /// Note that this method is on a best-effort basis.  It may return the latest
328        /// state before the specified timeout (including immediately), meaning even an
329        /// immediate response is no guarantee that the operation is done.
330        pub async fn wait_operation(
331            &mut self,
332            request: impl tonic::IntoRequest<super::WaitOperationRequest>,
333        ) -> std::result::Result<tonic::Response<super::Operation>, tonic::Status> {
334            self.inner.ready().await.map_err(|e| {
335                tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
336            })?;
337            let codec = tonic::codec::ProstCodec::default();
338            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/WaitOperation");
339            let mut req = request.into_request();
340            req.extensions_mut()
341                .insert(GrpcMethod::new("google.longrunning.Operations", "WaitOperation"));
342            self.inner.unary(req, path, codec).await
343        }
344    }
345}