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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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/// ```text
122/// rpc Export(ExportRequest) returns (google.longrunning.Operation) {
123///    option (google.longrunning.operation_info) = {
124///      response_type: "ExportResponse"
125///      metadata_type: "ExportMetadata"
126///    };
127/// }
128/// ```
129#[derive(Clone, PartialEq, Eq, Hash, ::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(
154        unused_variables,
155        dead_code,
156        missing_docs,
157        clippy::wildcard_imports,
158        clippy::let_unit_value
159    )]
160    use tonic::codegen::http::Uri;
161    use tonic::codegen::*;
162    /// Manages long-running operations with an API service.
163    ///
164    /// When an API method normally takes long time to complete, it can be designed
165    /// to return \[Operation\]\[google.longrunning.Operation\] to the client, and the
166    /// client can use this interface to receive the real response asynchronously by
167    /// polling the operation resource, or pass the operation resource to another API
168    /// (such as Pub/Sub API) to receive the response.  Any API service that returns
169    /// long-running operations should implement the `Operations` interface so
170    /// developers can have a consistent client experience.
171    #[derive(Debug, Clone)]
172    pub struct OperationsClient<T> {
173        inner: tonic::client::Grpc<T>,
174    }
175    impl OperationsClient<tonic::transport::Channel> {
176        /// Attempt to create a new client by connecting to a given endpoint.
177        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
178        where
179            D: TryInto<tonic::transport::Endpoint>,
180            D::Error: Into<StdError>,
181        {
182            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
183            Ok(Self::new(conn))
184        }
185    }
186    impl<T> OperationsClient<T>
187    where
188        T: tonic::client::GrpcService<tonic::body::Body>,
189        T::Error: Into<StdError>,
190        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
191        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
192    {
193        pub fn new(inner: T) -> Self {
194            let inner = tonic::client::Grpc::new(inner);
195            Self { inner }
196        }
197        pub fn with_origin(inner: T, origin: Uri) -> Self {
198            let inner = tonic::client::Grpc::with_origin(inner, origin);
199            Self { inner }
200        }
201        pub fn with_interceptor<F>(inner: T, interceptor: F) -> OperationsClient<InterceptedService<T, F>>
202        where
203            F: tonic::service::Interceptor,
204            T::ResponseBody: Default,
205            T: tonic::codegen::Service<
206                http::Request<tonic::body::Body>,
207                Response = http::Response<<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody>,
208            >,
209            <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
210                Into<StdError> + std::marker::Send + std::marker::Sync,
211        {
212            OperationsClient::new(InterceptedService::new(inner, interceptor))
213        }
214        /// Compress requests with the given encoding.
215        ///
216        /// This requires the server to support it otherwise it might respond with an
217        /// error.
218        #[must_use]
219        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
220            self.inner = self.inner.send_compressed(encoding);
221            self
222        }
223        /// Enable decompressing responses.
224        #[must_use]
225        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
226            self.inner = self.inner.accept_compressed(encoding);
227            self
228        }
229        /// Limits the maximum size of a decoded message.
230        ///
231        /// Default: `4MB`
232        #[must_use]
233        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
234            self.inner = self.inner.max_decoding_message_size(limit);
235            self
236        }
237        /// Limits the maximum size of an encoded message.
238        ///
239        /// Default: `usize::MAX`
240        #[must_use]
241        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
242            self.inner = self.inner.max_encoding_message_size(limit);
243            self
244        }
245        /// Lists operations that match the specified filter in the request. If the
246        /// server doesn't support this method, it returns `UNIMPLEMENTED`.
247        pub async fn list_operations(
248            &mut self,
249            request: impl tonic::IntoRequest<super::ListOperationsRequest>,
250        ) -> std::result::Result<tonic::Response<super::ListOperationsResponse>, tonic::Status> {
251            self.inner
252                .ready()
253                .await
254                .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
255            let codec = tonic_prost::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
270                .ready()
271                .await
272                .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
273            let codec = tonic_prost::ProstCodec::default();
274            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/GetOperation");
275            let mut req = request.into_request();
276            req.extensions_mut()
277                .insert(GrpcMethod::new("google.longrunning.Operations", "GetOperation"));
278            self.inner.unary(req, path, codec).await
279        }
280        /// Deletes a long-running operation. This method indicates that the client is
281        /// no longer interested in the operation result. It does not cancel the
282        /// operation. If the server doesn't support this method, it returns
283        /// `google.rpc.Code.UNIMPLEMENTED`.
284        pub async fn delete_operation(
285            &mut self,
286            request: impl tonic::IntoRequest<super::DeleteOperationRequest>,
287        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
288            self.inner
289                .ready()
290                .await
291                .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
292            let codec = tonic_prost::ProstCodec::default();
293            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/DeleteOperation");
294            let mut req = request.into_request();
295            req.extensions_mut()
296                .insert(GrpcMethod::new("google.longrunning.Operations", "DeleteOperation"));
297            self.inner.unary(req, path, codec).await
298        }
299        /// Starts asynchronous cancellation on a long-running operation.  The server
300        /// makes a best effort to cancel the operation, but success is not
301        /// guaranteed.  If the server doesn't support this method, it returns
302        /// `google.rpc.Code.UNIMPLEMENTED`.  Clients can use
303        /// \[Operations.GetOperation\]\[google.longrunning.Operations.GetOperation\] or
304        /// other methods to check whether the cancellation succeeded or whether the
305        /// operation completed despite cancellation. On successful cancellation,
306        /// the operation is not deleted; instead, it becomes an operation with
307        /// an \[Operation.error\]\[google.longrunning.Operation.error\] value with a
308        /// \[google.rpc.Status.code\]\[google.rpc.Status.code\] of `1`, corresponding to
309        /// `Code.CANCELLED`.
310        pub async fn cancel_operation(
311            &mut self,
312            request: impl tonic::IntoRequest<super::CancelOperationRequest>,
313        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
314            self.inner
315                .ready()
316                .await
317                .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
318            let codec = tonic_prost::ProstCodec::default();
319            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/CancelOperation");
320            let mut req = request.into_request();
321            req.extensions_mut()
322                .insert(GrpcMethod::new("google.longrunning.Operations", "CancelOperation"));
323            self.inner.unary(req, path, codec).await
324        }
325        /// Waits until the specified long-running operation is done or reaches at most
326        /// a specified timeout, returning the latest state.  If the operation is
327        /// already done, the latest state is immediately returned.  If the timeout
328        /// specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
329        /// timeout is used.  If the server does not support this method, it returns
330        /// `google.rpc.Code.UNIMPLEMENTED`.
331        /// Note that this method is on a best-effort basis.  It may return the latest
332        /// state before the specified timeout (including immediately), meaning even an
333        /// immediate response is no guarantee that the operation is done.
334        pub async fn wait_operation(
335            &mut self,
336            request: impl tonic::IntoRequest<super::WaitOperationRequest>,
337        ) -> std::result::Result<tonic::Response<super::Operation>, tonic::Status> {
338            self.inner
339                .ready()
340                .await
341                .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?;
342            let codec = tonic_prost::ProstCodec::default();
343            let path = http::uri::PathAndQuery::from_static("/google.longrunning.Operations/WaitOperation");
344            let mut req = request.into_request();
345            req.extensions_mut()
346                .insert(GrpcMethod::new("google.longrunning.Operations", "WaitOperation"));
347            self.inner.unary(req, path, codec).await
348        }
349    }
350}