google_cloud_longrunning/
model.rs

1// Copyright 2024 Google LLC
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//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate rpc;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// This resource represents a long-running operation that is the result of a
39/// network API call.
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct Operation {
43    /// The server-assigned name, which is only unique within the same service that
44    /// originally returns it. If you use the default HTTP mapping, the
45    /// `name` should be a resource name ending with `operations/{unique_id}`.
46    pub name: std::string::String,
47
48    /// Service-specific metadata associated with the operation.  It typically
49    /// contains progress information and common metadata such as create time.
50    /// Some services might not provide such metadata.  Any method that returns a
51    /// long-running operation should document the metadata type, if any.
52    pub metadata: std::option::Option<wkt::Any>,
53
54    /// If the value is `false`, it means the operation is still in progress.
55    /// If `true`, the operation is completed, and either `error` or `response` is
56    /// available.
57    pub done: bool,
58
59    /// The operation result, which can be either an `error` or a valid `response`.
60    /// If `done` == `false`, neither `error` nor `response` is set.
61    /// If `done` == `true`, exactly one of `error` or `response` can be set.
62    /// Some services might not provide the result.
63    pub result: std::option::Option<crate::model::operation::Result>,
64
65    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
66}
67
68impl Operation {
69    pub fn new() -> Self {
70        std::default::Default::default()
71    }
72
73    /// Sets the value of [name][crate::model::Operation::name].
74    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
75        self.name = v.into();
76        self
77    }
78
79    /// Sets the value of [metadata][crate::model::Operation::metadata].
80    pub fn set_metadata<T>(mut self, v: T) -> Self
81    where
82        T: std::convert::Into<wkt::Any>,
83    {
84        self.metadata = std::option::Option::Some(v.into());
85        self
86    }
87
88    /// Sets or clears the value of [metadata][crate::model::Operation::metadata].
89    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
90    where
91        T: std::convert::Into<wkt::Any>,
92    {
93        self.metadata = v.map(|x| x.into());
94        self
95    }
96
97    /// Sets the value of [done][crate::model::Operation::done].
98    pub fn set_done<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
99        self.done = v.into();
100        self
101    }
102
103    /// Sets the value of [result][crate::model::Operation::result].
104    ///
105    /// Note that all the setters affecting `result` are mutually
106    /// exclusive.
107    pub fn set_result<
108        T: std::convert::Into<std::option::Option<crate::model::operation::Result>>,
109    >(
110        mut self,
111        v: T,
112    ) -> Self {
113        self.result = v.into();
114        self
115    }
116
117    /// The value of [result][crate::model::Operation::result]
118    /// if it holds a `Error`, `None` if the field is not set or
119    /// holds a different branch.
120    pub fn error(&self) -> std::option::Option<&std::boxed::Box<rpc::model::Status>> {
121        #[allow(unreachable_patterns)]
122        self.result.as_ref().and_then(|v| match v {
123            crate::model::operation::Result::Error(v) => std::option::Option::Some(v),
124            _ => std::option::Option::None,
125        })
126    }
127
128    /// Sets the value of [result][crate::model::Operation::result]
129    /// to hold a `Error`.
130    ///
131    /// Note that all the setters affecting `result` are
132    /// mutually exclusive.
133    pub fn set_error<T: std::convert::Into<std::boxed::Box<rpc::model::Status>>>(
134        mut self,
135        v: T,
136    ) -> Self {
137        self.result = std::option::Option::Some(crate::model::operation::Result::Error(v.into()));
138        self
139    }
140
141    /// The value of [result][crate::model::Operation::result]
142    /// if it holds a `Response`, `None` if the field is not set or
143    /// holds a different branch.
144    pub fn response(&self) -> std::option::Option<&std::boxed::Box<wkt::Any>> {
145        #[allow(unreachable_patterns)]
146        self.result.as_ref().and_then(|v| match v {
147            crate::model::operation::Result::Response(v) => std::option::Option::Some(v),
148            _ => std::option::Option::None,
149        })
150    }
151
152    /// Sets the value of [result][crate::model::Operation::result]
153    /// to hold a `Response`.
154    ///
155    /// Note that all the setters affecting `result` are
156    /// mutually exclusive.
157    pub fn set_response<T: std::convert::Into<std::boxed::Box<wkt::Any>>>(mut self, v: T) -> Self {
158        self.result =
159            std::option::Option::Some(crate::model::operation::Result::Response(v.into()));
160        self
161    }
162}
163
164impl wkt::message::Message for Operation {
165    fn typename() -> &'static str {
166        "type.googleapis.com/google.longrunning.Operation"
167    }
168}
169
170/// Defines additional types related to [Operation].
171pub mod operation {
172    #[allow(unused_imports)]
173    use super::*;
174
175    /// The operation result, which can be either an `error` or a valid `response`.
176    /// If `done` == `false`, neither `error` nor `response` is set.
177    /// If `done` == `true`, exactly one of `error` or `response` can be set.
178    /// Some services might not provide the result.
179    #[derive(Clone, Debug, PartialEq)]
180    #[non_exhaustive]
181    pub enum Result {
182        /// The error result of the operation in case of failure or cancellation.
183        Error(std::boxed::Box<rpc::model::Status>),
184        /// The normal, successful response of the operation.  If the original
185        /// method returns no data on success, such as `Delete`, the response is
186        /// `google.protobuf.Empty`.  If the original method is standard
187        /// `Get`/`Create`/`Update`, the response should be the resource.  For other
188        /// methods, the response should have the type `XxxResponse`, where `Xxx`
189        /// is the original method name.  For example, if the original method name
190        /// is `TakeSnapshot()`, the inferred response type is
191        /// `TakeSnapshotResponse`.
192        Response(std::boxed::Box<wkt::Any>),
193    }
194}
195
196/// The request message for
197/// [Operations.GetOperation][google.longrunning.Operations.GetOperation].
198///
199/// [google.longrunning.Operations.GetOperation]: crate::client::Operations::get_operation
200#[derive(Clone, Default, PartialEq)]
201#[non_exhaustive]
202pub struct GetOperationRequest {
203    /// The name of the operation resource.
204    pub name: std::string::String,
205
206    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
207}
208
209impl GetOperationRequest {
210    pub fn new() -> Self {
211        std::default::Default::default()
212    }
213
214    /// Sets the value of [name][crate::model::GetOperationRequest::name].
215    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
216        self.name = v.into();
217        self
218    }
219}
220
221impl wkt::message::Message for GetOperationRequest {
222    fn typename() -> &'static str {
223        "type.googleapis.com/google.longrunning.GetOperationRequest"
224    }
225}
226
227/// The request message for
228/// [Operations.ListOperations][google.longrunning.Operations.ListOperations].
229///
230/// [google.longrunning.Operations.ListOperations]: crate::client::Operations::list_operations
231#[derive(Clone, Default, PartialEq)]
232#[non_exhaustive]
233pub struct ListOperationsRequest {
234    /// The name of the operation's parent resource.
235    pub name: std::string::String,
236
237    /// The standard list filter.
238    pub filter: std::string::String,
239
240    /// The standard list page size.
241    pub page_size: i32,
242
243    /// The standard list page token.
244    pub page_token: std::string::String,
245
246    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
247}
248
249impl ListOperationsRequest {
250    pub fn new() -> Self {
251        std::default::Default::default()
252    }
253
254    /// Sets the value of [name][crate::model::ListOperationsRequest::name].
255    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
256        self.name = v.into();
257        self
258    }
259
260    /// Sets the value of [filter][crate::model::ListOperationsRequest::filter].
261    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
262        self.filter = v.into();
263        self
264    }
265
266    /// Sets the value of [page_size][crate::model::ListOperationsRequest::page_size].
267    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
268        self.page_size = v.into();
269        self
270    }
271
272    /// Sets the value of [page_token][crate::model::ListOperationsRequest::page_token].
273    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
274        self.page_token = v.into();
275        self
276    }
277}
278
279impl wkt::message::Message for ListOperationsRequest {
280    fn typename() -> &'static str {
281        "type.googleapis.com/google.longrunning.ListOperationsRequest"
282    }
283}
284
285/// The response message for
286/// [Operations.ListOperations][google.longrunning.Operations.ListOperations].
287///
288/// [google.longrunning.Operations.ListOperations]: crate::client::Operations::list_operations
289#[derive(Clone, Default, PartialEq)]
290#[non_exhaustive]
291pub struct ListOperationsResponse {
292    /// A list of operations that matches the specified filter in the request.
293    pub operations: std::vec::Vec<crate::model::Operation>,
294
295    /// The standard List next-page token.
296    pub next_page_token: std::string::String,
297
298    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
299}
300
301impl ListOperationsResponse {
302    pub fn new() -> Self {
303        std::default::Default::default()
304    }
305
306    /// Sets the value of [operations][crate::model::ListOperationsResponse::operations].
307    pub fn set_operations<T, V>(mut self, v: T) -> Self
308    where
309        T: std::iter::IntoIterator<Item = V>,
310        V: std::convert::Into<crate::model::Operation>,
311    {
312        use std::iter::Iterator;
313        self.operations = v.into_iter().map(|i| i.into()).collect();
314        self
315    }
316
317    /// Sets the value of [next_page_token][crate::model::ListOperationsResponse::next_page_token].
318    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
319        self.next_page_token = v.into();
320        self
321    }
322}
323
324impl wkt::message::Message for ListOperationsResponse {
325    fn typename() -> &'static str {
326        "type.googleapis.com/google.longrunning.ListOperationsResponse"
327    }
328}
329
330#[doc(hidden)]
331impl gax::paginator::internal::PageableResponse for ListOperationsResponse {
332    type PageItem = crate::model::Operation;
333
334    fn items(self) -> std::vec::Vec<Self::PageItem> {
335        self.operations
336    }
337
338    fn next_page_token(&self) -> std::string::String {
339        use std::clone::Clone;
340        self.next_page_token.clone()
341    }
342}
343
344/// The request message for
345/// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
346///
347/// [google.longrunning.Operations.CancelOperation]: crate::client::Operations::cancel_operation
348#[derive(Clone, Default, PartialEq)]
349#[non_exhaustive]
350pub struct CancelOperationRequest {
351    /// The name of the operation resource to be cancelled.
352    pub name: std::string::String,
353
354    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
355}
356
357impl CancelOperationRequest {
358    pub fn new() -> Self {
359        std::default::Default::default()
360    }
361
362    /// Sets the value of [name][crate::model::CancelOperationRequest::name].
363    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
364        self.name = v.into();
365        self
366    }
367}
368
369impl wkt::message::Message for CancelOperationRequest {
370    fn typename() -> &'static str {
371        "type.googleapis.com/google.longrunning.CancelOperationRequest"
372    }
373}
374
375/// The request message for
376/// [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
377///
378/// [google.longrunning.Operations.DeleteOperation]: crate::client::Operations::delete_operation
379#[derive(Clone, Default, PartialEq)]
380#[non_exhaustive]
381pub struct DeleteOperationRequest {
382    /// The name of the operation resource to be deleted.
383    pub name: std::string::String,
384
385    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
386}
387
388impl DeleteOperationRequest {
389    pub fn new() -> Self {
390        std::default::Default::default()
391    }
392
393    /// Sets the value of [name][crate::model::DeleteOperationRequest::name].
394    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
395        self.name = v.into();
396        self
397    }
398}
399
400impl wkt::message::Message for DeleteOperationRequest {
401    fn typename() -> &'static str {
402        "type.googleapis.com/google.longrunning.DeleteOperationRequest"
403    }
404}
405
406/// The request message for
407/// [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
408#[derive(Clone, Default, PartialEq)]
409#[non_exhaustive]
410pub struct WaitOperationRequest {
411    /// The name of the operation resource to wait on.
412    pub name: std::string::String,
413
414    /// The maximum duration to wait before timing out. If left blank, the wait
415    /// will be at most the time permitted by the underlying HTTP/RPC protocol.
416    /// If RPC context deadline is also specified, the shorter one will be used.
417    pub timeout: std::option::Option<wkt::Duration>,
418
419    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
420}
421
422impl WaitOperationRequest {
423    pub fn new() -> Self {
424        std::default::Default::default()
425    }
426
427    /// Sets the value of [name][crate::model::WaitOperationRequest::name].
428    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
429        self.name = v.into();
430        self
431    }
432
433    /// Sets the value of [timeout][crate::model::WaitOperationRequest::timeout].
434    pub fn set_timeout<T>(mut self, v: T) -> Self
435    where
436        T: std::convert::Into<wkt::Duration>,
437    {
438        self.timeout = std::option::Option::Some(v.into());
439        self
440    }
441
442    /// Sets or clears the value of [timeout][crate::model::WaitOperationRequest::timeout].
443    pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
444    where
445        T: std::convert::Into<wkt::Duration>,
446    {
447        self.timeout = v.map(|x| x.into());
448        self
449    }
450}
451
452impl wkt::message::Message for WaitOperationRequest {
453    fn typename() -> &'static str {
454        "type.googleapis.com/google.longrunning.WaitOperationRequest"
455    }
456}
457
458/// A message representing the message types used by a long-running operation.
459///
460/// Example:
461///
462/// ```norust
463/// rpc Export(ExportRequest) returns (google.longrunning.Operation) {
464///   option (google.longrunning.operation_info) = {
465///     response_type: "ExportResponse"
466///     metadata_type: "ExportMetadata"
467///   };
468/// }
469/// ```
470#[derive(Clone, Default, PartialEq)]
471#[non_exhaustive]
472pub struct OperationInfo {
473    /// Required. The message name of the primary return type for this
474    /// long-running operation.
475    /// This type will be used to deserialize the LRO's response.
476    ///
477    /// If the response is in a different package from the rpc, a fully-qualified
478    /// message name must be used (e.g. `google.protobuf.Struct`).
479    ///
480    /// Note: Altering this value constitutes a breaking change.
481    pub response_type: std::string::String,
482
483    /// Required. The message name of the metadata type for this long-running
484    /// operation.
485    ///
486    /// If the response is in a different package from the rpc, a fully-qualified
487    /// message name must be used (e.g. `google.protobuf.Struct`).
488    ///
489    /// Note: Altering this value constitutes a breaking change.
490    pub metadata_type: std::string::String,
491
492    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
493}
494
495impl OperationInfo {
496    pub fn new() -> Self {
497        std::default::Default::default()
498    }
499
500    /// Sets the value of [response_type][crate::model::OperationInfo::response_type].
501    pub fn set_response_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
502        self.response_type = v.into();
503        self
504    }
505
506    /// Sets the value of [metadata_type][crate::model::OperationInfo::metadata_type].
507    pub fn set_metadata_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
508        self.metadata_type = v.into();
509        self
510    }
511}
512
513impl wkt::message::Message for OperationInfo {
514    fn typename() -> &'static str {
515        "type.googleapis.com/google.longrunning.OperationInfo"
516    }
517}