google_cloud_location/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 serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33mod debug;
34mod deserialize;
35mod serialize;
36
37/// The request message for [Locations.ListLocations][google.cloud.location.Locations.ListLocations].
38///
39/// [google.cloud.location.Locations.ListLocations]: crate::client::Locations::list_locations
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct ListLocationsRequest {
43 /// The resource that owns the locations collection, if applicable.
44 pub name: std::string::String,
45
46 /// The standard list filter.
47 pub filter: std::string::String,
48
49 /// The standard list page size.
50 pub page_size: i32,
51
52 /// The standard list page token.
53 pub page_token: std::string::String,
54
55 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
56}
57
58impl ListLocationsRequest {
59 pub fn new() -> Self {
60 std::default::Default::default()
61 }
62
63 /// Sets the value of [name][crate::model::ListLocationsRequest::name].
64 ///
65 /// # Example
66 /// ```ignore,no_run
67 /// # use google_cloud_location::model::ListLocationsRequest;
68 /// let x = ListLocationsRequest::new().set_name("example");
69 /// ```
70 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
71 self.name = v.into();
72 self
73 }
74
75 /// Sets the value of [filter][crate::model::ListLocationsRequest::filter].
76 ///
77 /// # Example
78 /// ```ignore,no_run
79 /// # use google_cloud_location::model::ListLocationsRequest;
80 /// let x = ListLocationsRequest::new().set_filter("example");
81 /// ```
82 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
83 self.filter = v.into();
84 self
85 }
86
87 /// Sets the value of [page_size][crate::model::ListLocationsRequest::page_size].
88 ///
89 /// # Example
90 /// ```ignore,no_run
91 /// # use google_cloud_location::model::ListLocationsRequest;
92 /// let x = ListLocationsRequest::new().set_page_size(42);
93 /// ```
94 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
95 self.page_size = v.into();
96 self
97 }
98
99 /// Sets the value of [page_token][crate::model::ListLocationsRequest::page_token].
100 ///
101 /// # Example
102 /// ```ignore,no_run
103 /// # use google_cloud_location::model::ListLocationsRequest;
104 /// let x = ListLocationsRequest::new().set_page_token("example");
105 /// ```
106 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
107 self.page_token = v.into();
108 self
109 }
110}
111
112impl wkt::message::Message for ListLocationsRequest {
113 fn typename() -> &'static str {
114 "type.googleapis.com/google.cloud.location.ListLocationsRequest"
115 }
116}
117
118/// The response message for [Locations.ListLocations][google.cloud.location.Locations.ListLocations].
119///
120/// [google.cloud.location.Locations.ListLocations]: crate::client::Locations::list_locations
121#[derive(Clone, Default, PartialEq)]
122#[non_exhaustive]
123pub struct ListLocationsResponse {
124 /// A list of locations that matches the specified filter in the request.
125 pub locations: std::vec::Vec<crate::model::Location>,
126
127 /// The standard List next-page token.
128 pub next_page_token: std::string::String,
129
130 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
131}
132
133impl ListLocationsResponse {
134 pub fn new() -> Self {
135 std::default::Default::default()
136 }
137
138 /// Sets the value of [locations][crate::model::ListLocationsResponse::locations].
139 ///
140 /// # Example
141 /// ```ignore,no_run
142 /// # use google_cloud_location::model::ListLocationsResponse;
143 /// use google_cloud_location::model::Location;
144 /// let x = ListLocationsResponse::new()
145 /// .set_locations([
146 /// Location::default()/* use setters */,
147 /// Location::default()/* use (different) setters */,
148 /// ]);
149 /// ```
150 pub fn set_locations<T, V>(mut self, v: T) -> Self
151 where
152 T: std::iter::IntoIterator<Item = V>,
153 V: std::convert::Into<crate::model::Location>,
154 {
155 use std::iter::Iterator;
156 self.locations = v.into_iter().map(|i| i.into()).collect();
157 self
158 }
159
160 /// Sets the value of [next_page_token][crate::model::ListLocationsResponse::next_page_token].
161 ///
162 /// # Example
163 /// ```ignore,no_run
164 /// # use google_cloud_location::model::ListLocationsResponse;
165 /// let x = ListLocationsResponse::new().set_next_page_token("example");
166 /// ```
167 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
168 self.next_page_token = v.into();
169 self
170 }
171}
172
173impl wkt::message::Message for ListLocationsResponse {
174 fn typename() -> &'static str {
175 "type.googleapis.com/google.cloud.location.ListLocationsResponse"
176 }
177}
178
179#[doc(hidden)]
180impl gax::paginator::internal::PageableResponse for ListLocationsResponse {
181 type PageItem = crate::model::Location;
182
183 fn items(self) -> std::vec::Vec<Self::PageItem> {
184 self.locations
185 }
186
187 fn next_page_token(&self) -> std::string::String {
188 use std::clone::Clone;
189 self.next_page_token.clone()
190 }
191}
192
193/// The request message for [Locations.GetLocation][google.cloud.location.Locations.GetLocation].
194///
195/// [google.cloud.location.Locations.GetLocation]: crate::client::Locations::get_location
196#[derive(Clone, Default, PartialEq)]
197#[non_exhaustive]
198pub struct GetLocationRequest {
199 /// Resource name for the location.
200 pub name: std::string::String,
201
202 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
203}
204
205impl GetLocationRequest {
206 pub fn new() -> Self {
207 std::default::Default::default()
208 }
209
210 /// Sets the value of [name][crate::model::GetLocationRequest::name].
211 ///
212 /// # Example
213 /// ```ignore,no_run
214 /// # use google_cloud_location::model::GetLocationRequest;
215 /// let x = GetLocationRequest::new().set_name("example");
216 /// ```
217 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
218 self.name = v.into();
219 self
220 }
221}
222
223impl wkt::message::Message for GetLocationRequest {
224 fn typename() -> &'static str {
225 "type.googleapis.com/google.cloud.location.GetLocationRequest"
226 }
227}
228
229/// A resource that represents Google Cloud Platform location.
230#[derive(Clone, Default, PartialEq)]
231#[non_exhaustive]
232pub struct Location {
233 /// Resource name for the location, which may vary between implementations.
234 /// For example: `"projects/example-project/locations/us-east1"`
235 pub name: std::string::String,
236
237 /// The canonical id for this location. For example: `"us-east1"`.
238 pub location_id: std::string::String,
239
240 /// The friendly name for this location, typically a nearby city name.
241 /// For example, "Tokyo".
242 pub display_name: std::string::String,
243
244 /// Cross-service attributes for the location. For example
245 ///
246 /// ```norust
247 /// {"cloud.googleapis.com/region": "us-east1"}
248 /// ```
249 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
250
251 /// Service-specific metadata. For example the available capacity at the given
252 /// location.
253 pub metadata: std::option::Option<wkt::Any>,
254
255 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
256}
257
258impl Location {
259 pub fn new() -> Self {
260 std::default::Default::default()
261 }
262
263 /// Sets the value of [name][crate::model::Location::name].
264 ///
265 /// # Example
266 /// ```ignore,no_run
267 /// # use google_cloud_location::model::Location;
268 /// let x = Location::new().set_name("example");
269 /// ```
270 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
271 self.name = v.into();
272 self
273 }
274
275 /// Sets the value of [location_id][crate::model::Location::location_id].
276 ///
277 /// # Example
278 /// ```ignore,no_run
279 /// # use google_cloud_location::model::Location;
280 /// let x = Location::new().set_location_id("example");
281 /// ```
282 pub fn set_location_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
283 self.location_id = v.into();
284 self
285 }
286
287 /// Sets the value of [display_name][crate::model::Location::display_name].
288 ///
289 /// # Example
290 /// ```ignore,no_run
291 /// # use google_cloud_location::model::Location;
292 /// let x = Location::new().set_display_name("example");
293 /// ```
294 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
295 self.display_name = v.into();
296 self
297 }
298
299 /// Sets the value of [labels][crate::model::Location::labels].
300 ///
301 /// # Example
302 /// ```ignore,no_run
303 /// # use google_cloud_location::model::Location;
304 /// let x = Location::new().set_labels([
305 /// ("key0", "abc"),
306 /// ("key1", "xyz"),
307 /// ]);
308 /// ```
309 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
310 where
311 T: std::iter::IntoIterator<Item = (K, V)>,
312 K: std::convert::Into<std::string::String>,
313 V: std::convert::Into<std::string::String>,
314 {
315 use std::iter::Iterator;
316 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
317 self
318 }
319
320 /// Sets the value of [metadata][crate::model::Location::metadata].
321 ///
322 /// # Example
323 /// ```ignore,no_run
324 /// # use google_cloud_location::model::Location;
325 /// use wkt::Any;
326 /// let x = Location::new().set_metadata(Any::default()/* use setters */);
327 /// ```
328 pub fn set_metadata<T>(mut self, v: T) -> Self
329 where
330 T: std::convert::Into<wkt::Any>,
331 {
332 self.metadata = std::option::Option::Some(v.into());
333 self
334 }
335
336 /// Sets or clears the value of [metadata][crate::model::Location::metadata].
337 ///
338 /// # Example
339 /// ```ignore,no_run
340 /// # use google_cloud_location::model::Location;
341 /// use wkt::Any;
342 /// let x = Location::new().set_or_clear_metadata(Some(Any::default()/* use setters */));
343 /// let x = Location::new().set_or_clear_metadata(None::<Any>);
344 /// ```
345 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
346 where
347 T: std::convert::Into<wkt::Any>,
348 {
349 self.metadata = v.map(|x| x.into());
350 self
351 }
352}
353
354impl wkt::message::Message for Location {
355 fn typename() -> &'static str {
356 "type.googleapis.com/google.cloud.location.Location"
357 }
358}