google_cloud_common/
model.rs

1// Copyright 2025 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 bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27mod debug;
28mod deserialize;
29mod serialize;
30
31/// Represents the metadata of the long-running operation.
32#[derive(Clone, Default, PartialEq)]
33#[non_exhaustive]
34pub struct OperationMetadata {
35    /// Output only. The time the operation was created.
36    pub create_time: std::option::Option<wkt::Timestamp>,
37
38    /// Output only. The time the operation finished running.
39    pub end_time: std::option::Option<wkt::Timestamp>,
40
41    /// Output only. Server-defined resource path for the target of the operation.
42    pub target: std::string::String,
43
44    /// Output only. Name of the verb executed by the operation.
45    pub verb: std::string::String,
46
47    /// Output only. Human-readable status of the operation, if any.
48    pub status_detail: std::string::String,
49
50    /// Output only. Identifies whether the user has requested cancellation
51    /// of the operation. Operations that have successfully been cancelled
52    /// have [Operation.error][] value with a [google.rpc.Status.code][] of 1,
53    /// corresponding to `Code.CANCELLED`.
54    pub cancel_requested: bool,
55
56    /// Output only. API version used to start the operation.
57    pub api_version: std::string::String,
58
59    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
60}
61
62impl OperationMetadata {
63    pub fn new() -> Self {
64        std::default::Default::default()
65    }
66
67    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
68    ///
69    /// # Example
70    /// ```ignore,no_run
71    /// # use google_cloud_common::model::OperationMetadata;
72    /// use wkt::Timestamp;
73    /// let x = OperationMetadata::new().set_create_time(Timestamp::default()/* use setters */);
74    /// ```
75    pub fn set_create_time<T>(mut self, v: T) -> Self
76    where
77        T: std::convert::Into<wkt::Timestamp>,
78    {
79        self.create_time = std::option::Option::Some(v.into());
80        self
81    }
82
83    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
84    ///
85    /// # Example
86    /// ```ignore,no_run
87    /// # use google_cloud_common::model::OperationMetadata;
88    /// use wkt::Timestamp;
89    /// let x = OperationMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
90    /// let x = OperationMetadata::new().set_or_clear_create_time(None::<Timestamp>);
91    /// ```
92    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
93    where
94        T: std::convert::Into<wkt::Timestamp>,
95    {
96        self.create_time = v.map(|x| x.into());
97        self
98    }
99
100    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
101    ///
102    /// # Example
103    /// ```ignore,no_run
104    /// # use google_cloud_common::model::OperationMetadata;
105    /// use wkt::Timestamp;
106    /// let x = OperationMetadata::new().set_end_time(Timestamp::default()/* use setters */);
107    /// ```
108    pub fn set_end_time<T>(mut self, v: T) -> Self
109    where
110        T: std::convert::Into<wkt::Timestamp>,
111    {
112        self.end_time = std::option::Option::Some(v.into());
113        self
114    }
115
116    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
117    ///
118    /// # Example
119    /// ```ignore,no_run
120    /// # use google_cloud_common::model::OperationMetadata;
121    /// use wkt::Timestamp;
122    /// let x = OperationMetadata::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
123    /// let x = OperationMetadata::new().set_or_clear_end_time(None::<Timestamp>);
124    /// ```
125    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
126    where
127        T: std::convert::Into<wkt::Timestamp>,
128    {
129        self.end_time = v.map(|x| x.into());
130        self
131    }
132
133    /// Sets the value of [target][crate::model::OperationMetadata::target].
134    ///
135    /// # Example
136    /// ```ignore,no_run
137    /// # use google_cloud_common::model::OperationMetadata;
138    /// let x = OperationMetadata::new().set_target("example");
139    /// ```
140    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
141        self.target = v.into();
142        self
143    }
144
145    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
146    ///
147    /// # Example
148    /// ```ignore,no_run
149    /// # use google_cloud_common::model::OperationMetadata;
150    /// let x = OperationMetadata::new().set_verb("example");
151    /// ```
152    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
153        self.verb = v.into();
154        self
155    }
156
157    /// Sets the value of [status_detail][crate::model::OperationMetadata::status_detail].
158    ///
159    /// # Example
160    /// ```ignore,no_run
161    /// # use google_cloud_common::model::OperationMetadata;
162    /// let x = OperationMetadata::new().set_status_detail("example");
163    /// ```
164    pub fn set_status_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
165        self.status_detail = v.into();
166        self
167    }
168
169    /// Sets the value of [cancel_requested][crate::model::OperationMetadata::cancel_requested].
170    ///
171    /// # Example
172    /// ```ignore,no_run
173    /// # use google_cloud_common::model::OperationMetadata;
174    /// let x = OperationMetadata::new().set_cancel_requested(true);
175    /// ```
176    pub fn set_cancel_requested<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
177        self.cancel_requested = v.into();
178        self
179    }
180
181    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
182    ///
183    /// # Example
184    /// ```ignore,no_run
185    /// # use google_cloud_common::model::OperationMetadata;
186    /// let x = OperationMetadata::new().set_api_version("example");
187    /// ```
188    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
189        self.api_version = v.into();
190        self
191    }
192}
193
194impl wkt::message::Message for OperationMetadata {
195    fn typename() -> &'static str {
196        "type.googleapis.com/google.cloud.common.OperationMetadata"
197    }
198}