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
33/// The request message for [Locations.ListLocations][google.cloud.location.Locations.ListLocations].
34///
35/// [google.cloud.location.Locations.ListLocations]: crate::client::Locations::list_locations
36#[serde_with::serde_as]
37#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
38#[serde(default, rename_all = "camelCase")]
39#[non_exhaustive]
40pub struct ListLocationsRequest {
41    /// The resource that owns the locations collection, if applicable.
42    #[serde(skip_serializing_if = "std::string::String::is_empty")]
43    pub name: std::string::String,
44
45    /// The standard list filter.
46    #[serde(skip_serializing_if = "std::string::String::is_empty")]
47    pub filter: std::string::String,
48
49    /// The standard list page size.
50    #[serde(skip_serializing_if = "wkt::internal::is_default")]
51    pub page_size: i32,
52
53    /// The standard list page token.
54    #[serde(skip_serializing_if = "std::string::String::is_empty")]
55    pub page_token: std::string::String,
56
57    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
58    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
59}
60
61impl ListLocationsRequest {
62    pub fn new() -> Self {
63        std::default::Default::default()
64    }
65
66    /// Sets the value of [name][crate::model::ListLocationsRequest::name].
67    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
68        self.name = v.into();
69        self
70    }
71
72    /// Sets the value of [filter][crate::model::ListLocationsRequest::filter].
73    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
74        self.filter = v.into();
75        self
76    }
77
78    /// Sets the value of [page_size][crate::model::ListLocationsRequest::page_size].
79    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
80        self.page_size = v.into();
81        self
82    }
83
84    /// Sets the value of [page_token][crate::model::ListLocationsRequest::page_token].
85    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
86        self.page_token = v.into();
87        self
88    }
89}
90
91impl wkt::message::Message for ListLocationsRequest {
92    fn typename() -> &'static str {
93        "type.googleapis.com/google.cloud.location.ListLocationsRequest"
94    }
95}
96
97/// The response message for [Locations.ListLocations][google.cloud.location.Locations.ListLocations].
98///
99/// [google.cloud.location.Locations.ListLocations]: crate::client::Locations::list_locations
100#[serde_with::serde_as]
101#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
102#[serde(default, rename_all = "camelCase")]
103#[non_exhaustive]
104pub struct ListLocationsResponse {
105    /// A list of locations that matches the specified filter in the request.
106    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
107    pub locations: std::vec::Vec<crate::model::Location>,
108
109    /// The standard List next-page token.
110    #[serde(skip_serializing_if = "std::string::String::is_empty")]
111    pub next_page_token: std::string::String,
112
113    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
114    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
115}
116
117impl ListLocationsResponse {
118    pub fn new() -> Self {
119        std::default::Default::default()
120    }
121
122    /// Sets the value of [locations][crate::model::ListLocationsResponse::locations].
123    pub fn set_locations<T, V>(mut self, v: T) -> Self
124    where
125        T: std::iter::IntoIterator<Item = V>,
126        V: std::convert::Into<crate::model::Location>,
127    {
128        use std::iter::Iterator;
129        self.locations = v.into_iter().map(|i| i.into()).collect();
130        self
131    }
132
133    /// Sets the value of [next_page_token][crate::model::ListLocationsResponse::next_page_token].
134    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
135        self.next_page_token = v.into();
136        self
137    }
138}
139
140impl wkt::message::Message for ListLocationsResponse {
141    fn typename() -> &'static str {
142        "type.googleapis.com/google.cloud.location.ListLocationsResponse"
143    }
144}
145
146#[doc(hidden)]
147impl gax::paginator::internal::PageableResponse for ListLocationsResponse {
148    type PageItem = crate::model::Location;
149
150    fn items(self) -> std::vec::Vec<Self::PageItem> {
151        self.locations
152    }
153
154    fn next_page_token(&self) -> std::string::String {
155        use std::clone::Clone;
156        self.next_page_token.clone()
157    }
158}
159
160/// The request message for [Locations.GetLocation][google.cloud.location.Locations.GetLocation].
161///
162/// [google.cloud.location.Locations.GetLocation]: crate::client::Locations::get_location
163#[serde_with::serde_as]
164#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
165#[serde(default, rename_all = "camelCase")]
166#[non_exhaustive]
167pub struct GetLocationRequest {
168    /// Resource name for the location.
169    #[serde(skip_serializing_if = "std::string::String::is_empty")]
170    pub name: std::string::String,
171
172    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
173    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
174}
175
176impl GetLocationRequest {
177    pub fn new() -> Self {
178        std::default::Default::default()
179    }
180
181    /// Sets the value of [name][crate::model::GetLocationRequest::name].
182    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
183        self.name = v.into();
184        self
185    }
186}
187
188impl wkt::message::Message for GetLocationRequest {
189    fn typename() -> &'static str {
190        "type.googleapis.com/google.cloud.location.GetLocationRequest"
191    }
192}
193
194/// A resource that represents Google Cloud Platform location.
195#[serde_with::serde_as]
196#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
197#[serde(default, rename_all = "camelCase")]
198#[non_exhaustive]
199pub struct Location {
200    /// Resource name for the location, which may vary between implementations.
201    /// For example: `"projects/example-project/locations/us-east1"`
202    #[serde(skip_serializing_if = "std::string::String::is_empty")]
203    pub name: std::string::String,
204
205    /// The canonical id for this location. For example: `"us-east1"`.
206    #[serde(skip_serializing_if = "std::string::String::is_empty")]
207    pub location_id: std::string::String,
208
209    /// The friendly name for this location, typically a nearby city name.
210    /// For example, "Tokyo".
211    #[serde(skip_serializing_if = "std::string::String::is_empty")]
212    pub display_name: std::string::String,
213
214    /// Cross-service attributes for the location. For example
215    ///
216    /// ```norust
217    /// {"cloud.googleapis.com/region": "us-east1"}
218    /// ```
219    #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
220    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
221
222    /// Service-specific metadata. For example the available capacity at the given
223    /// location.
224    #[serde(skip_serializing_if = "std::option::Option::is_none")]
225    pub metadata: std::option::Option<wkt::Any>,
226
227    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
228    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
229}
230
231impl Location {
232    pub fn new() -> Self {
233        std::default::Default::default()
234    }
235
236    /// Sets the value of [name][crate::model::Location::name].
237    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
238        self.name = v.into();
239        self
240    }
241
242    /// Sets the value of [location_id][crate::model::Location::location_id].
243    pub fn set_location_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
244        self.location_id = v.into();
245        self
246    }
247
248    /// Sets the value of [display_name][crate::model::Location::display_name].
249    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
250        self.display_name = v.into();
251        self
252    }
253
254    /// Sets the value of [labels][crate::model::Location::labels].
255    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
256    where
257        T: std::iter::IntoIterator<Item = (K, V)>,
258        K: std::convert::Into<std::string::String>,
259        V: std::convert::Into<std::string::String>,
260    {
261        use std::iter::Iterator;
262        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
263        self
264    }
265
266    /// Sets the value of [metadata][crate::model::Location::metadata].
267    pub fn set_metadata<T: std::convert::Into<std::option::Option<wkt::Any>>>(
268        mut self,
269        v: T,
270    ) -> Self {
271        self.metadata = v.into();
272        self
273    }
274}
275
276impl wkt::message::Message for Location {
277    fn typename() -> &'static str {
278        "type.googleapis.com/google.cloud.location.Location"
279    }
280}