Skip to main content

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