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