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