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