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