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#[derive(Clone, Debug, Default, PartialEq)]
37#[non_exhaustive]
38pub struct ListLocationsRequest {
39    /// The resource that owns the locations collection, if applicable.
40    pub name: std::string::String,
41
42    /// The standard list filter.
43    pub filter: std::string::String,
44
45    /// The standard list page size.
46    pub page_size: i32,
47
48    /// The standard list page token.
49    pub page_token: std::string::String,
50
51    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl ListLocationsRequest {
55    pub fn new() -> Self {
56        std::default::Default::default()
57    }
58
59    /// Sets the value of [name][crate::model::ListLocationsRequest::name].
60    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
61        self.name = v.into();
62        self
63    }
64
65    /// Sets the value of [filter][crate::model::ListLocationsRequest::filter].
66    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
67        self.filter = v.into();
68        self
69    }
70
71    /// Sets the value of [page_size][crate::model::ListLocationsRequest::page_size].
72    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
73        self.page_size = v.into();
74        self
75    }
76
77    /// Sets the value of [page_token][crate::model::ListLocationsRequest::page_token].
78    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
79        self.page_token = v.into();
80        self
81    }
82}
83
84impl wkt::message::Message for ListLocationsRequest {
85    fn typename() -> &'static str {
86        "type.googleapis.com/google.cloud.location.ListLocationsRequest"
87    }
88}
89
90#[doc(hidden)]
91impl<'de> serde::de::Deserialize<'de> for ListLocationsRequest {
92    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
93    where
94        D: serde::Deserializer<'de>,
95    {
96        #[allow(non_camel_case_types)]
97        #[doc(hidden)]
98        #[derive(PartialEq, Eq, Hash)]
99        enum __FieldTag {
100            __name,
101            __filter,
102            __page_size,
103            __page_token,
104            Unknown(std::string::String),
105        }
106        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
107            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
108            where
109                D: serde::Deserializer<'de>,
110            {
111                struct Visitor;
112                impl<'de> serde::de::Visitor<'de> for Visitor {
113                    type Value = __FieldTag;
114                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
115                        formatter.write_str("a field name for ListLocationsRequest")
116                    }
117                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
118                    where
119                        E: serde::de::Error,
120                    {
121                        use std::result::Result::Ok;
122                        use std::string::ToString;
123                        match value {
124                            "name" => Ok(__FieldTag::__name),
125                            "filter" => Ok(__FieldTag::__filter),
126                            "pageSize" => Ok(__FieldTag::__page_size),
127                            "page_size" => Ok(__FieldTag::__page_size),
128                            "pageToken" => Ok(__FieldTag::__page_token),
129                            "page_token" => Ok(__FieldTag::__page_token),
130                            _ => Ok(__FieldTag::Unknown(value.to_string())),
131                        }
132                    }
133                }
134                deserializer.deserialize_identifier(Visitor)
135            }
136        }
137        struct Visitor;
138        impl<'de> serde::de::Visitor<'de> for Visitor {
139            type Value = ListLocationsRequest;
140            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
141                formatter.write_str("struct ListLocationsRequest")
142            }
143            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
144            where
145                A: serde::de::MapAccess<'de>,
146            {
147                #[allow(unused_imports)]
148                use serde::de::Error;
149                use std::option::Option::Some;
150                let mut fields = std::collections::HashSet::new();
151                let mut result = Self::Value::new();
152                while let Some(tag) = map.next_key::<__FieldTag>()? {
153                    #[allow(clippy::match_single_binding)]
154                    match tag {
155                        __FieldTag::__name => {
156                            if !fields.insert(__FieldTag::__name) {
157                                return std::result::Result::Err(A::Error::duplicate_field(
158                                    "multiple values for name",
159                                ));
160                            }
161                            result.name = map
162                                .next_value::<std::option::Option<std::string::String>>()?
163                                .unwrap_or_default();
164                        }
165                        __FieldTag::__filter => {
166                            if !fields.insert(__FieldTag::__filter) {
167                                return std::result::Result::Err(A::Error::duplicate_field(
168                                    "multiple values for filter",
169                                ));
170                            }
171                            result.filter = map
172                                .next_value::<std::option::Option<std::string::String>>()?
173                                .unwrap_or_default();
174                        }
175                        __FieldTag::__page_size => {
176                            if !fields.insert(__FieldTag::__page_size) {
177                                return std::result::Result::Err(A::Error::duplicate_field(
178                                    "multiple values for page_size",
179                                ));
180                            }
181                            struct __With(std::option::Option<i32>);
182                            impl<'de> serde::de::Deserialize<'de> for __With {
183                                fn deserialize<D>(
184                                    deserializer: D,
185                                ) -> std::result::Result<Self, D::Error>
186                                where
187                                    D: serde::de::Deserializer<'de>,
188                                {
189                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
190                                }
191                            }
192                            result.page_size = map.next_value::<__With>()?.0.unwrap_or_default();
193                        }
194                        __FieldTag::__page_token => {
195                            if !fields.insert(__FieldTag::__page_token) {
196                                return std::result::Result::Err(A::Error::duplicate_field(
197                                    "multiple values for page_token",
198                                ));
199                            }
200                            result.page_token = map
201                                .next_value::<std::option::Option<std::string::String>>()?
202                                .unwrap_or_default();
203                        }
204                        __FieldTag::Unknown(key) => {
205                            let value = map.next_value::<serde_json::Value>()?;
206                            result._unknown_fields.insert(key, value);
207                        }
208                    }
209                }
210                std::result::Result::Ok(result)
211            }
212        }
213        deserializer.deserialize_any(Visitor)
214    }
215}
216
217#[doc(hidden)]
218impl serde::ser::Serialize for ListLocationsRequest {
219    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
220    where
221        S: serde::ser::Serializer,
222    {
223        use serde::ser::SerializeMap;
224        #[allow(unused_imports)]
225        use std::option::Option::Some;
226        let mut state = serializer.serialize_map(std::option::Option::None)?;
227        if !self.name.is_empty() {
228            state.serialize_entry("name", &self.name)?;
229        }
230        if !self.filter.is_empty() {
231            state.serialize_entry("filter", &self.filter)?;
232        }
233        if !wkt::internal::is_default(&self.page_size) {
234            struct __With<'a>(&'a i32);
235            impl<'a> serde::ser::Serialize for __With<'a> {
236                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
237                where
238                    S: serde::ser::Serializer,
239                {
240                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
241                }
242            }
243            state.serialize_entry("pageSize", &__With(&self.page_size))?;
244        }
245        if !self.page_token.is_empty() {
246            state.serialize_entry("pageToken", &self.page_token)?;
247        }
248        if !self._unknown_fields.is_empty() {
249            for (key, value) in self._unknown_fields.iter() {
250                state.serialize_entry(key, &value)?;
251            }
252        }
253        state.end()
254    }
255}
256
257/// The response message for [Locations.ListLocations][google.cloud.location.Locations.ListLocations].
258///
259/// [google.cloud.location.Locations.ListLocations]: crate::client::Locations::list_locations
260#[derive(Clone, Debug, Default, PartialEq)]
261#[non_exhaustive]
262pub struct ListLocationsResponse {
263    /// A list of locations that matches the specified filter in the request.
264    pub locations: std::vec::Vec<crate::model::Location>,
265
266    /// The standard List next-page token.
267    pub next_page_token: std::string::String,
268
269    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
270}
271
272impl ListLocationsResponse {
273    pub fn new() -> Self {
274        std::default::Default::default()
275    }
276
277    /// Sets the value of [locations][crate::model::ListLocationsResponse::locations].
278    pub fn set_locations<T, V>(mut self, v: T) -> Self
279    where
280        T: std::iter::IntoIterator<Item = V>,
281        V: std::convert::Into<crate::model::Location>,
282    {
283        use std::iter::Iterator;
284        self.locations = v.into_iter().map(|i| i.into()).collect();
285        self
286    }
287
288    /// Sets the value of [next_page_token][crate::model::ListLocationsResponse::next_page_token].
289    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
290        self.next_page_token = v.into();
291        self
292    }
293}
294
295impl wkt::message::Message for ListLocationsResponse {
296    fn typename() -> &'static str {
297        "type.googleapis.com/google.cloud.location.ListLocationsResponse"
298    }
299}
300
301#[doc(hidden)]
302impl gax::paginator::internal::PageableResponse for ListLocationsResponse {
303    type PageItem = crate::model::Location;
304
305    fn items(self) -> std::vec::Vec<Self::PageItem> {
306        self.locations
307    }
308
309    fn next_page_token(&self) -> std::string::String {
310        use std::clone::Clone;
311        self.next_page_token.clone()
312    }
313}
314
315#[doc(hidden)]
316impl<'de> serde::de::Deserialize<'de> for ListLocationsResponse {
317    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
318    where
319        D: serde::Deserializer<'de>,
320    {
321        #[allow(non_camel_case_types)]
322        #[doc(hidden)]
323        #[derive(PartialEq, Eq, Hash)]
324        enum __FieldTag {
325            __locations,
326            __next_page_token,
327            Unknown(std::string::String),
328        }
329        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
330            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
331            where
332                D: serde::Deserializer<'de>,
333            {
334                struct Visitor;
335                impl<'de> serde::de::Visitor<'de> for Visitor {
336                    type Value = __FieldTag;
337                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
338                        formatter.write_str("a field name for ListLocationsResponse")
339                    }
340                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
341                    where
342                        E: serde::de::Error,
343                    {
344                        use std::result::Result::Ok;
345                        use std::string::ToString;
346                        match value {
347                            "locations" => Ok(__FieldTag::__locations),
348                            "nextPageToken" => Ok(__FieldTag::__next_page_token),
349                            "next_page_token" => Ok(__FieldTag::__next_page_token),
350                            _ => Ok(__FieldTag::Unknown(value.to_string())),
351                        }
352                    }
353                }
354                deserializer.deserialize_identifier(Visitor)
355            }
356        }
357        struct Visitor;
358        impl<'de> serde::de::Visitor<'de> for Visitor {
359            type Value = ListLocationsResponse;
360            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
361                formatter.write_str("struct ListLocationsResponse")
362            }
363            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
364            where
365                A: serde::de::MapAccess<'de>,
366            {
367                #[allow(unused_imports)]
368                use serde::de::Error;
369                use std::option::Option::Some;
370                let mut fields = std::collections::HashSet::new();
371                let mut result = Self::Value::new();
372                while let Some(tag) = map.next_key::<__FieldTag>()? {
373                    #[allow(clippy::match_single_binding)]
374                    match tag {
375                        __FieldTag::__locations => {
376                            if !fields.insert(__FieldTag::__locations) {
377                                return std::result::Result::Err(A::Error::duplicate_field(
378                                    "multiple values for locations",
379                                ));
380                            }
381                            result.locations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Location>>>()?.unwrap_or_default();
382                        }
383                        __FieldTag::__next_page_token => {
384                            if !fields.insert(__FieldTag::__next_page_token) {
385                                return std::result::Result::Err(A::Error::duplicate_field(
386                                    "multiple values for next_page_token",
387                                ));
388                            }
389                            result.next_page_token = map
390                                .next_value::<std::option::Option<std::string::String>>()?
391                                .unwrap_or_default();
392                        }
393                        __FieldTag::Unknown(key) => {
394                            let value = map.next_value::<serde_json::Value>()?;
395                            result._unknown_fields.insert(key, value);
396                        }
397                    }
398                }
399                std::result::Result::Ok(result)
400            }
401        }
402        deserializer.deserialize_any(Visitor)
403    }
404}
405
406#[doc(hidden)]
407impl serde::ser::Serialize for ListLocationsResponse {
408    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
409    where
410        S: serde::ser::Serializer,
411    {
412        use serde::ser::SerializeMap;
413        #[allow(unused_imports)]
414        use std::option::Option::Some;
415        let mut state = serializer.serialize_map(std::option::Option::None)?;
416        if !self.locations.is_empty() {
417            state.serialize_entry("locations", &self.locations)?;
418        }
419        if !self.next_page_token.is_empty() {
420            state.serialize_entry("nextPageToken", &self.next_page_token)?;
421        }
422        if !self._unknown_fields.is_empty() {
423            for (key, value) in self._unknown_fields.iter() {
424                state.serialize_entry(key, &value)?;
425            }
426        }
427        state.end()
428    }
429}
430
431/// The request message for [Locations.GetLocation][google.cloud.location.Locations.GetLocation].
432///
433/// [google.cloud.location.Locations.GetLocation]: crate::client::Locations::get_location
434#[derive(Clone, Debug, Default, PartialEq)]
435#[non_exhaustive]
436pub struct GetLocationRequest {
437    /// Resource name for the location.
438    pub name: std::string::String,
439
440    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
441}
442
443impl GetLocationRequest {
444    pub fn new() -> Self {
445        std::default::Default::default()
446    }
447
448    /// Sets the value of [name][crate::model::GetLocationRequest::name].
449    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
450        self.name = v.into();
451        self
452    }
453}
454
455impl wkt::message::Message for GetLocationRequest {
456    fn typename() -> &'static str {
457        "type.googleapis.com/google.cloud.location.GetLocationRequest"
458    }
459}
460
461#[doc(hidden)]
462impl<'de> serde::de::Deserialize<'de> for GetLocationRequest {
463    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
464    where
465        D: serde::Deserializer<'de>,
466    {
467        #[allow(non_camel_case_types)]
468        #[doc(hidden)]
469        #[derive(PartialEq, Eq, Hash)]
470        enum __FieldTag {
471            __name,
472            Unknown(std::string::String),
473        }
474        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
475            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
476            where
477                D: serde::Deserializer<'de>,
478            {
479                struct Visitor;
480                impl<'de> serde::de::Visitor<'de> for Visitor {
481                    type Value = __FieldTag;
482                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
483                        formatter.write_str("a field name for GetLocationRequest")
484                    }
485                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
486                    where
487                        E: serde::de::Error,
488                    {
489                        use std::result::Result::Ok;
490                        use std::string::ToString;
491                        match value {
492                            "name" => Ok(__FieldTag::__name),
493                            _ => Ok(__FieldTag::Unknown(value.to_string())),
494                        }
495                    }
496                }
497                deserializer.deserialize_identifier(Visitor)
498            }
499        }
500        struct Visitor;
501        impl<'de> serde::de::Visitor<'de> for Visitor {
502            type Value = GetLocationRequest;
503            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
504                formatter.write_str("struct GetLocationRequest")
505            }
506            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
507            where
508                A: serde::de::MapAccess<'de>,
509            {
510                #[allow(unused_imports)]
511                use serde::de::Error;
512                use std::option::Option::Some;
513                let mut fields = std::collections::HashSet::new();
514                let mut result = Self::Value::new();
515                while let Some(tag) = map.next_key::<__FieldTag>()? {
516                    #[allow(clippy::match_single_binding)]
517                    match tag {
518                        __FieldTag::__name => {
519                            if !fields.insert(__FieldTag::__name) {
520                                return std::result::Result::Err(A::Error::duplicate_field(
521                                    "multiple values for name",
522                                ));
523                            }
524                            result.name = map
525                                .next_value::<std::option::Option<std::string::String>>()?
526                                .unwrap_or_default();
527                        }
528                        __FieldTag::Unknown(key) => {
529                            let value = map.next_value::<serde_json::Value>()?;
530                            result._unknown_fields.insert(key, value);
531                        }
532                    }
533                }
534                std::result::Result::Ok(result)
535            }
536        }
537        deserializer.deserialize_any(Visitor)
538    }
539}
540
541#[doc(hidden)]
542impl serde::ser::Serialize for GetLocationRequest {
543    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
544    where
545        S: serde::ser::Serializer,
546    {
547        use serde::ser::SerializeMap;
548        #[allow(unused_imports)]
549        use std::option::Option::Some;
550        let mut state = serializer.serialize_map(std::option::Option::None)?;
551        if !self.name.is_empty() {
552            state.serialize_entry("name", &self.name)?;
553        }
554        if !self._unknown_fields.is_empty() {
555            for (key, value) in self._unknown_fields.iter() {
556                state.serialize_entry(key, &value)?;
557            }
558        }
559        state.end()
560    }
561}
562
563/// A resource that represents Google Cloud Platform location.
564#[derive(Clone, Debug, Default, PartialEq)]
565#[non_exhaustive]
566pub struct Location {
567    /// Resource name for the location, which may vary between implementations.
568    /// For example: `"projects/example-project/locations/us-east1"`
569    pub name: std::string::String,
570
571    /// The canonical id for this location. For example: `"us-east1"`.
572    pub location_id: std::string::String,
573
574    /// The friendly name for this location, typically a nearby city name.
575    /// For example, "Tokyo".
576    pub display_name: std::string::String,
577
578    /// Cross-service attributes for the location. For example
579    ///
580    /// ```norust
581    /// {"cloud.googleapis.com/region": "us-east1"}
582    /// ```
583    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
584
585    /// Service-specific metadata. For example the available capacity at the given
586    /// location.
587    pub metadata: std::option::Option<wkt::Any>,
588
589    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
590}
591
592impl Location {
593    pub fn new() -> Self {
594        std::default::Default::default()
595    }
596
597    /// Sets the value of [name][crate::model::Location::name].
598    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
599        self.name = v.into();
600        self
601    }
602
603    /// Sets the value of [location_id][crate::model::Location::location_id].
604    pub fn set_location_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
605        self.location_id = v.into();
606        self
607    }
608
609    /// Sets the value of [display_name][crate::model::Location::display_name].
610    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
611        self.display_name = v.into();
612        self
613    }
614
615    /// Sets the value of [labels][crate::model::Location::labels].
616    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
617    where
618        T: std::iter::IntoIterator<Item = (K, V)>,
619        K: std::convert::Into<std::string::String>,
620        V: std::convert::Into<std::string::String>,
621    {
622        use std::iter::Iterator;
623        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
624        self
625    }
626
627    /// Sets the value of [metadata][crate::model::Location::metadata].
628    pub fn set_metadata<T>(mut self, v: T) -> Self
629    where
630        T: std::convert::Into<wkt::Any>,
631    {
632        self.metadata = std::option::Option::Some(v.into());
633        self
634    }
635
636    /// Sets or clears the value of [metadata][crate::model::Location::metadata].
637    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
638    where
639        T: std::convert::Into<wkt::Any>,
640    {
641        self.metadata = v.map(|x| x.into());
642        self
643    }
644}
645
646impl wkt::message::Message for Location {
647    fn typename() -> &'static str {
648        "type.googleapis.com/google.cloud.location.Location"
649    }
650}
651
652#[doc(hidden)]
653impl<'de> serde::de::Deserialize<'de> for Location {
654    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
655    where
656        D: serde::Deserializer<'de>,
657    {
658        #[allow(non_camel_case_types)]
659        #[doc(hidden)]
660        #[derive(PartialEq, Eq, Hash)]
661        enum __FieldTag {
662            __name,
663            __location_id,
664            __display_name,
665            __labels,
666            __metadata,
667            Unknown(std::string::String),
668        }
669        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
670            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
671            where
672                D: serde::Deserializer<'de>,
673            {
674                struct Visitor;
675                impl<'de> serde::de::Visitor<'de> for Visitor {
676                    type Value = __FieldTag;
677                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
678                        formatter.write_str("a field name for Location")
679                    }
680                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
681                    where
682                        E: serde::de::Error,
683                    {
684                        use std::result::Result::Ok;
685                        use std::string::ToString;
686                        match value {
687                            "name" => Ok(__FieldTag::__name),
688                            "locationId" => Ok(__FieldTag::__location_id),
689                            "location_id" => Ok(__FieldTag::__location_id),
690                            "displayName" => Ok(__FieldTag::__display_name),
691                            "display_name" => Ok(__FieldTag::__display_name),
692                            "labels" => Ok(__FieldTag::__labels),
693                            "metadata" => Ok(__FieldTag::__metadata),
694                            _ => Ok(__FieldTag::Unknown(value.to_string())),
695                        }
696                    }
697                }
698                deserializer.deserialize_identifier(Visitor)
699            }
700        }
701        struct Visitor;
702        impl<'de> serde::de::Visitor<'de> for Visitor {
703            type Value = Location;
704            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
705                formatter.write_str("struct Location")
706            }
707            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
708            where
709                A: serde::de::MapAccess<'de>,
710            {
711                #[allow(unused_imports)]
712                use serde::de::Error;
713                use std::option::Option::Some;
714                let mut fields = std::collections::HashSet::new();
715                let mut result = Self::Value::new();
716                while let Some(tag) = map.next_key::<__FieldTag>()? {
717                    #[allow(clippy::match_single_binding)]
718                    match tag {
719                        __FieldTag::__name => {
720                            if !fields.insert(__FieldTag::__name) {
721                                return std::result::Result::Err(A::Error::duplicate_field(
722                                    "multiple values for name",
723                                ));
724                            }
725                            result.name = map
726                                .next_value::<std::option::Option<std::string::String>>()?
727                                .unwrap_or_default();
728                        }
729                        __FieldTag::__location_id => {
730                            if !fields.insert(__FieldTag::__location_id) {
731                                return std::result::Result::Err(A::Error::duplicate_field(
732                                    "multiple values for location_id",
733                                ));
734                            }
735                            result.location_id = map
736                                .next_value::<std::option::Option<std::string::String>>()?
737                                .unwrap_or_default();
738                        }
739                        __FieldTag::__display_name => {
740                            if !fields.insert(__FieldTag::__display_name) {
741                                return std::result::Result::Err(A::Error::duplicate_field(
742                                    "multiple values for display_name",
743                                ));
744                            }
745                            result.display_name = map
746                                .next_value::<std::option::Option<std::string::String>>()?
747                                .unwrap_or_default();
748                        }
749                        __FieldTag::__labels => {
750                            if !fields.insert(__FieldTag::__labels) {
751                                return std::result::Result::Err(A::Error::duplicate_field(
752                                    "multiple values for labels",
753                                ));
754                            }
755                            result.labels = map
756                                .next_value::<std::option::Option<
757                                    std::collections::HashMap<
758                                        std::string::String,
759                                        std::string::String,
760                                    >,
761                                >>()?
762                                .unwrap_or_default();
763                        }
764                        __FieldTag::__metadata => {
765                            if !fields.insert(__FieldTag::__metadata) {
766                                return std::result::Result::Err(A::Error::duplicate_field(
767                                    "multiple values for metadata",
768                                ));
769                            }
770                            result.metadata = map.next_value::<std::option::Option<wkt::Any>>()?;
771                        }
772                        __FieldTag::Unknown(key) => {
773                            let value = map.next_value::<serde_json::Value>()?;
774                            result._unknown_fields.insert(key, value);
775                        }
776                    }
777                }
778                std::result::Result::Ok(result)
779            }
780        }
781        deserializer.deserialize_any(Visitor)
782    }
783}
784
785#[doc(hidden)]
786impl serde::ser::Serialize for Location {
787    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
788    where
789        S: serde::ser::Serializer,
790    {
791        use serde::ser::SerializeMap;
792        #[allow(unused_imports)]
793        use std::option::Option::Some;
794        let mut state = serializer.serialize_map(std::option::Option::None)?;
795        if !self.name.is_empty() {
796            state.serialize_entry("name", &self.name)?;
797        }
798        if !self.location_id.is_empty() {
799            state.serialize_entry("locationId", &self.location_id)?;
800        }
801        if !self.display_name.is_empty() {
802            state.serialize_entry("displayName", &self.display_name)?;
803        }
804        if !self.labels.is_empty() {
805            state.serialize_entry("labels", &self.labels)?;
806        }
807        if self.metadata.is_some() {
808            state.serialize_entry("metadata", &self.metadata)?;
809        }
810        if !self._unknown_fields.is_empty() {
811            for (key, value) in self._unknown_fields.iter() {
812                state.serialize_entry(key, &value)?;
813            }
814        }
815        state.end()
816    }
817}