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