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 /// When set to `true`, operations that are reachable are returned as normal,
247 /// and those that are unreachable are returned in the
248 /// [ListOperationsResponse.unreachable] field.
249 ///
250 /// This can only be `true` when reading across collections e.g. when `parent`
251 /// is set to `"projects/example/locations/-"`.
252 ///
253 /// This field is not by default supported and will result in an
254 /// `UNIMPLEMENTED` error if set unless explicitly documented otherwise in
255 /// service or product specific documentation.
256 pub return_partial_success: bool,
257
258 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
259}
260
261impl ListOperationsRequest {
262 pub fn new() -> Self {
263 std::default::Default::default()
264 }
265
266 /// Sets the value of [name][crate::model::ListOperationsRequest::name].
267 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
268 self.name = v.into();
269 self
270 }
271
272 /// Sets the value of [filter][crate::model::ListOperationsRequest::filter].
273 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
274 self.filter = v.into();
275 self
276 }
277
278 /// Sets the value of [page_size][crate::model::ListOperationsRequest::page_size].
279 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
280 self.page_size = v.into();
281 self
282 }
283
284 /// Sets the value of [page_token][crate::model::ListOperationsRequest::page_token].
285 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
286 self.page_token = v.into();
287 self
288 }
289
290 /// Sets the value of [return_partial_success][crate::model::ListOperationsRequest::return_partial_success].
291 pub fn set_return_partial_success<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
292 self.return_partial_success = v.into();
293 self
294 }
295}
296
297impl wkt::message::Message for ListOperationsRequest {
298 fn typename() -> &'static str {
299 "type.googleapis.com/google.longrunning.ListOperationsRequest"
300 }
301}
302
303/// The response message for
304/// [Operations.ListOperations][google.longrunning.Operations.ListOperations].
305///
306/// [google.longrunning.Operations.ListOperations]: crate::client::Operations::list_operations
307#[derive(Clone, Default, PartialEq)]
308#[non_exhaustive]
309pub struct ListOperationsResponse {
310 /// A list of operations that matches the specified filter in the request.
311 pub operations: std::vec::Vec<crate::model::Operation>,
312
313 /// The standard List next-page token.
314 pub next_page_token: std::string::String,
315
316 /// Unordered list. Unreachable resources. Populated when the request sets
317 /// `ListOperationsRequest.return_partial_success` and reads across
318 /// collections e.g. when attempting to list all resources across all supported
319 /// locations.
320 pub unreachable: std::vec::Vec<std::string::String>,
321
322 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
323}
324
325impl ListOperationsResponse {
326 pub fn new() -> Self {
327 std::default::Default::default()
328 }
329
330 /// Sets the value of [operations][crate::model::ListOperationsResponse::operations].
331 pub fn set_operations<T, V>(mut self, v: T) -> Self
332 where
333 T: std::iter::IntoIterator<Item = V>,
334 V: std::convert::Into<crate::model::Operation>,
335 {
336 use std::iter::Iterator;
337 self.operations = v.into_iter().map(|i| i.into()).collect();
338 self
339 }
340
341 /// Sets the value of [next_page_token][crate::model::ListOperationsResponse::next_page_token].
342 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
343 self.next_page_token = v.into();
344 self
345 }
346
347 /// Sets the value of [unreachable][crate::model::ListOperationsResponse::unreachable].
348 pub fn set_unreachable<T, V>(mut self, v: T) -> Self
349 where
350 T: std::iter::IntoIterator<Item = V>,
351 V: std::convert::Into<std::string::String>,
352 {
353 use std::iter::Iterator;
354 self.unreachable = v.into_iter().map(|i| i.into()).collect();
355 self
356 }
357}
358
359impl wkt::message::Message for ListOperationsResponse {
360 fn typename() -> &'static str {
361 "type.googleapis.com/google.longrunning.ListOperationsResponse"
362 }
363}
364
365#[doc(hidden)]
366impl gax::paginator::internal::PageableResponse for ListOperationsResponse {
367 type PageItem = crate::model::Operation;
368
369 fn items(self) -> std::vec::Vec<Self::PageItem> {
370 self.operations
371 }
372
373 fn next_page_token(&self) -> std::string::String {
374 use std::clone::Clone;
375 self.next_page_token.clone()
376 }
377}
378
379/// The request message for
380/// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
381///
382/// [google.longrunning.Operations.CancelOperation]: crate::client::Operations::cancel_operation
383#[derive(Clone, Default, PartialEq)]
384#[non_exhaustive]
385pub struct CancelOperationRequest {
386 /// The name of the operation resource to be cancelled.
387 pub name: std::string::String,
388
389 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
390}
391
392impl CancelOperationRequest {
393 pub fn new() -> Self {
394 std::default::Default::default()
395 }
396
397 /// Sets the value of [name][crate::model::CancelOperationRequest::name].
398 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
399 self.name = v.into();
400 self
401 }
402}
403
404impl wkt::message::Message for CancelOperationRequest {
405 fn typename() -> &'static str {
406 "type.googleapis.com/google.longrunning.CancelOperationRequest"
407 }
408}
409
410/// The request message for
411/// [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
412///
413/// [google.longrunning.Operations.DeleteOperation]: crate::client::Operations::delete_operation
414#[derive(Clone, Default, PartialEq)]
415#[non_exhaustive]
416pub struct DeleteOperationRequest {
417 /// The name of the operation resource to be deleted.
418 pub name: std::string::String,
419
420 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
421}
422
423impl DeleteOperationRequest {
424 pub fn new() -> Self {
425 std::default::Default::default()
426 }
427
428 /// Sets the value of [name][crate::model::DeleteOperationRequest::name].
429 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
430 self.name = v.into();
431 self
432 }
433}
434
435impl wkt::message::Message for DeleteOperationRequest {
436 fn typename() -> &'static str {
437 "type.googleapis.com/google.longrunning.DeleteOperationRequest"
438 }
439}
440
441/// The request message for
442/// [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
443#[derive(Clone, Default, PartialEq)]
444#[non_exhaustive]
445pub struct WaitOperationRequest {
446 /// The name of the operation resource to wait on.
447 pub name: std::string::String,
448
449 /// The maximum duration to wait before timing out. If left blank, the wait
450 /// will be at most the time permitted by the underlying HTTP/RPC protocol.
451 /// If RPC context deadline is also specified, the shorter one will be used.
452 pub timeout: std::option::Option<wkt::Duration>,
453
454 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
455}
456
457impl WaitOperationRequest {
458 pub fn new() -> Self {
459 std::default::Default::default()
460 }
461
462 /// Sets the value of [name][crate::model::WaitOperationRequest::name].
463 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
464 self.name = v.into();
465 self
466 }
467
468 /// Sets the value of [timeout][crate::model::WaitOperationRequest::timeout].
469 pub fn set_timeout<T>(mut self, v: T) -> Self
470 where
471 T: std::convert::Into<wkt::Duration>,
472 {
473 self.timeout = std::option::Option::Some(v.into());
474 self
475 }
476
477 /// Sets or clears the value of [timeout][crate::model::WaitOperationRequest::timeout].
478 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
479 where
480 T: std::convert::Into<wkt::Duration>,
481 {
482 self.timeout = v.map(|x| x.into());
483 self
484 }
485}
486
487impl wkt::message::Message for WaitOperationRequest {
488 fn typename() -> &'static str {
489 "type.googleapis.com/google.longrunning.WaitOperationRequest"
490 }
491}
492
493/// A message representing the message types used by a long-running operation.
494///
495/// Example:
496///
497/// ```norust
498/// rpc Export(ExportRequest) returns (google.longrunning.Operation) {
499/// option (google.longrunning.operation_info) = {
500/// response_type: "ExportResponse"
501/// metadata_type: "ExportMetadata"
502/// };
503/// }
504/// ```
505#[derive(Clone, Default, PartialEq)]
506#[non_exhaustive]
507pub struct OperationInfo {
508 /// Required. The message name of the primary return type for this
509 /// long-running operation.
510 /// This type will be used to deserialize the LRO's response.
511 ///
512 /// If the response is in a different package from the rpc, a fully-qualified
513 /// message name must be used (e.g. `google.protobuf.Struct`).
514 ///
515 /// Note: Altering this value constitutes a breaking change.
516 pub response_type: std::string::String,
517
518 /// Required. The message name of the metadata type for this long-running
519 /// operation.
520 ///
521 /// If the response is in a different package from the rpc, a fully-qualified
522 /// message name must be used (e.g. `google.protobuf.Struct`).
523 ///
524 /// Note: Altering this value constitutes a breaking change.
525 pub metadata_type: std::string::String,
526
527 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
528}
529
530impl OperationInfo {
531 pub fn new() -> Self {
532 std::default::Default::default()
533 }
534
535 /// Sets the value of [response_type][crate::model::OperationInfo::response_type].
536 pub fn set_response_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
537 self.response_type = v.into();
538 self
539 }
540
541 /// Sets the value of [metadata_type][crate::model::OperationInfo::metadata_type].
542 pub fn set_metadata_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
543 self.metadata_type = v.into();
544 self
545 }
546}
547
548impl wkt::message::Message for OperationInfo {
549 fn typename() -> &'static str {
550 "type.googleapis.com/google.longrunning.OperationInfo"
551 }
552}