google_cloud_api/
model.rs

1// Copyright 2025 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 bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27/// `Authentication` defines the authentication configuration for API methods
28/// provided by an API service.
29///
30/// Example:
31///
32/// ```norust
33/// name: calendar.googleapis.com
34/// authentication:
35///   providers:
36///   - id: google_calendar_auth
37///     jwks_uri: https://www.googleapis.com/oauth2/v1/certs
38///     issuer: https://securetoken.google.com
39///   rules:
40///   - selector: "*"
41///     requirements:
42///       provider_id: google_calendar_auth
43///   - selector: google.calendar.Delegate
44///     oauth:
45///       canonical_scopes: https://www.googleapis.com/auth/calendar.read
46/// ```
47#[derive(Clone, Default, PartialEq)]
48#[non_exhaustive]
49pub struct Authentication {
50    /// A list of authentication rules that apply to individual API methods.
51    ///
52    /// **NOTE:** All service configuration rules follow "last one wins" order.
53    pub rules: std::vec::Vec<crate::model::AuthenticationRule>,
54
55    /// Defines a set of authentication providers that a service supports.
56    pub providers: std::vec::Vec<crate::model::AuthProvider>,
57
58    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
59}
60
61impl Authentication {
62    pub fn new() -> Self {
63        std::default::Default::default()
64    }
65
66    /// Sets the value of [rules][crate::model::Authentication::rules].
67    pub fn set_rules<T, V>(mut self, v: T) -> Self
68    where
69        T: std::iter::IntoIterator<Item = V>,
70        V: std::convert::Into<crate::model::AuthenticationRule>,
71    {
72        use std::iter::Iterator;
73        self.rules = v.into_iter().map(|i| i.into()).collect();
74        self
75    }
76
77    /// Sets the value of [providers][crate::model::Authentication::providers].
78    pub fn set_providers<T, V>(mut self, v: T) -> Self
79    where
80        T: std::iter::IntoIterator<Item = V>,
81        V: std::convert::Into<crate::model::AuthProvider>,
82    {
83        use std::iter::Iterator;
84        self.providers = v.into_iter().map(|i| i.into()).collect();
85        self
86    }
87}
88
89impl wkt::message::Message for Authentication {
90    fn typename() -> &'static str {
91        "type.googleapis.com/google.api.Authentication"
92    }
93}
94
95#[doc(hidden)]
96impl<'de> serde::de::Deserialize<'de> for Authentication {
97    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
98    where
99        D: serde::Deserializer<'de>,
100    {
101        #[allow(non_camel_case_types)]
102        #[doc(hidden)]
103        #[derive(PartialEq, Eq, Hash)]
104        enum __FieldTag {
105            __rules,
106            __providers,
107            Unknown(std::string::String),
108        }
109        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
110            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
111            where
112                D: serde::Deserializer<'de>,
113            {
114                struct Visitor;
115                impl<'de> serde::de::Visitor<'de> for Visitor {
116                    type Value = __FieldTag;
117                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
118                        formatter.write_str("a field name for Authentication")
119                    }
120                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
121                    where
122                        E: serde::de::Error,
123                    {
124                        use std::result::Result::Ok;
125                        use std::string::ToString;
126                        match value {
127                            "rules" => Ok(__FieldTag::__rules),
128                            "providers" => Ok(__FieldTag::__providers),
129                            _ => Ok(__FieldTag::Unknown(value.to_string())),
130                        }
131                    }
132                }
133                deserializer.deserialize_identifier(Visitor)
134            }
135        }
136        struct Visitor;
137        impl<'de> serde::de::Visitor<'de> for Visitor {
138            type Value = Authentication;
139            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
140                formatter.write_str("struct Authentication")
141            }
142            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
143            where
144                A: serde::de::MapAccess<'de>,
145            {
146                #[allow(unused_imports)]
147                use serde::de::Error;
148                use std::option::Option::Some;
149                let mut fields = std::collections::HashSet::new();
150                let mut result = Self::Value::new();
151                while let Some(tag) = map.next_key::<__FieldTag>()? {
152                    #[allow(clippy::match_single_binding)]
153                    match tag {
154                        __FieldTag::__rules => {
155                            if !fields.insert(__FieldTag::__rules) {
156                                return std::result::Result::Err(A::Error::duplicate_field(
157                                    "multiple values for rules",
158                                ));
159                            }
160                            result.rules = map
161                                .next_value::<std::option::Option<
162                                    std::vec::Vec<crate::model::AuthenticationRule>,
163                                >>()?
164                                .unwrap_or_default();
165                        }
166                        __FieldTag::__providers => {
167                            if !fields.insert(__FieldTag::__providers) {
168                                return std::result::Result::Err(A::Error::duplicate_field(
169                                    "multiple values for providers",
170                                ));
171                            }
172                            result.providers = map.next_value::<std::option::Option<std::vec::Vec<crate::model::AuthProvider>>>()?.unwrap_or_default();
173                        }
174                        __FieldTag::Unknown(key) => {
175                            let value = map.next_value::<serde_json::Value>()?;
176                            result._unknown_fields.insert(key, value);
177                        }
178                    }
179                }
180                std::result::Result::Ok(result)
181            }
182        }
183        deserializer.deserialize_any(Visitor)
184    }
185}
186
187#[doc(hidden)]
188impl serde::ser::Serialize for Authentication {
189    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
190    where
191        S: serde::ser::Serializer,
192    {
193        use serde::ser::SerializeMap;
194        #[allow(unused_imports)]
195        use std::option::Option::Some;
196        let mut state = serializer.serialize_map(std::option::Option::None)?;
197        if !self.rules.is_empty() {
198            state.serialize_entry("rules", &self.rules)?;
199        }
200        if !self.providers.is_empty() {
201            state.serialize_entry("providers", &self.providers)?;
202        }
203        if !self._unknown_fields.is_empty() {
204            for (key, value) in self._unknown_fields.iter() {
205                state.serialize_entry(key, &value)?;
206            }
207        }
208        state.end()
209    }
210}
211
212impl std::fmt::Debug for Authentication {
213    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
214        let mut debug_struct = f.debug_struct("Authentication");
215        debug_struct.field("rules", &self.rules);
216        debug_struct.field("providers", &self.providers);
217        if !self._unknown_fields.is_empty() {
218            debug_struct.field("_unknown_fields", &self._unknown_fields);
219        }
220        debug_struct.finish()
221    }
222}
223
224/// Authentication rules for the service.
225///
226/// By default, if a method has any authentication requirements, every request
227/// must include a valid credential matching one of the requirements.
228/// It's an error to include more than one kind of credential in a single
229/// request.
230///
231/// If a method doesn't have any auth requirements, request credentials will be
232/// ignored.
233#[derive(Clone, Default, PartialEq)]
234#[non_exhaustive]
235pub struct AuthenticationRule {
236    /// Selects the methods to which this rule applies.
237    ///
238    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
239    /// details.
240    ///
241    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
242    pub selector: std::string::String,
243
244    /// The requirements for OAuth credentials.
245    pub oauth: std::option::Option<crate::model::OAuthRequirements>,
246
247    /// If true, the service accepts API keys without any other credential.
248    /// This flag only applies to HTTP and gRPC requests.
249    pub allow_without_credential: bool,
250
251    /// Requirements for additional authentication providers.
252    pub requirements: std::vec::Vec<crate::model::AuthRequirement>,
253
254    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
255}
256
257impl AuthenticationRule {
258    pub fn new() -> Self {
259        std::default::Default::default()
260    }
261
262    /// Sets the value of [selector][crate::model::AuthenticationRule::selector].
263    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
264        self.selector = v.into();
265        self
266    }
267
268    /// Sets the value of [oauth][crate::model::AuthenticationRule::oauth].
269    pub fn set_oauth<T>(mut self, v: T) -> Self
270    where
271        T: std::convert::Into<crate::model::OAuthRequirements>,
272    {
273        self.oauth = std::option::Option::Some(v.into());
274        self
275    }
276
277    /// Sets or clears the value of [oauth][crate::model::AuthenticationRule::oauth].
278    pub fn set_or_clear_oauth<T>(mut self, v: std::option::Option<T>) -> Self
279    where
280        T: std::convert::Into<crate::model::OAuthRequirements>,
281    {
282        self.oauth = v.map(|x| x.into());
283        self
284    }
285
286    /// Sets the value of [allow_without_credential][crate::model::AuthenticationRule::allow_without_credential].
287    pub fn set_allow_without_credential<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
288        self.allow_without_credential = v.into();
289        self
290    }
291
292    /// Sets the value of [requirements][crate::model::AuthenticationRule::requirements].
293    pub fn set_requirements<T, V>(mut self, v: T) -> Self
294    where
295        T: std::iter::IntoIterator<Item = V>,
296        V: std::convert::Into<crate::model::AuthRequirement>,
297    {
298        use std::iter::Iterator;
299        self.requirements = v.into_iter().map(|i| i.into()).collect();
300        self
301    }
302}
303
304impl wkt::message::Message for AuthenticationRule {
305    fn typename() -> &'static str {
306        "type.googleapis.com/google.api.AuthenticationRule"
307    }
308}
309
310#[doc(hidden)]
311impl<'de> serde::de::Deserialize<'de> for AuthenticationRule {
312    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
313    where
314        D: serde::Deserializer<'de>,
315    {
316        #[allow(non_camel_case_types)]
317        #[doc(hidden)]
318        #[derive(PartialEq, Eq, Hash)]
319        enum __FieldTag {
320            __selector,
321            __oauth,
322            __allow_without_credential,
323            __requirements,
324            Unknown(std::string::String),
325        }
326        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
327            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
328            where
329                D: serde::Deserializer<'de>,
330            {
331                struct Visitor;
332                impl<'de> serde::de::Visitor<'de> for Visitor {
333                    type Value = __FieldTag;
334                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
335                        formatter.write_str("a field name for AuthenticationRule")
336                    }
337                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
338                    where
339                        E: serde::de::Error,
340                    {
341                        use std::result::Result::Ok;
342                        use std::string::ToString;
343                        match value {
344                            "selector" => Ok(__FieldTag::__selector),
345                            "oauth" => Ok(__FieldTag::__oauth),
346                            "allowWithoutCredential" => Ok(__FieldTag::__allow_without_credential),
347                            "allow_without_credential" => {
348                                Ok(__FieldTag::__allow_without_credential)
349                            }
350                            "requirements" => Ok(__FieldTag::__requirements),
351                            _ => Ok(__FieldTag::Unknown(value.to_string())),
352                        }
353                    }
354                }
355                deserializer.deserialize_identifier(Visitor)
356            }
357        }
358        struct Visitor;
359        impl<'de> serde::de::Visitor<'de> for Visitor {
360            type Value = AuthenticationRule;
361            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
362                formatter.write_str("struct AuthenticationRule")
363            }
364            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
365            where
366                A: serde::de::MapAccess<'de>,
367            {
368                #[allow(unused_imports)]
369                use serde::de::Error;
370                use std::option::Option::Some;
371                let mut fields = std::collections::HashSet::new();
372                let mut result = Self::Value::new();
373                while let Some(tag) = map.next_key::<__FieldTag>()? {
374                    #[allow(clippy::match_single_binding)]
375                    match tag {
376                        __FieldTag::__selector => {
377                            if !fields.insert(__FieldTag::__selector) {
378                                return std::result::Result::Err(A::Error::duplicate_field(
379                                    "multiple values for selector",
380                                ));
381                            }
382                            result.selector = map
383                                .next_value::<std::option::Option<std::string::String>>()?
384                                .unwrap_or_default();
385                        }
386                        __FieldTag::__oauth => {
387                            if !fields.insert(__FieldTag::__oauth) {
388                                return std::result::Result::Err(A::Error::duplicate_field(
389                                    "multiple values for oauth",
390                                ));
391                            }
392                            result.oauth = map
393                                .next_value::<std::option::Option<crate::model::OAuthRequirements>>(
394                                )?;
395                        }
396                        __FieldTag::__allow_without_credential => {
397                            if !fields.insert(__FieldTag::__allow_without_credential) {
398                                return std::result::Result::Err(A::Error::duplicate_field(
399                                    "multiple values for allow_without_credential",
400                                ));
401                            }
402                            result.allow_without_credential = map
403                                .next_value::<std::option::Option<bool>>()?
404                                .unwrap_or_default();
405                        }
406                        __FieldTag::__requirements => {
407                            if !fields.insert(__FieldTag::__requirements) {
408                                return std::result::Result::Err(A::Error::duplicate_field(
409                                    "multiple values for requirements",
410                                ));
411                            }
412                            result.requirements =
413                                map.next_value::<std::option::Option<
414                                    std::vec::Vec<crate::model::AuthRequirement>,
415                                >>()?
416                                .unwrap_or_default();
417                        }
418                        __FieldTag::Unknown(key) => {
419                            let value = map.next_value::<serde_json::Value>()?;
420                            result._unknown_fields.insert(key, value);
421                        }
422                    }
423                }
424                std::result::Result::Ok(result)
425            }
426        }
427        deserializer.deserialize_any(Visitor)
428    }
429}
430
431#[doc(hidden)]
432impl serde::ser::Serialize for AuthenticationRule {
433    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
434    where
435        S: serde::ser::Serializer,
436    {
437        use serde::ser::SerializeMap;
438        #[allow(unused_imports)]
439        use std::option::Option::Some;
440        let mut state = serializer.serialize_map(std::option::Option::None)?;
441        if !self.selector.is_empty() {
442            state.serialize_entry("selector", &self.selector)?;
443        }
444        if self.oauth.is_some() {
445            state.serialize_entry("oauth", &self.oauth)?;
446        }
447        if !wkt::internal::is_default(&self.allow_without_credential) {
448            state.serialize_entry("allowWithoutCredential", &self.allow_without_credential)?;
449        }
450        if !self.requirements.is_empty() {
451            state.serialize_entry("requirements", &self.requirements)?;
452        }
453        if !self._unknown_fields.is_empty() {
454            for (key, value) in self._unknown_fields.iter() {
455                state.serialize_entry(key, &value)?;
456            }
457        }
458        state.end()
459    }
460}
461
462impl std::fmt::Debug for AuthenticationRule {
463    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
464        let mut debug_struct = f.debug_struct("AuthenticationRule");
465        debug_struct.field("selector", &self.selector);
466        debug_struct.field("oauth", &self.oauth);
467        debug_struct.field("allow_without_credential", &self.allow_without_credential);
468        debug_struct.field("requirements", &self.requirements);
469        if !self._unknown_fields.is_empty() {
470            debug_struct.field("_unknown_fields", &self._unknown_fields);
471        }
472        debug_struct.finish()
473    }
474}
475
476/// Specifies a location to extract JWT from an API request.
477#[derive(Clone, Default, PartialEq)]
478#[non_exhaustive]
479pub struct JwtLocation {
480    /// The value prefix. The value format is "value_prefix{token}"
481    /// Only applies to "in" header type. Must be empty for "in" query type.
482    /// If not empty, the header value has to match (case sensitive) this prefix.
483    /// If not matched, JWT will not be extracted. If matched, JWT will be
484    /// extracted after the prefix is removed.
485    ///
486    /// For example, for "Authorization: Bearer {JWT}",
487    /// value_prefix="Bearer " with a space at the end.
488    pub value_prefix: std::string::String,
489
490    pub r#in: std::option::Option<crate::model::jwt_location::In>,
491
492    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
493}
494
495impl JwtLocation {
496    pub fn new() -> Self {
497        std::default::Default::default()
498    }
499
500    /// Sets the value of [value_prefix][crate::model::JwtLocation::value_prefix].
501    pub fn set_value_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
502        self.value_prefix = v.into();
503        self
504    }
505
506    /// Sets the value of [r#in][crate::model::JwtLocation::in].
507    ///
508    /// Note that all the setters affecting `r#in` are mutually
509    /// exclusive.
510    pub fn set_in<T: std::convert::Into<std::option::Option<crate::model::jwt_location::In>>>(
511        mut self,
512        v: T,
513    ) -> Self {
514        self.r#in = v.into();
515        self
516    }
517
518    /// The value of [r#in][crate::model::JwtLocation::r#in]
519    /// if it holds a `Header`, `None` if the field is not set or
520    /// holds a different branch.
521    pub fn header(&self) -> std::option::Option<&std::string::String> {
522        #[allow(unreachable_patterns)]
523        self.r#in.as_ref().and_then(|v| match v {
524            crate::model::jwt_location::In::Header(v) => std::option::Option::Some(v),
525            _ => std::option::Option::None,
526        })
527    }
528
529    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
530    /// to hold a `Header`.
531    ///
532    /// Note that all the setters affecting `r#in` are
533    /// mutually exclusive.
534    pub fn set_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
535        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Header(v.into()));
536        self
537    }
538
539    /// The value of [r#in][crate::model::JwtLocation::r#in]
540    /// if it holds a `Query`, `None` if the field is not set or
541    /// holds a different branch.
542    pub fn query(&self) -> std::option::Option<&std::string::String> {
543        #[allow(unreachable_patterns)]
544        self.r#in.as_ref().and_then(|v| match v {
545            crate::model::jwt_location::In::Query(v) => std::option::Option::Some(v),
546            _ => std::option::Option::None,
547        })
548    }
549
550    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
551    /// to hold a `Query`.
552    ///
553    /// Note that all the setters affecting `r#in` are
554    /// mutually exclusive.
555    pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
556        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Query(v.into()));
557        self
558    }
559
560    /// The value of [r#in][crate::model::JwtLocation::r#in]
561    /// if it holds a `Cookie`, `None` if the field is not set or
562    /// holds a different branch.
563    pub fn cookie(&self) -> std::option::Option<&std::string::String> {
564        #[allow(unreachable_patterns)]
565        self.r#in.as_ref().and_then(|v| match v {
566            crate::model::jwt_location::In::Cookie(v) => std::option::Option::Some(v),
567            _ => std::option::Option::None,
568        })
569    }
570
571    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
572    /// to hold a `Cookie`.
573    ///
574    /// Note that all the setters affecting `r#in` are
575    /// mutually exclusive.
576    pub fn set_cookie<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
577        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Cookie(v.into()));
578        self
579    }
580}
581
582impl wkt::message::Message for JwtLocation {
583    fn typename() -> &'static str {
584        "type.googleapis.com/google.api.JwtLocation"
585    }
586}
587
588#[doc(hidden)]
589impl<'de> serde::de::Deserialize<'de> for JwtLocation {
590    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
591    where
592        D: serde::Deserializer<'de>,
593    {
594        #[allow(non_camel_case_types)]
595        #[doc(hidden)]
596        #[derive(PartialEq, Eq, Hash)]
597        enum __FieldTag {
598            __header,
599            __query,
600            __cookie,
601            __value_prefix,
602            Unknown(std::string::String),
603        }
604        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
605            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
606            where
607                D: serde::Deserializer<'de>,
608            {
609                struct Visitor;
610                impl<'de> serde::de::Visitor<'de> for Visitor {
611                    type Value = __FieldTag;
612                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
613                        formatter.write_str("a field name for JwtLocation")
614                    }
615                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
616                    where
617                        E: serde::de::Error,
618                    {
619                        use std::result::Result::Ok;
620                        use std::string::ToString;
621                        match value {
622                            "header" => Ok(__FieldTag::__header),
623                            "query" => Ok(__FieldTag::__query),
624                            "cookie" => Ok(__FieldTag::__cookie),
625                            "valuePrefix" => Ok(__FieldTag::__value_prefix),
626                            "value_prefix" => Ok(__FieldTag::__value_prefix),
627                            _ => Ok(__FieldTag::Unknown(value.to_string())),
628                        }
629                    }
630                }
631                deserializer.deserialize_identifier(Visitor)
632            }
633        }
634        struct Visitor;
635        impl<'de> serde::de::Visitor<'de> for Visitor {
636            type Value = JwtLocation;
637            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
638                formatter.write_str("struct JwtLocation")
639            }
640            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
641            where
642                A: serde::de::MapAccess<'de>,
643            {
644                #[allow(unused_imports)]
645                use serde::de::Error;
646                use std::option::Option::Some;
647                let mut fields = std::collections::HashSet::new();
648                let mut result = Self::Value::new();
649                while let Some(tag) = map.next_key::<__FieldTag>()? {
650                    #[allow(clippy::match_single_binding)]
651                    match tag {
652                        __FieldTag::__header => {
653                            if !fields.insert(__FieldTag::__header) {
654                                return std::result::Result::Err(A::Error::duplicate_field(
655                                    "multiple values for header",
656                                ));
657                            }
658                            if result.r#in.is_some() {
659                                return std::result::Result::Err(A::Error::duplicate_field(
660                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.header, latest field was header",
661                                ));
662                            }
663                            result.r#in =
664                                std::option::Option::Some(crate::model::jwt_location::In::Header(
665                                    map.next_value::<std::option::Option<std::string::String>>()?
666                                        .unwrap_or_default(),
667                                ));
668                        }
669                        __FieldTag::__query => {
670                            if !fields.insert(__FieldTag::__query) {
671                                return std::result::Result::Err(A::Error::duplicate_field(
672                                    "multiple values for query",
673                                ));
674                            }
675                            if result.r#in.is_some() {
676                                return std::result::Result::Err(A::Error::duplicate_field(
677                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.query, latest field was query",
678                                ));
679                            }
680                            result.r#in =
681                                std::option::Option::Some(crate::model::jwt_location::In::Query(
682                                    map.next_value::<std::option::Option<std::string::String>>()?
683                                        .unwrap_or_default(),
684                                ));
685                        }
686                        __FieldTag::__cookie => {
687                            if !fields.insert(__FieldTag::__cookie) {
688                                return std::result::Result::Err(A::Error::duplicate_field(
689                                    "multiple values for cookie",
690                                ));
691                            }
692                            if result.r#in.is_some() {
693                                return std::result::Result::Err(A::Error::duplicate_field(
694                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.cookie, latest field was cookie",
695                                ));
696                            }
697                            result.r#in =
698                                std::option::Option::Some(crate::model::jwt_location::In::Cookie(
699                                    map.next_value::<std::option::Option<std::string::String>>()?
700                                        .unwrap_or_default(),
701                                ));
702                        }
703                        __FieldTag::__value_prefix => {
704                            if !fields.insert(__FieldTag::__value_prefix) {
705                                return std::result::Result::Err(A::Error::duplicate_field(
706                                    "multiple values for value_prefix",
707                                ));
708                            }
709                            result.value_prefix = map
710                                .next_value::<std::option::Option<std::string::String>>()?
711                                .unwrap_or_default();
712                        }
713                        __FieldTag::Unknown(key) => {
714                            let value = map.next_value::<serde_json::Value>()?;
715                            result._unknown_fields.insert(key, value);
716                        }
717                    }
718                }
719                std::result::Result::Ok(result)
720            }
721        }
722        deserializer.deserialize_any(Visitor)
723    }
724}
725
726#[doc(hidden)]
727impl serde::ser::Serialize for JwtLocation {
728    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
729    where
730        S: serde::ser::Serializer,
731    {
732        use serde::ser::SerializeMap;
733        #[allow(unused_imports)]
734        use std::option::Option::Some;
735        let mut state = serializer.serialize_map(std::option::Option::None)?;
736        if let Some(value) = self.header() {
737            state.serialize_entry("header", value)?;
738        }
739        if let Some(value) = self.query() {
740            state.serialize_entry("query", value)?;
741        }
742        if let Some(value) = self.cookie() {
743            state.serialize_entry("cookie", value)?;
744        }
745        if !self.value_prefix.is_empty() {
746            state.serialize_entry("valuePrefix", &self.value_prefix)?;
747        }
748        if !self._unknown_fields.is_empty() {
749            for (key, value) in self._unknown_fields.iter() {
750                state.serialize_entry(key, &value)?;
751            }
752        }
753        state.end()
754    }
755}
756
757impl std::fmt::Debug for JwtLocation {
758    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
759        let mut debug_struct = f.debug_struct("JwtLocation");
760        debug_struct.field("value_prefix", &self.value_prefix);
761        debug_struct.field("r#in", &self.r#in);
762        if !self._unknown_fields.is_empty() {
763            debug_struct.field("_unknown_fields", &self._unknown_fields);
764        }
765        debug_struct.finish()
766    }
767}
768
769/// Defines additional types related to [JwtLocation].
770pub mod jwt_location {
771    #[allow(unused_imports)]
772    use super::*;
773
774    #[derive(Clone, Debug, PartialEq)]
775    #[non_exhaustive]
776    pub enum In {
777        /// Specifies HTTP header name to extract JWT token.
778        Header(std::string::String),
779        /// Specifies URL query parameter name to extract JWT token.
780        Query(std::string::String),
781        /// Specifies cookie name to extract JWT token.
782        Cookie(std::string::String),
783    }
784}
785
786/// Configuration for an authentication provider, including support for
787/// [JSON Web Token
788/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
789#[derive(Clone, Default, PartialEq)]
790#[non_exhaustive]
791pub struct AuthProvider {
792    /// The unique identifier of the auth provider. It will be referred to by
793    /// `AuthRequirement.provider_id`.
794    ///
795    /// Example: "bookstore_auth".
796    pub id: std::string::String,
797
798    /// Identifies the principal that issued the JWT. See
799    /// <https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1>
800    /// Usually a URL or an email address.
801    ///
802    /// Example: <https://securetoken.google.com>
803    /// Example: 1234567-compute@developer.gserviceaccount.com
804    pub issuer: std::string::String,
805
806    /// URL of the provider's public key set to validate signature of the JWT. See
807    /// [OpenID
808    /// Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
809    /// Optional if the key set document:
810    ///
811    /// - can be retrieved from
812    ///   [OpenID
813    ///   Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
814    ///   of the issuer.
815    /// - can be inferred from the email domain of the issuer (e.g. a Google
816    ///   service account).
817    ///
818    /// Example: <https://www.googleapis.com/oauth2/v1/certs>
819    pub jwks_uri: std::string::String,
820
821    /// The list of JWT
822    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
823    /// that are allowed to access. A JWT containing any of these audiences will
824    /// be accepted. When this setting is absent, JWTs with audiences:
825    ///
826    /// - "https://[service.name]/[google.protobuf.Api.name]"
827    /// - "https://[service.name]/"
828    ///   will be accepted.
829    ///   For example, if no audiences are in the setting, LibraryService API will
830    ///   accept JWTs with the following audiences:
831    ///
832    /// <https://library-example.googleapis.com/google.example.library.v1.LibraryService>
833    ///
834    /// - <https://library-example.googleapis.com/>
835    ///
836    /// Example:
837    ///
838    /// ```norust
839    /// audiences: bookstore_android.apps.googleusercontent.com,
840    ///            bookstore_web.apps.googleusercontent.com
841    /// ```
842    pub audiences: std::string::String,
843
844    /// Redirect URL if JWT token is required but not present or is expired.
845    /// Implement authorizationUrl of securityDefinitions in OpenAPI spec.
846    pub authorization_url: std::string::String,
847
848    /// Defines the locations to extract the JWT.  For now it is only used by the
849    /// Cloud Endpoints to store the OpenAPI extension [x-google-jwt-locations]
850    /// (<https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-jwt-locations>)
851    ///
852    /// JWT locations can be one of HTTP headers, URL query parameters or
853    /// cookies. The rule is that the first match wins.
854    ///
855    /// If not specified,  default to use following 3 locations:
856    ///
857    /// 1. Authorization: Bearer
858    /// 1. x-goog-iap-jwt-assertion
859    /// 1. access_token query parameter
860    ///
861    /// Default locations can be specified as followings:
862    /// jwt_locations:
863    ///
864    /// - header: Authorization
865    ///   value_prefix: "Bearer "
866    /// - header: x-goog-iap-jwt-assertion
867    /// - query: access_token
868    pub jwt_locations: std::vec::Vec<crate::model::JwtLocation>,
869
870    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
871}
872
873impl AuthProvider {
874    pub fn new() -> Self {
875        std::default::Default::default()
876    }
877
878    /// Sets the value of [id][crate::model::AuthProvider::id].
879    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
880        self.id = v.into();
881        self
882    }
883
884    /// Sets the value of [issuer][crate::model::AuthProvider::issuer].
885    pub fn set_issuer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
886        self.issuer = v.into();
887        self
888    }
889
890    /// Sets the value of [jwks_uri][crate::model::AuthProvider::jwks_uri].
891    pub fn set_jwks_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
892        self.jwks_uri = v.into();
893        self
894    }
895
896    /// Sets the value of [audiences][crate::model::AuthProvider::audiences].
897    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
898        self.audiences = v.into();
899        self
900    }
901
902    /// Sets the value of [authorization_url][crate::model::AuthProvider::authorization_url].
903    pub fn set_authorization_url<T: std::convert::Into<std::string::String>>(
904        mut self,
905        v: T,
906    ) -> Self {
907        self.authorization_url = v.into();
908        self
909    }
910
911    /// Sets the value of [jwt_locations][crate::model::AuthProvider::jwt_locations].
912    pub fn set_jwt_locations<T, V>(mut self, v: T) -> Self
913    where
914        T: std::iter::IntoIterator<Item = V>,
915        V: std::convert::Into<crate::model::JwtLocation>,
916    {
917        use std::iter::Iterator;
918        self.jwt_locations = v.into_iter().map(|i| i.into()).collect();
919        self
920    }
921}
922
923impl wkt::message::Message for AuthProvider {
924    fn typename() -> &'static str {
925        "type.googleapis.com/google.api.AuthProvider"
926    }
927}
928
929#[doc(hidden)]
930impl<'de> serde::de::Deserialize<'de> for AuthProvider {
931    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
932    where
933        D: serde::Deserializer<'de>,
934    {
935        #[allow(non_camel_case_types)]
936        #[doc(hidden)]
937        #[derive(PartialEq, Eq, Hash)]
938        enum __FieldTag {
939            __id,
940            __issuer,
941            __jwks_uri,
942            __audiences,
943            __authorization_url,
944            __jwt_locations,
945            Unknown(std::string::String),
946        }
947        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
948            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
949            where
950                D: serde::Deserializer<'de>,
951            {
952                struct Visitor;
953                impl<'de> serde::de::Visitor<'de> for Visitor {
954                    type Value = __FieldTag;
955                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
956                        formatter.write_str("a field name for AuthProvider")
957                    }
958                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
959                    where
960                        E: serde::de::Error,
961                    {
962                        use std::result::Result::Ok;
963                        use std::string::ToString;
964                        match value {
965                            "id" => Ok(__FieldTag::__id),
966                            "issuer" => Ok(__FieldTag::__issuer),
967                            "jwksUri" => Ok(__FieldTag::__jwks_uri),
968                            "jwks_uri" => Ok(__FieldTag::__jwks_uri),
969                            "audiences" => Ok(__FieldTag::__audiences),
970                            "authorizationUrl" => Ok(__FieldTag::__authorization_url),
971                            "authorization_url" => Ok(__FieldTag::__authorization_url),
972                            "jwtLocations" => Ok(__FieldTag::__jwt_locations),
973                            "jwt_locations" => Ok(__FieldTag::__jwt_locations),
974                            _ => Ok(__FieldTag::Unknown(value.to_string())),
975                        }
976                    }
977                }
978                deserializer.deserialize_identifier(Visitor)
979            }
980        }
981        struct Visitor;
982        impl<'de> serde::de::Visitor<'de> for Visitor {
983            type Value = AuthProvider;
984            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
985                formatter.write_str("struct AuthProvider")
986            }
987            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
988            where
989                A: serde::de::MapAccess<'de>,
990            {
991                #[allow(unused_imports)]
992                use serde::de::Error;
993                use std::option::Option::Some;
994                let mut fields = std::collections::HashSet::new();
995                let mut result = Self::Value::new();
996                while let Some(tag) = map.next_key::<__FieldTag>()? {
997                    #[allow(clippy::match_single_binding)]
998                    match tag {
999                        __FieldTag::__id => {
1000                            if !fields.insert(__FieldTag::__id) {
1001                                return std::result::Result::Err(A::Error::duplicate_field(
1002                                    "multiple values for id",
1003                                ));
1004                            }
1005                            result.id = map
1006                                .next_value::<std::option::Option<std::string::String>>()?
1007                                .unwrap_or_default();
1008                        }
1009                        __FieldTag::__issuer => {
1010                            if !fields.insert(__FieldTag::__issuer) {
1011                                return std::result::Result::Err(A::Error::duplicate_field(
1012                                    "multiple values for issuer",
1013                                ));
1014                            }
1015                            result.issuer = map
1016                                .next_value::<std::option::Option<std::string::String>>()?
1017                                .unwrap_or_default();
1018                        }
1019                        __FieldTag::__jwks_uri => {
1020                            if !fields.insert(__FieldTag::__jwks_uri) {
1021                                return std::result::Result::Err(A::Error::duplicate_field(
1022                                    "multiple values for jwks_uri",
1023                                ));
1024                            }
1025                            result.jwks_uri = map
1026                                .next_value::<std::option::Option<std::string::String>>()?
1027                                .unwrap_or_default();
1028                        }
1029                        __FieldTag::__audiences => {
1030                            if !fields.insert(__FieldTag::__audiences) {
1031                                return std::result::Result::Err(A::Error::duplicate_field(
1032                                    "multiple values for audiences",
1033                                ));
1034                            }
1035                            result.audiences = map
1036                                .next_value::<std::option::Option<std::string::String>>()?
1037                                .unwrap_or_default();
1038                        }
1039                        __FieldTag::__authorization_url => {
1040                            if !fields.insert(__FieldTag::__authorization_url) {
1041                                return std::result::Result::Err(A::Error::duplicate_field(
1042                                    "multiple values for authorization_url",
1043                                ));
1044                            }
1045                            result.authorization_url = map
1046                                .next_value::<std::option::Option<std::string::String>>()?
1047                                .unwrap_or_default();
1048                        }
1049                        __FieldTag::__jwt_locations => {
1050                            if !fields.insert(__FieldTag::__jwt_locations) {
1051                                return std::result::Result::Err(A::Error::duplicate_field(
1052                                    "multiple values for jwt_locations",
1053                                ));
1054                            }
1055                            result.jwt_locations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::JwtLocation>>>()?.unwrap_or_default();
1056                        }
1057                        __FieldTag::Unknown(key) => {
1058                            let value = map.next_value::<serde_json::Value>()?;
1059                            result._unknown_fields.insert(key, value);
1060                        }
1061                    }
1062                }
1063                std::result::Result::Ok(result)
1064            }
1065        }
1066        deserializer.deserialize_any(Visitor)
1067    }
1068}
1069
1070#[doc(hidden)]
1071impl serde::ser::Serialize for AuthProvider {
1072    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1073    where
1074        S: serde::ser::Serializer,
1075    {
1076        use serde::ser::SerializeMap;
1077        #[allow(unused_imports)]
1078        use std::option::Option::Some;
1079        let mut state = serializer.serialize_map(std::option::Option::None)?;
1080        if !self.id.is_empty() {
1081            state.serialize_entry("id", &self.id)?;
1082        }
1083        if !self.issuer.is_empty() {
1084            state.serialize_entry("issuer", &self.issuer)?;
1085        }
1086        if !self.jwks_uri.is_empty() {
1087            state.serialize_entry("jwksUri", &self.jwks_uri)?;
1088        }
1089        if !self.audiences.is_empty() {
1090            state.serialize_entry("audiences", &self.audiences)?;
1091        }
1092        if !self.authorization_url.is_empty() {
1093            state.serialize_entry("authorizationUrl", &self.authorization_url)?;
1094        }
1095        if !self.jwt_locations.is_empty() {
1096            state.serialize_entry("jwtLocations", &self.jwt_locations)?;
1097        }
1098        if !self._unknown_fields.is_empty() {
1099            for (key, value) in self._unknown_fields.iter() {
1100                state.serialize_entry(key, &value)?;
1101            }
1102        }
1103        state.end()
1104    }
1105}
1106
1107impl std::fmt::Debug for AuthProvider {
1108    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1109        let mut debug_struct = f.debug_struct("AuthProvider");
1110        debug_struct.field("id", &self.id);
1111        debug_struct.field("issuer", &self.issuer);
1112        debug_struct.field("jwks_uri", &self.jwks_uri);
1113        debug_struct.field("audiences", &self.audiences);
1114        debug_struct.field("authorization_url", &self.authorization_url);
1115        debug_struct.field("jwt_locations", &self.jwt_locations);
1116        if !self._unknown_fields.is_empty() {
1117            debug_struct.field("_unknown_fields", &self._unknown_fields);
1118        }
1119        debug_struct.finish()
1120    }
1121}
1122
1123/// OAuth scopes are a way to define data and permissions on data. For example,
1124/// there are scopes defined for "Read-only access to Google Calendar" and
1125/// "Access to Cloud Platform". Users can consent to a scope for an application,
1126/// giving it permission to access that data on their behalf.
1127///
1128/// OAuth scope specifications should be fairly coarse grained; a user will need
1129/// to see and understand the text description of what your scope means.
1130///
1131/// In most cases: use one or at most two OAuth scopes for an entire family of
1132/// products. If your product has multiple APIs, you should probably be sharing
1133/// the OAuth scope across all of those APIs.
1134///
1135/// When you need finer grained OAuth consent screens: talk with your product
1136/// management about how developers will use them in practice.
1137///
1138/// Please note that even though each of the canonical scopes is enough for a
1139/// request to be accepted and passed to the backend, a request can still fail
1140/// due to the backend requiring additional scopes or permissions.
1141#[derive(Clone, Default, PartialEq)]
1142#[non_exhaustive]
1143pub struct OAuthRequirements {
1144    /// The list of publicly documented OAuth scopes that are allowed access. An
1145    /// OAuth token containing any of these scopes will be accepted.
1146    ///
1147    /// Example:
1148    ///
1149    /// ```norust
1150    ///  canonical_scopes: https://www.googleapis.com/auth/calendar,
1151    ///                    https://www.googleapis.com/auth/calendar.read
1152    /// ```
1153    pub canonical_scopes: std::string::String,
1154
1155    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1156}
1157
1158impl OAuthRequirements {
1159    pub fn new() -> Self {
1160        std::default::Default::default()
1161    }
1162
1163    /// Sets the value of [canonical_scopes][crate::model::OAuthRequirements::canonical_scopes].
1164    pub fn set_canonical_scopes<T: std::convert::Into<std::string::String>>(
1165        mut self,
1166        v: T,
1167    ) -> Self {
1168        self.canonical_scopes = v.into();
1169        self
1170    }
1171}
1172
1173impl wkt::message::Message for OAuthRequirements {
1174    fn typename() -> &'static str {
1175        "type.googleapis.com/google.api.OAuthRequirements"
1176    }
1177}
1178
1179#[doc(hidden)]
1180impl<'de> serde::de::Deserialize<'de> for OAuthRequirements {
1181    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1182    where
1183        D: serde::Deserializer<'de>,
1184    {
1185        #[allow(non_camel_case_types)]
1186        #[doc(hidden)]
1187        #[derive(PartialEq, Eq, Hash)]
1188        enum __FieldTag {
1189            __canonical_scopes,
1190            Unknown(std::string::String),
1191        }
1192        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1193            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1194            where
1195                D: serde::Deserializer<'de>,
1196            {
1197                struct Visitor;
1198                impl<'de> serde::de::Visitor<'de> for Visitor {
1199                    type Value = __FieldTag;
1200                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1201                        formatter.write_str("a field name for OAuthRequirements")
1202                    }
1203                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1204                    where
1205                        E: serde::de::Error,
1206                    {
1207                        use std::result::Result::Ok;
1208                        use std::string::ToString;
1209                        match value {
1210                            "canonicalScopes" => Ok(__FieldTag::__canonical_scopes),
1211                            "canonical_scopes" => Ok(__FieldTag::__canonical_scopes),
1212                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1213                        }
1214                    }
1215                }
1216                deserializer.deserialize_identifier(Visitor)
1217            }
1218        }
1219        struct Visitor;
1220        impl<'de> serde::de::Visitor<'de> for Visitor {
1221            type Value = OAuthRequirements;
1222            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1223                formatter.write_str("struct OAuthRequirements")
1224            }
1225            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1226            where
1227                A: serde::de::MapAccess<'de>,
1228            {
1229                #[allow(unused_imports)]
1230                use serde::de::Error;
1231                use std::option::Option::Some;
1232                let mut fields = std::collections::HashSet::new();
1233                let mut result = Self::Value::new();
1234                while let Some(tag) = map.next_key::<__FieldTag>()? {
1235                    #[allow(clippy::match_single_binding)]
1236                    match tag {
1237                        __FieldTag::__canonical_scopes => {
1238                            if !fields.insert(__FieldTag::__canonical_scopes) {
1239                                return std::result::Result::Err(A::Error::duplicate_field(
1240                                    "multiple values for canonical_scopes",
1241                                ));
1242                            }
1243                            result.canonical_scopes = map
1244                                .next_value::<std::option::Option<std::string::String>>()?
1245                                .unwrap_or_default();
1246                        }
1247                        __FieldTag::Unknown(key) => {
1248                            let value = map.next_value::<serde_json::Value>()?;
1249                            result._unknown_fields.insert(key, value);
1250                        }
1251                    }
1252                }
1253                std::result::Result::Ok(result)
1254            }
1255        }
1256        deserializer.deserialize_any(Visitor)
1257    }
1258}
1259
1260#[doc(hidden)]
1261impl serde::ser::Serialize for OAuthRequirements {
1262    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1263    where
1264        S: serde::ser::Serializer,
1265    {
1266        use serde::ser::SerializeMap;
1267        #[allow(unused_imports)]
1268        use std::option::Option::Some;
1269        let mut state = serializer.serialize_map(std::option::Option::None)?;
1270        if !self.canonical_scopes.is_empty() {
1271            state.serialize_entry("canonicalScopes", &self.canonical_scopes)?;
1272        }
1273        if !self._unknown_fields.is_empty() {
1274            for (key, value) in self._unknown_fields.iter() {
1275                state.serialize_entry(key, &value)?;
1276            }
1277        }
1278        state.end()
1279    }
1280}
1281
1282impl std::fmt::Debug for OAuthRequirements {
1283    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1284        let mut debug_struct = f.debug_struct("OAuthRequirements");
1285        debug_struct.field("canonical_scopes", &self.canonical_scopes);
1286        if !self._unknown_fields.is_empty() {
1287            debug_struct.field("_unknown_fields", &self._unknown_fields);
1288        }
1289        debug_struct.finish()
1290    }
1291}
1292
1293/// User-defined authentication requirements, including support for
1294/// [JSON Web Token
1295/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
1296#[derive(Clone, Default, PartialEq)]
1297#[non_exhaustive]
1298pub struct AuthRequirement {
1299    /// [id][google.api.AuthProvider.id] from authentication provider.
1300    ///
1301    /// Example:
1302    ///
1303    /// ```norust
1304    /// provider_id: bookstore_auth
1305    /// ```
1306    ///
1307    /// [google.api.AuthProvider.id]: crate::model::AuthProvider::id
1308    pub provider_id: std::string::String,
1309
1310    /// NOTE: This will be deprecated soon, once AuthProvider.audiences is
1311    /// implemented and accepted in all the runtime components.
1312    ///
1313    /// The list of JWT
1314    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
1315    /// that are allowed to access. A JWT containing any of these audiences will
1316    /// be accepted. When this setting is absent, only JWTs with audience
1317    /// "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
1318    /// will be accepted. For example, if no audiences are in the setting,
1319    /// LibraryService API will only accept JWTs with the following audience
1320    /// `https://library-example.googleapis.com/google.example.library.v1.LibraryService`.
1321    ///
1322    /// Example:
1323    ///
1324    /// ```norust
1325    /// audiences: bookstore_android.apps.googleusercontent.com,
1326    ///            bookstore_web.apps.googleusercontent.com
1327    /// ```
1328    ///
1329    /// [google.api.Service.name]: crate::model::Service::name
1330    /// [google.protobuf.Api.name]: wkt::Api::name
1331    pub audiences: std::string::String,
1332
1333    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1334}
1335
1336impl AuthRequirement {
1337    pub fn new() -> Self {
1338        std::default::Default::default()
1339    }
1340
1341    /// Sets the value of [provider_id][crate::model::AuthRequirement::provider_id].
1342    pub fn set_provider_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1343        self.provider_id = v.into();
1344        self
1345    }
1346
1347    /// Sets the value of [audiences][crate::model::AuthRequirement::audiences].
1348    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1349        self.audiences = v.into();
1350        self
1351    }
1352}
1353
1354impl wkt::message::Message for AuthRequirement {
1355    fn typename() -> &'static str {
1356        "type.googleapis.com/google.api.AuthRequirement"
1357    }
1358}
1359
1360#[doc(hidden)]
1361impl<'de> serde::de::Deserialize<'de> for AuthRequirement {
1362    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1363    where
1364        D: serde::Deserializer<'de>,
1365    {
1366        #[allow(non_camel_case_types)]
1367        #[doc(hidden)]
1368        #[derive(PartialEq, Eq, Hash)]
1369        enum __FieldTag {
1370            __provider_id,
1371            __audiences,
1372            Unknown(std::string::String),
1373        }
1374        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1375            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1376            where
1377                D: serde::Deserializer<'de>,
1378            {
1379                struct Visitor;
1380                impl<'de> serde::de::Visitor<'de> for Visitor {
1381                    type Value = __FieldTag;
1382                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1383                        formatter.write_str("a field name for AuthRequirement")
1384                    }
1385                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1386                    where
1387                        E: serde::de::Error,
1388                    {
1389                        use std::result::Result::Ok;
1390                        use std::string::ToString;
1391                        match value {
1392                            "providerId" => Ok(__FieldTag::__provider_id),
1393                            "provider_id" => Ok(__FieldTag::__provider_id),
1394                            "audiences" => Ok(__FieldTag::__audiences),
1395                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1396                        }
1397                    }
1398                }
1399                deserializer.deserialize_identifier(Visitor)
1400            }
1401        }
1402        struct Visitor;
1403        impl<'de> serde::de::Visitor<'de> for Visitor {
1404            type Value = AuthRequirement;
1405            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1406                formatter.write_str("struct AuthRequirement")
1407            }
1408            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1409            where
1410                A: serde::de::MapAccess<'de>,
1411            {
1412                #[allow(unused_imports)]
1413                use serde::de::Error;
1414                use std::option::Option::Some;
1415                let mut fields = std::collections::HashSet::new();
1416                let mut result = Self::Value::new();
1417                while let Some(tag) = map.next_key::<__FieldTag>()? {
1418                    #[allow(clippy::match_single_binding)]
1419                    match tag {
1420                        __FieldTag::__provider_id => {
1421                            if !fields.insert(__FieldTag::__provider_id) {
1422                                return std::result::Result::Err(A::Error::duplicate_field(
1423                                    "multiple values for provider_id",
1424                                ));
1425                            }
1426                            result.provider_id = map
1427                                .next_value::<std::option::Option<std::string::String>>()?
1428                                .unwrap_or_default();
1429                        }
1430                        __FieldTag::__audiences => {
1431                            if !fields.insert(__FieldTag::__audiences) {
1432                                return std::result::Result::Err(A::Error::duplicate_field(
1433                                    "multiple values for audiences",
1434                                ));
1435                            }
1436                            result.audiences = map
1437                                .next_value::<std::option::Option<std::string::String>>()?
1438                                .unwrap_or_default();
1439                        }
1440                        __FieldTag::Unknown(key) => {
1441                            let value = map.next_value::<serde_json::Value>()?;
1442                            result._unknown_fields.insert(key, value);
1443                        }
1444                    }
1445                }
1446                std::result::Result::Ok(result)
1447            }
1448        }
1449        deserializer.deserialize_any(Visitor)
1450    }
1451}
1452
1453#[doc(hidden)]
1454impl serde::ser::Serialize for AuthRequirement {
1455    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1456    where
1457        S: serde::ser::Serializer,
1458    {
1459        use serde::ser::SerializeMap;
1460        #[allow(unused_imports)]
1461        use std::option::Option::Some;
1462        let mut state = serializer.serialize_map(std::option::Option::None)?;
1463        if !self.provider_id.is_empty() {
1464            state.serialize_entry("providerId", &self.provider_id)?;
1465        }
1466        if !self.audiences.is_empty() {
1467            state.serialize_entry("audiences", &self.audiences)?;
1468        }
1469        if !self._unknown_fields.is_empty() {
1470            for (key, value) in self._unknown_fields.iter() {
1471                state.serialize_entry(key, &value)?;
1472            }
1473        }
1474        state.end()
1475    }
1476}
1477
1478impl std::fmt::Debug for AuthRequirement {
1479    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1480        let mut debug_struct = f.debug_struct("AuthRequirement");
1481        debug_struct.field("provider_id", &self.provider_id);
1482        debug_struct.field("audiences", &self.audiences);
1483        if !self._unknown_fields.is_empty() {
1484            debug_struct.field("_unknown_fields", &self._unknown_fields);
1485        }
1486        debug_struct.finish()
1487    }
1488}
1489
1490/// `Backend` defines the backend configuration for a service.
1491#[derive(Clone, Default, PartialEq)]
1492#[non_exhaustive]
1493pub struct Backend {
1494    /// A list of API backend rules that apply to individual API methods.
1495    ///
1496    /// **NOTE:** All service configuration rules follow "last one wins" order.
1497    pub rules: std::vec::Vec<crate::model::BackendRule>,
1498
1499    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1500}
1501
1502impl Backend {
1503    pub fn new() -> Self {
1504        std::default::Default::default()
1505    }
1506
1507    /// Sets the value of [rules][crate::model::Backend::rules].
1508    pub fn set_rules<T, V>(mut self, v: T) -> Self
1509    where
1510        T: std::iter::IntoIterator<Item = V>,
1511        V: std::convert::Into<crate::model::BackendRule>,
1512    {
1513        use std::iter::Iterator;
1514        self.rules = v.into_iter().map(|i| i.into()).collect();
1515        self
1516    }
1517}
1518
1519impl wkt::message::Message for Backend {
1520    fn typename() -> &'static str {
1521        "type.googleapis.com/google.api.Backend"
1522    }
1523}
1524
1525#[doc(hidden)]
1526impl<'de> serde::de::Deserialize<'de> for Backend {
1527    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1528    where
1529        D: serde::Deserializer<'de>,
1530    {
1531        #[allow(non_camel_case_types)]
1532        #[doc(hidden)]
1533        #[derive(PartialEq, Eq, Hash)]
1534        enum __FieldTag {
1535            __rules,
1536            Unknown(std::string::String),
1537        }
1538        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1539            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1540            where
1541                D: serde::Deserializer<'de>,
1542            {
1543                struct Visitor;
1544                impl<'de> serde::de::Visitor<'de> for Visitor {
1545                    type Value = __FieldTag;
1546                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1547                        formatter.write_str("a field name for Backend")
1548                    }
1549                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1550                    where
1551                        E: serde::de::Error,
1552                    {
1553                        use std::result::Result::Ok;
1554                        use std::string::ToString;
1555                        match value {
1556                            "rules" => Ok(__FieldTag::__rules),
1557                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1558                        }
1559                    }
1560                }
1561                deserializer.deserialize_identifier(Visitor)
1562            }
1563        }
1564        struct Visitor;
1565        impl<'de> serde::de::Visitor<'de> for Visitor {
1566            type Value = Backend;
1567            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1568                formatter.write_str("struct Backend")
1569            }
1570            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1571            where
1572                A: serde::de::MapAccess<'de>,
1573            {
1574                #[allow(unused_imports)]
1575                use serde::de::Error;
1576                use std::option::Option::Some;
1577                let mut fields = std::collections::HashSet::new();
1578                let mut result = Self::Value::new();
1579                while let Some(tag) = map.next_key::<__FieldTag>()? {
1580                    #[allow(clippy::match_single_binding)]
1581                    match tag {
1582                        __FieldTag::__rules => {
1583                            if !fields.insert(__FieldTag::__rules) {
1584                                return std::result::Result::Err(A::Error::duplicate_field(
1585                                    "multiple values for rules",
1586                                ));
1587                            }
1588                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::BackendRule>>>()?.unwrap_or_default();
1589                        }
1590                        __FieldTag::Unknown(key) => {
1591                            let value = map.next_value::<serde_json::Value>()?;
1592                            result._unknown_fields.insert(key, value);
1593                        }
1594                    }
1595                }
1596                std::result::Result::Ok(result)
1597            }
1598        }
1599        deserializer.deserialize_any(Visitor)
1600    }
1601}
1602
1603#[doc(hidden)]
1604impl serde::ser::Serialize for Backend {
1605    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1606    where
1607        S: serde::ser::Serializer,
1608    {
1609        use serde::ser::SerializeMap;
1610        #[allow(unused_imports)]
1611        use std::option::Option::Some;
1612        let mut state = serializer.serialize_map(std::option::Option::None)?;
1613        if !self.rules.is_empty() {
1614            state.serialize_entry("rules", &self.rules)?;
1615        }
1616        if !self._unknown_fields.is_empty() {
1617            for (key, value) in self._unknown_fields.iter() {
1618                state.serialize_entry(key, &value)?;
1619            }
1620        }
1621        state.end()
1622    }
1623}
1624
1625impl std::fmt::Debug for Backend {
1626    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1627        let mut debug_struct = f.debug_struct("Backend");
1628        debug_struct.field("rules", &self.rules);
1629        if !self._unknown_fields.is_empty() {
1630            debug_struct.field("_unknown_fields", &self._unknown_fields);
1631        }
1632        debug_struct.finish()
1633    }
1634}
1635
1636/// A backend rule provides configuration for an individual API element.
1637#[derive(Clone, Default, PartialEq)]
1638#[non_exhaustive]
1639pub struct BackendRule {
1640    /// Selects the methods to which this rule applies.
1641    ///
1642    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
1643    /// details.
1644    ///
1645    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
1646    pub selector: std::string::String,
1647
1648    /// The address of the API backend.
1649    ///
1650    /// The scheme is used to determine the backend protocol and security.
1651    /// The following schemes are accepted:
1652    ///
1653    /// SCHEME        PROTOCOL    SECURITY
1654    /// http://       HTTP        None
1655    /// https://      HTTP        TLS
1656    /// grpc://       gRPC        None
1657    /// grpcs://      gRPC        TLS
1658    ///
1659    /// It is recommended to explicitly include a scheme. Leaving out the scheme
1660    /// may cause constrasting behaviors across platforms.
1661    ///
1662    /// If the port is unspecified, the default is:
1663    ///
1664    /// - 80 for schemes without TLS
1665    /// - 443 for schemes with TLS
1666    ///
1667    /// For HTTP backends, use [protocol][google.api.BackendRule.protocol]
1668    /// to specify the protocol version.
1669    ///
1670    /// [google.api.BackendRule.protocol]: crate::model::BackendRule::protocol
1671    pub address: std::string::String,
1672
1673    /// The number of seconds to wait for a response from a request. The default
1674    /// varies based on the request protocol and deployment environment.
1675    pub deadline: f64,
1676
1677    /// Deprecated, do not use.
1678    #[deprecated]
1679    pub min_deadline: f64,
1680
1681    /// The number of seconds to wait for the completion of a long running
1682    /// operation. The default is no deadline.
1683    pub operation_deadline: f64,
1684
1685    pub path_translation: crate::model::backend_rule::PathTranslation,
1686
1687    /// The protocol used for sending a request to the backend.
1688    /// The supported values are "http/1.1" and "h2".
1689    ///
1690    /// The default value is inferred from the scheme in the
1691    /// [address][google.api.BackendRule.address] field:
1692    ///
1693    /// SCHEME        PROTOCOL
1694    /// http://       http/1.1
1695    /// https://      http/1.1
1696    /// grpc://       h2
1697    /// grpcs://      h2
1698    ///
1699    /// For secure HTTP backends (https://) that support HTTP/2, set this field
1700    /// to "h2" for improved performance.
1701    ///
1702    /// Configuring this field to non-default values is only supported for secure
1703    /// HTTP backends. This field will be ignored for all other backends.
1704    ///
1705    /// See
1706    /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
1707    /// for more details on the supported values.
1708    ///
1709    /// [google.api.BackendRule.address]: crate::model::BackendRule::address
1710    pub protocol: std::string::String,
1711
1712    /// The map between request protocol and the backend address.
1713    pub overrides_by_request_protocol:
1714        std::collections::HashMap<std::string::String, crate::model::BackendRule>,
1715
1716    /// Authentication settings used by the backend.
1717    ///
1718    /// These are typically used to provide service management functionality to
1719    /// a backend served on a publicly-routable URL. The `authentication`
1720    /// details should match the authentication behavior used by the backend.
1721    ///
1722    /// For example, specifying `jwt_audience` implies that the backend expects
1723    /// authentication via a JWT.
1724    ///
1725    /// When authentication is unspecified, the resulting behavior is the same
1726    /// as `disable_auth` set to `true`.
1727    ///
1728    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
1729    /// JWT ID token.
1730    pub authentication: std::option::Option<crate::model::backend_rule::Authentication>,
1731
1732    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1733}
1734
1735impl BackendRule {
1736    pub fn new() -> Self {
1737        std::default::Default::default()
1738    }
1739
1740    /// Sets the value of [selector][crate::model::BackendRule::selector].
1741    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1742        self.selector = v.into();
1743        self
1744    }
1745
1746    /// Sets the value of [address][crate::model::BackendRule::address].
1747    pub fn set_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1748        self.address = v.into();
1749        self
1750    }
1751
1752    /// Sets the value of [deadline][crate::model::BackendRule::deadline].
1753    pub fn set_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1754        self.deadline = v.into();
1755        self
1756    }
1757
1758    /// Sets the value of [min_deadline][crate::model::BackendRule::min_deadline].
1759    #[deprecated]
1760    pub fn set_min_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1761        self.min_deadline = v.into();
1762        self
1763    }
1764
1765    /// Sets the value of [operation_deadline][crate::model::BackendRule::operation_deadline].
1766    pub fn set_operation_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1767        self.operation_deadline = v.into();
1768        self
1769    }
1770
1771    /// Sets the value of [path_translation][crate::model::BackendRule::path_translation].
1772    pub fn set_path_translation<
1773        T: std::convert::Into<crate::model::backend_rule::PathTranslation>,
1774    >(
1775        mut self,
1776        v: T,
1777    ) -> Self {
1778        self.path_translation = v.into();
1779        self
1780    }
1781
1782    /// Sets the value of [protocol][crate::model::BackendRule::protocol].
1783    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1784        self.protocol = v.into();
1785        self
1786    }
1787
1788    /// Sets the value of [overrides_by_request_protocol][crate::model::BackendRule::overrides_by_request_protocol].
1789    pub fn set_overrides_by_request_protocol<T, K, V>(mut self, v: T) -> Self
1790    where
1791        T: std::iter::IntoIterator<Item = (K, V)>,
1792        K: std::convert::Into<std::string::String>,
1793        V: std::convert::Into<crate::model::BackendRule>,
1794    {
1795        use std::iter::Iterator;
1796        self.overrides_by_request_protocol =
1797            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1798        self
1799    }
1800
1801    /// Sets the value of [authentication][crate::model::BackendRule::authentication].
1802    ///
1803    /// Note that all the setters affecting `authentication` are mutually
1804    /// exclusive.
1805    pub fn set_authentication<
1806        T: std::convert::Into<std::option::Option<crate::model::backend_rule::Authentication>>,
1807    >(
1808        mut self,
1809        v: T,
1810    ) -> Self {
1811        self.authentication = v.into();
1812        self
1813    }
1814
1815    /// The value of [authentication][crate::model::BackendRule::authentication]
1816    /// if it holds a `JwtAudience`, `None` if the field is not set or
1817    /// holds a different branch.
1818    pub fn jwt_audience(&self) -> std::option::Option<&std::string::String> {
1819        #[allow(unreachable_patterns)]
1820        self.authentication.as_ref().and_then(|v| match v {
1821            crate::model::backend_rule::Authentication::JwtAudience(v) => {
1822                std::option::Option::Some(v)
1823            }
1824            _ => std::option::Option::None,
1825        })
1826    }
1827
1828    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
1829    /// to hold a `JwtAudience`.
1830    ///
1831    /// Note that all the setters affecting `authentication` are
1832    /// mutually exclusive.
1833    pub fn set_jwt_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1834        self.authentication = std::option::Option::Some(
1835            crate::model::backend_rule::Authentication::JwtAudience(v.into()),
1836        );
1837        self
1838    }
1839
1840    /// The value of [authentication][crate::model::BackendRule::authentication]
1841    /// if it holds a `DisableAuth`, `None` if the field is not set or
1842    /// holds a different branch.
1843    pub fn disable_auth(&self) -> std::option::Option<&bool> {
1844        #[allow(unreachable_patterns)]
1845        self.authentication.as_ref().and_then(|v| match v {
1846            crate::model::backend_rule::Authentication::DisableAuth(v) => {
1847                std::option::Option::Some(v)
1848            }
1849            _ => std::option::Option::None,
1850        })
1851    }
1852
1853    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
1854    /// to hold a `DisableAuth`.
1855    ///
1856    /// Note that all the setters affecting `authentication` are
1857    /// mutually exclusive.
1858    pub fn set_disable_auth<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1859        self.authentication = std::option::Option::Some(
1860            crate::model::backend_rule::Authentication::DisableAuth(v.into()),
1861        );
1862        self
1863    }
1864}
1865
1866impl wkt::message::Message for BackendRule {
1867    fn typename() -> &'static str {
1868        "type.googleapis.com/google.api.BackendRule"
1869    }
1870}
1871
1872#[doc(hidden)]
1873impl<'de> serde::de::Deserialize<'de> for BackendRule {
1874    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1875    where
1876        D: serde::Deserializer<'de>,
1877    {
1878        #[allow(non_camel_case_types)]
1879        #[doc(hidden)]
1880        #[derive(PartialEq, Eq, Hash)]
1881        enum __FieldTag {
1882            __selector,
1883            __address,
1884            __deadline,
1885            __min_deadline,
1886            __operation_deadline,
1887            __path_translation,
1888            __jwt_audience,
1889            __disable_auth,
1890            __protocol,
1891            __overrides_by_request_protocol,
1892            Unknown(std::string::String),
1893        }
1894        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1895            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1896            where
1897                D: serde::Deserializer<'de>,
1898            {
1899                struct Visitor;
1900                impl<'de> serde::de::Visitor<'de> for Visitor {
1901                    type Value = __FieldTag;
1902                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1903                        formatter.write_str("a field name for BackendRule")
1904                    }
1905                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1906                    where
1907                        E: serde::de::Error,
1908                    {
1909                        use std::result::Result::Ok;
1910                        use std::string::ToString;
1911                        match value {
1912                            "selector" => Ok(__FieldTag::__selector),
1913                            "address" => Ok(__FieldTag::__address),
1914                            "deadline" => Ok(__FieldTag::__deadline),
1915                            "minDeadline" => Ok(__FieldTag::__min_deadline),
1916                            "min_deadline" => Ok(__FieldTag::__min_deadline),
1917                            "operationDeadline" => Ok(__FieldTag::__operation_deadline),
1918                            "operation_deadline" => Ok(__FieldTag::__operation_deadline),
1919                            "pathTranslation" => Ok(__FieldTag::__path_translation),
1920                            "path_translation" => Ok(__FieldTag::__path_translation),
1921                            "jwtAudience" => Ok(__FieldTag::__jwt_audience),
1922                            "jwt_audience" => Ok(__FieldTag::__jwt_audience),
1923                            "disableAuth" => Ok(__FieldTag::__disable_auth),
1924                            "disable_auth" => Ok(__FieldTag::__disable_auth),
1925                            "protocol" => Ok(__FieldTag::__protocol),
1926                            "overridesByRequestProtocol" => {
1927                                Ok(__FieldTag::__overrides_by_request_protocol)
1928                            }
1929                            "overrides_by_request_protocol" => {
1930                                Ok(__FieldTag::__overrides_by_request_protocol)
1931                            }
1932                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1933                        }
1934                    }
1935                }
1936                deserializer.deserialize_identifier(Visitor)
1937            }
1938        }
1939        struct Visitor;
1940        impl<'de> serde::de::Visitor<'de> for Visitor {
1941            type Value = BackendRule;
1942            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1943                formatter.write_str("struct BackendRule")
1944            }
1945            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1946            where
1947                A: serde::de::MapAccess<'de>,
1948            {
1949                #[allow(unused_imports)]
1950                use serde::de::Error;
1951                use std::option::Option::Some;
1952                let mut fields = std::collections::HashSet::new();
1953                let mut result = Self::Value::new();
1954                while let Some(tag) = map.next_key::<__FieldTag>()? {
1955                    #[allow(clippy::match_single_binding)]
1956                    match tag {
1957                        __FieldTag::__selector => {
1958                            if !fields.insert(__FieldTag::__selector) {
1959                                return std::result::Result::Err(A::Error::duplicate_field(
1960                                    "multiple values for selector",
1961                                ));
1962                            }
1963                            result.selector = map
1964                                .next_value::<std::option::Option<std::string::String>>()?
1965                                .unwrap_or_default();
1966                        }
1967                        __FieldTag::__address => {
1968                            if !fields.insert(__FieldTag::__address) {
1969                                return std::result::Result::Err(A::Error::duplicate_field(
1970                                    "multiple values for address",
1971                                ));
1972                            }
1973                            result.address = map
1974                                .next_value::<std::option::Option<std::string::String>>()?
1975                                .unwrap_or_default();
1976                        }
1977                        __FieldTag::__deadline => {
1978                            if !fields.insert(__FieldTag::__deadline) {
1979                                return std::result::Result::Err(A::Error::duplicate_field(
1980                                    "multiple values for deadline",
1981                                ));
1982                            }
1983                            struct __With(std::option::Option<f64>);
1984                            impl<'de> serde::de::Deserialize<'de> for __With {
1985                                fn deserialize<D>(
1986                                    deserializer: D,
1987                                ) -> std::result::Result<Self, D::Error>
1988                                where
1989                                    D: serde::de::Deserializer<'de>,
1990                                {
1991                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1992                                }
1993                            }
1994                            result.deadline = map.next_value::<__With>()?.0.unwrap_or_default();
1995                        }
1996                        __FieldTag::__min_deadline => {
1997                            if !fields.insert(__FieldTag::__min_deadline) {
1998                                return std::result::Result::Err(A::Error::duplicate_field(
1999                                    "multiple values for min_deadline",
2000                                ));
2001                            }
2002                            struct __With(std::option::Option<f64>);
2003                            impl<'de> serde::de::Deserialize<'de> for __With {
2004                                fn deserialize<D>(
2005                                    deserializer: D,
2006                                ) -> std::result::Result<Self, D::Error>
2007                                where
2008                                    D: serde::de::Deserializer<'de>,
2009                                {
2010                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2011                                }
2012                            }
2013                            result.min_deadline = map.next_value::<__With>()?.0.unwrap_or_default();
2014                        }
2015                        __FieldTag::__operation_deadline => {
2016                            if !fields.insert(__FieldTag::__operation_deadline) {
2017                                return std::result::Result::Err(A::Error::duplicate_field(
2018                                    "multiple values for operation_deadline",
2019                                ));
2020                            }
2021                            struct __With(std::option::Option<f64>);
2022                            impl<'de> serde::de::Deserialize<'de> for __With {
2023                                fn deserialize<D>(
2024                                    deserializer: D,
2025                                ) -> std::result::Result<Self, D::Error>
2026                                where
2027                                    D: serde::de::Deserializer<'de>,
2028                                {
2029                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2030                                }
2031                            }
2032                            result.operation_deadline =
2033                                map.next_value::<__With>()?.0.unwrap_or_default();
2034                        }
2035                        __FieldTag::__path_translation => {
2036                            if !fields.insert(__FieldTag::__path_translation) {
2037                                return std::result::Result::Err(A::Error::duplicate_field(
2038                                    "multiple values for path_translation",
2039                                ));
2040                            }
2041                            result.path_translation =
2042                                map.next_value::<std::option::Option<
2043                                    crate::model::backend_rule::PathTranslation,
2044                                >>()?
2045                                .unwrap_or_default();
2046                        }
2047                        __FieldTag::__jwt_audience => {
2048                            if !fields.insert(__FieldTag::__jwt_audience) {
2049                                return std::result::Result::Err(A::Error::duplicate_field(
2050                                    "multiple values for jwt_audience",
2051                                ));
2052                            }
2053                            if result.authentication.is_some() {
2054                                return std::result::Result::Err(A::Error::duplicate_field(
2055                                    "multiple values for `authentication`, a oneof with full ID .google.api.BackendRule.jwt_audience, latest field was jwtAudience",
2056                                ));
2057                            }
2058                            result.authentication = std::option::Option::Some(
2059                                crate::model::backend_rule::Authentication::JwtAudience(
2060                                    map.next_value::<std::option::Option<std::string::String>>()?
2061                                        .unwrap_or_default(),
2062                                ),
2063                            );
2064                        }
2065                        __FieldTag::__disable_auth => {
2066                            if !fields.insert(__FieldTag::__disable_auth) {
2067                                return std::result::Result::Err(A::Error::duplicate_field(
2068                                    "multiple values for disable_auth",
2069                                ));
2070                            }
2071                            if result.authentication.is_some() {
2072                                return std::result::Result::Err(A::Error::duplicate_field(
2073                                    "multiple values for `authentication`, a oneof with full ID .google.api.BackendRule.disable_auth, latest field was disableAuth",
2074                                ));
2075                            }
2076                            result.authentication = std::option::Option::Some(
2077                                crate::model::backend_rule::Authentication::DisableAuth(
2078                                    map.next_value::<std::option::Option<bool>>()?
2079                                        .unwrap_or_default(),
2080                                ),
2081                            );
2082                        }
2083                        __FieldTag::__protocol => {
2084                            if !fields.insert(__FieldTag::__protocol) {
2085                                return std::result::Result::Err(A::Error::duplicate_field(
2086                                    "multiple values for protocol",
2087                                ));
2088                            }
2089                            result.protocol = map
2090                                .next_value::<std::option::Option<std::string::String>>()?
2091                                .unwrap_or_default();
2092                        }
2093                        __FieldTag::__overrides_by_request_protocol => {
2094                            if !fields.insert(__FieldTag::__overrides_by_request_protocol) {
2095                                return std::result::Result::Err(A::Error::duplicate_field(
2096                                    "multiple values for overrides_by_request_protocol",
2097                                ));
2098                            }
2099                            result.overrides_by_request_protocol = map
2100                                .next_value::<std::option::Option<
2101                                    std::collections::HashMap<
2102                                        std::string::String,
2103                                        crate::model::BackendRule,
2104                                    >,
2105                                >>()?
2106                                .unwrap_or_default();
2107                        }
2108                        __FieldTag::Unknown(key) => {
2109                            let value = map.next_value::<serde_json::Value>()?;
2110                            result._unknown_fields.insert(key, value);
2111                        }
2112                    }
2113                }
2114                std::result::Result::Ok(result)
2115            }
2116        }
2117        deserializer.deserialize_any(Visitor)
2118    }
2119}
2120
2121#[doc(hidden)]
2122impl serde::ser::Serialize for BackendRule {
2123    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2124    where
2125        S: serde::ser::Serializer,
2126    {
2127        use serde::ser::SerializeMap;
2128        #[allow(unused_imports)]
2129        use std::option::Option::Some;
2130        let mut state = serializer.serialize_map(std::option::Option::None)?;
2131        if !self.selector.is_empty() {
2132            state.serialize_entry("selector", &self.selector)?;
2133        }
2134        if !self.address.is_empty() {
2135            state.serialize_entry("address", &self.address)?;
2136        }
2137        if !wkt::internal::is_default(&self.deadline) {
2138            struct __With<'a>(&'a f64);
2139            impl<'a> serde::ser::Serialize for __With<'a> {
2140                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2141                where
2142                    S: serde::ser::Serializer,
2143                {
2144                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2145                }
2146            }
2147            state.serialize_entry("deadline", &__With(&self.deadline))?;
2148        }
2149        if !wkt::internal::is_default(&self.min_deadline) {
2150            struct __With<'a>(&'a f64);
2151            impl<'a> serde::ser::Serialize for __With<'a> {
2152                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2153                where
2154                    S: serde::ser::Serializer,
2155                {
2156                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2157                }
2158            }
2159            state.serialize_entry("minDeadline", &__With(&self.min_deadline))?;
2160        }
2161        if !wkt::internal::is_default(&self.operation_deadline) {
2162            struct __With<'a>(&'a f64);
2163            impl<'a> serde::ser::Serialize for __With<'a> {
2164                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2165                where
2166                    S: serde::ser::Serializer,
2167                {
2168                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2169                }
2170            }
2171            state.serialize_entry("operationDeadline", &__With(&self.operation_deadline))?;
2172        }
2173        if !wkt::internal::is_default(&self.path_translation) {
2174            state.serialize_entry("pathTranslation", &self.path_translation)?;
2175        }
2176        if let Some(value) = self.jwt_audience() {
2177            state.serialize_entry("jwtAudience", value)?;
2178        }
2179        if let Some(value) = self.disable_auth() {
2180            state.serialize_entry("disableAuth", value)?;
2181        }
2182        if !self.protocol.is_empty() {
2183            state.serialize_entry("protocol", &self.protocol)?;
2184        }
2185        if !self.overrides_by_request_protocol.is_empty() {
2186            state.serialize_entry(
2187                "overridesByRequestProtocol",
2188                &self.overrides_by_request_protocol,
2189            )?;
2190        }
2191        if !self._unknown_fields.is_empty() {
2192            for (key, value) in self._unknown_fields.iter() {
2193                state.serialize_entry(key, &value)?;
2194            }
2195        }
2196        state.end()
2197    }
2198}
2199
2200impl std::fmt::Debug for BackendRule {
2201    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2202        let mut debug_struct = f.debug_struct("BackendRule");
2203        debug_struct.field("selector", &self.selector);
2204        debug_struct.field("address", &self.address);
2205        debug_struct.field("deadline", &self.deadline);
2206        debug_struct.field("min_deadline", &self.min_deadline);
2207        debug_struct.field("operation_deadline", &self.operation_deadline);
2208        debug_struct.field("path_translation", &self.path_translation);
2209        debug_struct.field("protocol", &self.protocol);
2210        debug_struct.field(
2211            "overrides_by_request_protocol",
2212            &self.overrides_by_request_protocol,
2213        );
2214        debug_struct.field("authentication", &self.authentication);
2215        if !self._unknown_fields.is_empty() {
2216            debug_struct.field("_unknown_fields", &self._unknown_fields);
2217        }
2218        debug_struct.finish()
2219    }
2220}
2221
2222/// Defines additional types related to [BackendRule].
2223pub mod backend_rule {
2224    #[allow(unused_imports)]
2225    use super::*;
2226
2227    /// Path Translation specifies how to combine the backend address with the
2228    /// request path in order to produce the appropriate forwarding URL for the
2229    /// request.
2230    ///
2231    /// Path Translation is applicable only to HTTP-based backends. Backends which
2232    /// do not accept requests over HTTP/HTTPS should leave `path_translation`
2233    /// unspecified.
2234    ///
2235    /// # Working with unknown values
2236    ///
2237    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2238    /// additional enum variants at any time. Adding new variants is not considered
2239    /// a breaking change. Applications should write their code in anticipation of:
2240    ///
2241    /// - New values appearing in future releases of the client library, **and**
2242    /// - New values received dynamically, without application changes.
2243    ///
2244    /// Please consult the [Working with enums] section in the user guide for some
2245    /// guidelines.
2246    ///
2247    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2248    #[derive(Clone, Debug, PartialEq)]
2249    #[non_exhaustive]
2250    pub enum PathTranslation {
2251        Unspecified,
2252        /// Use the backend address as-is, with no modification to the path. If the
2253        /// URL pattern contains variables, the variable names and values will be
2254        /// appended to the query string. If a query string parameter and a URL
2255        /// pattern variable have the same name, this may result in duplicate keys in
2256        /// the query string.
2257        ///
2258        /// # Examples
2259        ///
2260        /// Given the following operation config:
2261        ///
2262        /// ```norust
2263        /// Method path:        /api/company/{cid}/user/{uid}
2264        /// Backend address:    https://example.cloudfunctions.net/getUser
2265        /// ```
2266        ///
2267        /// Requests to the following request paths will call the backend at the
2268        /// translated path:
2269        ///
2270        /// ```norust
2271        /// Request path: /api/company/widgetworks/user/johndoe
2272        /// Translated:
2273        /// https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe
2274        ///
2275        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
2276        /// Translated:
2277        /// https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe
2278        /// ```
2279        ConstantAddress,
2280        /// The request path will be appended to the backend address.
2281        ///
2282        /// # Examples
2283        ///
2284        /// Given the following operation config:
2285        ///
2286        /// ```norust
2287        /// Method path:        /api/company/{cid}/user/{uid}
2288        /// Backend address:    https://example.appspot.com
2289        /// ```
2290        ///
2291        /// Requests to the following request paths will call the backend at the
2292        /// translated path:
2293        ///
2294        /// ```norust
2295        /// Request path: /api/company/widgetworks/user/johndoe
2296        /// Translated:
2297        /// https://example.appspot.com/api/company/widgetworks/user/johndoe
2298        ///
2299        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
2300        /// Translated:
2301        /// https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST
2302        /// ```
2303        AppendPathToAddress,
2304        /// If set, the enum was initialized with an unknown value.
2305        ///
2306        /// Applications can examine the value using [PathTranslation::value] or
2307        /// [PathTranslation::name].
2308        UnknownValue(path_translation::UnknownValue),
2309    }
2310
2311    #[doc(hidden)]
2312    pub mod path_translation {
2313        #[allow(unused_imports)]
2314        use super::*;
2315        #[derive(Clone, Debug, PartialEq)]
2316        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2317    }
2318
2319    impl PathTranslation {
2320        /// Gets the enum value.
2321        ///
2322        /// Returns `None` if the enum contains an unknown value deserialized from
2323        /// the string representation of enums.
2324        pub fn value(&self) -> std::option::Option<i32> {
2325            match self {
2326                Self::Unspecified => std::option::Option::Some(0),
2327                Self::ConstantAddress => std::option::Option::Some(1),
2328                Self::AppendPathToAddress => std::option::Option::Some(2),
2329                Self::UnknownValue(u) => u.0.value(),
2330            }
2331        }
2332
2333        /// Gets the enum value as a string.
2334        ///
2335        /// Returns `None` if the enum contains an unknown value deserialized from
2336        /// the integer representation of enums.
2337        pub fn name(&self) -> std::option::Option<&str> {
2338            match self {
2339                Self::Unspecified => std::option::Option::Some("PATH_TRANSLATION_UNSPECIFIED"),
2340                Self::ConstantAddress => std::option::Option::Some("CONSTANT_ADDRESS"),
2341                Self::AppendPathToAddress => std::option::Option::Some("APPEND_PATH_TO_ADDRESS"),
2342                Self::UnknownValue(u) => u.0.name(),
2343            }
2344        }
2345    }
2346
2347    impl std::default::Default for PathTranslation {
2348        fn default() -> Self {
2349            use std::convert::From;
2350            Self::from(0)
2351        }
2352    }
2353
2354    impl std::fmt::Display for PathTranslation {
2355        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2356            wkt::internal::display_enum(f, self.name(), self.value())
2357        }
2358    }
2359
2360    impl std::convert::From<i32> for PathTranslation {
2361        fn from(value: i32) -> Self {
2362            match value {
2363                0 => Self::Unspecified,
2364                1 => Self::ConstantAddress,
2365                2 => Self::AppendPathToAddress,
2366                _ => Self::UnknownValue(path_translation::UnknownValue(
2367                    wkt::internal::UnknownEnumValue::Integer(value),
2368                )),
2369            }
2370        }
2371    }
2372
2373    impl std::convert::From<&str> for PathTranslation {
2374        fn from(value: &str) -> Self {
2375            use std::string::ToString;
2376            match value {
2377                "PATH_TRANSLATION_UNSPECIFIED" => Self::Unspecified,
2378                "CONSTANT_ADDRESS" => Self::ConstantAddress,
2379                "APPEND_PATH_TO_ADDRESS" => Self::AppendPathToAddress,
2380                _ => Self::UnknownValue(path_translation::UnknownValue(
2381                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2382                )),
2383            }
2384        }
2385    }
2386
2387    impl serde::ser::Serialize for PathTranslation {
2388        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2389        where
2390            S: serde::Serializer,
2391        {
2392            match self {
2393                Self::Unspecified => serializer.serialize_i32(0),
2394                Self::ConstantAddress => serializer.serialize_i32(1),
2395                Self::AppendPathToAddress => serializer.serialize_i32(2),
2396                Self::UnknownValue(u) => u.0.serialize(serializer),
2397            }
2398        }
2399    }
2400
2401    impl<'de> serde::de::Deserialize<'de> for PathTranslation {
2402        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2403        where
2404            D: serde::Deserializer<'de>,
2405        {
2406            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PathTranslation>::new(
2407                ".google.api.BackendRule.PathTranslation",
2408            ))
2409        }
2410    }
2411
2412    /// Authentication settings used by the backend.
2413    ///
2414    /// These are typically used to provide service management functionality to
2415    /// a backend served on a publicly-routable URL. The `authentication`
2416    /// details should match the authentication behavior used by the backend.
2417    ///
2418    /// For example, specifying `jwt_audience` implies that the backend expects
2419    /// authentication via a JWT.
2420    ///
2421    /// When authentication is unspecified, the resulting behavior is the same
2422    /// as `disable_auth` set to `true`.
2423    ///
2424    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
2425    /// JWT ID token.
2426    #[derive(Clone, Debug, PartialEq)]
2427    #[non_exhaustive]
2428    pub enum Authentication {
2429        /// The JWT audience is used when generating a JWT ID token for the backend.
2430        /// This ID token will be added in the HTTP "authorization" header, and sent
2431        /// to the backend.
2432        JwtAudience(std::string::String),
2433        /// When disable_auth is true, a JWT ID token won't be generated and the
2434        /// original "Authorization" HTTP header will be preserved. If the header is
2435        /// used to carry the original token and is expected by the backend, this
2436        /// field must be set to true to preserve the header.
2437        DisableAuth(bool),
2438    }
2439}
2440
2441/// Billing related configuration of the service.
2442///
2443/// The following example shows how to configure monitored resources and metrics
2444/// for billing, `consumer_destinations` is the only supported destination and
2445/// the monitored resources need at least one label key
2446/// `cloud.googleapis.com/location` to indicate the location of the billing
2447/// usage, using different monitored resources between monitoring and billing is
2448/// recommended so they can be evolved independently:
2449///
2450/// ```norust
2451/// monitored_resources:
2452/// - type: library.googleapis.com/billing_branch
2453///   labels:
2454///   - key: cloud.googleapis.com/location
2455///     description: |
2456///       Predefined label to support billing location restriction.
2457///   - key: city
2458///     description: |
2459///       Custom label to define the city where the library branch is located
2460///       in.
2461///   - key: name
2462///     description: Custom label to define the name of the library branch.
2463/// metrics:
2464/// - name: library.googleapis.com/book/borrowed_count
2465///   metric_kind: DELTA
2466///   value_type: INT64
2467///   unit: "1"
2468/// billing:
2469///   consumer_destinations:
2470///   - monitored_resource: library.googleapis.com/billing_branch
2471///     metrics:
2472///     - library.googleapis.com/book/borrowed_count
2473/// ```
2474#[derive(Clone, Default, PartialEq)]
2475#[non_exhaustive]
2476pub struct Billing {
2477    /// Billing configurations for sending metrics to the consumer project.
2478    /// There can be multiple consumer destinations per service, each one must have
2479    /// a different monitored resource type. A metric can be used in at most
2480    /// one consumer destination.
2481    pub consumer_destinations: std::vec::Vec<crate::model::billing::BillingDestination>,
2482
2483    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2484}
2485
2486impl Billing {
2487    pub fn new() -> Self {
2488        std::default::Default::default()
2489    }
2490
2491    /// Sets the value of [consumer_destinations][crate::model::Billing::consumer_destinations].
2492    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
2493    where
2494        T: std::iter::IntoIterator<Item = V>,
2495        V: std::convert::Into<crate::model::billing::BillingDestination>,
2496    {
2497        use std::iter::Iterator;
2498        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
2499        self
2500    }
2501}
2502
2503impl wkt::message::Message for Billing {
2504    fn typename() -> &'static str {
2505        "type.googleapis.com/google.api.Billing"
2506    }
2507}
2508
2509#[doc(hidden)]
2510impl<'de> serde::de::Deserialize<'de> for Billing {
2511    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2512    where
2513        D: serde::Deserializer<'de>,
2514    {
2515        #[allow(non_camel_case_types)]
2516        #[doc(hidden)]
2517        #[derive(PartialEq, Eq, Hash)]
2518        enum __FieldTag {
2519            __consumer_destinations,
2520            Unknown(std::string::String),
2521        }
2522        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2523            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2524            where
2525                D: serde::Deserializer<'de>,
2526            {
2527                struct Visitor;
2528                impl<'de> serde::de::Visitor<'de> for Visitor {
2529                    type Value = __FieldTag;
2530                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2531                        formatter.write_str("a field name for Billing")
2532                    }
2533                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2534                    where
2535                        E: serde::de::Error,
2536                    {
2537                        use std::result::Result::Ok;
2538                        use std::string::ToString;
2539                        match value {
2540                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
2541                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
2542                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2543                        }
2544                    }
2545                }
2546                deserializer.deserialize_identifier(Visitor)
2547            }
2548        }
2549        struct Visitor;
2550        impl<'de> serde::de::Visitor<'de> for Visitor {
2551            type Value = Billing;
2552            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2553                formatter.write_str("struct Billing")
2554            }
2555            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2556            where
2557                A: serde::de::MapAccess<'de>,
2558            {
2559                #[allow(unused_imports)]
2560                use serde::de::Error;
2561                use std::option::Option::Some;
2562                let mut fields = std::collections::HashSet::new();
2563                let mut result = Self::Value::new();
2564                while let Some(tag) = map.next_key::<__FieldTag>()? {
2565                    #[allow(clippy::match_single_binding)]
2566                    match tag {
2567                        __FieldTag::__consumer_destinations => {
2568                            if !fields.insert(__FieldTag::__consumer_destinations) {
2569                                return std::result::Result::Err(A::Error::duplicate_field(
2570                                    "multiple values for consumer_destinations",
2571                                ));
2572                            }
2573                            result.consumer_destinations = map
2574                                .next_value::<std::option::Option<
2575                                    std::vec::Vec<crate::model::billing::BillingDestination>,
2576                                >>()?
2577                                .unwrap_or_default();
2578                        }
2579                        __FieldTag::Unknown(key) => {
2580                            let value = map.next_value::<serde_json::Value>()?;
2581                            result._unknown_fields.insert(key, value);
2582                        }
2583                    }
2584                }
2585                std::result::Result::Ok(result)
2586            }
2587        }
2588        deserializer.deserialize_any(Visitor)
2589    }
2590}
2591
2592#[doc(hidden)]
2593impl serde::ser::Serialize for Billing {
2594    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2595    where
2596        S: serde::ser::Serializer,
2597    {
2598        use serde::ser::SerializeMap;
2599        #[allow(unused_imports)]
2600        use std::option::Option::Some;
2601        let mut state = serializer.serialize_map(std::option::Option::None)?;
2602        if !self.consumer_destinations.is_empty() {
2603            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
2604        }
2605        if !self._unknown_fields.is_empty() {
2606            for (key, value) in self._unknown_fields.iter() {
2607                state.serialize_entry(key, &value)?;
2608            }
2609        }
2610        state.end()
2611    }
2612}
2613
2614impl std::fmt::Debug for Billing {
2615    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2616        let mut debug_struct = f.debug_struct("Billing");
2617        debug_struct.field("consumer_destinations", &self.consumer_destinations);
2618        if !self._unknown_fields.is_empty() {
2619            debug_struct.field("_unknown_fields", &self._unknown_fields);
2620        }
2621        debug_struct.finish()
2622    }
2623}
2624
2625/// Defines additional types related to [Billing].
2626pub mod billing {
2627    #[allow(unused_imports)]
2628    use super::*;
2629
2630    /// Configuration of a specific billing destination (Currently only support
2631    /// bill against consumer project).
2632    #[derive(Clone, Default, PartialEq)]
2633    #[non_exhaustive]
2634    pub struct BillingDestination {
2635        /// The monitored resource type. The type must be defined in
2636        /// [Service.monitored_resources][google.api.Service.monitored_resources]
2637        /// section.
2638        ///
2639        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
2640        pub monitored_resource: std::string::String,
2641
2642        /// Names of the metrics to report to this billing destination.
2643        /// Each name must be defined in
2644        /// [Service.metrics][google.api.Service.metrics] section.
2645        ///
2646        /// [google.api.Service.metrics]: crate::model::Service::metrics
2647        pub metrics: std::vec::Vec<std::string::String>,
2648
2649        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2650    }
2651
2652    impl BillingDestination {
2653        pub fn new() -> Self {
2654            std::default::Default::default()
2655        }
2656
2657        /// Sets the value of [monitored_resource][crate::model::billing::BillingDestination::monitored_resource].
2658        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
2659            mut self,
2660            v: T,
2661        ) -> Self {
2662            self.monitored_resource = v.into();
2663            self
2664        }
2665
2666        /// Sets the value of [metrics][crate::model::billing::BillingDestination::metrics].
2667        pub fn set_metrics<T, V>(mut self, v: T) -> Self
2668        where
2669            T: std::iter::IntoIterator<Item = V>,
2670            V: std::convert::Into<std::string::String>,
2671        {
2672            use std::iter::Iterator;
2673            self.metrics = v.into_iter().map(|i| i.into()).collect();
2674            self
2675        }
2676    }
2677
2678    impl wkt::message::Message for BillingDestination {
2679        fn typename() -> &'static str {
2680            "type.googleapis.com/google.api.Billing.BillingDestination"
2681        }
2682    }
2683
2684    #[doc(hidden)]
2685    impl<'de> serde::de::Deserialize<'de> for BillingDestination {
2686        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2687        where
2688            D: serde::Deserializer<'de>,
2689        {
2690            #[allow(non_camel_case_types)]
2691            #[doc(hidden)]
2692            #[derive(PartialEq, Eq, Hash)]
2693            enum __FieldTag {
2694                __monitored_resource,
2695                __metrics,
2696                Unknown(std::string::String),
2697            }
2698            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2699                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2700                where
2701                    D: serde::Deserializer<'de>,
2702                {
2703                    struct Visitor;
2704                    impl<'de> serde::de::Visitor<'de> for Visitor {
2705                        type Value = __FieldTag;
2706                        fn expecting(
2707                            &self,
2708                            formatter: &mut std::fmt::Formatter,
2709                        ) -> std::fmt::Result {
2710                            formatter.write_str("a field name for BillingDestination")
2711                        }
2712                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2713                        where
2714                            E: serde::de::Error,
2715                        {
2716                            use std::result::Result::Ok;
2717                            use std::string::ToString;
2718                            match value {
2719                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
2720                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
2721                                "metrics" => Ok(__FieldTag::__metrics),
2722                                _ => Ok(__FieldTag::Unknown(value.to_string())),
2723                            }
2724                        }
2725                    }
2726                    deserializer.deserialize_identifier(Visitor)
2727                }
2728            }
2729            struct Visitor;
2730            impl<'de> serde::de::Visitor<'de> for Visitor {
2731                type Value = BillingDestination;
2732                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2733                    formatter.write_str("struct BillingDestination")
2734                }
2735                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2736                where
2737                    A: serde::de::MapAccess<'de>,
2738                {
2739                    #[allow(unused_imports)]
2740                    use serde::de::Error;
2741                    use std::option::Option::Some;
2742                    let mut fields = std::collections::HashSet::new();
2743                    let mut result = Self::Value::new();
2744                    while let Some(tag) = map.next_key::<__FieldTag>()? {
2745                        #[allow(clippy::match_single_binding)]
2746                        match tag {
2747                            __FieldTag::__monitored_resource => {
2748                                if !fields.insert(__FieldTag::__monitored_resource) {
2749                                    return std::result::Result::Err(A::Error::duplicate_field(
2750                                        "multiple values for monitored_resource",
2751                                    ));
2752                                }
2753                                result.monitored_resource = map
2754                                    .next_value::<std::option::Option<std::string::String>>()?
2755                                    .unwrap_or_default();
2756                            }
2757                            __FieldTag::__metrics => {
2758                                if !fields.insert(__FieldTag::__metrics) {
2759                                    return std::result::Result::Err(A::Error::duplicate_field(
2760                                        "multiple values for metrics",
2761                                    ));
2762                                }
2763                                result.metrics = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
2764                            }
2765                            __FieldTag::Unknown(key) => {
2766                                let value = map.next_value::<serde_json::Value>()?;
2767                                result._unknown_fields.insert(key, value);
2768                            }
2769                        }
2770                    }
2771                    std::result::Result::Ok(result)
2772                }
2773            }
2774            deserializer.deserialize_any(Visitor)
2775        }
2776    }
2777
2778    #[doc(hidden)]
2779    impl serde::ser::Serialize for BillingDestination {
2780        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2781        where
2782            S: serde::ser::Serializer,
2783        {
2784            use serde::ser::SerializeMap;
2785            #[allow(unused_imports)]
2786            use std::option::Option::Some;
2787            let mut state = serializer.serialize_map(std::option::Option::None)?;
2788            if !self.monitored_resource.is_empty() {
2789                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
2790            }
2791            if !self.metrics.is_empty() {
2792                state.serialize_entry("metrics", &self.metrics)?;
2793            }
2794            if !self._unknown_fields.is_empty() {
2795                for (key, value) in self._unknown_fields.iter() {
2796                    state.serialize_entry(key, &value)?;
2797                }
2798            }
2799            state.end()
2800        }
2801    }
2802
2803    impl std::fmt::Debug for BillingDestination {
2804        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2805            let mut debug_struct = f.debug_struct("BillingDestination");
2806            debug_struct.field("monitored_resource", &self.monitored_resource);
2807            debug_struct.field("metrics", &self.metrics);
2808            if !self._unknown_fields.is_empty() {
2809                debug_struct.field("_unknown_fields", &self._unknown_fields);
2810            }
2811            debug_struct.finish()
2812        }
2813    }
2814}
2815
2816/// Required information for every language.
2817#[derive(Clone, Default, PartialEq)]
2818#[non_exhaustive]
2819pub struct CommonLanguageSettings {
2820    /// Link to automatically generated reference documentation.  Example:
2821    /// <https://cloud.google.com/nodejs/docs/reference/asset/latest>
2822    #[deprecated]
2823    pub reference_docs_uri: std::string::String,
2824
2825    /// The destination where API teams want this client library to be published.
2826    pub destinations: std::vec::Vec<crate::model::ClientLibraryDestination>,
2827
2828    /// Configuration for which RPCs should be generated in the GAPIC client.
2829    pub selective_gapic_generation: std::option::Option<crate::model::SelectiveGapicGeneration>,
2830
2831    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2832}
2833
2834impl CommonLanguageSettings {
2835    pub fn new() -> Self {
2836        std::default::Default::default()
2837    }
2838
2839    /// Sets the value of [reference_docs_uri][crate::model::CommonLanguageSettings::reference_docs_uri].
2840    #[deprecated]
2841    pub fn set_reference_docs_uri<T: std::convert::Into<std::string::String>>(
2842        mut self,
2843        v: T,
2844    ) -> Self {
2845        self.reference_docs_uri = v.into();
2846        self
2847    }
2848
2849    /// Sets the value of [destinations][crate::model::CommonLanguageSettings::destinations].
2850    pub fn set_destinations<T, V>(mut self, v: T) -> Self
2851    where
2852        T: std::iter::IntoIterator<Item = V>,
2853        V: std::convert::Into<crate::model::ClientLibraryDestination>,
2854    {
2855        use std::iter::Iterator;
2856        self.destinations = v.into_iter().map(|i| i.into()).collect();
2857        self
2858    }
2859
2860    /// Sets the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
2861    pub fn set_selective_gapic_generation<T>(mut self, v: T) -> Self
2862    where
2863        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
2864    {
2865        self.selective_gapic_generation = std::option::Option::Some(v.into());
2866        self
2867    }
2868
2869    /// Sets or clears the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
2870    pub fn set_or_clear_selective_gapic_generation<T>(mut self, v: std::option::Option<T>) -> Self
2871    where
2872        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
2873    {
2874        self.selective_gapic_generation = v.map(|x| x.into());
2875        self
2876    }
2877}
2878
2879impl wkt::message::Message for CommonLanguageSettings {
2880    fn typename() -> &'static str {
2881        "type.googleapis.com/google.api.CommonLanguageSettings"
2882    }
2883}
2884
2885#[doc(hidden)]
2886impl<'de> serde::de::Deserialize<'de> for CommonLanguageSettings {
2887    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2888    where
2889        D: serde::Deserializer<'de>,
2890    {
2891        #[allow(non_camel_case_types)]
2892        #[doc(hidden)]
2893        #[derive(PartialEq, Eq, Hash)]
2894        enum __FieldTag {
2895            __reference_docs_uri,
2896            __destinations,
2897            __selective_gapic_generation,
2898            Unknown(std::string::String),
2899        }
2900        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2901            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2902            where
2903                D: serde::Deserializer<'de>,
2904            {
2905                struct Visitor;
2906                impl<'de> serde::de::Visitor<'de> for Visitor {
2907                    type Value = __FieldTag;
2908                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2909                        formatter.write_str("a field name for CommonLanguageSettings")
2910                    }
2911                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2912                    where
2913                        E: serde::de::Error,
2914                    {
2915                        use std::result::Result::Ok;
2916                        use std::string::ToString;
2917                        match value {
2918                            "referenceDocsUri" => Ok(__FieldTag::__reference_docs_uri),
2919                            "reference_docs_uri" => Ok(__FieldTag::__reference_docs_uri),
2920                            "destinations" => Ok(__FieldTag::__destinations),
2921                            "selectiveGapicGeneration" => {
2922                                Ok(__FieldTag::__selective_gapic_generation)
2923                            }
2924                            "selective_gapic_generation" => {
2925                                Ok(__FieldTag::__selective_gapic_generation)
2926                            }
2927                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2928                        }
2929                    }
2930                }
2931                deserializer.deserialize_identifier(Visitor)
2932            }
2933        }
2934        struct Visitor;
2935        impl<'de> serde::de::Visitor<'de> for Visitor {
2936            type Value = CommonLanguageSettings;
2937            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2938                formatter.write_str("struct CommonLanguageSettings")
2939            }
2940            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2941            where
2942                A: serde::de::MapAccess<'de>,
2943            {
2944                #[allow(unused_imports)]
2945                use serde::de::Error;
2946                use std::option::Option::Some;
2947                let mut fields = std::collections::HashSet::new();
2948                let mut result = Self::Value::new();
2949                while let Some(tag) = map.next_key::<__FieldTag>()? {
2950                    #[allow(clippy::match_single_binding)]
2951                    match tag {
2952                        __FieldTag::__reference_docs_uri => {
2953                            if !fields.insert(__FieldTag::__reference_docs_uri) {
2954                                return std::result::Result::Err(A::Error::duplicate_field(
2955                                    "multiple values for reference_docs_uri",
2956                                ));
2957                            }
2958                            result.reference_docs_uri = map
2959                                .next_value::<std::option::Option<std::string::String>>()?
2960                                .unwrap_or_default();
2961                        }
2962                        __FieldTag::__destinations => {
2963                            if !fields.insert(__FieldTag::__destinations) {
2964                                return std::result::Result::Err(A::Error::duplicate_field(
2965                                    "multiple values for destinations",
2966                                ));
2967                            }
2968                            result.destinations = map
2969                                .next_value::<std::option::Option<
2970                                    std::vec::Vec<crate::model::ClientLibraryDestination>,
2971                                >>()?
2972                                .unwrap_or_default();
2973                        }
2974                        __FieldTag::__selective_gapic_generation => {
2975                            if !fields.insert(__FieldTag::__selective_gapic_generation) {
2976                                return std::result::Result::Err(A::Error::duplicate_field(
2977                                    "multiple values for selective_gapic_generation",
2978                                ));
2979                            }
2980                            result.selective_gapic_generation = map.next_value::<std::option::Option<crate::model::SelectiveGapicGeneration>>()?
2981                                ;
2982                        }
2983                        __FieldTag::Unknown(key) => {
2984                            let value = map.next_value::<serde_json::Value>()?;
2985                            result._unknown_fields.insert(key, value);
2986                        }
2987                    }
2988                }
2989                std::result::Result::Ok(result)
2990            }
2991        }
2992        deserializer.deserialize_any(Visitor)
2993    }
2994}
2995
2996#[doc(hidden)]
2997impl serde::ser::Serialize for CommonLanguageSettings {
2998    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2999    where
3000        S: serde::ser::Serializer,
3001    {
3002        use serde::ser::SerializeMap;
3003        #[allow(unused_imports)]
3004        use std::option::Option::Some;
3005        let mut state = serializer.serialize_map(std::option::Option::None)?;
3006        if !self.reference_docs_uri.is_empty() {
3007            state.serialize_entry("referenceDocsUri", &self.reference_docs_uri)?;
3008        }
3009        if !self.destinations.is_empty() {
3010            state.serialize_entry("destinations", &self.destinations)?;
3011        }
3012        if self.selective_gapic_generation.is_some() {
3013            state.serialize_entry("selectiveGapicGeneration", &self.selective_gapic_generation)?;
3014        }
3015        if !self._unknown_fields.is_empty() {
3016            for (key, value) in self._unknown_fields.iter() {
3017                state.serialize_entry(key, &value)?;
3018            }
3019        }
3020        state.end()
3021    }
3022}
3023
3024impl std::fmt::Debug for CommonLanguageSettings {
3025    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3026        let mut debug_struct = f.debug_struct("CommonLanguageSettings");
3027        debug_struct.field("reference_docs_uri", &self.reference_docs_uri);
3028        debug_struct.field("destinations", &self.destinations);
3029        debug_struct.field(
3030            "selective_gapic_generation",
3031            &self.selective_gapic_generation,
3032        );
3033        if !self._unknown_fields.is_empty() {
3034            debug_struct.field("_unknown_fields", &self._unknown_fields);
3035        }
3036        debug_struct.finish()
3037    }
3038}
3039
3040/// Details about how and where to publish client libraries.
3041#[derive(Clone, Default, PartialEq)]
3042#[non_exhaustive]
3043pub struct ClientLibrarySettings {
3044    /// Version of the API to apply these settings to. This is the full protobuf
3045    /// package for the API, ending in the version element.
3046    /// Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1".
3047    pub version: std::string::String,
3048
3049    /// Launch stage of this version of the API.
3050    pub launch_stage: crate::model::LaunchStage,
3051
3052    /// When using transport=rest, the client request will encode enums as
3053    /// numbers rather than strings.
3054    pub rest_numeric_enums: bool,
3055
3056    /// Settings for legacy Java features, supported in the Service YAML.
3057    pub java_settings: std::option::Option<crate::model::JavaSettings>,
3058
3059    /// Settings for C++ client libraries.
3060    pub cpp_settings: std::option::Option<crate::model::CppSettings>,
3061
3062    /// Settings for PHP client libraries.
3063    pub php_settings: std::option::Option<crate::model::PhpSettings>,
3064
3065    /// Settings for Python client libraries.
3066    pub python_settings: std::option::Option<crate::model::PythonSettings>,
3067
3068    /// Settings for Node client libraries.
3069    pub node_settings: std::option::Option<crate::model::NodeSettings>,
3070
3071    /// Settings for .NET client libraries.
3072    pub dotnet_settings: std::option::Option<crate::model::DotnetSettings>,
3073
3074    /// Settings for Ruby client libraries.
3075    pub ruby_settings: std::option::Option<crate::model::RubySettings>,
3076
3077    /// Settings for Go client libraries.
3078    pub go_settings: std::option::Option<crate::model::GoSettings>,
3079
3080    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3081}
3082
3083impl ClientLibrarySettings {
3084    pub fn new() -> Self {
3085        std::default::Default::default()
3086    }
3087
3088    /// Sets the value of [version][crate::model::ClientLibrarySettings::version].
3089    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3090        self.version = v.into();
3091        self
3092    }
3093
3094    /// Sets the value of [launch_stage][crate::model::ClientLibrarySettings::launch_stage].
3095    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
3096        mut self,
3097        v: T,
3098    ) -> Self {
3099        self.launch_stage = v.into();
3100        self
3101    }
3102
3103    /// Sets the value of [rest_numeric_enums][crate::model::ClientLibrarySettings::rest_numeric_enums].
3104    pub fn set_rest_numeric_enums<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3105        self.rest_numeric_enums = v.into();
3106        self
3107    }
3108
3109    /// Sets the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
3110    pub fn set_java_settings<T>(mut self, v: T) -> Self
3111    where
3112        T: std::convert::Into<crate::model::JavaSettings>,
3113    {
3114        self.java_settings = std::option::Option::Some(v.into());
3115        self
3116    }
3117
3118    /// Sets or clears the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
3119    pub fn set_or_clear_java_settings<T>(mut self, v: std::option::Option<T>) -> Self
3120    where
3121        T: std::convert::Into<crate::model::JavaSettings>,
3122    {
3123        self.java_settings = v.map(|x| x.into());
3124        self
3125    }
3126
3127    /// Sets the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
3128    pub fn set_cpp_settings<T>(mut self, v: T) -> Self
3129    where
3130        T: std::convert::Into<crate::model::CppSettings>,
3131    {
3132        self.cpp_settings = std::option::Option::Some(v.into());
3133        self
3134    }
3135
3136    /// Sets or clears the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
3137    pub fn set_or_clear_cpp_settings<T>(mut self, v: std::option::Option<T>) -> Self
3138    where
3139        T: std::convert::Into<crate::model::CppSettings>,
3140    {
3141        self.cpp_settings = v.map(|x| x.into());
3142        self
3143    }
3144
3145    /// Sets the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
3146    pub fn set_php_settings<T>(mut self, v: T) -> Self
3147    where
3148        T: std::convert::Into<crate::model::PhpSettings>,
3149    {
3150        self.php_settings = std::option::Option::Some(v.into());
3151        self
3152    }
3153
3154    /// Sets or clears the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
3155    pub fn set_or_clear_php_settings<T>(mut self, v: std::option::Option<T>) -> Self
3156    where
3157        T: std::convert::Into<crate::model::PhpSettings>,
3158    {
3159        self.php_settings = v.map(|x| x.into());
3160        self
3161    }
3162
3163    /// Sets the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
3164    pub fn set_python_settings<T>(mut self, v: T) -> Self
3165    where
3166        T: std::convert::Into<crate::model::PythonSettings>,
3167    {
3168        self.python_settings = std::option::Option::Some(v.into());
3169        self
3170    }
3171
3172    /// Sets or clears the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
3173    pub fn set_or_clear_python_settings<T>(mut self, v: std::option::Option<T>) -> Self
3174    where
3175        T: std::convert::Into<crate::model::PythonSettings>,
3176    {
3177        self.python_settings = v.map(|x| x.into());
3178        self
3179    }
3180
3181    /// Sets the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
3182    pub fn set_node_settings<T>(mut self, v: T) -> Self
3183    where
3184        T: std::convert::Into<crate::model::NodeSettings>,
3185    {
3186        self.node_settings = std::option::Option::Some(v.into());
3187        self
3188    }
3189
3190    /// Sets or clears the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
3191    pub fn set_or_clear_node_settings<T>(mut self, v: std::option::Option<T>) -> Self
3192    where
3193        T: std::convert::Into<crate::model::NodeSettings>,
3194    {
3195        self.node_settings = v.map(|x| x.into());
3196        self
3197    }
3198
3199    /// Sets the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
3200    pub fn set_dotnet_settings<T>(mut self, v: T) -> Self
3201    where
3202        T: std::convert::Into<crate::model::DotnetSettings>,
3203    {
3204        self.dotnet_settings = std::option::Option::Some(v.into());
3205        self
3206    }
3207
3208    /// Sets or clears the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
3209    pub fn set_or_clear_dotnet_settings<T>(mut self, v: std::option::Option<T>) -> Self
3210    where
3211        T: std::convert::Into<crate::model::DotnetSettings>,
3212    {
3213        self.dotnet_settings = v.map(|x| x.into());
3214        self
3215    }
3216
3217    /// Sets the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
3218    pub fn set_ruby_settings<T>(mut self, v: T) -> Self
3219    where
3220        T: std::convert::Into<crate::model::RubySettings>,
3221    {
3222        self.ruby_settings = std::option::Option::Some(v.into());
3223        self
3224    }
3225
3226    /// Sets or clears the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
3227    pub fn set_or_clear_ruby_settings<T>(mut self, v: std::option::Option<T>) -> Self
3228    where
3229        T: std::convert::Into<crate::model::RubySettings>,
3230    {
3231        self.ruby_settings = v.map(|x| x.into());
3232        self
3233    }
3234
3235    /// Sets the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
3236    pub fn set_go_settings<T>(mut self, v: T) -> Self
3237    where
3238        T: std::convert::Into<crate::model::GoSettings>,
3239    {
3240        self.go_settings = std::option::Option::Some(v.into());
3241        self
3242    }
3243
3244    /// Sets or clears the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
3245    pub fn set_or_clear_go_settings<T>(mut self, v: std::option::Option<T>) -> Self
3246    where
3247        T: std::convert::Into<crate::model::GoSettings>,
3248    {
3249        self.go_settings = v.map(|x| x.into());
3250        self
3251    }
3252}
3253
3254impl wkt::message::Message for ClientLibrarySettings {
3255    fn typename() -> &'static str {
3256        "type.googleapis.com/google.api.ClientLibrarySettings"
3257    }
3258}
3259
3260#[doc(hidden)]
3261impl<'de> serde::de::Deserialize<'de> for ClientLibrarySettings {
3262    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3263    where
3264        D: serde::Deserializer<'de>,
3265    {
3266        #[allow(non_camel_case_types)]
3267        #[doc(hidden)]
3268        #[derive(PartialEq, Eq, Hash)]
3269        enum __FieldTag {
3270            __version,
3271            __launch_stage,
3272            __rest_numeric_enums,
3273            __java_settings,
3274            __cpp_settings,
3275            __php_settings,
3276            __python_settings,
3277            __node_settings,
3278            __dotnet_settings,
3279            __ruby_settings,
3280            __go_settings,
3281            Unknown(std::string::String),
3282        }
3283        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3284            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3285            where
3286                D: serde::Deserializer<'de>,
3287            {
3288                struct Visitor;
3289                impl<'de> serde::de::Visitor<'de> for Visitor {
3290                    type Value = __FieldTag;
3291                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3292                        formatter.write_str("a field name for ClientLibrarySettings")
3293                    }
3294                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3295                    where
3296                        E: serde::de::Error,
3297                    {
3298                        use std::result::Result::Ok;
3299                        use std::string::ToString;
3300                        match value {
3301                            "version" => Ok(__FieldTag::__version),
3302                            "launchStage" => Ok(__FieldTag::__launch_stage),
3303                            "launch_stage" => Ok(__FieldTag::__launch_stage),
3304                            "restNumericEnums" => Ok(__FieldTag::__rest_numeric_enums),
3305                            "rest_numeric_enums" => Ok(__FieldTag::__rest_numeric_enums),
3306                            "javaSettings" => Ok(__FieldTag::__java_settings),
3307                            "java_settings" => Ok(__FieldTag::__java_settings),
3308                            "cppSettings" => Ok(__FieldTag::__cpp_settings),
3309                            "cpp_settings" => Ok(__FieldTag::__cpp_settings),
3310                            "phpSettings" => Ok(__FieldTag::__php_settings),
3311                            "php_settings" => Ok(__FieldTag::__php_settings),
3312                            "pythonSettings" => Ok(__FieldTag::__python_settings),
3313                            "python_settings" => Ok(__FieldTag::__python_settings),
3314                            "nodeSettings" => Ok(__FieldTag::__node_settings),
3315                            "node_settings" => Ok(__FieldTag::__node_settings),
3316                            "dotnetSettings" => Ok(__FieldTag::__dotnet_settings),
3317                            "dotnet_settings" => Ok(__FieldTag::__dotnet_settings),
3318                            "rubySettings" => Ok(__FieldTag::__ruby_settings),
3319                            "ruby_settings" => Ok(__FieldTag::__ruby_settings),
3320                            "goSettings" => Ok(__FieldTag::__go_settings),
3321                            "go_settings" => Ok(__FieldTag::__go_settings),
3322                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3323                        }
3324                    }
3325                }
3326                deserializer.deserialize_identifier(Visitor)
3327            }
3328        }
3329        struct Visitor;
3330        impl<'de> serde::de::Visitor<'de> for Visitor {
3331            type Value = ClientLibrarySettings;
3332            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3333                formatter.write_str("struct ClientLibrarySettings")
3334            }
3335            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3336            where
3337                A: serde::de::MapAccess<'de>,
3338            {
3339                #[allow(unused_imports)]
3340                use serde::de::Error;
3341                use std::option::Option::Some;
3342                let mut fields = std::collections::HashSet::new();
3343                let mut result = Self::Value::new();
3344                while let Some(tag) = map.next_key::<__FieldTag>()? {
3345                    #[allow(clippy::match_single_binding)]
3346                    match tag {
3347                        __FieldTag::__version => {
3348                            if !fields.insert(__FieldTag::__version) {
3349                                return std::result::Result::Err(A::Error::duplicate_field(
3350                                    "multiple values for version",
3351                                ));
3352                            }
3353                            result.version = map
3354                                .next_value::<std::option::Option<std::string::String>>()?
3355                                .unwrap_or_default();
3356                        }
3357                        __FieldTag::__launch_stage => {
3358                            if !fields.insert(__FieldTag::__launch_stage) {
3359                                return std::result::Result::Err(A::Error::duplicate_field(
3360                                    "multiple values for launch_stage",
3361                                ));
3362                            }
3363                            result.launch_stage = map
3364                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
3365                                .unwrap_or_default();
3366                        }
3367                        __FieldTag::__rest_numeric_enums => {
3368                            if !fields.insert(__FieldTag::__rest_numeric_enums) {
3369                                return std::result::Result::Err(A::Error::duplicate_field(
3370                                    "multiple values for rest_numeric_enums",
3371                                ));
3372                            }
3373                            result.rest_numeric_enums = map
3374                                .next_value::<std::option::Option<bool>>()?
3375                                .unwrap_or_default();
3376                        }
3377                        __FieldTag::__java_settings => {
3378                            if !fields.insert(__FieldTag::__java_settings) {
3379                                return std::result::Result::Err(A::Error::duplicate_field(
3380                                    "multiple values for java_settings",
3381                                ));
3382                            }
3383                            result.java_settings = map
3384                                .next_value::<std::option::Option<crate::model::JavaSettings>>()?;
3385                        }
3386                        __FieldTag::__cpp_settings => {
3387                            if !fields.insert(__FieldTag::__cpp_settings) {
3388                                return std::result::Result::Err(A::Error::duplicate_field(
3389                                    "multiple values for cpp_settings",
3390                                ));
3391                            }
3392                            result.cpp_settings =
3393                                map.next_value::<std::option::Option<crate::model::CppSettings>>()?;
3394                        }
3395                        __FieldTag::__php_settings => {
3396                            if !fields.insert(__FieldTag::__php_settings) {
3397                                return std::result::Result::Err(A::Error::duplicate_field(
3398                                    "multiple values for php_settings",
3399                                ));
3400                            }
3401                            result.php_settings =
3402                                map.next_value::<std::option::Option<crate::model::PhpSettings>>()?;
3403                        }
3404                        __FieldTag::__python_settings => {
3405                            if !fields.insert(__FieldTag::__python_settings) {
3406                                return std::result::Result::Err(A::Error::duplicate_field(
3407                                    "multiple values for python_settings",
3408                                ));
3409                            }
3410                            result.python_settings = map
3411                                .next_value::<std::option::Option<crate::model::PythonSettings>>(
3412                                )?;
3413                        }
3414                        __FieldTag::__node_settings => {
3415                            if !fields.insert(__FieldTag::__node_settings) {
3416                                return std::result::Result::Err(A::Error::duplicate_field(
3417                                    "multiple values for node_settings",
3418                                ));
3419                            }
3420                            result.node_settings = map
3421                                .next_value::<std::option::Option<crate::model::NodeSettings>>()?;
3422                        }
3423                        __FieldTag::__dotnet_settings => {
3424                            if !fields.insert(__FieldTag::__dotnet_settings) {
3425                                return std::result::Result::Err(A::Error::duplicate_field(
3426                                    "multiple values for dotnet_settings",
3427                                ));
3428                            }
3429                            result.dotnet_settings = map
3430                                .next_value::<std::option::Option<crate::model::DotnetSettings>>(
3431                                )?;
3432                        }
3433                        __FieldTag::__ruby_settings => {
3434                            if !fields.insert(__FieldTag::__ruby_settings) {
3435                                return std::result::Result::Err(A::Error::duplicate_field(
3436                                    "multiple values for ruby_settings",
3437                                ));
3438                            }
3439                            result.ruby_settings = map
3440                                .next_value::<std::option::Option<crate::model::RubySettings>>()?;
3441                        }
3442                        __FieldTag::__go_settings => {
3443                            if !fields.insert(__FieldTag::__go_settings) {
3444                                return std::result::Result::Err(A::Error::duplicate_field(
3445                                    "multiple values for go_settings",
3446                                ));
3447                            }
3448                            result.go_settings =
3449                                map.next_value::<std::option::Option<crate::model::GoSettings>>()?;
3450                        }
3451                        __FieldTag::Unknown(key) => {
3452                            let value = map.next_value::<serde_json::Value>()?;
3453                            result._unknown_fields.insert(key, value);
3454                        }
3455                    }
3456                }
3457                std::result::Result::Ok(result)
3458            }
3459        }
3460        deserializer.deserialize_any(Visitor)
3461    }
3462}
3463
3464#[doc(hidden)]
3465impl serde::ser::Serialize for ClientLibrarySettings {
3466    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3467    where
3468        S: serde::ser::Serializer,
3469    {
3470        use serde::ser::SerializeMap;
3471        #[allow(unused_imports)]
3472        use std::option::Option::Some;
3473        let mut state = serializer.serialize_map(std::option::Option::None)?;
3474        if !self.version.is_empty() {
3475            state.serialize_entry("version", &self.version)?;
3476        }
3477        if !wkt::internal::is_default(&self.launch_stage) {
3478            state.serialize_entry("launchStage", &self.launch_stage)?;
3479        }
3480        if !wkt::internal::is_default(&self.rest_numeric_enums) {
3481            state.serialize_entry("restNumericEnums", &self.rest_numeric_enums)?;
3482        }
3483        if self.java_settings.is_some() {
3484            state.serialize_entry("javaSettings", &self.java_settings)?;
3485        }
3486        if self.cpp_settings.is_some() {
3487            state.serialize_entry("cppSettings", &self.cpp_settings)?;
3488        }
3489        if self.php_settings.is_some() {
3490            state.serialize_entry("phpSettings", &self.php_settings)?;
3491        }
3492        if self.python_settings.is_some() {
3493            state.serialize_entry("pythonSettings", &self.python_settings)?;
3494        }
3495        if self.node_settings.is_some() {
3496            state.serialize_entry("nodeSettings", &self.node_settings)?;
3497        }
3498        if self.dotnet_settings.is_some() {
3499            state.serialize_entry("dotnetSettings", &self.dotnet_settings)?;
3500        }
3501        if self.ruby_settings.is_some() {
3502            state.serialize_entry("rubySettings", &self.ruby_settings)?;
3503        }
3504        if self.go_settings.is_some() {
3505            state.serialize_entry("goSettings", &self.go_settings)?;
3506        }
3507        if !self._unknown_fields.is_empty() {
3508            for (key, value) in self._unknown_fields.iter() {
3509                state.serialize_entry(key, &value)?;
3510            }
3511        }
3512        state.end()
3513    }
3514}
3515
3516impl std::fmt::Debug for ClientLibrarySettings {
3517    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3518        let mut debug_struct = f.debug_struct("ClientLibrarySettings");
3519        debug_struct.field("version", &self.version);
3520        debug_struct.field("launch_stage", &self.launch_stage);
3521        debug_struct.field("rest_numeric_enums", &self.rest_numeric_enums);
3522        debug_struct.field("java_settings", &self.java_settings);
3523        debug_struct.field("cpp_settings", &self.cpp_settings);
3524        debug_struct.field("php_settings", &self.php_settings);
3525        debug_struct.field("python_settings", &self.python_settings);
3526        debug_struct.field("node_settings", &self.node_settings);
3527        debug_struct.field("dotnet_settings", &self.dotnet_settings);
3528        debug_struct.field("ruby_settings", &self.ruby_settings);
3529        debug_struct.field("go_settings", &self.go_settings);
3530        if !self._unknown_fields.is_empty() {
3531            debug_struct.field("_unknown_fields", &self._unknown_fields);
3532        }
3533        debug_struct.finish()
3534    }
3535}
3536
3537/// This message configures the settings for publishing [Google Cloud Client
3538/// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
3539/// generated from the service config.
3540#[derive(Clone, Default, PartialEq)]
3541#[non_exhaustive]
3542pub struct Publishing {
3543    /// A list of API method settings, e.g. the behavior for methods that use the
3544    /// long-running operation pattern.
3545    pub method_settings: std::vec::Vec<crate::model::MethodSettings>,
3546
3547    /// Link to a *public* URI where users can report issues.  Example:
3548    /// <https://issuetracker.google.com/issues/new?component=190865&template=1161103>
3549    pub new_issue_uri: std::string::String,
3550
3551    /// Link to product home page.  Example:
3552    /// <https://cloud.google.com/asset-inventory/docs/overview>
3553    pub documentation_uri: std::string::String,
3554
3555    /// Used as a tracking tag when collecting data about the APIs developer
3556    /// relations artifacts like docs, packages delivered to package managers,
3557    /// etc.  Example: "speech".
3558    pub api_short_name: std::string::String,
3559
3560    /// GitHub label to apply to issues and pull requests opened for this API.
3561    pub github_label: std::string::String,
3562
3563    /// GitHub teams to be added to CODEOWNERS in the directory in GitHub
3564    /// containing source code for the client libraries for this API.
3565    pub codeowner_github_teams: std::vec::Vec<std::string::String>,
3566
3567    /// A prefix used in sample code when demarking regions to be included in
3568    /// documentation.
3569    pub doc_tag_prefix: std::string::String,
3570
3571    /// For whom the client library is being published.
3572    pub organization: crate::model::ClientLibraryOrganization,
3573
3574    /// Client library settings.  If the same version string appears multiple
3575    /// times in this list, then the last one wins.  Settings from earlier
3576    /// settings with the same version string are discarded.
3577    pub library_settings: std::vec::Vec<crate::model::ClientLibrarySettings>,
3578
3579    /// Optional link to proto reference documentation.  Example:
3580    /// <https://cloud.google.com/pubsub/lite/docs/reference/rpc>
3581    pub proto_reference_documentation_uri: std::string::String,
3582
3583    /// Optional link to REST reference documentation.  Example:
3584    /// <https://cloud.google.com/pubsub/lite/docs/reference/rest>
3585    pub rest_reference_documentation_uri: std::string::String,
3586
3587    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3588}
3589
3590impl Publishing {
3591    pub fn new() -> Self {
3592        std::default::Default::default()
3593    }
3594
3595    /// Sets the value of [method_settings][crate::model::Publishing::method_settings].
3596    pub fn set_method_settings<T, V>(mut self, v: T) -> Self
3597    where
3598        T: std::iter::IntoIterator<Item = V>,
3599        V: std::convert::Into<crate::model::MethodSettings>,
3600    {
3601        use std::iter::Iterator;
3602        self.method_settings = v.into_iter().map(|i| i.into()).collect();
3603        self
3604    }
3605
3606    /// Sets the value of [new_issue_uri][crate::model::Publishing::new_issue_uri].
3607    pub fn set_new_issue_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3608        self.new_issue_uri = v.into();
3609        self
3610    }
3611
3612    /// Sets the value of [documentation_uri][crate::model::Publishing::documentation_uri].
3613    pub fn set_documentation_uri<T: std::convert::Into<std::string::String>>(
3614        mut self,
3615        v: T,
3616    ) -> Self {
3617        self.documentation_uri = v.into();
3618        self
3619    }
3620
3621    /// Sets the value of [api_short_name][crate::model::Publishing::api_short_name].
3622    pub fn set_api_short_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3623        self.api_short_name = v.into();
3624        self
3625    }
3626
3627    /// Sets the value of [github_label][crate::model::Publishing::github_label].
3628    pub fn set_github_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3629        self.github_label = v.into();
3630        self
3631    }
3632
3633    /// Sets the value of [codeowner_github_teams][crate::model::Publishing::codeowner_github_teams].
3634    pub fn set_codeowner_github_teams<T, V>(mut self, v: T) -> Self
3635    where
3636        T: std::iter::IntoIterator<Item = V>,
3637        V: std::convert::Into<std::string::String>,
3638    {
3639        use std::iter::Iterator;
3640        self.codeowner_github_teams = v.into_iter().map(|i| i.into()).collect();
3641        self
3642    }
3643
3644    /// Sets the value of [doc_tag_prefix][crate::model::Publishing::doc_tag_prefix].
3645    pub fn set_doc_tag_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3646        self.doc_tag_prefix = v.into();
3647        self
3648    }
3649
3650    /// Sets the value of [organization][crate::model::Publishing::organization].
3651    pub fn set_organization<T: std::convert::Into<crate::model::ClientLibraryOrganization>>(
3652        mut self,
3653        v: T,
3654    ) -> Self {
3655        self.organization = v.into();
3656        self
3657    }
3658
3659    /// Sets the value of [library_settings][crate::model::Publishing::library_settings].
3660    pub fn set_library_settings<T, V>(mut self, v: T) -> Self
3661    where
3662        T: std::iter::IntoIterator<Item = V>,
3663        V: std::convert::Into<crate::model::ClientLibrarySettings>,
3664    {
3665        use std::iter::Iterator;
3666        self.library_settings = v.into_iter().map(|i| i.into()).collect();
3667        self
3668    }
3669
3670    /// Sets the value of [proto_reference_documentation_uri][crate::model::Publishing::proto_reference_documentation_uri].
3671    pub fn set_proto_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
3672        mut self,
3673        v: T,
3674    ) -> Self {
3675        self.proto_reference_documentation_uri = v.into();
3676        self
3677    }
3678
3679    /// Sets the value of [rest_reference_documentation_uri][crate::model::Publishing::rest_reference_documentation_uri].
3680    pub fn set_rest_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
3681        mut self,
3682        v: T,
3683    ) -> Self {
3684        self.rest_reference_documentation_uri = v.into();
3685        self
3686    }
3687}
3688
3689impl wkt::message::Message for Publishing {
3690    fn typename() -> &'static str {
3691        "type.googleapis.com/google.api.Publishing"
3692    }
3693}
3694
3695#[doc(hidden)]
3696impl<'de> serde::de::Deserialize<'de> for Publishing {
3697    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3698    where
3699        D: serde::Deserializer<'de>,
3700    {
3701        #[allow(non_camel_case_types)]
3702        #[doc(hidden)]
3703        #[derive(PartialEq, Eq, Hash)]
3704        enum __FieldTag {
3705            __method_settings,
3706            __new_issue_uri,
3707            __documentation_uri,
3708            __api_short_name,
3709            __github_label,
3710            __codeowner_github_teams,
3711            __doc_tag_prefix,
3712            __organization,
3713            __library_settings,
3714            __proto_reference_documentation_uri,
3715            __rest_reference_documentation_uri,
3716            Unknown(std::string::String),
3717        }
3718        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3719            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3720            where
3721                D: serde::Deserializer<'de>,
3722            {
3723                struct Visitor;
3724                impl<'de> serde::de::Visitor<'de> for Visitor {
3725                    type Value = __FieldTag;
3726                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3727                        formatter.write_str("a field name for Publishing")
3728                    }
3729                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3730                    where
3731                        E: serde::de::Error,
3732                    {
3733                        use std::result::Result::Ok;
3734                        use std::string::ToString;
3735                        match value {
3736                            "methodSettings" => Ok(__FieldTag::__method_settings),
3737                            "method_settings" => Ok(__FieldTag::__method_settings),
3738                            "newIssueUri" => Ok(__FieldTag::__new_issue_uri),
3739                            "new_issue_uri" => Ok(__FieldTag::__new_issue_uri),
3740                            "documentationUri" => Ok(__FieldTag::__documentation_uri),
3741                            "documentation_uri" => Ok(__FieldTag::__documentation_uri),
3742                            "apiShortName" => Ok(__FieldTag::__api_short_name),
3743                            "api_short_name" => Ok(__FieldTag::__api_short_name),
3744                            "githubLabel" => Ok(__FieldTag::__github_label),
3745                            "github_label" => Ok(__FieldTag::__github_label),
3746                            "codeownerGithubTeams" => Ok(__FieldTag::__codeowner_github_teams),
3747                            "codeowner_github_teams" => Ok(__FieldTag::__codeowner_github_teams),
3748                            "docTagPrefix" => Ok(__FieldTag::__doc_tag_prefix),
3749                            "doc_tag_prefix" => Ok(__FieldTag::__doc_tag_prefix),
3750                            "organization" => Ok(__FieldTag::__organization),
3751                            "librarySettings" => Ok(__FieldTag::__library_settings),
3752                            "library_settings" => Ok(__FieldTag::__library_settings),
3753                            "protoReferenceDocumentationUri" => {
3754                                Ok(__FieldTag::__proto_reference_documentation_uri)
3755                            }
3756                            "proto_reference_documentation_uri" => {
3757                                Ok(__FieldTag::__proto_reference_documentation_uri)
3758                            }
3759                            "restReferenceDocumentationUri" => {
3760                                Ok(__FieldTag::__rest_reference_documentation_uri)
3761                            }
3762                            "rest_reference_documentation_uri" => {
3763                                Ok(__FieldTag::__rest_reference_documentation_uri)
3764                            }
3765                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3766                        }
3767                    }
3768                }
3769                deserializer.deserialize_identifier(Visitor)
3770            }
3771        }
3772        struct Visitor;
3773        impl<'de> serde::de::Visitor<'de> for Visitor {
3774            type Value = Publishing;
3775            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3776                formatter.write_str("struct Publishing")
3777            }
3778            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3779            where
3780                A: serde::de::MapAccess<'de>,
3781            {
3782                #[allow(unused_imports)]
3783                use serde::de::Error;
3784                use std::option::Option::Some;
3785                let mut fields = std::collections::HashSet::new();
3786                let mut result = Self::Value::new();
3787                while let Some(tag) = map.next_key::<__FieldTag>()? {
3788                    #[allow(clippy::match_single_binding)]
3789                    match tag {
3790                        __FieldTag::__method_settings => {
3791                            if !fields.insert(__FieldTag::__method_settings) {
3792                                return std::result::Result::Err(A::Error::duplicate_field(
3793                                    "multiple values for method_settings",
3794                                ));
3795                            }
3796                            result.method_settings =
3797                                map.next_value::<std::option::Option<
3798                                    std::vec::Vec<crate::model::MethodSettings>,
3799                                >>()?
3800                                .unwrap_or_default();
3801                        }
3802                        __FieldTag::__new_issue_uri => {
3803                            if !fields.insert(__FieldTag::__new_issue_uri) {
3804                                return std::result::Result::Err(A::Error::duplicate_field(
3805                                    "multiple values for new_issue_uri",
3806                                ));
3807                            }
3808                            result.new_issue_uri = map
3809                                .next_value::<std::option::Option<std::string::String>>()?
3810                                .unwrap_or_default();
3811                        }
3812                        __FieldTag::__documentation_uri => {
3813                            if !fields.insert(__FieldTag::__documentation_uri) {
3814                                return std::result::Result::Err(A::Error::duplicate_field(
3815                                    "multiple values for documentation_uri",
3816                                ));
3817                            }
3818                            result.documentation_uri = map
3819                                .next_value::<std::option::Option<std::string::String>>()?
3820                                .unwrap_or_default();
3821                        }
3822                        __FieldTag::__api_short_name => {
3823                            if !fields.insert(__FieldTag::__api_short_name) {
3824                                return std::result::Result::Err(A::Error::duplicate_field(
3825                                    "multiple values for api_short_name",
3826                                ));
3827                            }
3828                            result.api_short_name = map
3829                                .next_value::<std::option::Option<std::string::String>>()?
3830                                .unwrap_or_default();
3831                        }
3832                        __FieldTag::__github_label => {
3833                            if !fields.insert(__FieldTag::__github_label) {
3834                                return std::result::Result::Err(A::Error::duplicate_field(
3835                                    "multiple values for github_label",
3836                                ));
3837                            }
3838                            result.github_label = map
3839                                .next_value::<std::option::Option<std::string::String>>()?
3840                                .unwrap_or_default();
3841                        }
3842                        __FieldTag::__codeowner_github_teams => {
3843                            if !fields.insert(__FieldTag::__codeowner_github_teams) {
3844                                return std::result::Result::Err(A::Error::duplicate_field(
3845                                    "multiple values for codeowner_github_teams",
3846                                ));
3847                            }
3848                            result.codeowner_github_teams = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
3849                        }
3850                        __FieldTag::__doc_tag_prefix => {
3851                            if !fields.insert(__FieldTag::__doc_tag_prefix) {
3852                                return std::result::Result::Err(A::Error::duplicate_field(
3853                                    "multiple values for doc_tag_prefix",
3854                                ));
3855                            }
3856                            result.doc_tag_prefix = map
3857                                .next_value::<std::option::Option<std::string::String>>()?
3858                                .unwrap_or_default();
3859                        }
3860                        __FieldTag::__organization => {
3861                            if !fields.insert(__FieldTag::__organization) {
3862                                return std::result::Result::Err(A::Error::duplicate_field(
3863                                    "multiple values for organization",
3864                                ));
3865                            }
3866                            result.organization = map.next_value::<std::option::Option<crate::model::ClientLibraryOrganization>>()?.unwrap_or_default();
3867                        }
3868                        __FieldTag::__library_settings => {
3869                            if !fields.insert(__FieldTag::__library_settings) {
3870                                return std::result::Result::Err(A::Error::duplicate_field(
3871                                    "multiple values for library_settings",
3872                                ));
3873                            }
3874                            result.library_settings = map
3875                                .next_value::<std::option::Option<
3876                                    std::vec::Vec<crate::model::ClientLibrarySettings>,
3877                                >>()?
3878                                .unwrap_or_default();
3879                        }
3880                        __FieldTag::__proto_reference_documentation_uri => {
3881                            if !fields.insert(__FieldTag::__proto_reference_documentation_uri) {
3882                                return std::result::Result::Err(A::Error::duplicate_field(
3883                                    "multiple values for proto_reference_documentation_uri",
3884                                ));
3885                            }
3886                            result.proto_reference_documentation_uri = map
3887                                .next_value::<std::option::Option<std::string::String>>()?
3888                                .unwrap_or_default();
3889                        }
3890                        __FieldTag::__rest_reference_documentation_uri => {
3891                            if !fields.insert(__FieldTag::__rest_reference_documentation_uri) {
3892                                return std::result::Result::Err(A::Error::duplicate_field(
3893                                    "multiple values for rest_reference_documentation_uri",
3894                                ));
3895                            }
3896                            result.rest_reference_documentation_uri = map
3897                                .next_value::<std::option::Option<std::string::String>>()?
3898                                .unwrap_or_default();
3899                        }
3900                        __FieldTag::Unknown(key) => {
3901                            let value = map.next_value::<serde_json::Value>()?;
3902                            result._unknown_fields.insert(key, value);
3903                        }
3904                    }
3905                }
3906                std::result::Result::Ok(result)
3907            }
3908        }
3909        deserializer.deserialize_any(Visitor)
3910    }
3911}
3912
3913#[doc(hidden)]
3914impl serde::ser::Serialize for Publishing {
3915    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3916    where
3917        S: serde::ser::Serializer,
3918    {
3919        use serde::ser::SerializeMap;
3920        #[allow(unused_imports)]
3921        use std::option::Option::Some;
3922        let mut state = serializer.serialize_map(std::option::Option::None)?;
3923        if !self.method_settings.is_empty() {
3924            state.serialize_entry("methodSettings", &self.method_settings)?;
3925        }
3926        if !self.new_issue_uri.is_empty() {
3927            state.serialize_entry("newIssueUri", &self.new_issue_uri)?;
3928        }
3929        if !self.documentation_uri.is_empty() {
3930            state.serialize_entry("documentationUri", &self.documentation_uri)?;
3931        }
3932        if !self.api_short_name.is_empty() {
3933            state.serialize_entry("apiShortName", &self.api_short_name)?;
3934        }
3935        if !self.github_label.is_empty() {
3936            state.serialize_entry("githubLabel", &self.github_label)?;
3937        }
3938        if !self.codeowner_github_teams.is_empty() {
3939            state.serialize_entry("codeownerGithubTeams", &self.codeowner_github_teams)?;
3940        }
3941        if !self.doc_tag_prefix.is_empty() {
3942            state.serialize_entry("docTagPrefix", &self.doc_tag_prefix)?;
3943        }
3944        if !wkt::internal::is_default(&self.organization) {
3945            state.serialize_entry("organization", &self.organization)?;
3946        }
3947        if !self.library_settings.is_empty() {
3948            state.serialize_entry("librarySettings", &self.library_settings)?;
3949        }
3950        if !self.proto_reference_documentation_uri.is_empty() {
3951            state.serialize_entry(
3952                "protoReferenceDocumentationUri",
3953                &self.proto_reference_documentation_uri,
3954            )?;
3955        }
3956        if !self.rest_reference_documentation_uri.is_empty() {
3957            state.serialize_entry(
3958                "restReferenceDocumentationUri",
3959                &self.rest_reference_documentation_uri,
3960            )?;
3961        }
3962        if !self._unknown_fields.is_empty() {
3963            for (key, value) in self._unknown_fields.iter() {
3964                state.serialize_entry(key, &value)?;
3965            }
3966        }
3967        state.end()
3968    }
3969}
3970
3971impl std::fmt::Debug for Publishing {
3972    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3973        let mut debug_struct = f.debug_struct("Publishing");
3974        debug_struct.field("method_settings", &self.method_settings);
3975        debug_struct.field("new_issue_uri", &self.new_issue_uri);
3976        debug_struct.field("documentation_uri", &self.documentation_uri);
3977        debug_struct.field("api_short_name", &self.api_short_name);
3978        debug_struct.field("github_label", &self.github_label);
3979        debug_struct.field("codeowner_github_teams", &self.codeowner_github_teams);
3980        debug_struct.field("doc_tag_prefix", &self.doc_tag_prefix);
3981        debug_struct.field("organization", &self.organization);
3982        debug_struct.field("library_settings", &self.library_settings);
3983        debug_struct.field(
3984            "proto_reference_documentation_uri",
3985            &self.proto_reference_documentation_uri,
3986        );
3987        debug_struct.field(
3988            "rest_reference_documentation_uri",
3989            &self.rest_reference_documentation_uri,
3990        );
3991        if !self._unknown_fields.is_empty() {
3992            debug_struct.field("_unknown_fields", &self._unknown_fields);
3993        }
3994        debug_struct.finish()
3995    }
3996}
3997
3998/// Settings for Java client libraries.
3999#[derive(Clone, Default, PartialEq)]
4000#[non_exhaustive]
4001pub struct JavaSettings {
4002    /// The package name to use in Java. Clobbers the java_package option
4003    /// set in the protobuf. This should be used **only** by APIs
4004    /// who have already set the language_settings.java.package_name" field
4005    /// in gapic.yaml. API teams should use the protobuf java_package option
4006    /// where possible.
4007    ///
4008    /// Example of a YAML configuration::
4009    ///
4010    /// publishing:
4011    /// java_settings:
4012    /// library_package: com.google.cloud.pubsub.v1
4013    pub library_package: std::string::String,
4014
4015    /// Configure the Java class name to use instead of the service's for its
4016    /// corresponding generated GAPIC client. Keys are fully-qualified
4017    /// service names as they appear in the protobuf (including the full
4018    /// the language_settings.java.interface_names" field in gapic.yaml. API
4019    /// teams should otherwise use the service name as it appears in the
4020    /// protobuf.
4021    ///
4022    /// Example of a YAML configuration::
4023    ///
4024    /// publishing:
4025    /// java_settings:
4026    /// service_class_names:
4027    /// - google.pubsub.v1.Publisher: TopicAdmin
4028    /// - google.pubsub.v1.Subscriber: SubscriptionAdmin
4029    pub service_class_names: std::collections::HashMap<std::string::String, std::string::String>,
4030
4031    /// Some settings.
4032    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4033
4034    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4035}
4036
4037impl JavaSettings {
4038    pub fn new() -> Self {
4039        std::default::Default::default()
4040    }
4041
4042    /// Sets the value of [library_package][crate::model::JavaSettings::library_package].
4043    pub fn set_library_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4044        self.library_package = v.into();
4045        self
4046    }
4047
4048    /// Sets the value of [service_class_names][crate::model::JavaSettings::service_class_names].
4049    pub fn set_service_class_names<T, K, V>(mut self, v: T) -> Self
4050    where
4051        T: std::iter::IntoIterator<Item = (K, V)>,
4052        K: std::convert::Into<std::string::String>,
4053        V: std::convert::Into<std::string::String>,
4054    {
4055        use std::iter::Iterator;
4056        self.service_class_names = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4057        self
4058    }
4059
4060    /// Sets the value of [common][crate::model::JavaSettings::common].
4061    pub fn set_common<T>(mut self, v: T) -> Self
4062    where
4063        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4064    {
4065        self.common = std::option::Option::Some(v.into());
4066        self
4067    }
4068
4069    /// Sets or clears the value of [common][crate::model::JavaSettings::common].
4070    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4071    where
4072        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4073    {
4074        self.common = v.map(|x| x.into());
4075        self
4076    }
4077}
4078
4079impl wkt::message::Message for JavaSettings {
4080    fn typename() -> &'static str {
4081        "type.googleapis.com/google.api.JavaSettings"
4082    }
4083}
4084
4085#[doc(hidden)]
4086impl<'de> serde::de::Deserialize<'de> for JavaSettings {
4087    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4088    where
4089        D: serde::Deserializer<'de>,
4090    {
4091        #[allow(non_camel_case_types)]
4092        #[doc(hidden)]
4093        #[derive(PartialEq, Eq, Hash)]
4094        enum __FieldTag {
4095            __library_package,
4096            __service_class_names,
4097            __common,
4098            Unknown(std::string::String),
4099        }
4100        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4101            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4102            where
4103                D: serde::Deserializer<'de>,
4104            {
4105                struct Visitor;
4106                impl<'de> serde::de::Visitor<'de> for Visitor {
4107                    type Value = __FieldTag;
4108                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4109                        formatter.write_str("a field name for JavaSettings")
4110                    }
4111                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4112                    where
4113                        E: serde::de::Error,
4114                    {
4115                        use std::result::Result::Ok;
4116                        use std::string::ToString;
4117                        match value {
4118                            "libraryPackage" => Ok(__FieldTag::__library_package),
4119                            "library_package" => Ok(__FieldTag::__library_package),
4120                            "serviceClassNames" => Ok(__FieldTag::__service_class_names),
4121                            "service_class_names" => Ok(__FieldTag::__service_class_names),
4122                            "common" => Ok(__FieldTag::__common),
4123                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4124                        }
4125                    }
4126                }
4127                deserializer.deserialize_identifier(Visitor)
4128            }
4129        }
4130        struct Visitor;
4131        impl<'de> serde::de::Visitor<'de> for Visitor {
4132            type Value = JavaSettings;
4133            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4134                formatter.write_str("struct JavaSettings")
4135            }
4136            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4137            where
4138                A: serde::de::MapAccess<'de>,
4139            {
4140                #[allow(unused_imports)]
4141                use serde::de::Error;
4142                use std::option::Option::Some;
4143                let mut fields = std::collections::HashSet::new();
4144                let mut result = Self::Value::new();
4145                while let Some(tag) = map.next_key::<__FieldTag>()? {
4146                    #[allow(clippy::match_single_binding)]
4147                    match tag {
4148                        __FieldTag::__library_package => {
4149                            if !fields.insert(__FieldTag::__library_package) {
4150                                return std::result::Result::Err(A::Error::duplicate_field(
4151                                    "multiple values for library_package",
4152                                ));
4153                            }
4154                            result.library_package = map
4155                                .next_value::<std::option::Option<std::string::String>>()?
4156                                .unwrap_or_default();
4157                        }
4158                        __FieldTag::__service_class_names => {
4159                            if !fields.insert(__FieldTag::__service_class_names) {
4160                                return std::result::Result::Err(A::Error::duplicate_field(
4161                                    "multiple values for service_class_names",
4162                                ));
4163                            }
4164                            result.service_class_names = map
4165                                .next_value::<std::option::Option<
4166                                    std::collections::HashMap<
4167                                        std::string::String,
4168                                        std::string::String,
4169                                    >,
4170                                >>()?
4171                                .unwrap_or_default();
4172                        }
4173                        __FieldTag::__common => {
4174                            if !fields.insert(__FieldTag::__common) {
4175                                return std::result::Result::Err(A::Error::duplicate_field(
4176                                    "multiple values for common",
4177                                ));
4178                            }
4179                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4180                                ;
4181                        }
4182                        __FieldTag::Unknown(key) => {
4183                            let value = map.next_value::<serde_json::Value>()?;
4184                            result._unknown_fields.insert(key, value);
4185                        }
4186                    }
4187                }
4188                std::result::Result::Ok(result)
4189            }
4190        }
4191        deserializer.deserialize_any(Visitor)
4192    }
4193}
4194
4195#[doc(hidden)]
4196impl serde::ser::Serialize for JavaSettings {
4197    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4198    where
4199        S: serde::ser::Serializer,
4200    {
4201        use serde::ser::SerializeMap;
4202        #[allow(unused_imports)]
4203        use std::option::Option::Some;
4204        let mut state = serializer.serialize_map(std::option::Option::None)?;
4205        if !self.library_package.is_empty() {
4206            state.serialize_entry("libraryPackage", &self.library_package)?;
4207        }
4208        if !self.service_class_names.is_empty() {
4209            state.serialize_entry("serviceClassNames", &self.service_class_names)?;
4210        }
4211        if self.common.is_some() {
4212            state.serialize_entry("common", &self.common)?;
4213        }
4214        if !self._unknown_fields.is_empty() {
4215            for (key, value) in self._unknown_fields.iter() {
4216                state.serialize_entry(key, &value)?;
4217            }
4218        }
4219        state.end()
4220    }
4221}
4222
4223impl std::fmt::Debug for JavaSettings {
4224    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4225        let mut debug_struct = f.debug_struct("JavaSettings");
4226        debug_struct.field("library_package", &self.library_package);
4227        debug_struct.field("service_class_names", &self.service_class_names);
4228        debug_struct.field("common", &self.common);
4229        if !self._unknown_fields.is_empty() {
4230            debug_struct.field("_unknown_fields", &self._unknown_fields);
4231        }
4232        debug_struct.finish()
4233    }
4234}
4235
4236/// Settings for C++ client libraries.
4237#[derive(Clone, Default, PartialEq)]
4238#[non_exhaustive]
4239pub struct CppSettings {
4240    /// Some settings.
4241    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4242
4243    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4244}
4245
4246impl CppSettings {
4247    pub fn new() -> Self {
4248        std::default::Default::default()
4249    }
4250
4251    /// Sets the value of [common][crate::model::CppSettings::common].
4252    pub fn set_common<T>(mut self, v: T) -> Self
4253    where
4254        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4255    {
4256        self.common = std::option::Option::Some(v.into());
4257        self
4258    }
4259
4260    /// Sets or clears the value of [common][crate::model::CppSettings::common].
4261    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4262    where
4263        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4264    {
4265        self.common = v.map(|x| x.into());
4266        self
4267    }
4268}
4269
4270impl wkt::message::Message for CppSettings {
4271    fn typename() -> &'static str {
4272        "type.googleapis.com/google.api.CppSettings"
4273    }
4274}
4275
4276#[doc(hidden)]
4277impl<'de> serde::de::Deserialize<'de> for CppSettings {
4278    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4279    where
4280        D: serde::Deserializer<'de>,
4281    {
4282        #[allow(non_camel_case_types)]
4283        #[doc(hidden)]
4284        #[derive(PartialEq, Eq, Hash)]
4285        enum __FieldTag {
4286            __common,
4287            Unknown(std::string::String),
4288        }
4289        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4290            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4291            where
4292                D: serde::Deserializer<'de>,
4293            {
4294                struct Visitor;
4295                impl<'de> serde::de::Visitor<'de> for Visitor {
4296                    type Value = __FieldTag;
4297                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4298                        formatter.write_str("a field name for CppSettings")
4299                    }
4300                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4301                    where
4302                        E: serde::de::Error,
4303                    {
4304                        use std::result::Result::Ok;
4305                        use std::string::ToString;
4306                        match value {
4307                            "common" => Ok(__FieldTag::__common),
4308                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4309                        }
4310                    }
4311                }
4312                deserializer.deserialize_identifier(Visitor)
4313            }
4314        }
4315        struct Visitor;
4316        impl<'de> serde::de::Visitor<'de> for Visitor {
4317            type Value = CppSettings;
4318            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4319                formatter.write_str("struct CppSettings")
4320            }
4321            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4322            where
4323                A: serde::de::MapAccess<'de>,
4324            {
4325                #[allow(unused_imports)]
4326                use serde::de::Error;
4327                use std::option::Option::Some;
4328                let mut fields = std::collections::HashSet::new();
4329                let mut result = Self::Value::new();
4330                while let Some(tag) = map.next_key::<__FieldTag>()? {
4331                    #[allow(clippy::match_single_binding)]
4332                    match tag {
4333                        __FieldTag::__common => {
4334                            if !fields.insert(__FieldTag::__common) {
4335                                return std::result::Result::Err(A::Error::duplicate_field(
4336                                    "multiple values for common",
4337                                ));
4338                            }
4339                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4340                                ;
4341                        }
4342                        __FieldTag::Unknown(key) => {
4343                            let value = map.next_value::<serde_json::Value>()?;
4344                            result._unknown_fields.insert(key, value);
4345                        }
4346                    }
4347                }
4348                std::result::Result::Ok(result)
4349            }
4350        }
4351        deserializer.deserialize_any(Visitor)
4352    }
4353}
4354
4355#[doc(hidden)]
4356impl serde::ser::Serialize for CppSettings {
4357    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4358    where
4359        S: serde::ser::Serializer,
4360    {
4361        use serde::ser::SerializeMap;
4362        #[allow(unused_imports)]
4363        use std::option::Option::Some;
4364        let mut state = serializer.serialize_map(std::option::Option::None)?;
4365        if self.common.is_some() {
4366            state.serialize_entry("common", &self.common)?;
4367        }
4368        if !self._unknown_fields.is_empty() {
4369            for (key, value) in self._unknown_fields.iter() {
4370                state.serialize_entry(key, &value)?;
4371            }
4372        }
4373        state.end()
4374    }
4375}
4376
4377impl std::fmt::Debug for CppSettings {
4378    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4379        let mut debug_struct = f.debug_struct("CppSettings");
4380        debug_struct.field("common", &self.common);
4381        if !self._unknown_fields.is_empty() {
4382            debug_struct.field("_unknown_fields", &self._unknown_fields);
4383        }
4384        debug_struct.finish()
4385    }
4386}
4387
4388/// Settings for Php client libraries.
4389#[derive(Clone, Default, PartialEq)]
4390#[non_exhaustive]
4391pub struct PhpSettings {
4392    /// Some settings.
4393    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4394
4395    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4396}
4397
4398impl PhpSettings {
4399    pub fn new() -> Self {
4400        std::default::Default::default()
4401    }
4402
4403    /// Sets the value of [common][crate::model::PhpSettings::common].
4404    pub fn set_common<T>(mut self, v: T) -> Self
4405    where
4406        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4407    {
4408        self.common = std::option::Option::Some(v.into());
4409        self
4410    }
4411
4412    /// Sets or clears the value of [common][crate::model::PhpSettings::common].
4413    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4414    where
4415        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4416    {
4417        self.common = v.map(|x| x.into());
4418        self
4419    }
4420}
4421
4422impl wkt::message::Message for PhpSettings {
4423    fn typename() -> &'static str {
4424        "type.googleapis.com/google.api.PhpSettings"
4425    }
4426}
4427
4428#[doc(hidden)]
4429impl<'de> serde::de::Deserialize<'de> for PhpSettings {
4430    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4431    where
4432        D: serde::Deserializer<'de>,
4433    {
4434        #[allow(non_camel_case_types)]
4435        #[doc(hidden)]
4436        #[derive(PartialEq, Eq, Hash)]
4437        enum __FieldTag {
4438            __common,
4439            Unknown(std::string::String),
4440        }
4441        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4442            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4443            where
4444                D: serde::Deserializer<'de>,
4445            {
4446                struct Visitor;
4447                impl<'de> serde::de::Visitor<'de> for Visitor {
4448                    type Value = __FieldTag;
4449                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4450                        formatter.write_str("a field name for PhpSettings")
4451                    }
4452                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4453                    where
4454                        E: serde::de::Error,
4455                    {
4456                        use std::result::Result::Ok;
4457                        use std::string::ToString;
4458                        match value {
4459                            "common" => Ok(__FieldTag::__common),
4460                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4461                        }
4462                    }
4463                }
4464                deserializer.deserialize_identifier(Visitor)
4465            }
4466        }
4467        struct Visitor;
4468        impl<'de> serde::de::Visitor<'de> for Visitor {
4469            type Value = PhpSettings;
4470            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4471                formatter.write_str("struct PhpSettings")
4472            }
4473            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4474            where
4475                A: serde::de::MapAccess<'de>,
4476            {
4477                #[allow(unused_imports)]
4478                use serde::de::Error;
4479                use std::option::Option::Some;
4480                let mut fields = std::collections::HashSet::new();
4481                let mut result = Self::Value::new();
4482                while let Some(tag) = map.next_key::<__FieldTag>()? {
4483                    #[allow(clippy::match_single_binding)]
4484                    match tag {
4485                        __FieldTag::__common => {
4486                            if !fields.insert(__FieldTag::__common) {
4487                                return std::result::Result::Err(A::Error::duplicate_field(
4488                                    "multiple values for common",
4489                                ));
4490                            }
4491                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4492                                ;
4493                        }
4494                        __FieldTag::Unknown(key) => {
4495                            let value = map.next_value::<serde_json::Value>()?;
4496                            result._unknown_fields.insert(key, value);
4497                        }
4498                    }
4499                }
4500                std::result::Result::Ok(result)
4501            }
4502        }
4503        deserializer.deserialize_any(Visitor)
4504    }
4505}
4506
4507#[doc(hidden)]
4508impl serde::ser::Serialize for PhpSettings {
4509    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4510    where
4511        S: serde::ser::Serializer,
4512    {
4513        use serde::ser::SerializeMap;
4514        #[allow(unused_imports)]
4515        use std::option::Option::Some;
4516        let mut state = serializer.serialize_map(std::option::Option::None)?;
4517        if self.common.is_some() {
4518            state.serialize_entry("common", &self.common)?;
4519        }
4520        if !self._unknown_fields.is_empty() {
4521            for (key, value) in self._unknown_fields.iter() {
4522                state.serialize_entry(key, &value)?;
4523            }
4524        }
4525        state.end()
4526    }
4527}
4528
4529impl std::fmt::Debug for PhpSettings {
4530    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4531        let mut debug_struct = f.debug_struct("PhpSettings");
4532        debug_struct.field("common", &self.common);
4533        if !self._unknown_fields.is_empty() {
4534            debug_struct.field("_unknown_fields", &self._unknown_fields);
4535        }
4536        debug_struct.finish()
4537    }
4538}
4539
4540/// Settings for Python client libraries.
4541#[derive(Clone, Default, PartialEq)]
4542#[non_exhaustive]
4543pub struct PythonSettings {
4544    /// Some settings.
4545    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4546
4547    /// Experimental features to be included during client library generation.
4548    pub experimental_features:
4549        std::option::Option<crate::model::python_settings::ExperimentalFeatures>,
4550
4551    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4552}
4553
4554impl PythonSettings {
4555    pub fn new() -> Self {
4556        std::default::Default::default()
4557    }
4558
4559    /// Sets the value of [common][crate::model::PythonSettings::common].
4560    pub fn set_common<T>(mut self, v: T) -> Self
4561    where
4562        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4563    {
4564        self.common = std::option::Option::Some(v.into());
4565        self
4566    }
4567
4568    /// Sets or clears the value of [common][crate::model::PythonSettings::common].
4569    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4570    where
4571        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4572    {
4573        self.common = v.map(|x| x.into());
4574        self
4575    }
4576
4577    /// Sets the value of [experimental_features][crate::model::PythonSettings::experimental_features].
4578    pub fn set_experimental_features<T>(mut self, v: T) -> Self
4579    where
4580        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
4581    {
4582        self.experimental_features = std::option::Option::Some(v.into());
4583        self
4584    }
4585
4586    /// Sets or clears the value of [experimental_features][crate::model::PythonSettings::experimental_features].
4587    pub fn set_or_clear_experimental_features<T>(mut self, v: std::option::Option<T>) -> Self
4588    where
4589        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
4590    {
4591        self.experimental_features = v.map(|x| x.into());
4592        self
4593    }
4594}
4595
4596impl wkt::message::Message for PythonSettings {
4597    fn typename() -> &'static str {
4598        "type.googleapis.com/google.api.PythonSettings"
4599    }
4600}
4601
4602#[doc(hidden)]
4603impl<'de> serde::de::Deserialize<'de> for PythonSettings {
4604    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4605    where
4606        D: serde::Deserializer<'de>,
4607    {
4608        #[allow(non_camel_case_types)]
4609        #[doc(hidden)]
4610        #[derive(PartialEq, Eq, Hash)]
4611        enum __FieldTag {
4612            __common,
4613            __experimental_features,
4614            Unknown(std::string::String),
4615        }
4616        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4617            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4618            where
4619                D: serde::Deserializer<'de>,
4620            {
4621                struct Visitor;
4622                impl<'de> serde::de::Visitor<'de> for Visitor {
4623                    type Value = __FieldTag;
4624                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4625                        formatter.write_str("a field name for PythonSettings")
4626                    }
4627                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4628                    where
4629                        E: serde::de::Error,
4630                    {
4631                        use std::result::Result::Ok;
4632                        use std::string::ToString;
4633                        match value {
4634                            "common" => Ok(__FieldTag::__common),
4635                            "experimentalFeatures" => Ok(__FieldTag::__experimental_features),
4636                            "experimental_features" => Ok(__FieldTag::__experimental_features),
4637                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4638                        }
4639                    }
4640                }
4641                deserializer.deserialize_identifier(Visitor)
4642            }
4643        }
4644        struct Visitor;
4645        impl<'de> serde::de::Visitor<'de> for Visitor {
4646            type Value = PythonSettings;
4647            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4648                formatter.write_str("struct PythonSettings")
4649            }
4650            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4651            where
4652                A: serde::de::MapAccess<'de>,
4653            {
4654                #[allow(unused_imports)]
4655                use serde::de::Error;
4656                use std::option::Option::Some;
4657                let mut fields = std::collections::HashSet::new();
4658                let mut result = Self::Value::new();
4659                while let Some(tag) = map.next_key::<__FieldTag>()? {
4660                    #[allow(clippy::match_single_binding)]
4661                    match tag {
4662                        __FieldTag::__common => {
4663                            if !fields.insert(__FieldTag::__common) {
4664                                return std::result::Result::Err(A::Error::duplicate_field(
4665                                    "multiple values for common",
4666                                ));
4667                            }
4668                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4669                                ;
4670                        }
4671                        __FieldTag::__experimental_features => {
4672                            if !fields.insert(__FieldTag::__experimental_features) {
4673                                return std::result::Result::Err(A::Error::duplicate_field(
4674                                    "multiple values for experimental_features",
4675                                ));
4676                            }
4677                            result.experimental_features = map.next_value::<std::option::Option<
4678                                crate::model::python_settings::ExperimentalFeatures,
4679                            >>()?;
4680                        }
4681                        __FieldTag::Unknown(key) => {
4682                            let value = map.next_value::<serde_json::Value>()?;
4683                            result._unknown_fields.insert(key, value);
4684                        }
4685                    }
4686                }
4687                std::result::Result::Ok(result)
4688            }
4689        }
4690        deserializer.deserialize_any(Visitor)
4691    }
4692}
4693
4694#[doc(hidden)]
4695impl serde::ser::Serialize for PythonSettings {
4696    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4697    where
4698        S: serde::ser::Serializer,
4699    {
4700        use serde::ser::SerializeMap;
4701        #[allow(unused_imports)]
4702        use std::option::Option::Some;
4703        let mut state = serializer.serialize_map(std::option::Option::None)?;
4704        if self.common.is_some() {
4705            state.serialize_entry("common", &self.common)?;
4706        }
4707        if self.experimental_features.is_some() {
4708            state.serialize_entry("experimentalFeatures", &self.experimental_features)?;
4709        }
4710        if !self._unknown_fields.is_empty() {
4711            for (key, value) in self._unknown_fields.iter() {
4712                state.serialize_entry(key, &value)?;
4713            }
4714        }
4715        state.end()
4716    }
4717}
4718
4719impl std::fmt::Debug for PythonSettings {
4720    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4721        let mut debug_struct = f.debug_struct("PythonSettings");
4722        debug_struct.field("common", &self.common);
4723        debug_struct.field("experimental_features", &self.experimental_features);
4724        if !self._unknown_fields.is_empty() {
4725            debug_struct.field("_unknown_fields", &self._unknown_fields);
4726        }
4727        debug_struct.finish()
4728    }
4729}
4730
4731/// Defines additional types related to [PythonSettings].
4732pub mod python_settings {
4733    #[allow(unused_imports)]
4734    use super::*;
4735
4736    /// Experimental features to be included during client library generation.
4737    /// These fields will be deprecated once the feature graduates and is enabled
4738    /// by default.
4739    #[derive(Clone, Default, PartialEq)]
4740    #[non_exhaustive]
4741    pub struct ExperimentalFeatures {
4742        /// Enables generation of asynchronous REST clients if `rest` transport is
4743        /// enabled. By default, asynchronous REST clients will not be generated.
4744        /// This feature will be enabled by default 1 month after launching the
4745        /// feature in preview packages.
4746        pub rest_async_io_enabled: bool,
4747
4748        /// Enables generation of protobuf code using new types that are more
4749        /// Pythonic which are included in `protobuf>=5.29.x`. This feature will be
4750        /// enabled by default 1 month after launching the feature in preview
4751        /// packages.
4752        pub protobuf_pythonic_types_enabled: bool,
4753
4754        /// Disables generation of an unversioned Python package for this client
4755        /// library. This means that the module names will need to be versioned in
4756        /// import statements. For example `import google.cloud.library_v2` instead
4757        /// of `import google.cloud.library`.
4758        pub unversioned_package_disabled: bool,
4759
4760        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4761    }
4762
4763    impl ExperimentalFeatures {
4764        pub fn new() -> Self {
4765            std::default::Default::default()
4766        }
4767
4768        /// Sets the value of [rest_async_io_enabled][crate::model::python_settings::ExperimentalFeatures::rest_async_io_enabled].
4769        pub fn set_rest_async_io_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4770            self.rest_async_io_enabled = v.into();
4771            self
4772        }
4773
4774        /// Sets the value of [protobuf_pythonic_types_enabled][crate::model::python_settings::ExperimentalFeatures::protobuf_pythonic_types_enabled].
4775        pub fn set_protobuf_pythonic_types_enabled<T: std::convert::Into<bool>>(
4776            mut self,
4777            v: T,
4778        ) -> Self {
4779            self.protobuf_pythonic_types_enabled = v.into();
4780            self
4781        }
4782
4783        /// Sets the value of [unversioned_package_disabled][crate::model::python_settings::ExperimentalFeatures::unversioned_package_disabled].
4784        pub fn set_unversioned_package_disabled<T: std::convert::Into<bool>>(
4785            mut self,
4786            v: T,
4787        ) -> Self {
4788            self.unversioned_package_disabled = v.into();
4789            self
4790        }
4791    }
4792
4793    impl wkt::message::Message for ExperimentalFeatures {
4794        fn typename() -> &'static str {
4795            "type.googleapis.com/google.api.PythonSettings.ExperimentalFeatures"
4796        }
4797    }
4798
4799    #[doc(hidden)]
4800    impl<'de> serde::de::Deserialize<'de> for ExperimentalFeatures {
4801        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4802        where
4803            D: serde::Deserializer<'de>,
4804        {
4805            #[allow(non_camel_case_types)]
4806            #[doc(hidden)]
4807            #[derive(PartialEq, Eq, Hash)]
4808            enum __FieldTag {
4809                __rest_async_io_enabled,
4810                __protobuf_pythonic_types_enabled,
4811                __unversioned_package_disabled,
4812                Unknown(std::string::String),
4813            }
4814            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4815                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4816                where
4817                    D: serde::Deserializer<'de>,
4818                {
4819                    struct Visitor;
4820                    impl<'de> serde::de::Visitor<'de> for Visitor {
4821                        type Value = __FieldTag;
4822                        fn expecting(
4823                            &self,
4824                            formatter: &mut std::fmt::Formatter,
4825                        ) -> std::fmt::Result {
4826                            formatter.write_str("a field name for ExperimentalFeatures")
4827                        }
4828                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4829                        where
4830                            E: serde::de::Error,
4831                        {
4832                            use std::result::Result::Ok;
4833                            use std::string::ToString;
4834                            match value {
4835                                "restAsyncIoEnabled" => Ok(__FieldTag::__rest_async_io_enabled),
4836                                "rest_async_io_enabled" => Ok(__FieldTag::__rest_async_io_enabled),
4837                                "protobufPythonicTypesEnabled" => {
4838                                    Ok(__FieldTag::__protobuf_pythonic_types_enabled)
4839                                }
4840                                "protobuf_pythonic_types_enabled" => {
4841                                    Ok(__FieldTag::__protobuf_pythonic_types_enabled)
4842                                }
4843                                "unversionedPackageDisabled" => {
4844                                    Ok(__FieldTag::__unversioned_package_disabled)
4845                                }
4846                                "unversioned_package_disabled" => {
4847                                    Ok(__FieldTag::__unversioned_package_disabled)
4848                                }
4849                                _ => Ok(__FieldTag::Unknown(value.to_string())),
4850                            }
4851                        }
4852                    }
4853                    deserializer.deserialize_identifier(Visitor)
4854                }
4855            }
4856            struct Visitor;
4857            impl<'de> serde::de::Visitor<'de> for Visitor {
4858                type Value = ExperimentalFeatures;
4859                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4860                    formatter.write_str("struct ExperimentalFeatures")
4861                }
4862                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4863                where
4864                    A: serde::de::MapAccess<'de>,
4865                {
4866                    #[allow(unused_imports)]
4867                    use serde::de::Error;
4868                    use std::option::Option::Some;
4869                    let mut fields = std::collections::HashSet::new();
4870                    let mut result = Self::Value::new();
4871                    while let Some(tag) = map.next_key::<__FieldTag>()? {
4872                        #[allow(clippy::match_single_binding)]
4873                        match tag {
4874                            __FieldTag::__rest_async_io_enabled => {
4875                                if !fields.insert(__FieldTag::__rest_async_io_enabled) {
4876                                    return std::result::Result::Err(A::Error::duplicate_field(
4877                                        "multiple values for rest_async_io_enabled",
4878                                    ));
4879                                }
4880                                result.rest_async_io_enabled = map
4881                                    .next_value::<std::option::Option<bool>>()?
4882                                    .unwrap_or_default();
4883                            }
4884                            __FieldTag::__protobuf_pythonic_types_enabled => {
4885                                if !fields.insert(__FieldTag::__protobuf_pythonic_types_enabled) {
4886                                    return std::result::Result::Err(A::Error::duplicate_field(
4887                                        "multiple values for protobuf_pythonic_types_enabled",
4888                                    ));
4889                                }
4890                                result.protobuf_pythonic_types_enabled = map
4891                                    .next_value::<std::option::Option<bool>>()?
4892                                    .unwrap_or_default();
4893                            }
4894                            __FieldTag::__unversioned_package_disabled => {
4895                                if !fields.insert(__FieldTag::__unversioned_package_disabled) {
4896                                    return std::result::Result::Err(A::Error::duplicate_field(
4897                                        "multiple values for unversioned_package_disabled",
4898                                    ));
4899                                }
4900                                result.unversioned_package_disabled = map
4901                                    .next_value::<std::option::Option<bool>>()?
4902                                    .unwrap_or_default();
4903                            }
4904                            __FieldTag::Unknown(key) => {
4905                                let value = map.next_value::<serde_json::Value>()?;
4906                                result._unknown_fields.insert(key, value);
4907                            }
4908                        }
4909                    }
4910                    std::result::Result::Ok(result)
4911                }
4912            }
4913            deserializer.deserialize_any(Visitor)
4914        }
4915    }
4916
4917    #[doc(hidden)]
4918    impl serde::ser::Serialize for ExperimentalFeatures {
4919        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4920        where
4921            S: serde::ser::Serializer,
4922        {
4923            use serde::ser::SerializeMap;
4924            #[allow(unused_imports)]
4925            use std::option::Option::Some;
4926            let mut state = serializer.serialize_map(std::option::Option::None)?;
4927            if !wkt::internal::is_default(&self.rest_async_io_enabled) {
4928                state.serialize_entry("restAsyncIoEnabled", &self.rest_async_io_enabled)?;
4929            }
4930            if !wkt::internal::is_default(&self.protobuf_pythonic_types_enabled) {
4931                state.serialize_entry(
4932                    "protobufPythonicTypesEnabled",
4933                    &self.protobuf_pythonic_types_enabled,
4934                )?;
4935            }
4936            if !wkt::internal::is_default(&self.unversioned_package_disabled) {
4937                state.serialize_entry(
4938                    "unversionedPackageDisabled",
4939                    &self.unversioned_package_disabled,
4940                )?;
4941            }
4942            if !self._unknown_fields.is_empty() {
4943                for (key, value) in self._unknown_fields.iter() {
4944                    state.serialize_entry(key, &value)?;
4945                }
4946            }
4947            state.end()
4948        }
4949    }
4950
4951    impl std::fmt::Debug for ExperimentalFeatures {
4952        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4953            let mut debug_struct = f.debug_struct("ExperimentalFeatures");
4954            debug_struct.field("rest_async_io_enabled", &self.rest_async_io_enabled);
4955            debug_struct.field(
4956                "protobuf_pythonic_types_enabled",
4957                &self.protobuf_pythonic_types_enabled,
4958            );
4959            debug_struct.field(
4960                "unversioned_package_disabled",
4961                &self.unversioned_package_disabled,
4962            );
4963            if !self._unknown_fields.is_empty() {
4964                debug_struct.field("_unknown_fields", &self._unknown_fields);
4965            }
4966            debug_struct.finish()
4967        }
4968    }
4969}
4970
4971/// Settings for Node client libraries.
4972#[derive(Clone, Default, PartialEq)]
4973#[non_exhaustive]
4974pub struct NodeSettings {
4975    /// Some settings.
4976    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4977
4978    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4979}
4980
4981impl NodeSettings {
4982    pub fn new() -> Self {
4983        std::default::Default::default()
4984    }
4985
4986    /// Sets the value of [common][crate::model::NodeSettings::common].
4987    pub fn set_common<T>(mut self, v: T) -> Self
4988    where
4989        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4990    {
4991        self.common = std::option::Option::Some(v.into());
4992        self
4993    }
4994
4995    /// Sets or clears the value of [common][crate::model::NodeSettings::common].
4996    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4997    where
4998        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4999    {
5000        self.common = v.map(|x| x.into());
5001        self
5002    }
5003}
5004
5005impl wkt::message::Message for NodeSettings {
5006    fn typename() -> &'static str {
5007        "type.googleapis.com/google.api.NodeSettings"
5008    }
5009}
5010
5011#[doc(hidden)]
5012impl<'de> serde::de::Deserialize<'de> for NodeSettings {
5013    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5014    where
5015        D: serde::Deserializer<'de>,
5016    {
5017        #[allow(non_camel_case_types)]
5018        #[doc(hidden)]
5019        #[derive(PartialEq, Eq, Hash)]
5020        enum __FieldTag {
5021            __common,
5022            Unknown(std::string::String),
5023        }
5024        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5025            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5026            where
5027                D: serde::Deserializer<'de>,
5028            {
5029                struct Visitor;
5030                impl<'de> serde::de::Visitor<'de> for Visitor {
5031                    type Value = __FieldTag;
5032                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5033                        formatter.write_str("a field name for NodeSettings")
5034                    }
5035                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5036                    where
5037                        E: serde::de::Error,
5038                    {
5039                        use std::result::Result::Ok;
5040                        use std::string::ToString;
5041                        match value {
5042                            "common" => Ok(__FieldTag::__common),
5043                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5044                        }
5045                    }
5046                }
5047                deserializer.deserialize_identifier(Visitor)
5048            }
5049        }
5050        struct Visitor;
5051        impl<'de> serde::de::Visitor<'de> for Visitor {
5052            type Value = NodeSettings;
5053            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5054                formatter.write_str("struct NodeSettings")
5055            }
5056            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5057            where
5058                A: serde::de::MapAccess<'de>,
5059            {
5060                #[allow(unused_imports)]
5061                use serde::de::Error;
5062                use std::option::Option::Some;
5063                let mut fields = std::collections::HashSet::new();
5064                let mut result = Self::Value::new();
5065                while let Some(tag) = map.next_key::<__FieldTag>()? {
5066                    #[allow(clippy::match_single_binding)]
5067                    match tag {
5068                        __FieldTag::__common => {
5069                            if !fields.insert(__FieldTag::__common) {
5070                                return std::result::Result::Err(A::Error::duplicate_field(
5071                                    "multiple values for common",
5072                                ));
5073                            }
5074                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5075                                ;
5076                        }
5077                        __FieldTag::Unknown(key) => {
5078                            let value = map.next_value::<serde_json::Value>()?;
5079                            result._unknown_fields.insert(key, value);
5080                        }
5081                    }
5082                }
5083                std::result::Result::Ok(result)
5084            }
5085        }
5086        deserializer.deserialize_any(Visitor)
5087    }
5088}
5089
5090#[doc(hidden)]
5091impl serde::ser::Serialize for NodeSettings {
5092    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5093    where
5094        S: serde::ser::Serializer,
5095    {
5096        use serde::ser::SerializeMap;
5097        #[allow(unused_imports)]
5098        use std::option::Option::Some;
5099        let mut state = serializer.serialize_map(std::option::Option::None)?;
5100        if self.common.is_some() {
5101            state.serialize_entry("common", &self.common)?;
5102        }
5103        if !self._unknown_fields.is_empty() {
5104            for (key, value) in self._unknown_fields.iter() {
5105                state.serialize_entry(key, &value)?;
5106            }
5107        }
5108        state.end()
5109    }
5110}
5111
5112impl std::fmt::Debug for NodeSettings {
5113    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5114        let mut debug_struct = f.debug_struct("NodeSettings");
5115        debug_struct.field("common", &self.common);
5116        if !self._unknown_fields.is_empty() {
5117            debug_struct.field("_unknown_fields", &self._unknown_fields);
5118        }
5119        debug_struct.finish()
5120    }
5121}
5122
5123/// Settings for Dotnet client libraries.
5124#[derive(Clone, Default, PartialEq)]
5125#[non_exhaustive]
5126pub struct DotnetSettings {
5127    /// Some settings.
5128    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
5129
5130    /// Map from original service names to renamed versions.
5131    /// This is used when the default generated types
5132    /// would cause a naming conflict. (Neither name is
5133    /// fully-qualified.)
5134    /// Example: Subscriber to SubscriberServiceApi.
5135    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,
5136
5137    /// Map from full resource types to the effective short name
5138    /// for the resource. This is used when otherwise resource
5139    /// named from different services would cause naming collisions.
5140    /// Example entry:
5141    /// "datalabeling.googleapis.com/Dataset": "DataLabelingDataset"
5142    pub renamed_resources: std::collections::HashMap<std::string::String, std::string::String>,
5143
5144    /// List of full resource types to ignore during generation.
5145    /// This is typically used for API-specific Location resources,
5146    /// which should be handled by the generator as if they were actually
5147    /// the common Location resources.
5148    /// Example entry: "documentai.googleapis.com/Location"
5149    pub ignored_resources: std::vec::Vec<std::string::String>,
5150
5151    /// Namespaces which must be aliased in snippets due to
5152    /// a known (but non-generator-predictable) naming collision
5153    pub forced_namespace_aliases: std::vec::Vec<std::string::String>,
5154
5155    /// Method signatures (in the form "service.method(signature)")
5156    /// which are provided separately, so shouldn't be generated.
5157    /// Snippets *calling* these methods are still generated, however.
5158    pub handwritten_signatures: std::vec::Vec<std::string::String>,
5159
5160    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5161}
5162
5163impl DotnetSettings {
5164    pub fn new() -> Self {
5165        std::default::Default::default()
5166    }
5167
5168    /// Sets the value of [common][crate::model::DotnetSettings::common].
5169    pub fn set_common<T>(mut self, v: T) -> Self
5170    where
5171        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5172    {
5173        self.common = std::option::Option::Some(v.into());
5174        self
5175    }
5176
5177    /// Sets or clears the value of [common][crate::model::DotnetSettings::common].
5178    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
5179    where
5180        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5181    {
5182        self.common = v.map(|x| x.into());
5183        self
5184    }
5185
5186    /// Sets the value of [renamed_services][crate::model::DotnetSettings::renamed_services].
5187    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
5188    where
5189        T: std::iter::IntoIterator<Item = (K, V)>,
5190        K: std::convert::Into<std::string::String>,
5191        V: std::convert::Into<std::string::String>,
5192    {
5193        use std::iter::Iterator;
5194        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5195        self
5196    }
5197
5198    /// Sets the value of [renamed_resources][crate::model::DotnetSettings::renamed_resources].
5199    pub fn set_renamed_resources<T, K, V>(mut self, v: T) -> Self
5200    where
5201        T: std::iter::IntoIterator<Item = (K, V)>,
5202        K: std::convert::Into<std::string::String>,
5203        V: std::convert::Into<std::string::String>,
5204    {
5205        use std::iter::Iterator;
5206        self.renamed_resources = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5207        self
5208    }
5209
5210    /// Sets the value of [ignored_resources][crate::model::DotnetSettings::ignored_resources].
5211    pub fn set_ignored_resources<T, V>(mut self, v: T) -> Self
5212    where
5213        T: std::iter::IntoIterator<Item = V>,
5214        V: std::convert::Into<std::string::String>,
5215    {
5216        use std::iter::Iterator;
5217        self.ignored_resources = v.into_iter().map(|i| i.into()).collect();
5218        self
5219    }
5220
5221    /// Sets the value of [forced_namespace_aliases][crate::model::DotnetSettings::forced_namespace_aliases].
5222    pub fn set_forced_namespace_aliases<T, V>(mut self, v: T) -> Self
5223    where
5224        T: std::iter::IntoIterator<Item = V>,
5225        V: std::convert::Into<std::string::String>,
5226    {
5227        use std::iter::Iterator;
5228        self.forced_namespace_aliases = v.into_iter().map(|i| i.into()).collect();
5229        self
5230    }
5231
5232    /// Sets the value of [handwritten_signatures][crate::model::DotnetSettings::handwritten_signatures].
5233    pub fn set_handwritten_signatures<T, V>(mut self, v: T) -> Self
5234    where
5235        T: std::iter::IntoIterator<Item = V>,
5236        V: std::convert::Into<std::string::String>,
5237    {
5238        use std::iter::Iterator;
5239        self.handwritten_signatures = v.into_iter().map(|i| i.into()).collect();
5240        self
5241    }
5242}
5243
5244impl wkt::message::Message for DotnetSettings {
5245    fn typename() -> &'static str {
5246        "type.googleapis.com/google.api.DotnetSettings"
5247    }
5248}
5249
5250#[doc(hidden)]
5251impl<'de> serde::de::Deserialize<'de> for DotnetSettings {
5252    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5253    where
5254        D: serde::Deserializer<'de>,
5255    {
5256        #[allow(non_camel_case_types)]
5257        #[doc(hidden)]
5258        #[derive(PartialEq, Eq, Hash)]
5259        enum __FieldTag {
5260            __common,
5261            __renamed_services,
5262            __renamed_resources,
5263            __ignored_resources,
5264            __forced_namespace_aliases,
5265            __handwritten_signatures,
5266            Unknown(std::string::String),
5267        }
5268        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5269            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5270            where
5271                D: serde::Deserializer<'de>,
5272            {
5273                struct Visitor;
5274                impl<'de> serde::de::Visitor<'de> for Visitor {
5275                    type Value = __FieldTag;
5276                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5277                        formatter.write_str("a field name for DotnetSettings")
5278                    }
5279                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5280                    where
5281                        E: serde::de::Error,
5282                    {
5283                        use std::result::Result::Ok;
5284                        use std::string::ToString;
5285                        match value {
5286                            "common" => Ok(__FieldTag::__common),
5287                            "renamedServices" => Ok(__FieldTag::__renamed_services),
5288                            "renamed_services" => Ok(__FieldTag::__renamed_services),
5289                            "renamedResources" => Ok(__FieldTag::__renamed_resources),
5290                            "renamed_resources" => Ok(__FieldTag::__renamed_resources),
5291                            "ignoredResources" => Ok(__FieldTag::__ignored_resources),
5292                            "ignored_resources" => Ok(__FieldTag::__ignored_resources),
5293                            "forcedNamespaceAliases" => Ok(__FieldTag::__forced_namespace_aliases),
5294                            "forced_namespace_aliases" => {
5295                                Ok(__FieldTag::__forced_namespace_aliases)
5296                            }
5297                            "handwrittenSignatures" => Ok(__FieldTag::__handwritten_signatures),
5298                            "handwritten_signatures" => Ok(__FieldTag::__handwritten_signatures),
5299                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5300                        }
5301                    }
5302                }
5303                deserializer.deserialize_identifier(Visitor)
5304            }
5305        }
5306        struct Visitor;
5307        impl<'de> serde::de::Visitor<'de> for Visitor {
5308            type Value = DotnetSettings;
5309            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5310                formatter.write_str("struct DotnetSettings")
5311            }
5312            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5313            where
5314                A: serde::de::MapAccess<'de>,
5315            {
5316                #[allow(unused_imports)]
5317                use serde::de::Error;
5318                use std::option::Option::Some;
5319                let mut fields = std::collections::HashSet::new();
5320                let mut result = Self::Value::new();
5321                while let Some(tag) = map.next_key::<__FieldTag>()? {
5322                    #[allow(clippy::match_single_binding)]
5323                    match tag {
5324                        __FieldTag::__common => {
5325                            if !fields.insert(__FieldTag::__common) {
5326                                return std::result::Result::Err(A::Error::duplicate_field(
5327                                    "multiple values for common",
5328                                ));
5329                            }
5330                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5331                                ;
5332                        }
5333                        __FieldTag::__renamed_services => {
5334                            if !fields.insert(__FieldTag::__renamed_services) {
5335                                return std::result::Result::Err(A::Error::duplicate_field(
5336                                    "multiple values for renamed_services",
5337                                ));
5338                            }
5339                            result.renamed_services = map
5340                                .next_value::<std::option::Option<
5341                                    std::collections::HashMap<
5342                                        std::string::String,
5343                                        std::string::String,
5344                                    >,
5345                                >>()?
5346                                .unwrap_or_default();
5347                        }
5348                        __FieldTag::__renamed_resources => {
5349                            if !fields.insert(__FieldTag::__renamed_resources) {
5350                                return std::result::Result::Err(A::Error::duplicate_field(
5351                                    "multiple values for renamed_resources",
5352                                ));
5353                            }
5354                            result.renamed_resources = map
5355                                .next_value::<std::option::Option<
5356                                    std::collections::HashMap<
5357                                        std::string::String,
5358                                        std::string::String,
5359                                    >,
5360                                >>()?
5361                                .unwrap_or_default();
5362                        }
5363                        __FieldTag::__ignored_resources => {
5364                            if !fields.insert(__FieldTag::__ignored_resources) {
5365                                return std::result::Result::Err(A::Error::duplicate_field(
5366                                    "multiple values for ignored_resources",
5367                                ));
5368                            }
5369                            result.ignored_resources = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5370                        }
5371                        __FieldTag::__forced_namespace_aliases => {
5372                            if !fields.insert(__FieldTag::__forced_namespace_aliases) {
5373                                return std::result::Result::Err(A::Error::duplicate_field(
5374                                    "multiple values for forced_namespace_aliases",
5375                                ));
5376                            }
5377                            result.forced_namespace_aliases = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5378                        }
5379                        __FieldTag::__handwritten_signatures => {
5380                            if !fields.insert(__FieldTag::__handwritten_signatures) {
5381                                return std::result::Result::Err(A::Error::duplicate_field(
5382                                    "multiple values for handwritten_signatures",
5383                                ));
5384                            }
5385                            result.handwritten_signatures = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5386                        }
5387                        __FieldTag::Unknown(key) => {
5388                            let value = map.next_value::<serde_json::Value>()?;
5389                            result._unknown_fields.insert(key, value);
5390                        }
5391                    }
5392                }
5393                std::result::Result::Ok(result)
5394            }
5395        }
5396        deserializer.deserialize_any(Visitor)
5397    }
5398}
5399
5400#[doc(hidden)]
5401impl serde::ser::Serialize for DotnetSettings {
5402    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5403    where
5404        S: serde::ser::Serializer,
5405    {
5406        use serde::ser::SerializeMap;
5407        #[allow(unused_imports)]
5408        use std::option::Option::Some;
5409        let mut state = serializer.serialize_map(std::option::Option::None)?;
5410        if self.common.is_some() {
5411            state.serialize_entry("common", &self.common)?;
5412        }
5413        if !self.renamed_services.is_empty() {
5414            state.serialize_entry("renamedServices", &self.renamed_services)?;
5415        }
5416        if !self.renamed_resources.is_empty() {
5417            state.serialize_entry("renamedResources", &self.renamed_resources)?;
5418        }
5419        if !self.ignored_resources.is_empty() {
5420            state.serialize_entry("ignoredResources", &self.ignored_resources)?;
5421        }
5422        if !self.forced_namespace_aliases.is_empty() {
5423            state.serialize_entry("forcedNamespaceAliases", &self.forced_namespace_aliases)?;
5424        }
5425        if !self.handwritten_signatures.is_empty() {
5426            state.serialize_entry("handwrittenSignatures", &self.handwritten_signatures)?;
5427        }
5428        if !self._unknown_fields.is_empty() {
5429            for (key, value) in self._unknown_fields.iter() {
5430                state.serialize_entry(key, &value)?;
5431            }
5432        }
5433        state.end()
5434    }
5435}
5436
5437impl std::fmt::Debug for DotnetSettings {
5438    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5439        let mut debug_struct = f.debug_struct("DotnetSettings");
5440        debug_struct.field("common", &self.common);
5441        debug_struct.field("renamed_services", &self.renamed_services);
5442        debug_struct.field("renamed_resources", &self.renamed_resources);
5443        debug_struct.field("ignored_resources", &self.ignored_resources);
5444        debug_struct.field("forced_namespace_aliases", &self.forced_namespace_aliases);
5445        debug_struct.field("handwritten_signatures", &self.handwritten_signatures);
5446        if !self._unknown_fields.is_empty() {
5447            debug_struct.field("_unknown_fields", &self._unknown_fields);
5448        }
5449        debug_struct.finish()
5450    }
5451}
5452
5453/// Settings for Ruby client libraries.
5454#[derive(Clone, Default, PartialEq)]
5455#[non_exhaustive]
5456pub struct RubySettings {
5457    /// Some settings.
5458    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
5459
5460    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5461}
5462
5463impl RubySettings {
5464    pub fn new() -> Self {
5465        std::default::Default::default()
5466    }
5467
5468    /// Sets the value of [common][crate::model::RubySettings::common].
5469    pub fn set_common<T>(mut self, v: T) -> Self
5470    where
5471        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5472    {
5473        self.common = std::option::Option::Some(v.into());
5474        self
5475    }
5476
5477    /// Sets or clears the value of [common][crate::model::RubySettings::common].
5478    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
5479    where
5480        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5481    {
5482        self.common = v.map(|x| x.into());
5483        self
5484    }
5485}
5486
5487impl wkt::message::Message for RubySettings {
5488    fn typename() -> &'static str {
5489        "type.googleapis.com/google.api.RubySettings"
5490    }
5491}
5492
5493#[doc(hidden)]
5494impl<'de> serde::de::Deserialize<'de> for RubySettings {
5495    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5496    where
5497        D: serde::Deserializer<'de>,
5498    {
5499        #[allow(non_camel_case_types)]
5500        #[doc(hidden)]
5501        #[derive(PartialEq, Eq, Hash)]
5502        enum __FieldTag {
5503            __common,
5504            Unknown(std::string::String),
5505        }
5506        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5507            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5508            where
5509                D: serde::Deserializer<'de>,
5510            {
5511                struct Visitor;
5512                impl<'de> serde::de::Visitor<'de> for Visitor {
5513                    type Value = __FieldTag;
5514                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5515                        formatter.write_str("a field name for RubySettings")
5516                    }
5517                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5518                    where
5519                        E: serde::de::Error,
5520                    {
5521                        use std::result::Result::Ok;
5522                        use std::string::ToString;
5523                        match value {
5524                            "common" => Ok(__FieldTag::__common),
5525                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5526                        }
5527                    }
5528                }
5529                deserializer.deserialize_identifier(Visitor)
5530            }
5531        }
5532        struct Visitor;
5533        impl<'de> serde::de::Visitor<'de> for Visitor {
5534            type Value = RubySettings;
5535            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5536                formatter.write_str("struct RubySettings")
5537            }
5538            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5539            where
5540                A: serde::de::MapAccess<'de>,
5541            {
5542                #[allow(unused_imports)]
5543                use serde::de::Error;
5544                use std::option::Option::Some;
5545                let mut fields = std::collections::HashSet::new();
5546                let mut result = Self::Value::new();
5547                while let Some(tag) = map.next_key::<__FieldTag>()? {
5548                    #[allow(clippy::match_single_binding)]
5549                    match tag {
5550                        __FieldTag::__common => {
5551                            if !fields.insert(__FieldTag::__common) {
5552                                return std::result::Result::Err(A::Error::duplicate_field(
5553                                    "multiple values for common",
5554                                ));
5555                            }
5556                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5557                                ;
5558                        }
5559                        __FieldTag::Unknown(key) => {
5560                            let value = map.next_value::<serde_json::Value>()?;
5561                            result._unknown_fields.insert(key, value);
5562                        }
5563                    }
5564                }
5565                std::result::Result::Ok(result)
5566            }
5567        }
5568        deserializer.deserialize_any(Visitor)
5569    }
5570}
5571
5572#[doc(hidden)]
5573impl serde::ser::Serialize for RubySettings {
5574    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5575    where
5576        S: serde::ser::Serializer,
5577    {
5578        use serde::ser::SerializeMap;
5579        #[allow(unused_imports)]
5580        use std::option::Option::Some;
5581        let mut state = serializer.serialize_map(std::option::Option::None)?;
5582        if self.common.is_some() {
5583            state.serialize_entry("common", &self.common)?;
5584        }
5585        if !self._unknown_fields.is_empty() {
5586            for (key, value) in self._unknown_fields.iter() {
5587                state.serialize_entry(key, &value)?;
5588            }
5589        }
5590        state.end()
5591    }
5592}
5593
5594impl std::fmt::Debug for RubySettings {
5595    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5596        let mut debug_struct = f.debug_struct("RubySettings");
5597        debug_struct.field("common", &self.common);
5598        if !self._unknown_fields.is_empty() {
5599            debug_struct.field("_unknown_fields", &self._unknown_fields);
5600        }
5601        debug_struct.finish()
5602    }
5603}
5604
5605/// Settings for Go client libraries.
5606#[derive(Clone, Default, PartialEq)]
5607#[non_exhaustive]
5608pub struct GoSettings {
5609    /// Some settings.
5610    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
5611
5612    /// Map of service names to renamed services. Keys are the package relative
5613    /// service names and values are the name to be used for the service client
5614    /// and call options.
5615    ///
5616    /// publishing:
5617    /// go_settings:
5618    /// renamed_services:
5619    /// Publisher: TopicAdmin
5620    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,
5621
5622    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5623}
5624
5625impl GoSettings {
5626    pub fn new() -> Self {
5627        std::default::Default::default()
5628    }
5629
5630    /// Sets the value of [common][crate::model::GoSettings::common].
5631    pub fn set_common<T>(mut self, v: T) -> Self
5632    where
5633        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5634    {
5635        self.common = std::option::Option::Some(v.into());
5636        self
5637    }
5638
5639    /// Sets or clears the value of [common][crate::model::GoSettings::common].
5640    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
5641    where
5642        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5643    {
5644        self.common = v.map(|x| x.into());
5645        self
5646    }
5647
5648    /// Sets the value of [renamed_services][crate::model::GoSettings::renamed_services].
5649    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
5650    where
5651        T: std::iter::IntoIterator<Item = (K, V)>,
5652        K: std::convert::Into<std::string::String>,
5653        V: std::convert::Into<std::string::String>,
5654    {
5655        use std::iter::Iterator;
5656        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5657        self
5658    }
5659}
5660
5661impl wkt::message::Message for GoSettings {
5662    fn typename() -> &'static str {
5663        "type.googleapis.com/google.api.GoSettings"
5664    }
5665}
5666
5667#[doc(hidden)]
5668impl<'de> serde::de::Deserialize<'de> for GoSettings {
5669    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5670    where
5671        D: serde::Deserializer<'de>,
5672    {
5673        #[allow(non_camel_case_types)]
5674        #[doc(hidden)]
5675        #[derive(PartialEq, Eq, Hash)]
5676        enum __FieldTag {
5677            __common,
5678            __renamed_services,
5679            Unknown(std::string::String),
5680        }
5681        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5682            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5683            where
5684                D: serde::Deserializer<'de>,
5685            {
5686                struct Visitor;
5687                impl<'de> serde::de::Visitor<'de> for Visitor {
5688                    type Value = __FieldTag;
5689                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5690                        formatter.write_str("a field name for GoSettings")
5691                    }
5692                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5693                    where
5694                        E: serde::de::Error,
5695                    {
5696                        use std::result::Result::Ok;
5697                        use std::string::ToString;
5698                        match value {
5699                            "common" => Ok(__FieldTag::__common),
5700                            "renamedServices" => Ok(__FieldTag::__renamed_services),
5701                            "renamed_services" => Ok(__FieldTag::__renamed_services),
5702                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5703                        }
5704                    }
5705                }
5706                deserializer.deserialize_identifier(Visitor)
5707            }
5708        }
5709        struct Visitor;
5710        impl<'de> serde::de::Visitor<'de> for Visitor {
5711            type Value = GoSettings;
5712            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5713                formatter.write_str("struct GoSettings")
5714            }
5715            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5716            where
5717                A: serde::de::MapAccess<'de>,
5718            {
5719                #[allow(unused_imports)]
5720                use serde::de::Error;
5721                use std::option::Option::Some;
5722                let mut fields = std::collections::HashSet::new();
5723                let mut result = Self::Value::new();
5724                while let Some(tag) = map.next_key::<__FieldTag>()? {
5725                    #[allow(clippy::match_single_binding)]
5726                    match tag {
5727                        __FieldTag::__common => {
5728                            if !fields.insert(__FieldTag::__common) {
5729                                return std::result::Result::Err(A::Error::duplicate_field(
5730                                    "multiple values for common",
5731                                ));
5732                            }
5733                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5734                                ;
5735                        }
5736                        __FieldTag::__renamed_services => {
5737                            if !fields.insert(__FieldTag::__renamed_services) {
5738                                return std::result::Result::Err(A::Error::duplicate_field(
5739                                    "multiple values for renamed_services",
5740                                ));
5741                            }
5742                            result.renamed_services = map
5743                                .next_value::<std::option::Option<
5744                                    std::collections::HashMap<
5745                                        std::string::String,
5746                                        std::string::String,
5747                                    >,
5748                                >>()?
5749                                .unwrap_or_default();
5750                        }
5751                        __FieldTag::Unknown(key) => {
5752                            let value = map.next_value::<serde_json::Value>()?;
5753                            result._unknown_fields.insert(key, value);
5754                        }
5755                    }
5756                }
5757                std::result::Result::Ok(result)
5758            }
5759        }
5760        deserializer.deserialize_any(Visitor)
5761    }
5762}
5763
5764#[doc(hidden)]
5765impl serde::ser::Serialize for GoSettings {
5766    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5767    where
5768        S: serde::ser::Serializer,
5769    {
5770        use serde::ser::SerializeMap;
5771        #[allow(unused_imports)]
5772        use std::option::Option::Some;
5773        let mut state = serializer.serialize_map(std::option::Option::None)?;
5774        if self.common.is_some() {
5775            state.serialize_entry("common", &self.common)?;
5776        }
5777        if !self.renamed_services.is_empty() {
5778            state.serialize_entry("renamedServices", &self.renamed_services)?;
5779        }
5780        if !self._unknown_fields.is_empty() {
5781            for (key, value) in self._unknown_fields.iter() {
5782                state.serialize_entry(key, &value)?;
5783            }
5784        }
5785        state.end()
5786    }
5787}
5788
5789impl std::fmt::Debug for GoSettings {
5790    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5791        let mut debug_struct = f.debug_struct("GoSettings");
5792        debug_struct.field("common", &self.common);
5793        debug_struct.field("renamed_services", &self.renamed_services);
5794        if !self._unknown_fields.is_empty() {
5795            debug_struct.field("_unknown_fields", &self._unknown_fields);
5796        }
5797        debug_struct.finish()
5798    }
5799}
5800
5801/// Describes the generator configuration for a method.
5802#[derive(Clone, Default, PartialEq)]
5803#[non_exhaustive]
5804pub struct MethodSettings {
5805    /// The fully qualified name of the method, for which the options below apply.
5806    /// This is used to find the method to apply the options.
5807    ///
5808    /// Example:
5809    ///
5810    /// ```norust
5811    /// publishing:
5812    ///   method_settings:
5813    ///   - selector: google.storage.control.v2.StorageControl.CreateFolder
5814    ///     # method settings for CreateFolder...
5815    /// ```
5816    pub selector: std::string::String,
5817
5818    /// Describes settings to use for long-running operations when generating
5819    /// API methods for RPCs. Complements RPCs that use the annotations in
5820    /// google/longrunning/operations.proto.
5821    ///
5822    /// Example of a YAML configuration::
5823    ///
5824    /// ```norust
5825    /// publishing:
5826    ///   method_settings:
5827    ///   - selector: google.cloud.speech.v2.Speech.BatchRecognize
5828    ///     long_running:
5829    ///       initial_poll_delay: 60s # 1 minute
5830    ///       poll_delay_multiplier: 1.5
5831    ///       max_poll_delay: 360s # 6 minutes
5832    ///       total_poll_timeout: 54000s # 90 minutes
5833    /// ```
5834    pub long_running: std::option::Option<crate::model::method_settings::LongRunning>,
5835
5836    /// List of top-level fields of the request message, that should be
5837    /// automatically populated by the client libraries based on their
5838    /// (google.api.field_info).format. Currently supported format: UUID4.
5839    ///
5840    /// Example of a YAML configuration:
5841    ///
5842    /// ```norust
5843    /// publishing:
5844    ///   method_settings:
5845    ///   - selector: google.example.v1.ExampleService.CreateExample
5846    ///     auto_populated_fields:
5847    ///     - request_id
5848    /// ```
5849    pub auto_populated_fields: std::vec::Vec<std::string::String>,
5850
5851    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5852}
5853
5854impl MethodSettings {
5855    pub fn new() -> Self {
5856        std::default::Default::default()
5857    }
5858
5859    /// Sets the value of [selector][crate::model::MethodSettings::selector].
5860    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5861        self.selector = v.into();
5862        self
5863    }
5864
5865    /// Sets the value of [long_running][crate::model::MethodSettings::long_running].
5866    pub fn set_long_running<T>(mut self, v: T) -> Self
5867    where
5868        T: std::convert::Into<crate::model::method_settings::LongRunning>,
5869    {
5870        self.long_running = std::option::Option::Some(v.into());
5871        self
5872    }
5873
5874    /// Sets or clears the value of [long_running][crate::model::MethodSettings::long_running].
5875    pub fn set_or_clear_long_running<T>(mut self, v: std::option::Option<T>) -> Self
5876    where
5877        T: std::convert::Into<crate::model::method_settings::LongRunning>,
5878    {
5879        self.long_running = v.map(|x| x.into());
5880        self
5881    }
5882
5883    /// Sets the value of [auto_populated_fields][crate::model::MethodSettings::auto_populated_fields].
5884    pub fn set_auto_populated_fields<T, V>(mut self, v: T) -> Self
5885    where
5886        T: std::iter::IntoIterator<Item = V>,
5887        V: std::convert::Into<std::string::String>,
5888    {
5889        use std::iter::Iterator;
5890        self.auto_populated_fields = v.into_iter().map(|i| i.into()).collect();
5891        self
5892    }
5893}
5894
5895impl wkt::message::Message for MethodSettings {
5896    fn typename() -> &'static str {
5897        "type.googleapis.com/google.api.MethodSettings"
5898    }
5899}
5900
5901#[doc(hidden)]
5902impl<'de> serde::de::Deserialize<'de> for MethodSettings {
5903    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5904    where
5905        D: serde::Deserializer<'de>,
5906    {
5907        #[allow(non_camel_case_types)]
5908        #[doc(hidden)]
5909        #[derive(PartialEq, Eq, Hash)]
5910        enum __FieldTag {
5911            __selector,
5912            __long_running,
5913            __auto_populated_fields,
5914            Unknown(std::string::String),
5915        }
5916        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5917            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5918            where
5919                D: serde::Deserializer<'de>,
5920            {
5921                struct Visitor;
5922                impl<'de> serde::de::Visitor<'de> for Visitor {
5923                    type Value = __FieldTag;
5924                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5925                        formatter.write_str("a field name for MethodSettings")
5926                    }
5927                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5928                    where
5929                        E: serde::de::Error,
5930                    {
5931                        use std::result::Result::Ok;
5932                        use std::string::ToString;
5933                        match value {
5934                            "selector" => Ok(__FieldTag::__selector),
5935                            "longRunning" => Ok(__FieldTag::__long_running),
5936                            "long_running" => Ok(__FieldTag::__long_running),
5937                            "autoPopulatedFields" => Ok(__FieldTag::__auto_populated_fields),
5938                            "auto_populated_fields" => Ok(__FieldTag::__auto_populated_fields),
5939                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5940                        }
5941                    }
5942                }
5943                deserializer.deserialize_identifier(Visitor)
5944            }
5945        }
5946        struct Visitor;
5947        impl<'de> serde::de::Visitor<'de> for Visitor {
5948            type Value = MethodSettings;
5949            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5950                formatter.write_str("struct MethodSettings")
5951            }
5952            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5953            where
5954                A: serde::de::MapAccess<'de>,
5955            {
5956                #[allow(unused_imports)]
5957                use serde::de::Error;
5958                use std::option::Option::Some;
5959                let mut fields = std::collections::HashSet::new();
5960                let mut result = Self::Value::new();
5961                while let Some(tag) = map.next_key::<__FieldTag>()? {
5962                    #[allow(clippy::match_single_binding)]
5963                    match tag {
5964                        __FieldTag::__selector => {
5965                            if !fields.insert(__FieldTag::__selector) {
5966                                return std::result::Result::Err(A::Error::duplicate_field(
5967                                    "multiple values for selector",
5968                                ));
5969                            }
5970                            result.selector = map
5971                                .next_value::<std::option::Option<std::string::String>>()?
5972                                .unwrap_or_default();
5973                        }
5974                        __FieldTag::__long_running => {
5975                            if !fields.insert(__FieldTag::__long_running) {
5976                                return std::result::Result::Err(A::Error::duplicate_field(
5977                                    "multiple values for long_running",
5978                                ));
5979                            }
5980                            result.long_running = map.next_value::<std::option::Option<crate::model::method_settings::LongRunning>>()?
5981                                ;
5982                        }
5983                        __FieldTag::__auto_populated_fields => {
5984                            if !fields.insert(__FieldTag::__auto_populated_fields) {
5985                                return std::result::Result::Err(A::Error::duplicate_field(
5986                                    "multiple values for auto_populated_fields",
5987                                ));
5988                            }
5989                            result.auto_populated_fields = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5990                        }
5991                        __FieldTag::Unknown(key) => {
5992                            let value = map.next_value::<serde_json::Value>()?;
5993                            result._unknown_fields.insert(key, value);
5994                        }
5995                    }
5996                }
5997                std::result::Result::Ok(result)
5998            }
5999        }
6000        deserializer.deserialize_any(Visitor)
6001    }
6002}
6003
6004#[doc(hidden)]
6005impl serde::ser::Serialize for MethodSettings {
6006    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6007    where
6008        S: serde::ser::Serializer,
6009    {
6010        use serde::ser::SerializeMap;
6011        #[allow(unused_imports)]
6012        use std::option::Option::Some;
6013        let mut state = serializer.serialize_map(std::option::Option::None)?;
6014        if !self.selector.is_empty() {
6015            state.serialize_entry("selector", &self.selector)?;
6016        }
6017        if self.long_running.is_some() {
6018            state.serialize_entry("longRunning", &self.long_running)?;
6019        }
6020        if !self.auto_populated_fields.is_empty() {
6021            state.serialize_entry("autoPopulatedFields", &self.auto_populated_fields)?;
6022        }
6023        if !self._unknown_fields.is_empty() {
6024            for (key, value) in self._unknown_fields.iter() {
6025                state.serialize_entry(key, &value)?;
6026            }
6027        }
6028        state.end()
6029    }
6030}
6031
6032impl std::fmt::Debug for MethodSettings {
6033    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6034        let mut debug_struct = f.debug_struct("MethodSettings");
6035        debug_struct.field("selector", &self.selector);
6036        debug_struct.field("long_running", &self.long_running);
6037        debug_struct.field("auto_populated_fields", &self.auto_populated_fields);
6038        if !self._unknown_fields.is_empty() {
6039            debug_struct.field("_unknown_fields", &self._unknown_fields);
6040        }
6041        debug_struct.finish()
6042    }
6043}
6044
6045/// Defines additional types related to [MethodSettings].
6046pub mod method_settings {
6047    #[allow(unused_imports)]
6048    use super::*;
6049
6050    /// Describes settings to use when generating API methods that use the
6051    /// long-running operation pattern.
6052    /// All default values below are from those used in the client library
6053    /// generators (e.g.
6054    /// [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)).
6055    #[derive(Clone, Default, PartialEq)]
6056    #[non_exhaustive]
6057    pub struct LongRunning {
6058        /// Initial delay after which the first poll request will be made.
6059        /// Default value: 5 seconds.
6060        pub initial_poll_delay: std::option::Option<wkt::Duration>,
6061
6062        /// Multiplier to gradually increase delay between subsequent polls until it
6063        /// reaches max_poll_delay.
6064        /// Default value: 1.5.
6065        pub poll_delay_multiplier: f32,
6066
6067        /// Maximum time between two subsequent poll requests.
6068        /// Default value: 45 seconds.
6069        pub max_poll_delay: std::option::Option<wkt::Duration>,
6070
6071        /// Total polling timeout.
6072        /// Default value: 5 minutes.
6073        pub total_poll_timeout: std::option::Option<wkt::Duration>,
6074
6075        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6076    }
6077
6078    impl LongRunning {
6079        pub fn new() -> Self {
6080            std::default::Default::default()
6081        }
6082
6083        /// Sets the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
6084        pub fn set_initial_poll_delay<T>(mut self, v: T) -> Self
6085        where
6086            T: std::convert::Into<wkt::Duration>,
6087        {
6088            self.initial_poll_delay = std::option::Option::Some(v.into());
6089            self
6090        }
6091
6092        /// Sets or clears the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
6093        pub fn set_or_clear_initial_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
6094        where
6095            T: std::convert::Into<wkt::Duration>,
6096        {
6097            self.initial_poll_delay = v.map(|x| x.into());
6098            self
6099        }
6100
6101        /// Sets the value of [poll_delay_multiplier][crate::model::method_settings::LongRunning::poll_delay_multiplier].
6102        pub fn set_poll_delay_multiplier<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
6103            self.poll_delay_multiplier = v.into();
6104            self
6105        }
6106
6107        /// Sets the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
6108        pub fn set_max_poll_delay<T>(mut self, v: T) -> Self
6109        where
6110            T: std::convert::Into<wkt::Duration>,
6111        {
6112            self.max_poll_delay = std::option::Option::Some(v.into());
6113            self
6114        }
6115
6116        /// Sets or clears the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
6117        pub fn set_or_clear_max_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
6118        where
6119            T: std::convert::Into<wkt::Duration>,
6120        {
6121            self.max_poll_delay = v.map(|x| x.into());
6122            self
6123        }
6124
6125        /// Sets the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
6126        pub fn set_total_poll_timeout<T>(mut self, v: T) -> Self
6127        where
6128            T: std::convert::Into<wkt::Duration>,
6129        {
6130            self.total_poll_timeout = std::option::Option::Some(v.into());
6131            self
6132        }
6133
6134        /// Sets or clears the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
6135        pub fn set_or_clear_total_poll_timeout<T>(mut self, v: std::option::Option<T>) -> Self
6136        where
6137            T: std::convert::Into<wkt::Duration>,
6138        {
6139            self.total_poll_timeout = v.map(|x| x.into());
6140            self
6141        }
6142    }
6143
6144    impl wkt::message::Message for LongRunning {
6145        fn typename() -> &'static str {
6146            "type.googleapis.com/google.api.MethodSettings.LongRunning"
6147        }
6148    }
6149
6150    #[doc(hidden)]
6151    impl<'de> serde::de::Deserialize<'de> for LongRunning {
6152        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6153        where
6154            D: serde::Deserializer<'de>,
6155        {
6156            #[allow(non_camel_case_types)]
6157            #[doc(hidden)]
6158            #[derive(PartialEq, Eq, Hash)]
6159            enum __FieldTag {
6160                __initial_poll_delay,
6161                __poll_delay_multiplier,
6162                __max_poll_delay,
6163                __total_poll_timeout,
6164                Unknown(std::string::String),
6165            }
6166            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6167                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6168                where
6169                    D: serde::Deserializer<'de>,
6170                {
6171                    struct Visitor;
6172                    impl<'de> serde::de::Visitor<'de> for Visitor {
6173                        type Value = __FieldTag;
6174                        fn expecting(
6175                            &self,
6176                            formatter: &mut std::fmt::Formatter,
6177                        ) -> std::fmt::Result {
6178                            formatter.write_str("a field name for LongRunning")
6179                        }
6180                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6181                        where
6182                            E: serde::de::Error,
6183                        {
6184                            use std::result::Result::Ok;
6185                            use std::string::ToString;
6186                            match value {
6187                                "initialPollDelay" => Ok(__FieldTag::__initial_poll_delay),
6188                                "initial_poll_delay" => Ok(__FieldTag::__initial_poll_delay),
6189                                "pollDelayMultiplier" => Ok(__FieldTag::__poll_delay_multiplier),
6190                                "poll_delay_multiplier" => Ok(__FieldTag::__poll_delay_multiplier),
6191                                "maxPollDelay" => Ok(__FieldTag::__max_poll_delay),
6192                                "max_poll_delay" => Ok(__FieldTag::__max_poll_delay),
6193                                "totalPollTimeout" => Ok(__FieldTag::__total_poll_timeout),
6194                                "total_poll_timeout" => Ok(__FieldTag::__total_poll_timeout),
6195                                _ => Ok(__FieldTag::Unknown(value.to_string())),
6196                            }
6197                        }
6198                    }
6199                    deserializer.deserialize_identifier(Visitor)
6200                }
6201            }
6202            struct Visitor;
6203            impl<'de> serde::de::Visitor<'de> for Visitor {
6204                type Value = LongRunning;
6205                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6206                    formatter.write_str("struct LongRunning")
6207                }
6208                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6209                where
6210                    A: serde::de::MapAccess<'de>,
6211                {
6212                    #[allow(unused_imports)]
6213                    use serde::de::Error;
6214                    use std::option::Option::Some;
6215                    let mut fields = std::collections::HashSet::new();
6216                    let mut result = Self::Value::new();
6217                    while let Some(tag) = map.next_key::<__FieldTag>()? {
6218                        #[allow(clippy::match_single_binding)]
6219                        match tag {
6220                            __FieldTag::__initial_poll_delay => {
6221                                if !fields.insert(__FieldTag::__initial_poll_delay) {
6222                                    return std::result::Result::Err(A::Error::duplicate_field(
6223                                        "multiple values for initial_poll_delay",
6224                                    ));
6225                                }
6226                                result.initial_poll_delay =
6227                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
6228                            }
6229                            __FieldTag::__poll_delay_multiplier => {
6230                                if !fields.insert(__FieldTag::__poll_delay_multiplier) {
6231                                    return std::result::Result::Err(A::Error::duplicate_field(
6232                                        "multiple values for poll_delay_multiplier",
6233                                    ));
6234                                }
6235                                struct __With(std::option::Option<f32>);
6236                                impl<'de> serde::de::Deserialize<'de> for __With {
6237                                    fn deserialize<D>(
6238                                        deserializer: D,
6239                                    ) -> std::result::Result<Self, D::Error>
6240                                    where
6241                                        D: serde::de::Deserializer<'de>,
6242                                    {
6243                                        serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
6244                                    }
6245                                }
6246                                result.poll_delay_multiplier =
6247                                    map.next_value::<__With>()?.0.unwrap_or_default();
6248                            }
6249                            __FieldTag::__max_poll_delay => {
6250                                if !fields.insert(__FieldTag::__max_poll_delay) {
6251                                    return std::result::Result::Err(A::Error::duplicate_field(
6252                                        "multiple values for max_poll_delay",
6253                                    ));
6254                                }
6255                                result.max_poll_delay =
6256                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
6257                            }
6258                            __FieldTag::__total_poll_timeout => {
6259                                if !fields.insert(__FieldTag::__total_poll_timeout) {
6260                                    return std::result::Result::Err(A::Error::duplicate_field(
6261                                        "multiple values for total_poll_timeout",
6262                                    ));
6263                                }
6264                                result.total_poll_timeout =
6265                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
6266                            }
6267                            __FieldTag::Unknown(key) => {
6268                                let value = map.next_value::<serde_json::Value>()?;
6269                                result._unknown_fields.insert(key, value);
6270                            }
6271                        }
6272                    }
6273                    std::result::Result::Ok(result)
6274                }
6275            }
6276            deserializer.deserialize_any(Visitor)
6277        }
6278    }
6279
6280    #[doc(hidden)]
6281    impl serde::ser::Serialize for LongRunning {
6282        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6283        where
6284            S: serde::ser::Serializer,
6285        {
6286            use serde::ser::SerializeMap;
6287            #[allow(unused_imports)]
6288            use std::option::Option::Some;
6289            let mut state = serializer.serialize_map(std::option::Option::None)?;
6290            if self.initial_poll_delay.is_some() {
6291                state.serialize_entry("initialPollDelay", &self.initial_poll_delay)?;
6292            }
6293            if !wkt::internal::is_default(&self.poll_delay_multiplier) {
6294                struct __With<'a>(&'a f32);
6295                impl<'a> serde::ser::Serialize for __With<'a> {
6296                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6297                    where
6298                        S: serde::ser::Serializer,
6299                    {
6300                        serde_with::As::<wkt::internal::F32>::serialize(self.0, serializer)
6301                    }
6302                }
6303                state
6304                    .serialize_entry("pollDelayMultiplier", &__With(&self.poll_delay_multiplier))?;
6305            }
6306            if self.max_poll_delay.is_some() {
6307                state.serialize_entry("maxPollDelay", &self.max_poll_delay)?;
6308            }
6309            if self.total_poll_timeout.is_some() {
6310                state.serialize_entry("totalPollTimeout", &self.total_poll_timeout)?;
6311            }
6312            if !self._unknown_fields.is_empty() {
6313                for (key, value) in self._unknown_fields.iter() {
6314                    state.serialize_entry(key, &value)?;
6315                }
6316            }
6317            state.end()
6318        }
6319    }
6320
6321    impl std::fmt::Debug for LongRunning {
6322        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6323            let mut debug_struct = f.debug_struct("LongRunning");
6324            debug_struct.field("initial_poll_delay", &self.initial_poll_delay);
6325            debug_struct.field("poll_delay_multiplier", &self.poll_delay_multiplier);
6326            debug_struct.field("max_poll_delay", &self.max_poll_delay);
6327            debug_struct.field("total_poll_timeout", &self.total_poll_timeout);
6328            if !self._unknown_fields.is_empty() {
6329                debug_struct.field("_unknown_fields", &self._unknown_fields);
6330            }
6331            debug_struct.finish()
6332        }
6333    }
6334}
6335
6336/// This message is used to configure the generation of a subset of the RPCs in
6337/// a service for client libraries.
6338#[derive(Clone, Default, PartialEq)]
6339#[non_exhaustive]
6340pub struct SelectiveGapicGeneration {
6341    /// An allowlist of the fully qualified names of RPCs that should be included
6342    /// on public client surfaces.
6343    pub methods: std::vec::Vec<std::string::String>,
6344
6345    /// Setting this to true indicates to the client generators that methods
6346    /// that would be excluded from the generation should instead be generated
6347    /// in a way that indicates these methods should not be consumed by
6348    /// end users. How this is expressed is up to individual language
6349    /// implementations to decide. Some examples may be: added annotations,
6350    /// obfuscated identifiers, or other language idiomatic patterns.
6351    pub generate_omitted_as_internal: bool,
6352
6353    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6354}
6355
6356impl SelectiveGapicGeneration {
6357    pub fn new() -> Self {
6358        std::default::Default::default()
6359    }
6360
6361    /// Sets the value of [methods][crate::model::SelectiveGapicGeneration::methods].
6362    pub fn set_methods<T, V>(mut self, v: T) -> Self
6363    where
6364        T: std::iter::IntoIterator<Item = V>,
6365        V: std::convert::Into<std::string::String>,
6366    {
6367        use std::iter::Iterator;
6368        self.methods = v.into_iter().map(|i| i.into()).collect();
6369        self
6370    }
6371
6372    /// Sets the value of [generate_omitted_as_internal][crate::model::SelectiveGapicGeneration::generate_omitted_as_internal].
6373    pub fn set_generate_omitted_as_internal<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6374        self.generate_omitted_as_internal = v.into();
6375        self
6376    }
6377}
6378
6379impl wkt::message::Message for SelectiveGapicGeneration {
6380    fn typename() -> &'static str {
6381        "type.googleapis.com/google.api.SelectiveGapicGeneration"
6382    }
6383}
6384
6385#[doc(hidden)]
6386impl<'de> serde::de::Deserialize<'de> for SelectiveGapicGeneration {
6387    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6388    where
6389        D: serde::Deserializer<'de>,
6390    {
6391        #[allow(non_camel_case_types)]
6392        #[doc(hidden)]
6393        #[derive(PartialEq, Eq, Hash)]
6394        enum __FieldTag {
6395            __methods,
6396            __generate_omitted_as_internal,
6397            Unknown(std::string::String),
6398        }
6399        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6400            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6401            where
6402                D: serde::Deserializer<'de>,
6403            {
6404                struct Visitor;
6405                impl<'de> serde::de::Visitor<'de> for Visitor {
6406                    type Value = __FieldTag;
6407                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6408                        formatter.write_str("a field name for SelectiveGapicGeneration")
6409                    }
6410                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6411                    where
6412                        E: serde::de::Error,
6413                    {
6414                        use std::result::Result::Ok;
6415                        use std::string::ToString;
6416                        match value {
6417                            "methods" => Ok(__FieldTag::__methods),
6418                            "generateOmittedAsInternal" => {
6419                                Ok(__FieldTag::__generate_omitted_as_internal)
6420                            }
6421                            "generate_omitted_as_internal" => {
6422                                Ok(__FieldTag::__generate_omitted_as_internal)
6423                            }
6424                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6425                        }
6426                    }
6427                }
6428                deserializer.deserialize_identifier(Visitor)
6429            }
6430        }
6431        struct Visitor;
6432        impl<'de> serde::de::Visitor<'de> for Visitor {
6433            type Value = SelectiveGapicGeneration;
6434            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6435                formatter.write_str("struct SelectiveGapicGeneration")
6436            }
6437            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6438            where
6439                A: serde::de::MapAccess<'de>,
6440            {
6441                #[allow(unused_imports)]
6442                use serde::de::Error;
6443                use std::option::Option::Some;
6444                let mut fields = std::collections::HashSet::new();
6445                let mut result = Self::Value::new();
6446                while let Some(tag) = map.next_key::<__FieldTag>()? {
6447                    #[allow(clippy::match_single_binding)]
6448                    match tag {
6449                        __FieldTag::__methods => {
6450                            if !fields.insert(__FieldTag::__methods) {
6451                                return std::result::Result::Err(A::Error::duplicate_field(
6452                                    "multiple values for methods",
6453                                ));
6454                            }
6455                            result.methods = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6456                        }
6457                        __FieldTag::__generate_omitted_as_internal => {
6458                            if !fields.insert(__FieldTag::__generate_omitted_as_internal) {
6459                                return std::result::Result::Err(A::Error::duplicate_field(
6460                                    "multiple values for generate_omitted_as_internal",
6461                                ));
6462                            }
6463                            result.generate_omitted_as_internal = map
6464                                .next_value::<std::option::Option<bool>>()?
6465                                .unwrap_or_default();
6466                        }
6467                        __FieldTag::Unknown(key) => {
6468                            let value = map.next_value::<serde_json::Value>()?;
6469                            result._unknown_fields.insert(key, value);
6470                        }
6471                    }
6472                }
6473                std::result::Result::Ok(result)
6474            }
6475        }
6476        deserializer.deserialize_any(Visitor)
6477    }
6478}
6479
6480#[doc(hidden)]
6481impl serde::ser::Serialize for SelectiveGapicGeneration {
6482    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6483    where
6484        S: serde::ser::Serializer,
6485    {
6486        use serde::ser::SerializeMap;
6487        #[allow(unused_imports)]
6488        use std::option::Option::Some;
6489        let mut state = serializer.serialize_map(std::option::Option::None)?;
6490        if !self.methods.is_empty() {
6491            state.serialize_entry("methods", &self.methods)?;
6492        }
6493        if !wkt::internal::is_default(&self.generate_omitted_as_internal) {
6494            state.serialize_entry(
6495                "generateOmittedAsInternal",
6496                &self.generate_omitted_as_internal,
6497            )?;
6498        }
6499        if !self._unknown_fields.is_empty() {
6500            for (key, value) in self._unknown_fields.iter() {
6501                state.serialize_entry(key, &value)?;
6502            }
6503        }
6504        state.end()
6505    }
6506}
6507
6508impl std::fmt::Debug for SelectiveGapicGeneration {
6509    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6510        let mut debug_struct = f.debug_struct("SelectiveGapicGeneration");
6511        debug_struct.field("methods", &self.methods);
6512        debug_struct.field(
6513            "generate_omitted_as_internal",
6514            &self.generate_omitted_as_internal,
6515        );
6516        if !self._unknown_fields.is_empty() {
6517            debug_struct.field("_unknown_fields", &self._unknown_fields);
6518        }
6519        debug_struct.finish()
6520    }
6521}
6522
6523/// Output generated from semantically comparing two versions of a service
6524/// configuration.
6525///
6526/// Includes detailed information about a field that have changed with
6527/// applicable advice about potential consequences for the change, such as
6528/// backwards-incompatibility.
6529#[derive(Clone, Default, PartialEq)]
6530#[non_exhaustive]
6531pub struct ConfigChange {
6532    /// Object hierarchy path to the change, with levels separated by a '.'
6533    /// character. For repeated fields, an applicable unique identifier field is
6534    /// used for the index (usually selector, name, or id). For maps, the term
6535    /// 'key' is used. If the field has no unique identifier, the numeric index
6536    /// is used.
6537    /// Examples:
6538    ///
6539    /// - visibility.rules[selector=="google.LibraryService.ListBooks"].restriction
6540    /// - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value
6541    /// - logging.producer_destinations[0]
6542    pub element: std::string::String,
6543
6544    /// Value of the changed object in the old Service configuration,
6545    /// in JSON format. This field will not be populated if ChangeType == ADDED.
6546    pub old_value: std::string::String,
6547
6548    /// Value of the changed object in the new Service configuration,
6549    /// in JSON format. This field will not be populated if ChangeType == REMOVED.
6550    pub new_value: std::string::String,
6551
6552    /// The type for this change, either ADDED, REMOVED, or MODIFIED.
6553    pub change_type: crate::model::ChangeType,
6554
6555    /// Collection of advice provided for this change, useful for determining the
6556    /// possible impact of this change.
6557    pub advices: std::vec::Vec<crate::model::Advice>,
6558
6559    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6560}
6561
6562impl ConfigChange {
6563    pub fn new() -> Self {
6564        std::default::Default::default()
6565    }
6566
6567    /// Sets the value of [element][crate::model::ConfigChange::element].
6568    pub fn set_element<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6569        self.element = v.into();
6570        self
6571    }
6572
6573    /// Sets the value of [old_value][crate::model::ConfigChange::old_value].
6574    pub fn set_old_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6575        self.old_value = v.into();
6576        self
6577    }
6578
6579    /// Sets the value of [new_value][crate::model::ConfigChange::new_value].
6580    pub fn set_new_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6581        self.new_value = v.into();
6582        self
6583    }
6584
6585    /// Sets the value of [change_type][crate::model::ConfigChange::change_type].
6586    pub fn set_change_type<T: std::convert::Into<crate::model::ChangeType>>(
6587        mut self,
6588        v: T,
6589    ) -> Self {
6590        self.change_type = v.into();
6591        self
6592    }
6593
6594    /// Sets the value of [advices][crate::model::ConfigChange::advices].
6595    pub fn set_advices<T, V>(mut self, v: T) -> Self
6596    where
6597        T: std::iter::IntoIterator<Item = V>,
6598        V: std::convert::Into<crate::model::Advice>,
6599    {
6600        use std::iter::Iterator;
6601        self.advices = v.into_iter().map(|i| i.into()).collect();
6602        self
6603    }
6604}
6605
6606impl wkt::message::Message for ConfigChange {
6607    fn typename() -> &'static str {
6608        "type.googleapis.com/google.api.ConfigChange"
6609    }
6610}
6611
6612#[doc(hidden)]
6613impl<'de> serde::de::Deserialize<'de> for ConfigChange {
6614    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6615    where
6616        D: serde::Deserializer<'de>,
6617    {
6618        #[allow(non_camel_case_types)]
6619        #[doc(hidden)]
6620        #[derive(PartialEq, Eq, Hash)]
6621        enum __FieldTag {
6622            __element,
6623            __old_value,
6624            __new_value,
6625            __change_type,
6626            __advices,
6627            Unknown(std::string::String),
6628        }
6629        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6630            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6631            where
6632                D: serde::Deserializer<'de>,
6633            {
6634                struct Visitor;
6635                impl<'de> serde::de::Visitor<'de> for Visitor {
6636                    type Value = __FieldTag;
6637                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6638                        formatter.write_str("a field name for ConfigChange")
6639                    }
6640                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6641                    where
6642                        E: serde::de::Error,
6643                    {
6644                        use std::result::Result::Ok;
6645                        use std::string::ToString;
6646                        match value {
6647                            "element" => Ok(__FieldTag::__element),
6648                            "oldValue" => Ok(__FieldTag::__old_value),
6649                            "old_value" => Ok(__FieldTag::__old_value),
6650                            "newValue" => Ok(__FieldTag::__new_value),
6651                            "new_value" => Ok(__FieldTag::__new_value),
6652                            "changeType" => Ok(__FieldTag::__change_type),
6653                            "change_type" => Ok(__FieldTag::__change_type),
6654                            "advices" => Ok(__FieldTag::__advices),
6655                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6656                        }
6657                    }
6658                }
6659                deserializer.deserialize_identifier(Visitor)
6660            }
6661        }
6662        struct Visitor;
6663        impl<'de> serde::de::Visitor<'de> for Visitor {
6664            type Value = ConfigChange;
6665            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6666                formatter.write_str("struct ConfigChange")
6667            }
6668            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6669            where
6670                A: serde::de::MapAccess<'de>,
6671            {
6672                #[allow(unused_imports)]
6673                use serde::de::Error;
6674                use std::option::Option::Some;
6675                let mut fields = std::collections::HashSet::new();
6676                let mut result = Self::Value::new();
6677                while let Some(tag) = map.next_key::<__FieldTag>()? {
6678                    #[allow(clippy::match_single_binding)]
6679                    match tag {
6680                        __FieldTag::__element => {
6681                            if !fields.insert(__FieldTag::__element) {
6682                                return std::result::Result::Err(A::Error::duplicate_field(
6683                                    "multiple values for element",
6684                                ));
6685                            }
6686                            result.element = map
6687                                .next_value::<std::option::Option<std::string::String>>()?
6688                                .unwrap_or_default();
6689                        }
6690                        __FieldTag::__old_value => {
6691                            if !fields.insert(__FieldTag::__old_value) {
6692                                return std::result::Result::Err(A::Error::duplicate_field(
6693                                    "multiple values for old_value",
6694                                ));
6695                            }
6696                            result.old_value = map
6697                                .next_value::<std::option::Option<std::string::String>>()?
6698                                .unwrap_or_default();
6699                        }
6700                        __FieldTag::__new_value => {
6701                            if !fields.insert(__FieldTag::__new_value) {
6702                                return std::result::Result::Err(A::Error::duplicate_field(
6703                                    "multiple values for new_value",
6704                                ));
6705                            }
6706                            result.new_value = map
6707                                .next_value::<std::option::Option<std::string::String>>()?
6708                                .unwrap_or_default();
6709                        }
6710                        __FieldTag::__change_type => {
6711                            if !fields.insert(__FieldTag::__change_type) {
6712                                return std::result::Result::Err(A::Error::duplicate_field(
6713                                    "multiple values for change_type",
6714                                ));
6715                            }
6716                            result.change_type = map
6717                                .next_value::<std::option::Option<crate::model::ChangeType>>()?
6718                                .unwrap_or_default();
6719                        }
6720                        __FieldTag::__advices => {
6721                            if !fields.insert(__FieldTag::__advices) {
6722                                return std::result::Result::Err(A::Error::duplicate_field(
6723                                    "multiple values for advices",
6724                                ));
6725                            }
6726                            result.advices = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Advice>>>()?.unwrap_or_default();
6727                        }
6728                        __FieldTag::Unknown(key) => {
6729                            let value = map.next_value::<serde_json::Value>()?;
6730                            result._unknown_fields.insert(key, value);
6731                        }
6732                    }
6733                }
6734                std::result::Result::Ok(result)
6735            }
6736        }
6737        deserializer.deserialize_any(Visitor)
6738    }
6739}
6740
6741#[doc(hidden)]
6742impl serde::ser::Serialize for ConfigChange {
6743    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6744    where
6745        S: serde::ser::Serializer,
6746    {
6747        use serde::ser::SerializeMap;
6748        #[allow(unused_imports)]
6749        use std::option::Option::Some;
6750        let mut state = serializer.serialize_map(std::option::Option::None)?;
6751        if !self.element.is_empty() {
6752            state.serialize_entry("element", &self.element)?;
6753        }
6754        if !self.old_value.is_empty() {
6755            state.serialize_entry("oldValue", &self.old_value)?;
6756        }
6757        if !self.new_value.is_empty() {
6758            state.serialize_entry("newValue", &self.new_value)?;
6759        }
6760        if !wkt::internal::is_default(&self.change_type) {
6761            state.serialize_entry("changeType", &self.change_type)?;
6762        }
6763        if !self.advices.is_empty() {
6764            state.serialize_entry("advices", &self.advices)?;
6765        }
6766        if !self._unknown_fields.is_empty() {
6767            for (key, value) in self._unknown_fields.iter() {
6768                state.serialize_entry(key, &value)?;
6769            }
6770        }
6771        state.end()
6772    }
6773}
6774
6775impl std::fmt::Debug for ConfigChange {
6776    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6777        let mut debug_struct = f.debug_struct("ConfigChange");
6778        debug_struct.field("element", &self.element);
6779        debug_struct.field("old_value", &self.old_value);
6780        debug_struct.field("new_value", &self.new_value);
6781        debug_struct.field("change_type", &self.change_type);
6782        debug_struct.field("advices", &self.advices);
6783        if !self._unknown_fields.is_empty() {
6784            debug_struct.field("_unknown_fields", &self._unknown_fields);
6785        }
6786        debug_struct.finish()
6787    }
6788}
6789
6790/// Generated advice about this change, used for providing more
6791/// information about how a change will affect the existing service.
6792#[derive(Clone, Default, PartialEq)]
6793#[non_exhaustive]
6794pub struct Advice {
6795    /// Useful description for why this advice was applied and what actions should
6796    /// be taken to mitigate any implied risks.
6797    pub description: std::string::String,
6798
6799    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6800}
6801
6802impl Advice {
6803    pub fn new() -> Self {
6804        std::default::Default::default()
6805    }
6806
6807    /// Sets the value of [description][crate::model::Advice::description].
6808    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6809        self.description = v.into();
6810        self
6811    }
6812}
6813
6814impl wkt::message::Message for Advice {
6815    fn typename() -> &'static str {
6816        "type.googleapis.com/google.api.Advice"
6817    }
6818}
6819
6820#[doc(hidden)]
6821impl<'de> serde::de::Deserialize<'de> for Advice {
6822    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6823    where
6824        D: serde::Deserializer<'de>,
6825    {
6826        #[allow(non_camel_case_types)]
6827        #[doc(hidden)]
6828        #[derive(PartialEq, Eq, Hash)]
6829        enum __FieldTag {
6830            __description,
6831            Unknown(std::string::String),
6832        }
6833        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6834            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6835            where
6836                D: serde::Deserializer<'de>,
6837            {
6838                struct Visitor;
6839                impl<'de> serde::de::Visitor<'de> for Visitor {
6840                    type Value = __FieldTag;
6841                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6842                        formatter.write_str("a field name for Advice")
6843                    }
6844                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6845                    where
6846                        E: serde::de::Error,
6847                    {
6848                        use std::result::Result::Ok;
6849                        use std::string::ToString;
6850                        match value {
6851                            "description" => Ok(__FieldTag::__description),
6852                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6853                        }
6854                    }
6855                }
6856                deserializer.deserialize_identifier(Visitor)
6857            }
6858        }
6859        struct Visitor;
6860        impl<'de> serde::de::Visitor<'de> for Visitor {
6861            type Value = Advice;
6862            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6863                formatter.write_str("struct Advice")
6864            }
6865            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6866            where
6867                A: serde::de::MapAccess<'de>,
6868            {
6869                #[allow(unused_imports)]
6870                use serde::de::Error;
6871                use std::option::Option::Some;
6872                let mut fields = std::collections::HashSet::new();
6873                let mut result = Self::Value::new();
6874                while let Some(tag) = map.next_key::<__FieldTag>()? {
6875                    #[allow(clippy::match_single_binding)]
6876                    match tag {
6877                        __FieldTag::__description => {
6878                            if !fields.insert(__FieldTag::__description) {
6879                                return std::result::Result::Err(A::Error::duplicate_field(
6880                                    "multiple values for description",
6881                                ));
6882                            }
6883                            result.description = map
6884                                .next_value::<std::option::Option<std::string::String>>()?
6885                                .unwrap_or_default();
6886                        }
6887                        __FieldTag::Unknown(key) => {
6888                            let value = map.next_value::<serde_json::Value>()?;
6889                            result._unknown_fields.insert(key, value);
6890                        }
6891                    }
6892                }
6893                std::result::Result::Ok(result)
6894            }
6895        }
6896        deserializer.deserialize_any(Visitor)
6897    }
6898}
6899
6900#[doc(hidden)]
6901impl serde::ser::Serialize for Advice {
6902    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6903    where
6904        S: serde::ser::Serializer,
6905    {
6906        use serde::ser::SerializeMap;
6907        #[allow(unused_imports)]
6908        use std::option::Option::Some;
6909        let mut state = serializer.serialize_map(std::option::Option::None)?;
6910        if !self.description.is_empty() {
6911            state.serialize_entry("description", &self.description)?;
6912        }
6913        if !self._unknown_fields.is_empty() {
6914            for (key, value) in self._unknown_fields.iter() {
6915                state.serialize_entry(key, &value)?;
6916            }
6917        }
6918        state.end()
6919    }
6920}
6921
6922impl std::fmt::Debug for Advice {
6923    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6924        let mut debug_struct = f.debug_struct("Advice");
6925        debug_struct.field("description", &self.description);
6926        if !self._unknown_fields.is_empty() {
6927            debug_struct.field("_unknown_fields", &self._unknown_fields);
6928        }
6929        debug_struct.finish()
6930    }
6931}
6932
6933/// A descriptor for defining project properties for a service. One service may
6934/// have many consumer projects, and the service may want to behave differently
6935/// depending on some properties on the project. For example, a project may be
6936/// associated with a school, or a business, or a government agency, a business
6937/// type property on the project may affect how a service responds to the client.
6938/// This descriptor defines which properties are allowed to be set on a project.
6939///
6940/// Example:
6941///
6942/// ```norust
6943/// project_properties:
6944///   properties:
6945///   - name: NO_WATERMARK
6946///     type: BOOL
6947///     description: Allows usage of the API without watermarks.
6948///   - name: EXTENDED_TILE_CACHE_PERIOD
6949///     type: INT64
6950/// ```
6951#[derive(Clone, Default, PartialEq)]
6952#[non_exhaustive]
6953pub struct ProjectProperties {
6954    /// List of per consumer project-specific properties.
6955    pub properties: std::vec::Vec<crate::model::Property>,
6956
6957    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6958}
6959
6960impl ProjectProperties {
6961    pub fn new() -> Self {
6962        std::default::Default::default()
6963    }
6964
6965    /// Sets the value of [properties][crate::model::ProjectProperties::properties].
6966    pub fn set_properties<T, V>(mut self, v: T) -> Self
6967    where
6968        T: std::iter::IntoIterator<Item = V>,
6969        V: std::convert::Into<crate::model::Property>,
6970    {
6971        use std::iter::Iterator;
6972        self.properties = v.into_iter().map(|i| i.into()).collect();
6973        self
6974    }
6975}
6976
6977impl wkt::message::Message for ProjectProperties {
6978    fn typename() -> &'static str {
6979        "type.googleapis.com/google.api.ProjectProperties"
6980    }
6981}
6982
6983#[doc(hidden)]
6984impl<'de> serde::de::Deserialize<'de> for ProjectProperties {
6985    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6986    where
6987        D: serde::Deserializer<'de>,
6988    {
6989        #[allow(non_camel_case_types)]
6990        #[doc(hidden)]
6991        #[derive(PartialEq, Eq, Hash)]
6992        enum __FieldTag {
6993            __properties,
6994            Unknown(std::string::String),
6995        }
6996        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6997            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6998            where
6999                D: serde::Deserializer<'de>,
7000            {
7001                struct Visitor;
7002                impl<'de> serde::de::Visitor<'de> for Visitor {
7003                    type Value = __FieldTag;
7004                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7005                        formatter.write_str("a field name for ProjectProperties")
7006                    }
7007                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7008                    where
7009                        E: serde::de::Error,
7010                    {
7011                        use std::result::Result::Ok;
7012                        use std::string::ToString;
7013                        match value {
7014                            "properties" => Ok(__FieldTag::__properties),
7015                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7016                        }
7017                    }
7018                }
7019                deserializer.deserialize_identifier(Visitor)
7020            }
7021        }
7022        struct Visitor;
7023        impl<'de> serde::de::Visitor<'de> for Visitor {
7024            type Value = ProjectProperties;
7025            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7026                formatter.write_str("struct ProjectProperties")
7027            }
7028            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7029            where
7030                A: serde::de::MapAccess<'de>,
7031            {
7032                #[allow(unused_imports)]
7033                use serde::de::Error;
7034                use std::option::Option::Some;
7035                let mut fields = std::collections::HashSet::new();
7036                let mut result = Self::Value::new();
7037                while let Some(tag) = map.next_key::<__FieldTag>()? {
7038                    #[allow(clippy::match_single_binding)]
7039                    match tag {
7040                        __FieldTag::__properties => {
7041                            if !fields.insert(__FieldTag::__properties) {
7042                                return std::result::Result::Err(A::Error::duplicate_field(
7043                                    "multiple values for properties",
7044                                ));
7045                            }
7046                            result.properties = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Property>>>()?.unwrap_or_default();
7047                        }
7048                        __FieldTag::Unknown(key) => {
7049                            let value = map.next_value::<serde_json::Value>()?;
7050                            result._unknown_fields.insert(key, value);
7051                        }
7052                    }
7053                }
7054                std::result::Result::Ok(result)
7055            }
7056        }
7057        deserializer.deserialize_any(Visitor)
7058    }
7059}
7060
7061#[doc(hidden)]
7062impl serde::ser::Serialize for ProjectProperties {
7063    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7064    where
7065        S: serde::ser::Serializer,
7066    {
7067        use serde::ser::SerializeMap;
7068        #[allow(unused_imports)]
7069        use std::option::Option::Some;
7070        let mut state = serializer.serialize_map(std::option::Option::None)?;
7071        if !self.properties.is_empty() {
7072            state.serialize_entry("properties", &self.properties)?;
7073        }
7074        if !self._unknown_fields.is_empty() {
7075            for (key, value) in self._unknown_fields.iter() {
7076                state.serialize_entry(key, &value)?;
7077            }
7078        }
7079        state.end()
7080    }
7081}
7082
7083impl std::fmt::Debug for ProjectProperties {
7084    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7085        let mut debug_struct = f.debug_struct("ProjectProperties");
7086        debug_struct.field("properties", &self.properties);
7087        if !self._unknown_fields.is_empty() {
7088            debug_struct.field("_unknown_fields", &self._unknown_fields);
7089        }
7090        debug_struct.finish()
7091    }
7092}
7093
7094/// Defines project properties.
7095///
7096/// API services can define properties that can be assigned to consumer projects
7097/// so that backends can perform response customization without having to make
7098/// additional calls or maintain additional storage. For example, Maps API
7099/// defines properties that controls map tile cache period, or whether to embed a
7100/// watermark in a result.
7101///
7102/// These values can be set via API producer console. Only API providers can
7103/// define and set these properties.
7104#[derive(Clone, Default, PartialEq)]
7105#[non_exhaustive]
7106pub struct Property {
7107    /// The name of the property (a.k.a key).
7108    pub name: std::string::String,
7109
7110    /// The type of this property.
7111    pub r#type: crate::model::property::PropertyType,
7112
7113    /// The description of the property
7114    pub description: std::string::String,
7115
7116    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7117}
7118
7119impl Property {
7120    pub fn new() -> Self {
7121        std::default::Default::default()
7122    }
7123
7124    /// Sets the value of [name][crate::model::Property::name].
7125    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7126        self.name = v.into();
7127        self
7128    }
7129
7130    /// Sets the value of [r#type][crate::model::Property::type].
7131    pub fn set_type<T: std::convert::Into<crate::model::property::PropertyType>>(
7132        mut self,
7133        v: T,
7134    ) -> Self {
7135        self.r#type = v.into();
7136        self
7137    }
7138
7139    /// Sets the value of [description][crate::model::Property::description].
7140    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7141        self.description = v.into();
7142        self
7143    }
7144}
7145
7146impl wkt::message::Message for Property {
7147    fn typename() -> &'static str {
7148        "type.googleapis.com/google.api.Property"
7149    }
7150}
7151
7152#[doc(hidden)]
7153impl<'de> serde::de::Deserialize<'de> for Property {
7154    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7155    where
7156        D: serde::Deserializer<'de>,
7157    {
7158        #[allow(non_camel_case_types)]
7159        #[doc(hidden)]
7160        #[derive(PartialEq, Eq, Hash)]
7161        enum __FieldTag {
7162            __name,
7163            __type,
7164            __description,
7165            Unknown(std::string::String),
7166        }
7167        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7168            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7169            where
7170                D: serde::Deserializer<'de>,
7171            {
7172                struct Visitor;
7173                impl<'de> serde::de::Visitor<'de> for Visitor {
7174                    type Value = __FieldTag;
7175                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7176                        formatter.write_str("a field name for Property")
7177                    }
7178                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7179                    where
7180                        E: serde::de::Error,
7181                    {
7182                        use std::result::Result::Ok;
7183                        use std::string::ToString;
7184                        match value {
7185                            "name" => Ok(__FieldTag::__name),
7186                            "type" => Ok(__FieldTag::__type),
7187                            "description" => Ok(__FieldTag::__description),
7188                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7189                        }
7190                    }
7191                }
7192                deserializer.deserialize_identifier(Visitor)
7193            }
7194        }
7195        struct Visitor;
7196        impl<'de> serde::de::Visitor<'de> for Visitor {
7197            type Value = Property;
7198            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7199                formatter.write_str("struct Property")
7200            }
7201            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7202            where
7203                A: serde::de::MapAccess<'de>,
7204            {
7205                #[allow(unused_imports)]
7206                use serde::de::Error;
7207                use std::option::Option::Some;
7208                let mut fields = std::collections::HashSet::new();
7209                let mut result = Self::Value::new();
7210                while let Some(tag) = map.next_key::<__FieldTag>()? {
7211                    #[allow(clippy::match_single_binding)]
7212                    match tag {
7213                        __FieldTag::__name => {
7214                            if !fields.insert(__FieldTag::__name) {
7215                                return std::result::Result::Err(A::Error::duplicate_field(
7216                                    "multiple values for name",
7217                                ));
7218                            }
7219                            result.name = map
7220                                .next_value::<std::option::Option<std::string::String>>()?
7221                                .unwrap_or_default();
7222                        }
7223                        __FieldTag::__type => {
7224                            if !fields.insert(__FieldTag::__type) {
7225                                return std::result::Result::Err(A::Error::duplicate_field(
7226                                    "multiple values for type",
7227                                ));
7228                            }
7229                            result.r#type = map.next_value::<std::option::Option<crate::model::property::PropertyType>>()?.unwrap_or_default();
7230                        }
7231                        __FieldTag::__description => {
7232                            if !fields.insert(__FieldTag::__description) {
7233                                return std::result::Result::Err(A::Error::duplicate_field(
7234                                    "multiple values for description",
7235                                ));
7236                            }
7237                            result.description = map
7238                                .next_value::<std::option::Option<std::string::String>>()?
7239                                .unwrap_or_default();
7240                        }
7241                        __FieldTag::Unknown(key) => {
7242                            let value = map.next_value::<serde_json::Value>()?;
7243                            result._unknown_fields.insert(key, value);
7244                        }
7245                    }
7246                }
7247                std::result::Result::Ok(result)
7248            }
7249        }
7250        deserializer.deserialize_any(Visitor)
7251    }
7252}
7253
7254#[doc(hidden)]
7255impl serde::ser::Serialize for Property {
7256    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7257    where
7258        S: serde::ser::Serializer,
7259    {
7260        use serde::ser::SerializeMap;
7261        #[allow(unused_imports)]
7262        use std::option::Option::Some;
7263        let mut state = serializer.serialize_map(std::option::Option::None)?;
7264        if !self.name.is_empty() {
7265            state.serialize_entry("name", &self.name)?;
7266        }
7267        if !wkt::internal::is_default(&self.r#type) {
7268            state.serialize_entry("type", &self.r#type)?;
7269        }
7270        if !self.description.is_empty() {
7271            state.serialize_entry("description", &self.description)?;
7272        }
7273        if !self._unknown_fields.is_empty() {
7274            for (key, value) in self._unknown_fields.iter() {
7275                state.serialize_entry(key, &value)?;
7276            }
7277        }
7278        state.end()
7279    }
7280}
7281
7282impl std::fmt::Debug for Property {
7283    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7284        let mut debug_struct = f.debug_struct("Property");
7285        debug_struct.field("name", &self.name);
7286        debug_struct.field("r#type", &self.r#type);
7287        debug_struct.field("description", &self.description);
7288        if !self._unknown_fields.is_empty() {
7289            debug_struct.field("_unknown_fields", &self._unknown_fields);
7290        }
7291        debug_struct.finish()
7292    }
7293}
7294
7295/// Defines additional types related to [Property].
7296pub mod property {
7297    #[allow(unused_imports)]
7298    use super::*;
7299
7300    /// Supported data type of the property values
7301    ///
7302    /// # Working with unknown values
7303    ///
7304    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7305    /// additional enum variants at any time. Adding new variants is not considered
7306    /// a breaking change. Applications should write their code in anticipation of:
7307    ///
7308    /// - New values appearing in future releases of the client library, **and**
7309    /// - New values received dynamically, without application changes.
7310    ///
7311    /// Please consult the [Working with enums] section in the user guide for some
7312    /// guidelines.
7313    ///
7314    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7315    #[derive(Clone, Debug, PartialEq)]
7316    #[non_exhaustive]
7317    pub enum PropertyType {
7318        /// The type is unspecified, and will result in an error.
7319        Unspecified,
7320        /// The type is `int64`.
7321        Int64,
7322        /// The type is `bool`.
7323        Bool,
7324        /// The type is `string`.
7325        String,
7326        /// The type is 'double'.
7327        Double,
7328        /// If set, the enum was initialized with an unknown value.
7329        ///
7330        /// Applications can examine the value using [PropertyType::value] or
7331        /// [PropertyType::name].
7332        UnknownValue(property_type::UnknownValue),
7333    }
7334
7335    #[doc(hidden)]
7336    pub mod property_type {
7337        #[allow(unused_imports)]
7338        use super::*;
7339        #[derive(Clone, Debug, PartialEq)]
7340        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7341    }
7342
7343    impl PropertyType {
7344        /// Gets the enum value.
7345        ///
7346        /// Returns `None` if the enum contains an unknown value deserialized from
7347        /// the string representation of enums.
7348        pub fn value(&self) -> std::option::Option<i32> {
7349            match self {
7350                Self::Unspecified => std::option::Option::Some(0),
7351                Self::Int64 => std::option::Option::Some(1),
7352                Self::Bool => std::option::Option::Some(2),
7353                Self::String => std::option::Option::Some(3),
7354                Self::Double => std::option::Option::Some(4),
7355                Self::UnknownValue(u) => u.0.value(),
7356            }
7357        }
7358
7359        /// Gets the enum value as a string.
7360        ///
7361        /// Returns `None` if the enum contains an unknown value deserialized from
7362        /// the integer representation of enums.
7363        pub fn name(&self) -> std::option::Option<&str> {
7364            match self {
7365                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
7366                Self::Int64 => std::option::Option::Some("INT64"),
7367                Self::Bool => std::option::Option::Some("BOOL"),
7368                Self::String => std::option::Option::Some("STRING"),
7369                Self::Double => std::option::Option::Some("DOUBLE"),
7370                Self::UnknownValue(u) => u.0.name(),
7371            }
7372        }
7373    }
7374
7375    impl std::default::Default for PropertyType {
7376        fn default() -> Self {
7377            use std::convert::From;
7378            Self::from(0)
7379        }
7380    }
7381
7382    impl std::fmt::Display for PropertyType {
7383        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7384            wkt::internal::display_enum(f, self.name(), self.value())
7385        }
7386    }
7387
7388    impl std::convert::From<i32> for PropertyType {
7389        fn from(value: i32) -> Self {
7390            match value {
7391                0 => Self::Unspecified,
7392                1 => Self::Int64,
7393                2 => Self::Bool,
7394                3 => Self::String,
7395                4 => Self::Double,
7396                _ => Self::UnknownValue(property_type::UnknownValue(
7397                    wkt::internal::UnknownEnumValue::Integer(value),
7398                )),
7399            }
7400        }
7401    }
7402
7403    impl std::convert::From<&str> for PropertyType {
7404        fn from(value: &str) -> Self {
7405            use std::string::ToString;
7406            match value {
7407                "UNSPECIFIED" => Self::Unspecified,
7408                "INT64" => Self::Int64,
7409                "BOOL" => Self::Bool,
7410                "STRING" => Self::String,
7411                "DOUBLE" => Self::Double,
7412                _ => Self::UnknownValue(property_type::UnknownValue(
7413                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7414                )),
7415            }
7416        }
7417    }
7418
7419    impl serde::ser::Serialize for PropertyType {
7420        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7421        where
7422            S: serde::Serializer,
7423        {
7424            match self {
7425                Self::Unspecified => serializer.serialize_i32(0),
7426                Self::Int64 => serializer.serialize_i32(1),
7427                Self::Bool => serializer.serialize_i32(2),
7428                Self::String => serializer.serialize_i32(3),
7429                Self::Double => serializer.serialize_i32(4),
7430                Self::UnknownValue(u) => u.0.serialize(serializer),
7431            }
7432        }
7433    }
7434
7435    impl<'de> serde::de::Deserialize<'de> for PropertyType {
7436        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7437        where
7438            D: serde::Deserializer<'de>,
7439        {
7440            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PropertyType>::new(
7441                ".google.api.Property.PropertyType",
7442            ))
7443        }
7444    }
7445}
7446
7447/// `Context` defines which contexts an API requests.
7448///
7449/// Example:
7450///
7451/// ```norust
7452/// context:
7453///   rules:
7454///   - selector: "*"
7455///     requested:
7456///     - google.rpc.context.ProjectContext
7457///     - google.rpc.context.OriginContext
7458/// ```
7459///
7460/// The above specifies that all methods in the API request
7461/// `google.rpc.context.ProjectContext` and
7462/// `google.rpc.context.OriginContext`.
7463///
7464/// Available context types are defined in package
7465/// `google.rpc.context`.
7466///
7467/// This also provides mechanism to allowlist any protobuf message extension that
7468/// can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
7469/// “x-goog-ext-<extension_id>-jspb” format. For example, list any service
7470/// specific protobuf types that can appear in grpc metadata as follows in your
7471/// yaml file:
7472///
7473/// Example:
7474///
7475/// ```norust
7476/// context:
7477///   rules:
7478///    - selector: "google.example.library.v1.LibraryService.CreateBook"
7479///      allowed_request_extensions:
7480///      - google.foo.v1.NewExtension
7481///      allowed_response_extensions:
7482///      - google.foo.v1.NewExtension
7483/// ```
7484///
7485/// You can also specify extension ID instead of fully qualified extension name
7486/// here.
7487#[derive(Clone, Default, PartialEq)]
7488#[non_exhaustive]
7489pub struct Context {
7490    /// A list of RPC context rules that apply to individual API methods.
7491    ///
7492    /// **NOTE:** All service configuration rules follow "last one wins" order.
7493    pub rules: std::vec::Vec<crate::model::ContextRule>,
7494
7495    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7496}
7497
7498impl Context {
7499    pub fn new() -> Self {
7500        std::default::Default::default()
7501    }
7502
7503    /// Sets the value of [rules][crate::model::Context::rules].
7504    pub fn set_rules<T, V>(mut self, v: T) -> Self
7505    where
7506        T: std::iter::IntoIterator<Item = V>,
7507        V: std::convert::Into<crate::model::ContextRule>,
7508    {
7509        use std::iter::Iterator;
7510        self.rules = v.into_iter().map(|i| i.into()).collect();
7511        self
7512    }
7513}
7514
7515impl wkt::message::Message for Context {
7516    fn typename() -> &'static str {
7517        "type.googleapis.com/google.api.Context"
7518    }
7519}
7520
7521#[doc(hidden)]
7522impl<'de> serde::de::Deserialize<'de> for Context {
7523    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7524    where
7525        D: serde::Deserializer<'de>,
7526    {
7527        #[allow(non_camel_case_types)]
7528        #[doc(hidden)]
7529        #[derive(PartialEq, Eq, Hash)]
7530        enum __FieldTag {
7531            __rules,
7532            Unknown(std::string::String),
7533        }
7534        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7535            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7536            where
7537                D: serde::Deserializer<'de>,
7538            {
7539                struct Visitor;
7540                impl<'de> serde::de::Visitor<'de> for Visitor {
7541                    type Value = __FieldTag;
7542                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7543                        formatter.write_str("a field name for Context")
7544                    }
7545                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7546                    where
7547                        E: serde::de::Error,
7548                    {
7549                        use std::result::Result::Ok;
7550                        use std::string::ToString;
7551                        match value {
7552                            "rules" => Ok(__FieldTag::__rules),
7553                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7554                        }
7555                    }
7556                }
7557                deserializer.deserialize_identifier(Visitor)
7558            }
7559        }
7560        struct Visitor;
7561        impl<'de> serde::de::Visitor<'de> for Visitor {
7562            type Value = Context;
7563            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7564                formatter.write_str("struct Context")
7565            }
7566            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7567            where
7568                A: serde::de::MapAccess<'de>,
7569            {
7570                #[allow(unused_imports)]
7571                use serde::de::Error;
7572                use std::option::Option::Some;
7573                let mut fields = std::collections::HashSet::new();
7574                let mut result = Self::Value::new();
7575                while let Some(tag) = map.next_key::<__FieldTag>()? {
7576                    #[allow(clippy::match_single_binding)]
7577                    match tag {
7578                        __FieldTag::__rules => {
7579                            if !fields.insert(__FieldTag::__rules) {
7580                                return std::result::Result::Err(A::Error::duplicate_field(
7581                                    "multiple values for rules",
7582                                ));
7583                            }
7584                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ContextRule>>>()?.unwrap_or_default();
7585                        }
7586                        __FieldTag::Unknown(key) => {
7587                            let value = map.next_value::<serde_json::Value>()?;
7588                            result._unknown_fields.insert(key, value);
7589                        }
7590                    }
7591                }
7592                std::result::Result::Ok(result)
7593            }
7594        }
7595        deserializer.deserialize_any(Visitor)
7596    }
7597}
7598
7599#[doc(hidden)]
7600impl serde::ser::Serialize for Context {
7601    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7602    where
7603        S: serde::ser::Serializer,
7604    {
7605        use serde::ser::SerializeMap;
7606        #[allow(unused_imports)]
7607        use std::option::Option::Some;
7608        let mut state = serializer.serialize_map(std::option::Option::None)?;
7609        if !self.rules.is_empty() {
7610            state.serialize_entry("rules", &self.rules)?;
7611        }
7612        if !self._unknown_fields.is_empty() {
7613            for (key, value) in self._unknown_fields.iter() {
7614                state.serialize_entry(key, &value)?;
7615            }
7616        }
7617        state.end()
7618    }
7619}
7620
7621impl std::fmt::Debug for Context {
7622    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7623        let mut debug_struct = f.debug_struct("Context");
7624        debug_struct.field("rules", &self.rules);
7625        if !self._unknown_fields.is_empty() {
7626            debug_struct.field("_unknown_fields", &self._unknown_fields);
7627        }
7628        debug_struct.finish()
7629    }
7630}
7631
7632/// A context rule provides information about the context for an individual API
7633/// element.
7634#[derive(Clone, Default, PartialEq)]
7635#[non_exhaustive]
7636pub struct ContextRule {
7637    /// Selects the methods to which this rule applies.
7638    ///
7639    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
7640    /// details.
7641    ///
7642    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
7643    pub selector: std::string::String,
7644
7645    /// A list of full type names of requested contexts, only the requested context
7646    /// will be made available to the backend.
7647    pub requested: std::vec::Vec<std::string::String>,
7648
7649    /// A list of full type names of provided contexts. It is used to support
7650    /// propagating HTTP headers and ETags from the response extension.
7651    pub provided: std::vec::Vec<std::string::String>,
7652
7653    /// A list of full type names or extension IDs of extensions allowed in grpc
7654    /// side channel from client to backend.
7655    pub allowed_request_extensions: std::vec::Vec<std::string::String>,
7656
7657    /// A list of full type names or extension IDs of extensions allowed in grpc
7658    /// side channel from backend to client.
7659    pub allowed_response_extensions: std::vec::Vec<std::string::String>,
7660
7661    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7662}
7663
7664impl ContextRule {
7665    pub fn new() -> Self {
7666        std::default::Default::default()
7667    }
7668
7669    /// Sets the value of [selector][crate::model::ContextRule::selector].
7670    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7671        self.selector = v.into();
7672        self
7673    }
7674
7675    /// Sets the value of [requested][crate::model::ContextRule::requested].
7676    pub fn set_requested<T, V>(mut self, v: T) -> Self
7677    where
7678        T: std::iter::IntoIterator<Item = V>,
7679        V: std::convert::Into<std::string::String>,
7680    {
7681        use std::iter::Iterator;
7682        self.requested = v.into_iter().map(|i| i.into()).collect();
7683        self
7684    }
7685
7686    /// Sets the value of [provided][crate::model::ContextRule::provided].
7687    pub fn set_provided<T, V>(mut self, v: T) -> Self
7688    where
7689        T: std::iter::IntoIterator<Item = V>,
7690        V: std::convert::Into<std::string::String>,
7691    {
7692        use std::iter::Iterator;
7693        self.provided = v.into_iter().map(|i| i.into()).collect();
7694        self
7695    }
7696
7697    /// Sets the value of [allowed_request_extensions][crate::model::ContextRule::allowed_request_extensions].
7698    pub fn set_allowed_request_extensions<T, V>(mut self, v: T) -> Self
7699    where
7700        T: std::iter::IntoIterator<Item = V>,
7701        V: std::convert::Into<std::string::String>,
7702    {
7703        use std::iter::Iterator;
7704        self.allowed_request_extensions = v.into_iter().map(|i| i.into()).collect();
7705        self
7706    }
7707
7708    /// Sets the value of [allowed_response_extensions][crate::model::ContextRule::allowed_response_extensions].
7709    pub fn set_allowed_response_extensions<T, V>(mut self, v: T) -> Self
7710    where
7711        T: std::iter::IntoIterator<Item = V>,
7712        V: std::convert::Into<std::string::String>,
7713    {
7714        use std::iter::Iterator;
7715        self.allowed_response_extensions = v.into_iter().map(|i| i.into()).collect();
7716        self
7717    }
7718}
7719
7720impl wkt::message::Message for ContextRule {
7721    fn typename() -> &'static str {
7722        "type.googleapis.com/google.api.ContextRule"
7723    }
7724}
7725
7726#[doc(hidden)]
7727impl<'de> serde::de::Deserialize<'de> for ContextRule {
7728    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7729    where
7730        D: serde::Deserializer<'de>,
7731    {
7732        #[allow(non_camel_case_types)]
7733        #[doc(hidden)]
7734        #[derive(PartialEq, Eq, Hash)]
7735        enum __FieldTag {
7736            __selector,
7737            __requested,
7738            __provided,
7739            __allowed_request_extensions,
7740            __allowed_response_extensions,
7741            Unknown(std::string::String),
7742        }
7743        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7744            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7745            where
7746                D: serde::Deserializer<'de>,
7747            {
7748                struct Visitor;
7749                impl<'de> serde::de::Visitor<'de> for Visitor {
7750                    type Value = __FieldTag;
7751                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7752                        formatter.write_str("a field name for ContextRule")
7753                    }
7754                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7755                    where
7756                        E: serde::de::Error,
7757                    {
7758                        use std::result::Result::Ok;
7759                        use std::string::ToString;
7760                        match value {
7761                            "selector" => Ok(__FieldTag::__selector),
7762                            "requested" => Ok(__FieldTag::__requested),
7763                            "provided" => Ok(__FieldTag::__provided),
7764                            "allowedRequestExtensions" => {
7765                                Ok(__FieldTag::__allowed_request_extensions)
7766                            }
7767                            "allowed_request_extensions" => {
7768                                Ok(__FieldTag::__allowed_request_extensions)
7769                            }
7770                            "allowedResponseExtensions" => {
7771                                Ok(__FieldTag::__allowed_response_extensions)
7772                            }
7773                            "allowed_response_extensions" => {
7774                                Ok(__FieldTag::__allowed_response_extensions)
7775                            }
7776                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7777                        }
7778                    }
7779                }
7780                deserializer.deserialize_identifier(Visitor)
7781            }
7782        }
7783        struct Visitor;
7784        impl<'de> serde::de::Visitor<'de> for Visitor {
7785            type Value = ContextRule;
7786            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7787                formatter.write_str("struct ContextRule")
7788            }
7789            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7790            where
7791                A: serde::de::MapAccess<'de>,
7792            {
7793                #[allow(unused_imports)]
7794                use serde::de::Error;
7795                use std::option::Option::Some;
7796                let mut fields = std::collections::HashSet::new();
7797                let mut result = Self::Value::new();
7798                while let Some(tag) = map.next_key::<__FieldTag>()? {
7799                    #[allow(clippy::match_single_binding)]
7800                    match tag {
7801                        __FieldTag::__selector => {
7802                            if !fields.insert(__FieldTag::__selector) {
7803                                return std::result::Result::Err(A::Error::duplicate_field(
7804                                    "multiple values for selector",
7805                                ));
7806                            }
7807                            result.selector = map
7808                                .next_value::<std::option::Option<std::string::String>>()?
7809                                .unwrap_or_default();
7810                        }
7811                        __FieldTag::__requested => {
7812                            if !fields.insert(__FieldTag::__requested) {
7813                                return std::result::Result::Err(A::Error::duplicate_field(
7814                                    "multiple values for requested",
7815                                ));
7816                            }
7817                            result.requested = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7818                        }
7819                        __FieldTag::__provided => {
7820                            if !fields.insert(__FieldTag::__provided) {
7821                                return std::result::Result::Err(A::Error::duplicate_field(
7822                                    "multiple values for provided",
7823                                ));
7824                            }
7825                            result.provided = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7826                        }
7827                        __FieldTag::__allowed_request_extensions => {
7828                            if !fields.insert(__FieldTag::__allowed_request_extensions) {
7829                                return std::result::Result::Err(A::Error::duplicate_field(
7830                                    "multiple values for allowed_request_extensions",
7831                                ));
7832                            }
7833                            result.allowed_request_extensions = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7834                        }
7835                        __FieldTag::__allowed_response_extensions => {
7836                            if !fields.insert(__FieldTag::__allowed_response_extensions) {
7837                                return std::result::Result::Err(A::Error::duplicate_field(
7838                                    "multiple values for allowed_response_extensions",
7839                                ));
7840                            }
7841                            result.allowed_response_extensions = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7842                        }
7843                        __FieldTag::Unknown(key) => {
7844                            let value = map.next_value::<serde_json::Value>()?;
7845                            result._unknown_fields.insert(key, value);
7846                        }
7847                    }
7848                }
7849                std::result::Result::Ok(result)
7850            }
7851        }
7852        deserializer.deserialize_any(Visitor)
7853    }
7854}
7855
7856#[doc(hidden)]
7857impl serde::ser::Serialize for ContextRule {
7858    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7859    where
7860        S: serde::ser::Serializer,
7861    {
7862        use serde::ser::SerializeMap;
7863        #[allow(unused_imports)]
7864        use std::option::Option::Some;
7865        let mut state = serializer.serialize_map(std::option::Option::None)?;
7866        if !self.selector.is_empty() {
7867            state.serialize_entry("selector", &self.selector)?;
7868        }
7869        if !self.requested.is_empty() {
7870            state.serialize_entry("requested", &self.requested)?;
7871        }
7872        if !self.provided.is_empty() {
7873            state.serialize_entry("provided", &self.provided)?;
7874        }
7875        if !self.allowed_request_extensions.is_empty() {
7876            state.serialize_entry("allowedRequestExtensions", &self.allowed_request_extensions)?;
7877        }
7878        if !self.allowed_response_extensions.is_empty() {
7879            state.serialize_entry(
7880                "allowedResponseExtensions",
7881                &self.allowed_response_extensions,
7882            )?;
7883        }
7884        if !self._unknown_fields.is_empty() {
7885            for (key, value) in self._unknown_fields.iter() {
7886                state.serialize_entry(key, &value)?;
7887            }
7888        }
7889        state.end()
7890    }
7891}
7892
7893impl std::fmt::Debug for ContextRule {
7894    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7895        let mut debug_struct = f.debug_struct("ContextRule");
7896        debug_struct.field("selector", &self.selector);
7897        debug_struct.field("requested", &self.requested);
7898        debug_struct.field("provided", &self.provided);
7899        debug_struct.field(
7900            "allowed_request_extensions",
7901            &self.allowed_request_extensions,
7902        );
7903        debug_struct.field(
7904            "allowed_response_extensions",
7905            &self.allowed_response_extensions,
7906        );
7907        if !self._unknown_fields.is_empty() {
7908            debug_struct.field("_unknown_fields", &self._unknown_fields);
7909        }
7910        debug_struct.finish()
7911    }
7912}
7913
7914/// Selects and configures the service controller used by the service.
7915///
7916/// Example:
7917///
7918/// ```norust
7919/// control:
7920///   environment: servicecontrol.googleapis.com
7921/// ```
7922#[derive(Clone, Default, PartialEq)]
7923#[non_exhaustive]
7924pub struct Control {
7925    /// The service controller environment to use. If empty, no control plane
7926    /// feature (like quota and billing) will be enabled. The recommended value for
7927    /// most services is servicecontrol.googleapis.com
7928    pub environment: std::string::String,
7929
7930    /// Defines policies applying to the API methods of the service.
7931    pub method_policies: std::vec::Vec<crate::model::MethodPolicy>,
7932
7933    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7934}
7935
7936impl Control {
7937    pub fn new() -> Self {
7938        std::default::Default::default()
7939    }
7940
7941    /// Sets the value of [environment][crate::model::Control::environment].
7942    pub fn set_environment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7943        self.environment = v.into();
7944        self
7945    }
7946
7947    /// Sets the value of [method_policies][crate::model::Control::method_policies].
7948    pub fn set_method_policies<T, V>(mut self, v: T) -> Self
7949    where
7950        T: std::iter::IntoIterator<Item = V>,
7951        V: std::convert::Into<crate::model::MethodPolicy>,
7952    {
7953        use std::iter::Iterator;
7954        self.method_policies = v.into_iter().map(|i| i.into()).collect();
7955        self
7956    }
7957}
7958
7959impl wkt::message::Message for Control {
7960    fn typename() -> &'static str {
7961        "type.googleapis.com/google.api.Control"
7962    }
7963}
7964
7965#[doc(hidden)]
7966impl<'de> serde::de::Deserialize<'de> for Control {
7967    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7968    where
7969        D: serde::Deserializer<'de>,
7970    {
7971        #[allow(non_camel_case_types)]
7972        #[doc(hidden)]
7973        #[derive(PartialEq, Eq, Hash)]
7974        enum __FieldTag {
7975            __environment,
7976            __method_policies,
7977            Unknown(std::string::String),
7978        }
7979        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7980            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7981            where
7982                D: serde::Deserializer<'de>,
7983            {
7984                struct Visitor;
7985                impl<'de> serde::de::Visitor<'de> for Visitor {
7986                    type Value = __FieldTag;
7987                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7988                        formatter.write_str("a field name for Control")
7989                    }
7990                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7991                    where
7992                        E: serde::de::Error,
7993                    {
7994                        use std::result::Result::Ok;
7995                        use std::string::ToString;
7996                        match value {
7997                            "environment" => Ok(__FieldTag::__environment),
7998                            "methodPolicies" => Ok(__FieldTag::__method_policies),
7999                            "method_policies" => Ok(__FieldTag::__method_policies),
8000                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8001                        }
8002                    }
8003                }
8004                deserializer.deserialize_identifier(Visitor)
8005            }
8006        }
8007        struct Visitor;
8008        impl<'de> serde::de::Visitor<'de> for Visitor {
8009            type Value = Control;
8010            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8011                formatter.write_str("struct Control")
8012            }
8013            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8014            where
8015                A: serde::de::MapAccess<'de>,
8016            {
8017                #[allow(unused_imports)]
8018                use serde::de::Error;
8019                use std::option::Option::Some;
8020                let mut fields = std::collections::HashSet::new();
8021                let mut result = Self::Value::new();
8022                while let Some(tag) = map.next_key::<__FieldTag>()? {
8023                    #[allow(clippy::match_single_binding)]
8024                    match tag {
8025                        __FieldTag::__environment => {
8026                            if !fields.insert(__FieldTag::__environment) {
8027                                return std::result::Result::Err(A::Error::duplicate_field(
8028                                    "multiple values for environment",
8029                                ));
8030                            }
8031                            result.environment = map
8032                                .next_value::<std::option::Option<std::string::String>>()?
8033                                .unwrap_or_default();
8034                        }
8035                        __FieldTag::__method_policies => {
8036                            if !fields.insert(__FieldTag::__method_policies) {
8037                                return std::result::Result::Err(A::Error::duplicate_field(
8038                                    "multiple values for method_policies",
8039                                ));
8040                            }
8041                            result.method_policies = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MethodPolicy>>>()?.unwrap_or_default();
8042                        }
8043                        __FieldTag::Unknown(key) => {
8044                            let value = map.next_value::<serde_json::Value>()?;
8045                            result._unknown_fields.insert(key, value);
8046                        }
8047                    }
8048                }
8049                std::result::Result::Ok(result)
8050            }
8051        }
8052        deserializer.deserialize_any(Visitor)
8053    }
8054}
8055
8056#[doc(hidden)]
8057impl serde::ser::Serialize for Control {
8058    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8059    where
8060        S: serde::ser::Serializer,
8061    {
8062        use serde::ser::SerializeMap;
8063        #[allow(unused_imports)]
8064        use std::option::Option::Some;
8065        let mut state = serializer.serialize_map(std::option::Option::None)?;
8066        if !self.environment.is_empty() {
8067            state.serialize_entry("environment", &self.environment)?;
8068        }
8069        if !self.method_policies.is_empty() {
8070            state.serialize_entry("methodPolicies", &self.method_policies)?;
8071        }
8072        if !self._unknown_fields.is_empty() {
8073            for (key, value) in self._unknown_fields.iter() {
8074                state.serialize_entry(key, &value)?;
8075            }
8076        }
8077        state.end()
8078    }
8079}
8080
8081impl std::fmt::Debug for Control {
8082    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8083        let mut debug_struct = f.debug_struct("Control");
8084        debug_struct.field("environment", &self.environment);
8085        debug_struct.field("method_policies", &self.method_policies);
8086        if !self._unknown_fields.is_empty() {
8087            debug_struct.field("_unknown_fields", &self._unknown_fields);
8088        }
8089        debug_struct.finish()
8090    }
8091}
8092
8093/// `Distribution` contains summary statistics for a population of values. It
8094/// optionally contains a histogram representing the distribution of those values
8095/// across a set of buckets.
8096///
8097/// The summary statistics are the count, mean, sum of the squared deviation from
8098/// the mean, the minimum, and the maximum of the set of population of values.
8099/// The histogram is based on a sequence of buckets and gives a count of values
8100/// that fall into each bucket. The boundaries of the buckets are given either
8101/// explicitly or by formulas for buckets of fixed or exponentially increasing
8102/// widths.
8103///
8104/// Although it is not forbidden, it is generally a bad idea to include
8105/// non-finite values (infinities or NaNs) in the population of values, as this
8106/// will render the `mean` and `sum_of_squared_deviation` fields meaningless.
8107#[derive(Clone, Default, PartialEq)]
8108#[non_exhaustive]
8109pub struct Distribution {
8110    /// The number of values in the population. Must be non-negative. This value
8111    /// must equal the sum of the values in `bucket_counts` if a histogram is
8112    /// provided.
8113    pub count: i64,
8114
8115    /// The arithmetic mean of the values in the population. If `count` is zero
8116    /// then this field must be zero.
8117    pub mean: f64,
8118
8119    /// The sum of squared deviations from the mean of the values in the
8120    /// population. For values x_i this is:
8121    ///
8122    /// ```norust
8123    /// Sum[i=1..n]((x_i - mean)^2)
8124    /// ```
8125    ///
8126    /// Knuth, "The Art of Computer Programming", Vol. 2, page 232, 3rd edition
8127    /// describes Welford's method for accumulating this sum in one pass.
8128    ///
8129    /// If `count` is zero then this field must be zero.
8130    pub sum_of_squared_deviation: f64,
8131
8132    /// If specified, contains the range of the population values. The field
8133    /// must not be present if the `count` is zero.
8134    pub range: std::option::Option<crate::model::distribution::Range>,
8135
8136    /// Defines the histogram bucket boundaries. If the distribution does not
8137    /// contain a histogram, then omit this field.
8138    pub bucket_options: std::option::Option<crate::model::distribution::BucketOptions>,
8139
8140    /// The number of values in each bucket of the histogram, as described in
8141    /// `bucket_options`. If the distribution does not have a histogram, then omit
8142    /// this field. If there is a histogram, then the sum of the values in
8143    /// `bucket_counts` must equal the value in the `count` field of the
8144    /// distribution.
8145    ///
8146    /// If present, `bucket_counts` should contain N values, where N is the number
8147    /// of buckets specified in `bucket_options`. If you supply fewer than N
8148    /// values, the remaining values are assumed to be 0.
8149    ///
8150    /// The order of the values in `bucket_counts` follows the bucket numbering
8151    /// schemes described for the three bucket types. The first value must be the
8152    /// count for the underflow bucket (number 0). The next N-2 values are the
8153    /// counts for the finite buckets (number 1 through N-2). The N'th value in
8154    /// `bucket_counts` is the count for the overflow bucket (number N-1).
8155    pub bucket_counts: std::vec::Vec<i64>,
8156
8157    /// Must be in increasing order of `value` field.
8158    pub exemplars: std::vec::Vec<crate::model::distribution::Exemplar>,
8159
8160    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8161}
8162
8163impl Distribution {
8164    pub fn new() -> Self {
8165        std::default::Default::default()
8166    }
8167
8168    /// Sets the value of [count][crate::model::Distribution::count].
8169    pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
8170        self.count = v.into();
8171        self
8172    }
8173
8174    /// Sets the value of [mean][crate::model::Distribution::mean].
8175    pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8176        self.mean = v.into();
8177        self
8178    }
8179
8180    /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
8181    pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8182        self.sum_of_squared_deviation = v.into();
8183        self
8184    }
8185
8186    /// Sets the value of [range][crate::model::Distribution::range].
8187    pub fn set_range<T>(mut self, v: T) -> Self
8188    where
8189        T: std::convert::Into<crate::model::distribution::Range>,
8190    {
8191        self.range = std::option::Option::Some(v.into());
8192        self
8193    }
8194
8195    /// Sets or clears the value of [range][crate::model::Distribution::range].
8196    pub fn set_or_clear_range<T>(mut self, v: std::option::Option<T>) -> Self
8197    where
8198        T: std::convert::Into<crate::model::distribution::Range>,
8199    {
8200        self.range = v.map(|x| x.into());
8201        self
8202    }
8203
8204    /// Sets the value of [bucket_options][crate::model::Distribution::bucket_options].
8205    pub fn set_bucket_options<T>(mut self, v: T) -> Self
8206    where
8207        T: std::convert::Into<crate::model::distribution::BucketOptions>,
8208    {
8209        self.bucket_options = std::option::Option::Some(v.into());
8210        self
8211    }
8212
8213    /// Sets or clears the value of [bucket_options][crate::model::Distribution::bucket_options].
8214    pub fn set_or_clear_bucket_options<T>(mut self, v: std::option::Option<T>) -> Self
8215    where
8216        T: std::convert::Into<crate::model::distribution::BucketOptions>,
8217    {
8218        self.bucket_options = v.map(|x| x.into());
8219        self
8220    }
8221
8222    /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
8223    pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
8224    where
8225        T: std::iter::IntoIterator<Item = V>,
8226        V: std::convert::Into<i64>,
8227    {
8228        use std::iter::Iterator;
8229        self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
8230        self
8231    }
8232
8233    /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
8234    pub fn set_exemplars<T, V>(mut self, v: T) -> Self
8235    where
8236        T: std::iter::IntoIterator<Item = V>,
8237        V: std::convert::Into<crate::model::distribution::Exemplar>,
8238    {
8239        use std::iter::Iterator;
8240        self.exemplars = v.into_iter().map(|i| i.into()).collect();
8241        self
8242    }
8243}
8244
8245impl wkt::message::Message for Distribution {
8246    fn typename() -> &'static str {
8247        "type.googleapis.com/google.api.Distribution"
8248    }
8249}
8250
8251#[doc(hidden)]
8252impl<'de> serde::de::Deserialize<'de> for Distribution {
8253    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8254    where
8255        D: serde::Deserializer<'de>,
8256    {
8257        #[allow(non_camel_case_types)]
8258        #[doc(hidden)]
8259        #[derive(PartialEq, Eq, Hash)]
8260        enum __FieldTag {
8261            __count,
8262            __mean,
8263            __sum_of_squared_deviation,
8264            __range,
8265            __bucket_options,
8266            __bucket_counts,
8267            __exemplars,
8268            Unknown(std::string::String),
8269        }
8270        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8271            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8272            where
8273                D: serde::Deserializer<'de>,
8274            {
8275                struct Visitor;
8276                impl<'de> serde::de::Visitor<'de> for Visitor {
8277                    type Value = __FieldTag;
8278                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8279                        formatter.write_str("a field name for Distribution")
8280                    }
8281                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8282                    where
8283                        E: serde::de::Error,
8284                    {
8285                        use std::result::Result::Ok;
8286                        use std::string::ToString;
8287                        match value {
8288                            "count" => Ok(__FieldTag::__count),
8289                            "mean" => Ok(__FieldTag::__mean),
8290                            "sumOfSquaredDeviation" => Ok(__FieldTag::__sum_of_squared_deviation),
8291                            "sum_of_squared_deviation" => {
8292                                Ok(__FieldTag::__sum_of_squared_deviation)
8293                            }
8294                            "range" => Ok(__FieldTag::__range),
8295                            "bucketOptions" => Ok(__FieldTag::__bucket_options),
8296                            "bucket_options" => Ok(__FieldTag::__bucket_options),
8297                            "bucketCounts" => Ok(__FieldTag::__bucket_counts),
8298                            "bucket_counts" => Ok(__FieldTag::__bucket_counts),
8299                            "exemplars" => Ok(__FieldTag::__exemplars),
8300                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8301                        }
8302                    }
8303                }
8304                deserializer.deserialize_identifier(Visitor)
8305            }
8306        }
8307        struct Visitor;
8308        impl<'de> serde::de::Visitor<'de> for Visitor {
8309            type Value = Distribution;
8310            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8311                formatter.write_str("struct Distribution")
8312            }
8313            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8314            where
8315                A: serde::de::MapAccess<'de>,
8316            {
8317                #[allow(unused_imports)]
8318                use serde::de::Error;
8319                use std::option::Option::Some;
8320                let mut fields = std::collections::HashSet::new();
8321                let mut result = Self::Value::new();
8322                while let Some(tag) = map.next_key::<__FieldTag>()? {
8323                    #[allow(clippy::match_single_binding)]
8324                    match tag {
8325                        __FieldTag::__count => {
8326                            if !fields.insert(__FieldTag::__count) {
8327                                return std::result::Result::Err(A::Error::duplicate_field(
8328                                    "multiple values for count",
8329                                ));
8330                            }
8331                            struct __With(std::option::Option<i64>);
8332                            impl<'de> serde::de::Deserialize<'de> for __With {
8333                                fn deserialize<D>(
8334                                    deserializer: D,
8335                                ) -> std::result::Result<Self, D::Error>
8336                                where
8337                                    D: serde::de::Deserializer<'de>,
8338                                {
8339                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
8340                                }
8341                            }
8342                            result.count = map.next_value::<__With>()?.0.unwrap_or_default();
8343                        }
8344                        __FieldTag::__mean => {
8345                            if !fields.insert(__FieldTag::__mean) {
8346                                return std::result::Result::Err(A::Error::duplicate_field(
8347                                    "multiple values for mean",
8348                                ));
8349                            }
8350                            struct __With(std::option::Option<f64>);
8351                            impl<'de> serde::de::Deserialize<'de> for __With {
8352                                fn deserialize<D>(
8353                                    deserializer: D,
8354                                ) -> std::result::Result<Self, D::Error>
8355                                where
8356                                    D: serde::de::Deserializer<'de>,
8357                                {
8358                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8359                                }
8360                            }
8361                            result.mean = map.next_value::<__With>()?.0.unwrap_or_default();
8362                        }
8363                        __FieldTag::__sum_of_squared_deviation => {
8364                            if !fields.insert(__FieldTag::__sum_of_squared_deviation) {
8365                                return std::result::Result::Err(A::Error::duplicate_field(
8366                                    "multiple values for sum_of_squared_deviation",
8367                                ));
8368                            }
8369                            struct __With(std::option::Option<f64>);
8370                            impl<'de> serde::de::Deserialize<'de> for __With {
8371                                fn deserialize<D>(
8372                                    deserializer: D,
8373                                ) -> std::result::Result<Self, D::Error>
8374                                where
8375                                    D: serde::de::Deserializer<'de>,
8376                                {
8377                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8378                                }
8379                            }
8380                            result.sum_of_squared_deviation =
8381                                map.next_value::<__With>()?.0.unwrap_or_default();
8382                        }
8383                        __FieldTag::__range => {
8384                            if !fields.insert(__FieldTag::__range) {
8385                                return std::result::Result::Err(A::Error::duplicate_field(
8386                                    "multiple values for range",
8387                                ));
8388                            }
8389                            result.range = map.next_value::<std::option::Option<crate::model::distribution::Range>>()?
8390                                ;
8391                        }
8392                        __FieldTag::__bucket_options => {
8393                            if !fields.insert(__FieldTag::__bucket_options) {
8394                                return std::result::Result::Err(A::Error::duplicate_field(
8395                                    "multiple values for bucket_options",
8396                                ));
8397                            }
8398                            result.bucket_options = map.next_value::<std::option::Option<crate::model::distribution::BucketOptions>>()?
8399                                ;
8400                        }
8401                        __FieldTag::__bucket_counts => {
8402                            if !fields.insert(__FieldTag::__bucket_counts) {
8403                                return std::result::Result::Err(A::Error::duplicate_field(
8404                                    "multiple values for bucket_counts",
8405                                ));
8406                            }
8407                            struct __With(std::option::Option<std::vec::Vec<i64>>);
8408                            impl<'de> serde::de::Deserialize<'de> for __With {
8409                                fn deserialize<D>(
8410                                    deserializer: D,
8411                                ) -> std::result::Result<Self, D::Error>
8412                                where
8413                                    D: serde::de::Deserializer<'de>,
8414                                {
8415                                    serde_with::As::<
8416                                        std::option::Option<std::vec::Vec<wkt::internal::I64>>,
8417                                    >::deserialize(deserializer)
8418                                    .map(__With)
8419                                }
8420                            }
8421                            result.bucket_counts =
8422                                map.next_value::<__With>()?.0.unwrap_or_default();
8423                        }
8424                        __FieldTag::__exemplars => {
8425                            if !fields.insert(__FieldTag::__exemplars) {
8426                                return std::result::Result::Err(A::Error::duplicate_field(
8427                                    "multiple values for exemplars",
8428                                ));
8429                            }
8430                            result.exemplars = map
8431                                .next_value::<std::option::Option<
8432                                    std::vec::Vec<crate::model::distribution::Exemplar>,
8433                                >>()?
8434                                .unwrap_or_default();
8435                        }
8436                        __FieldTag::Unknown(key) => {
8437                            let value = map.next_value::<serde_json::Value>()?;
8438                            result._unknown_fields.insert(key, value);
8439                        }
8440                    }
8441                }
8442                std::result::Result::Ok(result)
8443            }
8444        }
8445        deserializer.deserialize_any(Visitor)
8446    }
8447}
8448
8449#[doc(hidden)]
8450impl serde::ser::Serialize for Distribution {
8451    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8452    where
8453        S: serde::ser::Serializer,
8454    {
8455        use serde::ser::SerializeMap;
8456        #[allow(unused_imports)]
8457        use std::option::Option::Some;
8458        let mut state = serializer.serialize_map(std::option::Option::None)?;
8459        if !wkt::internal::is_default(&self.count) {
8460            struct __With<'a>(&'a i64);
8461            impl<'a> serde::ser::Serialize for __With<'a> {
8462                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8463                where
8464                    S: serde::ser::Serializer,
8465                {
8466                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
8467                }
8468            }
8469            state.serialize_entry("count", &__With(&self.count))?;
8470        }
8471        if !wkt::internal::is_default(&self.mean) {
8472            struct __With<'a>(&'a f64);
8473            impl<'a> serde::ser::Serialize for __With<'a> {
8474                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8475                where
8476                    S: serde::ser::Serializer,
8477                {
8478                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8479                }
8480            }
8481            state.serialize_entry("mean", &__With(&self.mean))?;
8482        }
8483        if !wkt::internal::is_default(&self.sum_of_squared_deviation) {
8484            struct __With<'a>(&'a f64);
8485            impl<'a> serde::ser::Serialize for __With<'a> {
8486                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8487                where
8488                    S: serde::ser::Serializer,
8489                {
8490                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8491                }
8492            }
8493            state.serialize_entry(
8494                "sumOfSquaredDeviation",
8495                &__With(&self.sum_of_squared_deviation),
8496            )?;
8497        }
8498        if self.range.is_some() {
8499            state.serialize_entry("range", &self.range)?;
8500        }
8501        if self.bucket_options.is_some() {
8502            state.serialize_entry("bucketOptions", &self.bucket_options)?;
8503        }
8504        if !self.bucket_counts.is_empty() {
8505            struct __With<'a>(&'a std::vec::Vec<i64>);
8506            impl<'a> serde::ser::Serialize for __With<'a> {
8507                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8508                where
8509                    S: serde::ser::Serializer,
8510                {
8511                    serde_with::As::<std::vec::Vec<wkt::internal::I64>>::serialize(
8512                        self.0, serializer,
8513                    )
8514                }
8515            }
8516            state.serialize_entry("bucketCounts", &__With(&self.bucket_counts))?;
8517        }
8518        if !self.exemplars.is_empty() {
8519            state.serialize_entry("exemplars", &self.exemplars)?;
8520        }
8521        if !self._unknown_fields.is_empty() {
8522            for (key, value) in self._unknown_fields.iter() {
8523                state.serialize_entry(key, &value)?;
8524            }
8525        }
8526        state.end()
8527    }
8528}
8529
8530impl std::fmt::Debug for Distribution {
8531    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8532        let mut debug_struct = f.debug_struct("Distribution");
8533        debug_struct.field("count", &self.count);
8534        debug_struct.field("mean", &self.mean);
8535        debug_struct.field("sum_of_squared_deviation", &self.sum_of_squared_deviation);
8536        debug_struct.field("range", &self.range);
8537        debug_struct.field("bucket_options", &self.bucket_options);
8538        debug_struct.field("bucket_counts", &self.bucket_counts);
8539        debug_struct.field("exemplars", &self.exemplars);
8540        if !self._unknown_fields.is_empty() {
8541            debug_struct.field("_unknown_fields", &self._unknown_fields);
8542        }
8543        debug_struct.finish()
8544    }
8545}
8546
8547/// Defines additional types related to [Distribution].
8548pub mod distribution {
8549    #[allow(unused_imports)]
8550    use super::*;
8551
8552    /// The range of the population values.
8553    #[derive(Clone, Default, PartialEq)]
8554    #[non_exhaustive]
8555    pub struct Range {
8556        /// The minimum of the population values.
8557        pub min: f64,
8558
8559        /// The maximum of the population values.
8560        pub max: f64,
8561
8562        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8563    }
8564
8565    impl Range {
8566        pub fn new() -> Self {
8567            std::default::Default::default()
8568        }
8569
8570        /// Sets the value of [min][crate::model::distribution::Range::min].
8571        pub fn set_min<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8572            self.min = v.into();
8573            self
8574        }
8575
8576        /// Sets the value of [max][crate::model::distribution::Range::max].
8577        pub fn set_max<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8578            self.max = v.into();
8579            self
8580        }
8581    }
8582
8583    impl wkt::message::Message for Range {
8584        fn typename() -> &'static str {
8585            "type.googleapis.com/google.api.Distribution.Range"
8586        }
8587    }
8588
8589    #[doc(hidden)]
8590    impl<'de> serde::de::Deserialize<'de> for Range {
8591        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8592        where
8593            D: serde::Deserializer<'de>,
8594        {
8595            #[allow(non_camel_case_types)]
8596            #[doc(hidden)]
8597            #[derive(PartialEq, Eq, Hash)]
8598            enum __FieldTag {
8599                __min,
8600                __max,
8601                Unknown(std::string::String),
8602            }
8603            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8604                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8605                where
8606                    D: serde::Deserializer<'de>,
8607                {
8608                    struct Visitor;
8609                    impl<'de> serde::de::Visitor<'de> for Visitor {
8610                        type Value = __FieldTag;
8611                        fn expecting(
8612                            &self,
8613                            formatter: &mut std::fmt::Formatter,
8614                        ) -> std::fmt::Result {
8615                            formatter.write_str("a field name for Range")
8616                        }
8617                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8618                        where
8619                            E: serde::de::Error,
8620                        {
8621                            use std::result::Result::Ok;
8622                            use std::string::ToString;
8623                            match value {
8624                                "min" => Ok(__FieldTag::__min),
8625                                "max" => Ok(__FieldTag::__max),
8626                                _ => Ok(__FieldTag::Unknown(value.to_string())),
8627                            }
8628                        }
8629                    }
8630                    deserializer.deserialize_identifier(Visitor)
8631                }
8632            }
8633            struct Visitor;
8634            impl<'de> serde::de::Visitor<'de> for Visitor {
8635                type Value = Range;
8636                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8637                    formatter.write_str("struct Range")
8638                }
8639                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8640                where
8641                    A: serde::de::MapAccess<'de>,
8642                {
8643                    #[allow(unused_imports)]
8644                    use serde::de::Error;
8645                    use std::option::Option::Some;
8646                    let mut fields = std::collections::HashSet::new();
8647                    let mut result = Self::Value::new();
8648                    while let Some(tag) = map.next_key::<__FieldTag>()? {
8649                        #[allow(clippy::match_single_binding)]
8650                        match tag {
8651                            __FieldTag::__min => {
8652                                if !fields.insert(__FieldTag::__min) {
8653                                    return std::result::Result::Err(A::Error::duplicate_field(
8654                                        "multiple values for min",
8655                                    ));
8656                                }
8657                                struct __With(std::option::Option<f64>);
8658                                impl<'de> serde::de::Deserialize<'de> for __With {
8659                                    fn deserialize<D>(
8660                                        deserializer: D,
8661                                    ) -> std::result::Result<Self, D::Error>
8662                                    where
8663                                        D: serde::de::Deserializer<'de>,
8664                                    {
8665                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8666                                    }
8667                                }
8668                                result.min = map.next_value::<__With>()?.0.unwrap_or_default();
8669                            }
8670                            __FieldTag::__max => {
8671                                if !fields.insert(__FieldTag::__max) {
8672                                    return std::result::Result::Err(A::Error::duplicate_field(
8673                                        "multiple values for max",
8674                                    ));
8675                                }
8676                                struct __With(std::option::Option<f64>);
8677                                impl<'de> serde::de::Deserialize<'de> for __With {
8678                                    fn deserialize<D>(
8679                                        deserializer: D,
8680                                    ) -> std::result::Result<Self, D::Error>
8681                                    where
8682                                        D: serde::de::Deserializer<'de>,
8683                                    {
8684                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8685                                    }
8686                                }
8687                                result.max = map.next_value::<__With>()?.0.unwrap_or_default();
8688                            }
8689                            __FieldTag::Unknown(key) => {
8690                                let value = map.next_value::<serde_json::Value>()?;
8691                                result._unknown_fields.insert(key, value);
8692                            }
8693                        }
8694                    }
8695                    std::result::Result::Ok(result)
8696                }
8697            }
8698            deserializer.deserialize_any(Visitor)
8699        }
8700    }
8701
8702    #[doc(hidden)]
8703    impl serde::ser::Serialize for Range {
8704        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8705        where
8706            S: serde::ser::Serializer,
8707        {
8708            use serde::ser::SerializeMap;
8709            #[allow(unused_imports)]
8710            use std::option::Option::Some;
8711            let mut state = serializer.serialize_map(std::option::Option::None)?;
8712            if !wkt::internal::is_default(&self.min) {
8713                struct __With<'a>(&'a f64);
8714                impl<'a> serde::ser::Serialize for __With<'a> {
8715                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8716                    where
8717                        S: serde::ser::Serializer,
8718                    {
8719                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8720                    }
8721                }
8722                state.serialize_entry("min", &__With(&self.min))?;
8723            }
8724            if !wkt::internal::is_default(&self.max) {
8725                struct __With<'a>(&'a f64);
8726                impl<'a> serde::ser::Serialize for __With<'a> {
8727                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8728                    where
8729                        S: serde::ser::Serializer,
8730                    {
8731                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8732                    }
8733                }
8734                state.serialize_entry("max", &__With(&self.max))?;
8735            }
8736            if !self._unknown_fields.is_empty() {
8737                for (key, value) in self._unknown_fields.iter() {
8738                    state.serialize_entry(key, &value)?;
8739                }
8740            }
8741            state.end()
8742        }
8743    }
8744
8745    impl std::fmt::Debug for Range {
8746        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8747            let mut debug_struct = f.debug_struct("Range");
8748            debug_struct.field("min", &self.min);
8749            debug_struct.field("max", &self.max);
8750            if !self._unknown_fields.is_empty() {
8751                debug_struct.field("_unknown_fields", &self._unknown_fields);
8752            }
8753            debug_struct.finish()
8754        }
8755    }
8756
8757    /// `BucketOptions` describes the bucket boundaries used to create a histogram
8758    /// for the distribution. The buckets can be in a linear sequence, an
8759    /// exponential sequence, or each bucket can be specified explicitly.
8760    /// `BucketOptions` does not include the number of values in each bucket.
8761    ///
8762    /// A bucket has an inclusive lower bound and exclusive upper bound for the
8763    /// values that are counted for that bucket. The upper bound of a bucket must
8764    /// be strictly greater than the lower bound. The sequence of N buckets for a
8765    /// distribution consists of an underflow bucket (number 0), zero or more
8766    /// finite buckets (number 1 through N - 2) and an overflow bucket (number N -
8767    /// 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the
8768    /// same as the upper bound of bucket i - 1. The buckets span the whole range
8769    /// of finite values: lower bound of the underflow bucket is -infinity and the
8770    /// upper bound of the overflow bucket is +infinity. The finite buckets are
8771    /// so-called because both bounds are finite.
8772    #[derive(Clone, Default, PartialEq)]
8773    #[non_exhaustive]
8774    pub struct BucketOptions {
8775        /// Exactly one of these three fields must be set.
8776        pub options: std::option::Option<crate::model::distribution::bucket_options::Options>,
8777
8778        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8779    }
8780
8781    impl BucketOptions {
8782        pub fn new() -> Self {
8783            std::default::Default::default()
8784        }
8785
8786        /// Sets the value of [options][crate::model::distribution::BucketOptions::options].
8787        ///
8788        /// Note that all the setters affecting `options` are mutually
8789        /// exclusive.
8790        pub fn set_options<
8791            T: std::convert::Into<
8792                    std::option::Option<crate::model::distribution::bucket_options::Options>,
8793                >,
8794        >(
8795            mut self,
8796            v: T,
8797        ) -> Self {
8798            self.options = v.into();
8799            self
8800        }
8801
8802        /// The value of [options][crate::model::distribution::BucketOptions::options]
8803        /// if it holds a `LinearBuckets`, `None` if the field is not set or
8804        /// holds a different branch.
8805        pub fn linear_buckets(
8806            &self,
8807        ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::bucket_options::Linear>>
8808        {
8809            #[allow(unreachable_patterns)]
8810            self.options.as_ref().and_then(|v| match v {
8811                crate::model::distribution::bucket_options::Options::LinearBuckets(v) => {
8812                    std::option::Option::Some(v)
8813                }
8814                _ => std::option::Option::None,
8815            })
8816        }
8817
8818        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8819        /// to hold a `LinearBuckets`.
8820        ///
8821        /// Note that all the setters affecting `options` are
8822        /// mutually exclusive.
8823        pub fn set_linear_buckets<
8824            T: std::convert::Into<std::boxed::Box<crate::model::distribution::bucket_options::Linear>>,
8825        >(
8826            mut self,
8827            v: T,
8828        ) -> Self {
8829            self.options = std::option::Option::Some(
8830                crate::model::distribution::bucket_options::Options::LinearBuckets(v.into()),
8831            );
8832            self
8833        }
8834
8835        /// The value of [options][crate::model::distribution::BucketOptions::options]
8836        /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
8837        /// holds a different branch.
8838        pub fn exponential_buckets(
8839            &self,
8840        ) -> std::option::Option<
8841            &std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
8842        > {
8843            #[allow(unreachable_patterns)]
8844            self.options.as_ref().and_then(|v| match v {
8845                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v) => {
8846                    std::option::Option::Some(v)
8847                }
8848                _ => std::option::Option::None,
8849            })
8850        }
8851
8852        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8853        /// to hold a `ExponentialBuckets`.
8854        ///
8855        /// Note that all the setters affecting `options` are
8856        /// mutually exclusive.
8857        pub fn set_exponential_buckets<
8858            T: std::convert::Into<
8859                    std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
8860                >,
8861        >(
8862            mut self,
8863            v: T,
8864        ) -> Self {
8865            self.options = std::option::Option::Some(
8866                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v.into()),
8867            );
8868            self
8869        }
8870
8871        /// The value of [options][crate::model::distribution::BucketOptions::options]
8872        /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
8873        /// holds a different branch.
8874        pub fn explicit_buckets(
8875            &self,
8876        ) -> std::option::Option<
8877            &std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
8878        > {
8879            #[allow(unreachable_patterns)]
8880            self.options.as_ref().and_then(|v| match v {
8881                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v) => {
8882                    std::option::Option::Some(v)
8883                }
8884                _ => std::option::Option::None,
8885            })
8886        }
8887
8888        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8889        /// to hold a `ExplicitBuckets`.
8890        ///
8891        /// Note that all the setters affecting `options` are
8892        /// mutually exclusive.
8893        pub fn set_explicit_buckets<
8894            T: std::convert::Into<
8895                    std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
8896                >,
8897        >(
8898            mut self,
8899            v: T,
8900        ) -> Self {
8901            self.options = std::option::Option::Some(
8902                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v.into()),
8903            );
8904            self
8905        }
8906    }
8907
8908    impl wkt::message::Message for BucketOptions {
8909        fn typename() -> &'static str {
8910            "type.googleapis.com/google.api.Distribution.BucketOptions"
8911        }
8912    }
8913
8914    #[doc(hidden)]
8915    impl<'de> serde::de::Deserialize<'de> for BucketOptions {
8916        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8917        where
8918            D: serde::Deserializer<'de>,
8919        {
8920            #[allow(non_camel_case_types)]
8921            #[doc(hidden)]
8922            #[derive(PartialEq, Eq, Hash)]
8923            enum __FieldTag {
8924                __linear_buckets,
8925                __exponential_buckets,
8926                __explicit_buckets,
8927                Unknown(std::string::String),
8928            }
8929            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8930                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8931                where
8932                    D: serde::Deserializer<'de>,
8933                {
8934                    struct Visitor;
8935                    impl<'de> serde::de::Visitor<'de> for Visitor {
8936                        type Value = __FieldTag;
8937                        fn expecting(
8938                            &self,
8939                            formatter: &mut std::fmt::Formatter,
8940                        ) -> std::fmt::Result {
8941                            formatter.write_str("a field name for BucketOptions")
8942                        }
8943                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8944                        where
8945                            E: serde::de::Error,
8946                        {
8947                            use std::result::Result::Ok;
8948                            use std::string::ToString;
8949                            match value {
8950                                "linearBuckets" => Ok(__FieldTag::__linear_buckets),
8951                                "linear_buckets" => Ok(__FieldTag::__linear_buckets),
8952                                "exponentialBuckets" => Ok(__FieldTag::__exponential_buckets),
8953                                "exponential_buckets" => Ok(__FieldTag::__exponential_buckets),
8954                                "explicitBuckets" => Ok(__FieldTag::__explicit_buckets),
8955                                "explicit_buckets" => Ok(__FieldTag::__explicit_buckets),
8956                                _ => Ok(__FieldTag::Unknown(value.to_string())),
8957                            }
8958                        }
8959                    }
8960                    deserializer.deserialize_identifier(Visitor)
8961                }
8962            }
8963            struct Visitor;
8964            impl<'de> serde::de::Visitor<'de> for Visitor {
8965                type Value = BucketOptions;
8966                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8967                    formatter.write_str("struct BucketOptions")
8968                }
8969                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8970                where
8971                    A: serde::de::MapAccess<'de>,
8972                {
8973                    #[allow(unused_imports)]
8974                    use serde::de::Error;
8975                    use std::option::Option::Some;
8976                    let mut fields = std::collections::HashSet::new();
8977                    let mut result = Self::Value::new();
8978                    while let Some(tag) = map.next_key::<__FieldTag>()? {
8979                        #[allow(clippy::match_single_binding)]
8980                        match tag {
8981                            __FieldTag::__linear_buckets => {
8982                                if !fields.insert(__FieldTag::__linear_buckets) {
8983                                    return std::result::Result::Err(A::Error::duplicate_field(
8984                                        "multiple values for linear_buckets",
8985                                    ));
8986                                }
8987                                if result.options.is_some() {
8988                                    return std::result::Result::Err(A::Error::duplicate_field(
8989                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.linear_buckets, latest field was linearBuckets",
8990                                    ));
8991                                }
8992                                result.options = std::option::Option::Some(
8993                                    crate::model::distribution::bucket_options::Options::LinearBuckets(
8994                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Linear>>>()?.unwrap_or_default()
8995                                    ),
8996                                );
8997                            }
8998                            __FieldTag::__exponential_buckets => {
8999                                if !fields.insert(__FieldTag::__exponential_buckets) {
9000                                    return std::result::Result::Err(A::Error::duplicate_field(
9001                                        "multiple values for exponential_buckets",
9002                                    ));
9003                                }
9004                                if result.options.is_some() {
9005                                    return std::result::Result::Err(A::Error::duplicate_field(
9006                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.exponential_buckets, latest field was exponentialBuckets",
9007                                    ));
9008                                }
9009                                result.options = std::option::Option::Some(
9010                                    crate::model::distribution::bucket_options::Options::ExponentialBuckets(
9011                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Exponential>>>()?.unwrap_or_default()
9012                                    ),
9013                                );
9014                            }
9015                            __FieldTag::__explicit_buckets => {
9016                                if !fields.insert(__FieldTag::__explicit_buckets) {
9017                                    return std::result::Result::Err(A::Error::duplicate_field(
9018                                        "multiple values for explicit_buckets",
9019                                    ));
9020                                }
9021                                if result.options.is_some() {
9022                                    return std::result::Result::Err(A::Error::duplicate_field(
9023                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.explicit_buckets, latest field was explicitBuckets",
9024                                    ));
9025                                }
9026                                result.options = std::option::Option::Some(
9027                                    crate::model::distribution::bucket_options::Options::ExplicitBuckets(
9028                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Explicit>>>()?.unwrap_or_default()
9029                                    ),
9030                                );
9031                            }
9032                            __FieldTag::Unknown(key) => {
9033                                let value = map.next_value::<serde_json::Value>()?;
9034                                result._unknown_fields.insert(key, value);
9035                            }
9036                        }
9037                    }
9038                    std::result::Result::Ok(result)
9039                }
9040            }
9041            deserializer.deserialize_any(Visitor)
9042        }
9043    }
9044
9045    #[doc(hidden)]
9046    impl serde::ser::Serialize for BucketOptions {
9047        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9048        where
9049            S: serde::ser::Serializer,
9050        {
9051            use serde::ser::SerializeMap;
9052            #[allow(unused_imports)]
9053            use std::option::Option::Some;
9054            let mut state = serializer.serialize_map(std::option::Option::None)?;
9055            if let Some(value) = self.linear_buckets() {
9056                state.serialize_entry("linearBuckets", value)?;
9057            }
9058            if let Some(value) = self.exponential_buckets() {
9059                state.serialize_entry("exponentialBuckets", value)?;
9060            }
9061            if let Some(value) = self.explicit_buckets() {
9062                state.serialize_entry("explicitBuckets", value)?;
9063            }
9064            if !self._unknown_fields.is_empty() {
9065                for (key, value) in self._unknown_fields.iter() {
9066                    state.serialize_entry(key, &value)?;
9067                }
9068            }
9069            state.end()
9070        }
9071    }
9072
9073    impl std::fmt::Debug for BucketOptions {
9074        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9075            let mut debug_struct = f.debug_struct("BucketOptions");
9076            debug_struct.field("options", &self.options);
9077            if !self._unknown_fields.is_empty() {
9078                debug_struct.field("_unknown_fields", &self._unknown_fields);
9079            }
9080            debug_struct.finish()
9081        }
9082    }
9083
9084    /// Defines additional types related to [BucketOptions].
9085    pub mod bucket_options {
9086        #[allow(unused_imports)]
9087        use super::*;
9088
9089        /// Specifies a linear sequence of buckets that all have the same width
9090        /// (except overflow and underflow). Each bucket represents a constant
9091        /// absolute uncertainty on the specific value in the bucket.
9092        ///
9093        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
9094        /// following boundaries:
9095        ///
9096        /// Upper bound (0 <= i < N-1):     offset + (width * i).
9097        ///
9098        /// Lower bound (1 <= i < N):       offset + (width * (i - 1)).
9099        #[derive(Clone, Default, PartialEq)]
9100        #[non_exhaustive]
9101        pub struct Linear {
9102            /// Must be greater than 0.
9103            pub num_finite_buckets: i32,
9104
9105            /// Must be greater than 0.
9106            pub width: f64,
9107
9108            /// Lower bound of the first bucket.
9109            pub offset: f64,
9110
9111            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9112        }
9113
9114        impl Linear {
9115            pub fn new() -> Self {
9116                std::default::Default::default()
9117            }
9118
9119            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Linear::num_finite_buckets].
9120            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9121                self.num_finite_buckets = v.into();
9122                self
9123            }
9124
9125            /// Sets the value of [width][crate::model::distribution::bucket_options::Linear::width].
9126            pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9127                self.width = v.into();
9128                self
9129            }
9130
9131            /// Sets the value of [offset][crate::model::distribution::bucket_options::Linear::offset].
9132            pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9133                self.offset = v.into();
9134                self
9135            }
9136        }
9137
9138        impl wkt::message::Message for Linear {
9139            fn typename() -> &'static str {
9140                "type.googleapis.com/google.api.Distribution.BucketOptions.Linear"
9141            }
9142        }
9143
9144        #[doc(hidden)]
9145        impl<'de> serde::de::Deserialize<'de> for Linear {
9146            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9147            where
9148                D: serde::Deserializer<'de>,
9149            {
9150                #[allow(non_camel_case_types)]
9151                #[doc(hidden)]
9152                #[derive(PartialEq, Eq, Hash)]
9153                enum __FieldTag {
9154                    __num_finite_buckets,
9155                    __width,
9156                    __offset,
9157                    Unknown(std::string::String),
9158                }
9159                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9160                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9161                    where
9162                        D: serde::Deserializer<'de>,
9163                    {
9164                        struct Visitor;
9165                        impl<'de> serde::de::Visitor<'de> for Visitor {
9166                            type Value = __FieldTag;
9167                            fn expecting(
9168                                &self,
9169                                formatter: &mut std::fmt::Formatter,
9170                            ) -> std::fmt::Result {
9171                                formatter.write_str("a field name for Linear")
9172                            }
9173                            fn visit_str<E>(
9174                                self,
9175                                value: &str,
9176                            ) -> std::result::Result<Self::Value, E>
9177                            where
9178                                E: serde::de::Error,
9179                            {
9180                                use std::result::Result::Ok;
9181                                use std::string::ToString;
9182                                match value {
9183                                    "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
9184                                    "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
9185                                    "width" => Ok(__FieldTag::__width),
9186                                    "offset" => Ok(__FieldTag::__offset),
9187                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
9188                                }
9189                            }
9190                        }
9191                        deserializer.deserialize_identifier(Visitor)
9192                    }
9193                }
9194                struct Visitor;
9195                impl<'de> serde::de::Visitor<'de> for Visitor {
9196                    type Value = Linear;
9197                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9198                        formatter.write_str("struct Linear")
9199                    }
9200                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9201                    where
9202                        A: serde::de::MapAccess<'de>,
9203                    {
9204                        #[allow(unused_imports)]
9205                        use serde::de::Error;
9206                        use std::option::Option::Some;
9207                        let mut fields = std::collections::HashSet::new();
9208                        let mut result = Self::Value::new();
9209                        while let Some(tag) = map.next_key::<__FieldTag>()? {
9210                            #[allow(clippy::match_single_binding)]
9211                            match tag {
9212                                __FieldTag::__num_finite_buckets => {
9213                                    if !fields.insert(__FieldTag::__num_finite_buckets) {
9214                                        return std::result::Result::Err(
9215                                            A::Error::duplicate_field(
9216                                                "multiple values for num_finite_buckets",
9217                                            ),
9218                                        );
9219                                    }
9220                                    struct __With(std::option::Option<i32>);
9221                                    impl<'de> serde::de::Deserialize<'de> for __With {
9222                                        fn deserialize<D>(
9223                                            deserializer: D,
9224                                        ) -> std::result::Result<Self, D::Error>
9225                                        where
9226                                            D: serde::de::Deserializer<'de>,
9227                                        {
9228                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
9229                                        }
9230                                    }
9231                                    result.num_finite_buckets =
9232                                        map.next_value::<__With>()?.0.unwrap_or_default();
9233                                }
9234                                __FieldTag::__width => {
9235                                    if !fields.insert(__FieldTag::__width) {
9236                                        return std::result::Result::Err(
9237                                            A::Error::duplicate_field("multiple values for width"),
9238                                        );
9239                                    }
9240                                    struct __With(std::option::Option<f64>);
9241                                    impl<'de> serde::de::Deserialize<'de> for __With {
9242                                        fn deserialize<D>(
9243                                            deserializer: D,
9244                                        ) -> std::result::Result<Self, D::Error>
9245                                        where
9246                                            D: serde::de::Deserializer<'de>,
9247                                        {
9248                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9249                                        }
9250                                    }
9251                                    result.width =
9252                                        map.next_value::<__With>()?.0.unwrap_or_default();
9253                                }
9254                                __FieldTag::__offset => {
9255                                    if !fields.insert(__FieldTag::__offset) {
9256                                        return std::result::Result::Err(
9257                                            A::Error::duplicate_field("multiple values for offset"),
9258                                        );
9259                                    }
9260                                    struct __With(std::option::Option<f64>);
9261                                    impl<'de> serde::de::Deserialize<'de> for __With {
9262                                        fn deserialize<D>(
9263                                            deserializer: D,
9264                                        ) -> std::result::Result<Self, D::Error>
9265                                        where
9266                                            D: serde::de::Deserializer<'de>,
9267                                        {
9268                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9269                                        }
9270                                    }
9271                                    result.offset =
9272                                        map.next_value::<__With>()?.0.unwrap_or_default();
9273                                }
9274                                __FieldTag::Unknown(key) => {
9275                                    let value = map.next_value::<serde_json::Value>()?;
9276                                    result._unknown_fields.insert(key, value);
9277                                }
9278                            }
9279                        }
9280                        std::result::Result::Ok(result)
9281                    }
9282                }
9283                deserializer.deserialize_any(Visitor)
9284            }
9285        }
9286
9287        #[doc(hidden)]
9288        impl serde::ser::Serialize for Linear {
9289            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9290            where
9291                S: serde::ser::Serializer,
9292            {
9293                use serde::ser::SerializeMap;
9294                #[allow(unused_imports)]
9295                use std::option::Option::Some;
9296                let mut state = serializer.serialize_map(std::option::Option::None)?;
9297                if !wkt::internal::is_default(&self.num_finite_buckets) {
9298                    struct __With<'a>(&'a i32);
9299                    impl<'a> serde::ser::Serialize for __With<'a> {
9300                        fn serialize<S>(
9301                            &self,
9302                            serializer: S,
9303                        ) -> std::result::Result<S::Ok, S::Error>
9304                        where
9305                            S: serde::ser::Serializer,
9306                        {
9307                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
9308                        }
9309                    }
9310                    state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
9311                }
9312                if !wkt::internal::is_default(&self.width) {
9313                    struct __With<'a>(&'a f64);
9314                    impl<'a> serde::ser::Serialize for __With<'a> {
9315                        fn serialize<S>(
9316                            &self,
9317                            serializer: S,
9318                        ) -> std::result::Result<S::Ok, S::Error>
9319                        where
9320                            S: serde::ser::Serializer,
9321                        {
9322                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9323                        }
9324                    }
9325                    state.serialize_entry("width", &__With(&self.width))?;
9326                }
9327                if !wkt::internal::is_default(&self.offset) {
9328                    struct __With<'a>(&'a f64);
9329                    impl<'a> serde::ser::Serialize for __With<'a> {
9330                        fn serialize<S>(
9331                            &self,
9332                            serializer: S,
9333                        ) -> std::result::Result<S::Ok, S::Error>
9334                        where
9335                            S: serde::ser::Serializer,
9336                        {
9337                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9338                        }
9339                    }
9340                    state.serialize_entry("offset", &__With(&self.offset))?;
9341                }
9342                if !self._unknown_fields.is_empty() {
9343                    for (key, value) in self._unknown_fields.iter() {
9344                        state.serialize_entry(key, &value)?;
9345                    }
9346                }
9347                state.end()
9348            }
9349        }
9350
9351        impl std::fmt::Debug for Linear {
9352            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9353                let mut debug_struct = f.debug_struct("Linear");
9354                debug_struct.field("num_finite_buckets", &self.num_finite_buckets);
9355                debug_struct.field("width", &self.width);
9356                debug_struct.field("offset", &self.offset);
9357                if !self._unknown_fields.is_empty() {
9358                    debug_struct.field("_unknown_fields", &self._unknown_fields);
9359                }
9360                debug_struct.finish()
9361            }
9362        }
9363
9364        /// Specifies an exponential sequence of buckets that have a width that is
9365        /// proportional to the value of the lower bound. Each bucket represents a
9366        /// constant relative uncertainty on a specific value in the bucket.
9367        ///
9368        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
9369        /// following boundaries:
9370        ///
9371        /// Upper bound (0 <= i < N-1):     scale * (growth_factor ^ i).
9372        ///
9373        /// Lower bound (1 <= i < N):       scale * (growth_factor ^ (i - 1)).
9374        #[derive(Clone, Default, PartialEq)]
9375        #[non_exhaustive]
9376        pub struct Exponential {
9377            /// Must be greater than 0.
9378            pub num_finite_buckets: i32,
9379
9380            /// Must be greater than 1.
9381            pub growth_factor: f64,
9382
9383            /// Must be greater than 0.
9384            pub scale: f64,
9385
9386            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9387        }
9388
9389        impl Exponential {
9390            pub fn new() -> Self {
9391                std::default::Default::default()
9392            }
9393
9394            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Exponential::num_finite_buckets].
9395            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9396                self.num_finite_buckets = v.into();
9397                self
9398            }
9399
9400            /// Sets the value of [growth_factor][crate::model::distribution::bucket_options::Exponential::growth_factor].
9401            pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9402                self.growth_factor = v.into();
9403                self
9404            }
9405
9406            /// Sets the value of [scale][crate::model::distribution::bucket_options::Exponential::scale].
9407            pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9408                self.scale = v.into();
9409                self
9410            }
9411        }
9412
9413        impl wkt::message::Message for Exponential {
9414            fn typename() -> &'static str {
9415                "type.googleapis.com/google.api.Distribution.BucketOptions.Exponential"
9416            }
9417        }
9418
9419        #[doc(hidden)]
9420        impl<'de> serde::de::Deserialize<'de> for Exponential {
9421            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9422            where
9423                D: serde::Deserializer<'de>,
9424            {
9425                #[allow(non_camel_case_types)]
9426                #[doc(hidden)]
9427                #[derive(PartialEq, Eq, Hash)]
9428                enum __FieldTag {
9429                    __num_finite_buckets,
9430                    __growth_factor,
9431                    __scale,
9432                    Unknown(std::string::String),
9433                }
9434                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9435                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9436                    where
9437                        D: serde::Deserializer<'de>,
9438                    {
9439                        struct Visitor;
9440                        impl<'de> serde::de::Visitor<'de> for Visitor {
9441                            type Value = __FieldTag;
9442                            fn expecting(
9443                                &self,
9444                                formatter: &mut std::fmt::Formatter,
9445                            ) -> std::fmt::Result {
9446                                formatter.write_str("a field name for Exponential")
9447                            }
9448                            fn visit_str<E>(
9449                                self,
9450                                value: &str,
9451                            ) -> std::result::Result<Self::Value, E>
9452                            where
9453                                E: serde::de::Error,
9454                            {
9455                                use std::result::Result::Ok;
9456                                use std::string::ToString;
9457                                match value {
9458                                    "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
9459                                    "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
9460                                    "growthFactor" => Ok(__FieldTag::__growth_factor),
9461                                    "growth_factor" => Ok(__FieldTag::__growth_factor),
9462                                    "scale" => Ok(__FieldTag::__scale),
9463                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
9464                                }
9465                            }
9466                        }
9467                        deserializer.deserialize_identifier(Visitor)
9468                    }
9469                }
9470                struct Visitor;
9471                impl<'de> serde::de::Visitor<'de> for Visitor {
9472                    type Value = Exponential;
9473                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9474                        formatter.write_str("struct Exponential")
9475                    }
9476                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9477                    where
9478                        A: serde::de::MapAccess<'de>,
9479                    {
9480                        #[allow(unused_imports)]
9481                        use serde::de::Error;
9482                        use std::option::Option::Some;
9483                        let mut fields = std::collections::HashSet::new();
9484                        let mut result = Self::Value::new();
9485                        while let Some(tag) = map.next_key::<__FieldTag>()? {
9486                            #[allow(clippy::match_single_binding)]
9487                            match tag {
9488                                __FieldTag::__num_finite_buckets => {
9489                                    if !fields.insert(__FieldTag::__num_finite_buckets) {
9490                                        return std::result::Result::Err(
9491                                            A::Error::duplicate_field(
9492                                                "multiple values for num_finite_buckets",
9493                                            ),
9494                                        );
9495                                    }
9496                                    struct __With(std::option::Option<i32>);
9497                                    impl<'de> serde::de::Deserialize<'de> for __With {
9498                                        fn deserialize<D>(
9499                                            deserializer: D,
9500                                        ) -> std::result::Result<Self, D::Error>
9501                                        where
9502                                            D: serde::de::Deserializer<'de>,
9503                                        {
9504                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
9505                                        }
9506                                    }
9507                                    result.num_finite_buckets =
9508                                        map.next_value::<__With>()?.0.unwrap_or_default();
9509                                }
9510                                __FieldTag::__growth_factor => {
9511                                    if !fields.insert(__FieldTag::__growth_factor) {
9512                                        return std::result::Result::Err(
9513                                            A::Error::duplicate_field(
9514                                                "multiple values for growth_factor",
9515                                            ),
9516                                        );
9517                                    }
9518                                    struct __With(std::option::Option<f64>);
9519                                    impl<'de> serde::de::Deserialize<'de> for __With {
9520                                        fn deserialize<D>(
9521                                            deserializer: D,
9522                                        ) -> std::result::Result<Self, D::Error>
9523                                        where
9524                                            D: serde::de::Deserializer<'de>,
9525                                        {
9526                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9527                                        }
9528                                    }
9529                                    result.growth_factor =
9530                                        map.next_value::<__With>()?.0.unwrap_or_default();
9531                                }
9532                                __FieldTag::__scale => {
9533                                    if !fields.insert(__FieldTag::__scale) {
9534                                        return std::result::Result::Err(
9535                                            A::Error::duplicate_field("multiple values for scale"),
9536                                        );
9537                                    }
9538                                    struct __With(std::option::Option<f64>);
9539                                    impl<'de> serde::de::Deserialize<'de> for __With {
9540                                        fn deserialize<D>(
9541                                            deserializer: D,
9542                                        ) -> std::result::Result<Self, D::Error>
9543                                        where
9544                                            D: serde::de::Deserializer<'de>,
9545                                        {
9546                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9547                                        }
9548                                    }
9549                                    result.scale =
9550                                        map.next_value::<__With>()?.0.unwrap_or_default();
9551                                }
9552                                __FieldTag::Unknown(key) => {
9553                                    let value = map.next_value::<serde_json::Value>()?;
9554                                    result._unknown_fields.insert(key, value);
9555                                }
9556                            }
9557                        }
9558                        std::result::Result::Ok(result)
9559                    }
9560                }
9561                deserializer.deserialize_any(Visitor)
9562            }
9563        }
9564
9565        #[doc(hidden)]
9566        impl serde::ser::Serialize for Exponential {
9567            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9568            where
9569                S: serde::ser::Serializer,
9570            {
9571                use serde::ser::SerializeMap;
9572                #[allow(unused_imports)]
9573                use std::option::Option::Some;
9574                let mut state = serializer.serialize_map(std::option::Option::None)?;
9575                if !wkt::internal::is_default(&self.num_finite_buckets) {
9576                    struct __With<'a>(&'a i32);
9577                    impl<'a> serde::ser::Serialize for __With<'a> {
9578                        fn serialize<S>(
9579                            &self,
9580                            serializer: S,
9581                        ) -> std::result::Result<S::Ok, S::Error>
9582                        where
9583                            S: serde::ser::Serializer,
9584                        {
9585                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
9586                        }
9587                    }
9588                    state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
9589                }
9590                if !wkt::internal::is_default(&self.growth_factor) {
9591                    struct __With<'a>(&'a f64);
9592                    impl<'a> serde::ser::Serialize for __With<'a> {
9593                        fn serialize<S>(
9594                            &self,
9595                            serializer: S,
9596                        ) -> std::result::Result<S::Ok, S::Error>
9597                        where
9598                            S: serde::ser::Serializer,
9599                        {
9600                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9601                        }
9602                    }
9603                    state.serialize_entry("growthFactor", &__With(&self.growth_factor))?;
9604                }
9605                if !wkt::internal::is_default(&self.scale) {
9606                    struct __With<'a>(&'a f64);
9607                    impl<'a> serde::ser::Serialize for __With<'a> {
9608                        fn serialize<S>(
9609                            &self,
9610                            serializer: S,
9611                        ) -> std::result::Result<S::Ok, S::Error>
9612                        where
9613                            S: serde::ser::Serializer,
9614                        {
9615                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9616                        }
9617                    }
9618                    state.serialize_entry("scale", &__With(&self.scale))?;
9619                }
9620                if !self._unknown_fields.is_empty() {
9621                    for (key, value) in self._unknown_fields.iter() {
9622                        state.serialize_entry(key, &value)?;
9623                    }
9624                }
9625                state.end()
9626            }
9627        }
9628
9629        impl std::fmt::Debug for Exponential {
9630            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9631                let mut debug_struct = f.debug_struct("Exponential");
9632                debug_struct.field("num_finite_buckets", &self.num_finite_buckets);
9633                debug_struct.field("growth_factor", &self.growth_factor);
9634                debug_struct.field("scale", &self.scale);
9635                if !self._unknown_fields.is_empty() {
9636                    debug_struct.field("_unknown_fields", &self._unknown_fields);
9637                }
9638                debug_struct.finish()
9639            }
9640        }
9641
9642        /// Specifies a set of buckets with arbitrary widths.
9643        ///
9644        /// There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following
9645        /// boundaries:
9646        ///
9647        /// Upper bound (0 <= i < N-1):     bounds[i]
9648        /// Lower bound (1 <= i < N);       bounds[i - 1]
9649        ///
9650        /// The `bounds` field must contain at least one element. If `bounds` has
9651        /// only one element, then there are no finite buckets, and that single
9652        /// element is the common boundary of the overflow and underflow buckets.
9653        #[derive(Clone, Default, PartialEq)]
9654        #[non_exhaustive]
9655        pub struct Explicit {
9656            /// The values must be monotonically increasing.
9657            pub bounds: std::vec::Vec<f64>,
9658
9659            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9660        }
9661
9662        impl Explicit {
9663            pub fn new() -> Self {
9664                std::default::Default::default()
9665            }
9666
9667            /// Sets the value of [bounds][crate::model::distribution::bucket_options::Explicit::bounds].
9668            pub fn set_bounds<T, V>(mut self, v: T) -> Self
9669            where
9670                T: std::iter::IntoIterator<Item = V>,
9671                V: std::convert::Into<f64>,
9672            {
9673                use std::iter::Iterator;
9674                self.bounds = v.into_iter().map(|i| i.into()).collect();
9675                self
9676            }
9677        }
9678
9679        impl wkt::message::Message for Explicit {
9680            fn typename() -> &'static str {
9681                "type.googleapis.com/google.api.Distribution.BucketOptions.Explicit"
9682            }
9683        }
9684
9685        #[doc(hidden)]
9686        impl<'de> serde::de::Deserialize<'de> for Explicit {
9687            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9688            where
9689                D: serde::Deserializer<'de>,
9690            {
9691                #[allow(non_camel_case_types)]
9692                #[doc(hidden)]
9693                #[derive(PartialEq, Eq, Hash)]
9694                enum __FieldTag {
9695                    __bounds,
9696                    Unknown(std::string::String),
9697                }
9698                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9699                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9700                    where
9701                        D: serde::Deserializer<'de>,
9702                    {
9703                        struct Visitor;
9704                        impl<'de> serde::de::Visitor<'de> for Visitor {
9705                            type Value = __FieldTag;
9706                            fn expecting(
9707                                &self,
9708                                formatter: &mut std::fmt::Formatter,
9709                            ) -> std::fmt::Result {
9710                                formatter.write_str("a field name for Explicit")
9711                            }
9712                            fn visit_str<E>(
9713                                self,
9714                                value: &str,
9715                            ) -> std::result::Result<Self::Value, E>
9716                            where
9717                                E: serde::de::Error,
9718                            {
9719                                use std::result::Result::Ok;
9720                                use std::string::ToString;
9721                                match value {
9722                                    "bounds" => Ok(__FieldTag::__bounds),
9723                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
9724                                }
9725                            }
9726                        }
9727                        deserializer.deserialize_identifier(Visitor)
9728                    }
9729                }
9730                struct Visitor;
9731                impl<'de> serde::de::Visitor<'de> for Visitor {
9732                    type Value = Explicit;
9733                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9734                        formatter.write_str("struct Explicit")
9735                    }
9736                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9737                    where
9738                        A: serde::de::MapAccess<'de>,
9739                    {
9740                        #[allow(unused_imports)]
9741                        use serde::de::Error;
9742                        use std::option::Option::Some;
9743                        let mut fields = std::collections::HashSet::new();
9744                        let mut result = Self::Value::new();
9745                        while let Some(tag) = map.next_key::<__FieldTag>()? {
9746                            #[allow(clippy::match_single_binding)]
9747                            match tag {
9748                                __FieldTag::__bounds => {
9749                                    if !fields.insert(__FieldTag::__bounds) {
9750                                        return std::result::Result::Err(
9751                                            A::Error::duplicate_field("multiple values for bounds"),
9752                                        );
9753                                    }
9754                                    struct __With(std::option::Option<std::vec::Vec<f64>>);
9755                                    impl<'de> serde::de::Deserialize<'de> for __With {
9756                                        fn deserialize<D>(
9757                                            deserializer: D,
9758                                        ) -> std::result::Result<Self, D::Error>
9759                                        where
9760                                            D: serde::de::Deserializer<'de>,
9761                                        {
9762                                            serde_with::As::<
9763                                                std::option::Option<
9764                                                    std::vec::Vec<wkt::internal::F64>,
9765                                                >,
9766                                            >::deserialize(
9767                                                deserializer
9768                                            )
9769                                            .map(__With)
9770                                        }
9771                                    }
9772                                    result.bounds =
9773                                        map.next_value::<__With>()?.0.unwrap_or_default();
9774                                }
9775                                __FieldTag::Unknown(key) => {
9776                                    let value = map.next_value::<serde_json::Value>()?;
9777                                    result._unknown_fields.insert(key, value);
9778                                }
9779                            }
9780                        }
9781                        std::result::Result::Ok(result)
9782                    }
9783                }
9784                deserializer.deserialize_any(Visitor)
9785            }
9786        }
9787
9788        #[doc(hidden)]
9789        impl serde::ser::Serialize for Explicit {
9790            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9791            where
9792                S: serde::ser::Serializer,
9793            {
9794                use serde::ser::SerializeMap;
9795                #[allow(unused_imports)]
9796                use std::option::Option::Some;
9797                let mut state = serializer.serialize_map(std::option::Option::None)?;
9798                if !self.bounds.is_empty() {
9799                    struct __With<'a>(&'a std::vec::Vec<f64>);
9800                    impl<'a> serde::ser::Serialize for __With<'a> {
9801                        fn serialize<S>(
9802                            &self,
9803                            serializer: S,
9804                        ) -> std::result::Result<S::Ok, S::Error>
9805                        where
9806                            S: serde::ser::Serializer,
9807                        {
9808                            serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
9809                                self.0, serializer,
9810                            )
9811                        }
9812                    }
9813                    state.serialize_entry("bounds", &__With(&self.bounds))?;
9814                }
9815                if !self._unknown_fields.is_empty() {
9816                    for (key, value) in self._unknown_fields.iter() {
9817                        state.serialize_entry(key, &value)?;
9818                    }
9819                }
9820                state.end()
9821            }
9822        }
9823
9824        impl std::fmt::Debug for Explicit {
9825            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9826                let mut debug_struct = f.debug_struct("Explicit");
9827                debug_struct.field("bounds", &self.bounds);
9828                if !self._unknown_fields.is_empty() {
9829                    debug_struct.field("_unknown_fields", &self._unknown_fields);
9830                }
9831                debug_struct.finish()
9832            }
9833        }
9834
9835        /// Exactly one of these three fields must be set.
9836        #[derive(Clone, Debug, PartialEq)]
9837        #[non_exhaustive]
9838        pub enum Options {
9839            /// The linear bucket.
9840            LinearBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Linear>),
9841            /// The exponential buckets.
9842            ExponentialBuckets(
9843                std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
9844            ),
9845            /// The explicit buckets.
9846            ExplicitBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Explicit>),
9847        }
9848    }
9849
9850    /// Exemplars are example points that may be used to annotate aggregated
9851    /// distribution values. They are metadata that gives information about a
9852    /// particular value added to a Distribution bucket, such as a trace ID that
9853    /// was active when a value was added. They may contain further information,
9854    /// such as a example values and timestamps, origin, etc.
9855    #[derive(Clone, Default, PartialEq)]
9856    #[non_exhaustive]
9857    pub struct Exemplar {
9858        /// Value of the exemplar point. This value determines to which bucket the
9859        /// exemplar belongs.
9860        pub value: f64,
9861
9862        /// The observation (sampling) time of the above value.
9863        pub timestamp: std::option::Option<wkt::Timestamp>,
9864
9865        /// Contextual information about the example value. Examples are:
9866        ///
9867        /// Trace: type.googleapis.com/google.monitoring.v3.SpanContext
9868        ///
9869        /// Literal string: type.googleapis.com/google.protobuf.StringValue
9870        ///
9871        /// Labels dropped during aggregation:
9872        /// type.googleapis.com/google.monitoring.v3.DroppedLabels
9873        ///
9874        /// There may be only a single attachment of any given message type in a
9875        /// single exemplar, and this is enforced by the system.
9876        pub attachments: std::vec::Vec<wkt::Any>,
9877
9878        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9879    }
9880
9881    impl Exemplar {
9882        pub fn new() -> Self {
9883            std::default::Default::default()
9884        }
9885
9886        /// Sets the value of [value][crate::model::distribution::Exemplar::value].
9887        pub fn set_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9888            self.value = v.into();
9889            self
9890        }
9891
9892        /// Sets the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
9893        pub fn set_timestamp<T>(mut self, v: T) -> Self
9894        where
9895            T: std::convert::Into<wkt::Timestamp>,
9896        {
9897            self.timestamp = std::option::Option::Some(v.into());
9898            self
9899        }
9900
9901        /// Sets or clears the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
9902        pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
9903        where
9904            T: std::convert::Into<wkt::Timestamp>,
9905        {
9906            self.timestamp = v.map(|x| x.into());
9907            self
9908        }
9909
9910        /// Sets the value of [attachments][crate::model::distribution::Exemplar::attachments].
9911        pub fn set_attachments<T, V>(mut self, v: T) -> Self
9912        where
9913            T: std::iter::IntoIterator<Item = V>,
9914            V: std::convert::Into<wkt::Any>,
9915        {
9916            use std::iter::Iterator;
9917            self.attachments = v.into_iter().map(|i| i.into()).collect();
9918            self
9919        }
9920    }
9921
9922    impl wkt::message::Message for Exemplar {
9923        fn typename() -> &'static str {
9924            "type.googleapis.com/google.api.Distribution.Exemplar"
9925        }
9926    }
9927
9928    #[doc(hidden)]
9929    impl<'de> serde::de::Deserialize<'de> for Exemplar {
9930        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9931        where
9932            D: serde::Deserializer<'de>,
9933        {
9934            #[allow(non_camel_case_types)]
9935            #[doc(hidden)]
9936            #[derive(PartialEq, Eq, Hash)]
9937            enum __FieldTag {
9938                __value,
9939                __timestamp,
9940                __attachments,
9941                Unknown(std::string::String),
9942            }
9943            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9944                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9945                where
9946                    D: serde::Deserializer<'de>,
9947                {
9948                    struct Visitor;
9949                    impl<'de> serde::de::Visitor<'de> for Visitor {
9950                        type Value = __FieldTag;
9951                        fn expecting(
9952                            &self,
9953                            formatter: &mut std::fmt::Formatter,
9954                        ) -> std::fmt::Result {
9955                            formatter.write_str("a field name for Exemplar")
9956                        }
9957                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9958                        where
9959                            E: serde::de::Error,
9960                        {
9961                            use std::result::Result::Ok;
9962                            use std::string::ToString;
9963                            match value {
9964                                "value" => Ok(__FieldTag::__value),
9965                                "timestamp" => Ok(__FieldTag::__timestamp),
9966                                "attachments" => Ok(__FieldTag::__attachments),
9967                                _ => Ok(__FieldTag::Unknown(value.to_string())),
9968                            }
9969                        }
9970                    }
9971                    deserializer.deserialize_identifier(Visitor)
9972                }
9973            }
9974            struct Visitor;
9975            impl<'de> serde::de::Visitor<'de> for Visitor {
9976                type Value = Exemplar;
9977                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9978                    formatter.write_str("struct Exemplar")
9979                }
9980                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9981                where
9982                    A: serde::de::MapAccess<'de>,
9983                {
9984                    #[allow(unused_imports)]
9985                    use serde::de::Error;
9986                    use std::option::Option::Some;
9987                    let mut fields = std::collections::HashSet::new();
9988                    let mut result = Self::Value::new();
9989                    while let Some(tag) = map.next_key::<__FieldTag>()? {
9990                        #[allow(clippy::match_single_binding)]
9991                        match tag {
9992                            __FieldTag::__value => {
9993                                if !fields.insert(__FieldTag::__value) {
9994                                    return std::result::Result::Err(A::Error::duplicate_field(
9995                                        "multiple values for value",
9996                                    ));
9997                                }
9998                                struct __With(std::option::Option<f64>);
9999                                impl<'de> serde::de::Deserialize<'de> for __With {
10000                                    fn deserialize<D>(
10001                                        deserializer: D,
10002                                    ) -> std::result::Result<Self, D::Error>
10003                                    where
10004                                        D: serde::de::Deserializer<'de>,
10005                                    {
10006                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10007                                    }
10008                                }
10009                                result.value = map.next_value::<__With>()?.0.unwrap_or_default();
10010                            }
10011                            __FieldTag::__timestamp => {
10012                                if !fields.insert(__FieldTag::__timestamp) {
10013                                    return std::result::Result::Err(A::Error::duplicate_field(
10014                                        "multiple values for timestamp",
10015                                    ));
10016                                }
10017                                result.timestamp =
10018                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
10019                            }
10020                            __FieldTag::__attachments => {
10021                                if !fields.insert(__FieldTag::__attachments) {
10022                                    return std::result::Result::Err(A::Error::duplicate_field(
10023                                        "multiple values for attachments",
10024                                    ));
10025                                }
10026                                result.attachments = map
10027                                    .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
10028                                    .unwrap_or_default();
10029                            }
10030                            __FieldTag::Unknown(key) => {
10031                                let value = map.next_value::<serde_json::Value>()?;
10032                                result._unknown_fields.insert(key, value);
10033                            }
10034                        }
10035                    }
10036                    std::result::Result::Ok(result)
10037                }
10038            }
10039            deserializer.deserialize_any(Visitor)
10040        }
10041    }
10042
10043    #[doc(hidden)]
10044    impl serde::ser::Serialize for Exemplar {
10045        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10046        where
10047            S: serde::ser::Serializer,
10048        {
10049            use serde::ser::SerializeMap;
10050            #[allow(unused_imports)]
10051            use std::option::Option::Some;
10052            let mut state = serializer.serialize_map(std::option::Option::None)?;
10053            if !wkt::internal::is_default(&self.value) {
10054                struct __With<'a>(&'a f64);
10055                impl<'a> serde::ser::Serialize for __With<'a> {
10056                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10057                    where
10058                        S: serde::ser::Serializer,
10059                    {
10060                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
10061                    }
10062                }
10063                state.serialize_entry("value", &__With(&self.value))?;
10064            }
10065            if self.timestamp.is_some() {
10066                state.serialize_entry("timestamp", &self.timestamp)?;
10067            }
10068            if !self.attachments.is_empty() {
10069                state.serialize_entry("attachments", &self.attachments)?;
10070            }
10071            if !self._unknown_fields.is_empty() {
10072                for (key, value) in self._unknown_fields.iter() {
10073                    state.serialize_entry(key, &value)?;
10074                }
10075            }
10076            state.end()
10077        }
10078    }
10079
10080    impl std::fmt::Debug for Exemplar {
10081        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10082            let mut debug_struct = f.debug_struct("Exemplar");
10083            debug_struct.field("value", &self.value);
10084            debug_struct.field("timestamp", &self.timestamp);
10085            debug_struct.field("attachments", &self.attachments);
10086            if !self._unknown_fields.is_empty() {
10087                debug_struct.field("_unknown_fields", &self._unknown_fields);
10088            }
10089            debug_struct.finish()
10090        }
10091    }
10092}
10093
10094/// `Documentation` provides the information for describing a service.
10095///
10096/// Example:
10097///
10098/// Documentation is provided in markdown syntax. In addition to
10099/// standard markdown features, definition lists, tables and fenced
10100/// code blocks are supported. Section headers can be provided and are
10101/// interpreted relative to the section nesting of the context where
10102/// a documentation fragment is embedded.
10103///
10104/// Documentation from the IDL is merged with documentation defined
10105/// via the config at normalization time, where documentation provided
10106/// by config rules overrides IDL provided.
10107///
10108/// A number of constructs specific to the API platform are supported
10109/// in documentation text.
10110///
10111/// In order to reference a proto element, the following
10112/// notation can be used:
10113///
10114/// To override the display text used for the link, this can be used:
10115///
10116/// Text can be excluded from doc using the following notation:
10117///
10118/// A few directives are available in documentation. Note that
10119/// directives must appear on a single line to be properly
10120/// identified. The `include` directive includes a markdown file from
10121/// an external source:
10122///
10123/// The `resource_for` directive marks a message to be the resource of
10124/// a collection in REST view. If it is not specified, tools attempt
10125/// to infer the resource from the operations in a collection:
10126///
10127/// The directive `suppress_warning` does not directly affect documentation
10128/// and is documented together with service config validation.
10129#[derive(Clone, Default, PartialEq)]
10130#[non_exhaustive]
10131pub struct Documentation {
10132    /// A short description of what the service does. The summary must be plain
10133    /// text. It becomes the overview of the service displayed in Google Cloud
10134    /// Console.
10135    /// NOTE: This field is equivalent to the standard field `description`.
10136    pub summary: std::string::String,
10137
10138    /// The top level pages for the documentation set.
10139    pub pages: std::vec::Vec<crate::model::Page>,
10140
10141    /// A list of documentation rules that apply to individual API elements.
10142    ///
10143    /// **NOTE:** All service configuration rules follow "last one wins" order.
10144    pub rules: std::vec::Vec<crate::model::DocumentationRule>,
10145
10146    /// The URL to the root of documentation.
10147    pub documentation_root_url: std::string::String,
10148
10149    /// Specifies the service root url if the default one (the service name
10150    /// from the yaml file) is not suitable. This can be seen in any fully
10151    /// specified service urls as well as sections that show a base that other
10152    /// urls are relative to.
10153    pub service_root_url: std::string::String,
10154
10155    /// Declares a single overview page. For example:
10156    ///
10157    /// This is a shortcut for the following declaration (using pages style):
10158    ///
10159    /// Note: you cannot specify both `overview` field and `pages` field.
10160    pub overview: std::string::String,
10161
10162    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10163}
10164
10165impl Documentation {
10166    pub fn new() -> Self {
10167        std::default::Default::default()
10168    }
10169
10170    /// Sets the value of [summary][crate::model::Documentation::summary].
10171    pub fn set_summary<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10172        self.summary = v.into();
10173        self
10174    }
10175
10176    /// Sets the value of [pages][crate::model::Documentation::pages].
10177    pub fn set_pages<T, V>(mut self, v: T) -> Self
10178    where
10179        T: std::iter::IntoIterator<Item = V>,
10180        V: std::convert::Into<crate::model::Page>,
10181    {
10182        use std::iter::Iterator;
10183        self.pages = v.into_iter().map(|i| i.into()).collect();
10184        self
10185    }
10186
10187    /// Sets the value of [rules][crate::model::Documentation::rules].
10188    pub fn set_rules<T, V>(mut self, v: T) -> Self
10189    where
10190        T: std::iter::IntoIterator<Item = V>,
10191        V: std::convert::Into<crate::model::DocumentationRule>,
10192    {
10193        use std::iter::Iterator;
10194        self.rules = v.into_iter().map(|i| i.into()).collect();
10195        self
10196    }
10197
10198    /// Sets the value of [documentation_root_url][crate::model::Documentation::documentation_root_url].
10199    pub fn set_documentation_root_url<T: std::convert::Into<std::string::String>>(
10200        mut self,
10201        v: T,
10202    ) -> Self {
10203        self.documentation_root_url = v.into();
10204        self
10205    }
10206
10207    /// Sets the value of [service_root_url][crate::model::Documentation::service_root_url].
10208    pub fn set_service_root_url<T: std::convert::Into<std::string::String>>(
10209        mut self,
10210        v: T,
10211    ) -> Self {
10212        self.service_root_url = v.into();
10213        self
10214    }
10215
10216    /// Sets the value of [overview][crate::model::Documentation::overview].
10217    pub fn set_overview<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10218        self.overview = v.into();
10219        self
10220    }
10221}
10222
10223impl wkt::message::Message for Documentation {
10224    fn typename() -> &'static str {
10225        "type.googleapis.com/google.api.Documentation"
10226    }
10227}
10228
10229#[doc(hidden)]
10230impl<'de> serde::de::Deserialize<'de> for Documentation {
10231    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10232    where
10233        D: serde::Deserializer<'de>,
10234    {
10235        #[allow(non_camel_case_types)]
10236        #[doc(hidden)]
10237        #[derive(PartialEq, Eq, Hash)]
10238        enum __FieldTag {
10239            __summary,
10240            __pages,
10241            __rules,
10242            __documentation_root_url,
10243            __service_root_url,
10244            __overview,
10245            Unknown(std::string::String),
10246        }
10247        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10248            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10249            where
10250                D: serde::Deserializer<'de>,
10251            {
10252                struct Visitor;
10253                impl<'de> serde::de::Visitor<'de> for Visitor {
10254                    type Value = __FieldTag;
10255                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10256                        formatter.write_str("a field name for Documentation")
10257                    }
10258                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10259                    where
10260                        E: serde::de::Error,
10261                    {
10262                        use std::result::Result::Ok;
10263                        use std::string::ToString;
10264                        match value {
10265                            "summary" => Ok(__FieldTag::__summary),
10266                            "pages" => Ok(__FieldTag::__pages),
10267                            "rules" => Ok(__FieldTag::__rules),
10268                            "documentationRootUrl" => Ok(__FieldTag::__documentation_root_url),
10269                            "documentation_root_url" => Ok(__FieldTag::__documentation_root_url),
10270                            "serviceRootUrl" => Ok(__FieldTag::__service_root_url),
10271                            "service_root_url" => Ok(__FieldTag::__service_root_url),
10272                            "overview" => Ok(__FieldTag::__overview),
10273                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10274                        }
10275                    }
10276                }
10277                deserializer.deserialize_identifier(Visitor)
10278            }
10279        }
10280        struct Visitor;
10281        impl<'de> serde::de::Visitor<'de> for Visitor {
10282            type Value = Documentation;
10283            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10284                formatter.write_str("struct Documentation")
10285            }
10286            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10287            where
10288                A: serde::de::MapAccess<'de>,
10289            {
10290                #[allow(unused_imports)]
10291                use serde::de::Error;
10292                use std::option::Option::Some;
10293                let mut fields = std::collections::HashSet::new();
10294                let mut result = Self::Value::new();
10295                while let Some(tag) = map.next_key::<__FieldTag>()? {
10296                    #[allow(clippy::match_single_binding)]
10297                    match tag {
10298                        __FieldTag::__summary => {
10299                            if !fields.insert(__FieldTag::__summary) {
10300                                return std::result::Result::Err(A::Error::duplicate_field(
10301                                    "multiple values for summary",
10302                                ));
10303                            }
10304                            result.summary = map
10305                                .next_value::<std::option::Option<std::string::String>>()?
10306                                .unwrap_or_default();
10307                        }
10308                        __FieldTag::__pages => {
10309                            if !fields.insert(__FieldTag::__pages) {
10310                                return std::result::Result::Err(A::Error::duplicate_field(
10311                                    "multiple values for pages",
10312                                ));
10313                            }
10314                            result.pages = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Page>>>()?.unwrap_or_default();
10315                        }
10316                        __FieldTag::__rules => {
10317                            if !fields.insert(__FieldTag::__rules) {
10318                                return std::result::Result::Err(A::Error::duplicate_field(
10319                                    "multiple values for rules",
10320                                ));
10321                            }
10322                            result.rules =
10323                                map.next_value::<std::option::Option<
10324                                    std::vec::Vec<crate::model::DocumentationRule>,
10325                                >>()?
10326                                .unwrap_or_default();
10327                        }
10328                        __FieldTag::__documentation_root_url => {
10329                            if !fields.insert(__FieldTag::__documentation_root_url) {
10330                                return std::result::Result::Err(A::Error::duplicate_field(
10331                                    "multiple values for documentation_root_url",
10332                                ));
10333                            }
10334                            result.documentation_root_url = map
10335                                .next_value::<std::option::Option<std::string::String>>()?
10336                                .unwrap_or_default();
10337                        }
10338                        __FieldTag::__service_root_url => {
10339                            if !fields.insert(__FieldTag::__service_root_url) {
10340                                return std::result::Result::Err(A::Error::duplicate_field(
10341                                    "multiple values for service_root_url",
10342                                ));
10343                            }
10344                            result.service_root_url = map
10345                                .next_value::<std::option::Option<std::string::String>>()?
10346                                .unwrap_or_default();
10347                        }
10348                        __FieldTag::__overview => {
10349                            if !fields.insert(__FieldTag::__overview) {
10350                                return std::result::Result::Err(A::Error::duplicate_field(
10351                                    "multiple values for overview",
10352                                ));
10353                            }
10354                            result.overview = map
10355                                .next_value::<std::option::Option<std::string::String>>()?
10356                                .unwrap_or_default();
10357                        }
10358                        __FieldTag::Unknown(key) => {
10359                            let value = map.next_value::<serde_json::Value>()?;
10360                            result._unknown_fields.insert(key, value);
10361                        }
10362                    }
10363                }
10364                std::result::Result::Ok(result)
10365            }
10366        }
10367        deserializer.deserialize_any(Visitor)
10368    }
10369}
10370
10371#[doc(hidden)]
10372impl serde::ser::Serialize for Documentation {
10373    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10374    where
10375        S: serde::ser::Serializer,
10376    {
10377        use serde::ser::SerializeMap;
10378        #[allow(unused_imports)]
10379        use std::option::Option::Some;
10380        let mut state = serializer.serialize_map(std::option::Option::None)?;
10381        if !self.summary.is_empty() {
10382            state.serialize_entry("summary", &self.summary)?;
10383        }
10384        if !self.pages.is_empty() {
10385            state.serialize_entry("pages", &self.pages)?;
10386        }
10387        if !self.rules.is_empty() {
10388            state.serialize_entry("rules", &self.rules)?;
10389        }
10390        if !self.documentation_root_url.is_empty() {
10391            state.serialize_entry("documentationRootUrl", &self.documentation_root_url)?;
10392        }
10393        if !self.service_root_url.is_empty() {
10394            state.serialize_entry("serviceRootUrl", &self.service_root_url)?;
10395        }
10396        if !self.overview.is_empty() {
10397            state.serialize_entry("overview", &self.overview)?;
10398        }
10399        if !self._unknown_fields.is_empty() {
10400            for (key, value) in self._unknown_fields.iter() {
10401                state.serialize_entry(key, &value)?;
10402            }
10403        }
10404        state.end()
10405    }
10406}
10407
10408impl std::fmt::Debug for Documentation {
10409    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10410        let mut debug_struct = f.debug_struct("Documentation");
10411        debug_struct.field("summary", &self.summary);
10412        debug_struct.field("pages", &self.pages);
10413        debug_struct.field("rules", &self.rules);
10414        debug_struct.field("documentation_root_url", &self.documentation_root_url);
10415        debug_struct.field("service_root_url", &self.service_root_url);
10416        debug_struct.field("overview", &self.overview);
10417        if !self._unknown_fields.is_empty() {
10418            debug_struct.field("_unknown_fields", &self._unknown_fields);
10419        }
10420        debug_struct.finish()
10421    }
10422}
10423
10424/// A documentation rule provides information about individual API elements.
10425#[derive(Clone, Default, PartialEq)]
10426#[non_exhaustive]
10427pub struct DocumentationRule {
10428    /// The selector is a comma-separated list of patterns for any element such as
10429    /// a method, a field, an enum value. Each pattern is a qualified name of the
10430    /// element which may end in "*", indicating a wildcard. Wildcards are only
10431    /// allowed at the end and for a whole component of the qualified name,
10432    /// i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". A wildcard will match
10433    /// one or more components. To specify a default for all applicable elements,
10434    /// the whole pattern "*" is used.
10435    pub selector: std::string::String,
10436
10437    /// Description of the selected proto element (e.g. a message, a method, a
10438    /// 'service' definition, or a field). Defaults to leading & trailing comments
10439    /// taken from the proto source definition of the proto element.
10440    pub description: std::string::String,
10441
10442    /// Deprecation description of the selected element(s). It can be provided if
10443    /// an element is marked as `deprecated`.
10444    pub deprecation_description: std::string::String,
10445
10446    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10447}
10448
10449impl DocumentationRule {
10450    pub fn new() -> Self {
10451        std::default::Default::default()
10452    }
10453
10454    /// Sets the value of [selector][crate::model::DocumentationRule::selector].
10455    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10456        self.selector = v.into();
10457        self
10458    }
10459
10460    /// Sets the value of [description][crate::model::DocumentationRule::description].
10461    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10462        self.description = v.into();
10463        self
10464    }
10465
10466    /// Sets the value of [deprecation_description][crate::model::DocumentationRule::deprecation_description].
10467    pub fn set_deprecation_description<T: std::convert::Into<std::string::String>>(
10468        mut self,
10469        v: T,
10470    ) -> Self {
10471        self.deprecation_description = v.into();
10472        self
10473    }
10474}
10475
10476impl wkt::message::Message for DocumentationRule {
10477    fn typename() -> &'static str {
10478        "type.googleapis.com/google.api.DocumentationRule"
10479    }
10480}
10481
10482#[doc(hidden)]
10483impl<'de> serde::de::Deserialize<'de> for DocumentationRule {
10484    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10485    where
10486        D: serde::Deserializer<'de>,
10487    {
10488        #[allow(non_camel_case_types)]
10489        #[doc(hidden)]
10490        #[derive(PartialEq, Eq, Hash)]
10491        enum __FieldTag {
10492            __selector,
10493            __description,
10494            __deprecation_description,
10495            Unknown(std::string::String),
10496        }
10497        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10498            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10499            where
10500                D: serde::Deserializer<'de>,
10501            {
10502                struct Visitor;
10503                impl<'de> serde::de::Visitor<'de> for Visitor {
10504                    type Value = __FieldTag;
10505                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10506                        formatter.write_str("a field name for DocumentationRule")
10507                    }
10508                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10509                    where
10510                        E: serde::de::Error,
10511                    {
10512                        use std::result::Result::Ok;
10513                        use std::string::ToString;
10514                        match value {
10515                            "selector" => Ok(__FieldTag::__selector),
10516                            "description" => Ok(__FieldTag::__description),
10517                            "deprecationDescription" => Ok(__FieldTag::__deprecation_description),
10518                            "deprecation_description" => Ok(__FieldTag::__deprecation_description),
10519                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10520                        }
10521                    }
10522                }
10523                deserializer.deserialize_identifier(Visitor)
10524            }
10525        }
10526        struct Visitor;
10527        impl<'de> serde::de::Visitor<'de> for Visitor {
10528            type Value = DocumentationRule;
10529            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10530                formatter.write_str("struct DocumentationRule")
10531            }
10532            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10533            where
10534                A: serde::de::MapAccess<'de>,
10535            {
10536                #[allow(unused_imports)]
10537                use serde::de::Error;
10538                use std::option::Option::Some;
10539                let mut fields = std::collections::HashSet::new();
10540                let mut result = Self::Value::new();
10541                while let Some(tag) = map.next_key::<__FieldTag>()? {
10542                    #[allow(clippy::match_single_binding)]
10543                    match tag {
10544                        __FieldTag::__selector => {
10545                            if !fields.insert(__FieldTag::__selector) {
10546                                return std::result::Result::Err(A::Error::duplicate_field(
10547                                    "multiple values for selector",
10548                                ));
10549                            }
10550                            result.selector = map
10551                                .next_value::<std::option::Option<std::string::String>>()?
10552                                .unwrap_or_default();
10553                        }
10554                        __FieldTag::__description => {
10555                            if !fields.insert(__FieldTag::__description) {
10556                                return std::result::Result::Err(A::Error::duplicate_field(
10557                                    "multiple values for description",
10558                                ));
10559                            }
10560                            result.description = map
10561                                .next_value::<std::option::Option<std::string::String>>()?
10562                                .unwrap_or_default();
10563                        }
10564                        __FieldTag::__deprecation_description => {
10565                            if !fields.insert(__FieldTag::__deprecation_description) {
10566                                return std::result::Result::Err(A::Error::duplicate_field(
10567                                    "multiple values for deprecation_description",
10568                                ));
10569                            }
10570                            result.deprecation_description = map
10571                                .next_value::<std::option::Option<std::string::String>>()?
10572                                .unwrap_or_default();
10573                        }
10574                        __FieldTag::Unknown(key) => {
10575                            let value = map.next_value::<serde_json::Value>()?;
10576                            result._unknown_fields.insert(key, value);
10577                        }
10578                    }
10579                }
10580                std::result::Result::Ok(result)
10581            }
10582        }
10583        deserializer.deserialize_any(Visitor)
10584    }
10585}
10586
10587#[doc(hidden)]
10588impl serde::ser::Serialize for DocumentationRule {
10589    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10590    where
10591        S: serde::ser::Serializer,
10592    {
10593        use serde::ser::SerializeMap;
10594        #[allow(unused_imports)]
10595        use std::option::Option::Some;
10596        let mut state = serializer.serialize_map(std::option::Option::None)?;
10597        if !self.selector.is_empty() {
10598            state.serialize_entry("selector", &self.selector)?;
10599        }
10600        if !self.description.is_empty() {
10601            state.serialize_entry("description", &self.description)?;
10602        }
10603        if !self.deprecation_description.is_empty() {
10604            state.serialize_entry("deprecationDescription", &self.deprecation_description)?;
10605        }
10606        if !self._unknown_fields.is_empty() {
10607            for (key, value) in self._unknown_fields.iter() {
10608                state.serialize_entry(key, &value)?;
10609            }
10610        }
10611        state.end()
10612    }
10613}
10614
10615impl std::fmt::Debug for DocumentationRule {
10616    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10617        let mut debug_struct = f.debug_struct("DocumentationRule");
10618        debug_struct.field("selector", &self.selector);
10619        debug_struct.field("description", &self.description);
10620        debug_struct.field("deprecation_description", &self.deprecation_description);
10621        if !self._unknown_fields.is_empty() {
10622            debug_struct.field("_unknown_fields", &self._unknown_fields);
10623        }
10624        debug_struct.finish()
10625    }
10626}
10627
10628/// Represents a documentation page. A page can contain subpages to represent
10629/// nested documentation set structure.
10630#[derive(Clone, Default, PartialEq)]
10631#[non_exhaustive]
10632pub struct Page {
10633    /// The name of the page. It will be used as an identity of the page to
10634    /// generate URI of the page, text of the link to this page in navigation,
10635    /// etc. The full page name (start from the root page name to this page
10636    /// concatenated with `.`) can be used as reference to the page in your
10637    /// documentation. For example:
10638    ///
10639    /// You can reference `Java` page using Markdown reference link syntax:
10640    /// `[Java][Tutorial.Java]`.
10641    pub name: std::string::String,
10642
10643    /// The Markdown content of the page. You can use ```(== include {path}
10644    /// ==)``` to include content from a Markdown file. The content can be used
10645    /// to produce the documentation page such as HTML format page.
10646    pub content: std::string::String,
10647
10648    /// Subpages of this page. The order of subpages specified here will be
10649    /// honored in the generated docset.
10650    pub subpages: std::vec::Vec<crate::model::Page>,
10651
10652    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10653}
10654
10655impl Page {
10656    pub fn new() -> Self {
10657        std::default::Default::default()
10658    }
10659
10660    /// Sets the value of [name][crate::model::Page::name].
10661    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10662        self.name = v.into();
10663        self
10664    }
10665
10666    /// Sets the value of [content][crate::model::Page::content].
10667    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10668        self.content = v.into();
10669        self
10670    }
10671
10672    /// Sets the value of [subpages][crate::model::Page::subpages].
10673    pub fn set_subpages<T, V>(mut self, v: T) -> Self
10674    where
10675        T: std::iter::IntoIterator<Item = V>,
10676        V: std::convert::Into<crate::model::Page>,
10677    {
10678        use std::iter::Iterator;
10679        self.subpages = v.into_iter().map(|i| i.into()).collect();
10680        self
10681    }
10682}
10683
10684impl wkt::message::Message for Page {
10685    fn typename() -> &'static str {
10686        "type.googleapis.com/google.api.Page"
10687    }
10688}
10689
10690#[doc(hidden)]
10691impl<'de> serde::de::Deserialize<'de> for Page {
10692    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10693    where
10694        D: serde::Deserializer<'de>,
10695    {
10696        #[allow(non_camel_case_types)]
10697        #[doc(hidden)]
10698        #[derive(PartialEq, Eq, Hash)]
10699        enum __FieldTag {
10700            __name,
10701            __content,
10702            __subpages,
10703            Unknown(std::string::String),
10704        }
10705        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10706            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10707            where
10708                D: serde::Deserializer<'de>,
10709            {
10710                struct Visitor;
10711                impl<'de> serde::de::Visitor<'de> for Visitor {
10712                    type Value = __FieldTag;
10713                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10714                        formatter.write_str("a field name for Page")
10715                    }
10716                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10717                    where
10718                        E: serde::de::Error,
10719                    {
10720                        use std::result::Result::Ok;
10721                        use std::string::ToString;
10722                        match value {
10723                            "name" => Ok(__FieldTag::__name),
10724                            "content" => Ok(__FieldTag::__content),
10725                            "subpages" => Ok(__FieldTag::__subpages),
10726                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10727                        }
10728                    }
10729                }
10730                deserializer.deserialize_identifier(Visitor)
10731            }
10732        }
10733        struct Visitor;
10734        impl<'de> serde::de::Visitor<'de> for Visitor {
10735            type Value = Page;
10736            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10737                formatter.write_str("struct Page")
10738            }
10739            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10740            where
10741                A: serde::de::MapAccess<'de>,
10742            {
10743                #[allow(unused_imports)]
10744                use serde::de::Error;
10745                use std::option::Option::Some;
10746                let mut fields = std::collections::HashSet::new();
10747                let mut result = Self::Value::new();
10748                while let Some(tag) = map.next_key::<__FieldTag>()? {
10749                    #[allow(clippy::match_single_binding)]
10750                    match tag {
10751                        __FieldTag::__name => {
10752                            if !fields.insert(__FieldTag::__name) {
10753                                return std::result::Result::Err(A::Error::duplicate_field(
10754                                    "multiple values for name",
10755                                ));
10756                            }
10757                            result.name = map
10758                                .next_value::<std::option::Option<std::string::String>>()?
10759                                .unwrap_or_default();
10760                        }
10761                        __FieldTag::__content => {
10762                            if !fields.insert(__FieldTag::__content) {
10763                                return std::result::Result::Err(A::Error::duplicate_field(
10764                                    "multiple values for content",
10765                                ));
10766                            }
10767                            result.content = map
10768                                .next_value::<std::option::Option<std::string::String>>()?
10769                                .unwrap_or_default();
10770                        }
10771                        __FieldTag::__subpages => {
10772                            if !fields.insert(__FieldTag::__subpages) {
10773                                return std::result::Result::Err(A::Error::duplicate_field(
10774                                    "multiple values for subpages",
10775                                ));
10776                            }
10777                            result.subpages = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Page>>>()?.unwrap_or_default();
10778                        }
10779                        __FieldTag::Unknown(key) => {
10780                            let value = map.next_value::<serde_json::Value>()?;
10781                            result._unknown_fields.insert(key, value);
10782                        }
10783                    }
10784                }
10785                std::result::Result::Ok(result)
10786            }
10787        }
10788        deserializer.deserialize_any(Visitor)
10789    }
10790}
10791
10792#[doc(hidden)]
10793impl serde::ser::Serialize for Page {
10794    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10795    where
10796        S: serde::ser::Serializer,
10797    {
10798        use serde::ser::SerializeMap;
10799        #[allow(unused_imports)]
10800        use std::option::Option::Some;
10801        let mut state = serializer.serialize_map(std::option::Option::None)?;
10802        if !self.name.is_empty() {
10803            state.serialize_entry("name", &self.name)?;
10804        }
10805        if !self.content.is_empty() {
10806            state.serialize_entry("content", &self.content)?;
10807        }
10808        if !self.subpages.is_empty() {
10809            state.serialize_entry("subpages", &self.subpages)?;
10810        }
10811        if !self._unknown_fields.is_empty() {
10812            for (key, value) in self._unknown_fields.iter() {
10813                state.serialize_entry(key, &value)?;
10814            }
10815        }
10816        state.end()
10817    }
10818}
10819
10820impl std::fmt::Debug for Page {
10821    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10822        let mut debug_struct = f.debug_struct("Page");
10823        debug_struct.field("name", &self.name);
10824        debug_struct.field("content", &self.content);
10825        debug_struct.field("subpages", &self.subpages);
10826        if !self._unknown_fields.is_empty() {
10827            debug_struct.field("_unknown_fields", &self._unknown_fields);
10828        }
10829        debug_struct.finish()
10830    }
10831}
10832
10833/// `Endpoint` describes a network address of a service that serves a set of
10834/// APIs. It is commonly known as a service endpoint. A service may expose
10835/// any number of service endpoints, and all service endpoints share the same
10836/// service definition, such as quota limits and monitoring metrics.
10837///
10838/// Example:
10839///
10840/// ```norust
10841/// type: google.api.Service
10842/// name: library-example.googleapis.com
10843/// endpoints:
10844///   # Declares network address `https://library-example.googleapis.com`
10845///   # for service `library-example.googleapis.com`. The `https` scheme
10846///   # is implicit for all service endpoints. Other schemes may be
10847///   # supported in the future.
10848/// - name: library-example.googleapis.com
10849///   allow_cors: false
10850/// - name: content-staging-library-example.googleapis.com
10851///   # Allows HTTP OPTIONS calls to be passed to the API frontend, for it
10852///   # to decide whether the subsequent cross-origin request is allowed
10853///   # to proceed.
10854///   allow_cors: true
10855/// ```
10856#[derive(Clone, Default, PartialEq)]
10857#[non_exhaustive]
10858pub struct Endpoint {
10859    /// The canonical name of this endpoint.
10860    pub name: std::string::String,
10861
10862    /// Aliases for this endpoint, these will be served by the same UrlMap as the
10863    /// parent endpoint, and will be provisioned in the GCP stack for the Regional
10864    /// Endpoints.
10865    pub aliases: std::vec::Vec<std::string::String>,
10866
10867    /// The specification of an Internet routable address of API frontend that will
10868    /// handle requests to this [API
10869    /// Endpoint](https://cloud.google.com/apis/design/glossary). It should be
10870    /// either a valid IPv4 address or a fully-qualified domain name. For example,
10871    /// "8.8.8.8" or "myservice.appspot.com".
10872    pub target: std::string::String,
10873
10874    /// Allowing
10875    /// [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka
10876    /// cross-domain traffic, would allow the backends served from this endpoint to
10877    /// receive and respond to HTTP OPTIONS requests. The response will be used by
10878    /// the browser to determine whether the subsequent cross-origin request is
10879    /// allowed to proceed.
10880    pub allow_cors: bool,
10881
10882    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10883}
10884
10885impl Endpoint {
10886    pub fn new() -> Self {
10887        std::default::Default::default()
10888    }
10889
10890    /// Sets the value of [name][crate::model::Endpoint::name].
10891    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10892        self.name = v.into();
10893        self
10894    }
10895
10896    /// Sets the value of [aliases][crate::model::Endpoint::aliases].
10897    pub fn set_aliases<T, V>(mut self, v: T) -> Self
10898    where
10899        T: std::iter::IntoIterator<Item = V>,
10900        V: std::convert::Into<std::string::String>,
10901    {
10902        use std::iter::Iterator;
10903        self.aliases = v.into_iter().map(|i| i.into()).collect();
10904        self
10905    }
10906
10907    /// Sets the value of [target][crate::model::Endpoint::target].
10908    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10909        self.target = v.into();
10910        self
10911    }
10912
10913    /// Sets the value of [allow_cors][crate::model::Endpoint::allow_cors].
10914    pub fn set_allow_cors<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10915        self.allow_cors = v.into();
10916        self
10917    }
10918}
10919
10920impl wkt::message::Message for Endpoint {
10921    fn typename() -> &'static str {
10922        "type.googleapis.com/google.api.Endpoint"
10923    }
10924}
10925
10926#[doc(hidden)]
10927impl<'de> serde::de::Deserialize<'de> for Endpoint {
10928    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10929    where
10930        D: serde::Deserializer<'de>,
10931    {
10932        #[allow(non_camel_case_types)]
10933        #[doc(hidden)]
10934        #[derive(PartialEq, Eq, Hash)]
10935        enum __FieldTag {
10936            __name,
10937            __aliases,
10938            __target,
10939            __allow_cors,
10940            Unknown(std::string::String),
10941        }
10942        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10943            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10944            where
10945                D: serde::Deserializer<'de>,
10946            {
10947                struct Visitor;
10948                impl<'de> serde::de::Visitor<'de> for Visitor {
10949                    type Value = __FieldTag;
10950                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10951                        formatter.write_str("a field name for Endpoint")
10952                    }
10953                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10954                    where
10955                        E: serde::de::Error,
10956                    {
10957                        use std::result::Result::Ok;
10958                        use std::string::ToString;
10959                        match value {
10960                            "name" => Ok(__FieldTag::__name),
10961                            "aliases" => Ok(__FieldTag::__aliases),
10962                            "target" => Ok(__FieldTag::__target),
10963                            "allowCors" => Ok(__FieldTag::__allow_cors),
10964                            "allow_cors" => Ok(__FieldTag::__allow_cors),
10965                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10966                        }
10967                    }
10968                }
10969                deserializer.deserialize_identifier(Visitor)
10970            }
10971        }
10972        struct Visitor;
10973        impl<'de> serde::de::Visitor<'de> for Visitor {
10974            type Value = Endpoint;
10975            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10976                formatter.write_str("struct Endpoint")
10977            }
10978            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10979            where
10980                A: serde::de::MapAccess<'de>,
10981            {
10982                #[allow(unused_imports)]
10983                use serde::de::Error;
10984                use std::option::Option::Some;
10985                let mut fields = std::collections::HashSet::new();
10986                let mut result = Self::Value::new();
10987                while let Some(tag) = map.next_key::<__FieldTag>()? {
10988                    #[allow(clippy::match_single_binding)]
10989                    match tag {
10990                        __FieldTag::__name => {
10991                            if !fields.insert(__FieldTag::__name) {
10992                                return std::result::Result::Err(A::Error::duplicate_field(
10993                                    "multiple values for name",
10994                                ));
10995                            }
10996                            result.name = map
10997                                .next_value::<std::option::Option<std::string::String>>()?
10998                                .unwrap_or_default();
10999                        }
11000                        __FieldTag::__aliases => {
11001                            if !fields.insert(__FieldTag::__aliases) {
11002                                return std::result::Result::Err(A::Error::duplicate_field(
11003                                    "multiple values for aliases",
11004                                ));
11005                            }
11006                            result.aliases = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
11007                        }
11008                        __FieldTag::__target => {
11009                            if !fields.insert(__FieldTag::__target) {
11010                                return std::result::Result::Err(A::Error::duplicate_field(
11011                                    "multiple values for target",
11012                                ));
11013                            }
11014                            result.target = map
11015                                .next_value::<std::option::Option<std::string::String>>()?
11016                                .unwrap_or_default();
11017                        }
11018                        __FieldTag::__allow_cors => {
11019                            if !fields.insert(__FieldTag::__allow_cors) {
11020                                return std::result::Result::Err(A::Error::duplicate_field(
11021                                    "multiple values for allow_cors",
11022                                ));
11023                            }
11024                            result.allow_cors = map
11025                                .next_value::<std::option::Option<bool>>()?
11026                                .unwrap_or_default();
11027                        }
11028                        __FieldTag::Unknown(key) => {
11029                            let value = map.next_value::<serde_json::Value>()?;
11030                            result._unknown_fields.insert(key, value);
11031                        }
11032                    }
11033                }
11034                std::result::Result::Ok(result)
11035            }
11036        }
11037        deserializer.deserialize_any(Visitor)
11038    }
11039}
11040
11041#[doc(hidden)]
11042impl serde::ser::Serialize for Endpoint {
11043    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11044    where
11045        S: serde::ser::Serializer,
11046    {
11047        use serde::ser::SerializeMap;
11048        #[allow(unused_imports)]
11049        use std::option::Option::Some;
11050        let mut state = serializer.serialize_map(std::option::Option::None)?;
11051        if !self.name.is_empty() {
11052            state.serialize_entry("name", &self.name)?;
11053        }
11054        if !self.aliases.is_empty() {
11055            state.serialize_entry("aliases", &self.aliases)?;
11056        }
11057        if !self.target.is_empty() {
11058            state.serialize_entry("target", &self.target)?;
11059        }
11060        if !wkt::internal::is_default(&self.allow_cors) {
11061            state.serialize_entry("allowCors", &self.allow_cors)?;
11062        }
11063        if !self._unknown_fields.is_empty() {
11064            for (key, value) in self._unknown_fields.iter() {
11065                state.serialize_entry(key, &value)?;
11066            }
11067        }
11068        state.end()
11069    }
11070}
11071
11072impl std::fmt::Debug for Endpoint {
11073    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11074        let mut debug_struct = f.debug_struct("Endpoint");
11075        debug_struct.field("name", &self.name);
11076        debug_struct.field("aliases", &self.aliases);
11077        debug_struct.field("target", &self.target);
11078        debug_struct.field("allow_cors", &self.allow_cors);
11079        if !self._unknown_fields.is_empty() {
11080            debug_struct.field("_unknown_fields", &self._unknown_fields);
11081        }
11082        debug_struct.finish()
11083    }
11084}
11085
11086/// Rich semantic information of an API field beyond basic typing.
11087#[derive(Clone, Default, PartialEq)]
11088#[non_exhaustive]
11089pub struct FieldInfo {
11090    /// The standard format of a field value. This does not explicitly configure
11091    /// any API consumer, just documents the API's format for the field it is
11092    /// applied to.
11093    pub format: crate::model::field_info::Format,
11094
11095    /// The type(s) that the annotated, generic field may represent.
11096    ///
11097    /// Currently, this must only be used on fields of type `google.protobuf.Any`.
11098    /// Supporting other generic types may be considered in the future.
11099    pub referenced_types: std::vec::Vec<crate::model::TypeReference>,
11100
11101    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11102}
11103
11104impl FieldInfo {
11105    pub fn new() -> Self {
11106        std::default::Default::default()
11107    }
11108
11109    /// Sets the value of [format][crate::model::FieldInfo::format].
11110    pub fn set_format<T: std::convert::Into<crate::model::field_info::Format>>(
11111        mut self,
11112        v: T,
11113    ) -> Self {
11114        self.format = v.into();
11115        self
11116    }
11117
11118    /// Sets the value of [referenced_types][crate::model::FieldInfo::referenced_types].
11119    pub fn set_referenced_types<T, V>(mut self, v: T) -> Self
11120    where
11121        T: std::iter::IntoIterator<Item = V>,
11122        V: std::convert::Into<crate::model::TypeReference>,
11123    {
11124        use std::iter::Iterator;
11125        self.referenced_types = v.into_iter().map(|i| i.into()).collect();
11126        self
11127    }
11128}
11129
11130impl wkt::message::Message for FieldInfo {
11131    fn typename() -> &'static str {
11132        "type.googleapis.com/google.api.FieldInfo"
11133    }
11134}
11135
11136#[doc(hidden)]
11137impl<'de> serde::de::Deserialize<'de> for FieldInfo {
11138    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11139    where
11140        D: serde::Deserializer<'de>,
11141    {
11142        #[allow(non_camel_case_types)]
11143        #[doc(hidden)]
11144        #[derive(PartialEq, Eq, Hash)]
11145        enum __FieldTag {
11146            __format,
11147            __referenced_types,
11148            Unknown(std::string::String),
11149        }
11150        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11151            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11152            where
11153                D: serde::Deserializer<'de>,
11154            {
11155                struct Visitor;
11156                impl<'de> serde::de::Visitor<'de> for Visitor {
11157                    type Value = __FieldTag;
11158                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11159                        formatter.write_str("a field name for FieldInfo")
11160                    }
11161                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11162                    where
11163                        E: serde::de::Error,
11164                    {
11165                        use std::result::Result::Ok;
11166                        use std::string::ToString;
11167                        match value {
11168                            "format" => Ok(__FieldTag::__format),
11169                            "referencedTypes" => Ok(__FieldTag::__referenced_types),
11170                            "referenced_types" => Ok(__FieldTag::__referenced_types),
11171                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11172                        }
11173                    }
11174                }
11175                deserializer.deserialize_identifier(Visitor)
11176            }
11177        }
11178        struct Visitor;
11179        impl<'de> serde::de::Visitor<'de> for Visitor {
11180            type Value = FieldInfo;
11181            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11182                formatter.write_str("struct FieldInfo")
11183            }
11184            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11185            where
11186                A: serde::de::MapAccess<'de>,
11187            {
11188                #[allow(unused_imports)]
11189                use serde::de::Error;
11190                use std::option::Option::Some;
11191                let mut fields = std::collections::HashSet::new();
11192                let mut result = Self::Value::new();
11193                while let Some(tag) = map.next_key::<__FieldTag>()? {
11194                    #[allow(clippy::match_single_binding)]
11195                    match tag {
11196                        __FieldTag::__format => {
11197                            if !fields.insert(__FieldTag::__format) {
11198                                return std::result::Result::Err(A::Error::duplicate_field(
11199                                    "multiple values for format",
11200                                ));
11201                            }
11202                            result.format = map.next_value::<std::option::Option<crate::model::field_info::Format>>()?.unwrap_or_default();
11203                        }
11204                        __FieldTag::__referenced_types => {
11205                            if !fields.insert(__FieldTag::__referenced_types) {
11206                                return std::result::Result::Err(A::Error::duplicate_field(
11207                                    "multiple values for referenced_types",
11208                                ));
11209                            }
11210                            result.referenced_types = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TypeReference>>>()?.unwrap_or_default();
11211                        }
11212                        __FieldTag::Unknown(key) => {
11213                            let value = map.next_value::<serde_json::Value>()?;
11214                            result._unknown_fields.insert(key, value);
11215                        }
11216                    }
11217                }
11218                std::result::Result::Ok(result)
11219            }
11220        }
11221        deserializer.deserialize_any(Visitor)
11222    }
11223}
11224
11225#[doc(hidden)]
11226impl serde::ser::Serialize for FieldInfo {
11227    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11228    where
11229        S: serde::ser::Serializer,
11230    {
11231        use serde::ser::SerializeMap;
11232        #[allow(unused_imports)]
11233        use std::option::Option::Some;
11234        let mut state = serializer.serialize_map(std::option::Option::None)?;
11235        if !wkt::internal::is_default(&self.format) {
11236            state.serialize_entry("format", &self.format)?;
11237        }
11238        if !self.referenced_types.is_empty() {
11239            state.serialize_entry("referencedTypes", &self.referenced_types)?;
11240        }
11241        if !self._unknown_fields.is_empty() {
11242            for (key, value) in self._unknown_fields.iter() {
11243                state.serialize_entry(key, &value)?;
11244            }
11245        }
11246        state.end()
11247    }
11248}
11249
11250impl std::fmt::Debug for FieldInfo {
11251    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11252        let mut debug_struct = f.debug_struct("FieldInfo");
11253        debug_struct.field("format", &self.format);
11254        debug_struct.field("referenced_types", &self.referenced_types);
11255        if !self._unknown_fields.is_empty() {
11256            debug_struct.field("_unknown_fields", &self._unknown_fields);
11257        }
11258        debug_struct.finish()
11259    }
11260}
11261
11262/// Defines additional types related to [FieldInfo].
11263pub mod field_info {
11264    #[allow(unused_imports)]
11265    use super::*;
11266
11267    /// The standard format of a field value. The supported formats are all backed
11268    /// by either an RFC defined by the IETF or a Google-defined AIP.
11269    ///
11270    /// # Working with unknown values
11271    ///
11272    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11273    /// additional enum variants at any time. Adding new variants is not considered
11274    /// a breaking change. Applications should write their code in anticipation of:
11275    ///
11276    /// - New values appearing in future releases of the client library, **and**
11277    /// - New values received dynamically, without application changes.
11278    ///
11279    /// Please consult the [Working with enums] section in the user guide for some
11280    /// guidelines.
11281    ///
11282    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
11283    #[derive(Clone, Debug, PartialEq)]
11284    #[non_exhaustive]
11285    pub enum Format {
11286        /// Default, unspecified value.
11287        Unspecified,
11288        /// Universally Unique Identifier, version 4, value as defined by
11289        /// <https://datatracker.ietf.org/doc/html/rfc4122>. The value may be
11290        /// normalized to entirely lowercase letters. For example, the value
11291        /// `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to
11292        /// `f47ac10b-58cc-0372-8567-0e02b2c3d479`.
11293        Uuid4,
11294        /// Internet Protocol v4 value as defined by [RFC
11295        /// 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be
11296        /// condensed, with leading zeros in each octet stripped. For example,
11297        /// `001.022.233.040` would be condensed to `1.22.233.40`.
11298        Ipv4,
11299        /// Internet Protocol v6 value as defined by [RFC
11300        /// 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be
11301        /// normalized to entirely lowercase letters with zeros compressed, following
11302        /// [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example,
11303        /// the value `2001:0DB8:0::0` would be normalized to `2001:db8::`.
11304        Ipv6,
11305        /// An IP address in either v4 or v6 format as described by the individual
11306        /// values defined herein. See the comments on the IPV4 and IPV6 types for
11307        /// allowed normalizations of each.
11308        Ipv4OrIpv6,
11309        /// If set, the enum was initialized with an unknown value.
11310        ///
11311        /// Applications can examine the value using [Format::value] or
11312        /// [Format::name].
11313        UnknownValue(format::UnknownValue),
11314    }
11315
11316    #[doc(hidden)]
11317    pub mod format {
11318        #[allow(unused_imports)]
11319        use super::*;
11320        #[derive(Clone, Debug, PartialEq)]
11321        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11322    }
11323
11324    impl Format {
11325        /// Gets the enum value.
11326        ///
11327        /// Returns `None` if the enum contains an unknown value deserialized from
11328        /// the string representation of enums.
11329        pub fn value(&self) -> std::option::Option<i32> {
11330            match self {
11331                Self::Unspecified => std::option::Option::Some(0),
11332                Self::Uuid4 => std::option::Option::Some(1),
11333                Self::Ipv4 => std::option::Option::Some(2),
11334                Self::Ipv6 => std::option::Option::Some(3),
11335                Self::Ipv4OrIpv6 => std::option::Option::Some(4),
11336                Self::UnknownValue(u) => u.0.value(),
11337            }
11338        }
11339
11340        /// Gets the enum value as a string.
11341        ///
11342        /// Returns `None` if the enum contains an unknown value deserialized from
11343        /// the integer representation of enums.
11344        pub fn name(&self) -> std::option::Option<&str> {
11345            match self {
11346                Self::Unspecified => std::option::Option::Some("FORMAT_UNSPECIFIED"),
11347                Self::Uuid4 => std::option::Option::Some("UUID4"),
11348                Self::Ipv4 => std::option::Option::Some("IPV4"),
11349                Self::Ipv6 => std::option::Option::Some("IPV6"),
11350                Self::Ipv4OrIpv6 => std::option::Option::Some("IPV4_OR_IPV6"),
11351                Self::UnknownValue(u) => u.0.name(),
11352            }
11353        }
11354    }
11355
11356    impl std::default::Default for Format {
11357        fn default() -> Self {
11358            use std::convert::From;
11359            Self::from(0)
11360        }
11361    }
11362
11363    impl std::fmt::Display for Format {
11364        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11365            wkt::internal::display_enum(f, self.name(), self.value())
11366        }
11367    }
11368
11369    impl std::convert::From<i32> for Format {
11370        fn from(value: i32) -> Self {
11371            match value {
11372                0 => Self::Unspecified,
11373                1 => Self::Uuid4,
11374                2 => Self::Ipv4,
11375                3 => Self::Ipv6,
11376                4 => Self::Ipv4OrIpv6,
11377                _ => Self::UnknownValue(format::UnknownValue(
11378                    wkt::internal::UnknownEnumValue::Integer(value),
11379                )),
11380            }
11381        }
11382    }
11383
11384    impl std::convert::From<&str> for Format {
11385        fn from(value: &str) -> Self {
11386            use std::string::ToString;
11387            match value {
11388                "FORMAT_UNSPECIFIED" => Self::Unspecified,
11389                "UUID4" => Self::Uuid4,
11390                "IPV4" => Self::Ipv4,
11391                "IPV6" => Self::Ipv6,
11392                "IPV4_OR_IPV6" => Self::Ipv4OrIpv6,
11393                _ => Self::UnknownValue(format::UnknownValue(
11394                    wkt::internal::UnknownEnumValue::String(value.to_string()),
11395                )),
11396            }
11397        }
11398    }
11399
11400    impl serde::ser::Serialize for Format {
11401        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11402        where
11403            S: serde::Serializer,
11404        {
11405            match self {
11406                Self::Unspecified => serializer.serialize_i32(0),
11407                Self::Uuid4 => serializer.serialize_i32(1),
11408                Self::Ipv4 => serializer.serialize_i32(2),
11409                Self::Ipv6 => serializer.serialize_i32(3),
11410                Self::Ipv4OrIpv6 => serializer.serialize_i32(4),
11411                Self::UnknownValue(u) => u.0.serialize(serializer),
11412            }
11413        }
11414    }
11415
11416    impl<'de> serde::de::Deserialize<'de> for Format {
11417        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11418        where
11419            D: serde::Deserializer<'de>,
11420        {
11421            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Format>::new(
11422                ".google.api.FieldInfo.Format",
11423            ))
11424        }
11425    }
11426}
11427
11428/// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo].
11429///
11430/// [google.api.FieldInfo]: crate::model::FieldInfo
11431#[derive(Clone, Default, PartialEq)]
11432#[non_exhaustive]
11433pub struct TypeReference {
11434    /// The name of the type that the annotated, generic field may represent.
11435    /// If the type is in the same protobuf package, the value can be the simple
11436    /// message name e.g., `"MyMessage"`. Otherwise, the value must be the
11437    /// fully-qualified message name e.g., `"google.library.v1.Book"`.
11438    ///
11439    /// If the type(s) are unknown to the service (e.g. the field accepts generic
11440    /// user input), use the wildcard `"*"` to denote this behavior.
11441    ///
11442    /// See [AIP-202](https://google.aip.dev/202#type-references) for more details.
11443    pub type_name: std::string::String,
11444
11445    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11446}
11447
11448impl TypeReference {
11449    pub fn new() -> Self {
11450        std::default::Default::default()
11451    }
11452
11453    /// Sets the value of [type_name][crate::model::TypeReference::type_name].
11454    pub fn set_type_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11455        self.type_name = v.into();
11456        self
11457    }
11458}
11459
11460impl wkt::message::Message for TypeReference {
11461    fn typename() -> &'static str {
11462        "type.googleapis.com/google.api.TypeReference"
11463    }
11464}
11465
11466#[doc(hidden)]
11467impl<'de> serde::de::Deserialize<'de> for TypeReference {
11468    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11469    where
11470        D: serde::Deserializer<'de>,
11471    {
11472        #[allow(non_camel_case_types)]
11473        #[doc(hidden)]
11474        #[derive(PartialEq, Eq, Hash)]
11475        enum __FieldTag {
11476            __type_name,
11477            Unknown(std::string::String),
11478        }
11479        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11480            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11481            where
11482                D: serde::Deserializer<'de>,
11483            {
11484                struct Visitor;
11485                impl<'de> serde::de::Visitor<'de> for Visitor {
11486                    type Value = __FieldTag;
11487                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11488                        formatter.write_str("a field name for TypeReference")
11489                    }
11490                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11491                    where
11492                        E: serde::de::Error,
11493                    {
11494                        use std::result::Result::Ok;
11495                        use std::string::ToString;
11496                        match value {
11497                            "typeName" => Ok(__FieldTag::__type_name),
11498                            "type_name" => Ok(__FieldTag::__type_name),
11499                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11500                        }
11501                    }
11502                }
11503                deserializer.deserialize_identifier(Visitor)
11504            }
11505        }
11506        struct Visitor;
11507        impl<'de> serde::de::Visitor<'de> for Visitor {
11508            type Value = TypeReference;
11509            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11510                formatter.write_str("struct TypeReference")
11511            }
11512            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11513            where
11514                A: serde::de::MapAccess<'de>,
11515            {
11516                #[allow(unused_imports)]
11517                use serde::de::Error;
11518                use std::option::Option::Some;
11519                let mut fields = std::collections::HashSet::new();
11520                let mut result = Self::Value::new();
11521                while let Some(tag) = map.next_key::<__FieldTag>()? {
11522                    #[allow(clippy::match_single_binding)]
11523                    match tag {
11524                        __FieldTag::__type_name => {
11525                            if !fields.insert(__FieldTag::__type_name) {
11526                                return std::result::Result::Err(A::Error::duplicate_field(
11527                                    "multiple values for type_name",
11528                                ));
11529                            }
11530                            result.type_name = map
11531                                .next_value::<std::option::Option<std::string::String>>()?
11532                                .unwrap_or_default();
11533                        }
11534                        __FieldTag::Unknown(key) => {
11535                            let value = map.next_value::<serde_json::Value>()?;
11536                            result._unknown_fields.insert(key, value);
11537                        }
11538                    }
11539                }
11540                std::result::Result::Ok(result)
11541            }
11542        }
11543        deserializer.deserialize_any(Visitor)
11544    }
11545}
11546
11547#[doc(hidden)]
11548impl serde::ser::Serialize for TypeReference {
11549    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11550    where
11551        S: serde::ser::Serializer,
11552    {
11553        use serde::ser::SerializeMap;
11554        #[allow(unused_imports)]
11555        use std::option::Option::Some;
11556        let mut state = serializer.serialize_map(std::option::Option::None)?;
11557        if !self.type_name.is_empty() {
11558            state.serialize_entry("typeName", &self.type_name)?;
11559        }
11560        if !self._unknown_fields.is_empty() {
11561            for (key, value) in self._unknown_fields.iter() {
11562                state.serialize_entry(key, &value)?;
11563            }
11564        }
11565        state.end()
11566    }
11567}
11568
11569impl std::fmt::Debug for TypeReference {
11570    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11571        let mut debug_struct = f.debug_struct("TypeReference");
11572        debug_struct.field("type_name", &self.type_name);
11573        if !self._unknown_fields.is_empty() {
11574            debug_struct.field("_unknown_fields", &self._unknown_fields);
11575        }
11576        debug_struct.finish()
11577    }
11578}
11579
11580/// Defines the HTTP configuration for an API service. It contains a list of
11581/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
11582/// to one or more HTTP REST API methods.
11583///
11584/// [google.api.HttpRule]: crate::model::HttpRule
11585#[derive(Clone, Default, PartialEq)]
11586#[non_exhaustive]
11587pub struct Http {
11588    /// A list of HTTP configuration rules that apply to individual API methods.
11589    ///
11590    /// **NOTE:** All service configuration rules follow "last one wins" order.
11591    pub rules: std::vec::Vec<crate::model::HttpRule>,
11592
11593    /// When set to true, URL path parameters will be fully URI-decoded except in
11594    /// cases of single segment matches in reserved expansion, where "%2F" will be
11595    /// left encoded.
11596    ///
11597    /// The default behavior is to not decode RFC 6570 reserved characters in multi
11598    /// segment matches.
11599    pub fully_decode_reserved_expansion: bool,
11600
11601    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11602}
11603
11604impl Http {
11605    pub fn new() -> Self {
11606        std::default::Default::default()
11607    }
11608
11609    /// Sets the value of [rules][crate::model::Http::rules].
11610    pub fn set_rules<T, V>(mut self, v: T) -> Self
11611    where
11612        T: std::iter::IntoIterator<Item = V>,
11613        V: std::convert::Into<crate::model::HttpRule>,
11614    {
11615        use std::iter::Iterator;
11616        self.rules = v.into_iter().map(|i| i.into()).collect();
11617        self
11618    }
11619
11620    /// Sets the value of [fully_decode_reserved_expansion][crate::model::Http::fully_decode_reserved_expansion].
11621    pub fn set_fully_decode_reserved_expansion<T: std::convert::Into<bool>>(
11622        mut self,
11623        v: T,
11624    ) -> Self {
11625        self.fully_decode_reserved_expansion = v.into();
11626        self
11627    }
11628}
11629
11630impl wkt::message::Message for Http {
11631    fn typename() -> &'static str {
11632        "type.googleapis.com/google.api.Http"
11633    }
11634}
11635
11636#[doc(hidden)]
11637impl<'de> serde::de::Deserialize<'de> for Http {
11638    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11639    where
11640        D: serde::Deserializer<'de>,
11641    {
11642        #[allow(non_camel_case_types)]
11643        #[doc(hidden)]
11644        #[derive(PartialEq, Eq, Hash)]
11645        enum __FieldTag {
11646            __rules,
11647            __fully_decode_reserved_expansion,
11648            Unknown(std::string::String),
11649        }
11650        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11651            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11652            where
11653                D: serde::Deserializer<'de>,
11654            {
11655                struct Visitor;
11656                impl<'de> serde::de::Visitor<'de> for Visitor {
11657                    type Value = __FieldTag;
11658                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11659                        formatter.write_str("a field name for Http")
11660                    }
11661                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11662                    where
11663                        E: serde::de::Error,
11664                    {
11665                        use std::result::Result::Ok;
11666                        use std::string::ToString;
11667                        match value {
11668                            "rules" => Ok(__FieldTag::__rules),
11669                            "fullyDecodeReservedExpansion" => {
11670                                Ok(__FieldTag::__fully_decode_reserved_expansion)
11671                            }
11672                            "fully_decode_reserved_expansion" => {
11673                                Ok(__FieldTag::__fully_decode_reserved_expansion)
11674                            }
11675                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11676                        }
11677                    }
11678                }
11679                deserializer.deserialize_identifier(Visitor)
11680            }
11681        }
11682        struct Visitor;
11683        impl<'de> serde::de::Visitor<'de> for Visitor {
11684            type Value = Http;
11685            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11686                formatter.write_str("struct Http")
11687            }
11688            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11689            where
11690                A: serde::de::MapAccess<'de>,
11691            {
11692                #[allow(unused_imports)]
11693                use serde::de::Error;
11694                use std::option::Option::Some;
11695                let mut fields = std::collections::HashSet::new();
11696                let mut result = Self::Value::new();
11697                while let Some(tag) = map.next_key::<__FieldTag>()? {
11698                    #[allow(clippy::match_single_binding)]
11699                    match tag {
11700                        __FieldTag::__rules => {
11701                            if !fields.insert(__FieldTag::__rules) {
11702                                return std::result::Result::Err(A::Error::duplicate_field(
11703                                    "multiple values for rules",
11704                                ));
11705                            }
11706                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpRule>>>()?.unwrap_or_default();
11707                        }
11708                        __FieldTag::__fully_decode_reserved_expansion => {
11709                            if !fields.insert(__FieldTag::__fully_decode_reserved_expansion) {
11710                                return std::result::Result::Err(A::Error::duplicate_field(
11711                                    "multiple values for fully_decode_reserved_expansion",
11712                                ));
11713                            }
11714                            result.fully_decode_reserved_expansion = map
11715                                .next_value::<std::option::Option<bool>>()?
11716                                .unwrap_or_default();
11717                        }
11718                        __FieldTag::Unknown(key) => {
11719                            let value = map.next_value::<serde_json::Value>()?;
11720                            result._unknown_fields.insert(key, value);
11721                        }
11722                    }
11723                }
11724                std::result::Result::Ok(result)
11725            }
11726        }
11727        deserializer.deserialize_any(Visitor)
11728    }
11729}
11730
11731#[doc(hidden)]
11732impl serde::ser::Serialize for Http {
11733    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11734    where
11735        S: serde::ser::Serializer,
11736    {
11737        use serde::ser::SerializeMap;
11738        #[allow(unused_imports)]
11739        use std::option::Option::Some;
11740        let mut state = serializer.serialize_map(std::option::Option::None)?;
11741        if !self.rules.is_empty() {
11742            state.serialize_entry("rules", &self.rules)?;
11743        }
11744        if !wkt::internal::is_default(&self.fully_decode_reserved_expansion) {
11745            state.serialize_entry(
11746                "fullyDecodeReservedExpansion",
11747                &self.fully_decode_reserved_expansion,
11748            )?;
11749        }
11750        if !self._unknown_fields.is_empty() {
11751            for (key, value) in self._unknown_fields.iter() {
11752                state.serialize_entry(key, &value)?;
11753            }
11754        }
11755        state.end()
11756    }
11757}
11758
11759impl std::fmt::Debug for Http {
11760    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11761        let mut debug_struct = f.debug_struct("Http");
11762        debug_struct.field("rules", &self.rules);
11763        debug_struct.field(
11764            "fully_decode_reserved_expansion",
11765            &self.fully_decode_reserved_expansion,
11766        );
11767        if !self._unknown_fields.is_empty() {
11768            debug_struct.field("_unknown_fields", &self._unknown_fields);
11769        }
11770        debug_struct.finish()
11771    }
11772}
11773
11774/// gRPC Transcoding
11775///
11776/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
11777/// more HTTP REST endpoints. It allows developers to build a single API service
11778/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
11779/// APIs](https://github.com/googleapis/googleapis),
11780/// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC
11781/// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),
11782/// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature
11783/// and use it for large scale production services.
11784///
11785/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
11786/// how different portions of the gRPC request message are mapped to the URL
11787/// path, URL query parameters, and HTTP request body. It also controls how the
11788/// gRPC response message is mapped to the HTTP response body. `HttpRule` is
11789/// typically specified as an `google.api.http` annotation on the gRPC method.
11790///
11791/// Each mapping specifies a URL path template and an HTTP method. The path
11792/// template may refer to one or more fields in the gRPC request message, as long
11793/// as each field is a non-repeated field with a primitive (non-message) type.
11794/// The path template controls how fields of the request message are mapped to
11795/// the URL path.
11796///
11797/// Example:
11798///
11799/// ```norust
11800/// service Messaging {
11801///   rpc GetMessage(GetMessageRequest) returns (Message) {
11802///     option (google.api.http) = {
11803///         get: "/v1/{name=messages/*}"
11804///     };
11805///   }
11806/// }
11807/// message GetMessageRequest {
11808///   string name = 1; // Mapped to URL path.
11809/// }
11810/// message Message {
11811///   string text = 1; // The resource content.
11812/// }
11813/// ```
11814///
11815/// This enables an HTTP REST to gRPC mapping as below:
11816///
11817/// - HTTP: `GET /v1/messages/123456`
11818/// - gRPC: `GetMessage(name: "messages/123456")`
11819///
11820/// Any fields in the request message which are not bound by the path template
11821/// automatically become HTTP query parameters if there is no HTTP request body.
11822/// For example:
11823///
11824/// ```norust
11825/// service Messaging {
11826///   rpc GetMessage(GetMessageRequest) returns (Message) {
11827///     option (google.api.http) = {
11828///         get:"/v1/messages/{message_id}"
11829///     };
11830///   }
11831/// }
11832/// message GetMessageRequest {
11833///   message SubMessage {
11834///     string subfield = 1;
11835///   }
11836///   string message_id = 1; // Mapped to URL path.
11837///   int64 revision = 2;    // Mapped to URL query parameter `revision`.
11838///   SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`.
11839/// }
11840/// ```
11841///
11842/// This enables a HTTP JSON to RPC mapping as below:
11843///
11844/// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo`
11845/// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub:
11846///   SubMessage(subfield: "foo"))`
11847///
11848/// Note that fields which are mapped to URL query parameters must have a
11849/// primitive type or a repeated primitive type or a non-repeated message type.
11850/// In the case of a repeated type, the parameter can be repeated in the URL
11851/// as `...?param=A&param=B`. In the case of a message type, each field of the
11852/// message is mapped to a separate parameter, such as
11853/// `...?foo.a=A&foo.b=B&foo.c=C`.
11854///
11855/// For HTTP methods that allow a request body, the `body` field
11856/// specifies the mapping. Consider a REST update method on the
11857/// message resource collection:
11858///
11859/// ```norust
11860/// service Messaging {
11861///   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
11862///     option (google.api.http) = {
11863///       patch: "/v1/messages/{message_id}"
11864///       body: "message"
11865///     };
11866///   }
11867/// }
11868/// message UpdateMessageRequest {
11869///   string message_id = 1; // mapped to the URL
11870///   Message message = 2;   // mapped to the body
11871/// }
11872/// ```
11873///
11874/// The following HTTP JSON to RPC mapping is enabled, where the
11875/// representation of the JSON in the request body is determined by
11876/// protos JSON encoding:
11877///
11878/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
11879/// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
11880///
11881/// The special name `*` can be used in the body mapping to define that
11882/// every field not bound by the path template should be mapped to the
11883/// request body.  This enables the following alternative definition of
11884/// the update method:
11885///
11886/// ```norust
11887/// service Messaging {
11888///   rpc UpdateMessage(Message) returns (Message) {
11889///     option (google.api.http) = {
11890///       patch: "/v1/messages/{message_id}"
11891///       body: "*"
11892///     };
11893///   }
11894/// }
11895/// message Message {
11896///   string message_id = 1;
11897///   string text = 2;
11898/// }
11899/// ```
11900///
11901/// The following HTTP JSON to RPC mapping is enabled:
11902///
11903/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
11904/// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")`
11905///
11906/// Note that when using `*` in the body mapping, it is not possible to
11907/// have HTTP parameters, as all fields not bound by the path end in
11908/// the body. This makes this option more rarely used in practice when
11909/// defining REST APIs. The common usage of `*` is in custom methods
11910/// which don't use the URL at all for transferring data.
11911///
11912/// It is possible to define multiple HTTP methods for one RPC by using
11913/// the `additional_bindings` option. Example:
11914///
11915/// ```norust
11916/// service Messaging {
11917///   rpc GetMessage(GetMessageRequest) returns (Message) {
11918///     option (google.api.http) = {
11919///       get: "/v1/messages/{message_id}"
11920///       additional_bindings {
11921///         get: "/v1/users/{user_id}/messages/{message_id}"
11922///       }
11923///     };
11924///   }
11925/// }
11926/// message GetMessageRequest {
11927///   string message_id = 1;
11928///   string user_id = 2;
11929/// }
11930/// ```
11931///
11932/// This enables the following two alternative HTTP JSON to RPC mappings:
11933///
11934/// - HTTP: `GET /v1/messages/123456`
11935///
11936/// - gRPC: `GetMessage(message_id: "123456")`
11937///
11938/// - HTTP: `GET /v1/users/me/messages/123456`
11939///
11940/// - gRPC: `GetMessage(user_id: "me" message_id: "123456")`
11941///
11942///
11943/// Rules for HTTP mapping
11944///
11945/// 1. Leaf request fields (recursive expansion nested messages in the request
11946///    message) are classified into three categories:
11947///    - Fields referred by the path template. They are passed via the URL path.
11948///    - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
11949///      are passed via the HTTP
11950///      request body.
11951///    - All other fields are passed via the URL query parameters, and the
11952///      parameter name is the field path in the request message. A repeated
11953///      field can be represented as multiple query parameters under the same
11954///      name.
11955/// 1. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
11956///    query parameter, all fields
11957///    are passed via URL path and HTTP request body.
11958/// 1. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
11959///    request body, all
11960///    fields are passed via URL path and URL query parameters.
11961///
11962/// Path template syntax
11963///
11964/// ```norust
11965/// Template = "/" Segments [ Verb ] ;
11966/// Segments = Segment { "/" Segment } ;
11967/// Segment  = "*" | "**" | LITERAL | Variable ;
11968/// Variable = "{" FieldPath [ "=" Segments ] "}" ;
11969/// FieldPath = IDENT { "." IDENT } ;
11970/// Verb     = ":" LITERAL ;
11971/// ```
11972///
11973/// The syntax `*` matches a single URL path segment. The syntax `**` matches
11974/// zero or more URL path segments, which must be the last part of the URL path
11975/// except the `Verb`.
11976///
11977/// The syntax `Variable` matches part of the URL path as specified by its
11978/// template. A variable template must not contain other variables. If a variable
11979/// matches a single path segment, its template may be omitted, e.g. `{var}`
11980/// is equivalent to `{var=*}`.
11981///
11982/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
11983/// contains any reserved character, such characters should be percent-encoded
11984/// before the matching.
11985///
11986/// If a variable contains exactly one path segment, such as `"{var}"` or
11987/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
11988/// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The
11989/// server side does the reverse decoding. Such variables show up in the
11990/// [Discovery
11991/// Document](https://developers.google.com/discovery/v1/reference/apis) as
11992/// `{var}`.
11993///
11994/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
11995/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
11996/// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.
11997/// The server side does the reverse decoding, except "%2F" and "%2f" are left
11998/// unchanged. Such variables show up in the
11999/// [Discovery
12000/// Document](https://developers.google.com/discovery/v1/reference/apis) as
12001/// `{+var}`.
12002///
12003/// Using gRPC API Service Configuration
12004///
12005/// gRPC API Service Configuration (service config) is a configuration language
12006/// for configuring a gRPC service to become a user-facing product. The
12007/// service config is simply the YAML representation of the `google.api.Service`
12008/// proto message.
12009///
12010/// As an alternative to annotating your proto file, you can configure gRPC
12011/// transcoding in your service config YAML files. You do this by specifying a
12012/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
12013/// effect as the proto annotation. This can be particularly useful if you
12014/// have a proto that is reused in multiple services. Note that any transcoding
12015/// specified in the service config will override any matching transcoding
12016/// configuration in the proto.
12017///
12018/// The following example selects a gRPC method and applies an `HttpRule` to it:
12019///
12020/// ```norust
12021/// http:
12022///   rules:
12023///     - selector: example.v1.Messaging.GetMessage
12024///       get: /v1/messages/{message_id}/{sub.subfield}
12025/// ```
12026///
12027/// Special notes
12028///
12029/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
12030/// proto to JSON conversion must follow the [proto3
12031/// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).
12032///
12033/// While the single segment variable follows the semantics of
12034/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String
12035/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
12036/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
12037/// does not expand special characters like `?` and `#`, which would lead
12038/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
12039/// for multi segment variables.
12040///
12041/// The path variables **must not** refer to any repeated or mapped field,
12042/// because client libraries are not capable of handling such variable expansion.
12043///
12044/// The path variables **must not** capture the leading "/" character. The reason
12045/// is that the most common use case "{var}" does not capture the leading "/"
12046/// character. For consistency, all path variables must share the same behavior.
12047///
12048/// Repeated message fields must not be mapped to URL query parameters, because
12049/// no client library can support such complicated mapping.
12050///
12051/// If an API needs to use a JSON array for request or response body, it can map
12052/// the request or response body to a repeated field. However, some gRPC
12053/// Transcoding implementations may not support this feature.
12054///
12055/// [google.api.HttpRule.body]: crate::model::HttpRule::body
12056#[derive(Clone, Default, PartialEq)]
12057#[non_exhaustive]
12058pub struct HttpRule {
12059    /// Selects a method to which this rule applies.
12060    ///
12061    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
12062    /// details.
12063    ///
12064    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
12065    pub selector: std::string::String,
12066
12067    /// The name of the request field whose value is mapped to the HTTP request
12068    /// body, or `*` for mapping all request fields not captured by the path
12069    /// pattern to the HTTP body, or omitted for not having any HTTP request body.
12070    ///
12071    /// NOTE: the referred field must be present at the top-level of the request
12072    /// message type.
12073    pub body: std::string::String,
12074
12075    /// Optional. The name of the response field whose value is mapped to the HTTP
12076    /// response body. When omitted, the entire response message will be used
12077    /// as the HTTP response body.
12078    ///
12079    /// NOTE: The referred field must be present at the top-level of the response
12080    /// message type.
12081    pub response_body: std::string::String,
12082
12083    /// Additional HTTP bindings for the selector. Nested bindings must
12084    /// not contain an `additional_bindings` field themselves (that is,
12085    /// the nesting may only be one level deep).
12086    pub additional_bindings: std::vec::Vec<crate::model::HttpRule>,
12087
12088    /// Determines the URL pattern is matched by this rules. This pattern can be
12089    /// used with any of the {get|put|post|delete|patch} methods. A custom method
12090    /// can be defined using the 'custom' field.
12091    pub pattern: std::option::Option<crate::model::http_rule::Pattern>,
12092
12093    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12094}
12095
12096impl HttpRule {
12097    pub fn new() -> Self {
12098        std::default::Default::default()
12099    }
12100
12101    /// Sets the value of [selector][crate::model::HttpRule::selector].
12102    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12103        self.selector = v.into();
12104        self
12105    }
12106
12107    /// Sets the value of [body][crate::model::HttpRule::body].
12108    pub fn set_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12109        self.body = v.into();
12110        self
12111    }
12112
12113    /// Sets the value of [response_body][crate::model::HttpRule::response_body].
12114    pub fn set_response_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12115        self.response_body = v.into();
12116        self
12117    }
12118
12119    /// Sets the value of [additional_bindings][crate::model::HttpRule::additional_bindings].
12120    pub fn set_additional_bindings<T, V>(mut self, v: T) -> Self
12121    where
12122        T: std::iter::IntoIterator<Item = V>,
12123        V: std::convert::Into<crate::model::HttpRule>,
12124    {
12125        use std::iter::Iterator;
12126        self.additional_bindings = v.into_iter().map(|i| i.into()).collect();
12127        self
12128    }
12129
12130    /// Sets the value of [pattern][crate::model::HttpRule::pattern].
12131    ///
12132    /// Note that all the setters affecting `pattern` are mutually
12133    /// exclusive.
12134    pub fn set_pattern<
12135        T: std::convert::Into<std::option::Option<crate::model::http_rule::Pattern>>,
12136    >(
12137        mut self,
12138        v: T,
12139    ) -> Self {
12140        self.pattern = v.into();
12141        self
12142    }
12143
12144    /// The value of [pattern][crate::model::HttpRule::pattern]
12145    /// if it holds a `Get`, `None` if the field is not set or
12146    /// holds a different branch.
12147    pub fn get(&self) -> std::option::Option<&std::string::String> {
12148        #[allow(unreachable_patterns)]
12149        self.pattern.as_ref().and_then(|v| match v {
12150            crate::model::http_rule::Pattern::Get(v) => std::option::Option::Some(v),
12151            _ => std::option::Option::None,
12152        })
12153    }
12154
12155    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12156    /// to hold a `Get`.
12157    ///
12158    /// Note that all the setters affecting `pattern` are
12159    /// mutually exclusive.
12160    pub fn set_get<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12161        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Get(v.into()));
12162        self
12163    }
12164
12165    /// The value of [pattern][crate::model::HttpRule::pattern]
12166    /// if it holds a `Put`, `None` if the field is not set or
12167    /// holds a different branch.
12168    pub fn put(&self) -> std::option::Option<&std::string::String> {
12169        #[allow(unreachable_patterns)]
12170        self.pattern.as_ref().and_then(|v| match v {
12171            crate::model::http_rule::Pattern::Put(v) => std::option::Option::Some(v),
12172            _ => std::option::Option::None,
12173        })
12174    }
12175
12176    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12177    /// to hold a `Put`.
12178    ///
12179    /// Note that all the setters affecting `pattern` are
12180    /// mutually exclusive.
12181    pub fn set_put<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12182        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Put(v.into()));
12183        self
12184    }
12185
12186    /// The value of [pattern][crate::model::HttpRule::pattern]
12187    /// if it holds a `Post`, `None` if the field is not set or
12188    /// holds a different branch.
12189    pub fn post(&self) -> std::option::Option<&std::string::String> {
12190        #[allow(unreachable_patterns)]
12191        self.pattern.as_ref().and_then(|v| match v {
12192            crate::model::http_rule::Pattern::Post(v) => std::option::Option::Some(v),
12193            _ => std::option::Option::None,
12194        })
12195    }
12196
12197    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12198    /// to hold a `Post`.
12199    ///
12200    /// Note that all the setters affecting `pattern` are
12201    /// mutually exclusive.
12202    pub fn set_post<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12203        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Post(v.into()));
12204        self
12205    }
12206
12207    /// The value of [pattern][crate::model::HttpRule::pattern]
12208    /// if it holds a `Delete`, `None` if the field is not set or
12209    /// holds a different branch.
12210    pub fn delete(&self) -> std::option::Option<&std::string::String> {
12211        #[allow(unreachable_patterns)]
12212        self.pattern.as_ref().and_then(|v| match v {
12213            crate::model::http_rule::Pattern::Delete(v) => std::option::Option::Some(v),
12214            _ => std::option::Option::None,
12215        })
12216    }
12217
12218    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12219    /// to hold a `Delete`.
12220    ///
12221    /// Note that all the setters affecting `pattern` are
12222    /// mutually exclusive.
12223    pub fn set_delete<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12224        self.pattern =
12225            std::option::Option::Some(crate::model::http_rule::Pattern::Delete(v.into()));
12226        self
12227    }
12228
12229    /// The value of [pattern][crate::model::HttpRule::pattern]
12230    /// if it holds a `Patch`, `None` if the field is not set or
12231    /// holds a different branch.
12232    pub fn patch(&self) -> std::option::Option<&std::string::String> {
12233        #[allow(unreachable_patterns)]
12234        self.pattern.as_ref().and_then(|v| match v {
12235            crate::model::http_rule::Pattern::Patch(v) => std::option::Option::Some(v),
12236            _ => std::option::Option::None,
12237        })
12238    }
12239
12240    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12241    /// to hold a `Patch`.
12242    ///
12243    /// Note that all the setters affecting `pattern` are
12244    /// mutually exclusive.
12245    pub fn set_patch<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12246        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Patch(v.into()));
12247        self
12248    }
12249
12250    /// The value of [pattern][crate::model::HttpRule::pattern]
12251    /// if it holds a `Custom`, `None` if the field is not set or
12252    /// holds a different branch.
12253    pub fn custom(&self) -> std::option::Option<&std::boxed::Box<crate::model::CustomHttpPattern>> {
12254        #[allow(unreachable_patterns)]
12255        self.pattern.as_ref().and_then(|v| match v {
12256            crate::model::http_rule::Pattern::Custom(v) => std::option::Option::Some(v),
12257            _ => std::option::Option::None,
12258        })
12259    }
12260
12261    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
12262    /// to hold a `Custom`.
12263    ///
12264    /// Note that all the setters affecting `pattern` are
12265    /// mutually exclusive.
12266    pub fn set_custom<T: std::convert::Into<std::boxed::Box<crate::model::CustomHttpPattern>>>(
12267        mut self,
12268        v: T,
12269    ) -> Self {
12270        self.pattern =
12271            std::option::Option::Some(crate::model::http_rule::Pattern::Custom(v.into()));
12272        self
12273    }
12274}
12275
12276impl wkt::message::Message for HttpRule {
12277    fn typename() -> &'static str {
12278        "type.googleapis.com/google.api.HttpRule"
12279    }
12280}
12281
12282#[doc(hidden)]
12283impl<'de> serde::de::Deserialize<'de> for HttpRule {
12284    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12285    where
12286        D: serde::Deserializer<'de>,
12287    {
12288        #[allow(non_camel_case_types)]
12289        #[doc(hidden)]
12290        #[derive(PartialEq, Eq, Hash)]
12291        enum __FieldTag {
12292            __selector,
12293            __get,
12294            __put,
12295            __post,
12296            __delete,
12297            __patch,
12298            __custom,
12299            __body,
12300            __response_body,
12301            __additional_bindings,
12302            Unknown(std::string::String),
12303        }
12304        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12305            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12306            where
12307                D: serde::Deserializer<'de>,
12308            {
12309                struct Visitor;
12310                impl<'de> serde::de::Visitor<'de> for Visitor {
12311                    type Value = __FieldTag;
12312                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12313                        formatter.write_str("a field name for HttpRule")
12314                    }
12315                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12316                    where
12317                        E: serde::de::Error,
12318                    {
12319                        use std::result::Result::Ok;
12320                        use std::string::ToString;
12321                        match value {
12322                            "selector" => Ok(__FieldTag::__selector),
12323                            "get" => Ok(__FieldTag::__get),
12324                            "put" => Ok(__FieldTag::__put),
12325                            "post" => Ok(__FieldTag::__post),
12326                            "delete" => Ok(__FieldTag::__delete),
12327                            "patch" => Ok(__FieldTag::__patch),
12328                            "custom" => Ok(__FieldTag::__custom),
12329                            "body" => Ok(__FieldTag::__body),
12330                            "responseBody" => Ok(__FieldTag::__response_body),
12331                            "response_body" => Ok(__FieldTag::__response_body),
12332                            "additionalBindings" => Ok(__FieldTag::__additional_bindings),
12333                            "additional_bindings" => Ok(__FieldTag::__additional_bindings),
12334                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12335                        }
12336                    }
12337                }
12338                deserializer.deserialize_identifier(Visitor)
12339            }
12340        }
12341        struct Visitor;
12342        impl<'de> serde::de::Visitor<'de> for Visitor {
12343            type Value = HttpRule;
12344            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12345                formatter.write_str("struct HttpRule")
12346            }
12347            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12348            where
12349                A: serde::de::MapAccess<'de>,
12350            {
12351                #[allow(unused_imports)]
12352                use serde::de::Error;
12353                use std::option::Option::Some;
12354                let mut fields = std::collections::HashSet::new();
12355                let mut result = Self::Value::new();
12356                while let Some(tag) = map.next_key::<__FieldTag>()? {
12357                    #[allow(clippy::match_single_binding)]
12358                    match tag {
12359                        __FieldTag::__selector => {
12360                            if !fields.insert(__FieldTag::__selector) {
12361                                return std::result::Result::Err(A::Error::duplicate_field(
12362                                    "multiple values for selector",
12363                                ));
12364                            }
12365                            result.selector = map
12366                                .next_value::<std::option::Option<std::string::String>>()?
12367                                .unwrap_or_default();
12368                        }
12369                        __FieldTag::__get => {
12370                            if !fields.insert(__FieldTag::__get) {
12371                                return std::result::Result::Err(A::Error::duplicate_field(
12372                                    "multiple values for get",
12373                                ));
12374                            }
12375                            if result.pattern.is_some() {
12376                                return std::result::Result::Err(A::Error::duplicate_field(
12377                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.get, latest field was get",
12378                                ));
12379                            }
12380                            result.pattern =
12381                                std::option::Option::Some(crate::model::http_rule::Pattern::Get(
12382                                    map.next_value::<std::option::Option<std::string::String>>()?
12383                                        .unwrap_or_default(),
12384                                ));
12385                        }
12386                        __FieldTag::__put => {
12387                            if !fields.insert(__FieldTag::__put) {
12388                                return std::result::Result::Err(A::Error::duplicate_field(
12389                                    "multiple values for put",
12390                                ));
12391                            }
12392                            if result.pattern.is_some() {
12393                                return std::result::Result::Err(A::Error::duplicate_field(
12394                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.put, latest field was put",
12395                                ));
12396                            }
12397                            result.pattern =
12398                                std::option::Option::Some(crate::model::http_rule::Pattern::Put(
12399                                    map.next_value::<std::option::Option<std::string::String>>()?
12400                                        .unwrap_or_default(),
12401                                ));
12402                        }
12403                        __FieldTag::__post => {
12404                            if !fields.insert(__FieldTag::__post) {
12405                                return std::result::Result::Err(A::Error::duplicate_field(
12406                                    "multiple values for post",
12407                                ));
12408                            }
12409                            if result.pattern.is_some() {
12410                                return std::result::Result::Err(A::Error::duplicate_field(
12411                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.post, latest field was post",
12412                                ));
12413                            }
12414                            result.pattern =
12415                                std::option::Option::Some(crate::model::http_rule::Pattern::Post(
12416                                    map.next_value::<std::option::Option<std::string::String>>()?
12417                                        .unwrap_or_default(),
12418                                ));
12419                        }
12420                        __FieldTag::__delete => {
12421                            if !fields.insert(__FieldTag::__delete) {
12422                                return std::result::Result::Err(A::Error::duplicate_field(
12423                                    "multiple values for delete",
12424                                ));
12425                            }
12426                            if result.pattern.is_some() {
12427                                return std::result::Result::Err(A::Error::duplicate_field(
12428                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.delete, latest field was delete",
12429                                ));
12430                            }
12431                            result.pattern = std::option::Option::Some(
12432                                crate::model::http_rule::Pattern::Delete(
12433                                    map.next_value::<std::option::Option<std::string::String>>()?
12434                                        .unwrap_or_default(),
12435                                ),
12436                            );
12437                        }
12438                        __FieldTag::__patch => {
12439                            if !fields.insert(__FieldTag::__patch) {
12440                                return std::result::Result::Err(A::Error::duplicate_field(
12441                                    "multiple values for patch",
12442                                ));
12443                            }
12444                            if result.pattern.is_some() {
12445                                return std::result::Result::Err(A::Error::duplicate_field(
12446                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.patch, latest field was patch",
12447                                ));
12448                            }
12449                            result.pattern =
12450                                std::option::Option::Some(crate::model::http_rule::Pattern::Patch(
12451                                    map.next_value::<std::option::Option<std::string::String>>()?
12452                                        .unwrap_or_default(),
12453                                ));
12454                        }
12455                        __FieldTag::__custom => {
12456                            if !fields.insert(__FieldTag::__custom) {
12457                                return std::result::Result::Err(A::Error::duplicate_field(
12458                                    "multiple values for custom",
12459                                ));
12460                            }
12461                            if result.pattern.is_some() {
12462                                return std::result::Result::Err(A::Error::duplicate_field(
12463                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.custom, latest field was custom",
12464                                ));
12465                            }
12466                            result.pattern = std::option::Option::Some(
12467                                crate::model::http_rule::Pattern::Custom(
12468                                    map.next_value::<std::option::Option<
12469                                        std::boxed::Box<crate::model::CustomHttpPattern>,
12470                                    >>()?
12471                                    .unwrap_or_default(),
12472                                ),
12473                            );
12474                        }
12475                        __FieldTag::__body => {
12476                            if !fields.insert(__FieldTag::__body) {
12477                                return std::result::Result::Err(A::Error::duplicate_field(
12478                                    "multiple values for body",
12479                                ));
12480                            }
12481                            result.body = map
12482                                .next_value::<std::option::Option<std::string::String>>()?
12483                                .unwrap_or_default();
12484                        }
12485                        __FieldTag::__response_body => {
12486                            if !fields.insert(__FieldTag::__response_body) {
12487                                return std::result::Result::Err(A::Error::duplicate_field(
12488                                    "multiple values for response_body",
12489                                ));
12490                            }
12491                            result.response_body = map
12492                                .next_value::<std::option::Option<std::string::String>>()?
12493                                .unwrap_or_default();
12494                        }
12495                        __FieldTag::__additional_bindings => {
12496                            if !fields.insert(__FieldTag::__additional_bindings) {
12497                                return std::result::Result::Err(A::Error::duplicate_field(
12498                                    "multiple values for additional_bindings",
12499                                ));
12500                            }
12501                            result.additional_bindings = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpRule>>>()?.unwrap_or_default();
12502                        }
12503                        __FieldTag::Unknown(key) => {
12504                            let value = map.next_value::<serde_json::Value>()?;
12505                            result._unknown_fields.insert(key, value);
12506                        }
12507                    }
12508                }
12509                std::result::Result::Ok(result)
12510            }
12511        }
12512        deserializer.deserialize_any(Visitor)
12513    }
12514}
12515
12516#[doc(hidden)]
12517impl serde::ser::Serialize for HttpRule {
12518    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12519    where
12520        S: serde::ser::Serializer,
12521    {
12522        use serde::ser::SerializeMap;
12523        #[allow(unused_imports)]
12524        use std::option::Option::Some;
12525        let mut state = serializer.serialize_map(std::option::Option::None)?;
12526        if !self.selector.is_empty() {
12527            state.serialize_entry("selector", &self.selector)?;
12528        }
12529        if let Some(value) = self.get() {
12530            state.serialize_entry("get", value)?;
12531        }
12532        if let Some(value) = self.put() {
12533            state.serialize_entry("put", value)?;
12534        }
12535        if let Some(value) = self.post() {
12536            state.serialize_entry("post", value)?;
12537        }
12538        if let Some(value) = self.delete() {
12539            state.serialize_entry("delete", value)?;
12540        }
12541        if let Some(value) = self.patch() {
12542            state.serialize_entry("patch", value)?;
12543        }
12544        if let Some(value) = self.custom() {
12545            state.serialize_entry("custom", value)?;
12546        }
12547        if !self.body.is_empty() {
12548            state.serialize_entry("body", &self.body)?;
12549        }
12550        if !self.response_body.is_empty() {
12551            state.serialize_entry("responseBody", &self.response_body)?;
12552        }
12553        if !self.additional_bindings.is_empty() {
12554            state.serialize_entry("additionalBindings", &self.additional_bindings)?;
12555        }
12556        if !self._unknown_fields.is_empty() {
12557            for (key, value) in self._unknown_fields.iter() {
12558                state.serialize_entry(key, &value)?;
12559            }
12560        }
12561        state.end()
12562    }
12563}
12564
12565impl std::fmt::Debug for HttpRule {
12566    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12567        let mut debug_struct = f.debug_struct("HttpRule");
12568        debug_struct.field("selector", &self.selector);
12569        debug_struct.field("body", &self.body);
12570        debug_struct.field("response_body", &self.response_body);
12571        debug_struct.field("additional_bindings", &self.additional_bindings);
12572        debug_struct.field("pattern", &self.pattern);
12573        if !self._unknown_fields.is_empty() {
12574            debug_struct.field("_unknown_fields", &self._unknown_fields);
12575        }
12576        debug_struct.finish()
12577    }
12578}
12579
12580/// Defines additional types related to [HttpRule].
12581pub mod http_rule {
12582    #[allow(unused_imports)]
12583    use super::*;
12584
12585    /// Determines the URL pattern is matched by this rules. This pattern can be
12586    /// used with any of the {get|put|post|delete|patch} methods. A custom method
12587    /// can be defined using the 'custom' field.
12588    #[derive(Clone, Debug, PartialEq)]
12589    #[non_exhaustive]
12590    pub enum Pattern {
12591        /// Maps to HTTP GET. Used for listing and getting information about
12592        /// resources.
12593        Get(std::string::String),
12594        /// Maps to HTTP PUT. Used for replacing a resource.
12595        Put(std::string::String),
12596        /// Maps to HTTP POST. Used for creating a resource or performing an action.
12597        Post(std::string::String),
12598        /// Maps to HTTP DELETE. Used for deleting a resource.
12599        Delete(std::string::String),
12600        /// Maps to HTTP PATCH. Used for updating a resource.
12601        Patch(std::string::String),
12602        /// The custom pattern is used for specifying an HTTP method that is not
12603        /// included in the `pattern` field, such as HEAD, or "*" to leave the
12604        /// HTTP method unspecified for this rule. The wild-card rule is useful
12605        /// for services that provide content to Web (HTML) clients.
12606        Custom(std::boxed::Box<crate::model::CustomHttpPattern>),
12607    }
12608}
12609
12610/// A custom pattern is used for defining custom HTTP verb.
12611#[derive(Clone, Default, PartialEq)]
12612#[non_exhaustive]
12613pub struct CustomHttpPattern {
12614    /// The name of this custom HTTP verb.
12615    pub kind: std::string::String,
12616
12617    /// The path matched by this custom verb.
12618    pub path: std::string::String,
12619
12620    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12621}
12622
12623impl CustomHttpPattern {
12624    pub fn new() -> Self {
12625        std::default::Default::default()
12626    }
12627
12628    /// Sets the value of [kind][crate::model::CustomHttpPattern::kind].
12629    pub fn set_kind<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12630        self.kind = v.into();
12631        self
12632    }
12633
12634    /// Sets the value of [path][crate::model::CustomHttpPattern::path].
12635    pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12636        self.path = v.into();
12637        self
12638    }
12639}
12640
12641impl wkt::message::Message for CustomHttpPattern {
12642    fn typename() -> &'static str {
12643        "type.googleapis.com/google.api.CustomHttpPattern"
12644    }
12645}
12646
12647#[doc(hidden)]
12648impl<'de> serde::de::Deserialize<'de> for CustomHttpPattern {
12649    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12650    where
12651        D: serde::Deserializer<'de>,
12652    {
12653        #[allow(non_camel_case_types)]
12654        #[doc(hidden)]
12655        #[derive(PartialEq, Eq, Hash)]
12656        enum __FieldTag {
12657            __kind,
12658            __path,
12659            Unknown(std::string::String),
12660        }
12661        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12662            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12663            where
12664                D: serde::Deserializer<'de>,
12665            {
12666                struct Visitor;
12667                impl<'de> serde::de::Visitor<'de> for Visitor {
12668                    type Value = __FieldTag;
12669                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12670                        formatter.write_str("a field name for CustomHttpPattern")
12671                    }
12672                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12673                    where
12674                        E: serde::de::Error,
12675                    {
12676                        use std::result::Result::Ok;
12677                        use std::string::ToString;
12678                        match value {
12679                            "kind" => Ok(__FieldTag::__kind),
12680                            "path" => Ok(__FieldTag::__path),
12681                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12682                        }
12683                    }
12684                }
12685                deserializer.deserialize_identifier(Visitor)
12686            }
12687        }
12688        struct Visitor;
12689        impl<'de> serde::de::Visitor<'de> for Visitor {
12690            type Value = CustomHttpPattern;
12691            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12692                formatter.write_str("struct CustomHttpPattern")
12693            }
12694            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12695            where
12696                A: serde::de::MapAccess<'de>,
12697            {
12698                #[allow(unused_imports)]
12699                use serde::de::Error;
12700                use std::option::Option::Some;
12701                let mut fields = std::collections::HashSet::new();
12702                let mut result = Self::Value::new();
12703                while let Some(tag) = map.next_key::<__FieldTag>()? {
12704                    #[allow(clippy::match_single_binding)]
12705                    match tag {
12706                        __FieldTag::__kind => {
12707                            if !fields.insert(__FieldTag::__kind) {
12708                                return std::result::Result::Err(A::Error::duplicate_field(
12709                                    "multiple values for kind",
12710                                ));
12711                            }
12712                            result.kind = map
12713                                .next_value::<std::option::Option<std::string::String>>()?
12714                                .unwrap_or_default();
12715                        }
12716                        __FieldTag::__path => {
12717                            if !fields.insert(__FieldTag::__path) {
12718                                return std::result::Result::Err(A::Error::duplicate_field(
12719                                    "multiple values for path",
12720                                ));
12721                            }
12722                            result.path = map
12723                                .next_value::<std::option::Option<std::string::String>>()?
12724                                .unwrap_or_default();
12725                        }
12726                        __FieldTag::Unknown(key) => {
12727                            let value = map.next_value::<serde_json::Value>()?;
12728                            result._unknown_fields.insert(key, value);
12729                        }
12730                    }
12731                }
12732                std::result::Result::Ok(result)
12733            }
12734        }
12735        deserializer.deserialize_any(Visitor)
12736    }
12737}
12738
12739#[doc(hidden)]
12740impl serde::ser::Serialize for CustomHttpPattern {
12741    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12742    where
12743        S: serde::ser::Serializer,
12744    {
12745        use serde::ser::SerializeMap;
12746        #[allow(unused_imports)]
12747        use std::option::Option::Some;
12748        let mut state = serializer.serialize_map(std::option::Option::None)?;
12749        if !self.kind.is_empty() {
12750            state.serialize_entry("kind", &self.kind)?;
12751        }
12752        if !self.path.is_empty() {
12753            state.serialize_entry("path", &self.path)?;
12754        }
12755        if !self._unknown_fields.is_empty() {
12756            for (key, value) in self._unknown_fields.iter() {
12757                state.serialize_entry(key, &value)?;
12758            }
12759        }
12760        state.end()
12761    }
12762}
12763
12764impl std::fmt::Debug for CustomHttpPattern {
12765    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12766        let mut debug_struct = f.debug_struct("CustomHttpPattern");
12767        debug_struct.field("kind", &self.kind);
12768        debug_struct.field("path", &self.path);
12769        if !self._unknown_fields.is_empty() {
12770            debug_struct.field("_unknown_fields", &self._unknown_fields);
12771        }
12772        debug_struct.finish()
12773    }
12774}
12775
12776/// Message that represents an arbitrary HTTP body. It should only be used for
12777/// payload formats that can't be represented as JSON, such as raw binary or
12778/// an HTML page.
12779///
12780/// This message can be used both in streaming and non-streaming API methods in
12781/// the request as well as the response.
12782///
12783/// It can be used as a top-level request field, which is convenient if one
12784/// wants to extract parameters from either the URL or HTTP template into the
12785/// request fields and also want access to the raw HTTP body.
12786///
12787/// Example:
12788///
12789/// ```norust
12790/// message GetResourceRequest {
12791///   // A unique request id.
12792///   string request_id = 1;
12793///
12794///   // The raw HTTP body is bound to this field.
12795///   google.api.HttpBody http_body = 2;
12796///
12797/// }
12798///
12799/// service ResourceService {
12800///   rpc GetResource(GetResourceRequest)
12801///     returns (google.api.HttpBody);
12802///   rpc UpdateResource(google.api.HttpBody)
12803///     returns (google.protobuf.Empty);
12804///
12805/// }
12806/// ```
12807///
12808/// Example with streaming methods:
12809///
12810/// ```norust
12811/// service CaldavService {
12812///   rpc GetCalendar(stream google.api.HttpBody)
12813///     returns (stream google.api.HttpBody);
12814///   rpc UpdateCalendar(stream google.api.HttpBody)
12815///     returns (stream google.api.HttpBody);
12816///
12817/// }
12818/// ```
12819///
12820/// Use of this type only changes how the request and response bodies are
12821/// handled, all other features will continue to work unchanged.
12822#[derive(Clone, Default, PartialEq)]
12823#[non_exhaustive]
12824pub struct HttpBody {
12825    /// The HTTP Content-Type header value specifying the content type of the body.
12826    pub content_type: std::string::String,
12827
12828    /// The HTTP request/response body as raw binary.
12829    pub data: ::bytes::Bytes,
12830
12831    /// Application specific response metadata. Must be set in the first response
12832    /// for streaming APIs.
12833    pub extensions: std::vec::Vec<wkt::Any>,
12834
12835    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12836}
12837
12838impl HttpBody {
12839    pub fn new() -> Self {
12840        std::default::Default::default()
12841    }
12842
12843    /// Sets the value of [content_type][crate::model::HttpBody::content_type].
12844    pub fn set_content_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12845        self.content_type = v.into();
12846        self
12847    }
12848
12849    /// Sets the value of [data][crate::model::HttpBody::data].
12850    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
12851        self.data = v.into();
12852        self
12853    }
12854
12855    /// Sets the value of [extensions][crate::model::HttpBody::extensions].
12856    pub fn set_extensions<T, V>(mut self, v: T) -> Self
12857    where
12858        T: std::iter::IntoIterator<Item = V>,
12859        V: std::convert::Into<wkt::Any>,
12860    {
12861        use std::iter::Iterator;
12862        self.extensions = v.into_iter().map(|i| i.into()).collect();
12863        self
12864    }
12865}
12866
12867impl wkt::message::Message for HttpBody {
12868    fn typename() -> &'static str {
12869        "type.googleapis.com/google.api.HttpBody"
12870    }
12871}
12872
12873#[doc(hidden)]
12874impl<'de> serde::de::Deserialize<'de> for HttpBody {
12875    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12876    where
12877        D: serde::Deserializer<'de>,
12878    {
12879        #[allow(non_camel_case_types)]
12880        #[doc(hidden)]
12881        #[derive(PartialEq, Eq, Hash)]
12882        enum __FieldTag {
12883            __content_type,
12884            __data,
12885            __extensions,
12886            Unknown(std::string::String),
12887        }
12888        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12889            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12890            where
12891                D: serde::Deserializer<'de>,
12892            {
12893                struct Visitor;
12894                impl<'de> serde::de::Visitor<'de> for Visitor {
12895                    type Value = __FieldTag;
12896                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12897                        formatter.write_str("a field name for HttpBody")
12898                    }
12899                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12900                    where
12901                        E: serde::de::Error,
12902                    {
12903                        use std::result::Result::Ok;
12904                        use std::string::ToString;
12905                        match value {
12906                            "contentType" => Ok(__FieldTag::__content_type),
12907                            "content_type" => Ok(__FieldTag::__content_type),
12908                            "data" => Ok(__FieldTag::__data),
12909                            "extensions" => Ok(__FieldTag::__extensions),
12910                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12911                        }
12912                    }
12913                }
12914                deserializer.deserialize_identifier(Visitor)
12915            }
12916        }
12917        struct Visitor;
12918        impl<'de> serde::de::Visitor<'de> for Visitor {
12919            type Value = HttpBody;
12920            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12921                formatter.write_str("struct HttpBody")
12922            }
12923            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12924            where
12925                A: serde::de::MapAccess<'de>,
12926            {
12927                #[allow(unused_imports)]
12928                use serde::de::Error;
12929                use std::option::Option::Some;
12930                let mut fields = std::collections::HashSet::new();
12931                let mut result = Self::Value::new();
12932                while let Some(tag) = map.next_key::<__FieldTag>()? {
12933                    #[allow(clippy::match_single_binding)]
12934                    match tag {
12935                        __FieldTag::__content_type => {
12936                            if !fields.insert(__FieldTag::__content_type) {
12937                                return std::result::Result::Err(A::Error::duplicate_field(
12938                                    "multiple values for content_type",
12939                                ));
12940                            }
12941                            result.content_type = map
12942                                .next_value::<std::option::Option<std::string::String>>()?
12943                                .unwrap_or_default();
12944                        }
12945                        __FieldTag::__data => {
12946                            if !fields.insert(__FieldTag::__data) {
12947                                return std::result::Result::Err(A::Error::duplicate_field(
12948                                    "multiple values for data",
12949                                ));
12950                            }
12951                            struct __With(std::option::Option<::bytes::Bytes>);
12952                            impl<'de> serde::de::Deserialize<'de> for __With {
12953                                fn deserialize<D>(
12954                                    deserializer: D,
12955                                ) -> std::result::Result<Self, D::Error>
12956                                where
12957                                    D: serde::de::Deserializer<'de>,
12958                                {
12959                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
12960                                }
12961                            }
12962                            result.data = map.next_value::<__With>()?.0.unwrap_or_default();
12963                        }
12964                        __FieldTag::__extensions => {
12965                            if !fields.insert(__FieldTag::__extensions) {
12966                                return std::result::Result::Err(A::Error::duplicate_field(
12967                                    "multiple values for extensions",
12968                                ));
12969                            }
12970                            result.extensions = map
12971                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
12972                                .unwrap_or_default();
12973                        }
12974                        __FieldTag::Unknown(key) => {
12975                            let value = map.next_value::<serde_json::Value>()?;
12976                            result._unknown_fields.insert(key, value);
12977                        }
12978                    }
12979                }
12980                std::result::Result::Ok(result)
12981            }
12982        }
12983        deserializer.deserialize_any(Visitor)
12984    }
12985}
12986
12987#[doc(hidden)]
12988impl serde::ser::Serialize for HttpBody {
12989    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12990    where
12991        S: serde::ser::Serializer,
12992    {
12993        use serde::ser::SerializeMap;
12994        #[allow(unused_imports)]
12995        use std::option::Option::Some;
12996        let mut state = serializer.serialize_map(std::option::Option::None)?;
12997        if !self.content_type.is_empty() {
12998            state.serialize_entry("contentType", &self.content_type)?;
12999        }
13000        if !self.data.is_empty() {
13001            struct __With<'a>(&'a ::bytes::Bytes);
13002            impl<'a> serde::ser::Serialize for __With<'a> {
13003                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13004                where
13005                    S: serde::ser::Serializer,
13006                {
13007                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
13008                }
13009            }
13010            state.serialize_entry("data", &__With(&self.data))?;
13011        }
13012        if !self.extensions.is_empty() {
13013            state.serialize_entry("extensions", &self.extensions)?;
13014        }
13015        if !self._unknown_fields.is_empty() {
13016            for (key, value) in self._unknown_fields.iter() {
13017                state.serialize_entry(key, &value)?;
13018            }
13019        }
13020        state.end()
13021    }
13022}
13023
13024impl std::fmt::Debug for HttpBody {
13025    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13026        let mut debug_struct = f.debug_struct("HttpBody");
13027        debug_struct.field("content_type", &self.content_type);
13028        debug_struct.field("data", &self.data);
13029        debug_struct.field("extensions", &self.extensions);
13030        if !self._unknown_fields.is_empty() {
13031            debug_struct.field("_unknown_fields", &self._unknown_fields);
13032        }
13033        debug_struct.finish()
13034    }
13035}
13036
13037/// A description of a label.
13038#[derive(Clone, Default, PartialEq)]
13039#[non_exhaustive]
13040pub struct LabelDescriptor {
13041    /// The label key.
13042    pub key: std::string::String,
13043
13044    /// The type of data that can be assigned to the label.
13045    pub value_type: crate::model::label_descriptor::ValueType,
13046
13047    /// A human-readable description for the label.
13048    pub description: std::string::String,
13049
13050    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13051}
13052
13053impl LabelDescriptor {
13054    pub fn new() -> Self {
13055        std::default::Default::default()
13056    }
13057
13058    /// Sets the value of [key][crate::model::LabelDescriptor::key].
13059    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13060        self.key = v.into();
13061        self
13062    }
13063
13064    /// Sets the value of [value_type][crate::model::LabelDescriptor::value_type].
13065    pub fn set_value_type<T: std::convert::Into<crate::model::label_descriptor::ValueType>>(
13066        mut self,
13067        v: T,
13068    ) -> Self {
13069        self.value_type = v.into();
13070        self
13071    }
13072
13073    /// Sets the value of [description][crate::model::LabelDescriptor::description].
13074    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13075        self.description = v.into();
13076        self
13077    }
13078}
13079
13080impl wkt::message::Message for LabelDescriptor {
13081    fn typename() -> &'static str {
13082        "type.googleapis.com/google.api.LabelDescriptor"
13083    }
13084}
13085
13086#[doc(hidden)]
13087impl<'de> serde::de::Deserialize<'de> for LabelDescriptor {
13088    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13089    where
13090        D: serde::Deserializer<'de>,
13091    {
13092        #[allow(non_camel_case_types)]
13093        #[doc(hidden)]
13094        #[derive(PartialEq, Eq, Hash)]
13095        enum __FieldTag {
13096            __key,
13097            __value_type,
13098            __description,
13099            Unknown(std::string::String),
13100        }
13101        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13102            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13103            where
13104                D: serde::Deserializer<'de>,
13105            {
13106                struct Visitor;
13107                impl<'de> serde::de::Visitor<'de> for Visitor {
13108                    type Value = __FieldTag;
13109                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13110                        formatter.write_str("a field name for LabelDescriptor")
13111                    }
13112                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13113                    where
13114                        E: serde::de::Error,
13115                    {
13116                        use std::result::Result::Ok;
13117                        use std::string::ToString;
13118                        match value {
13119                            "key" => Ok(__FieldTag::__key),
13120                            "valueType" => Ok(__FieldTag::__value_type),
13121                            "value_type" => Ok(__FieldTag::__value_type),
13122                            "description" => Ok(__FieldTag::__description),
13123                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13124                        }
13125                    }
13126                }
13127                deserializer.deserialize_identifier(Visitor)
13128            }
13129        }
13130        struct Visitor;
13131        impl<'de> serde::de::Visitor<'de> for Visitor {
13132            type Value = LabelDescriptor;
13133            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13134                formatter.write_str("struct LabelDescriptor")
13135            }
13136            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13137            where
13138                A: serde::de::MapAccess<'de>,
13139            {
13140                #[allow(unused_imports)]
13141                use serde::de::Error;
13142                use std::option::Option::Some;
13143                let mut fields = std::collections::HashSet::new();
13144                let mut result = Self::Value::new();
13145                while let Some(tag) = map.next_key::<__FieldTag>()? {
13146                    #[allow(clippy::match_single_binding)]
13147                    match tag {
13148                        __FieldTag::__key => {
13149                            if !fields.insert(__FieldTag::__key) {
13150                                return std::result::Result::Err(A::Error::duplicate_field(
13151                                    "multiple values for key",
13152                                ));
13153                            }
13154                            result.key = map
13155                                .next_value::<std::option::Option<std::string::String>>()?
13156                                .unwrap_or_default();
13157                        }
13158                        __FieldTag::__value_type => {
13159                            if !fields.insert(__FieldTag::__value_type) {
13160                                return std::result::Result::Err(A::Error::duplicate_field(
13161                                    "multiple values for value_type",
13162                                ));
13163                            }
13164                            result.value_type = map.next_value::<std::option::Option<crate::model::label_descriptor::ValueType>>()?.unwrap_or_default();
13165                        }
13166                        __FieldTag::__description => {
13167                            if !fields.insert(__FieldTag::__description) {
13168                                return std::result::Result::Err(A::Error::duplicate_field(
13169                                    "multiple values for description",
13170                                ));
13171                            }
13172                            result.description = map
13173                                .next_value::<std::option::Option<std::string::String>>()?
13174                                .unwrap_or_default();
13175                        }
13176                        __FieldTag::Unknown(key) => {
13177                            let value = map.next_value::<serde_json::Value>()?;
13178                            result._unknown_fields.insert(key, value);
13179                        }
13180                    }
13181                }
13182                std::result::Result::Ok(result)
13183            }
13184        }
13185        deserializer.deserialize_any(Visitor)
13186    }
13187}
13188
13189#[doc(hidden)]
13190impl serde::ser::Serialize for LabelDescriptor {
13191    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13192    where
13193        S: serde::ser::Serializer,
13194    {
13195        use serde::ser::SerializeMap;
13196        #[allow(unused_imports)]
13197        use std::option::Option::Some;
13198        let mut state = serializer.serialize_map(std::option::Option::None)?;
13199        if !self.key.is_empty() {
13200            state.serialize_entry("key", &self.key)?;
13201        }
13202        if !wkt::internal::is_default(&self.value_type) {
13203            state.serialize_entry("valueType", &self.value_type)?;
13204        }
13205        if !self.description.is_empty() {
13206            state.serialize_entry("description", &self.description)?;
13207        }
13208        if !self._unknown_fields.is_empty() {
13209            for (key, value) in self._unknown_fields.iter() {
13210                state.serialize_entry(key, &value)?;
13211            }
13212        }
13213        state.end()
13214    }
13215}
13216
13217impl std::fmt::Debug for LabelDescriptor {
13218    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13219        let mut debug_struct = f.debug_struct("LabelDescriptor");
13220        debug_struct.field("key", &self.key);
13221        debug_struct.field("value_type", &self.value_type);
13222        debug_struct.field("description", &self.description);
13223        if !self._unknown_fields.is_empty() {
13224            debug_struct.field("_unknown_fields", &self._unknown_fields);
13225        }
13226        debug_struct.finish()
13227    }
13228}
13229
13230/// Defines additional types related to [LabelDescriptor].
13231pub mod label_descriptor {
13232    #[allow(unused_imports)]
13233    use super::*;
13234
13235    /// Value types that can be used as label values.
13236    ///
13237    /// # Working with unknown values
13238    ///
13239    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
13240    /// additional enum variants at any time. Adding new variants is not considered
13241    /// a breaking change. Applications should write their code in anticipation of:
13242    ///
13243    /// - New values appearing in future releases of the client library, **and**
13244    /// - New values received dynamically, without application changes.
13245    ///
13246    /// Please consult the [Working with enums] section in the user guide for some
13247    /// guidelines.
13248    ///
13249    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
13250    #[derive(Clone, Debug, PartialEq)]
13251    #[non_exhaustive]
13252    pub enum ValueType {
13253        /// A variable-length string. This is the default.
13254        String,
13255        /// Boolean; true or false.
13256        Bool,
13257        /// A 64-bit signed integer.
13258        Int64,
13259        /// If set, the enum was initialized with an unknown value.
13260        ///
13261        /// Applications can examine the value using [ValueType::value] or
13262        /// [ValueType::name].
13263        UnknownValue(value_type::UnknownValue),
13264    }
13265
13266    #[doc(hidden)]
13267    pub mod value_type {
13268        #[allow(unused_imports)]
13269        use super::*;
13270        #[derive(Clone, Debug, PartialEq)]
13271        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
13272    }
13273
13274    impl ValueType {
13275        /// Gets the enum value.
13276        ///
13277        /// Returns `None` if the enum contains an unknown value deserialized from
13278        /// the string representation of enums.
13279        pub fn value(&self) -> std::option::Option<i32> {
13280            match self {
13281                Self::String => std::option::Option::Some(0),
13282                Self::Bool => std::option::Option::Some(1),
13283                Self::Int64 => std::option::Option::Some(2),
13284                Self::UnknownValue(u) => u.0.value(),
13285            }
13286        }
13287
13288        /// Gets the enum value as a string.
13289        ///
13290        /// Returns `None` if the enum contains an unknown value deserialized from
13291        /// the integer representation of enums.
13292        pub fn name(&self) -> std::option::Option<&str> {
13293            match self {
13294                Self::String => std::option::Option::Some("STRING"),
13295                Self::Bool => std::option::Option::Some("BOOL"),
13296                Self::Int64 => std::option::Option::Some("INT64"),
13297                Self::UnknownValue(u) => u.0.name(),
13298            }
13299        }
13300    }
13301
13302    impl std::default::Default for ValueType {
13303        fn default() -> Self {
13304            use std::convert::From;
13305            Self::from(0)
13306        }
13307    }
13308
13309    impl std::fmt::Display for ValueType {
13310        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
13311            wkt::internal::display_enum(f, self.name(), self.value())
13312        }
13313    }
13314
13315    impl std::convert::From<i32> for ValueType {
13316        fn from(value: i32) -> Self {
13317            match value {
13318                0 => Self::String,
13319                1 => Self::Bool,
13320                2 => Self::Int64,
13321                _ => Self::UnknownValue(value_type::UnknownValue(
13322                    wkt::internal::UnknownEnumValue::Integer(value),
13323                )),
13324            }
13325        }
13326    }
13327
13328    impl std::convert::From<&str> for ValueType {
13329        fn from(value: &str) -> Self {
13330            use std::string::ToString;
13331            match value {
13332                "STRING" => Self::String,
13333                "BOOL" => Self::Bool,
13334                "INT64" => Self::Int64,
13335                _ => Self::UnknownValue(value_type::UnknownValue(
13336                    wkt::internal::UnknownEnumValue::String(value.to_string()),
13337                )),
13338            }
13339        }
13340    }
13341
13342    impl serde::ser::Serialize for ValueType {
13343        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13344        where
13345            S: serde::Serializer,
13346        {
13347            match self {
13348                Self::String => serializer.serialize_i32(0),
13349                Self::Bool => serializer.serialize_i32(1),
13350                Self::Int64 => serializer.serialize_i32(2),
13351                Self::UnknownValue(u) => u.0.serialize(serializer),
13352            }
13353        }
13354    }
13355
13356    impl<'de> serde::de::Deserialize<'de> for ValueType {
13357        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13358        where
13359            D: serde::Deserializer<'de>,
13360        {
13361            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
13362                ".google.api.LabelDescriptor.ValueType",
13363            ))
13364        }
13365    }
13366}
13367
13368/// A description of a log type. Example in YAML format:
13369///
13370/// ```norust
13371/// - name: library.googleapis.com/activity_history
13372///   description: The history of borrowing and returning library items.
13373///   display_name: Activity
13374///   labels:
13375///   - key: /customer_id
13376///     description: Identifier of a library customer
13377/// ```
13378#[derive(Clone, Default, PartialEq)]
13379#[non_exhaustive]
13380pub struct LogDescriptor {
13381    /// The name of the log. It must be less than 512 characters long and can
13382    /// include the following characters: upper- and lower-case alphanumeric
13383    /// characters [A-Za-z0-9], and punctuation characters including
13384    /// slash, underscore, hyphen, period [/_-.].
13385    pub name: std::string::String,
13386
13387    /// The set of labels that are available to describe a specific log entry.
13388    /// Runtime requests that contain labels not specified here are
13389    /// considered invalid.
13390    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
13391
13392    /// A human-readable description of this log. This information appears in
13393    /// the documentation and can contain details.
13394    pub description: std::string::String,
13395
13396    /// The human-readable name for this log. This information appears on
13397    /// the user interface and should be concise.
13398    pub display_name: std::string::String,
13399
13400    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13401}
13402
13403impl LogDescriptor {
13404    pub fn new() -> Self {
13405        std::default::Default::default()
13406    }
13407
13408    /// Sets the value of [name][crate::model::LogDescriptor::name].
13409    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13410        self.name = v.into();
13411        self
13412    }
13413
13414    /// Sets the value of [labels][crate::model::LogDescriptor::labels].
13415    pub fn set_labels<T, V>(mut self, v: T) -> Self
13416    where
13417        T: std::iter::IntoIterator<Item = V>,
13418        V: std::convert::Into<crate::model::LabelDescriptor>,
13419    {
13420        use std::iter::Iterator;
13421        self.labels = v.into_iter().map(|i| i.into()).collect();
13422        self
13423    }
13424
13425    /// Sets the value of [description][crate::model::LogDescriptor::description].
13426    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13427        self.description = v.into();
13428        self
13429    }
13430
13431    /// Sets the value of [display_name][crate::model::LogDescriptor::display_name].
13432    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13433        self.display_name = v.into();
13434        self
13435    }
13436}
13437
13438impl wkt::message::Message for LogDescriptor {
13439    fn typename() -> &'static str {
13440        "type.googleapis.com/google.api.LogDescriptor"
13441    }
13442}
13443
13444#[doc(hidden)]
13445impl<'de> serde::de::Deserialize<'de> for LogDescriptor {
13446    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13447    where
13448        D: serde::Deserializer<'de>,
13449    {
13450        #[allow(non_camel_case_types)]
13451        #[doc(hidden)]
13452        #[derive(PartialEq, Eq, Hash)]
13453        enum __FieldTag {
13454            __name,
13455            __labels,
13456            __description,
13457            __display_name,
13458            Unknown(std::string::String),
13459        }
13460        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13461            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13462            where
13463                D: serde::Deserializer<'de>,
13464            {
13465                struct Visitor;
13466                impl<'de> serde::de::Visitor<'de> for Visitor {
13467                    type Value = __FieldTag;
13468                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13469                        formatter.write_str("a field name for LogDescriptor")
13470                    }
13471                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13472                    where
13473                        E: serde::de::Error,
13474                    {
13475                        use std::result::Result::Ok;
13476                        use std::string::ToString;
13477                        match value {
13478                            "name" => Ok(__FieldTag::__name),
13479                            "labels" => Ok(__FieldTag::__labels),
13480                            "description" => Ok(__FieldTag::__description),
13481                            "displayName" => Ok(__FieldTag::__display_name),
13482                            "display_name" => Ok(__FieldTag::__display_name),
13483                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13484                        }
13485                    }
13486                }
13487                deserializer.deserialize_identifier(Visitor)
13488            }
13489        }
13490        struct Visitor;
13491        impl<'de> serde::de::Visitor<'de> for Visitor {
13492            type Value = LogDescriptor;
13493            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13494                formatter.write_str("struct LogDescriptor")
13495            }
13496            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13497            where
13498                A: serde::de::MapAccess<'de>,
13499            {
13500                #[allow(unused_imports)]
13501                use serde::de::Error;
13502                use std::option::Option::Some;
13503                let mut fields = std::collections::HashSet::new();
13504                let mut result = Self::Value::new();
13505                while let Some(tag) = map.next_key::<__FieldTag>()? {
13506                    #[allow(clippy::match_single_binding)]
13507                    match tag {
13508                        __FieldTag::__name => {
13509                            if !fields.insert(__FieldTag::__name) {
13510                                return std::result::Result::Err(A::Error::duplicate_field(
13511                                    "multiple values for name",
13512                                ));
13513                            }
13514                            result.name = map
13515                                .next_value::<std::option::Option<std::string::String>>()?
13516                                .unwrap_or_default();
13517                        }
13518                        __FieldTag::__labels => {
13519                            if !fields.insert(__FieldTag::__labels) {
13520                                return std::result::Result::Err(A::Error::duplicate_field(
13521                                    "multiple values for labels",
13522                                ));
13523                            }
13524                            result.labels =
13525                                map.next_value::<std::option::Option<
13526                                    std::vec::Vec<crate::model::LabelDescriptor>,
13527                                >>()?
13528                                .unwrap_or_default();
13529                        }
13530                        __FieldTag::__description => {
13531                            if !fields.insert(__FieldTag::__description) {
13532                                return std::result::Result::Err(A::Error::duplicate_field(
13533                                    "multiple values for description",
13534                                ));
13535                            }
13536                            result.description = map
13537                                .next_value::<std::option::Option<std::string::String>>()?
13538                                .unwrap_or_default();
13539                        }
13540                        __FieldTag::__display_name => {
13541                            if !fields.insert(__FieldTag::__display_name) {
13542                                return std::result::Result::Err(A::Error::duplicate_field(
13543                                    "multiple values for display_name",
13544                                ));
13545                            }
13546                            result.display_name = map
13547                                .next_value::<std::option::Option<std::string::String>>()?
13548                                .unwrap_or_default();
13549                        }
13550                        __FieldTag::Unknown(key) => {
13551                            let value = map.next_value::<serde_json::Value>()?;
13552                            result._unknown_fields.insert(key, value);
13553                        }
13554                    }
13555                }
13556                std::result::Result::Ok(result)
13557            }
13558        }
13559        deserializer.deserialize_any(Visitor)
13560    }
13561}
13562
13563#[doc(hidden)]
13564impl serde::ser::Serialize for LogDescriptor {
13565    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13566    where
13567        S: serde::ser::Serializer,
13568    {
13569        use serde::ser::SerializeMap;
13570        #[allow(unused_imports)]
13571        use std::option::Option::Some;
13572        let mut state = serializer.serialize_map(std::option::Option::None)?;
13573        if !self.name.is_empty() {
13574            state.serialize_entry("name", &self.name)?;
13575        }
13576        if !self.labels.is_empty() {
13577            state.serialize_entry("labels", &self.labels)?;
13578        }
13579        if !self.description.is_empty() {
13580            state.serialize_entry("description", &self.description)?;
13581        }
13582        if !self.display_name.is_empty() {
13583            state.serialize_entry("displayName", &self.display_name)?;
13584        }
13585        if !self._unknown_fields.is_empty() {
13586            for (key, value) in self._unknown_fields.iter() {
13587                state.serialize_entry(key, &value)?;
13588            }
13589        }
13590        state.end()
13591    }
13592}
13593
13594impl std::fmt::Debug for LogDescriptor {
13595    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13596        let mut debug_struct = f.debug_struct("LogDescriptor");
13597        debug_struct.field("name", &self.name);
13598        debug_struct.field("labels", &self.labels);
13599        debug_struct.field("description", &self.description);
13600        debug_struct.field("display_name", &self.display_name);
13601        if !self._unknown_fields.is_empty() {
13602            debug_struct.field("_unknown_fields", &self._unknown_fields);
13603        }
13604        debug_struct.finish()
13605    }
13606}
13607
13608/// Logging configuration of the service.
13609///
13610/// The following example shows how to configure logs to be sent to the
13611/// producer and consumer projects. In the example, the `activity_history`
13612/// log is sent to both the producer and consumer projects, whereas the
13613/// `purchase_history` log is only sent to the producer project.
13614///
13615/// ```norust
13616/// monitored_resources:
13617/// - type: library.googleapis.com/branch
13618///   labels:
13619///   - key: /city
13620///     description: The city where the library branch is located in.
13621///   - key: /name
13622///     description: The name of the branch.
13623/// logs:
13624/// - name: activity_history
13625///   labels:
13626///   - key: /customer_id
13627/// - name: purchase_history
13628/// logging:
13629///   producer_destinations:
13630///   - monitored_resource: library.googleapis.com/branch
13631///     logs:
13632///     - activity_history
13633///     - purchase_history
13634///   consumer_destinations:
13635///   - monitored_resource: library.googleapis.com/branch
13636///     logs:
13637///     - activity_history
13638/// ```
13639#[derive(Clone, Default, PartialEq)]
13640#[non_exhaustive]
13641pub struct Logging {
13642    /// Logging configurations for sending logs to the producer project.
13643    /// There can be multiple producer destinations, each one must have a
13644    /// different monitored resource type. A log can be used in at most
13645    /// one producer destination.
13646    pub producer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,
13647
13648    /// Logging configurations for sending logs to the consumer project.
13649    /// There can be multiple consumer destinations, each one must have a
13650    /// different monitored resource type. A log can be used in at most
13651    /// one consumer destination.
13652    pub consumer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,
13653
13654    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13655}
13656
13657impl Logging {
13658    pub fn new() -> Self {
13659        std::default::Default::default()
13660    }
13661
13662    /// Sets the value of [producer_destinations][crate::model::Logging::producer_destinations].
13663    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
13664    where
13665        T: std::iter::IntoIterator<Item = V>,
13666        V: std::convert::Into<crate::model::logging::LoggingDestination>,
13667    {
13668        use std::iter::Iterator;
13669        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
13670        self
13671    }
13672
13673    /// Sets the value of [consumer_destinations][crate::model::Logging::consumer_destinations].
13674    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
13675    where
13676        T: std::iter::IntoIterator<Item = V>,
13677        V: std::convert::Into<crate::model::logging::LoggingDestination>,
13678    {
13679        use std::iter::Iterator;
13680        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
13681        self
13682    }
13683}
13684
13685impl wkt::message::Message for Logging {
13686    fn typename() -> &'static str {
13687        "type.googleapis.com/google.api.Logging"
13688    }
13689}
13690
13691#[doc(hidden)]
13692impl<'de> serde::de::Deserialize<'de> for Logging {
13693    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13694    where
13695        D: serde::Deserializer<'de>,
13696    {
13697        #[allow(non_camel_case_types)]
13698        #[doc(hidden)]
13699        #[derive(PartialEq, Eq, Hash)]
13700        enum __FieldTag {
13701            __producer_destinations,
13702            __consumer_destinations,
13703            Unknown(std::string::String),
13704        }
13705        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13706            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13707            where
13708                D: serde::Deserializer<'de>,
13709            {
13710                struct Visitor;
13711                impl<'de> serde::de::Visitor<'de> for Visitor {
13712                    type Value = __FieldTag;
13713                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13714                        formatter.write_str("a field name for Logging")
13715                    }
13716                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13717                    where
13718                        E: serde::de::Error,
13719                    {
13720                        use std::result::Result::Ok;
13721                        use std::string::ToString;
13722                        match value {
13723                            "producerDestinations" => Ok(__FieldTag::__producer_destinations),
13724                            "producer_destinations" => Ok(__FieldTag::__producer_destinations),
13725                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
13726                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
13727                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13728                        }
13729                    }
13730                }
13731                deserializer.deserialize_identifier(Visitor)
13732            }
13733        }
13734        struct Visitor;
13735        impl<'de> serde::de::Visitor<'de> for Visitor {
13736            type Value = Logging;
13737            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13738                formatter.write_str("struct Logging")
13739            }
13740            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13741            where
13742                A: serde::de::MapAccess<'de>,
13743            {
13744                #[allow(unused_imports)]
13745                use serde::de::Error;
13746                use std::option::Option::Some;
13747                let mut fields = std::collections::HashSet::new();
13748                let mut result = Self::Value::new();
13749                while let Some(tag) = map.next_key::<__FieldTag>()? {
13750                    #[allow(clippy::match_single_binding)]
13751                    match tag {
13752                        __FieldTag::__producer_destinations => {
13753                            if !fields.insert(__FieldTag::__producer_destinations) {
13754                                return std::result::Result::Err(A::Error::duplicate_field(
13755                                    "multiple values for producer_destinations",
13756                                ));
13757                            }
13758                            result.producer_destinations = map
13759                                .next_value::<std::option::Option<
13760                                    std::vec::Vec<crate::model::logging::LoggingDestination>,
13761                                >>()?
13762                                .unwrap_or_default();
13763                        }
13764                        __FieldTag::__consumer_destinations => {
13765                            if !fields.insert(__FieldTag::__consumer_destinations) {
13766                                return std::result::Result::Err(A::Error::duplicate_field(
13767                                    "multiple values for consumer_destinations",
13768                                ));
13769                            }
13770                            result.consumer_destinations = map
13771                                .next_value::<std::option::Option<
13772                                    std::vec::Vec<crate::model::logging::LoggingDestination>,
13773                                >>()?
13774                                .unwrap_or_default();
13775                        }
13776                        __FieldTag::Unknown(key) => {
13777                            let value = map.next_value::<serde_json::Value>()?;
13778                            result._unknown_fields.insert(key, value);
13779                        }
13780                    }
13781                }
13782                std::result::Result::Ok(result)
13783            }
13784        }
13785        deserializer.deserialize_any(Visitor)
13786    }
13787}
13788
13789#[doc(hidden)]
13790impl serde::ser::Serialize for Logging {
13791    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13792    where
13793        S: serde::ser::Serializer,
13794    {
13795        use serde::ser::SerializeMap;
13796        #[allow(unused_imports)]
13797        use std::option::Option::Some;
13798        let mut state = serializer.serialize_map(std::option::Option::None)?;
13799        if !self.producer_destinations.is_empty() {
13800            state.serialize_entry("producerDestinations", &self.producer_destinations)?;
13801        }
13802        if !self.consumer_destinations.is_empty() {
13803            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
13804        }
13805        if !self._unknown_fields.is_empty() {
13806            for (key, value) in self._unknown_fields.iter() {
13807                state.serialize_entry(key, &value)?;
13808            }
13809        }
13810        state.end()
13811    }
13812}
13813
13814impl std::fmt::Debug for Logging {
13815    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13816        let mut debug_struct = f.debug_struct("Logging");
13817        debug_struct.field("producer_destinations", &self.producer_destinations);
13818        debug_struct.field("consumer_destinations", &self.consumer_destinations);
13819        if !self._unknown_fields.is_empty() {
13820            debug_struct.field("_unknown_fields", &self._unknown_fields);
13821        }
13822        debug_struct.finish()
13823    }
13824}
13825
13826/// Defines additional types related to [Logging].
13827pub mod logging {
13828    #[allow(unused_imports)]
13829    use super::*;
13830
13831    /// Configuration of a specific logging destination (the producer project
13832    /// or the consumer project).
13833    #[derive(Clone, Default, PartialEq)]
13834    #[non_exhaustive]
13835    pub struct LoggingDestination {
13836        /// The monitored resource type. The type must be defined in the
13837        /// [Service.monitored_resources][google.api.Service.monitored_resources]
13838        /// section.
13839        ///
13840        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
13841        pub monitored_resource: std::string::String,
13842
13843        /// Names of the logs to be sent to this destination. Each name must
13844        /// be defined in the [Service.logs][google.api.Service.logs] section. If the
13845        /// log name is not a domain scoped name, it will be automatically prefixed
13846        /// with the service name followed by "/".
13847        ///
13848        /// [google.api.Service.logs]: crate::model::Service::logs
13849        pub logs: std::vec::Vec<std::string::String>,
13850
13851        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13852    }
13853
13854    impl LoggingDestination {
13855        pub fn new() -> Self {
13856            std::default::Default::default()
13857        }
13858
13859        /// Sets the value of [monitored_resource][crate::model::logging::LoggingDestination::monitored_resource].
13860        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
13861            mut self,
13862            v: T,
13863        ) -> Self {
13864            self.monitored_resource = v.into();
13865            self
13866        }
13867
13868        /// Sets the value of [logs][crate::model::logging::LoggingDestination::logs].
13869        pub fn set_logs<T, V>(mut self, v: T) -> Self
13870        where
13871            T: std::iter::IntoIterator<Item = V>,
13872            V: std::convert::Into<std::string::String>,
13873        {
13874            use std::iter::Iterator;
13875            self.logs = v.into_iter().map(|i| i.into()).collect();
13876            self
13877        }
13878    }
13879
13880    impl wkt::message::Message for LoggingDestination {
13881        fn typename() -> &'static str {
13882            "type.googleapis.com/google.api.Logging.LoggingDestination"
13883        }
13884    }
13885
13886    #[doc(hidden)]
13887    impl<'de> serde::de::Deserialize<'de> for LoggingDestination {
13888        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13889        where
13890            D: serde::Deserializer<'de>,
13891        {
13892            #[allow(non_camel_case_types)]
13893            #[doc(hidden)]
13894            #[derive(PartialEq, Eq, Hash)]
13895            enum __FieldTag {
13896                __monitored_resource,
13897                __logs,
13898                Unknown(std::string::String),
13899            }
13900            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13901                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13902                where
13903                    D: serde::Deserializer<'de>,
13904                {
13905                    struct Visitor;
13906                    impl<'de> serde::de::Visitor<'de> for Visitor {
13907                        type Value = __FieldTag;
13908                        fn expecting(
13909                            &self,
13910                            formatter: &mut std::fmt::Formatter,
13911                        ) -> std::fmt::Result {
13912                            formatter.write_str("a field name for LoggingDestination")
13913                        }
13914                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13915                        where
13916                            E: serde::de::Error,
13917                        {
13918                            use std::result::Result::Ok;
13919                            use std::string::ToString;
13920                            match value {
13921                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
13922                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
13923                                "logs" => Ok(__FieldTag::__logs),
13924                                _ => Ok(__FieldTag::Unknown(value.to_string())),
13925                            }
13926                        }
13927                    }
13928                    deserializer.deserialize_identifier(Visitor)
13929                }
13930            }
13931            struct Visitor;
13932            impl<'de> serde::de::Visitor<'de> for Visitor {
13933                type Value = LoggingDestination;
13934                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13935                    formatter.write_str("struct LoggingDestination")
13936                }
13937                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13938                where
13939                    A: serde::de::MapAccess<'de>,
13940                {
13941                    #[allow(unused_imports)]
13942                    use serde::de::Error;
13943                    use std::option::Option::Some;
13944                    let mut fields = std::collections::HashSet::new();
13945                    let mut result = Self::Value::new();
13946                    while let Some(tag) = map.next_key::<__FieldTag>()? {
13947                        #[allow(clippy::match_single_binding)]
13948                        match tag {
13949                            __FieldTag::__monitored_resource => {
13950                                if !fields.insert(__FieldTag::__monitored_resource) {
13951                                    return std::result::Result::Err(A::Error::duplicate_field(
13952                                        "multiple values for monitored_resource",
13953                                    ));
13954                                }
13955                                result.monitored_resource = map
13956                                    .next_value::<std::option::Option<std::string::String>>()?
13957                                    .unwrap_or_default();
13958                            }
13959                            __FieldTag::__logs => {
13960                                if !fields.insert(__FieldTag::__logs) {
13961                                    return std::result::Result::Err(A::Error::duplicate_field(
13962                                        "multiple values for logs",
13963                                    ));
13964                                }
13965                                result.logs = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
13966                            }
13967                            __FieldTag::Unknown(key) => {
13968                                let value = map.next_value::<serde_json::Value>()?;
13969                                result._unknown_fields.insert(key, value);
13970                            }
13971                        }
13972                    }
13973                    std::result::Result::Ok(result)
13974                }
13975            }
13976            deserializer.deserialize_any(Visitor)
13977        }
13978    }
13979
13980    #[doc(hidden)]
13981    impl serde::ser::Serialize for LoggingDestination {
13982        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13983        where
13984            S: serde::ser::Serializer,
13985        {
13986            use serde::ser::SerializeMap;
13987            #[allow(unused_imports)]
13988            use std::option::Option::Some;
13989            let mut state = serializer.serialize_map(std::option::Option::None)?;
13990            if !self.monitored_resource.is_empty() {
13991                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
13992            }
13993            if !self.logs.is_empty() {
13994                state.serialize_entry("logs", &self.logs)?;
13995            }
13996            if !self._unknown_fields.is_empty() {
13997                for (key, value) in self._unknown_fields.iter() {
13998                    state.serialize_entry(key, &value)?;
13999                }
14000            }
14001            state.end()
14002        }
14003    }
14004
14005    impl std::fmt::Debug for LoggingDestination {
14006        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14007            let mut debug_struct = f.debug_struct("LoggingDestination");
14008            debug_struct.field("monitored_resource", &self.monitored_resource);
14009            debug_struct.field("logs", &self.logs);
14010            if !self._unknown_fields.is_empty() {
14011                debug_struct.field("_unknown_fields", &self._unknown_fields);
14012            }
14013            debug_struct.finish()
14014        }
14015    }
14016}
14017
14018/// Defines a metric type and its schema. Once a metric descriptor is created,
14019/// deleting or altering it stops data collection and makes the metric type's
14020/// existing data unusable.
14021#[derive(Clone, Default, PartialEq)]
14022#[non_exhaustive]
14023pub struct MetricDescriptor {
14024    /// The resource name of the metric descriptor.
14025    pub name: std::string::String,
14026
14027    /// The metric type, including its DNS name prefix. The type is not
14028    /// URL-encoded. All user-defined metric types have the DNS name
14029    /// `custom.googleapis.com` or `external.googleapis.com`. Metric types should
14030    /// use a natural hierarchical grouping. For example:
14031    ///
14032    /// ```norust
14033    /// "custom.googleapis.com/invoice/paid/amount"
14034    /// "external.googleapis.com/prometheus/up"
14035    /// "appengine.googleapis.com/http/server/response_latencies"
14036    /// ```
14037    pub r#type: std::string::String,
14038
14039    /// The set of labels that can be used to describe a specific
14040    /// instance of this metric type. For example, the
14041    /// `appengine.googleapis.com/http/server/response_latencies` metric
14042    /// type has a label for the HTTP response code, `response_code`, so
14043    /// you can look at latencies for successful responses or just
14044    /// for responses that failed.
14045    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
14046
14047    /// Whether the metric records instantaneous values, changes to a value, etc.
14048    /// Some combinations of `metric_kind` and `value_type` might not be supported.
14049    pub metric_kind: crate::model::metric_descriptor::MetricKind,
14050
14051    /// Whether the measurement is an integer, a floating-point number, etc.
14052    /// Some combinations of `metric_kind` and `value_type` might not be supported.
14053    pub value_type: crate::model::metric_descriptor::ValueType,
14054
14055    /// The units in which the metric value is reported. It is only applicable
14056    /// if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit`
14057    /// defines the representation of the stored metric values.
14058    ///
14059    /// Different systems might scale the values to be more easily displayed (so a
14060    /// value of `0.02kBy` _might_ be displayed as `20By`, and a value of
14061    /// `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is
14062    /// `kBy`, then the value of the metric is always in thousands of bytes, no
14063    /// matter how it might be displayed.
14064    ///
14065    /// If you want a custom metric to record the exact number of CPU-seconds used
14066    /// by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is
14067    /// `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005
14068    /// CPU-seconds, then the value is written as `12005`.
14069    ///
14070    /// Alternatively, if you want a custom metric to record data in a more
14071    /// granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is
14072    /// `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`),
14073    /// or use `Kis{CPU}` and write `11.723` (which is `12005/1024`).
14074    ///
14075    /// The supported units are a subset of [The Unified Code for Units of
14076    /// Measure](https://unitsofmeasure.org/ucum.html) standard:
14077    ///
14078    /// **Basic units (UNIT)**
14079    ///
14080    /// * `bit`   bit
14081    /// * `By`    byte
14082    /// * `s`     second
14083    /// * `min`   minute
14084    /// * `h`     hour
14085    /// * `d`     day
14086    /// * `1`     dimensionless
14087    ///
14088    /// **Prefixes (PREFIX)**
14089    ///
14090    /// * `k`     kilo    (10^3)
14091    ///
14092    /// * `M`     mega    (10^6)
14093    ///
14094    /// * `G`     giga    (10^9)
14095    ///
14096    /// * `T`     tera    (10^12)
14097    ///
14098    /// * `P`     peta    (10^15)
14099    ///
14100    /// * `E`     exa     (10^18)
14101    ///
14102    /// * `Z`     zetta   (10^21)
14103    ///
14104    /// * `Y`     yotta   (10^24)
14105    ///
14106    /// * `m`     milli   (10^-3)
14107    ///
14108    /// * `u`     micro   (10^-6)
14109    ///
14110    /// * `n`     nano    (10^-9)
14111    ///
14112    /// * `p`     pico    (10^-12)
14113    ///
14114    /// * `f`     femto   (10^-15)
14115    ///
14116    /// * `a`     atto    (10^-18)
14117    ///
14118    /// * `z`     zepto   (10^-21)
14119    ///
14120    /// * `y`     yocto   (10^-24)
14121    ///
14122    /// * `Ki`    kibi    (2^10)
14123    ///
14124    /// * `Mi`    mebi    (2^20)
14125    ///
14126    /// * `Gi`    gibi    (2^30)
14127    ///
14128    /// * `Ti`    tebi    (2^40)
14129    ///
14130    /// * `Pi`    pebi    (2^50)
14131    ///
14132    ///
14133    /// **Grammar**
14134    ///
14135    /// The grammar also includes these connectors:
14136    ///
14137    /// * `/`    division or ratio (as an infix operator). For examples,
14138    ///   `kBy/{email}` or `MiBy/10ms` (although you should almost never
14139    ///   have `/s` in a metric `unit`; rates should always be computed at
14140    ///   query time from the underlying cumulative or delta value).
14141    /// * `.`    multiplication or composition (as an infix operator). For
14142    ///   examples, `GBy.d` or `k{watt}.h`.
14143    ///
14144    /// The grammar for a unit is as follows:
14145    ///
14146    /// ```norust
14147    /// Expression = Component { "." Component } { "/" Component } ;
14148    ///
14149    /// Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ]
14150    ///           | Annotation
14151    ///           | "1"
14152    ///           ;
14153    ///
14154    /// Annotation = "{" NAME "}" ;
14155    /// ```
14156    ///
14157    /// Notes:
14158    ///
14159    /// * `Annotation` is just a comment if it follows a `UNIT`. If the annotation
14160    ///   is used alone, then the unit is equivalent to `1`. For examples,
14161    ///   `{request}/s == 1/s`, `By{transmitted}/s == By/s`.
14162    /// * `NAME` is a sequence of non-blank printable ASCII characters not
14163    ///   containing `{` or `}`.
14164    /// * `1` represents a unitary [dimensionless
14165    ///   unit](https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such
14166    ///   as in `1/s`. It is typically used when none of the basic units are
14167    ///   appropriate. For example, "new users per day" can be represented as
14168    ///   `1/d` or `{new-users}/d` (and a metric value `5` would mean "5 new
14169    ///   users). Alternatively, "thousands of page views per day" would be
14170    ///   represented as `1000/d` or `k1/d` or `k{page_views}/d` (and a metric
14171    ///   value of `5.3` would mean "5300 page views per day").
14172    /// * `%` represents dimensionless value of 1/100, and annotates values giving
14173    ///   a percentage (so the metric values are typically in the range of 0..100,
14174    ///   and a metric value `3` means "3 percent").
14175    /// * `10^2.%` indicates a metric contains a ratio, typically in the range
14176    ///   0..1, that will be multiplied by 100 and displayed as a percentage
14177    ///   (so a metric value `0.03` means "3 percent").
14178    pub unit: std::string::String,
14179
14180    /// A detailed description of the metric, which can be used in documentation.
14181    pub description: std::string::String,
14182
14183    /// A concise name for the metric, which can be displayed in user interfaces.
14184    /// Use sentence case without an ending period, for example "Request count".
14185    /// This field is optional but it is recommended to be set for any metrics
14186    /// associated with user-visible concepts, such as Quota.
14187    pub display_name: std::string::String,
14188
14189    /// Optional. Metadata which can be used to guide usage of the metric.
14190    pub metadata: std::option::Option<crate::model::metric_descriptor::MetricDescriptorMetadata>,
14191
14192    /// Optional. The launch stage of the metric definition.
14193    pub launch_stage: crate::model::LaunchStage,
14194
14195    /// Read-only. If present, then a [time
14196    /// series][google.monitoring.v3.TimeSeries], which is identified partially by
14197    /// a metric type and a
14198    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor], that
14199    /// is associated with this metric type can only be associated with one of the
14200    /// monitored resource types listed here.
14201    ///
14202    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
14203    pub monitored_resource_types: std::vec::Vec<std::string::String>,
14204
14205    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14206}
14207
14208impl MetricDescriptor {
14209    pub fn new() -> Self {
14210        std::default::Default::default()
14211    }
14212
14213    /// Sets the value of [name][crate::model::MetricDescriptor::name].
14214    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14215        self.name = v.into();
14216        self
14217    }
14218
14219    /// Sets the value of [r#type][crate::model::MetricDescriptor::type].
14220    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14221        self.r#type = v.into();
14222        self
14223    }
14224
14225    /// Sets the value of [labels][crate::model::MetricDescriptor::labels].
14226    pub fn set_labels<T, V>(mut self, v: T) -> Self
14227    where
14228        T: std::iter::IntoIterator<Item = V>,
14229        V: std::convert::Into<crate::model::LabelDescriptor>,
14230    {
14231        use std::iter::Iterator;
14232        self.labels = v.into_iter().map(|i| i.into()).collect();
14233        self
14234    }
14235
14236    /// Sets the value of [metric_kind][crate::model::MetricDescriptor::metric_kind].
14237    pub fn set_metric_kind<T: std::convert::Into<crate::model::metric_descriptor::MetricKind>>(
14238        mut self,
14239        v: T,
14240    ) -> Self {
14241        self.metric_kind = v.into();
14242        self
14243    }
14244
14245    /// Sets the value of [value_type][crate::model::MetricDescriptor::value_type].
14246    pub fn set_value_type<T: std::convert::Into<crate::model::metric_descriptor::ValueType>>(
14247        mut self,
14248        v: T,
14249    ) -> Self {
14250        self.value_type = v.into();
14251        self
14252    }
14253
14254    /// Sets the value of [unit][crate::model::MetricDescriptor::unit].
14255    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14256        self.unit = v.into();
14257        self
14258    }
14259
14260    /// Sets the value of [description][crate::model::MetricDescriptor::description].
14261    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14262        self.description = v.into();
14263        self
14264    }
14265
14266    /// Sets the value of [display_name][crate::model::MetricDescriptor::display_name].
14267    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14268        self.display_name = v.into();
14269        self
14270    }
14271
14272    /// Sets the value of [metadata][crate::model::MetricDescriptor::metadata].
14273    pub fn set_metadata<T>(mut self, v: T) -> Self
14274    where
14275        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
14276    {
14277        self.metadata = std::option::Option::Some(v.into());
14278        self
14279    }
14280
14281    /// Sets or clears the value of [metadata][crate::model::MetricDescriptor::metadata].
14282    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
14283    where
14284        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
14285    {
14286        self.metadata = v.map(|x| x.into());
14287        self
14288    }
14289
14290    /// Sets the value of [launch_stage][crate::model::MetricDescriptor::launch_stage].
14291    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
14292        mut self,
14293        v: T,
14294    ) -> Self {
14295        self.launch_stage = v.into();
14296        self
14297    }
14298
14299    /// Sets the value of [monitored_resource_types][crate::model::MetricDescriptor::monitored_resource_types].
14300    pub fn set_monitored_resource_types<T, V>(mut self, v: T) -> Self
14301    where
14302        T: std::iter::IntoIterator<Item = V>,
14303        V: std::convert::Into<std::string::String>,
14304    {
14305        use std::iter::Iterator;
14306        self.monitored_resource_types = v.into_iter().map(|i| i.into()).collect();
14307        self
14308    }
14309}
14310
14311impl wkt::message::Message for MetricDescriptor {
14312    fn typename() -> &'static str {
14313        "type.googleapis.com/google.api.MetricDescriptor"
14314    }
14315}
14316
14317#[doc(hidden)]
14318impl<'de> serde::de::Deserialize<'de> for MetricDescriptor {
14319    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14320    where
14321        D: serde::Deserializer<'de>,
14322    {
14323        #[allow(non_camel_case_types)]
14324        #[doc(hidden)]
14325        #[derive(PartialEq, Eq, Hash)]
14326        enum __FieldTag {
14327            __name,
14328            __type,
14329            __labels,
14330            __metric_kind,
14331            __value_type,
14332            __unit,
14333            __description,
14334            __display_name,
14335            __metadata,
14336            __launch_stage,
14337            __monitored_resource_types,
14338            Unknown(std::string::String),
14339        }
14340        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14341            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14342            where
14343                D: serde::Deserializer<'de>,
14344            {
14345                struct Visitor;
14346                impl<'de> serde::de::Visitor<'de> for Visitor {
14347                    type Value = __FieldTag;
14348                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14349                        formatter.write_str("a field name for MetricDescriptor")
14350                    }
14351                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14352                    where
14353                        E: serde::de::Error,
14354                    {
14355                        use std::result::Result::Ok;
14356                        use std::string::ToString;
14357                        match value {
14358                            "name" => Ok(__FieldTag::__name),
14359                            "type" => Ok(__FieldTag::__type),
14360                            "labels" => Ok(__FieldTag::__labels),
14361                            "metricKind" => Ok(__FieldTag::__metric_kind),
14362                            "metric_kind" => Ok(__FieldTag::__metric_kind),
14363                            "valueType" => Ok(__FieldTag::__value_type),
14364                            "value_type" => Ok(__FieldTag::__value_type),
14365                            "unit" => Ok(__FieldTag::__unit),
14366                            "description" => Ok(__FieldTag::__description),
14367                            "displayName" => Ok(__FieldTag::__display_name),
14368                            "display_name" => Ok(__FieldTag::__display_name),
14369                            "metadata" => Ok(__FieldTag::__metadata),
14370                            "launchStage" => Ok(__FieldTag::__launch_stage),
14371                            "launch_stage" => Ok(__FieldTag::__launch_stage),
14372                            "monitoredResourceTypes" => Ok(__FieldTag::__monitored_resource_types),
14373                            "monitored_resource_types" => {
14374                                Ok(__FieldTag::__monitored_resource_types)
14375                            }
14376                            _ => Ok(__FieldTag::Unknown(value.to_string())),
14377                        }
14378                    }
14379                }
14380                deserializer.deserialize_identifier(Visitor)
14381            }
14382        }
14383        struct Visitor;
14384        impl<'de> serde::de::Visitor<'de> for Visitor {
14385            type Value = MetricDescriptor;
14386            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14387                formatter.write_str("struct MetricDescriptor")
14388            }
14389            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14390            where
14391                A: serde::de::MapAccess<'de>,
14392            {
14393                #[allow(unused_imports)]
14394                use serde::de::Error;
14395                use std::option::Option::Some;
14396                let mut fields = std::collections::HashSet::new();
14397                let mut result = Self::Value::new();
14398                while let Some(tag) = map.next_key::<__FieldTag>()? {
14399                    #[allow(clippy::match_single_binding)]
14400                    match tag {
14401                        __FieldTag::__name => {
14402                            if !fields.insert(__FieldTag::__name) {
14403                                return std::result::Result::Err(A::Error::duplicate_field(
14404                                    "multiple values for name",
14405                                ));
14406                            }
14407                            result.name = map
14408                                .next_value::<std::option::Option<std::string::String>>()?
14409                                .unwrap_or_default();
14410                        }
14411                        __FieldTag::__type => {
14412                            if !fields.insert(__FieldTag::__type) {
14413                                return std::result::Result::Err(A::Error::duplicate_field(
14414                                    "multiple values for type",
14415                                ));
14416                            }
14417                            result.r#type = map
14418                                .next_value::<std::option::Option<std::string::String>>()?
14419                                .unwrap_or_default();
14420                        }
14421                        __FieldTag::__labels => {
14422                            if !fields.insert(__FieldTag::__labels) {
14423                                return std::result::Result::Err(A::Error::duplicate_field(
14424                                    "multiple values for labels",
14425                                ));
14426                            }
14427                            result.labels =
14428                                map.next_value::<std::option::Option<
14429                                    std::vec::Vec<crate::model::LabelDescriptor>,
14430                                >>()?
14431                                .unwrap_or_default();
14432                        }
14433                        __FieldTag::__metric_kind => {
14434                            if !fields.insert(__FieldTag::__metric_kind) {
14435                                return std::result::Result::Err(A::Error::duplicate_field(
14436                                    "multiple values for metric_kind",
14437                                ));
14438                            }
14439                            result.metric_kind =
14440                                map.next_value::<std::option::Option<
14441                                    crate::model::metric_descriptor::MetricKind,
14442                                >>()?
14443                                .unwrap_or_default();
14444                        }
14445                        __FieldTag::__value_type => {
14446                            if !fields.insert(__FieldTag::__value_type) {
14447                                return std::result::Result::Err(A::Error::duplicate_field(
14448                                    "multiple values for value_type",
14449                                ));
14450                            }
14451                            result.value_type = map.next_value::<std::option::Option<crate::model::metric_descriptor::ValueType>>()?.unwrap_or_default();
14452                        }
14453                        __FieldTag::__unit => {
14454                            if !fields.insert(__FieldTag::__unit) {
14455                                return std::result::Result::Err(A::Error::duplicate_field(
14456                                    "multiple values for unit",
14457                                ));
14458                            }
14459                            result.unit = map
14460                                .next_value::<std::option::Option<std::string::String>>()?
14461                                .unwrap_or_default();
14462                        }
14463                        __FieldTag::__description => {
14464                            if !fields.insert(__FieldTag::__description) {
14465                                return std::result::Result::Err(A::Error::duplicate_field(
14466                                    "multiple values for description",
14467                                ));
14468                            }
14469                            result.description = map
14470                                .next_value::<std::option::Option<std::string::String>>()?
14471                                .unwrap_or_default();
14472                        }
14473                        __FieldTag::__display_name => {
14474                            if !fields.insert(__FieldTag::__display_name) {
14475                                return std::result::Result::Err(A::Error::duplicate_field(
14476                                    "multiple values for display_name",
14477                                ));
14478                            }
14479                            result.display_name = map
14480                                .next_value::<std::option::Option<std::string::String>>()?
14481                                .unwrap_or_default();
14482                        }
14483                        __FieldTag::__metadata => {
14484                            if !fields.insert(__FieldTag::__metadata) {
14485                                return std::result::Result::Err(A::Error::duplicate_field(
14486                                    "multiple values for metadata",
14487                                ));
14488                            }
14489                            result.metadata = map.next_value::<std::option::Option<
14490                                crate::model::metric_descriptor::MetricDescriptorMetadata,
14491                            >>()?;
14492                        }
14493                        __FieldTag::__launch_stage => {
14494                            if !fields.insert(__FieldTag::__launch_stage) {
14495                                return std::result::Result::Err(A::Error::duplicate_field(
14496                                    "multiple values for launch_stage",
14497                                ));
14498                            }
14499                            result.launch_stage = map
14500                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
14501                                .unwrap_or_default();
14502                        }
14503                        __FieldTag::__monitored_resource_types => {
14504                            if !fields.insert(__FieldTag::__monitored_resource_types) {
14505                                return std::result::Result::Err(A::Error::duplicate_field(
14506                                    "multiple values for monitored_resource_types",
14507                                ));
14508                            }
14509                            result.monitored_resource_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
14510                        }
14511                        __FieldTag::Unknown(key) => {
14512                            let value = map.next_value::<serde_json::Value>()?;
14513                            result._unknown_fields.insert(key, value);
14514                        }
14515                    }
14516                }
14517                std::result::Result::Ok(result)
14518            }
14519        }
14520        deserializer.deserialize_any(Visitor)
14521    }
14522}
14523
14524#[doc(hidden)]
14525impl serde::ser::Serialize for MetricDescriptor {
14526    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14527    where
14528        S: serde::ser::Serializer,
14529    {
14530        use serde::ser::SerializeMap;
14531        #[allow(unused_imports)]
14532        use std::option::Option::Some;
14533        let mut state = serializer.serialize_map(std::option::Option::None)?;
14534        if !self.name.is_empty() {
14535            state.serialize_entry("name", &self.name)?;
14536        }
14537        if !self.r#type.is_empty() {
14538            state.serialize_entry("type", &self.r#type)?;
14539        }
14540        if !self.labels.is_empty() {
14541            state.serialize_entry("labels", &self.labels)?;
14542        }
14543        if !wkt::internal::is_default(&self.metric_kind) {
14544            state.serialize_entry("metricKind", &self.metric_kind)?;
14545        }
14546        if !wkt::internal::is_default(&self.value_type) {
14547            state.serialize_entry("valueType", &self.value_type)?;
14548        }
14549        if !self.unit.is_empty() {
14550            state.serialize_entry("unit", &self.unit)?;
14551        }
14552        if !self.description.is_empty() {
14553            state.serialize_entry("description", &self.description)?;
14554        }
14555        if !self.display_name.is_empty() {
14556            state.serialize_entry("displayName", &self.display_name)?;
14557        }
14558        if self.metadata.is_some() {
14559            state.serialize_entry("metadata", &self.metadata)?;
14560        }
14561        if !wkt::internal::is_default(&self.launch_stage) {
14562            state.serialize_entry("launchStage", &self.launch_stage)?;
14563        }
14564        if !self.monitored_resource_types.is_empty() {
14565            state.serialize_entry("monitoredResourceTypes", &self.monitored_resource_types)?;
14566        }
14567        if !self._unknown_fields.is_empty() {
14568            for (key, value) in self._unknown_fields.iter() {
14569                state.serialize_entry(key, &value)?;
14570            }
14571        }
14572        state.end()
14573    }
14574}
14575
14576impl std::fmt::Debug for MetricDescriptor {
14577    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14578        let mut debug_struct = f.debug_struct("MetricDescriptor");
14579        debug_struct.field("name", &self.name);
14580        debug_struct.field("r#type", &self.r#type);
14581        debug_struct.field("labels", &self.labels);
14582        debug_struct.field("metric_kind", &self.metric_kind);
14583        debug_struct.field("value_type", &self.value_type);
14584        debug_struct.field("unit", &self.unit);
14585        debug_struct.field("description", &self.description);
14586        debug_struct.field("display_name", &self.display_name);
14587        debug_struct.field("metadata", &self.metadata);
14588        debug_struct.field("launch_stage", &self.launch_stage);
14589        debug_struct.field("monitored_resource_types", &self.monitored_resource_types);
14590        if !self._unknown_fields.is_empty() {
14591            debug_struct.field("_unknown_fields", &self._unknown_fields);
14592        }
14593        debug_struct.finish()
14594    }
14595}
14596
14597/// Defines additional types related to [MetricDescriptor].
14598pub mod metric_descriptor {
14599    #[allow(unused_imports)]
14600    use super::*;
14601
14602    /// Additional annotations that can be used to guide the usage of a metric.
14603    #[derive(Clone, Default, PartialEq)]
14604    #[non_exhaustive]
14605    pub struct MetricDescriptorMetadata {
14606
14607        /// Deprecated. Must use the
14608        /// [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage]
14609        /// instead.
14610        ///
14611        /// [google.api.MetricDescriptor.launch_stage]: crate::model::MetricDescriptor::launch_stage
14612        #[deprecated]
14613        pub launch_stage: crate::model::LaunchStage,
14614
14615        /// The sampling period of metric data points. For metrics which are written
14616        /// periodically, consecutive data points are stored at this time interval,
14617        /// excluding data loss due to errors. Metrics with a higher granularity have
14618        /// a smaller sampling period.
14619        pub sample_period: std::option::Option<wkt::Duration>,
14620
14621        /// The delay of data points caused by ingestion. Data points older than this
14622        /// age are guaranteed to be ingested and available to be read, excluding
14623        /// data loss due to errors.
14624        pub ingest_delay: std::option::Option<wkt::Duration>,
14625
14626        /// The scope of the timeseries data of the metric.
14627        pub time_series_resource_hierarchy_level: std::vec::Vec<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>,
14628
14629        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14630    }
14631
14632    impl MetricDescriptorMetadata {
14633        pub fn new() -> Self {
14634            std::default::Default::default()
14635        }
14636
14637        /// Sets the value of [launch_stage][crate::model::metric_descriptor::MetricDescriptorMetadata::launch_stage].
14638        #[deprecated]
14639        pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
14640            mut self,
14641            v: T,
14642        ) -> Self {
14643            self.launch_stage = v.into();
14644            self
14645        }
14646
14647        /// Sets the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
14648        pub fn set_sample_period<T>(mut self, v: T) -> Self
14649        where
14650            T: std::convert::Into<wkt::Duration>,
14651        {
14652            self.sample_period = std::option::Option::Some(v.into());
14653            self
14654        }
14655
14656        /// Sets or clears the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
14657        pub fn set_or_clear_sample_period<T>(mut self, v: std::option::Option<T>) -> Self
14658        where
14659            T: std::convert::Into<wkt::Duration>,
14660        {
14661            self.sample_period = v.map(|x| x.into());
14662            self
14663        }
14664
14665        /// Sets the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
14666        pub fn set_ingest_delay<T>(mut self, v: T) -> Self
14667        where
14668            T: std::convert::Into<wkt::Duration>,
14669        {
14670            self.ingest_delay = std::option::Option::Some(v.into());
14671            self
14672        }
14673
14674        /// Sets or clears the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
14675        pub fn set_or_clear_ingest_delay<T>(mut self, v: std::option::Option<T>) -> Self
14676        where
14677            T: std::convert::Into<wkt::Duration>,
14678        {
14679            self.ingest_delay = v.map(|x| x.into());
14680            self
14681        }
14682
14683        /// Sets the value of [time_series_resource_hierarchy_level][crate::model::metric_descriptor::MetricDescriptorMetadata::time_series_resource_hierarchy_level].
14684        pub fn set_time_series_resource_hierarchy_level<T, V>(mut self, v: T) -> Self
14685        where
14686            T: std::iter::IntoIterator<Item = V>,
14687            V: std::convert::Into<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>
14688        {
14689            use std::iter::Iterator;
14690            self.time_series_resource_hierarchy_level = v.into_iter().map(|i| i.into()).collect();
14691            self
14692        }
14693    }
14694
14695    impl wkt::message::Message for MetricDescriptorMetadata {
14696        fn typename() -> &'static str {
14697            "type.googleapis.com/google.api.MetricDescriptor.MetricDescriptorMetadata"
14698        }
14699    }
14700
14701    #[doc(hidden)]
14702    impl<'de> serde::de::Deserialize<'de> for MetricDescriptorMetadata {
14703        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14704        where
14705            D: serde::Deserializer<'de>,
14706        {
14707            #[allow(non_camel_case_types)]
14708            #[doc(hidden)]
14709            #[derive(PartialEq, Eq, Hash)]
14710            enum __FieldTag {
14711                __launch_stage,
14712                __sample_period,
14713                __ingest_delay,
14714                __time_series_resource_hierarchy_level,
14715                Unknown(std::string::String),
14716            }
14717            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14718                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14719                where
14720                    D: serde::Deserializer<'de>,
14721                {
14722                    struct Visitor;
14723                    impl<'de> serde::de::Visitor<'de> for Visitor {
14724                        type Value = __FieldTag;
14725                        fn expecting(
14726                            &self,
14727                            formatter: &mut std::fmt::Formatter,
14728                        ) -> std::fmt::Result {
14729                            formatter.write_str("a field name for MetricDescriptorMetadata")
14730                        }
14731                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14732                        where
14733                            E: serde::de::Error,
14734                        {
14735                            use std::result::Result::Ok;
14736                            use std::string::ToString;
14737                            match value {
14738                                "launchStage" => Ok(__FieldTag::__launch_stage),
14739                                "launch_stage" => Ok(__FieldTag::__launch_stage),
14740                                "samplePeriod" => Ok(__FieldTag::__sample_period),
14741                                "sample_period" => Ok(__FieldTag::__sample_period),
14742                                "ingestDelay" => Ok(__FieldTag::__ingest_delay),
14743                                "ingest_delay" => Ok(__FieldTag::__ingest_delay),
14744                                "timeSeriesResourceHierarchyLevel" => {
14745                                    Ok(__FieldTag::__time_series_resource_hierarchy_level)
14746                                }
14747                                "time_series_resource_hierarchy_level" => {
14748                                    Ok(__FieldTag::__time_series_resource_hierarchy_level)
14749                                }
14750                                _ => Ok(__FieldTag::Unknown(value.to_string())),
14751                            }
14752                        }
14753                    }
14754                    deserializer.deserialize_identifier(Visitor)
14755                }
14756            }
14757            struct Visitor;
14758            impl<'de> serde::de::Visitor<'de> for Visitor {
14759                type Value = MetricDescriptorMetadata;
14760                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14761                    formatter.write_str("struct MetricDescriptorMetadata")
14762                }
14763                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14764                where
14765                    A: serde::de::MapAccess<'de>,
14766                {
14767                    #[allow(unused_imports)]
14768                    use serde::de::Error;
14769                    use std::option::Option::Some;
14770                    let mut fields = std::collections::HashSet::new();
14771                    let mut result = Self::Value::new();
14772                    while let Some(tag) = map.next_key::<__FieldTag>()? {
14773                        #[allow(clippy::match_single_binding)]
14774                        match tag {
14775                            __FieldTag::__launch_stage => {
14776                                if !fields.insert(__FieldTag::__launch_stage) {
14777                                    return std::result::Result::Err(A::Error::duplicate_field(
14778                                        "multiple values for launch_stage",
14779                                    ));
14780                                }
14781                                result.launch_stage = map
14782                                    .next_value::<std::option::Option<crate::model::LaunchStage>>()?
14783                                    .unwrap_or_default();
14784                            }
14785                            __FieldTag::__sample_period => {
14786                                if !fields.insert(__FieldTag::__sample_period) {
14787                                    return std::result::Result::Err(A::Error::duplicate_field(
14788                                        "multiple values for sample_period",
14789                                    ));
14790                                }
14791                                result.sample_period =
14792                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14793                            }
14794                            __FieldTag::__ingest_delay => {
14795                                if !fields.insert(__FieldTag::__ingest_delay) {
14796                                    return std::result::Result::Err(A::Error::duplicate_field(
14797                                        "multiple values for ingest_delay",
14798                                    ));
14799                                }
14800                                result.ingest_delay =
14801                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14802                            }
14803                            __FieldTag::__time_series_resource_hierarchy_level => {
14804                                if !fields
14805                                    .insert(__FieldTag::__time_series_resource_hierarchy_level)
14806                                {
14807                                    return std::result::Result::Err(A::Error::duplicate_field(
14808                                        "multiple values for time_series_resource_hierarchy_level",
14809                                    ));
14810                                }
14811                                result.time_series_resource_hierarchy_level = map.next_value::<std::option::Option<std::vec::Vec<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>>>()?.unwrap_or_default();
14812                            }
14813                            __FieldTag::Unknown(key) => {
14814                                let value = map.next_value::<serde_json::Value>()?;
14815                                result._unknown_fields.insert(key, value);
14816                            }
14817                        }
14818                    }
14819                    std::result::Result::Ok(result)
14820                }
14821            }
14822            deserializer.deserialize_any(Visitor)
14823        }
14824    }
14825
14826    #[doc(hidden)]
14827    impl serde::ser::Serialize for MetricDescriptorMetadata {
14828        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14829        where
14830            S: serde::ser::Serializer,
14831        {
14832            use serde::ser::SerializeMap;
14833            #[allow(unused_imports)]
14834            use std::option::Option::Some;
14835            let mut state = serializer.serialize_map(std::option::Option::None)?;
14836            if !wkt::internal::is_default(&self.launch_stage) {
14837                state.serialize_entry("launchStage", &self.launch_stage)?;
14838            }
14839            if self.sample_period.is_some() {
14840                state.serialize_entry("samplePeriod", &self.sample_period)?;
14841            }
14842            if self.ingest_delay.is_some() {
14843                state.serialize_entry("ingestDelay", &self.ingest_delay)?;
14844            }
14845            if !self.time_series_resource_hierarchy_level.is_empty() {
14846                state.serialize_entry(
14847                    "timeSeriesResourceHierarchyLevel",
14848                    &self.time_series_resource_hierarchy_level,
14849                )?;
14850            }
14851            if !self._unknown_fields.is_empty() {
14852                for (key, value) in self._unknown_fields.iter() {
14853                    state.serialize_entry(key, &value)?;
14854                }
14855            }
14856            state.end()
14857        }
14858    }
14859
14860    impl std::fmt::Debug for MetricDescriptorMetadata {
14861        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14862            let mut debug_struct = f.debug_struct("MetricDescriptorMetadata");
14863            debug_struct.field("launch_stage", &self.launch_stage);
14864            debug_struct.field("sample_period", &self.sample_period);
14865            debug_struct.field("ingest_delay", &self.ingest_delay);
14866            debug_struct.field(
14867                "time_series_resource_hierarchy_level",
14868                &self.time_series_resource_hierarchy_level,
14869            );
14870            if !self._unknown_fields.is_empty() {
14871                debug_struct.field("_unknown_fields", &self._unknown_fields);
14872            }
14873            debug_struct.finish()
14874        }
14875    }
14876
14877    /// Defines additional types related to [MetricDescriptorMetadata].
14878    pub mod metric_descriptor_metadata {
14879        #[allow(unused_imports)]
14880        use super::*;
14881
14882        /// The resource hierarchy level of the timeseries data of a metric.
14883        ///
14884        /// # Working with unknown values
14885        ///
14886        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
14887        /// additional enum variants at any time. Adding new variants is not considered
14888        /// a breaking change. Applications should write their code in anticipation of:
14889        ///
14890        /// - New values appearing in future releases of the client library, **and**
14891        /// - New values received dynamically, without application changes.
14892        ///
14893        /// Please consult the [Working with enums] section in the user guide for some
14894        /// guidelines.
14895        ///
14896        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
14897        #[derive(Clone, Debug, PartialEq)]
14898        #[non_exhaustive]
14899        pub enum TimeSeriesResourceHierarchyLevel {
14900            /// Do not use this default value.
14901            Unspecified,
14902            /// Scopes a metric to a project.
14903            Project,
14904            /// Scopes a metric to an organization.
14905            Organization,
14906            /// Scopes a metric to a folder.
14907            Folder,
14908            /// If set, the enum was initialized with an unknown value.
14909            ///
14910            /// Applications can examine the value using [TimeSeriesResourceHierarchyLevel::value] or
14911            /// [TimeSeriesResourceHierarchyLevel::name].
14912            UnknownValue(time_series_resource_hierarchy_level::UnknownValue),
14913        }
14914
14915        #[doc(hidden)]
14916        pub mod time_series_resource_hierarchy_level {
14917            #[allow(unused_imports)]
14918            use super::*;
14919            #[derive(Clone, Debug, PartialEq)]
14920            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
14921        }
14922
14923        impl TimeSeriesResourceHierarchyLevel {
14924            /// Gets the enum value.
14925            ///
14926            /// Returns `None` if the enum contains an unknown value deserialized from
14927            /// the string representation of enums.
14928            pub fn value(&self) -> std::option::Option<i32> {
14929                match self {
14930                    Self::Unspecified => std::option::Option::Some(0),
14931                    Self::Project => std::option::Option::Some(1),
14932                    Self::Organization => std::option::Option::Some(2),
14933                    Self::Folder => std::option::Option::Some(3),
14934                    Self::UnknownValue(u) => u.0.value(),
14935                }
14936            }
14937
14938            /// Gets the enum value as a string.
14939            ///
14940            /// Returns `None` if the enum contains an unknown value deserialized from
14941            /// the integer representation of enums.
14942            pub fn name(&self) -> std::option::Option<&str> {
14943                match self {
14944                    Self::Unspecified => std::option::Option::Some(
14945                        "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED",
14946                    ),
14947                    Self::Project => std::option::Option::Some("PROJECT"),
14948                    Self::Organization => std::option::Option::Some("ORGANIZATION"),
14949                    Self::Folder => std::option::Option::Some("FOLDER"),
14950                    Self::UnknownValue(u) => u.0.name(),
14951                }
14952            }
14953        }
14954
14955        impl std::default::Default for TimeSeriesResourceHierarchyLevel {
14956            fn default() -> Self {
14957                use std::convert::From;
14958                Self::from(0)
14959            }
14960        }
14961
14962        impl std::fmt::Display for TimeSeriesResourceHierarchyLevel {
14963            fn fmt(
14964                &self,
14965                f: &mut std::fmt::Formatter<'_>,
14966            ) -> std::result::Result<(), std::fmt::Error> {
14967                wkt::internal::display_enum(f, self.name(), self.value())
14968            }
14969        }
14970
14971        impl std::convert::From<i32> for TimeSeriesResourceHierarchyLevel {
14972            fn from(value: i32) -> Self {
14973                match value {
14974                    0 => Self::Unspecified,
14975                    1 => Self::Project,
14976                    2 => Self::Organization,
14977                    3 => Self::Folder,
14978                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
14979                        wkt::internal::UnknownEnumValue::Integer(value),
14980                    )),
14981                }
14982            }
14983        }
14984
14985        impl std::convert::From<&str> for TimeSeriesResourceHierarchyLevel {
14986            fn from(value: &str) -> Self {
14987                use std::string::ToString;
14988                match value {
14989                    "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED" => Self::Unspecified,
14990                    "PROJECT" => Self::Project,
14991                    "ORGANIZATION" => Self::Organization,
14992                    "FOLDER" => Self::Folder,
14993                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
14994                        wkt::internal::UnknownEnumValue::String(value.to_string()),
14995                    )),
14996                }
14997            }
14998        }
14999
15000        impl serde::ser::Serialize for TimeSeriesResourceHierarchyLevel {
15001            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15002            where
15003                S: serde::Serializer,
15004            {
15005                match self {
15006                    Self::Unspecified => serializer.serialize_i32(0),
15007                    Self::Project => serializer.serialize_i32(1),
15008                    Self::Organization => serializer.serialize_i32(2),
15009                    Self::Folder => serializer.serialize_i32(3),
15010                    Self::UnknownValue(u) => u.0.serialize(serializer),
15011                }
15012            }
15013        }
15014
15015        impl<'de> serde::de::Deserialize<'de> for TimeSeriesResourceHierarchyLevel {
15016            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15017            where
15018                D: serde::Deserializer<'de>,
15019            {
15020                deserializer.deserialize_any(wkt::internal::EnumVisitor::<TimeSeriesResourceHierarchyLevel>::new(
15021                    ".google.api.MetricDescriptor.MetricDescriptorMetadata.TimeSeriesResourceHierarchyLevel"))
15022            }
15023        }
15024    }
15025
15026    /// The kind of measurement. It describes how the data is reported.
15027    /// For information on setting the start time and end time based on
15028    /// the MetricKind, see [TimeInterval][google.monitoring.v3.TimeInterval].
15029    ///
15030    /// # Working with unknown values
15031    ///
15032    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
15033    /// additional enum variants at any time. Adding new variants is not considered
15034    /// a breaking change. Applications should write their code in anticipation of:
15035    ///
15036    /// - New values appearing in future releases of the client library, **and**
15037    /// - New values received dynamically, without application changes.
15038    ///
15039    /// Please consult the [Working with enums] section in the user guide for some
15040    /// guidelines.
15041    ///
15042    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
15043    #[derive(Clone, Debug, PartialEq)]
15044    #[non_exhaustive]
15045    pub enum MetricKind {
15046        /// Do not use this default value.
15047        Unspecified,
15048        /// An instantaneous measurement of a value.
15049        Gauge,
15050        /// The change in a value during a time interval.
15051        Delta,
15052        /// A value accumulated over a time interval.  Cumulative
15053        /// measurements in a time series should have the same start time
15054        /// and increasing end times, until an event resets the cumulative
15055        /// value to zero and sets a new start time for the following
15056        /// points.
15057        Cumulative,
15058        /// If set, the enum was initialized with an unknown value.
15059        ///
15060        /// Applications can examine the value using [MetricKind::value] or
15061        /// [MetricKind::name].
15062        UnknownValue(metric_kind::UnknownValue),
15063    }
15064
15065    #[doc(hidden)]
15066    pub mod metric_kind {
15067        #[allow(unused_imports)]
15068        use super::*;
15069        #[derive(Clone, Debug, PartialEq)]
15070        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
15071    }
15072
15073    impl MetricKind {
15074        /// Gets the enum value.
15075        ///
15076        /// Returns `None` if the enum contains an unknown value deserialized from
15077        /// the string representation of enums.
15078        pub fn value(&self) -> std::option::Option<i32> {
15079            match self {
15080                Self::Unspecified => std::option::Option::Some(0),
15081                Self::Gauge => std::option::Option::Some(1),
15082                Self::Delta => std::option::Option::Some(2),
15083                Self::Cumulative => std::option::Option::Some(3),
15084                Self::UnknownValue(u) => u.0.value(),
15085            }
15086        }
15087
15088        /// Gets the enum value as a string.
15089        ///
15090        /// Returns `None` if the enum contains an unknown value deserialized from
15091        /// the integer representation of enums.
15092        pub fn name(&self) -> std::option::Option<&str> {
15093            match self {
15094                Self::Unspecified => std::option::Option::Some("METRIC_KIND_UNSPECIFIED"),
15095                Self::Gauge => std::option::Option::Some("GAUGE"),
15096                Self::Delta => std::option::Option::Some("DELTA"),
15097                Self::Cumulative => std::option::Option::Some("CUMULATIVE"),
15098                Self::UnknownValue(u) => u.0.name(),
15099            }
15100        }
15101    }
15102
15103    impl std::default::Default for MetricKind {
15104        fn default() -> Self {
15105            use std::convert::From;
15106            Self::from(0)
15107        }
15108    }
15109
15110    impl std::fmt::Display for MetricKind {
15111        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
15112            wkt::internal::display_enum(f, self.name(), self.value())
15113        }
15114    }
15115
15116    impl std::convert::From<i32> for MetricKind {
15117        fn from(value: i32) -> Self {
15118            match value {
15119                0 => Self::Unspecified,
15120                1 => Self::Gauge,
15121                2 => Self::Delta,
15122                3 => Self::Cumulative,
15123                _ => Self::UnknownValue(metric_kind::UnknownValue(
15124                    wkt::internal::UnknownEnumValue::Integer(value),
15125                )),
15126            }
15127        }
15128    }
15129
15130    impl std::convert::From<&str> for MetricKind {
15131        fn from(value: &str) -> Self {
15132            use std::string::ToString;
15133            match value {
15134                "METRIC_KIND_UNSPECIFIED" => Self::Unspecified,
15135                "GAUGE" => Self::Gauge,
15136                "DELTA" => Self::Delta,
15137                "CUMULATIVE" => Self::Cumulative,
15138                _ => Self::UnknownValue(metric_kind::UnknownValue(
15139                    wkt::internal::UnknownEnumValue::String(value.to_string()),
15140                )),
15141            }
15142        }
15143    }
15144
15145    impl serde::ser::Serialize for MetricKind {
15146        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15147        where
15148            S: serde::Serializer,
15149        {
15150            match self {
15151                Self::Unspecified => serializer.serialize_i32(0),
15152                Self::Gauge => serializer.serialize_i32(1),
15153                Self::Delta => serializer.serialize_i32(2),
15154                Self::Cumulative => serializer.serialize_i32(3),
15155                Self::UnknownValue(u) => u.0.serialize(serializer),
15156            }
15157        }
15158    }
15159
15160    impl<'de> serde::de::Deserialize<'de> for MetricKind {
15161        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15162        where
15163            D: serde::Deserializer<'de>,
15164        {
15165            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MetricKind>::new(
15166                ".google.api.MetricDescriptor.MetricKind",
15167            ))
15168        }
15169    }
15170
15171    /// The value type of a metric.
15172    ///
15173    /// # Working with unknown values
15174    ///
15175    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
15176    /// additional enum variants at any time. Adding new variants is not considered
15177    /// a breaking change. Applications should write their code in anticipation of:
15178    ///
15179    /// - New values appearing in future releases of the client library, **and**
15180    /// - New values received dynamically, without application changes.
15181    ///
15182    /// Please consult the [Working with enums] section in the user guide for some
15183    /// guidelines.
15184    ///
15185    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
15186    #[derive(Clone, Debug, PartialEq)]
15187    #[non_exhaustive]
15188    pub enum ValueType {
15189        /// Do not use this default value.
15190        Unspecified,
15191        /// The value is a boolean.
15192        /// This value type can be used only if the metric kind is `GAUGE`.
15193        Bool,
15194        /// The value is a signed 64-bit integer.
15195        Int64,
15196        /// The value is a double precision floating point number.
15197        Double,
15198        /// The value is a text string.
15199        /// This value type can be used only if the metric kind is `GAUGE`.
15200        String,
15201        /// The value is a [`Distribution`][google.api.Distribution].
15202        ///
15203        /// [google.api.Distribution]: crate::model::Distribution
15204        Distribution,
15205        /// The value is money.
15206        Money,
15207        /// If set, the enum was initialized with an unknown value.
15208        ///
15209        /// Applications can examine the value using [ValueType::value] or
15210        /// [ValueType::name].
15211        UnknownValue(value_type::UnknownValue),
15212    }
15213
15214    #[doc(hidden)]
15215    pub mod value_type {
15216        #[allow(unused_imports)]
15217        use super::*;
15218        #[derive(Clone, Debug, PartialEq)]
15219        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
15220    }
15221
15222    impl ValueType {
15223        /// Gets the enum value.
15224        ///
15225        /// Returns `None` if the enum contains an unknown value deserialized from
15226        /// the string representation of enums.
15227        pub fn value(&self) -> std::option::Option<i32> {
15228            match self {
15229                Self::Unspecified => std::option::Option::Some(0),
15230                Self::Bool => std::option::Option::Some(1),
15231                Self::Int64 => std::option::Option::Some(2),
15232                Self::Double => std::option::Option::Some(3),
15233                Self::String => std::option::Option::Some(4),
15234                Self::Distribution => std::option::Option::Some(5),
15235                Self::Money => std::option::Option::Some(6),
15236                Self::UnknownValue(u) => u.0.value(),
15237            }
15238        }
15239
15240        /// Gets the enum value as a string.
15241        ///
15242        /// Returns `None` if the enum contains an unknown value deserialized from
15243        /// the integer representation of enums.
15244        pub fn name(&self) -> std::option::Option<&str> {
15245            match self {
15246                Self::Unspecified => std::option::Option::Some("VALUE_TYPE_UNSPECIFIED"),
15247                Self::Bool => std::option::Option::Some("BOOL"),
15248                Self::Int64 => std::option::Option::Some("INT64"),
15249                Self::Double => std::option::Option::Some("DOUBLE"),
15250                Self::String => std::option::Option::Some("STRING"),
15251                Self::Distribution => std::option::Option::Some("DISTRIBUTION"),
15252                Self::Money => std::option::Option::Some("MONEY"),
15253                Self::UnknownValue(u) => u.0.name(),
15254            }
15255        }
15256    }
15257
15258    impl std::default::Default for ValueType {
15259        fn default() -> Self {
15260            use std::convert::From;
15261            Self::from(0)
15262        }
15263    }
15264
15265    impl std::fmt::Display for ValueType {
15266        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
15267            wkt::internal::display_enum(f, self.name(), self.value())
15268        }
15269    }
15270
15271    impl std::convert::From<i32> for ValueType {
15272        fn from(value: i32) -> Self {
15273            match value {
15274                0 => Self::Unspecified,
15275                1 => Self::Bool,
15276                2 => Self::Int64,
15277                3 => Self::Double,
15278                4 => Self::String,
15279                5 => Self::Distribution,
15280                6 => Self::Money,
15281                _ => Self::UnknownValue(value_type::UnknownValue(
15282                    wkt::internal::UnknownEnumValue::Integer(value),
15283                )),
15284            }
15285        }
15286    }
15287
15288    impl std::convert::From<&str> for ValueType {
15289        fn from(value: &str) -> Self {
15290            use std::string::ToString;
15291            match value {
15292                "VALUE_TYPE_UNSPECIFIED" => Self::Unspecified,
15293                "BOOL" => Self::Bool,
15294                "INT64" => Self::Int64,
15295                "DOUBLE" => Self::Double,
15296                "STRING" => Self::String,
15297                "DISTRIBUTION" => Self::Distribution,
15298                "MONEY" => Self::Money,
15299                _ => Self::UnknownValue(value_type::UnknownValue(
15300                    wkt::internal::UnknownEnumValue::String(value.to_string()),
15301                )),
15302            }
15303        }
15304    }
15305
15306    impl serde::ser::Serialize for ValueType {
15307        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15308        where
15309            S: serde::Serializer,
15310        {
15311            match self {
15312                Self::Unspecified => serializer.serialize_i32(0),
15313                Self::Bool => serializer.serialize_i32(1),
15314                Self::Int64 => serializer.serialize_i32(2),
15315                Self::Double => serializer.serialize_i32(3),
15316                Self::String => serializer.serialize_i32(4),
15317                Self::Distribution => serializer.serialize_i32(5),
15318                Self::Money => serializer.serialize_i32(6),
15319                Self::UnknownValue(u) => u.0.serialize(serializer),
15320            }
15321        }
15322    }
15323
15324    impl<'de> serde::de::Deserialize<'de> for ValueType {
15325        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15326        where
15327            D: serde::Deserializer<'de>,
15328        {
15329            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
15330                ".google.api.MetricDescriptor.ValueType",
15331            ))
15332        }
15333    }
15334}
15335
15336/// A specific metric, identified by specifying values for all of the
15337/// labels of a [`MetricDescriptor`][google.api.MetricDescriptor].
15338///
15339/// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
15340#[derive(Clone, Default, PartialEq)]
15341#[non_exhaustive]
15342pub struct Metric {
15343    /// An existing metric type, see
15344    /// [google.api.MetricDescriptor][google.api.MetricDescriptor]. For example,
15345    /// `custom.googleapis.com/invoice/paid/amount`.
15346    ///
15347    /// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
15348    pub r#type: std::string::String,
15349
15350    /// The set of label values that uniquely identify this metric. All
15351    /// labels listed in the `MetricDescriptor` must be assigned values.
15352    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
15353
15354    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15355}
15356
15357impl Metric {
15358    pub fn new() -> Self {
15359        std::default::Default::default()
15360    }
15361
15362    /// Sets the value of [r#type][crate::model::Metric::type].
15363    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15364        self.r#type = v.into();
15365        self
15366    }
15367
15368    /// Sets the value of [labels][crate::model::Metric::labels].
15369    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
15370    where
15371        T: std::iter::IntoIterator<Item = (K, V)>,
15372        K: std::convert::Into<std::string::String>,
15373        V: std::convert::Into<std::string::String>,
15374    {
15375        use std::iter::Iterator;
15376        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15377        self
15378    }
15379}
15380
15381impl wkt::message::Message for Metric {
15382    fn typename() -> &'static str {
15383        "type.googleapis.com/google.api.Metric"
15384    }
15385}
15386
15387#[doc(hidden)]
15388impl<'de> serde::de::Deserialize<'de> for Metric {
15389    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15390    where
15391        D: serde::Deserializer<'de>,
15392    {
15393        #[allow(non_camel_case_types)]
15394        #[doc(hidden)]
15395        #[derive(PartialEq, Eq, Hash)]
15396        enum __FieldTag {
15397            __type,
15398            __labels,
15399            Unknown(std::string::String),
15400        }
15401        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15402            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15403            where
15404                D: serde::Deserializer<'de>,
15405            {
15406                struct Visitor;
15407                impl<'de> serde::de::Visitor<'de> for Visitor {
15408                    type Value = __FieldTag;
15409                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15410                        formatter.write_str("a field name for Metric")
15411                    }
15412                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15413                    where
15414                        E: serde::de::Error,
15415                    {
15416                        use std::result::Result::Ok;
15417                        use std::string::ToString;
15418                        match value {
15419                            "type" => Ok(__FieldTag::__type),
15420                            "labels" => Ok(__FieldTag::__labels),
15421                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15422                        }
15423                    }
15424                }
15425                deserializer.deserialize_identifier(Visitor)
15426            }
15427        }
15428        struct Visitor;
15429        impl<'de> serde::de::Visitor<'de> for Visitor {
15430            type Value = Metric;
15431            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15432                formatter.write_str("struct Metric")
15433            }
15434            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15435            where
15436                A: serde::de::MapAccess<'de>,
15437            {
15438                #[allow(unused_imports)]
15439                use serde::de::Error;
15440                use std::option::Option::Some;
15441                let mut fields = std::collections::HashSet::new();
15442                let mut result = Self::Value::new();
15443                while let Some(tag) = map.next_key::<__FieldTag>()? {
15444                    #[allow(clippy::match_single_binding)]
15445                    match tag {
15446                        __FieldTag::__type => {
15447                            if !fields.insert(__FieldTag::__type) {
15448                                return std::result::Result::Err(A::Error::duplicate_field(
15449                                    "multiple values for type",
15450                                ));
15451                            }
15452                            result.r#type = map
15453                                .next_value::<std::option::Option<std::string::String>>()?
15454                                .unwrap_or_default();
15455                        }
15456                        __FieldTag::__labels => {
15457                            if !fields.insert(__FieldTag::__labels) {
15458                                return std::result::Result::Err(A::Error::duplicate_field(
15459                                    "multiple values for labels",
15460                                ));
15461                            }
15462                            result.labels = map
15463                                .next_value::<std::option::Option<
15464                                    std::collections::HashMap<
15465                                        std::string::String,
15466                                        std::string::String,
15467                                    >,
15468                                >>()?
15469                                .unwrap_or_default();
15470                        }
15471                        __FieldTag::Unknown(key) => {
15472                            let value = map.next_value::<serde_json::Value>()?;
15473                            result._unknown_fields.insert(key, value);
15474                        }
15475                    }
15476                }
15477                std::result::Result::Ok(result)
15478            }
15479        }
15480        deserializer.deserialize_any(Visitor)
15481    }
15482}
15483
15484#[doc(hidden)]
15485impl serde::ser::Serialize for Metric {
15486    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15487    where
15488        S: serde::ser::Serializer,
15489    {
15490        use serde::ser::SerializeMap;
15491        #[allow(unused_imports)]
15492        use std::option::Option::Some;
15493        let mut state = serializer.serialize_map(std::option::Option::None)?;
15494        if !self.r#type.is_empty() {
15495            state.serialize_entry("type", &self.r#type)?;
15496        }
15497        if !self.labels.is_empty() {
15498            state.serialize_entry("labels", &self.labels)?;
15499        }
15500        if !self._unknown_fields.is_empty() {
15501            for (key, value) in self._unknown_fields.iter() {
15502                state.serialize_entry(key, &value)?;
15503            }
15504        }
15505        state.end()
15506    }
15507}
15508
15509impl std::fmt::Debug for Metric {
15510    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15511        let mut debug_struct = f.debug_struct("Metric");
15512        debug_struct.field("r#type", &self.r#type);
15513        debug_struct.field("labels", &self.labels);
15514        if !self._unknown_fields.is_empty() {
15515            debug_struct.field("_unknown_fields", &self._unknown_fields);
15516        }
15517        debug_struct.finish()
15518    }
15519}
15520
15521/// An object that describes the schema of a
15522/// [MonitoredResource][google.api.MonitoredResource] object using a type name
15523/// and a set of labels.  For example, the monitored resource descriptor for
15524/// Google Compute Engine VM instances has a type of
15525/// `"gce_instance"` and specifies the use of the labels `"instance_id"` and
15526/// `"zone"` to identify particular VM instances.
15527///
15528/// Different APIs can support different monitored resource types. APIs generally
15529/// provide a `list` method that returns the monitored resource descriptors used
15530/// by the API.
15531///
15532/// [google.api.MonitoredResource]: crate::model::MonitoredResource
15533#[derive(Clone, Default, PartialEq)]
15534#[non_exhaustive]
15535pub struct MonitoredResourceDescriptor {
15536    /// Optional. The resource name of the monitored resource descriptor:
15537    /// `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where
15538    /// {type} is the value of the `type` field in this object and
15539    /// {project_id} is a project ID that provides API-specific context for
15540    /// accessing the type.  APIs that do not use project information can use the
15541    /// resource name format `"monitoredResourceDescriptors/{type}"`.
15542    pub name: std::string::String,
15543
15544    /// Required. The monitored resource type. For example, the type
15545    /// `"cloudsql_database"` represents databases in Google Cloud SQL.
15546    /// For a list of types, see [Monitored resource
15547    /// types](https://cloud.google.com/monitoring/api/resources)
15548    /// and [Logging resource
15549    /// types](https://cloud.google.com/logging/docs/api/v2/resource-list).
15550    pub r#type: std::string::String,
15551
15552    /// Optional. A concise name for the monitored resource type that might be
15553    /// displayed in user interfaces. It should be a Title Cased Noun Phrase,
15554    /// without any article or other determiners. For example,
15555    /// `"Google Cloud SQL Database"`.
15556    pub display_name: std::string::String,
15557
15558    /// Optional. A detailed description of the monitored resource type that might
15559    /// be used in documentation.
15560    pub description: std::string::String,
15561
15562    /// Required. A set of labels used to describe instances of this monitored
15563    /// resource type. For example, an individual Google Cloud SQL database is
15564    /// identified by values for the labels `"database_id"` and `"zone"`.
15565    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
15566
15567    /// Optional. The launch stage of the monitored resource definition.
15568    pub launch_stage: crate::model::LaunchStage,
15569
15570    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15571}
15572
15573impl MonitoredResourceDescriptor {
15574    pub fn new() -> Self {
15575        std::default::Default::default()
15576    }
15577
15578    /// Sets the value of [name][crate::model::MonitoredResourceDescriptor::name].
15579    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15580        self.name = v.into();
15581        self
15582    }
15583
15584    /// Sets the value of [r#type][crate::model::MonitoredResourceDescriptor::type].
15585    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15586        self.r#type = v.into();
15587        self
15588    }
15589
15590    /// Sets the value of [display_name][crate::model::MonitoredResourceDescriptor::display_name].
15591    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15592        self.display_name = v.into();
15593        self
15594    }
15595
15596    /// Sets the value of [description][crate::model::MonitoredResourceDescriptor::description].
15597    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15598        self.description = v.into();
15599        self
15600    }
15601
15602    /// Sets the value of [labels][crate::model::MonitoredResourceDescriptor::labels].
15603    pub fn set_labels<T, V>(mut self, v: T) -> Self
15604    where
15605        T: std::iter::IntoIterator<Item = V>,
15606        V: std::convert::Into<crate::model::LabelDescriptor>,
15607    {
15608        use std::iter::Iterator;
15609        self.labels = v.into_iter().map(|i| i.into()).collect();
15610        self
15611    }
15612
15613    /// Sets the value of [launch_stage][crate::model::MonitoredResourceDescriptor::launch_stage].
15614    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
15615        mut self,
15616        v: T,
15617    ) -> Self {
15618        self.launch_stage = v.into();
15619        self
15620    }
15621}
15622
15623impl wkt::message::Message for MonitoredResourceDescriptor {
15624    fn typename() -> &'static str {
15625        "type.googleapis.com/google.api.MonitoredResourceDescriptor"
15626    }
15627}
15628
15629#[doc(hidden)]
15630impl<'de> serde::de::Deserialize<'de> for MonitoredResourceDescriptor {
15631    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15632    where
15633        D: serde::Deserializer<'de>,
15634    {
15635        #[allow(non_camel_case_types)]
15636        #[doc(hidden)]
15637        #[derive(PartialEq, Eq, Hash)]
15638        enum __FieldTag {
15639            __name,
15640            __type,
15641            __display_name,
15642            __description,
15643            __labels,
15644            __launch_stage,
15645            Unknown(std::string::String),
15646        }
15647        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15648            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15649            where
15650                D: serde::Deserializer<'de>,
15651            {
15652                struct Visitor;
15653                impl<'de> serde::de::Visitor<'de> for Visitor {
15654                    type Value = __FieldTag;
15655                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15656                        formatter.write_str("a field name for MonitoredResourceDescriptor")
15657                    }
15658                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15659                    where
15660                        E: serde::de::Error,
15661                    {
15662                        use std::result::Result::Ok;
15663                        use std::string::ToString;
15664                        match value {
15665                            "name" => Ok(__FieldTag::__name),
15666                            "type" => Ok(__FieldTag::__type),
15667                            "displayName" => Ok(__FieldTag::__display_name),
15668                            "display_name" => Ok(__FieldTag::__display_name),
15669                            "description" => Ok(__FieldTag::__description),
15670                            "labels" => Ok(__FieldTag::__labels),
15671                            "launchStage" => Ok(__FieldTag::__launch_stage),
15672                            "launch_stage" => Ok(__FieldTag::__launch_stage),
15673                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15674                        }
15675                    }
15676                }
15677                deserializer.deserialize_identifier(Visitor)
15678            }
15679        }
15680        struct Visitor;
15681        impl<'de> serde::de::Visitor<'de> for Visitor {
15682            type Value = MonitoredResourceDescriptor;
15683            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15684                formatter.write_str("struct MonitoredResourceDescriptor")
15685            }
15686            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15687            where
15688                A: serde::de::MapAccess<'de>,
15689            {
15690                #[allow(unused_imports)]
15691                use serde::de::Error;
15692                use std::option::Option::Some;
15693                let mut fields = std::collections::HashSet::new();
15694                let mut result = Self::Value::new();
15695                while let Some(tag) = map.next_key::<__FieldTag>()? {
15696                    #[allow(clippy::match_single_binding)]
15697                    match tag {
15698                        __FieldTag::__name => {
15699                            if !fields.insert(__FieldTag::__name) {
15700                                return std::result::Result::Err(A::Error::duplicate_field(
15701                                    "multiple values for name",
15702                                ));
15703                            }
15704                            result.name = map
15705                                .next_value::<std::option::Option<std::string::String>>()?
15706                                .unwrap_or_default();
15707                        }
15708                        __FieldTag::__type => {
15709                            if !fields.insert(__FieldTag::__type) {
15710                                return std::result::Result::Err(A::Error::duplicate_field(
15711                                    "multiple values for type",
15712                                ));
15713                            }
15714                            result.r#type = map
15715                                .next_value::<std::option::Option<std::string::String>>()?
15716                                .unwrap_or_default();
15717                        }
15718                        __FieldTag::__display_name => {
15719                            if !fields.insert(__FieldTag::__display_name) {
15720                                return std::result::Result::Err(A::Error::duplicate_field(
15721                                    "multiple values for display_name",
15722                                ));
15723                            }
15724                            result.display_name = map
15725                                .next_value::<std::option::Option<std::string::String>>()?
15726                                .unwrap_or_default();
15727                        }
15728                        __FieldTag::__description => {
15729                            if !fields.insert(__FieldTag::__description) {
15730                                return std::result::Result::Err(A::Error::duplicate_field(
15731                                    "multiple values for description",
15732                                ));
15733                            }
15734                            result.description = map
15735                                .next_value::<std::option::Option<std::string::String>>()?
15736                                .unwrap_or_default();
15737                        }
15738                        __FieldTag::__labels => {
15739                            if !fields.insert(__FieldTag::__labels) {
15740                                return std::result::Result::Err(A::Error::duplicate_field(
15741                                    "multiple values for labels",
15742                                ));
15743                            }
15744                            result.labels =
15745                                map.next_value::<std::option::Option<
15746                                    std::vec::Vec<crate::model::LabelDescriptor>,
15747                                >>()?
15748                                .unwrap_or_default();
15749                        }
15750                        __FieldTag::__launch_stage => {
15751                            if !fields.insert(__FieldTag::__launch_stage) {
15752                                return std::result::Result::Err(A::Error::duplicate_field(
15753                                    "multiple values for launch_stage",
15754                                ));
15755                            }
15756                            result.launch_stage = map
15757                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
15758                                .unwrap_or_default();
15759                        }
15760                        __FieldTag::Unknown(key) => {
15761                            let value = map.next_value::<serde_json::Value>()?;
15762                            result._unknown_fields.insert(key, value);
15763                        }
15764                    }
15765                }
15766                std::result::Result::Ok(result)
15767            }
15768        }
15769        deserializer.deserialize_any(Visitor)
15770    }
15771}
15772
15773#[doc(hidden)]
15774impl serde::ser::Serialize for MonitoredResourceDescriptor {
15775    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15776    where
15777        S: serde::ser::Serializer,
15778    {
15779        use serde::ser::SerializeMap;
15780        #[allow(unused_imports)]
15781        use std::option::Option::Some;
15782        let mut state = serializer.serialize_map(std::option::Option::None)?;
15783        if !self.name.is_empty() {
15784            state.serialize_entry("name", &self.name)?;
15785        }
15786        if !self.r#type.is_empty() {
15787            state.serialize_entry("type", &self.r#type)?;
15788        }
15789        if !self.display_name.is_empty() {
15790            state.serialize_entry("displayName", &self.display_name)?;
15791        }
15792        if !self.description.is_empty() {
15793            state.serialize_entry("description", &self.description)?;
15794        }
15795        if !self.labels.is_empty() {
15796            state.serialize_entry("labels", &self.labels)?;
15797        }
15798        if !wkt::internal::is_default(&self.launch_stage) {
15799            state.serialize_entry("launchStage", &self.launch_stage)?;
15800        }
15801        if !self._unknown_fields.is_empty() {
15802            for (key, value) in self._unknown_fields.iter() {
15803                state.serialize_entry(key, &value)?;
15804            }
15805        }
15806        state.end()
15807    }
15808}
15809
15810impl std::fmt::Debug for MonitoredResourceDescriptor {
15811    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15812        let mut debug_struct = f.debug_struct("MonitoredResourceDescriptor");
15813        debug_struct.field("name", &self.name);
15814        debug_struct.field("r#type", &self.r#type);
15815        debug_struct.field("display_name", &self.display_name);
15816        debug_struct.field("description", &self.description);
15817        debug_struct.field("labels", &self.labels);
15818        debug_struct.field("launch_stage", &self.launch_stage);
15819        if !self._unknown_fields.is_empty() {
15820            debug_struct.field("_unknown_fields", &self._unknown_fields);
15821        }
15822        debug_struct.finish()
15823    }
15824}
15825
15826/// An object representing a resource that can be used for monitoring, logging,
15827/// billing, or other purposes. Examples include virtual machine instances,
15828/// databases, and storage devices such as disks. The `type` field identifies a
15829/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object
15830/// that describes the resource's schema. Information in the `labels` field
15831/// identifies the actual resource and its attributes according to the schema.
15832/// For example, a particular Compute Engine VM instance could be represented by
15833/// the following object, because the
15834/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for
15835/// `"gce_instance"` has labels
15836/// `"project_id"`, `"instance_id"` and `"zone"`:
15837///
15838/// ```norust
15839/// { "type": "gce_instance",
15840///   "labels": { "project_id": "my-project",
15841///               "instance_id": "12345678901234",
15842///               "zone": "us-central1-a" }}
15843/// ```
15844///
15845/// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
15846#[derive(Clone, Default, PartialEq)]
15847#[non_exhaustive]
15848pub struct MonitoredResource {
15849    /// Required. The monitored resource type. This field must match
15850    /// the `type` field of a
15851    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor]
15852    /// object. For example, the type of a Compute Engine VM instance is
15853    /// `gce_instance`. Some descriptors include the service name in the type; for
15854    /// example, the type of a Datastream stream is
15855    /// `datastream.googleapis.com/Stream`.
15856    ///
15857    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
15858    pub r#type: std::string::String,
15859
15860    /// Required. Values for all of the labels listed in the associated monitored
15861    /// resource descriptor. For example, Compute Engine VM instances use the
15862    /// labels `"project_id"`, `"instance_id"`, and `"zone"`.
15863    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
15864
15865    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15866}
15867
15868impl MonitoredResource {
15869    pub fn new() -> Self {
15870        std::default::Default::default()
15871    }
15872
15873    /// Sets the value of [r#type][crate::model::MonitoredResource::type].
15874    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15875        self.r#type = v.into();
15876        self
15877    }
15878
15879    /// Sets the value of [labels][crate::model::MonitoredResource::labels].
15880    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
15881    where
15882        T: std::iter::IntoIterator<Item = (K, V)>,
15883        K: std::convert::Into<std::string::String>,
15884        V: std::convert::Into<std::string::String>,
15885    {
15886        use std::iter::Iterator;
15887        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15888        self
15889    }
15890}
15891
15892impl wkt::message::Message for MonitoredResource {
15893    fn typename() -> &'static str {
15894        "type.googleapis.com/google.api.MonitoredResource"
15895    }
15896}
15897
15898#[doc(hidden)]
15899impl<'de> serde::de::Deserialize<'de> for MonitoredResource {
15900    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15901    where
15902        D: serde::Deserializer<'de>,
15903    {
15904        #[allow(non_camel_case_types)]
15905        #[doc(hidden)]
15906        #[derive(PartialEq, Eq, Hash)]
15907        enum __FieldTag {
15908            __type,
15909            __labels,
15910            Unknown(std::string::String),
15911        }
15912        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15913            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15914            where
15915                D: serde::Deserializer<'de>,
15916            {
15917                struct Visitor;
15918                impl<'de> serde::de::Visitor<'de> for Visitor {
15919                    type Value = __FieldTag;
15920                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15921                        formatter.write_str("a field name for MonitoredResource")
15922                    }
15923                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15924                    where
15925                        E: serde::de::Error,
15926                    {
15927                        use std::result::Result::Ok;
15928                        use std::string::ToString;
15929                        match value {
15930                            "type" => Ok(__FieldTag::__type),
15931                            "labels" => Ok(__FieldTag::__labels),
15932                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15933                        }
15934                    }
15935                }
15936                deserializer.deserialize_identifier(Visitor)
15937            }
15938        }
15939        struct Visitor;
15940        impl<'de> serde::de::Visitor<'de> for Visitor {
15941            type Value = MonitoredResource;
15942            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15943                formatter.write_str("struct MonitoredResource")
15944            }
15945            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15946            where
15947                A: serde::de::MapAccess<'de>,
15948            {
15949                #[allow(unused_imports)]
15950                use serde::de::Error;
15951                use std::option::Option::Some;
15952                let mut fields = std::collections::HashSet::new();
15953                let mut result = Self::Value::new();
15954                while let Some(tag) = map.next_key::<__FieldTag>()? {
15955                    #[allow(clippy::match_single_binding)]
15956                    match tag {
15957                        __FieldTag::__type => {
15958                            if !fields.insert(__FieldTag::__type) {
15959                                return std::result::Result::Err(A::Error::duplicate_field(
15960                                    "multiple values for type",
15961                                ));
15962                            }
15963                            result.r#type = map
15964                                .next_value::<std::option::Option<std::string::String>>()?
15965                                .unwrap_or_default();
15966                        }
15967                        __FieldTag::__labels => {
15968                            if !fields.insert(__FieldTag::__labels) {
15969                                return std::result::Result::Err(A::Error::duplicate_field(
15970                                    "multiple values for labels",
15971                                ));
15972                            }
15973                            result.labels = map
15974                                .next_value::<std::option::Option<
15975                                    std::collections::HashMap<
15976                                        std::string::String,
15977                                        std::string::String,
15978                                    >,
15979                                >>()?
15980                                .unwrap_or_default();
15981                        }
15982                        __FieldTag::Unknown(key) => {
15983                            let value = map.next_value::<serde_json::Value>()?;
15984                            result._unknown_fields.insert(key, value);
15985                        }
15986                    }
15987                }
15988                std::result::Result::Ok(result)
15989            }
15990        }
15991        deserializer.deserialize_any(Visitor)
15992    }
15993}
15994
15995#[doc(hidden)]
15996impl serde::ser::Serialize for MonitoredResource {
15997    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15998    where
15999        S: serde::ser::Serializer,
16000    {
16001        use serde::ser::SerializeMap;
16002        #[allow(unused_imports)]
16003        use std::option::Option::Some;
16004        let mut state = serializer.serialize_map(std::option::Option::None)?;
16005        if !self.r#type.is_empty() {
16006            state.serialize_entry("type", &self.r#type)?;
16007        }
16008        if !self.labels.is_empty() {
16009            state.serialize_entry("labels", &self.labels)?;
16010        }
16011        if !self._unknown_fields.is_empty() {
16012            for (key, value) in self._unknown_fields.iter() {
16013                state.serialize_entry(key, &value)?;
16014            }
16015        }
16016        state.end()
16017    }
16018}
16019
16020impl std::fmt::Debug for MonitoredResource {
16021    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16022        let mut debug_struct = f.debug_struct("MonitoredResource");
16023        debug_struct.field("r#type", &self.r#type);
16024        debug_struct.field("labels", &self.labels);
16025        if !self._unknown_fields.is_empty() {
16026            debug_struct.field("_unknown_fields", &self._unknown_fields);
16027        }
16028        debug_struct.finish()
16029    }
16030}
16031
16032/// Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource]
16033/// object. [MonitoredResource][google.api.MonitoredResource] objects contain the
16034/// minimum set of information to uniquely identify a monitored resource
16035/// instance. There is some other useful auxiliary metadata. Monitoring and
16036/// Logging use an ingestion pipeline to extract metadata for cloud resources of
16037/// all types, and store the metadata in this message.
16038///
16039/// [google.api.MonitoredResource]: crate::model::MonitoredResource
16040#[derive(Clone, Default, PartialEq)]
16041#[non_exhaustive]
16042pub struct MonitoredResourceMetadata {
16043    /// Output only. Values for predefined system metadata labels.
16044    /// System labels are a kind of metadata extracted by Google, including
16045    /// "machine_image", "vpc", "subnet_id",
16046    /// "security_group", "name", etc.
16047    /// System label values can be only strings, Boolean values, or a list of
16048    /// strings. For example:
16049    ///
16050    /// ```norust
16051    /// { "name": "my-test-instance",
16052    ///   "security_group": ["a", "b", "c"],
16053    ///   "spot_instance": false }
16054    /// ```
16055    pub system_labels: std::option::Option<wkt::Struct>,
16056
16057    /// Output only. A map of user-defined metadata labels.
16058    pub user_labels: std::collections::HashMap<std::string::String, std::string::String>,
16059
16060    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16061}
16062
16063impl MonitoredResourceMetadata {
16064    pub fn new() -> Self {
16065        std::default::Default::default()
16066    }
16067
16068    /// Sets the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
16069    pub fn set_system_labels<T>(mut self, v: T) -> Self
16070    where
16071        T: std::convert::Into<wkt::Struct>,
16072    {
16073        self.system_labels = std::option::Option::Some(v.into());
16074        self
16075    }
16076
16077    /// Sets or clears the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
16078    pub fn set_or_clear_system_labels<T>(mut self, v: std::option::Option<T>) -> Self
16079    where
16080        T: std::convert::Into<wkt::Struct>,
16081    {
16082        self.system_labels = v.map(|x| x.into());
16083        self
16084    }
16085
16086    /// Sets the value of [user_labels][crate::model::MonitoredResourceMetadata::user_labels].
16087    pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
16088    where
16089        T: std::iter::IntoIterator<Item = (K, V)>,
16090        K: std::convert::Into<std::string::String>,
16091        V: std::convert::Into<std::string::String>,
16092    {
16093        use std::iter::Iterator;
16094        self.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
16095        self
16096    }
16097}
16098
16099impl wkt::message::Message for MonitoredResourceMetadata {
16100    fn typename() -> &'static str {
16101        "type.googleapis.com/google.api.MonitoredResourceMetadata"
16102    }
16103}
16104
16105#[doc(hidden)]
16106impl<'de> serde::de::Deserialize<'de> for MonitoredResourceMetadata {
16107    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16108    where
16109        D: serde::Deserializer<'de>,
16110    {
16111        #[allow(non_camel_case_types)]
16112        #[doc(hidden)]
16113        #[derive(PartialEq, Eq, Hash)]
16114        enum __FieldTag {
16115            __system_labels,
16116            __user_labels,
16117            Unknown(std::string::String),
16118        }
16119        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16120            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16121            where
16122                D: serde::Deserializer<'de>,
16123            {
16124                struct Visitor;
16125                impl<'de> serde::de::Visitor<'de> for Visitor {
16126                    type Value = __FieldTag;
16127                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16128                        formatter.write_str("a field name for MonitoredResourceMetadata")
16129                    }
16130                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16131                    where
16132                        E: serde::de::Error,
16133                    {
16134                        use std::result::Result::Ok;
16135                        use std::string::ToString;
16136                        match value {
16137                            "systemLabels" => Ok(__FieldTag::__system_labels),
16138                            "system_labels" => Ok(__FieldTag::__system_labels),
16139                            "userLabels" => Ok(__FieldTag::__user_labels),
16140                            "user_labels" => Ok(__FieldTag::__user_labels),
16141                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16142                        }
16143                    }
16144                }
16145                deserializer.deserialize_identifier(Visitor)
16146            }
16147        }
16148        struct Visitor;
16149        impl<'de> serde::de::Visitor<'de> for Visitor {
16150            type Value = MonitoredResourceMetadata;
16151            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16152                formatter.write_str("struct MonitoredResourceMetadata")
16153            }
16154            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16155            where
16156                A: serde::de::MapAccess<'de>,
16157            {
16158                #[allow(unused_imports)]
16159                use serde::de::Error;
16160                use std::option::Option::Some;
16161                let mut fields = std::collections::HashSet::new();
16162                let mut result = Self::Value::new();
16163                while let Some(tag) = map.next_key::<__FieldTag>()? {
16164                    #[allow(clippy::match_single_binding)]
16165                    match tag {
16166                        __FieldTag::__system_labels => {
16167                            if !fields.insert(__FieldTag::__system_labels) {
16168                                return std::result::Result::Err(A::Error::duplicate_field(
16169                                    "multiple values for system_labels",
16170                                ));
16171                            }
16172                            result.system_labels =
16173                                map.next_value::<std::option::Option<wkt::Struct>>()?;
16174                        }
16175                        __FieldTag::__user_labels => {
16176                            if !fields.insert(__FieldTag::__user_labels) {
16177                                return std::result::Result::Err(A::Error::duplicate_field(
16178                                    "multiple values for user_labels",
16179                                ));
16180                            }
16181                            result.user_labels = map
16182                                .next_value::<std::option::Option<
16183                                    std::collections::HashMap<
16184                                        std::string::String,
16185                                        std::string::String,
16186                                    >,
16187                                >>()?
16188                                .unwrap_or_default();
16189                        }
16190                        __FieldTag::Unknown(key) => {
16191                            let value = map.next_value::<serde_json::Value>()?;
16192                            result._unknown_fields.insert(key, value);
16193                        }
16194                    }
16195                }
16196                std::result::Result::Ok(result)
16197            }
16198        }
16199        deserializer.deserialize_any(Visitor)
16200    }
16201}
16202
16203#[doc(hidden)]
16204impl serde::ser::Serialize for MonitoredResourceMetadata {
16205    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16206    where
16207        S: serde::ser::Serializer,
16208    {
16209        use serde::ser::SerializeMap;
16210        #[allow(unused_imports)]
16211        use std::option::Option::Some;
16212        let mut state = serializer.serialize_map(std::option::Option::None)?;
16213        if self.system_labels.is_some() {
16214            state.serialize_entry("systemLabels", &self.system_labels)?;
16215        }
16216        if !self.user_labels.is_empty() {
16217            state.serialize_entry("userLabels", &self.user_labels)?;
16218        }
16219        if !self._unknown_fields.is_empty() {
16220            for (key, value) in self._unknown_fields.iter() {
16221                state.serialize_entry(key, &value)?;
16222            }
16223        }
16224        state.end()
16225    }
16226}
16227
16228impl std::fmt::Debug for MonitoredResourceMetadata {
16229    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16230        let mut debug_struct = f.debug_struct("MonitoredResourceMetadata");
16231        debug_struct.field("system_labels", &self.system_labels);
16232        debug_struct.field("user_labels", &self.user_labels);
16233        if !self._unknown_fields.is_empty() {
16234            debug_struct.field("_unknown_fields", &self._unknown_fields);
16235        }
16236        debug_struct.finish()
16237    }
16238}
16239
16240/// Monitoring configuration of the service.
16241///
16242/// The example below shows how to configure monitored resources and metrics
16243/// for monitoring. In the example, a monitored resource and two metrics are
16244/// defined. The `library.googleapis.com/book/returned_count` metric is sent
16245/// to both producer and consumer projects, whereas the
16246/// `library.googleapis.com/book/num_overdue` metric is only sent to the
16247/// consumer project.
16248///
16249/// ```norust
16250/// monitored_resources:
16251/// - type: library.googleapis.com/Branch
16252///   display_name: "Library Branch"
16253///   description: "A branch of a library."
16254///   launch_stage: GA
16255///   labels:
16256///   - key: resource_container
16257///     description: "The Cloud container (ie. project id) for the Branch."
16258///   - key: location
16259///     description: "The location of the library branch."
16260///   - key: branch_id
16261///     description: "The id of the branch."
16262/// metrics:
16263/// - name: library.googleapis.com/book/returned_count
16264///   display_name: "Books Returned"
16265///   description: "The count of books that have been returned."
16266///   launch_stage: GA
16267///   metric_kind: DELTA
16268///   value_type: INT64
16269///   unit: "1"
16270///   labels:
16271///   - key: customer_id
16272///     description: "The id of the customer."
16273/// - name: library.googleapis.com/book/num_overdue
16274///   display_name: "Books Overdue"
16275///   description: "The current number of overdue books."
16276///   launch_stage: GA
16277///   metric_kind: GAUGE
16278///   value_type: INT64
16279///   unit: "1"
16280///   labels:
16281///   - key: customer_id
16282///     description: "The id of the customer."
16283/// monitoring:
16284///   producer_destinations:
16285///   - monitored_resource: library.googleapis.com/Branch
16286///     metrics:
16287///     - library.googleapis.com/book/returned_count
16288///   consumer_destinations:
16289///   - monitored_resource: library.googleapis.com/Branch
16290///     metrics:
16291///     - library.googleapis.com/book/returned_count
16292///     - library.googleapis.com/book/num_overdue
16293/// ```
16294#[derive(Clone, Default, PartialEq)]
16295#[non_exhaustive]
16296pub struct Monitoring {
16297    /// Monitoring configurations for sending metrics to the producer project.
16298    /// There can be multiple producer destinations. A monitored resource type may
16299    /// appear in multiple monitoring destinations if different aggregations are
16300    /// needed for different sets of metrics associated with that monitored
16301    /// resource type. A monitored resource and metric pair may only be used once
16302    /// in the Monitoring configuration.
16303    pub producer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
16304
16305    /// Monitoring configurations for sending metrics to the consumer project.
16306    /// There can be multiple consumer destinations. A monitored resource type may
16307    /// appear in multiple monitoring destinations if different aggregations are
16308    /// needed for different sets of metrics associated with that monitored
16309    /// resource type. A monitored resource and metric pair may only be used once
16310    /// in the Monitoring configuration.
16311    pub consumer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
16312
16313    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16314}
16315
16316impl Monitoring {
16317    pub fn new() -> Self {
16318        std::default::Default::default()
16319    }
16320
16321    /// Sets the value of [producer_destinations][crate::model::Monitoring::producer_destinations].
16322    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
16323    where
16324        T: std::iter::IntoIterator<Item = V>,
16325        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
16326    {
16327        use std::iter::Iterator;
16328        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
16329        self
16330    }
16331
16332    /// Sets the value of [consumer_destinations][crate::model::Monitoring::consumer_destinations].
16333    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
16334    where
16335        T: std::iter::IntoIterator<Item = V>,
16336        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
16337    {
16338        use std::iter::Iterator;
16339        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
16340        self
16341    }
16342}
16343
16344impl wkt::message::Message for Monitoring {
16345    fn typename() -> &'static str {
16346        "type.googleapis.com/google.api.Monitoring"
16347    }
16348}
16349
16350#[doc(hidden)]
16351impl<'de> serde::de::Deserialize<'de> for Monitoring {
16352    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16353    where
16354        D: serde::Deserializer<'de>,
16355    {
16356        #[allow(non_camel_case_types)]
16357        #[doc(hidden)]
16358        #[derive(PartialEq, Eq, Hash)]
16359        enum __FieldTag {
16360            __producer_destinations,
16361            __consumer_destinations,
16362            Unknown(std::string::String),
16363        }
16364        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16365            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16366            where
16367                D: serde::Deserializer<'de>,
16368            {
16369                struct Visitor;
16370                impl<'de> serde::de::Visitor<'de> for Visitor {
16371                    type Value = __FieldTag;
16372                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16373                        formatter.write_str("a field name for Monitoring")
16374                    }
16375                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16376                    where
16377                        E: serde::de::Error,
16378                    {
16379                        use std::result::Result::Ok;
16380                        use std::string::ToString;
16381                        match value {
16382                            "producerDestinations" => Ok(__FieldTag::__producer_destinations),
16383                            "producer_destinations" => Ok(__FieldTag::__producer_destinations),
16384                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
16385                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
16386                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16387                        }
16388                    }
16389                }
16390                deserializer.deserialize_identifier(Visitor)
16391            }
16392        }
16393        struct Visitor;
16394        impl<'de> serde::de::Visitor<'de> for Visitor {
16395            type Value = Monitoring;
16396            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16397                formatter.write_str("struct Monitoring")
16398            }
16399            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16400            where
16401                A: serde::de::MapAccess<'de>,
16402            {
16403                #[allow(unused_imports)]
16404                use serde::de::Error;
16405                use std::option::Option::Some;
16406                let mut fields = std::collections::HashSet::new();
16407                let mut result = Self::Value::new();
16408                while let Some(tag) = map.next_key::<__FieldTag>()? {
16409                    #[allow(clippy::match_single_binding)]
16410                    match tag {
16411                        __FieldTag::__producer_destinations => {
16412                            if !fields.insert(__FieldTag::__producer_destinations) {
16413                                return std::result::Result::Err(A::Error::duplicate_field(
16414                                    "multiple values for producer_destinations",
16415                                ));
16416                            }
16417                            result.producer_destinations = map
16418                                .next_value::<std::option::Option<
16419                                    std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
16420                                >>()?
16421                                .unwrap_or_default();
16422                        }
16423                        __FieldTag::__consumer_destinations => {
16424                            if !fields.insert(__FieldTag::__consumer_destinations) {
16425                                return std::result::Result::Err(A::Error::duplicate_field(
16426                                    "multiple values for consumer_destinations",
16427                                ));
16428                            }
16429                            result.consumer_destinations = map
16430                                .next_value::<std::option::Option<
16431                                    std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
16432                                >>()?
16433                                .unwrap_or_default();
16434                        }
16435                        __FieldTag::Unknown(key) => {
16436                            let value = map.next_value::<serde_json::Value>()?;
16437                            result._unknown_fields.insert(key, value);
16438                        }
16439                    }
16440                }
16441                std::result::Result::Ok(result)
16442            }
16443        }
16444        deserializer.deserialize_any(Visitor)
16445    }
16446}
16447
16448#[doc(hidden)]
16449impl serde::ser::Serialize for Monitoring {
16450    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16451    where
16452        S: serde::ser::Serializer,
16453    {
16454        use serde::ser::SerializeMap;
16455        #[allow(unused_imports)]
16456        use std::option::Option::Some;
16457        let mut state = serializer.serialize_map(std::option::Option::None)?;
16458        if !self.producer_destinations.is_empty() {
16459            state.serialize_entry("producerDestinations", &self.producer_destinations)?;
16460        }
16461        if !self.consumer_destinations.is_empty() {
16462            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
16463        }
16464        if !self._unknown_fields.is_empty() {
16465            for (key, value) in self._unknown_fields.iter() {
16466                state.serialize_entry(key, &value)?;
16467            }
16468        }
16469        state.end()
16470    }
16471}
16472
16473impl std::fmt::Debug for Monitoring {
16474    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16475        let mut debug_struct = f.debug_struct("Monitoring");
16476        debug_struct.field("producer_destinations", &self.producer_destinations);
16477        debug_struct.field("consumer_destinations", &self.consumer_destinations);
16478        if !self._unknown_fields.is_empty() {
16479            debug_struct.field("_unknown_fields", &self._unknown_fields);
16480        }
16481        debug_struct.finish()
16482    }
16483}
16484
16485/// Defines additional types related to [Monitoring].
16486pub mod monitoring {
16487    #[allow(unused_imports)]
16488    use super::*;
16489
16490    /// Configuration of a specific monitoring destination (the producer project
16491    /// or the consumer project).
16492    #[derive(Clone, Default, PartialEq)]
16493    #[non_exhaustive]
16494    pub struct MonitoringDestination {
16495        /// The monitored resource type. The type must be defined in
16496        /// [Service.monitored_resources][google.api.Service.monitored_resources]
16497        /// section.
16498        ///
16499        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
16500        pub monitored_resource: std::string::String,
16501
16502        /// Types of the metrics to report to this monitoring destination.
16503        /// Each type must be defined in
16504        /// [Service.metrics][google.api.Service.metrics] section.
16505        ///
16506        /// [google.api.Service.metrics]: crate::model::Service::metrics
16507        pub metrics: std::vec::Vec<std::string::String>,
16508
16509        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16510    }
16511
16512    impl MonitoringDestination {
16513        pub fn new() -> Self {
16514            std::default::Default::default()
16515        }
16516
16517        /// Sets the value of [monitored_resource][crate::model::monitoring::MonitoringDestination::monitored_resource].
16518        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
16519            mut self,
16520            v: T,
16521        ) -> Self {
16522            self.monitored_resource = v.into();
16523            self
16524        }
16525
16526        /// Sets the value of [metrics][crate::model::monitoring::MonitoringDestination::metrics].
16527        pub fn set_metrics<T, V>(mut self, v: T) -> Self
16528        where
16529            T: std::iter::IntoIterator<Item = V>,
16530            V: std::convert::Into<std::string::String>,
16531        {
16532            use std::iter::Iterator;
16533            self.metrics = v.into_iter().map(|i| i.into()).collect();
16534            self
16535        }
16536    }
16537
16538    impl wkt::message::Message for MonitoringDestination {
16539        fn typename() -> &'static str {
16540            "type.googleapis.com/google.api.Monitoring.MonitoringDestination"
16541        }
16542    }
16543
16544    #[doc(hidden)]
16545    impl<'de> serde::de::Deserialize<'de> for MonitoringDestination {
16546        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16547        where
16548            D: serde::Deserializer<'de>,
16549        {
16550            #[allow(non_camel_case_types)]
16551            #[doc(hidden)]
16552            #[derive(PartialEq, Eq, Hash)]
16553            enum __FieldTag {
16554                __monitored_resource,
16555                __metrics,
16556                Unknown(std::string::String),
16557            }
16558            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16559                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16560                where
16561                    D: serde::Deserializer<'de>,
16562                {
16563                    struct Visitor;
16564                    impl<'de> serde::de::Visitor<'de> for Visitor {
16565                        type Value = __FieldTag;
16566                        fn expecting(
16567                            &self,
16568                            formatter: &mut std::fmt::Formatter,
16569                        ) -> std::fmt::Result {
16570                            formatter.write_str("a field name for MonitoringDestination")
16571                        }
16572                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16573                        where
16574                            E: serde::de::Error,
16575                        {
16576                            use std::result::Result::Ok;
16577                            use std::string::ToString;
16578                            match value {
16579                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
16580                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
16581                                "metrics" => Ok(__FieldTag::__metrics),
16582                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16583                            }
16584                        }
16585                    }
16586                    deserializer.deserialize_identifier(Visitor)
16587                }
16588            }
16589            struct Visitor;
16590            impl<'de> serde::de::Visitor<'de> for Visitor {
16591                type Value = MonitoringDestination;
16592                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16593                    formatter.write_str("struct MonitoringDestination")
16594                }
16595                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16596                where
16597                    A: serde::de::MapAccess<'de>,
16598                {
16599                    #[allow(unused_imports)]
16600                    use serde::de::Error;
16601                    use std::option::Option::Some;
16602                    let mut fields = std::collections::HashSet::new();
16603                    let mut result = Self::Value::new();
16604                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16605                        #[allow(clippy::match_single_binding)]
16606                        match tag {
16607                            __FieldTag::__monitored_resource => {
16608                                if !fields.insert(__FieldTag::__monitored_resource) {
16609                                    return std::result::Result::Err(A::Error::duplicate_field(
16610                                        "multiple values for monitored_resource",
16611                                    ));
16612                                }
16613                                result.monitored_resource = map
16614                                    .next_value::<std::option::Option<std::string::String>>()?
16615                                    .unwrap_or_default();
16616                            }
16617                            __FieldTag::__metrics => {
16618                                if !fields.insert(__FieldTag::__metrics) {
16619                                    return std::result::Result::Err(A::Error::duplicate_field(
16620                                        "multiple values for metrics",
16621                                    ));
16622                                }
16623                                result.metrics = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
16624                            }
16625                            __FieldTag::Unknown(key) => {
16626                                let value = map.next_value::<serde_json::Value>()?;
16627                                result._unknown_fields.insert(key, value);
16628                            }
16629                        }
16630                    }
16631                    std::result::Result::Ok(result)
16632                }
16633            }
16634            deserializer.deserialize_any(Visitor)
16635        }
16636    }
16637
16638    #[doc(hidden)]
16639    impl serde::ser::Serialize for MonitoringDestination {
16640        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16641        where
16642            S: serde::ser::Serializer,
16643        {
16644            use serde::ser::SerializeMap;
16645            #[allow(unused_imports)]
16646            use std::option::Option::Some;
16647            let mut state = serializer.serialize_map(std::option::Option::None)?;
16648            if !self.monitored_resource.is_empty() {
16649                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
16650            }
16651            if !self.metrics.is_empty() {
16652                state.serialize_entry("metrics", &self.metrics)?;
16653            }
16654            if !self._unknown_fields.is_empty() {
16655                for (key, value) in self._unknown_fields.iter() {
16656                    state.serialize_entry(key, &value)?;
16657                }
16658            }
16659            state.end()
16660        }
16661    }
16662
16663    impl std::fmt::Debug for MonitoringDestination {
16664        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16665            let mut debug_struct = f.debug_struct("MonitoringDestination");
16666            debug_struct.field("monitored_resource", &self.monitored_resource);
16667            debug_struct.field("metrics", &self.metrics);
16668            if !self._unknown_fields.is_empty() {
16669                debug_struct.field("_unknown_fields", &self._unknown_fields);
16670            }
16671            debug_struct.finish()
16672        }
16673    }
16674}
16675
16676/// Google API Policy Annotation
16677///
16678/// This message defines a simple API policy annotation that can be used to
16679/// annotate API request and response message fields with applicable policies.
16680/// One field may have multiple applicable policies that must all be satisfied
16681/// before a request can be processed. This policy annotation is used to
16682/// generate the overall policy that will be used for automatic runtime
16683/// policy enforcement and documentation generation.
16684#[derive(Clone, Default, PartialEq)]
16685#[non_exhaustive]
16686pub struct FieldPolicy {
16687    /// Selects one or more request or response message fields to apply this
16688    /// `FieldPolicy`.
16689    ///
16690    /// When a `FieldPolicy` is used in proto annotation, the selector must
16691    /// be left as empty. The service config generator will automatically fill
16692    /// the correct value.
16693    ///
16694    /// When a `FieldPolicy` is used in service config, the selector must be a
16695    /// comma-separated string with valid request or response field paths,
16696    /// such as "foo.bar" or "foo.bar,foo.baz".
16697    pub selector: std::string::String,
16698
16699    /// Specifies the required permission(s) for the resource referred to by the
16700    /// field. It requires the field contains a valid resource reference, and
16701    /// the request must pass the permission checks to proceed. For example,
16702    /// "resourcemanager.projects.get".
16703    pub resource_permission: std::string::String,
16704
16705    /// Specifies the resource type for the resource referred to by the field.
16706    pub resource_type: std::string::String,
16707
16708    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16709}
16710
16711impl FieldPolicy {
16712    pub fn new() -> Self {
16713        std::default::Default::default()
16714    }
16715
16716    /// Sets the value of [selector][crate::model::FieldPolicy::selector].
16717    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16718        self.selector = v.into();
16719        self
16720    }
16721
16722    /// Sets the value of [resource_permission][crate::model::FieldPolicy::resource_permission].
16723    pub fn set_resource_permission<T: std::convert::Into<std::string::String>>(
16724        mut self,
16725        v: T,
16726    ) -> Self {
16727        self.resource_permission = v.into();
16728        self
16729    }
16730
16731    /// Sets the value of [resource_type][crate::model::FieldPolicy::resource_type].
16732    pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16733        self.resource_type = v.into();
16734        self
16735    }
16736}
16737
16738impl wkt::message::Message for FieldPolicy {
16739    fn typename() -> &'static str {
16740        "type.googleapis.com/google.api.FieldPolicy"
16741    }
16742}
16743
16744#[doc(hidden)]
16745impl<'de> serde::de::Deserialize<'de> for FieldPolicy {
16746    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16747    where
16748        D: serde::Deserializer<'de>,
16749    {
16750        #[allow(non_camel_case_types)]
16751        #[doc(hidden)]
16752        #[derive(PartialEq, Eq, Hash)]
16753        enum __FieldTag {
16754            __selector,
16755            __resource_permission,
16756            __resource_type,
16757            Unknown(std::string::String),
16758        }
16759        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16760            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16761            where
16762                D: serde::Deserializer<'de>,
16763            {
16764                struct Visitor;
16765                impl<'de> serde::de::Visitor<'de> for Visitor {
16766                    type Value = __FieldTag;
16767                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16768                        formatter.write_str("a field name for FieldPolicy")
16769                    }
16770                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16771                    where
16772                        E: serde::de::Error,
16773                    {
16774                        use std::result::Result::Ok;
16775                        use std::string::ToString;
16776                        match value {
16777                            "selector" => Ok(__FieldTag::__selector),
16778                            "resourcePermission" => Ok(__FieldTag::__resource_permission),
16779                            "resource_permission" => Ok(__FieldTag::__resource_permission),
16780                            "resourceType" => Ok(__FieldTag::__resource_type),
16781                            "resource_type" => Ok(__FieldTag::__resource_type),
16782                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16783                        }
16784                    }
16785                }
16786                deserializer.deserialize_identifier(Visitor)
16787            }
16788        }
16789        struct Visitor;
16790        impl<'de> serde::de::Visitor<'de> for Visitor {
16791            type Value = FieldPolicy;
16792            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16793                formatter.write_str("struct FieldPolicy")
16794            }
16795            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16796            where
16797                A: serde::de::MapAccess<'de>,
16798            {
16799                #[allow(unused_imports)]
16800                use serde::de::Error;
16801                use std::option::Option::Some;
16802                let mut fields = std::collections::HashSet::new();
16803                let mut result = Self::Value::new();
16804                while let Some(tag) = map.next_key::<__FieldTag>()? {
16805                    #[allow(clippy::match_single_binding)]
16806                    match tag {
16807                        __FieldTag::__selector => {
16808                            if !fields.insert(__FieldTag::__selector) {
16809                                return std::result::Result::Err(A::Error::duplicate_field(
16810                                    "multiple values for selector",
16811                                ));
16812                            }
16813                            result.selector = map
16814                                .next_value::<std::option::Option<std::string::String>>()?
16815                                .unwrap_or_default();
16816                        }
16817                        __FieldTag::__resource_permission => {
16818                            if !fields.insert(__FieldTag::__resource_permission) {
16819                                return std::result::Result::Err(A::Error::duplicate_field(
16820                                    "multiple values for resource_permission",
16821                                ));
16822                            }
16823                            result.resource_permission = map
16824                                .next_value::<std::option::Option<std::string::String>>()?
16825                                .unwrap_or_default();
16826                        }
16827                        __FieldTag::__resource_type => {
16828                            if !fields.insert(__FieldTag::__resource_type) {
16829                                return std::result::Result::Err(A::Error::duplicate_field(
16830                                    "multiple values for resource_type",
16831                                ));
16832                            }
16833                            result.resource_type = map
16834                                .next_value::<std::option::Option<std::string::String>>()?
16835                                .unwrap_or_default();
16836                        }
16837                        __FieldTag::Unknown(key) => {
16838                            let value = map.next_value::<serde_json::Value>()?;
16839                            result._unknown_fields.insert(key, value);
16840                        }
16841                    }
16842                }
16843                std::result::Result::Ok(result)
16844            }
16845        }
16846        deserializer.deserialize_any(Visitor)
16847    }
16848}
16849
16850#[doc(hidden)]
16851impl serde::ser::Serialize for FieldPolicy {
16852    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16853    where
16854        S: serde::ser::Serializer,
16855    {
16856        use serde::ser::SerializeMap;
16857        #[allow(unused_imports)]
16858        use std::option::Option::Some;
16859        let mut state = serializer.serialize_map(std::option::Option::None)?;
16860        if !self.selector.is_empty() {
16861            state.serialize_entry("selector", &self.selector)?;
16862        }
16863        if !self.resource_permission.is_empty() {
16864            state.serialize_entry("resourcePermission", &self.resource_permission)?;
16865        }
16866        if !self.resource_type.is_empty() {
16867            state.serialize_entry("resourceType", &self.resource_type)?;
16868        }
16869        if !self._unknown_fields.is_empty() {
16870            for (key, value) in self._unknown_fields.iter() {
16871                state.serialize_entry(key, &value)?;
16872            }
16873        }
16874        state.end()
16875    }
16876}
16877
16878impl std::fmt::Debug for FieldPolicy {
16879    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16880        let mut debug_struct = f.debug_struct("FieldPolicy");
16881        debug_struct.field("selector", &self.selector);
16882        debug_struct.field("resource_permission", &self.resource_permission);
16883        debug_struct.field("resource_type", &self.resource_type);
16884        if !self._unknown_fields.is_empty() {
16885            debug_struct.field("_unknown_fields", &self._unknown_fields);
16886        }
16887        debug_struct.finish()
16888    }
16889}
16890
16891/// Defines policies applying to an RPC method.
16892#[derive(Clone, Default, PartialEq)]
16893#[non_exhaustive]
16894pub struct MethodPolicy {
16895    /// Selects a method to which these policies should be enforced, for example,
16896    /// "google.pubsub.v1.Subscriber.CreateSubscription".
16897    ///
16898    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
16899    /// details.
16900    ///
16901    /// NOTE: This field must not be set in the proto annotation. It will be
16902    /// automatically filled by the service config compiler .
16903    ///
16904    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
16905    pub selector: std::string::String,
16906
16907    /// Policies that are applicable to the request message.
16908    pub request_policies: std::vec::Vec<crate::model::FieldPolicy>,
16909
16910    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16911}
16912
16913impl MethodPolicy {
16914    pub fn new() -> Self {
16915        std::default::Default::default()
16916    }
16917
16918    /// Sets the value of [selector][crate::model::MethodPolicy::selector].
16919    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16920        self.selector = v.into();
16921        self
16922    }
16923
16924    /// Sets the value of [request_policies][crate::model::MethodPolicy::request_policies].
16925    pub fn set_request_policies<T, V>(mut self, v: T) -> Self
16926    where
16927        T: std::iter::IntoIterator<Item = V>,
16928        V: std::convert::Into<crate::model::FieldPolicy>,
16929    {
16930        use std::iter::Iterator;
16931        self.request_policies = v.into_iter().map(|i| i.into()).collect();
16932        self
16933    }
16934}
16935
16936impl wkt::message::Message for MethodPolicy {
16937    fn typename() -> &'static str {
16938        "type.googleapis.com/google.api.MethodPolicy"
16939    }
16940}
16941
16942#[doc(hidden)]
16943impl<'de> serde::de::Deserialize<'de> for MethodPolicy {
16944    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16945    where
16946        D: serde::Deserializer<'de>,
16947    {
16948        #[allow(non_camel_case_types)]
16949        #[doc(hidden)]
16950        #[derive(PartialEq, Eq, Hash)]
16951        enum __FieldTag {
16952            __selector,
16953            __request_policies,
16954            Unknown(std::string::String),
16955        }
16956        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16957            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16958            where
16959                D: serde::Deserializer<'de>,
16960            {
16961                struct Visitor;
16962                impl<'de> serde::de::Visitor<'de> for Visitor {
16963                    type Value = __FieldTag;
16964                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16965                        formatter.write_str("a field name for MethodPolicy")
16966                    }
16967                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16968                    where
16969                        E: serde::de::Error,
16970                    {
16971                        use std::result::Result::Ok;
16972                        use std::string::ToString;
16973                        match value {
16974                            "selector" => Ok(__FieldTag::__selector),
16975                            "requestPolicies" => Ok(__FieldTag::__request_policies),
16976                            "request_policies" => Ok(__FieldTag::__request_policies),
16977                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16978                        }
16979                    }
16980                }
16981                deserializer.deserialize_identifier(Visitor)
16982            }
16983        }
16984        struct Visitor;
16985        impl<'de> serde::de::Visitor<'de> for Visitor {
16986            type Value = MethodPolicy;
16987            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16988                formatter.write_str("struct MethodPolicy")
16989            }
16990            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16991            where
16992                A: serde::de::MapAccess<'de>,
16993            {
16994                #[allow(unused_imports)]
16995                use serde::de::Error;
16996                use std::option::Option::Some;
16997                let mut fields = std::collections::HashSet::new();
16998                let mut result = Self::Value::new();
16999                while let Some(tag) = map.next_key::<__FieldTag>()? {
17000                    #[allow(clippy::match_single_binding)]
17001                    match tag {
17002                        __FieldTag::__selector => {
17003                            if !fields.insert(__FieldTag::__selector) {
17004                                return std::result::Result::Err(A::Error::duplicate_field(
17005                                    "multiple values for selector",
17006                                ));
17007                            }
17008                            result.selector = map
17009                                .next_value::<std::option::Option<std::string::String>>()?
17010                                .unwrap_or_default();
17011                        }
17012                        __FieldTag::__request_policies => {
17013                            if !fields.insert(__FieldTag::__request_policies) {
17014                                return std::result::Result::Err(A::Error::duplicate_field(
17015                                    "multiple values for request_policies",
17016                                ));
17017                            }
17018                            result.request_policies = map.next_value::<std::option::Option<std::vec::Vec<crate::model::FieldPolicy>>>()?.unwrap_or_default();
17019                        }
17020                        __FieldTag::Unknown(key) => {
17021                            let value = map.next_value::<serde_json::Value>()?;
17022                            result._unknown_fields.insert(key, value);
17023                        }
17024                    }
17025                }
17026                std::result::Result::Ok(result)
17027            }
17028        }
17029        deserializer.deserialize_any(Visitor)
17030    }
17031}
17032
17033#[doc(hidden)]
17034impl serde::ser::Serialize for MethodPolicy {
17035    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17036    where
17037        S: serde::ser::Serializer,
17038    {
17039        use serde::ser::SerializeMap;
17040        #[allow(unused_imports)]
17041        use std::option::Option::Some;
17042        let mut state = serializer.serialize_map(std::option::Option::None)?;
17043        if !self.selector.is_empty() {
17044            state.serialize_entry("selector", &self.selector)?;
17045        }
17046        if !self.request_policies.is_empty() {
17047            state.serialize_entry("requestPolicies", &self.request_policies)?;
17048        }
17049        if !self._unknown_fields.is_empty() {
17050            for (key, value) in self._unknown_fields.iter() {
17051                state.serialize_entry(key, &value)?;
17052            }
17053        }
17054        state.end()
17055    }
17056}
17057
17058impl std::fmt::Debug for MethodPolicy {
17059    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17060        let mut debug_struct = f.debug_struct("MethodPolicy");
17061        debug_struct.field("selector", &self.selector);
17062        debug_struct.field("request_policies", &self.request_policies);
17063        if !self._unknown_fields.is_empty() {
17064            debug_struct.field("_unknown_fields", &self._unknown_fields);
17065        }
17066        debug_struct.finish()
17067    }
17068}
17069
17070/// Quota configuration helps to achieve fairness and budgeting in service
17071/// usage.
17072///
17073/// The metric based quota configuration works this way:
17074///
17075/// - The service configuration defines a set of metrics.
17076/// - For API calls, the quota.metric_rules maps methods to metrics with
17077///   corresponding costs.
17078/// - The quota.limits defines limits on the metrics, which will be used for
17079///   quota checks at runtime.
17080///
17081/// An example quota configuration in yaml format:
17082///
17083/// quota:
17084/// limits:
17085///
17086/// ```norust
17087///  - name: apiWriteQpsPerProject
17088///    metric: library.googleapis.com/write_calls
17089///    unit: "1/min/{project}"  # rate limit for consumer projects
17090///    values:
17091///      STANDARD: 10000
17092///
17093///
17094///  (The metric rules bind all methods to the read_calls metric,
17095///   except for the UpdateBook and DeleteBook methods. These two methods
17096///   are mapped to the write_calls metric, with the UpdateBook method
17097///   consuming at twice rate as the DeleteBook method.)
17098///  metric_rules:
17099///  - selector: "*"
17100///    metric_costs:
17101///      library.googleapis.com/read_calls: 1
17102///  - selector: google.example.library.v1.LibraryService.UpdateBook
17103///    metric_costs:
17104///      library.googleapis.com/write_calls: 2
17105///  - selector: google.example.library.v1.LibraryService.DeleteBook
17106///    metric_costs:
17107///      library.googleapis.com/write_calls: 1
17108/// ```
17109///
17110/// Corresponding Metric definition:
17111///
17112/// ```norust
17113///  metrics:
17114///  - name: library.googleapis.com/read_calls
17115///    display_name: Read requests
17116///    metric_kind: DELTA
17117///    value_type: INT64
17118///
17119///  - name: library.googleapis.com/write_calls
17120///    display_name: Write requests
17121///    metric_kind: DELTA
17122///    value_type: INT64
17123/// ```
17124#[derive(Clone, Default, PartialEq)]
17125#[non_exhaustive]
17126pub struct Quota {
17127    /// List of QuotaLimit definitions for the service.
17128    pub limits: std::vec::Vec<crate::model::QuotaLimit>,
17129
17130    /// List of MetricRule definitions, each one mapping a selected method to one
17131    /// or more metrics.
17132    pub metric_rules: std::vec::Vec<crate::model::MetricRule>,
17133
17134    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17135}
17136
17137impl Quota {
17138    pub fn new() -> Self {
17139        std::default::Default::default()
17140    }
17141
17142    /// Sets the value of [limits][crate::model::Quota::limits].
17143    pub fn set_limits<T, V>(mut self, v: T) -> Self
17144    where
17145        T: std::iter::IntoIterator<Item = V>,
17146        V: std::convert::Into<crate::model::QuotaLimit>,
17147    {
17148        use std::iter::Iterator;
17149        self.limits = v.into_iter().map(|i| i.into()).collect();
17150        self
17151    }
17152
17153    /// Sets the value of [metric_rules][crate::model::Quota::metric_rules].
17154    pub fn set_metric_rules<T, V>(mut self, v: T) -> Self
17155    where
17156        T: std::iter::IntoIterator<Item = V>,
17157        V: std::convert::Into<crate::model::MetricRule>,
17158    {
17159        use std::iter::Iterator;
17160        self.metric_rules = v.into_iter().map(|i| i.into()).collect();
17161        self
17162    }
17163}
17164
17165impl wkt::message::Message for Quota {
17166    fn typename() -> &'static str {
17167        "type.googleapis.com/google.api.Quota"
17168    }
17169}
17170
17171#[doc(hidden)]
17172impl<'de> serde::de::Deserialize<'de> for Quota {
17173    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17174    where
17175        D: serde::Deserializer<'de>,
17176    {
17177        #[allow(non_camel_case_types)]
17178        #[doc(hidden)]
17179        #[derive(PartialEq, Eq, Hash)]
17180        enum __FieldTag {
17181            __limits,
17182            __metric_rules,
17183            Unknown(std::string::String),
17184        }
17185        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17186            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17187            where
17188                D: serde::Deserializer<'de>,
17189            {
17190                struct Visitor;
17191                impl<'de> serde::de::Visitor<'de> for Visitor {
17192                    type Value = __FieldTag;
17193                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17194                        formatter.write_str("a field name for Quota")
17195                    }
17196                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17197                    where
17198                        E: serde::de::Error,
17199                    {
17200                        use std::result::Result::Ok;
17201                        use std::string::ToString;
17202                        match value {
17203                            "limits" => Ok(__FieldTag::__limits),
17204                            "metricRules" => Ok(__FieldTag::__metric_rules),
17205                            "metric_rules" => Ok(__FieldTag::__metric_rules),
17206                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17207                        }
17208                    }
17209                }
17210                deserializer.deserialize_identifier(Visitor)
17211            }
17212        }
17213        struct Visitor;
17214        impl<'de> serde::de::Visitor<'de> for Visitor {
17215            type Value = Quota;
17216            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17217                formatter.write_str("struct Quota")
17218            }
17219            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17220            where
17221                A: serde::de::MapAccess<'de>,
17222            {
17223                #[allow(unused_imports)]
17224                use serde::de::Error;
17225                use std::option::Option::Some;
17226                let mut fields = std::collections::HashSet::new();
17227                let mut result = Self::Value::new();
17228                while let Some(tag) = map.next_key::<__FieldTag>()? {
17229                    #[allow(clippy::match_single_binding)]
17230                    match tag {
17231                        __FieldTag::__limits => {
17232                            if !fields.insert(__FieldTag::__limits) {
17233                                return std::result::Result::Err(A::Error::duplicate_field(
17234                                    "multiple values for limits",
17235                                ));
17236                            }
17237                            result.limits = map.next_value::<std::option::Option<std::vec::Vec<crate::model::QuotaLimit>>>()?.unwrap_or_default();
17238                        }
17239                        __FieldTag::__metric_rules => {
17240                            if !fields.insert(__FieldTag::__metric_rules) {
17241                                return std::result::Result::Err(A::Error::duplicate_field(
17242                                    "multiple values for metric_rules",
17243                                ));
17244                            }
17245                            result.metric_rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MetricRule>>>()?.unwrap_or_default();
17246                        }
17247                        __FieldTag::Unknown(key) => {
17248                            let value = map.next_value::<serde_json::Value>()?;
17249                            result._unknown_fields.insert(key, value);
17250                        }
17251                    }
17252                }
17253                std::result::Result::Ok(result)
17254            }
17255        }
17256        deserializer.deserialize_any(Visitor)
17257    }
17258}
17259
17260#[doc(hidden)]
17261impl serde::ser::Serialize for Quota {
17262    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17263    where
17264        S: serde::ser::Serializer,
17265    {
17266        use serde::ser::SerializeMap;
17267        #[allow(unused_imports)]
17268        use std::option::Option::Some;
17269        let mut state = serializer.serialize_map(std::option::Option::None)?;
17270        if !self.limits.is_empty() {
17271            state.serialize_entry("limits", &self.limits)?;
17272        }
17273        if !self.metric_rules.is_empty() {
17274            state.serialize_entry("metricRules", &self.metric_rules)?;
17275        }
17276        if !self._unknown_fields.is_empty() {
17277            for (key, value) in self._unknown_fields.iter() {
17278                state.serialize_entry(key, &value)?;
17279            }
17280        }
17281        state.end()
17282    }
17283}
17284
17285impl std::fmt::Debug for Quota {
17286    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17287        let mut debug_struct = f.debug_struct("Quota");
17288        debug_struct.field("limits", &self.limits);
17289        debug_struct.field("metric_rules", &self.metric_rules);
17290        if !self._unknown_fields.is_empty() {
17291            debug_struct.field("_unknown_fields", &self._unknown_fields);
17292        }
17293        debug_struct.finish()
17294    }
17295}
17296
17297/// Bind API methods to metrics. Binding a method to a metric causes that
17298/// metric's configured quota behaviors to apply to the method call.
17299#[derive(Clone, Default, PartialEq)]
17300#[non_exhaustive]
17301pub struct MetricRule {
17302    /// Selects the methods to which this rule applies.
17303    ///
17304    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
17305    /// details.
17306    ///
17307    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
17308    pub selector: std::string::String,
17309
17310    /// Metrics to update when the selected methods are called, and the associated
17311    /// cost applied to each metric.
17312    ///
17313    /// The key of the map is the metric name, and the values are the amount
17314    /// increased for the metric against which the quota limits are defined.
17315    /// The value must not be negative.
17316    pub metric_costs: std::collections::HashMap<std::string::String, i64>,
17317
17318    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17319}
17320
17321impl MetricRule {
17322    pub fn new() -> Self {
17323        std::default::Default::default()
17324    }
17325
17326    /// Sets the value of [selector][crate::model::MetricRule::selector].
17327    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17328        self.selector = v.into();
17329        self
17330    }
17331
17332    /// Sets the value of [metric_costs][crate::model::MetricRule::metric_costs].
17333    pub fn set_metric_costs<T, K, V>(mut self, v: T) -> Self
17334    where
17335        T: std::iter::IntoIterator<Item = (K, V)>,
17336        K: std::convert::Into<std::string::String>,
17337        V: std::convert::Into<i64>,
17338    {
17339        use std::iter::Iterator;
17340        self.metric_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17341        self
17342    }
17343}
17344
17345impl wkt::message::Message for MetricRule {
17346    fn typename() -> &'static str {
17347        "type.googleapis.com/google.api.MetricRule"
17348    }
17349}
17350
17351#[doc(hidden)]
17352impl<'de> serde::de::Deserialize<'de> for MetricRule {
17353    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17354    where
17355        D: serde::Deserializer<'de>,
17356    {
17357        #[allow(non_camel_case_types)]
17358        #[doc(hidden)]
17359        #[derive(PartialEq, Eq, Hash)]
17360        enum __FieldTag {
17361            __selector,
17362            __metric_costs,
17363            Unknown(std::string::String),
17364        }
17365        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17366            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17367            where
17368                D: serde::Deserializer<'de>,
17369            {
17370                struct Visitor;
17371                impl<'de> serde::de::Visitor<'de> for Visitor {
17372                    type Value = __FieldTag;
17373                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17374                        formatter.write_str("a field name for MetricRule")
17375                    }
17376                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17377                    where
17378                        E: serde::de::Error,
17379                    {
17380                        use std::result::Result::Ok;
17381                        use std::string::ToString;
17382                        match value {
17383                            "selector" => Ok(__FieldTag::__selector),
17384                            "metricCosts" => Ok(__FieldTag::__metric_costs),
17385                            "metric_costs" => Ok(__FieldTag::__metric_costs),
17386                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17387                        }
17388                    }
17389                }
17390                deserializer.deserialize_identifier(Visitor)
17391            }
17392        }
17393        struct Visitor;
17394        impl<'de> serde::de::Visitor<'de> for Visitor {
17395            type Value = MetricRule;
17396            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17397                formatter.write_str("struct MetricRule")
17398            }
17399            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17400            where
17401                A: serde::de::MapAccess<'de>,
17402            {
17403                #[allow(unused_imports)]
17404                use serde::de::Error;
17405                use std::option::Option::Some;
17406                let mut fields = std::collections::HashSet::new();
17407                let mut result = Self::Value::new();
17408                while let Some(tag) = map.next_key::<__FieldTag>()? {
17409                    #[allow(clippy::match_single_binding)]
17410                    match tag {
17411                        __FieldTag::__selector => {
17412                            if !fields.insert(__FieldTag::__selector) {
17413                                return std::result::Result::Err(A::Error::duplicate_field(
17414                                    "multiple values for selector",
17415                                ));
17416                            }
17417                            result.selector = map
17418                                .next_value::<std::option::Option<std::string::String>>()?
17419                                .unwrap_or_default();
17420                        }
17421                        __FieldTag::__metric_costs => {
17422                            if !fields.insert(__FieldTag::__metric_costs) {
17423                                return std::result::Result::Err(A::Error::duplicate_field(
17424                                    "multiple values for metric_costs",
17425                                ));
17426                            }
17427                            struct __With(
17428                                std::option::Option<
17429                                    std::collections::HashMap<std::string::String, i64>,
17430                                >,
17431                            );
17432                            impl<'de> serde::de::Deserialize<'de> for __With {
17433                                fn deserialize<D>(
17434                                    deserializer: D,
17435                                ) -> std::result::Result<Self, D::Error>
17436                                where
17437                                    D: serde::de::Deserializer<'de>,
17438                                {
17439                                    serde_with::As::<
17440                                        std::option::Option<
17441                                            std::collections::HashMap<
17442                                                serde_with::Same,
17443                                                wkt::internal::I64,
17444                                            >,
17445                                        >,
17446                                    >::deserialize(deserializer)
17447                                    .map(__With)
17448                                }
17449                            }
17450                            result.metric_costs = map.next_value::<__With>()?.0.unwrap_or_default();
17451                        }
17452                        __FieldTag::Unknown(key) => {
17453                            let value = map.next_value::<serde_json::Value>()?;
17454                            result._unknown_fields.insert(key, value);
17455                        }
17456                    }
17457                }
17458                std::result::Result::Ok(result)
17459            }
17460        }
17461        deserializer.deserialize_any(Visitor)
17462    }
17463}
17464
17465#[doc(hidden)]
17466impl serde::ser::Serialize for MetricRule {
17467    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17468    where
17469        S: serde::ser::Serializer,
17470    {
17471        use serde::ser::SerializeMap;
17472        #[allow(unused_imports)]
17473        use std::option::Option::Some;
17474        let mut state = serializer.serialize_map(std::option::Option::None)?;
17475        if !self.selector.is_empty() {
17476            state.serialize_entry("selector", &self.selector)?;
17477        }
17478        if !self.metric_costs.is_empty() {
17479            struct __With<'a>(&'a std::collections::HashMap<std::string::String, i64>);
17480            impl<'a> serde::ser::Serialize for __With<'a> {
17481                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17482                where
17483                    S: serde::ser::Serializer,
17484                {
17485                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::I64> >::serialize(self.0, serializer)
17486                }
17487            }
17488            state.serialize_entry("metricCosts", &__With(&self.metric_costs))?;
17489        }
17490        if !self._unknown_fields.is_empty() {
17491            for (key, value) in self._unknown_fields.iter() {
17492                state.serialize_entry(key, &value)?;
17493            }
17494        }
17495        state.end()
17496    }
17497}
17498
17499impl std::fmt::Debug for MetricRule {
17500    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17501        let mut debug_struct = f.debug_struct("MetricRule");
17502        debug_struct.field("selector", &self.selector);
17503        debug_struct.field("metric_costs", &self.metric_costs);
17504        if !self._unknown_fields.is_empty() {
17505            debug_struct.field("_unknown_fields", &self._unknown_fields);
17506        }
17507        debug_struct.finish()
17508    }
17509}
17510
17511/// `QuotaLimit` defines a specific limit that applies over a specified duration
17512/// for a limit type. There can be at most one limit for a duration and limit
17513/// type combination defined within a `QuotaGroup`.
17514#[derive(Clone, Default, PartialEq)]
17515#[non_exhaustive]
17516pub struct QuotaLimit {
17517    /// Name of the quota limit.
17518    ///
17519    /// The name must be provided, and it must be unique within the service. The
17520    /// name can only include alphanumeric characters as well as '-'.
17521    ///
17522    /// The maximum length of the limit name is 64 characters.
17523    pub name: std::string::String,
17524
17525    /// Optional. User-visible, extended description for this quota limit.
17526    /// Should be used only when more context is needed to understand this limit
17527    /// than provided by the limit's display name (see: `display_name`).
17528    pub description: std::string::String,
17529
17530    /// Default number of tokens that can be consumed during the specified
17531    /// duration. This is the number of tokens assigned when a client
17532    /// application developer activates the service for his/her project.
17533    ///
17534    /// Specifying a value of 0 will block all requests. This can be used if you
17535    /// are provisioning quota to selected consumers and blocking others.
17536    /// Similarly, a value of -1 will indicate an unlimited quota. No other
17537    /// negative values are allowed.
17538    ///
17539    /// Used by group-based quotas only.
17540    pub default_limit: i64,
17541
17542    /// Maximum number of tokens that can be consumed during the specified
17543    /// duration. Client application developers can override the default limit up
17544    /// to this maximum. If specified, this value cannot be set to a value less
17545    /// than the default limit. If not specified, it is set to the default limit.
17546    ///
17547    /// To allow clients to apply overrides with no upper bound, set this to -1,
17548    /// indicating unlimited maximum quota.
17549    ///
17550    /// Used by group-based quotas only.
17551    pub max_limit: i64,
17552
17553    /// Free tier value displayed in the Developers Console for this limit.
17554    /// The free tier is the number of tokens that will be subtracted from the
17555    /// billed amount when billing is enabled.
17556    /// This field can only be set on a limit with duration "1d", in a billable
17557    /// group; it is invalid on any other limit. If this field is not set, it
17558    /// defaults to 0, indicating that there is no free tier for this service.
17559    ///
17560    /// Used by group-based quotas only.
17561    pub free_tier: i64,
17562
17563    /// Duration of this limit in textual notation. Must be "100s" or "1d".
17564    ///
17565    /// Used by group-based quotas only.
17566    pub duration: std::string::String,
17567
17568    /// The name of the metric this quota limit applies to. The quota limits with
17569    /// the same metric will be checked together during runtime. The metric must be
17570    /// defined within the service config.
17571    pub metric: std::string::String,
17572
17573    /// Specify the unit of the quota limit. It uses the same syntax as
17574    /// [MetricDescriptor.unit][google.api.MetricDescriptor.unit]. The supported
17575    /// unit kinds are determined by the quota backend system.
17576    ///
17577    /// Here are some examples:
17578    ///
17579    /// * "1/min/{project}" for quota per minute per project.
17580    ///
17581    /// Note: the order of unit components is insignificant.
17582    /// The "1" at the beginning is required to follow the metric unit syntax.
17583    ///
17584    /// [google.api.MetricDescriptor.unit]: crate::model::MetricDescriptor::unit
17585    pub unit: std::string::String,
17586
17587    /// Tiered limit values. You must specify this as a key:value pair, with an
17588    /// integer value that is the maximum number of requests allowed for the
17589    /// specified unit. Currently only STANDARD is supported.
17590    pub values: std::collections::HashMap<std::string::String, i64>,
17591
17592    /// User-visible display name for this limit.
17593    /// Optional. If not set, the UI will provide a default display name based on
17594    /// the quota configuration. This field can be used to override the default
17595    /// display name generated from the configuration.
17596    pub display_name: std::string::String,
17597
17598    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17599}
17600
17601impl QuotaLimit {
17602    pub fn new() -> Self {
17603        std::default::Default::default()
17604    }
17605
17606    /// Sets the value of [name][crate::model::QuotaLimit::name].
17607    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17608        self.name = v.into();
17609        self
17610    }
17611
17612    /// Sets the value of [description][crate::model::QuotaLimit::description].
17613    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17614        self.description = v.into();
17615        self
17616    }
17617
17618    /// Sets the value of [default_limit][crate::model::QuotaLimit::default_limit].
17619    pub fn set_default_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
17620        self.default_limit = v.into();
17621        self
17622    }
17623
17624    /// Sets the value of [max_limit][crate::model::QuotaLimit::max_limit].
17625    pub fn set_max_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
17626        self.max_limit = v.into();
17627        self
17628    }
17629
17630    /// Sets the value of [free_tier][crate::model::QuotaLimit::free_tier].
17631    pub fn set_free_tier<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
17632        self.free_tier = v.into();
17633        self
17634    }
17635
17636    /// Sets the value of [duration][crate::model::QuotaLimit::duration].
17637    pub fn set_duration<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17638        self.duration = v.into();
17639        self
17640    }
17641
17642    /// Sets the value of [metric][crate::model::QuotaLimit::metric].
17643    pub fn set_metric<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17644        self.metric = v.into();
17645        self
17646    }
17647
17648    /// Sets the value of [unit][crate::model::QuotaLimit::unit].
17649    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17650        self.unit = v.into();
17651        self
17652    }
17653
17654    /// Sets the value of [values][crate::model::QuotaLimit::values].
17655    pub fn set_values<T, K, V>(mut self, v: T) -> Self
17656    where
17657        T: std::iter::IntoIterator<Item = (K, V)>,
17658        K: std::convert::Into<std::string::String>,
17659        V: std::convert::Into<i64>,
17660    {
17661        use std::iter::Iterator;
17662        self.values = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17663        self
17664    }
17665
17666    /// Sets the value of [display_name][crate::model::QuotaLimit::display_name].
17667    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17668        self.display_name = v.into();
17669        self
17670    }
17671}
17672
17673impl wkt::message::Message for QuotaLimit {
17674    fn typename() -> &'static str {
17675        "type.googleapis.com/google.api.QuotaLimit"
17676    }
17677}
17678
17679#[doc(hidden)]
17680impl<'de> serde::de::Deserialize<'de> for QuotaLimit {
17681    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17682    where
17683        D: serde::Deserializer<'de>,
17684    {
17685        #[allow(non_camel_case_types)]
17686        #[doc(hidden)]
17687        #[derive(PartialEq, Eq, Hash)]
17688        enum __FieldTag {
17689            __name,
17690            __description,
17691            __default_limit,
17692            __max_limit,
17693            __free_tier,
17694            __duration,
17695            __metric,
17696            __unit,
17697            __values,
17698            __display_name,
17699            Unknown(std::string::String),
17700        }
17701        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17702            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17703            where
17704                D: serde::Deserializer<'de>,
17705            {
17706                struct Visitor;
17707                impl<'de> serde::de::Visitor<'de> for Visitor {
17708                    type Value = __FieldTag;
17709                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17710                        formatter.write_str("a field name for QuotaLimit")
17711                    }
17712                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17713                    where
17714                        E: serde::de::Error,
17715                    {
17716                        use std::result::Result::Ok;
17717                        use std::string::ToString;
17718                        match value {
17719                            "name" => Ok(__FieldTag::__name),
17720                            "description" => Ok(__FieldTag::__description),
17721                            "defaultLimit" => Ok(__FieldTag::__default_limit),
17722                            "default_limit" => Ok(__FieldTag::__default_limit),
17723                            "maxLimit" => Ok(__FieldTag::__max_limit),
17724                            "max_limit" => Ok(__FieldTag::__max_limit),
17725                            "freeTier" => Ok(__FieldTag::__free_tier),
17726                            "free_tier" => Ok(__FieldTag::__free_tier),
17727                            "duration" => Ok(__FieldTag::__duration),
17728                            "metric" => Ok(__FieldTag::__metric),
17729                            "unit" => Ok(__FieldTag::__unit),
17730                            "values" => Ok(__FieldTag::__values),
17731                            "displayName" => Ok(__FieldTag::__display_name),
17732                            "display_name" => Ok(__FieldTag::__display_name),
17733                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17734                        }
17735                    }
17736                }
17737                deserializer.deserialize_identifier(Visitor)
17738            }
17739        }
17740        struct Visitor;
17741        impl<'de> serde::de::Visitor<'de> for Visitor {
17742            type Value = QuotaLimit;
17743            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17744                formatter.write_str("struct QuotaLimit")
17745            }
17746            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17747            where
17748                A: serde::de::MapAccess<'de>,
17749            {
17750                #[allow(unused_imports)]
17751                use serde::de::Error;
17752                use std::option::Option::Some;
17753                let mut fields = std::collections::HashSet::new();
17754                let mut result = Self::Value::new();
17755                while let Some(tag) = map.next_key::<__FieldTag>()? {
17756                    #[allow(clippy::match_single_binding)]
17757                    match tag {
17758                        __FieldTag::__name => {
17759                            if !fields.insert(__FieldTag::__name) {
17760                                return std::result::Result::Err(A::Error::duplicate_field(
17761                                    "multiple values for name",
17762                                ));
17763                            }
17764                            result.name = map
17765                                .next_value::<std::option::Option<std::string::String>>()?
17766                                .unwrap_or_default();
17767                        }
17768                        __FieldTag::__description => {
17769                            if !fields.insert(__FieldTag::__description) {
17770                                return std::result::Result::Err(A::Error::duplicate_field(
17771                                    "multiple values for description",
17772                                ));
17773                            }
17774                            result.description = map
17775                                .next_value::<std::option::Option<std::string::String>>()?
17776                                .unwrap_or_default();
17777                        }
17778                        __FieldTag::__default_limit => {
17779                            if !fields.insert(__FieldTag::__default_limit) {
17780                                return std::result::Result::Err(A::Error::duplicate_field(
17781                                    "multiple values for default_limit",
17782                                ));
17783                            }
17784                            struct __With(std::option::Option<i64>);
17785                            impl<'de> serde::de::Deserialize<'de> for __With {
17786                                fn deserialize<D>(
17787                                    deserializer: D,
17788                                ) -> std::result::Result<Self, D::Error>
17789                                where
17790                                    D: serde::de::Deserializer<'de>,
17791                                {
17792                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
17793                                }
17794                            }
17795                            result.default_limit =
17796                                map.next_value::<__With>()?.0.unwrap_or_default();
17797                        }
17798                        __FieldTag::__max_limit => {
17799                            if !fields.insert(__FieldTag::__max_limit) {
17800                                return std::result::Result::Err(A::Error::duplicate_field(
17801                                    "multiple values for max_limit",
17802                                ));
17803                            }
17804                            struct __With(std::option::Option<i64>);
17805                            impl<'de> serde::de::Deserialize<'de> for __With {
17806                                fn deserialize<D>(
17807                                    deserializer: D,
17808                                ) -> std::result::Result<Self, D::Error>
17809                                where
17810                                    D: serde::de::Deserializer<'de>,
17811                                {
17812                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
17813                                }
17814                            }
17815                            result.max_limit = map.next_value::<__With>()?.0.unwrap_or_default();
17816                        }
17817                        __FieldTag::__free_tier => {
17818                            if !fields.insert(__FieldTag::__free_tier) {
17819                                return std::result::Result::Err(A::Error::duplicate_field(
17820                                    "multiple values for free_tier",
17821                                ));
17822                            }
17823                            struct __With(std::option::Option<i64>);
17824                            impl<'de> serde::de::Deserialize<'de> for __With {
17825                                fn deserialize<D>(
17826                                    deserializer: D,
17827                                ) -> std::result::Result<Self, D::Error>
17828                                where
17829                                    D: serde::de::Deserializer<'de>,
17830                                {
17831                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
17832                                }
17833                            }
17834                            result.free_tier = map.next_value::<__With>()?.0.unwrap_or_default();
17835                        }
17836                        __FieldTag::__duration => {
17837                            if !fields.insert(__FieldTag::__duration) {
17838                                return std::result::Result::Err(A::Error::duplicate_field(
17839                                    "multiple values for duration",
17840                                ));
17841                            }
17842                            result.duration = map
17843                                .next_value::<std::option::Option<std::string::String>>()?
17844                                .unwrap_or_default();
17845                        }
17846                        __FieldTag::__metric => {
17847                            if !fields.insert(__FieldTag::__metric) {
17848                                return std::result::Result::Err(A::Error::duplicate_field(
17849                                    "multiple values for metric",
17850                                ));
17851                            }
17852                            result.metric = map
17853                                .next_value::<std::option::Option<std::string::String>>()?
17854                                .unwrap_or_default();
17855                        }
17856                        __FieldTag::__unit => {
17857                            if !fields.insert(__FieldTag::__unit) {
17858                                return std::result::Result::Err(A::Error::duplicate_field(
17859                                    "multiple values for unit",
17860                                ));
17861                            }
17862                            result.unit = map
17863                                .next_value::<std::option::Option<std::string::String>>()?
17864                                .unwrap_or_default();
17865                        }
17866                        __FieldTag::__values => {
17867                            if !fields.insert(__FieldTag::__values) {
17868                                return std::result::Result::Err(A::Error::duplicate_field(
17869                                    "multiple values for values",
17870                                ));
17871                            }
17872                            struct __With(
17873                                std::option::Option<
17874                                    std::collections::HashMap<std::string::String, i64>,
17875                                >,
17876                            );
17877                            impl<'de> serde::de::Deserialize<'de> for __With {
17878                                fn deserialize<D>(
17879                                    deserializer: D,
17880                                ) -> std::result::Result<Self, D::Error>
17881                                where
17882                                    D: serde::de::Deserializer<'de>,
17883                                {
17884                                    serde_with::As::<
17885                                        std::option::Option<
17886                                            std::collections::HashMap<
17887                                                serde_with::Same,
17888                                                wkt::internal::I64,
17889                                            >,
17890                                        >,
17891                                    >::deserialize(deserializer)
17892                                    .map(__With)
17893                                }
17894                            }
17895                            result.values = map.next_value::<__With>()?.0.unwrap_or_default();
17896                        }
17897                        __FieldTag::__display_name => {
17898                            if !fields.insert(__FieldTag::__display_name) {
17899                                return std::result::Result::Err(A::Error::duplicate_field(
17900                                    "multiple values for display_name",
17901                                ));
17902                            }
17903                            result.display_name = map
17904                                .next_value::<std::option::Option<std::string::String>>()?
17905                                .unwrap_or_default();
17906                        }
17907                        __FieldTag::Unknown(key) => {
17908                            let value = map.next_value::<serde_json::Value>()?;
17909                            result._unknown_fields.insert(key, value);
17910                        }
17911                    }
17912                }
17913                std::result::Result::Ok(result)
17914            }
17915        }
17916        deserializer.deserialize_any(Visitor)
17917    }
17918}
17919
17920#[doc(hidden)]
17921impl serde::ser::Serialize for QuotaLimit {
17922    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17923    where
17924        S: serde::ser::Serializer,
17925    {
17926        use serde::ser::SerializeMap;
17927        #[allow(unused_imports)]
17928        use std::option::Option::Some;
17929        let mut state = serializer.serialize_map(std::option::Option::None)?;
17930        if !self.name.is_empty() {
17931            state.serialize_entry("name", &self.name)?;
17932        }
17933        if !self.description.is_empty() {
17934            state.serialize_entry("description", &self.description)?;
17935        }
17936        if !wkt::internal::is_default(&self.default_limit) {
17937            struct __With<'a>(&'a i64);
17938            impl<'a> serde::ser::Serialize for __With<'a> {
17939                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17940                where
17941                    S: serde::ser::Serializer,
17942                {
17943                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17944                }
17945            }
17946            state.serialize_entry("defaultLimit", &__With(&self.default_limit))?;
17947        }
17948        if !wkt::internal::is_default(&self.max_limit) {
17949            struct __With<'a>(&'a i64);
17950            impl<'a> serde::ser::Serialize for __With<'a> {
17951                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17952                where
17953                    S: serde::ser::Serializer,
17954                {
17955                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17956                }
17957            }
17958            state.serialize_entry("maxLimit", &__With(&self.max_limit))?;
17959        }
17960        if !wkt::internal::is_default(&self.free_tier) {
17961            struct __With<'a>(&'a i64);
17962            impl<'a> serde::ser::Serialize for __With<'a> {
17963                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17964                where
17965                    S: serde::ser::Serializer,
17966                {
17967                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17968                }
17969            }
17970            state.serialize_entry("freeTier", &__With(&self.free_tier))?;
17971        }
17972        if !self.duration.is_empty() {
17973            state.serialize_entry("duration", &self.duration)?;
17974        }
17975        if !self.metric.is_empty() {
17976            state.serialize_entry("metric", &self.metric)?;
17977        }
17978        if !self.unit.is_empty() {
17979            state.serialize_entry("unit", &self.unit)?;
17980        }
17981        if !self.values.is_empty() {
17982            struct __With<'a>(&'a std::collections::HashMap<std::string::String, i64>);
17983            impl<'a> serde::ser::Serialize for __With<'a> {
17984                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17985                where
17986                    S: serde::ser::Serializer,
17987                {
17988                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::I64> >::serialize(self.0, serializer)
17989                }
17990            }
17991            state.serialize_entry("values", &__With(&self.values))?;
17992        }
17993        if !self.display_name.is_empty() {
17994            state.serialize_entry("displayName", &self.display_name)?;
17995        }
17996        if !self._unknown_fields.is_empty() {
17997            for (key, value) in self._unknown_fields.iter() {
17998                state.serialize_entry(key, &value)?;
17999            }
18000        }
18001        state.end()
18002    }
18003}
18004
18005impl std::fmt::Debug for QuotaLimit {
18006    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18007        let mut debug_struct = f.debug_struct("QuotaLimit");
18008        debug_struct.field("name", &self.name);
18009        debug_struct.field("description", &self.description);
18010        debug_struct.field("default_limit", &self.default_limit);
18011        debug_struct.field("max_limit", &self.max_limit);
18012        debug_struct.field("free_tier", &self.free_tier);
18013        debug_struct.field("duration", &self.duration);
18014        debug_struct.field("metric", &self.metric);
18015        debug_struct.field("unit", &self.unit);
18016        debug_struct.field("values", &self.values);
18017        debug_struct.field("display_name", &self.display_name);
18018        if !self._unknown_fields.is_empty() {
18019            debug_struct.field("_unknown_fields", &self._unknown_fields);
18020        }
18021        debug_struct.finish()
18022    }
18023}
18024
18025/// A simple descriptor of a resource type.
18026///
18027/// ResourceDescriptor annotates a resource message (either by means of a
18028/// protobuf annotation or use in the service config), and associates the
18029/// resource's schema, the resource type, and the pattern of the resource name.
18030///
18031/// Example:
18032///
18033/// ```norust
18034/// message Topic {
18035///   // Indicates this message defines a resource schema.
18036///   // Declares the resource type in the format of {service}/{kind}.
18037///   // For Kubernetes resources, the format is {api group}/{kind}.
18038///   option (google.api.resource) = {
18039///     type: "pubsub.googleapis.com/Topic"
18040///     pattern: "projects/{project}/topics/{topic}"
18041///   };
18042/// }
18043/// ```
18044///
18045/// The ResourceDescriptor Yaml config will look like:
18046///
18047/// ```norust
18048/// resources:
18049/// - type: "pubsub.googleapis.com/Topic"
18050///   pattern: "projects/{project}/topics/{topic}"
18051/// ```
18052///
18053/// Sometimes, resources have multiple patterns, typically because they can
18054/// live under multiple parents.
18055///
18056/// Example:
18057///
18058/// ```norust
18059/// message LogEntry {
18060///   option (google.api.resource) = {
18061///     type: "logging.googleapis.com/LogEntry"
18062///     pattern: "projects/{project}/logs/{log}"
18063///     pattern: "folders/{folder}/logs/{log}"
18064///     pattern: "organizations/{organization}/logs/{log}"
18065///     pattern: "billingAccounts/{billing_account}/logs/{log}"
18066///   };
18067/// }
18068/// ```
18069///
18070/// The ResourceDescriptor Yaml config will look like:
18071///
18072/// ```norust
18073/// resources:
18074/// - type: 'logging.googleapis.com/LogEntry'
18075///   pattern: "projects/{project}/logs/{log}"
18076///   pattern: "folders/{folder}/logs/{log}"
18077///   pattern: "organizations/{organization}/logs/{log}"
18078///   pattern: "billingAccounts/{billing_account}/logs/{log}"
18079/// ```
18080#[derive(Clone, Default, PartialEq)]
18081#[non_exhaustive]
18082pub struct ResourceDescriptor {
18083    /// The resource type. It must be in the format of
18084    /// {service_name}/{resource_type_kind}. The `resource_type_kind` must be
18085    /// singular and must not include version numbers.
18086    ///
18087    /// Example: `storage.googleapis.com/Bucket`
18088    ///
18089    /// The value of the resource_type_kind must follow the regular expression
18090    /// /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
18091    /// should use PascalCase (UpperCamelCase). The maximum number of
18092    /// characters allowed for the `resource_type_kind` is 100.
18093    pub r#type: std::string::String,
18094
18095    /// Optional. The relative resource name pattern associated with this resource
18096    /// type. The DNS prefix of the full resource name shouldn't be specified here.
18097    ///
18098    /// The path pattern must follow the syntax, which aligns with HTTP binding
18099    /// syntax:
18100    ///
18101    /// ```norust
18102    /// Template = Segment { "/" Segment } ;
18103    /// Segment = LITERAL | Variable ;
18104    /// Variable = "{" LITERAL "}" ;
18105    /// ```
18106    ///
18107    /// Examples:
18108    ///
18109    /// ```norust
18110    /// - "projects/{project}/topics/{topic}"
18111    /// - "projects/{project}/knowledgeBases/{knowledge_base}"
18112    /// ```
18113    ///
18114    /// The components in braces correspond to the IDs for each resource in the
18115    /// hierarchy. It is expected that, if multiple patterns are provided,
18116    /// the same component name (e.g. "project") refers to IDs of the same
18117    /// type of resource.
18118    pub pattern: std::vec::Vec<std::string::String>,
18119
18120    /// Optional. The field on the resource that designates the resource name
18121    /// field. If omitted, this is assumed to be "name".
18122    pub name_field: std::string::String,
18123
18124    /// Optional. The historical or future-looking state of the resource pattern.
18125    ///
18126    /// Example:
18127    ///
18128    /// ```norust
18129    /// // The InspectTemplate message originally only supported resource
18130    /// // names with organization, and project was added later.
18131    /// message InspectTemplate {
18132    ///   option (google.api.resource) = {
18133    ///     type: "dlp.googleapis.com/InspectTemplate"
18134    ///     pattern:
18135    ///     "organizations/{organization}/inspectTemplates/{inspect_template}"
18136    ///     pattern: "projects/{project}/inspectTemplates/{inspect_template}"
18137    ///     history: ORIGINALLY_SINGLE_PATTERN
18138    ///   };
18139    /// }
18140    /// ```
18141    pub history: crate::model::resource_descriptor::History,
18142
18143    /// The plural name used in the resource name and permission names, such as
18144    /// 'projects' for the resource name of 'projects/{project}' and the permission
18145    /// name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception
18146    /// to this is for Nested Collections that have stuttering names, as defined
18147    /// in [AIP-122](https://google.aip.dev/122#nested-collections), where the
18148    /// collection ID in the resource name pattern does not necessarily directly
18149    /// match the `plural` value.
18150    ///
18151    /// It is the same concept of the `plural` field in k8s CRD spec
18152    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
18153    ///
18154    /// Note: The plural form is required even for singleton resources. See
18155    /// <https://aip.dev/156>
18156    pub plural: std::string::String,
18157
18158    /// The same concept of the `singular` field in k8s CRD spec
18159    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
18160    /// Such as "project" for the `resourcemanager.googleapis.com/Project` type.
18161    pub singular: std::string::String,
18162
18163    /// Style flag(s) for this resource.
18164    /// These indicate that a resource is expected to conform to a given
18165    /// style. See the specific style flags for additional information.
18166    pub style: std::vec::Vec<crate::model::resource_descriptor::Style>,
18167
18168    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18169}
18170
18171impl ResourceDescriptor {
18172    pub fn new() -> Self {
18173        std::default::Default::default()
18174    }
18175
18176    /// Sets the value of [r#type][crate::model::ResourceDescriptor::type].
18177    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18178        self.r#type = v.into();
18179        self
18180    }
18181
18182    /// Sets the value of [pattern][crate::model::ResourceDescriptor::pattern].
18183    pub fn set_pattern<T, V>(mut self, v: T) -> Self
18184    where
18185        T: std::iter::IntoIterator<Item = V>,
18186        V: std::convert::Into<std::string::String>,
18187    {
18188        use std::iter::Iterator;
18189        self.pattern = v.into_iter().map(|i| i.into()).collect();
18190        self
18191    }
18192
18193    /// Sets the value of [name_field][crate::model::ResourceDescriptor::name_field].
18194    pub fn set_name_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18195        self.name_field = v.into();
18196        self
18197    }
18198
18199    /// Sets the value of [history][crate::model::ResourceDescriptor::history].
18200    pub fn set_history<T: std::convert::Into<crate::model::resource_descriptor::History>>(
18201        mut self,
18202        v: T,
18203    ) -> Self {
18204        self.history = v.into();
18205        self
18206    }
18207
18208    /// Sets the value of [plural][crate::model::ResourceDescriptor::plural].
18209    pub fn set_plural<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18210        self.plural = v.into();
18211        self
18212    }
18213
18214    /// Sets the value of [singular][crate::model::ResourceDescriptor::singular].
18215    pub fn set_singular<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18216        self.singular = v.into();
18217        self
18218    }
18219
18220    /// Sets the value of [style][crate::model::ResourceDescriptor::style].
18221    pub fn set_style<T, V>(mut self, v: T) -> Self
18222    where
18223        T: std::iter::IntoIterator<Item = V>,
18224        V: std::convert::Into<crate::model::resource_descriptor::Style>,
18225    {
18226        use std::iter::Iterator;
18227        self.style = v.into_iter().map(|i| i.into()).collect();
18228        self
18229    }
18230}
18231
18232impl wkt::message::Message for ResourceDescriptor {
18233    fn typename() -> &'static str {
18234        "type.googleapis.com/google.api.ResourceDescriptor"
18235    }
18236}
18237
18238#[doc(hidden)]
18239impl<'de> serde::de::Deserialize<'de> for ResourceDescriptor {
18240    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18241    where
18242        D: serde::Deserializer<'de>,
18243    {
18244        #[allow(non_camel_case_types)]
18245        #[doc(hidden)]
18246        #[derive(PartialEq, Eq, Hash)]
18247        enum __FieldTag {
18248            __type,
18249            __pattern,
18250            __name_field,
18251            __history,
18252            __plural,
18253            __singular,
18254            __style,
18255            Unknown(std::string::String),
18256        }
18257        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18258            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18259            where
18260                D: serde::Deserializer<'de>,
18261            {
18262                struct Visitor;
18263                impl<'de> serde::de::Visitor<'de> for Visitor {
18264                    type Value = __FieldTag;
18265                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18266                        formatter.write_str("a field name for ResourceDescriptor")
18267                    }
18268                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18269                    where
18270                        E: serde::de::Error,
18271                    {
18272                        use std::result::Result::Ok;
18273                        use std::string::ToString;
18274                        match value {
18275                            "type" => Ok(__FieldTag::__type),
18276                            "pattern" => Ok(__FieldTag::__pattern),
18277                            "nameField" => Ok(__FieldTag::__name_field),
18278                            "name_field" => Ok(__FieldTag::__name_field),
18279                            "history" => Ok(__FieldTag::__history),
18280                            "plural" => Ok(__FieldTag::__plural),
18281                            "singular" => Ok(__FieldTag::__singular),
18282                            "style" => Ok(__FieldTag::__style),
18283                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18284                        }
18285                    }
18286                }
18287                deserializer.deserialize_identifier(Visitor)
18288            }
18289        }
18290        struct Visitor;
18291        impl<'de> serde::de::Visitor<'de> for Visitor {
18292            type Value = ResourceDescriptor;
18293            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18294                formatter.write_str("struct ResourceDescriptor")
18295            }
18296            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18297            where
18298                A: serde::de::MapAccess<'de>,
18299            {
18300                #[allow(unused_imports)]
18301                use serde::de::Error;
18302                use std::option::Option::Some;
18303                let mut fields = std::collections::HashSet::new();
18304                let mut result = Self::Value::new();
18305                while let Some(tag) = map.next_key::<__FieldTag>()? {
18306                    #[allow(clippy::match_single_binding)]
18307                    match tag {
18308                        __FieldTag::__type => {
18309                            if !fields.insert(__FieldTag::__type) {
18310                                return std::result::Result::Err(A::Error::duplicate_field(
18311                                    "multiple values for type",
18312                                ));
18313                            }
18314                            result.r#type = map
18315                                .next_value::<std::option::Option<std::string::String>>()?
18316                                .unwrap_or_default();
18317                        }
18318                        __FieldTag::__pattern => {
18319                            if !fields.insert(__FieldTag::__pattern) {
18320                                return std::result::Result::Err(A::Error::duplicate_field(
18321                                    "multiple values for pattern",
18322                                ));
18323                            }
18324                            result.pattern = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
18325                        }
18326                        __FieldTag::__name_field => {
18327                            if !fields.insert(__FieldTag::__name_field) {
18328                                return std::result::Result::Err(A::Error::duplicate_field(
18329                                    "multiple values for name_field",
18330                                ));
18331                            }
18332                            result.name_field = map
18333                                .next_value::<std::option::Option<std::string::String>>()?
18334                                .unwrap_or_default();
18335                        }
18336                        __FieldTag::__history => {
18337                            if !fields.insert(__FieldTag::__history) {
18338                                return std::result::Result::Err(A::Error::duplicate_field(
18339                                    "multiple values for history",
18340                                ));
18341                            }
18342                            result.history = map.next_value::<std::option::Option<crate::model::resource_descriptor::History>>()?.unwrap_or_default();
18343                        }
18344                        __FieldTag::__plural => {
18345                            if !fields.insert(__FieldTag::__plural) {
18346                                return std::result::Result::Err(A::Error::duplicate_field(
18347                                    "multiple values for plural",
18348                                ));
18349                            }
18350                            result.plural = map
18351                                .next_value::<std::option::Option<std::string::String>>()?
18352                                .unwrap_or_default();
18353                        }
18354                        __FieldTag::__singular => {
18355                            if !fields.insert(__FieldTag::__singular) {
18356                                return std::result::Result::Err(A::Error::duplicate_field(
18357                                    "multiple values for singular",
18358                                ));
18359                            }
18360                            result.singular = map
18361                                .next_value::<std::option::Option<std::string::String>>()?
18362                                .unwrap_or_default();
18363                        }
18364                        __FieldTag::__style => {
18365                            if !fields.insert(__FieldTag::__style) {
18366                                return std::result::Result::Err(A::Error::duplicate_field(
18367                                    "multiple values for style",
18368                                ));
18369                            }
18370                            result.style = map
18371                                .next_value::<std::option::Option<
18372                                    std::vec::Vec<crate::model::resource_descriptor::Style>,
18373                                >>()?
18374                                .unwrap_or_default();
18375                        }
18376                        __FieldTag::Unknown(key) => {
18377                            let value = map.next_value::<serde_json::Value>()?;
18378                            result._unknown_fields.insert(key, value);
18379                        }
18380                    }
18381                }
18382                std::result::Result::Ok(result)
18383            }
18384        }
18385        deserializer.deserialize_any(Visitor)
18386    }
18387}
18388
18389#[doc(hidden)]
18390impl serde::ser::Serialize for ResourceDescriptor {
18391    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18392    where
18393        S: serde::ser::Serializer,
18394    {
18395        use serde::ser::SerializeMap;
18396        #[allow(unused_imports)]
18397        use std::option::Option::Some;
18398        let mut state = serializer.serialize_map(std::option::Option::None)?;
18399        if !self.r#type.is_empty() {
18400            state.serialize_entry("type", &self.r#type)?;
18401        }
18402        if !self.pattern.is_empty() {
18403            state.serialize_entry("pattern", &self.pattern)?;
18404        }
18405        if !self.name_field.is_empty() {
18406            state.serialize_entry("nameField", &self.name_field)?;
18407        }
18408        if !wkt::internal::is_default(&self.history) {
18409            state.serialize_entry("history", &self.history)?;
18410        }
18411        if !self.plural.is_empty() {
18412            state.serialize_entry("plural", &self.plural)?;
18413        }
18414        if !self.singular.is_empty() {
18415            state.serialize_entry("singular", &self.singular)?;
18416        }
18417        if !self.style.is_empty() {
18418            state.serialize_entry("style", &self.style)?;
18419        }
18420        if !self._unknown_fields.is_empty() {
18421            for (key, value) in self._unknown_fields.iter() {
18422                state.serialize_entry(key, &value)?;
18423            }
18424        }
18425        state.end()
18426    }
18427}
18428
18429impl std::fmt::Debug for ResourceDescriptor {
18430    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18431        let mut debug_struct = f.debug_struct("ResourceDescriptor");
18432        debug_struct.field("r#type", &self.r#type);
18433        debug_struct.field("pattern", &self.pattern);
18434        debug_struct.field("name_field", &self.name_field);
18435        debug_struct.field("history", &self.history);
18436        debug_struct.field("plural", &self.plural);
18437        debug_struct.field("singular", &self.singular);
18438        debug_struct.field("style", &self.style);
18439        if !self._unknown_fields.is_empty() {
18440            debug_struct.field("_unknown_fields", &self._unknown_fields);
18441        }
18442        debug_struct.finish()
18443    }
18444}
18445
18446/// Defines additional types related to [ResourceDescriptor].
18447pub mod resource_descriptor {
18448    #[allow(unused_imports)]
18449    use super::*;
18450
18451    /// A description of the historical or future-looking state of the
18452    /// resource pattern.
18453    ///
18454    /// # Working with unknown values
18455    ///
18456    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
18457    /// additional enum variants at any time. Adding new variants is not considered
18458    /// a breaking change. Applications should write their code in anticipation of:
18459    ///
18460    /// - New values appearing in future releases of the client library, **and**
18461    /// - New values received dynamically, without application changes.
18462    ///
18463    /// Please consult the [Working with enums] section in the user guide for some
18464    /// guidelines.
18465    ///
18466    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
18467    #[derive(Clone, Debug, PartialEq)]
18468    #[non_exhaustive]
18469    pub enum History {
18470        /// The "unset" value.
18471        Unspecified,
18472        /// The resource originally had one pattern and launched as such, and
18473        /// additional patterns were added later.
18474        OriginallySinglePattern,
18475        /// The resource has one pattern, but the API owner expects to add more
18476        /// later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents
18477        /// that from being necessary once there are multiple patterns.)
18478        FutureMultiPattern,
18479        /// If set, the enum was initialized with an unknown value.
18480        ///
18481        /// Applications can examine the value using [History::value] or
18482        /// [History::name].
18483        UnknownValue(history::UnknownValue),
18484    }
18485
18486    #[doc(hidden)]
18487    pub mod history {
18488        #[allow(unused_imports)]
18489        use super::*;
18490        #[derive(Clone, Debug, PartialEq)]
18491        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
18492    }
18493
18494    impl History {
18495        /// Gets the enum value.
18496        ///
18497        /// Returns `None` if the enum contains an unknown value deserialized from
18498        /// the string representation of enums.
18499        pub fn value(&self) -> std::option::Option<i32> {
18500            match self {
18501                Self::Unspecified => std::option::Option::Some(0),
18502                Self::OriginallySinglePattern => std::option::Option::Some(1),
18503                Self::FutureMultiPattern => std::option::Option::Some(2),
18504                Self::UnknownValue(u) => u.0.value(),
18505            }
18506        }
18507
18508        /// Gets the enum value as a string.
18509        ///
18510        /// Returns `None` if the enum contains an unknown value deserialized from
18511        /// the integer representation of enums.
18512        pub fn name(&self) -> std::option::Option<&str> {
18513            match self {
18514                Self::Unspecified => std::option::Option::Some("HISTORY_UNSPECIFIED"),
18515                Self::OriginallySinglePattern => {
18516                    std::option::Option::Some("ORIGINALLY_SINGLE_PATTERN")
18517                }
18518                Self::FutureMultiPattern => std::option::Option::Some("FUTURE_MULTI_PATTERN"),
18519                Self::UnknownValue(u) => u.0.name(),
18520            }
18521        }
18522    }
18523
18524    impl std::default::Default for History {
18525        fn default() -> Self {
18526            use std::convert::From;
18527            Self::from(0)
18528        }
18529    }
18530
18531    impl std::fmt::Display for History {
18532        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
18533            wkt::internal::display_enum(f, self.name(), self.value())
18534        }
18535    }
18536
18537    impl std::convert::From<i32> for History {
18538        fn from(value: i32) -> Self {
18539            match value {
18540                0 => Self::Unspecified,
18541                1 => Self::OriginallySinglePattern,
18542                2 => Self::FutureMultiPattern,
18543                _ => Self::UnknownValue(history::UnknownValue(
18544                    wkt::internal::UnknownEnumValue::Integer(value),
18545                )),
18546            }
18547        }
18548    }
18549
18550    impl std::convert::From<&str> for History {
18551        fn from(value: &str) -> Self {
18552            use std::string::ToString;
18553            match value {
18554                "HISTORY_UNSPECIFIED" => Self::Unspecified,
18555                "ORIGINALLY_SINGLE_PATTERN" => Self::OriginallySinglePattern,
18556                "FUTURE_MULTI_PATTERN" => Self::FutureMultiPattern,
18557                _ => Self::UnknownValue(history::UnknownValue(
18558                    wkt::internal::UnknownEnumValue::String(value.to_string()),
18559                )),
18560            }
18561        }
18562    }
18563
18564    impl serde::ser::Serialize for History {
18565        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18566        where
18567            S: serde::Serializer,
18568        {
18569            match self {
18570                Self::Unspecified => serializer.serialize_i32(0),
18571                Self::OriginallySinglePattern => serializer.serialize_i32(1),
18572                Self::FutureMultiPattern => serializer.serialize_i32(2),
18573                Self::UnknownValue(u) => u.0.serialize(serializer),
18574            }
18575        }
18576    }
18577
18578    impl<'de> serde::de::Deserialize<'de> for History {
18579        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18580        where
18581            D: serde::Deserializer<'de>,
18582        {
18583            deserializer.deserialize_any(wkt::internal::EnumVisitor::<History>::new(
18584                ".google.api.ResourceDescriptor.History",
18585            ))
18586        }
18587    }
18588
18589    /// A flag representing a specific style that a resource claims to conform to.
18590    ///
18591    /// # Working with unknown values
18592    ///
18593    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
18594    /// additional enum variants at any time. Adding new variants is not considered
18595    /// a breaking change. Applications should write their code in anticipation of:
18596    ///
18597    /// - New values appearing in future releases of the client library, **and**
18598    /// - New values received dynamically, without application changes.
18599    ///
18600    /// Please consult the [Working with enums] section in the user guide for some
18601    /// guidelines.
18602    ///
18603    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
18604    #[derive(Clone, Debug, PartialEq)]
18605    #[non_exhaustive]
18606    pub enum Style {
18607        /// The unspecified value. Do not use.
18608        Unspecified,
18609        /// This resource is intended to be "declarative-friendly".
18610        ///
18611        /// Declarative-friendly resources must be more strictly consistent, and
18612        /// setting this to true communicates to tools that this resource should
18613        /// adhere to declarative-friendly expectations.
18614        ///
18615        /// Note: This is used by the API linter (linter.aip.dev) to enable
18616        /// additional checks.
18617        DeclarativeFriendly,
18618        /// If set, the enum was initialized with an unknown value.
18619        ///
18620        /// Applications can examine the value using [Style::value] or
18621        /// [Style::name].
18622        UnknownValue(style::UnknownValue),
18623    }
18624
18625    #[doc(hidden)]
18626    pub mod style {
18627        #[allow(unused_imports)]
18628        use super::*;
18629        #[derive(Clone, Debug, PartialEq)]
18630        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
18631    }
18632
18633    impl Style {
18634        /// Gets the enum value.
18635        ///
18636        /// Returns `None` if the enum contains an unknown value deserialized from
18637        /// the string representation of enums.
18638        pub fn value(&self) -> std::option::Option<i32> {
18639            match self {
18640                Self::Unspecified => std::option::Option::Some(0),
18641                Self::DeclarativeFriendly => std::option::Option::Some(1),
18642                Self::UnknownValue(u) => u.0.value(),
18643            }
18644        }
18645
18646        /// Gets the enum value as a string.
18647        ///
18648        /// Returns `None` if the enum contains an unknown value deserialized from
18649        /// the integer representation of enums.
18650        pub fn name(&self) -> std::option::Option<&str> {
18651            match self {
18652                Self::Unspecified => std::option::Option::Some("STYLE_UNSPECIFIED"),
18653                Self::DeclarativeFriendly => std::option::Option::Some("DECLARATIVE_FRIENDLY"),
18654                Self::UnknownValue(u) => u.0.name(),
18655            }
18656        }
18657    }
18658
18659    impl std::default::Default for Style {
18660        fn default() -> Self {
18661            use std::convert::From;
18662            Self::from(0)
18663        }
18664    }
18665
18666    impl std::fmt::Display for Style {
18667        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
18668            wkt::internal::display_enum(f, self.name(), self.value())
18669        }
18670    }
18671
18672    impl std::convert::From<i32> for Style {
18673        fn from(value: i32) -> Self {
18674            match value {
18675                0 => Self::Unspecified,
18676                1 => Self::DeclarativeFriendly,
18677                _ => Self::UnknownValue(style::UnknownValue(
18678                    wkt::internal::UnknownEnumValue::Integer(value),
18679                )),
18680            }
18681        }
18682    }
18683
18684    impl std::convert::From<&str> for Style {
18685        fn from(value: &str) -> Self {
18686            use std::string::ToString;
18687            match value {
18688                "STYLE_UNSPECIFIED" => Self::Unspecified,
18689                "DECLARATIVE_FRIENDLY" => Self::DeclarativeFriendly,
18690                _ => Self::UnknownValue(style::UnknownValue(
18691                    wkt::internal::UnknownEnumValue::String(value.to_string()),
18692                )),
18693            }
18694        }
18695    }
18696
18697    impl serde::ser::Serialize for Style {
18698        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18699        where
18700            S: serde::Serializer,
18701        {
18702            match self {
18703                Self::Unspecified => serializer.serialize_i32(0),
18704                Self::DeclarativeFriendly => serializer.serialize_i32(1),
18705                Self::UnknownValue(u) => u.0.serialize(serializer),
18706            }
18707        }
18708    }
18709
18710    impl<'de> serde::de::Deserialize<'de> for Style {
18711        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18712        where
18713            D: serde::Deserializer<'de>,
18714        {
18715            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Style>::new(
18716                ".google.api.ResourceDescriptor.Style",
18717            ))
18718        }
18719    }
18720}
18721
18722/// Defines a proto annotation that describes a string field that refers to
18723/// an API resource.
18724#[derive(Clone, Default, PartialEq)]
18725#[non_exhaustive]
18726pub struct ResourceReference {
18727    /// The resource type that the annotated field references.
18728    ///
18729    /// Example:
18730    ///
18731    /// ```norust
18732    /// message Subscription {
18733    ///   string topic = 2 [(google.api.resource_reference) = {
18734    ///     type: "pubsub.googleapis.com/Topic"
18735    ///   }];
18736    /// }
18737    /// ```
18738    ///
18739    /// Occasionally, a field may reference an arbitrary resource. In this case,
18740    /// APIs use the special value * in their resource reference.
18741    ///
18742    /// Example:
18743    ///
18744    /// ```norust
18745    /// message GetIamPolicyRequest {
18746    ///   string resource = 2 [(google.api.resource_reference) = {
18747    ///     type: "*"
18748    ///   }];
18749    /// }
18750    /// ```
18751    pub r#type: std::string::String,
18752
18753    /// The resource type of a child collection that the annotated field
18754    /// references. This is useful for annotating the `parent` field that
18755    /// doesn't have a fixed resource type.
18756    ///
18757    /// Example:
18758    ///
18759    /// ```norust
18760    /// message ListLogEntriesRequest {
18761    ///   string parent = 1 [(google.api.resource_reference) = {
18762    ///     child_type: "logging.googleapis.com/LogEntry"
18763    ///   };
18764    /// }
18765    /// ```
18766    pub child_type: std::string::String,
18767
18768    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18769}
18770
18771impl ResourceReference {
18772    pub fn new() -> Self {
18773        std::default::Default::default()
18774    }
18775
18776    /// Sets the value of [r#type][crate::model::ResourceReference::type].
18777    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18778        self.r#type = v.into();
18779        self
18780    }
18781
18782    /// Sets the value of [child_type][crate::model::ResourceReference::child_type].
18783    pub fn set_child_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18784        self.child_type = v.into();
18785        self
18786    }
18787}
18788
18789impl wkt::message::Message for ResourceReference {
18790    fn typename() -> &'static str {
18791        "type.googleapis.com/google.api.ResourceReference"
18792    }
18793}
18794
18795#[doc(hidden)]
18796impl<'de> serde::de::Deserialize<'de> for ResourceReference {
18797    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18798    where
18799        D: serde::Deserializer<'de>,
18800    {
18801        #[allow(non_camel_case_types)]
18802        #[doc(hidden)]
18803        #[derive(PartialEq, Eq, Hash)]
18804        enum __FieldTag {
18805            __type,
18806            __child_type,
18807            Unknown(std::string::String),
18808        }
18809        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18810            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18811            where
18812                D: serde::Deserializer<'de>,
18813            {
18814                struct Visitor;
18815                impl<'de> serde::de::Visitor<'de> for Visitor {
18816                    type Value = __FieldTag;
18817                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18818                        formatter.write_str("a field name for ResourceReference")
18819                    }
18820                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18821                    where
18822                        E: serde::de::Error,
18823                    {
18824                        use std::result::Result::Ok;
18825                        use std::string::ToString;
18826                        match value {
18827                            "type" => Ok(__FieldTag::__type),
18828                            "childType" => Ok(__FieldTag::__child_type),
18829                            "child_type" => Ok(__FieldTag::__child_type),
18830                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18831                        }
18832                    }
18833                }
18834                deserializer.deserialize_identifier(Visitor)
18835            }
18836        }
18837        struct Visitor;
18838        impl<'de> serde::de::Visitor<'de> for Visitor {
18839            type Value = ResourceReference;
18840            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18841                formatter.write_str("struct ResourceReference")
18842            }
18843            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18844            where
18845                A: serde::de::MapAccess<'de>,
18846            {
18847                #[allow(unused_imports)]
18848                use serde::de::Error;
18849                use std::option::Option::Some;
18850                let mut fields = std::collections::HashSet::new();
18851                let mut result = Self::Value::new();
18852                while let Some(tag) = map.next_key::<__FieldTag>()? {
18853                    #[allow(clippy::match_single_binding)]
18854                    match tag {
18855                        __FieldTag::__type => {
18856                            if !fields.insert(__FieldTag::__type) {
18857                                return std::result::Result::Err(A::Error::duplicate_field(
18858                                    "multiple values for type",
18859                                ));
18860                            }
18861                            result.r#type = map
18862                                .next_value::<std::option::Option<std::string::String>>()?
18863                                .unwrap_or_default();
18864                        }
18865                        __FieldTag::__child_type => {
18866                            if !fields.insert(__FieldTag::__child_type) {
18867                                return std::result::Result::Err(A::Error::duplicate_field(
18868                                    "multiple values for child_type",
18869                                ));
18870                            }
18871                            result.child_type = map
18872                                .next_value::<std::option::Option<std::string::String>>()?
18873                                .unwrap_or_default();
18874                        }
18875                        __FieldTag::Unknown(key) => {
18876                            let value = map.next_value::<serde_json::Value>()?;
18877                            result._unknown_fields.insert(key, value);
18878                        }
18879                    }
18880                }
18881                std::result::Result::Ok(result)
18882            }
18883        }
18884        deserializer.deserialize_any(Visitor)
18885    }
18886}
18887
18888#[doc(hidden)]
18889impl serde::ser::Serialize for ResourceReference {
18890    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18891    where
18892        S: serde::ser::Serializer,
18893    {
18894        use serde::ser::SerializeMap;
18895        #[allow(unused_imports)]
18896        use std::option::Option::Some;
18897        let mut state = serializer.serialize_map(std::option::Option::None)?;
18898        if !self.r#type.is_empty() {
18899            state.serialize_entry("type", &self.r#type)?;
18900        }
18901        if !self.child_type.is_empty() {
18902            state.serialize_entry("childType", &self.child_type)?;
18903        }
18904        if !self._unknown_fields.is_empty() {
18905            for (key, value) in self._unknown_fields.iter() {
18906                state.serialize_entry(key, &value)?;
18907            }
18908        }
18909        state.end()
18910    }
18911}
18912
18913impl std::fmt::Debug for ResourceReference {
18914    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18915        let mut debug_struct = f.debug_struct("ResourceReference");
18916        debug_struct.field("r#type", &self.r#type);
18917        debug_struct.field("child_type", &self.child_type);
18918        if !self._unknown_fields.is_empty() {
18919            debug_struct.field("_unknown_fields", &self._unknown_fields);
18920        }
18921        debug_struct.finish()
18922    }
18923}
18924
18925/// Specifies the routing information that should be sent along with the request
18926/// in the form of routing header.
18927/// **NOTE:** All service configuration rules follow the "last one wins" order.
18928///
18929/// The examples below will apply to an RPC which has the following request type:
18930///
18931/// Message Definition:
18932///
18933/// ```norust
18934/// message Request {
18935///   // The name of the Table
18936///   // Values can be of the following formats:
18937///   // - `projects/<project>/tables/<table>`
18938///   // - `projects/<project>/instances/<instance>/tables/<table>`
18939///   // - `region/<region>/zones/<zone>/tables/<table>`
18940///   string table_name = 1;
18941///
18942///   // This value specifies routing for replication.
18943///   // It can be in the following formats:
18944///   // - `profiles/<profile_id>`
18945///   // - a legacy `profile_id` that can be any string
18946///   string app_profile_id = 2;
18947/// }
18948/// ```
18949///
18950/// Example message:
18951///
18952/// ```norust
18953/// {
18954///   table_name: projects/proj_foo/instances/instance_bar/table/table_baz,
18955///   app_profile_id: profiles/prof_qux
18956/// }
18957/// ```
18958///
18959/// The routing header consists of one or multiple key-value pairs. Every key
18960/// and value must be percent-encoded, and joined together in the format of
18961/// `key1=value1&key2=value2`.
18962/// The examples below skip the percent-encoding for readability.
18963///
18964/// Example 1
18965///
18966/// Extracting a field from the request to put into the routing header
18967/// unchanged, with the key equal to the field name.
18968///
18969/// annotation:
18970///
18971/// ```norust
18972/// option (google.api.routing) = {
18973///   // Take the `app_profile_id`.
18974///   routing_parameters {
18975///     field: "app_profile_id"
18976///   }
18977/// };
18978/// ```
18979///
18980/// result:
18981///
18982/// ```norust
18983/// x-goog-request-params: app_profile_id=profiles/prof_qux
18984/// ```
18985///
18986/// Example 2
18987///
18988/// Extracting a field from the request to put into the routing header
18989/// unchanged, with the key different from the field name.
18990///
18991/// annotation:
18992///
18993/// ```norust
18994/// option (google.api.routing) = {
18995///   // Take the `app_profile_id`, but name it `routing_id` in the header.
18996///   routing_parameters {
18997///     field: "app_profile_id"
18998///     path_template: "{routing_id=**}"
18999///   }
19000/// };
19001/// ```
19002///
19003/// result:
19004///
19005/// ```norust
19006/// x-goog-request-params: routing_id=profiles/prof_qux
19007/// ```
19008///
19009/// Example 3
19010///
19011/// Extracting a field from the request to put into the routing
19012/// header, while matching a path template syntax on the field's value.
19013///
19014/// NB: it is more useful to send nothing than to send garbage for the purpose
19015/// of dynamic routing, since garbage pollutes cache. Thus the matching.
19016///
19017/// Sub-example 3a
19018///
19019/// The field matches the template.
19020///
19021/// annotation:
19022///
19023/// ```norust
19024/// option (google.api.routing) = {
19025///   // Take the `table_name`, if it's well-formed (with project-based
19026///   // syntax).
19027///   routing_parameters {
19028///     field: "table_name"
19029///     path_template: "{table_name=projects/*/instances/*/**}"
19030///   }
19031/// };
19032/// ```
19033///
19034/// result:
19035///
19036/// ```norust
19037/// x-goog-request-params:
19038/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
19039/// ```
19040///
19041/// Sub-example 3b
19042///
19043/// The field does not match the template.
19044///
19045/// annotation:
19046///
19047/// ```norust
19048/// option (google.api.routing) = {
19049///   // Take the `table_name`, if it's well-formed (with region-based
19050///   // syntax).
19051///   routing_parameters {
19052///     field: "table_name"
19053///     path_template: "{table_name=regions/*/zones/*/**}"
19054///   }
19055/// };
19056/// ```
19057///
19058/// result:
19059///
19060/// ```norust
19061/// <no routing header will be sent>
19062/// ```
19063///
19064/// Sub-example 3c
19065///
19066/// Multiple alternative conflictingly named path templates are
19067/// specified. The one that matches is used to construct the header.
19068///
19069/// annotation:
19070///
19071/// ```norust
19072/// option (google.api.routing) = {
19073///   // Take the `table_name`, if it's well-formed, whether
19074///   // using the region- or projects-based syntax.
19075///
19076///   routing_parameters {
19077///     field: "table_name"
19078///     path_template: "{table_name=regions/*/zones/*/**}"
19079///   }
19080///   routing_parameters {
19081///     field: "table_name"
19082///     path_template: "{table_name=projects/*/instances/*/**}"
19083///   }
19084/// };
19085/// ```
19086///
19087/// result:
19088///
19089/// ```norust
19090/// x-goog-request-params:
19091/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
19092/// ```
19093///
19094/// Example 4
19095///
19096/// Extracting a single routing header key-value pair by matching a
19097/// template syntax on (a part of) a single request field.
19098///
19099/// annotation:
19100///
19101/// ```norust
19102/// option (google.api.routing) = {
19103///   // Take just the project id from the `table_name` field.
19104///   routing_parameters {
19105///     field: "table_name"
19106///     path_template: "{routing_id=projects/*}/**"
19107///   }
19108/// };
19109/// ```
19110///
19111/// result:
19112///
19113/// ```norust
19114/// x-goog-request-params: routing_id=projects/proj_foo
19115/// ```
19116///
19117/// Example 5
19118///
19119/// Extracting a single routing header key-value pair by matching
19120/// several conflictingly named path templates on (parts of) a single request
19121/// field. The last template to match "wins" the conflict.
19122///
19123/// annotation:
19124///
19125/// ```norust
19126/// option (google.api.routing) = {
19127///   // If the `table_name` does not have instances information,
19128///   // take just the project id for routing.
19129///   // Otherwise take project + instance.
19130///
19131///   routing_parameters {
19132///     field: "table_name"
19133///     path_template: "{routing_id=projects/*}/**"
19134///   }
19135///   routing_parameters {
19136///     field: "table_name"
19137///     path_template: "{routing_id=projects/*/instances/*}/**"
19138///   }
19139/// };
19140/// ```
19141///
19142/// result:
19143///
19144/// ```norust
19145/// x-goog-request-params:
19146/// routing_id=projects/proj_foo/instances/instance_bar
19147/// ```
19148///
19149/// Example 6
19150///
19151/// Extracting multiple routing header key-value pairs by matching
19152/// several non-conflicting path templates on (parts of) a single request field.
19153///
19154/// Sub-example 6a
19155///
19156/// Make the templates strict, so that if the `table_name` does not
19157/// have an instance information, nothing is sent.
19158///
19159/// annotation:
19160///
19161/// ```norust
19162/// option (google.api.routing) = {
19163///   // The routing code needs two keys instead of one composite
19164///   // but works only for the tables with the "project-instance" name
19165///   // syntax.
19166///
19167///   routing_parameters {
19168///     field: "table_name"
19169///     path_template: "{project_id=projects/*}/instances/*/**"
19170///   }
19171///   routing_parameters {
19172///     field: "table_name"
19173///     path_template: "projects/*/{instance_id=instances/*}/**"
19174///   }
19175/// };
19176/// ```
19177///
19178/// result:
19179///
19180/// ```norust
19181/// x-goog-request-params:
19182/// project_id=projects/proj_foo&instance_id=instances/instance_bar
19183/// ```
19184///
19185/// Sub-example 6b
19186///
19187/// Make the templates loose, so that if the `table_name` does not
19188/// have an instance information, just the project id part is sent.
19189///
19190/// annotation:
19191///
19192/// ```norust
19193/// option (google.api.routing) = {
19194///   // The routing code wants two keys instead of one composite
19195///   // but will work with just the `project_id` for tables without
19196///   // an instance in the `table_name`.
19197///
19198///   routing_parameters {
19199///     field: "table_name"
19200///     path_template: "{project_id=projects/*}/**"
19201///   }
19202///   routing_parameters {
19203///     field: "table_name"
19204///     path_template: "projects/*/{instance_id=instances/*}/**"
19205///   }
19206/// };
19207/// ```
19208///
19209/// result (is the same as 6a for our example message because it has the instance
19210/// information):
19211///
19212/// ```norust
19213/// x-goog-request-params:
19214/// project_id=projects/proj_foo&instance_id=instances/instance_bar
19215/// ```
19216///
19217/// Example 7
19218///
19219/// Extracting multiple routing header key-value pairs by matching
19220/// several path templates on multiple request fields.
19221///
19222/// NB: note that here there is no way to specify sending nothing if one of the
19223/// fields does not match its template. E.g. if the `table_name` is in the wrong
19224/// format, the `project_id` will not be sent, but the `routing_id` will be.
19225/// The backend routing code has to be aware of that and be prepared to not
19226/// receive a full complement of keys if it expects multiple.
19227///
19228/// annotation:
19229///
19230/// ```norust
19231/// option (google.api.routing) = {
19232///   // The routing needs both `project_id` and `routing_id`
19233///   // (from the `app_profile_id` field) for routing.
19234///
19235///   routing_parameters {
19236///     field: "table_name"
19237///     path_template: "{project_id=projects/*}/**"
19238///   }
19239///   routing_parameters {
19240///     field: "app_profile_id"
19241///     path_template: "{routing_id=**}"
19242///   }
19243/// };
19244/// ```
19245///
19246/// result:
19247///
19248/// ```norust
19249/// x-goog-request-params:
19250/// project_id=projects/proj_foo&routing_id=profiles/prof_qux
19251/// ```
19252///
19253/// Example 8
19254///
19255/// Extracting a single routing header key-value pair by matching
19256/// several conflictingly named path templates on several request fields. The
19257/// last template to match "wins" the conflict.
19258///
19259/// annotation:
19260///
19261/// ```norust
19262/// option (google.api.routing) = {
19263///   // The `routing_id` can be a project id or a region id depending on
19264///   // the table name format, but only if the `app_profile_id` is not set.
19265///   // If `app_profile_id` is set it should be used instead.
19266///
19267///   routing_parameters {
19268///     field: "table_name"
19269///     path_template: "{routing_id=projects/*}/**"
19270///   }
19271///   routing_parameters {
19272///      field: "table_name"
19273///      path_template: "{routing_id=regions/*}/**"
19274///   }
19275///   routing_parameters {
19276///     field: "app_profile_id"
19277///     path_template: "{routing_id=**}"
19278///   }
19279/// };
19280/// ```
19281///
19282/// result:
19283///
19284/// ```norust
19285/// x-goog-request-params: routing_id=profiles/prof_qux
19286/// ```
19287///
19288/// Example 9
19289///
19290/// Bringing it all together.
19291///
19292/// annotation:
19293///
19294/// ```norust
19295/// option (google.api.routing) = {
19296///   // For routing both `table_location` and a `routing_id` are needed.
19297///   //
19298///   // table_location can be either an instance id or a region+zone id.
19299///   //
19300///   // For `routing_id`, take the value of `app_profile_id`
19301///   // - If it's in the format `profiles/<profile_id>`, send
19302///   // just the `<profile_id>` part.
19303///   // - If it's any other literal, send it as is.
19304///   // If the `app_profile_id` is empty, and the `table_name` starts with
19305///   // the project_id, send that instead.
19306///
19307///   routing_parameters {
19308///     field: "table_name"
19309///     path_template: "projects/*/{table_location=instances/*}/tables/*"
19310///   }
19311///   routing_parameters {
19312///     field: "table_name"
19313///     path_template: "{table_location=regions/*/zones/*}/tables/*"
19314///   }
19315///   routing_parameters {
19316///     field: "table_name"
19317///     path_template: "{routing_id=projects/*}/**"
19318///   }
19319///   routing_parameters {
19320///     field: "app_profile_id"
19321///     path_template: "{routing_id=**}"
19322///   }
19323///   routing_parameters {
19324///     field: "app_profile_id"
19325///     path_template: "profiles/{routing_id=*}"
19326///   }
19327/// };
19328/// ```
19329///
19330/// result:
19331///
19332/// ```norust
19333/// x-goog-request-params:
19334/// table_location=instances/instance_bar&routing_id=prof_qux
19335/// ```
19336#[derive(Clone, Default, PartialEq)]
19337#[non_exhaustive]
19338pub struct RoutingRule {
19339    /// A collection of Routing Parameter specifications.
19340    /// **NOTE:** If multiple Routing Parameters describe the same key
19341    /// (via the `path_template` field or via the `field` field when
19342    /// `path_template` is not provided), "last one wins" rule
19343    /// determines which Parameter gets used.
19344    /// See the examples for more details.
19345    pub routing_parameters: std::vec::Vec<crate::model::RoutingParameter>,
19346
19347    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19348}
19349
19350impl RoutingRule {
19351    pub fn new() -> Self {
19352        std::default::Default::default()
19353    }
19354
19355    /// Sets the value of [routing_parameters][crate::model::RoutingRule::routing_parameters].
19356    pub fn set_routing_parameters<T, V>(mut self, v: T) -> Self
19357    where
19358        T: std::iter::IntoIterator<Item = V>,
19359        V: std::convert::Into<crate::model::RoutingParameter>,
19360    {
19361        use std::iter::Iterator;
19362        self.routing_parameters = v.into_iter().map(|i| i.into()).collect();
19363        self
19364    }
19365}
19366
19367impl wkt::message::Message for RoutingRule {
19368    fn typename() -> &'static str {
19369        "type.googleapis.com/google.api.RoutingRule"
19370    }
19371}
19372
19373#[doc(hidden)]
19374impl<'de> serde::de::Deserialize<'de> for RoutingRule {
19375    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19376    where
19377        D: serde::Deserializer<'de>,
19378    {
19379        #[allow(non_camel_case_types)]
19380        #[doc(hidden)]
19381        #[derive(PartialEq, Eq, Hash)]
19382        enum __FieldTag {
19383            __routing_parameters,
19384            Unknown(std::string::String),
19385        }
19386        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19387            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19388            where
19389                D: serde::Deserializer<'de>,
19390            {
19391                struct Visitor;
19392                impl<'de> serde::de::Visitor<'de> for Visitor {
19393                    type Value = __FieldTag;
19394                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19395                        formatter.write_str("a field name for RoutingRule")
19396                    }
19397                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19398                    where
19399                        E: serde::de::Error,
19400                    {
19401                        use std::result::Result::Ok;
19402                        use std::string::ToString;
19403                        match value {
19404                            "routingParameters" => Ok(__FieldTag::__routing_parameters),
19405                            "routing_parameters" => Ok(__FieldTag::__routing_parameters),
19406                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19407                        }
19408                    }
19409                }
19410                deserializer.deserialize_identifier(Visitor)
19411            }
19412        }
19413        struct Visitor;
19414        impl<'de> serde::de::Visitor<'de> for Visitor {
19415            type Value = RoutingRule;
19416            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19417                formatter.write_str("struct RoutingRule")
19418            }
19419            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19420            where
19421                A: serde::de::MapAccess<'de>,
19422            {
19423                #[allow(unused_imports)]
19424                use serde::de::Error;
19425                use std::option::Option::Some;
19426                let mut fields = std::collections::HashSet::new();
19427                let mut result = Self::Value::new();
19428                while let Some(tag) = map.next_key::<__FieldTag>()? {
19429                    #[allow(clippy::match_single_binding)]
19430                    match tag {
19431                        __FieldTag::__routing_parameters => {
19432                            if !fields.insert(__FieldTag::__routing_parameters) {
19433                                return std::result::Result::Err(A::Error::duplicate_field(
19434                                    "multiple values for routing_parameters",
19435                                ));
19436                            }
19437                            result.routing_parameters =
19438                                map.next_value::<std::option::Option<
19439                                    std::vec::Vec<crate::model::RoutingParameter>,
19440                                >>()?
19441                                .unwrap_or_default();
19442                        }
19443                        __FieldTag::Unknown(key) => {
19444                            let value = map.next_value::<serde_json::Value>()?;
19445                            result._unknown_fields.insert(key, value);
19446                        }
19447                    }
19448                }
19449                std::result::Result::Ok(result)
19450            }
19451        }
19452        deserializer.deserialize_any(Visitor)
19453    }
19454}
19455
19456#[doc(hidden)]
19457impl serde::ser::Serialize for RoutingRule {
19458    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19459    where
19460        S: serde::ser::Serializer,
19461    {
19462        use serde::ser::SerializeMap;
19463        #[allow(unused_imports)]
19464        use std::option::Option::Some;
19465        let mut state = serializer.serialize_map(std::option::Option::None)?;
19466        if !self.routing_parameters.is_empty() {
19467            state.serialize_entry("routingParameters", &self.routing_parameters)?;
19468        }
19469        if !self._unknown_fields.is_empty() {
19470            for (key, value) in self._unknown_fields.iter() {
19471                state.serialize_entry(key, &value)?;
19472            }
19473        }
19474        state.end()
19475    }
19476}
19477
19478impl std::fmt::Debug for RoutingRule {
19479    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19480        let mut debug_struct = f.debug_struct("RoutingRule");
19481        debug_struct.field("routing_parameters", &self.routing_parameters);
19482        if !self._unknown_fields.is_empty() {
19483            debug_struct.field("_unknown_fields", &self._unknown_fields);
19484        }
19485        debug_struct.finish()
19486    }
19487}
19488
19489/// A projection from an input message to the GRPC or REST header.
19490#[derive(Clone, Default, PartialEq)]
19491#[non_exhaustive]
19492pub struct RoutingParameter {
19493    /// A request field to extract the header key-value pair from.
19494    pub field: std::string::String,
19495
19496    /// A pattern matching the key-value field. Optional.
19497    /// If not specified, the whole field specified in the `field` field will be
19498    /// taken as value, and its name used as key. If specified, it MUST contain
19499    /// exactly one named segment (along with any number of unnamed segments) The
19500    /// pattern will be matched over the field specified in the `field` field, then
19501    /// if the match is successful:
19502    ///
19503    /// - the name of the single named segment will be used as a header name,
19504    /// - the match value of the segment will be used as a header value;
19505    ///   if the match is NOT successful, nothing will be sent.
19506    ///
19507    /// Example:
19508    ///
19509    /// ```norust
19510    ///           -- This is a field in the request message
19511    ///          |   that the header value will be extracted from.
19512    ///          |
19513    ///          |                     -- This is the key name in the
19514    ///          |                    |   routing header.
19515    ///          V                    |
19516    /// field: "table_name"           v
19517    /// path_template: "projects/*/{table_location=instances/*}/tables/*"
19518    ///                                            ^            ^
19519    ///                                            |            |
19520    ///   In the {} brackets is the pattern that --             |
19521    ///   specifies what to extract from the                    |
19522    ///   field as a value to be sent.                          |
19523    ///                                                         |
19524    ///  The string in the field must match the whole pattern --
19525    ///  before brackets, inside brackets, after brackets.
19526    /// ```
19527    ///
19528    /// When looking at this specific example, we can see that:
19529    ///
19530    /// - A key-value pair with the key `table_location`
19531    ///   and the value matching `instances/*` should be added
19532    ///   to the x-goog-request-params routing header.
19533    /// - The value is extracted from the request message's `table_name` field
19534    ///   if it matches the full pattern specified:
19535    ///   `projects/*/instances/*/tables/*`.
19536    ///
19537    /// **NB:** If the `path_template` field is not provided, the key name is
19538    /// equal to the field name, and the whole field should be sent as a value.
19539    /// This makes the pattern for the field and the value functionally equivalent
19540    /// to `**`, and the configuration
19541    ///
19542    /// ```norust
19543    /// {
19544    ///   field: "table_name"
19545    /// }
19546    /// ```
19547    ///
19548    /// is a functionally equivalent shorthand to:
19549    ///
19550    /// ```norust
19551    /// {
19552    ///   field: "table_name"
19553    ///   path_template: "{table_name=**}"
19554    /// }
19555    /// ```
19556    ///
19557    /// See Example 1 for more details.
19558    pub path_template: std::string::String,
19559
19560    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19561}
19562
19563impl RoutingParameter {
19564    pub fn new() -> Self {
19565        std::default::Default::default()
19566    }
19567
19568    /// Sets the value of [field][crate::model::RoutingParameter::field].
19569    pub fn set_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19570        self.field = v.into();
19571        self
19572    }
19573
19574    /// Sets the value of [path_template][crate::model::RoutingParameter::path_template].
19575    pub fn set_path_template<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19576        self.path_template = v.into();
19577        self
19578    }
19579}
19580
19581impl wkt::message::Message for RoutingParameter {
19582    fn typename() -> &'static str {
19583        "type.googleapis.com/google.api.RoutingParameter"
19584    }
19585}
19586
19587#[doc(hidden)]
19588impl<'de> serde::de::Deserialize<'de> for RoutingParameter {
19589    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19590    where
19591        D: serde::Deserializer<'de>,
19592    {
19593        #[allow(non_camel_case_types)]
19594        #[doc(hidden)]
19595        #[derive(PartialEq, Eq, Hash)]
19596        enum __FieldTag {
19597            __field,
19598            __path_template,
19599            Unknown(std::string::String),
19600        }
19601        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19602            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19603            where
19604                D: serde::Deserializer<'de>,
19605            {
19606                struct Visitor;
19607                impl<'de> serde::de::Visitor<'de> for Visitor {
19608                    type Value = __FieldTag;
19609                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19610                        formatter.write_str("a field name for RoutingParameter")
19611                    }
19612                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19613                    where
19614                        E: serde::de::Error,
19615                    {
19616                        use std::result::Result::Ok;
19617                        use std::string::ToString;
19618                        match value {
19619                            "field" => Ok(__FieldTag::__field),
19620                            "pathTemplate" => Ok(__FieldTag::__path_template),
19621                            "path_template" => Ok(__FieldTag::__path_template),
19622                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19623                        }
19624                    }
19625                }
19626                deserializer.deserialize_identifier(Visitor)
19627            }
19628        }
19629        struct Visitor;
19630        impl<'de> serde::de::Visitor<'de> for Visitor {
19631            type Value = RoutingParameter;
19632            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19633                formatter.write_str("struct RoutingParameter")
19634            }
19635            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19636            where
19637                A: serde::de::MapAccess<'de>,
19638            {
19639                #[allow(unused_imports)]
19640                use serde::de::Error;
19641                use std::option::Option::Some;
19642                let mut fields = std::collections::HashSet::new();
19643                let mut result = Self::Value::new();
19644                while let Some(tag) = map.next_key::<__FieldTag>()? {
19645                    #[allow(clippy::match_single_binding)]
19646                    match tag {
19647                        __FieldTag::__field => {
19648                            if !fields.insert(__FieldTag::__field) {
19649                                return std::result::Result::Err(A::Error::duplicate_field(
19650                                    "multiple values for field",
19651                                ));
19652                            }
19653                            result.field = map
19654                                .next_value::<std::option::Option<std::string::String>>()?
19655                                .unwrap_or_default();
19656                        }
19657                        __FieldTag::__path_template => {
19658                            if !fields.insert(__FieldTag::__path_template) {
19659                                return std::result::Result::Err(A::Error::duplicate_field(
19660                                    "multiple values for path_template",
19661                                ));
19662                            }
19663                            result.path_template = map
19664                                .next_value::<std::option::Option<std::string::String>>()?
19665                                .unwrap_or_default();
19666                        }
19667                        __FieldTag::Unknown(key) => {
19668                            let value = map.next_value::<serde_json::Value>()?;
19669                            result._unknown_fields.insert(key, value);
19670                        }
19671                    }
19672                }
19673                std::result::Result::Ok(result)
19674            }
19675        }
19676        deserializer.deserialize_any(Visitor)
19677    }
19678}
19679
19680#[doc(hidden)]
19681impl serde::ser::Serialize for RoutingParameter {
19682    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19683    where
19684        S: serde::ser::Serializer,
19685    {
19686        use serde::ser::SerializeMap;
19687        #[allow(unused_imports)]
19688        use std::option::Option::Some;
19689        let mut state = serializer.serialize_map(std::option::Option::None)?;
19690        if !self.field.is_empty() {
19691            state.serialize_entry("field", &self.field)?;
19692        }
19693        if !self.path_template.is_empty() {
19694            state.serialize_entry("pathTemplate", &self.path_template)?;
19695        }
19696        if !self._unknown_fields.is_empty() {
19697            for (key, value) in self._unknown_fields.iter() {
19698                state.serialize_entry(key, &value)?;
19699            }
19700        }
19701        state.end()
19702    }
19703}
19704
19705impl std::fmt::Debug for RoutingParameter {
19706    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19707        let mut debug_struct = f.debug_struct("RoutingParameter");
19708        debug_struct.field("field", &self.field);
19709        debug_struct.field("path_template", &self.path_template);
19710        if !self._unknown_fields.is_empty() {
19711            debug_struct.field("_unknown_fields", &self._unknown_fields);
19712        }
19713        debug_struct.finish()
19714    }
19715}
19716
19717/// `Service` is the root object of Google API service configuration (service
19718/// config). It describes the basic information about a logical service,
19719/// such as the service name and the user-facing title, and delegates other
19720/// aspects to sub-sections. Each sub-section is either a proto message or a
19721/// repeated proto message that configures a specific aspect, such as auth.
19722/// For more information, see each proto message definition.
19723///
19724/// Example:
19725///
19726/// ```norust
19727/// type: google.api.Service
19728/// name: calendar.googleapis.com
19729/// title: Google Calendar API
19730/// apis:
19731/// - name: google.calendar.v3.Calendar
19732///
19733/// visibility:
19734///   rules:
19735///   - selector: "google.calendar.v3.*"
19736///     restriction: PREVIEW
19737/// backend:
19738///   rules:
19739///   - selector: "google.calendar.v3.*"
19740///     address: calendar.example.com
19741///
19742/// authentication:
19743///   providers:
19744///   - id: google_calendar_auth
19745///     jwks_uri: https://www.googleapis.com/oauth2/v1/certs
19746///     issuer: https://securetoken.google.com
19747///   rules:
19748///   - selector: "*"
19749///     requirements:
19750///       provider_id: google_calendar_auth
19751/// ```
19752#[derive(Clone, Default, PartialEq)]
19753#[non_exhaustive]
19754pub struct Service {
19755    /// The service name, which is a DNS-like logical identifier for the
19756    /// service, such as `calendar.googleapis.com`. The service name
19757    /// typically goes through DNS verification to make sure the owner
19758    /// of the service also owns the DNS name.
19759    pub name: std::string::String,
19760
19761    /// The product title for this service, it is the name displayed in Google
19762    /// Cloud Console.
19763    pub title: std::string::String,
19764
19765    /// The Google project that owns this service.
19766    pub producer_project_id: std::string::String,
19767
19768    /// A unique ID for a specific instance of this message, typically assigned
19769    /// by the client for tracking purpose. Must be no longer than 63 characters
19770    /// and only lower case letters, digits, '.', '_' and '-' are allowed. If
19771    /// empty, the server may choose to generate one instead.
19772    pub id: std::string::String,
19773
19774    /// A list of API interfaces exported by this service. Only the `name` field
19775    /// of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by
19776    /// the configuration author, as the remaining fields will be derived from the
19777    /// IDL during the normalization process. It is an error to specify an API
19778    /// interface here which cannot be resolved against the associated IDL files.
19779    ///
19780    /// [google.protobuf.Api]: wkt::Api
19781    pub apis: std::vec::Vec<wkt::Api>,
19782
19783    /// A list of all proto message types included in this API service.
19784    /// Types referenced directly or indirectly by the `apis` are automatically
19785    /// included.  Messages which are not referenced but shall be included, such as
19786    /// types used by the `google.protobuf.Any` type, should be listed here by
19787    /// name by the configuration author. Example:
19788    ///
19789    /// ```norust
19790    /// types:
19791    /// - name: google.protobuf.Int32
19792    /// ```
19793    pub types: std::vec::Vec<wkt::Type>,
19794
19795    /// A list of all enum types included in this API service.  Enums referenced
19796    /// directly or indirectly by the `apis` are automatically included.  Enums
19797    /// which are not referenced but shall be included should be listed here by
19798    /// name by the configuration author. Example:
19799    ///
19800    /// ```norust
19801    /// enums:
19802    /// - name: google.someapi.v1.SomeEnum
19803    /// ```
19804    pub enums: std::vec::Vec<wkt::Enum>,
19805
19806    /// Additional API documentation.
19807    pub documentation: std::option::Option<crate::model::Documentation>,
19808
19809    /// API backend configuration.
19810    pub backend: std::option::Option<crate::model::Backend>,
19811
19812    /// HTTP configuration.
19813    pub http: std::option::Option<crate::model::Http>,
19814
19815    /// Quota configuration.
19816    pub quota: std::option::Option<crate::model::Quota>,
19817
19818    /// Auth configuration.
19819    pub authentication: std::option::Option<crate::model::Authentication>,
19820
19821    /// Context configuration.
19822    pub context: std::option::Option<crate::model::Context>,
19823
19824    /// Configuration controlling usage of this service.
19825    pub usage: std::option::Option<crate::model::Usage>,
19826
19827    /// Configuration for network endpoints.  If this is empty, then an endpoint
19828    /// with the same name as the service is automatically generated to service all
19829    /// defined APIs.
19830    pub endpoints: std::vec::Vec<crate::model::Endpoint>,
19831
19832    /// Configuration for the service control plane.
19833    pub control: std::option::Option<crate::model::Control>,
19834
19835    /// Defines the logs used by this service.
19836    pub logs: std::vec::Vec<crate::model::LogDescriptor>,
19837
19838    /// Defines the metrics used by this service.
19839    pub metrics: std::vec::Vec<crate::model::MetricDescriptor>,
19840
19841    /// Defines the monitored resources used by this service. This is required
19842    /// by the [Service.monitoring][google.api.Service.monitoring] and
19843    /// [Service.logging][google.api.Service.logging] configurations.
19844    ///
19845    /// [google.api.Service.logging]: crate::model::Service::logging
19846    /// [google.api.Service.monitoring]: crate::model::Service::monitoring
19847    pub monitored_resources: std::vec::Vec<crate::model::MonitoredResourceDescriptor>,
19848
19849    /// Billing configuration.
19850    pub billing: std::option::Option<crate::model::Billing>,
19851
19852    /// Logging configuration.
19853    pub logging: std::option::Option<crate::model::Logging>,
19854
19855    /// Monitoring configuration.
19856    pub monitoring: std::option::Option<crate::model::Monitoring>,
19857
19858    /// System parameter configuration.
19859    pub system_parameters: std::option::Option<crate::model::SystemParameters>,
19860
19861    /// Output only. The source information for this configuration if available.
19862    pub source_info: std::option::Option<crate::model::SourceInfo>,
19863
19864    /// Settings for [Google Cloud Client
19865    /// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
19866    /// generated from APIs defined as protocol buffers.
19867    pub publishing: std::option::Option<crate::model::Publishing>,
19868
19869    /// Obsolete. Do not use.
19870    ///
19871    /// This field has no semantic meaning. The service config compiler always
19872    /// sets this field to `3`.
19873    pub config_version: std::option::Option<wkt::UInt32Value>,
19874
19875    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19876}
19877
19878impl Service {
19879    pub fn new() -> Self {
19880        std::default::Default::default()
19881    }
19882
19883    /// Sets the value of [name][crate::model::Service::name].
19884    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19885        self.name = v.into();
19886        self
19887    }
19888
19889    /// Sets the value of [title][crate::model::Service::title].
19890    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19891        self.title = v.into();
19892        self
19893    }
19894
19895    /// Sets the value of [producer_project_id][crate::model::Service::producer_project_id].
19896    pub fn set_producer_project_id<T: std::convert::Into<std::string::String>>(
19897        mut self,
19898        v: T,
19899    ) -> Self {
19900        self.producer_project_id = v.into();
19901        self
19902    }
19903
19904    /// Sets the value of [id][crate::model::Service::id].
19905    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19906        self.id = v.into();
19907        self
19908    }
19909
19910    /// Sets the value of [apis][crate::model::Service::apis].
19911    pub fn set_apis<T, V>(mut self, v: T) -> Self
19912    where
19913        T: std::iter::IntoIterator<Item = V>,
19914        V: std::convert::Into<wkt::Api>,
19915    {
19916        use std::iter::Iterator;
19917        self.apis = v.into_iter().map(|i| i.into()).collect();
19918        self
19919    }
19920
19921    /// Sets the value of [types][crate::model::Service::types].
19922    pub fn set_types<T, V>(mut self, v: T) -> Self
19923    where
19924        T: std::iter::IntoIterator<Item = V>,
19925        V: std::convert::Into<wkt::Type>,
19926    {
19927        use std::iter::Iterator;
19928        self.types = v.into_iter().map(|i| i.into()).collect();
19929        self
19930    }
19931
19932    /// Sets the value of [enums][crate::model::Service::enums].
19933    pub fn set_enums<T, V>(mut self, v: T) -> Self
19934    where
19935        T: std::iter::IntoIterator<Item = V>,
19936        V: std::convert::Into<wkt::Enum>,
19937    {
19938        use std::iter::Iterator;
19939        self.enums = v.into_iter().map(|i| i.into()).collect();
19940        self
19941    }
19942
19943    /// Sets the value of [documentation][crate::model::Service::documentation].
19944    pub fn set_documentation<T>(mut self, v: T) -> Self
19945    where
19946        T: std::convert::Into<crate::model::Documentation>,
19947    {
19948        self.documentation = std::option::Option::Some(v.into());
19949        self
19950    }
19951
19952    /// Sets or clears the value of [documentation][crate::model::Service::documentation].
19953    pub fn set_or_clear_documentation<T>(mut self, v: std::option::Option<T>) -> Self
19954    where
19955        T: std::convert::Into<crate::model::Documentation>,
19956    {
19957        self.documentation = v.map(|x| x.into());
19958        self
19959    }
19960
19961    /// Sets the value of [backend][crate::model::Service::backend].
19962    pub fn set_backend<T>(mut self, v: T) -> Self
19963    where
19964        T: std::convert::Into<crate::model::Backend>,
19965    {
19966        self.backend = std::option::Option::Some(v.into());
19967        self
19968    }
19969
19970    /// Sets or clears the value of [backend][crate::model::Service::backend].
19971    pub fn set_or_clear_backend<T>(mut self, v: std::option::Option<T>) -> Self
19972    where
19973        T: std::convert::Into<crate::model::Backend>,
19974    {
19975        self.backend = v.map(|x| x.into());
19976        self
19977    }
19978
19979    /// Sets the value of [http][crate::model::Service::http].
19980    pub fn set_http<T>(mut self, v: T) -> Self
19981    where
19982        T: std::convert::Into<crate::model::Http>,
19983    {
19984        self.http = std::option::Option::Some(v.into());
19985        self
19986    }
19987
19988    /// Sets or clears the value of [http][crate::model::Service::http].
19989    pub fn set_or_clear_http<T>(mut self, v: std::option::Option<T>) -> Self
19990    where
19991        T: std::convert::Into<crate::model::Http>,
19992    {
19993        self.http = v.map(|x| x.into());
19994        self
19995    }
19996
19997    /// Sets the value of [quota][crate::model::Service::quota].
19998    pub fn set_quota<T>(mut self, v: T) -> Self
19999    where
20000        T: std::convert::Into<crate::model::Quota>,
20001    {
20002        self.quota = std::option::Option::Some(v.into());
20003        self
20004    }
20005
20006    /// Sets or clears the value of [quota][crate::model::Service::quota].
20007    pub fn set_or_clear_quota<T>(mut self, v: std::option::Option<T>) -> Self
20008    where
20009        T: std::convert::Into<crate::model::Quota>,
20010    {
20011        self.quota = v.map(|x| x.into());
20012        self
20013    }
20014
20015    /// Sets the value of [authentication][crate::model::Service::authentication].
20016    pub fn set_authentication<T>(mut self, v: T) -> Self
20017    where
20018        T: std::convert::Into<crate::model::Authentication>,
20019    {
20020        self.authentication = std::option::Option::Some(v.into());
20021        self
20022    }
20023
20024    /// Sets or clears the value of [authentication][crate::model::Service::authentication].
20025    pub fn set_or_clear_authentication<T>(mut self, v: std::option::Option<T>) -> Self
20026    where
20027        T: std::convert::Into<crate::model::Authentication>,
20028    {
20029        self.authentication = v.map(|x| x.into());
20030        self
20031    }
20032
20033    /// Sets the value of [context][crate::model::Service::context].
20034    pub fn set_context<T>(mut self, v: T) -> Self
20035    where
20036        T: std::convert::Into<crate::model::Context>,
20037    {
20038        self.context = std::option::Option::Some(v.into());
20039        self
20040    }
20041
20042    /// Sets or clears the value of [context][crate::model::Service::context].
20043    pub fn set_or_clear_context<T>(mut self, v: std::option::Option<T>) -> Self
20044    where
20045        T: std::convert::Into<crate::model::Context>,
20046    {
20047        self.context = v.map(|x| x.into());
20048        self
20049    }
20050
20051    /// Sets the value of [usage][crate::model::Service::usage].
20052    pub fn set_usage<T>(mut self, v: T) -> Self
20053    where
20054        T: std::convert::Into<crate::model::Usage>,
20055    {
20056        self.usage = std::option::Option::Some(v.into());
20057        self
20058    }
20059
20060    /// Sets or clears the value of [usage][crate::model::Service::usage].
20061    pub fn set_or_clear_usage<T>(mut self, v: std::option::Option<T>) -> Self
20062    where
20063        T: std::convert::Into<crate::model::Usage>,
20064    {
20065        self.usage = v.map(|x| x.into());
20066        self
20067    }
20068
20069    /// Sets the value of [endpoints][crate::model::Service::endpoints].
20070    pub fn set_endpoints<T, V>(mut self, v: T) -> Self
20071    where
20072        T: std::iter::IntoIterator<Item = V>,
20073        V: std::convert::Into<crate::model::Endpoint>,
20074    {
20075        use std::iter::Iterator;
20076        self.endpoints = v.into_iter().map(|i| i.into()).collect();
20077        self
20078    }
20079
20080    /// Sets the value of [control][crate::model::Service::control].
20081    pub fn set_control<T>(mut self, v: T) -> Self
20082    where
20083        T: std::convert::Into<crate::model::Control>,
20084    {
20085        self.control = std::option::Option::Some(v.into());
20086        self
20087    }
20088
20089    /// Sets or clears the value of [control][crate::model::Service::control].
20090    pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
20091    where
20092        T: std::convert::Into<crate::model::Control>,
20093    {
20094        self.control = v.map(|x| x.into());
20095        self
20096    }
20097
20098    /// Sets the value of [logs][crate::model::Service::logs].
20099    pub fn set_logs<T, V>(mut self, v: T) -> Self
20100    where
20101        T: std::iter::IntoIterator<Item = V>,
20102        V: std::convert::Into<crate::model::LogDescriptor>,
20103    {
20104        use std::iter::Iterator;
20105        self.logs = v.into_iter().map(|i| i.into()).collect();
20106        self
20107    }
20108
20109    /// Sets the value of [metrics][crate::model::Service::metrics].
20110    pub fn set_metrics<T, V>(mut self, v: T) -> Self
20111    where
20112        T: std::iter::IntoIterator<Item = V>,
20113        V: std::convert::Into<crate::model::MetricDescriptor>,
20114    {
20115        use std::iter::Iterator;
20116        self.metrics = v.into_iter().map(|i| i.into()).collect();
20117        self
20118    }
20119
20120    /// Sets the value of [monitored_resources][crate::model::Service::monitored_resources].
20121    pub fn set_monitored_resources<T, V>(mut self, v: T) -> Self
20122    where
20123        T: std::iter::IntoIterator<Item = V>,
20124        V: std::convert::Into<crate::model::MonitoredResourceDescriptor>,
20125    {
20126        use std::iter::Iterator;
20127        self.monitored_resources = v.into_iter().map(|i| i.into()).collect();
20128        self
20129    }
20130
20131    /// Sets the value of [billing][crate::model::Service::billing].
20132    pub fn set_billing<T>(mut self, v: T) -> Self
20133    where
20134        T: std::convert::Into<crate::model::Billing>,
20135    {
20136        self.billing = std::option::Option::Some(v.into());
20137        self
20138    }
20139
20140    /// Sets or clears the value of [billing][crate::model::Service::billing].
20141    pub fn set_or_clear_billing<T>(mut self, v: std::option::Option<T>) -> Self
20142    where
20143        T: std::convert::Into<crate::model::Billing>,
20144    {
20145        self.billing = v.map(|x| x.into());
20146        self
20147    }
20148
20149    /// Sets the value of [logging][crate::model::Service::logging].
20150    pub fn set_logging<T>(mut self, v: T) -> Self
20151    where
20152        T: std::convert::Into<crate::model::Logging>,
20153    {
20154        self.logging = std::option::Option::Some(v.into());
20155        self
20156    }
20157
20158    /// Sets or clears the value of [logging][crate::model::Service::logging].
20159    pub fn set_or_clear_logging<T>(mut self, v: std::option::Option<T>) -> Self
20160    where
20161        T: std::convert::Into<crate::model::Logging>,
20162    {
20163        self.logging = v.map(|x| x.into());
20164        self
20165    }
20166
20167    /// Sets the value of [monitoring][crate::model::Service::monitoring].
20168    pub fn set_monitoring<T>(mut self, v: T) -> Self
20169    where
20170        T: std::convert::Into<crate::model::Monitoring>,
20171    {
20172        self.monitoring = std::option::Option::Some(v.into());
20173        self
20174    }
20175
20176    /// Sets or clears the value of [monitoring][crate::model::Service::monitoring].
20177    pub fn set_or_clear_monitoring<T>(mut self, v: std::option::Option<T>) -> Self
20178    where
20179        T: std::convert::Into<crate::model::Monitoring>,
20180    {
20181        self.monitoring = v.map(|x| x.into());
20182        self
20183    }
20184
20185    /// Sets the value of [system_parameters][crate::model::Service::system_parameters].
20186    pub fn set_system_parameters<T>(mut self, v: T) -> Self
20187    where
20188        T: std::convert::Into<crate::model::SystemParameters>,
20189    {
20190        self.system_parameters = std::option::Option::Some(v.into());
20191        self
20192    }
20193
20194    /// Sets or clears the value of [system_parameters][crate::model::Service::system_parameters].
20195    pub fn set_or_clear_system_parameters<T>(mut self, v: std::option::Option<T>) -> Self
20196    where
20197        T: std::convert::Into<crate::model::SystemParameters>,
20198    {
20199        self.system_parameters = v.map(|x| x.into());
20200        self
20201    }
20202
20203    /// Sets the value of [source_info][crate::model::Service::source_info].
20204    pub fn set_source_info<T>(mut self, v: T) -> Self
20205    where
20206        T: std::convert::Into<crate::model::SourceInfo>,
20207    {
20208        self.source_info = std::option::Option::Some(v.into());
20209        self
20210    }
20211
20212    /// Sets or clears the value of [source_info][crate::model::Service::source_info].
20213    pub fn set_or_clear_source_info<T>(mut self, v: std::option::Option<T>) -> Self
20214    where
20215        T: std::convert::Into<crate::model::SourceInfo>,
20216    {
20217        self.source_info = v.map(|x| x.into());
20218        self
20219    }
20220
20221    /// Sets the value of [publishing][crate::model::Service::publishing].
20222    pub fn set_publishing<T>(mut self, v: T) -> Self
20223    where
20224        T: std::convert::Into<crate::model::Publishing>,
20225    {
20226        self.publishing = std::option::Option::Some(v.into());
20227        self
20228    }
20229
20230    /// Sets or clears the value of [publishing][crate::model::Service::publishing].
20231    pub fn set_or_clear_publishing<T>(mut self, v: std::option::Option<T>) -> Self
20232    where
20233        T: std::convert::Into<crate::model::Publishing>,
20234    {
20235        self.publishing = v.map(|x| x.into());
20236        self
20237    }
20238
20239    /// Sets the value of [config_version][crate::model::Service::config_version].
20240    pub fn set_config_version<T>(mut self, v: T) -> Self
20241    where
20242        T: std::convert::Into<wkt::UInt32Value>,
20243    {
20244        self.config_version = std::option::Option::Some(v.into());
20245        self
20246    }
20247
20248    /// Sets or clears the value of [config_version][crate::model::Service::config_version].
20249    pub fn set_or_clear_config_version<T>(mut self, v: std::option::Option<T>) -> Self
20250    where
20251        T: std::convert::Into<wkt::UInt32Value>,
20252    {
20253        self.config_version = v.map(|x| x.into());
20254        self
20255    }
20256}
20257
20258impl wkt::message::Message for Service {
20259    fn typename() -> &'static str {
20260        "type.googleapis.com/google.api.Service"
20261    }
20262}
20263
20264#[doc(hidden)]
20265impl<'de> serde::de::Deserialize<'de> for Service {
20266    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20267    where
20268        D: serde::Deserializer<'de>,
20269    {
20270        #[allow(non_camel_case_types)]
20271        #[doc(hidden)]
20272        #[derive(PartialEq, Eq, Hash)]
20273        enum __FieldTag {
20274            __name,
20275            __title,
20276            __producer_project_id,
20277            __id,
20278            __apis,
20279            __types,
20280            __enums,
20281            __documentation,
20282            __backend,
20283            __http,
20284            __quota,
20285            __authentication,
20286            __context,
20287            __usage,
20288            __endpoints,
20289            __control,
20290            __logs,
20291            __metrics,
20292            __monitored_resources,
20293            __billing,
20294            __logging,
20295            __monitoring,
20296            __system_parameters,
20297            __source_info,
20298            __publishing,
20299            __config_version,
20300            Unknown(std::string::String),
20301        }
20302        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20303            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20304            where
20305                D: serde::Deserializer<'de>,
20306            {
20307                struct Visitor;
20308                impl<'de> serde::de::Visitor<'de> for Visitor {
20309                    type Value = __FieldTag;
20310                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20311                        formatter.write_str("a field name for Service")
20312                    }
20313                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20314                    where
20315                        E: serde::de::Error,
20316                    {
20317                        use std::result::Result::Ok;
20318                        use std::string::ToString;
20319                        match value {
20320                            "name" => Ok(__FieldTag::__name),
20321                            "title" => Ok(__FieldTag::__title),
20322                            "producerProjectId" => Ok(__FieldTag::__producer_project_id),
20323                            "producer_project_id" => Ok(__FieldTag::__producer_project_id),
20324                            "id" => Ok(__FieldTag::__id),
20325                            "apis" => Ok(__FieldTag::__apis),
20326                            "types" => Ok(__FieldTag::__types),
20327                            "enums" => Ok(__FieldTag::__enums),
20328                            "documentation" => Ok(__FieldTag::__documentation),
20329                            "backend" => Ok(__FieldTag::__backend),
20330                            "http" => Ok(__FieldTag::__http),
20331                            "quota" => Ok(__FieldTag::__quota),
20332                            "authentication" => Ok(__FieldTag::__authentication),
20333                            "context" => Ok(__FieldTag::__context),
20334                            "usage" => Ok(__FieldTag::__usage),
20335                            "endpoints" => Ok(__FieldTag::__endpoints),
20336                            "control" => Ok(__FieldTag::__control),
20337                            "logs" => Ok(__FieldTag::__logs),
20338                            "metrics" => Ok(__FieldTag::__metrics),
20339                            "monitoredResources" => Ok(__FieldTag::__monitored_resources),
20340                            "monitored_resources" => Ok(__FieldTag::__monitored_resources),
20341                            "billing" => Ok(__FieldTag::__billing),
20342                            "logging" => Ok(__FieldTag::__logging),
20343                            "monitoring" => Ok(__FieldTag::__monitoring),
20344                            "systemParameters" => Ok(__FieldTag::__system_parameters),
20345                            "system_parameters" => Ok(__FieldTag::__system_parameters),
20346                            "sourceInfo" => Ok(__FieldTag::__source_info),
20347                            "source_info" => Ok(__FieldTag::__source_info),
20348                            "publishing" => Ok(__FieldTag::__publishing),
20349                            "configVersion" => Ok(__FieldTag::__config_version),
20350                            "config_version" => Ok(__FieldTag::__config_version),
20351                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20352                        }
20353                    }
20354                }
20355                deserializer.deserialize_identifier(Visitor)
20356            }
20357        }
20358        struct Visitor;
20359        impl<'de> serde::de::Visitor<'de> for Visitor {
20360            type Value = Service;
20361            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20362                formatter.write_str("struct Service")
20363            }
20364            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20365            where
20366                A: serde::de::MapAccess<'de>,
20367            {
20368                #[allow(unused_imports)]
20369                use serde::de::Error;
20370                use std::option::Option::Some;
20371                let mut fields = std::collections::HashSet::new();
20372                let mut result = Self::Value::new();
20373                while let Some(tag) = map.next_key::<__FieldTag>()? {
20374                    #[allow(clippy::match_single_binding)]
20375                    match tag {
20376                        __FieldTag::__name => {
20377                            if !fields.insert(__FieldTag::__name) {
20378                                return std::result::Result::Err(A::Error::duplicate_field(
20379                                    "multiple values for name",
20380                                ));
20381                            }
20382                            result.name = map
20383                                .next_value::<std::option::Option<std::string::String>>()?
20384                                .unwrap_or_default();
20385                        }
20386                        __FieldTag::__title => {
20387                            if !fields.insert(__FieldTag::__title) {
20388                                return std::result::Result::Err(A::Error::duplicate_field(
20389                                    "multiple values for title",
20390                                ));
20391                            }
20392                            result.title = map
20393                                .next_value::<std::option::Option<std::string::String>>()?
20394                                .unwrap_or_default();
20395                        }
20396                        __FieldTag::__producer_project_id => {
20397                            if !fields.insert(__FieldTag::__producer_project_id) {
20398                                return std::result::Result::Err(A::Error::duplicate_field(
20399                                    "multiple values for producer_project_id",
20400                                ));
20401                            }
20402                            result.producer_project_id = map
20403                                .next_value::<std::option::Option<std::string::String>>()?
20404                                .unwrap_or_default();
20405                        }
20406                        __FieldTag::__id => {
20407                            if !fields.insert(__FieldTag::__id) {
20408                                return std::result::Result::Err(A::Error::duplicate_field(
20409                                    "multiple values for id",
20410                                ));
20411                            }
20412                            result.id = map
20413                                .next_value::<std::option::Option<std::string::String>>()?
20414                                .unwrap_or_default();
20415                        }
20416                        __FieldTag::__apis => {
20417                            if !fields.insert(__FieldTag::__apis) {
20418                                return std::result::Result::Err(A::Error::duplicate_field(
20419                                    "multiple values for apis",
20420                                ));
20421                            }
20422                            result.apis = map
20423                                .next_value::<std::option::Option<std::vec::Vec<wkt::Api>>>()?
20424                                .unwrap_or_default();
20425                        }
20426                        __FieldTag::__types => {
20427                            if !fields.insert(__FieldTag::__types) {
20428                                return std::result::Result::Err(A::Error::duplicate_field(
20429                                    "multiple values for types",
20430                                ));
20431                            }
20432                            result.types = map
20433                                .next_value::<std::option::Option<std::vec::Vec<wkt::Type>>>()?
20434                                .unwrap_or_default();
20435                        }
20436                        __FieldTag::__enums => {
20437                            if !fields.insert(__FieldTag::__enums) {
20438                                return std::result::Result::Err(A::Error::duplicate_field(
20439                                    "multiple values for enums",
20440                                ));
20441                            }
20442                            result.enums = map
20443                                .next_value::<std::option::Option<std::vec::Vec<wkt::Enum>>>()?
20444                                .unwrap_or_default();
20445                        }
20446                        __FieldTag::__documentation => {
20447                            if !fields.insert(__FieldTag::__documentation) {
20448                                return std::result::Result::Err(A::Error::duplicate_field(
20449                                    "multiple values for documentation",
20450                                ));
20451                            }
20452                            result.documentation = map
20453                                .next_value::<std::option::Option<crate::model::Documentation>>()?;
20454                        }
20455                        __FieldTag::__backend => {
20456                            if !fields.insert(__FieldTag::__backend) {
20457                                return std::result::Result::Err(A::Error::duplicate_field(
20458                                    "multiple values for backend",
20459                                ));
20460                            }
20461                            result.backend =
20462                                map.next_value::<std::option::Option<crate::model::Backend>>()?;
20463                        }
20464                        __FieldTag::__http => {
20465                            if !fields.insert(__FieldTag::__http) {
20466                                return std::result::Result::Err(A::Error::duplicate_field(
20467                                    "multiple values for http",
20468                                ));
20469                            }
20470                            result.http =
20471                                map.next_value::<std::option::Option<crate::model::Http>>()?;
20472                        }
20473                        __FieldTag::__quota => {
20474                            if !fields.insert(__FieldTag::__quota) {
20475                                return std::result::Result::Err(A::Error::duplicate_field(
20476                                    "multiple values for quota",
20477                                ));
20478                            }
20479                            result.quota =
20480                                map.next_value::<std::option::Option<crate::model::Quota>>()?;
20481                        }
20482                        __FieldTag::__authentication => {
20483                            if !fields.insert(__FieldTag::__authentication) {
20484                                return std::result::Result::Err(A::Error::duplicate_field(
20485                                    "multiple values for authentication",
20486                                ));
20487                            }
20488                            result.authentication = map
20489                                .next_value::<std::option::Option<crate::model::Authentication>>(
20490                                )?;
20491                        }
20492                        __FieldTag::__context => {
20493                            if !fields.insert(__FieldTag::__context) {
20494                                return std::result::Result::Err(A::Error::duplicate_field(
20495                                    "multiple values for context",
20496                                ));
20497                            }
20498                            result.context =
20499                                map.next_value::<std::option::Option<crate::model::Context>>()?;
20500                        }
20501                        __FieldTag::__usage => {
20502                            if !fields.insert(__FieldTag::__usage) {
20503                                return std::result::Result::Err(A::Error::duplicate_field(
20504                                    "multiple values for usage",
20505                                ));
20506                            }
20507                            result.usage =
20508                                map.next_value::<std::option::Option<crate::model::Usage>>()?;
20509                        }
20510                        __FieldTag::__endpoints => {
20511                            if !fields.insert(__FieldTag::__endpoints) {
20512                                return std::result::Result::Err(A::Error::duplicate_field(
20513                                    "multiple values for endpoints",
20514                                ));
20515                            }
20516                            result.endpoints = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Endpoint>>>()?.unwrap_or_default();
20517                        }
20518                        __FieldTag::__control => {
20519                            if !fields.insert(__FieldTag::__control) {
20520                                return std::result::Result::Err(A::Error::duplicate_field(
20521                                    "multiple values for control",
20522                                ));
20523                            }
20524                            result.control =
20525                                map.next_value::<std::option::Option<crate::model::Control>>()?;
20526                        }
20527                        __FieldTag::__logs => {
20528                            if !fields.insert(__FieldTag::__logs) {
20529                                return std::result::Result::Err(A::Error::duplicate_field(
20530                                    "multiple values for logs",
20531                                ));
20532                            }
20533                            result.logs = map.next_value::<std::option::Option<std::vec::Vec<crate::model::LogDescriptor>>>()?.unwrap_or_default();
20534                        }
20535                        __FieldTag::__metrics => {
20536                            if !fields.insert(__FieldTag::__metrics) {
20537                                return std::result::Result::Err(A::Error::duplicate_field(
20538                                    "multiple values for metrics",
20539                                ));
20540                            }
20541                            result.metrics =
20542                                map.next_value::<std::option::Option<
20543                                    std::vec::Vec<crate::model::MetricDescriptor>,
20544                                >>()?
20545                                .unwrap_or_default();
20546                        }
20547                        __FieldTag::__monitored_resources => {
20548                            if !fields.insert(__FieldTag::__monitored_resources) {
20549                                return std::result::Result::Err(A::Error::duplicate_field(
20550                                    "multiple values for monitored_resources",
20551                                ));
20552                            }
20553                            result.monitored_resources = map
20554                                .next_value::<std::option::Option<
20555                                    std::vec::Vec<crate::model::MonitoredResourceDescriptor>,
20556                                >>()?
20557                                .unwrap_or_default();
20558                        }
20559                        __FieldTag::__billing => {
20560                            if !fields.insert(__FieldTag::__billing) {
20561                                return std::result::Result::Err(A::Error::duplicate_field(
20562                                    "multiple values for billing",
20563                                ));
20564                            }
20565                            result.billing =
20566                                map.next_value::<std::option::Option<crate::model::Billing>>()?;
20567                        }
20568                        __FieldTag::__logging => {
20569                            if !fields.insert(__FieldTag::__logging) {
20570                                return std::result::Result::Err(A::Error::duplicate_field(
20571                                    "multiple values for logging",
20572                                ));
20573                            }
20574                            result.logging =
20575                                map.next_value::<std::option::Option<crate::model::Logging>>()?;
20576                        }
20577                        __FieldTag::__monitoring => {
20578                            if !fields.insert(__FieldTag::__monitoring) {
20579                                return std::result::Result::Err(A::Error::duplicate_field(
20580                                    "multiple values for monitoring",
20581                                ));
20582                            }
20583                            result.monitoring =
20584                                map.next_value::<std::option::Option<crate::model::Monitoring>>()?;
20585                        }
20586                        __FieldTag::__system_parameters => {
20587                            if !fields.insert(__FieldTag::__system_parameters) {
20588                                return std::result::Result::Err(A::Error::duplicate_field(
20589                                    "multiple values for system_parameters",
20590                                ));
20591                            }
20592                            result.system_parameters = map
20593                                .next_value::<std::option::Option<crate::model::SystemParameters>>(
20594                                )?;
20595                        }
20596                        __FieldTag::__source_info => {
20597                            if !fields.insert(__FieldTag::__source_info) {
20598                                return std::result::Result::Err(A::Error::duplicate_field(
20599                                    "multiple values for source_info",
20600                                ));
20601                            }
20602                            result.source_info =
20603                                map.next_value::<std::option::Option<crate::model::SourceInfo>>()?;
20604                        }
20605                        __FieldTag::__publishing => {
20606                            if !fields.insert(__FieldTag::__publishing) {
20607                                return std::result::Result::Err(A::Error::duplicate_field(
20608                                    "multiple values for publishing",
20609                                ));
20610                            }
20611                            result.publishing =
20612                                map.next_value::<std::option::Option<crate::model::Publishing>>()?;
20613                        }
20614                        __FieldTag::__config_version => {
20615                            if !fields.insert(__FieldTag::__config_version) {
20616                                return std::result::Result::Err(A::Error::duplicate_field(
20617                                    "multiple values for config_version",
20618                                ));
20619                            }
20620                            struct __With(std::option::Option<wkt::UInt32Value>);
20621                            impl<'de> serde::de::Deserialize<'de> for __With {
20622                                fn deserialize<D>(
20623                                    deserializer: D,
20624                                ) -> std::result::Result<Self, D::Error>
20625                                where
20626                                    D: serde::de::Deserializer<'de>,
20627                                {
20628                                    serde_with::As::< std::option::Option<wkt::internal::U32> >::deserialize(deserializer).map(__With)
20629                                }
20630                            }
20631                            result.config_version = map.next_value::<__With>()?.0;
20632                        }
20633                        __FieldTag::Unknown(key) => {
20634                            let value = map.next_value::<serde_json::Value>()?;
20635                            result._unknown_fields.insert(key, value);
20636                        }
20637                    }
20638                }
20639                std::result::Result::Ok(result)
20640            }
20641        }
20642        deserializer.deserialize_any(Visitor)
20643    }
20644}
20645
20646#[doc(hidden)]
20647impl serde::ser::Serialize for Service {
20648    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20649    where
20650        S: serde::ser::Serializer,
20651    {
20652        use serde::ser::SerializeMap;
20653        #[allow(unused_imports)]
20654        use std::option::Option::Some;
20655        let mut state = serializer.serialize_map(std::option::Option::None)?;
20656        if !self.name.is_empty() {
20657            state.serialize_entry("name", &self.name)?;
20658        }
20659        if !self.title.is_empty() {
20660            state.serialize_entry("title", &self.title)?;
20661        }
20662        if !self.producer_project_id.is_empty() {
20663            state.serialize_entry("producerProjectId", &self.producer_project_id)?;
20664        }
20665        if !self.id.is_empty() {
20666            state.serialize_entry("id", &self.id)?;
20667        }
20668        if !self.apis.is_empty() {
20669            state.serialize_entry("apis", &self.apis)?;
20670        }
20671        if !self.types.is_empty() {
20672            state.serialize_entry("types", &self.types)?;
20673        }
20674        if !self.enums.is_empty() {
20675            state.serialize_entry("enums", &self.enums)?;
20676        }
20677        if self.documentation.is_some() {
20678            state.serialize_entry("documentation", &self.documentation)?;
20679        }
20680        if self.backend.is_some() {
20681            state.serialize_entry("backend", &self.backend)?;
20682        }
20683        if self.http.is_some() {
20684            state.serialize_entry("http", &self.http)?;
20685        }
20686        if self.quota.is_some() {
20687            state.serialize_entry("quota", &self.quota)?;
20688        }
20689        if self.authentication.is_some() {
20690            state.serialize_entry("authentication", &self.authentication)?;
20691        }
20692        if self.context.is_some() {
20693            state.serialize_entry("context", &self.context)?;
20694        }
20695        if self.usage.is_some() {
20696            state.serialize_entry("usage", &self.usage)?;
20697        }
20698        if !self.endpoints.is_empty() {
20699            state.serialize_entry("endpoints", &self.endpoints)?;
20700        }
20701        if self.control.is_some() {
20702            state.serialize_entry("control", &self.control)?;
20703        }
20704        if !self.logs.is_empty() {
20705            state.serialize_entry("logs", &self.logs)?;
20706        }
20707        if !self.metrics.is_empty() {
20708            state.serialize_entry("metrics", &self.metrics)?;
20709        }
20710        if !self.monitored_resources.is_empty() {
20711            state.serialize_entry("monitoredResources", &self.monitored_resources)?;
20712        }
20713        if self.billing.is_some() {
20714            state.serialize_entry("billing", &self.billing)?;
20715        }
20716        if self.logging.is_some() {
20717            state.serialize_entry("logging", &self.logging)?;
20718        }
20719        if self.monitoring.is_some() {
20720            state.serialize_entry("monitoring", &self.monitoring)?;
20721        }
20722        if self.system_parameters.is_some() {
20723            state.serialize_entry("systemParameters", &self.system_parameters)?;
20724        }
20725        if self.source_info.is_some() {
20726            state.serialize_entry("sourceInfo", &self.source_info)?;
20727        }
20728        if self.publishing.is_some() {
20729            state.serialize_entry("publishing", &self.publishing)?;
20730        }
20731        if self.config_version.is_some() {
20732            struct __With<'a>(&'a std::option::Option<wkt::UInt32Value>);
20733            impl<'a> serde::ser::Serialize for __With<'a> {
20734                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20735                where
20736                    S: serde::ser::Serializer,
20737                {
20738                    serde_with::As::<std::option::Option<wkt::internal::U32>>::serialize(
20739                        self.0, serializer,
20740                    )
20741                }
20742            }
20743            state.serialize_entry("configVersion", &__With(&self.config_version))?;
20744        }
20745        if !self._unknown_fields.is_empty() {
20746            for (key, value) in self._unknown_fields.iter() {
20747                state.serialize_entry(key, &value)?;
20748            }
20749        }
20750        state.end()
20751    }
20752}
20753
20754impl std::fmt::Debug for Service {
20755    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20756        let mut debug_struct = f.debug_struct("Service");
20757        debug_struct.field("name", &self.name);
20758        debug_struct.field("title", &self.title);
20759        debug_struct.field("producer_project_id", &self.producer_project_id);
20760        debug_struct.field("id", &self.id);
20761        debug_struct.field("apis", &self.apis);
20762        debug_struct.field("types", &self.types);
20763        debug_struct.field("enums", &self.enums);
20764        debug_struct.field("documentation", &self.documentation);
20765        debug_struct.field("backend", &self.backend);
20766        debug_struct.field("http", &self.http);
20767        debug_struct.field("quota", &self.quota);
20768        debug_struct.field("authentication", &self.authentication);
20769        debug_struct.field("context", &self.context);
20770        debug_struct.field("usage", &self.usage);
20771        debug_struct.field("endpoints", &self.endpoints);
20772        debug_struct.field("control", &self.control);
20773        debug_struct.field("logs", &self.logs);
20774        debug_struct.field("metrics", &self.metrics);
20775        debug_struct.field("monitored_resources", &self.monitored_resources);
20776        debug_struct.field("billing", &self.billing);
20777        debug_struct.field("logging", &self.logging);
20778        debug_struct.field("monitoring", &self.monitoring);
20779        debug_struct.field("system_parameters", &self.system_parameters);
20780        debug_struct.field("source_info", &self.source_info);
20781        debug_struct.field("publishing", &self.publishing);
20782        debug_struct.field("config_version", &self.config_version);
20783        if !self._unknown_fields.is_empty() {
20784            debug_struct.field("_unknown_fields", &self._unknown_fields);
20785        }
20786        debug_struct.finish()
20787    }
20788}
20789
20790/// Source information used to create a Service Config
20791#[derive(Clone, Default, PartialEq)]
20792#[non_exhaustive]
20793pub struct SourceInfo {
20794    /// All files used during config generation.
20795    pub source_files: std::vec::Vec<wkt::Any>,
20796
20797    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20798}
20799
20800impl SourceInfo {
20801    pub fn new() -> Self {
20802        std::default::Default::default()
20803    }
20804
20805    /// Sets the value of [source_files][crate::model::SourceInfo::source_files].
20806    pub fn set_source_files<T, V>(mut self, v: T) -> Self
20807    where
20808        T: std::iter::IntoIterator<Item = V>,
20809        V: std::convert::Into<wkt::Any>,
20810    {
20811        use std::iter::Iterator;
20812        self.source_files = v.into_iter().map(|i| i.into()).collect();
20813        self
20814    }
20815}
20816
20817impl wkt::message::Message for SourceInfo {
20818    fn typename() -> &'static str {
20819        "type.googleapis.com/google.api.SourceInfo"
20820    }
20821}
20822
20823#[doc(hidden)]
20824impl<'de> serde::de::Deserialize<'de> for SourceInfo {
20825    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20826    where
20827        D: serde::Deserializer<'de>,
20828    {
20829        #[allow(non_camel_case_types)]
20830        #[doc(hidden)]
20831        #[derive(PartialEq, Eq, Hash)]
20832        enum __FieldTag {
20833            __source_files,
20834            Unknown(std::string::String),
20835        }
20836        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20837            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20838            where
20839                D: serde::Deserializer<'de>,
20840            {
20841                struct Visitor;
20842                impl<'de> serde::de::Visitor<'de> for Visitor {
20843                    type Value = __FieldTag;
20844                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20845                        formatter.write_str("a field name for SourceInfo")
20846                    }
20847                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20848                    where
20849                        E: serde::de::Error,
20850                    {
20851                        use std::result::Result::Ok;
20852                        use std::string::ToString;
20853                        match value {
20854                            "sourceFiles" => Ok(__FieldTag::__source_files),
20855                            "source_files" => Ok(__FieldTag::__source_files),
20856                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20857                        }
20858                    }
20859                }
20860                deserializer.deserialize_identifier(Visitor)
20861            }
20862        }
20863        struct Visitor;
20864        impl<'de> serde::de::Visitor<'de> for Visitor {
20865            type Value = SourceInfo;
20866            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20867                formatter.write_str("struct SourceInfo")
20868            }
20869            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20870            where
20871                A: serde::de::MapAccess<'de>,
20872            {
20873                #[allow(unused_imports)]
20874                use serde::de::Error;
20875                use std::option::Option::Some;
20876                let mut fields = std::collections::HashSet::new();
20877                let mut result = Self::Value::new();
20878                while let Some(tag) = map.next_key::<__FieldTag>()? {
20879                    #[allow(clippy::match_single_binding)]
20880                    match tag {
20881                        __FieldTag::__source_files => {
20882                            if !fields.insert(__FieldTag::__source_files) {
20883                                return std::result::Result::Err(A::Error::duplicate_field(
20884                                    "multiple values for source_files",
20885                                ));
20886                            }
20887                            result.source_files = map
20888                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
20889                                .unwrap_or_default();
20890                        }
20891                        __FieldTag::Unknown(key) => {
20892                            let value = map.next_value::<serde_json::Value>()?;
20893                            result._unknown_fields.insert(key, value);
20894                        }
20895                    }
20896                }
20897                std::result::Result::Ok(result)
20898            }
20899        }
20900        deserializer.deserialize_any(Visitor)
20901    }
20902}
20903
20904#[doc(hidden)]
20905impl serde::ser::Serialize for SourceInfo {
20906    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20907    where
20908        S: serde::ser::Serializer,
20909    {
20910        use serde::ser::SerializeMap;
20911        #[allow(unused_imports)]
20912        use std::option::Option::Some;
20913        let mut state = serializer.serialize_map(std::option::Option::None)?;
20914        if !self.source_files.is_empty() {
20915            state.serialize_entry("sourceFiles", &self.source_files)?;
20916        }
20917        if !self._unknown_fields.is_empty() {
20918            for (key, value) in self._unknown_fields.iter() {
20919                state.serialize_entry(key, &value)?;
20920            }
20921        }
20922        state.end()
20923    }
20924}
20925
20926impl std::fmt::Debug for SourceInfo {
20927    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20928        let mut debug_struct = f.debug_struct("SourceInfo");
20929        debug_struct.field("source_files", &self.source_files);
20930        if !self._unknown_fields.is_empty() {
20931            debug_struct.field("_unknown_fields", &self._unknown_fields);
20932        }
20933        debug_struct.finish()
20934    }
20935}
20936
20937/// ### System parameter configuration
20938///
20939/// A system parameter is a special kind of parameter defined by the API
20940/// system, not by an individual API. It is typically mapped to an HTTP header
20941/// and/or a URL query parameter. This configuration specifies which methods
20942/// change the names of the system parameters.
20943#[derive(Clone, Default, PartialEq)]
20944#[non_exhaustive]
20945pub struct SystemParameters {
20946    /// Define system parameters.
20947    ///
20948    /// The parameters defined here will override the default parameters
20949    /// implemented by the system. If this field is missing from the service
20950    /// config, default system parameters will be used. Default system parameters
20951    /// and names is implementation-dependent.
20952    ///
20953    /// Example: define api key for all methods
20954    ///
20955    /// ```norust
20956    /// system_parameters
20957    ///   rules:
20958    ///     - selector: "*"
20959    ///       parameters:
20960    ///         - name: api_key
20961    ///           url_query_parameter: api_key
20962    /// ```
20963    ///
20964    /// Example: define 2 api key names for a specific method.
20965    ///
20966    /// ```norust
20967    /// system_parameters
20968    ///   rules:
20969    ///     - selector: "/ListShelves"
20970    ///       parameters:
20971    ///         - name: api_key
20972    ///           http_header: Api-Key1
20973    ///         - name: api_key
20974    ///           http_header: Api-Key2
20975    /// ```
20976    ///
20977    /// **NOTE:** All service configuration rules follow "last one wins" order.
20978    pub rules: std::vec::Vec<crate::model::SystemParameterRule>,
20979
20980    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20981}
20982
20983impl SystemParameters {
20984    pub fn new() -> Self {
20985        std::default::Default::default()
20986    }
20987
20988    /// Sets the value of [rules][crate::model::SystemParameters::rules].
20989    pub fn set_rules<T, V>(mut self, v: T) -> Self
20990    where
20991        T: std::iter::IntoIterator<Item = V>,
20992        V: std::convert::Into<crate::model::SystemParameterRule>,
20993    {
20994        use std::iter::Iterator;
20995        self.rules = v.into_iter().map(|i| i.into()).collect();
20996        self
20997    }
20998}
20999
21000impl wkt::message::Message for SystemParameters {
21001    fn typename() -> &'static str {
21002        "type.googleapis.com/google.api.SystemParameters"
21003    }
21004}
21005
21006#[doc(hidden)]
21007impl<'de> serde::de::Deserialize<'de> for SystemParameters {
21008    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21009    where
21010        D: serde::Deserializer<'de>,
21011    {
21012        #[allow(non_camel_case_types)]
21013        #[doc(hidden)]
21014        #[derive(PartialEq, Eq, Hash)]
21015        enum __FieldTag {
21016            __rules,
21017            Unknown(std::string::String),
21018        }
21019        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21020            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21021            where
21022                D: serde::Deserializer<'de>,
21023            {
21024                struct Visitor;
21025                impl<'de> serde::de::Visitor<'de> for Visitor {
21026                    type Value = __FieldTag;
21027                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21028                        formatter.write_str("a field name for SystemParameters")
21029                    }
21030                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21031                    where
21032                        E: serde::de::Error,
21033                    {
21034                        use std::result::Result::Ok;
21035                        use std::string::ToString;
21036                        match value {
21037                            "rules" => Ok(__FieldTag::__rules),
21038                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21039                        }
21040                    }
21041                }
21042                deserializer.deserialize_identifier(Visitor)
21043            }
21044        }
21045        struct Visitor;
21046        impl<'de> serde::de::Visitor<'de> for Visitor {
21047            type Value = SystemParameters;
21048            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21049                formatter.write_str("struct SystemParameters")
21050            }
21051            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21052            where
21053                A: serde::de::MapAccess<'de>,
21054            {
21055                #[allow(unused_imports)]
21056                use serde::de::Error;
21057                use std::option::Option::Some;
21058                let mut fields = std::collections::HashSet::new();
21059                let mut result = Self::Value::new();
21060                while let Some(tag) = map.next_key::<__FieldTag>()? {
21061                    #[allow(clippy::match_single_binding)]
21062                    match tag {
21063                        __FieldTag::__rules => {
21064                            if !fields.insert(__FieldTag::__rules) {
21065                                return std::result::Result::Err(A::Error::duplicate_field(
21066                                    "multiple values for rules",
21067                                ));
21068                            }
21069                            result.rules = map
21070                                .next_value::<std::option::Option<
21071                                    std::vec::Vec<crate::model::SystemParameterRule>,
21072                                >>()?
21073                                .unwrap_or_default();
21074                        }
21075                        __FieldTag::Unknown(key) => {
21076                            let value = map.next_value::<serde_json::Value>()?;
21077                            result._unknown_fields.insert(key, value);
21078                        }
21079                    }
21080                }
21081                std::result::Result::Ok(result)
21082            }
21083        }
21084        deserializer.deserialize_any(Visitor)
21085    }
21086}
21087
21088#[doc(hidden)]
21089impl serde::ser::Serialize for SystemParameters {
21090    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21091    where
21092        S: serde::ser::Serializer,
21093    {
21094        use serde::ser::SerializeMap;
21095        #[allow(unused_imports)]
21096        use std::option::Option::Some;
21097        let mut state = serializer.serialize_map(std::option::Option::None)?;
21098        if !self.rules.is_empty() {
21099            state.serialize_entry("rules", &self.rules)?;
21100        }
21101        if !self._unknown_fields.is_empty() {
21102            for (key, value) in self._unknown_fields.iter() {
21103                state.serialize_entry(key, &value)?;
21104            }
21105        }
21106        state.end()
21107    }
21108}
21109
21110impl std::fmt::Debug for SystemParameters {
21111    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21112        let mut debug_struct = f.debug_struct("SystemParameters");
21113        debug_struct.field("rules", &self.rules);
21114        if !self._unknown_fields.is_empty() {
21115            debug_struct.field("_unknown_fields", &self._unknown_fields);
21116        }
21117        debug_struct.finish()
21118    }
21119}
21120
21121/// Define a system parameter rule mapping system parameter definitions to
21122/// methods.
21123#[derive(Clone, Default, PartialEq)]
21124#[non_exhaustive]
21125pub struct SystemParameterRule {
21126    /// Selects the methods to which this rule applies. Use '*' to indicate all
21127    /// methods in all APIs.
21128    ///
21129    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
21130    /// details.
21131    ///
21132    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
21133    pub selector: std::string::String,
21134
21135    /// Define parameters. Multiple names may be defined for a parameter.
21136    /// For a given method call, only one of them should be used. If multiple
21137    /// names are used the behavior is implementation-dependent.
21138    /// If none of the specified names are present the behavior is
21139    /// parameter-dependent.
21140    pub parameters: std::vec::Vec<crate::model::SystemParameter>,
21141
21142    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21143}
21144
21145impl SystemParameterRule {
21146    pub fn new() -> Self {
21147        std::default::Default::default()
21148    }
21149
21150    /// Sets the value of [selector][crate::model::SystemParameterRule::selector].
21151    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21152        self.selector = v.into();
21153        self
21154    }
21155
21156    /// Sets the value of [parameters][crate::model::SystemParameterRule::parameters].
21157    pub fn set_parameters<T, V>(mut self, v: T) -> Self
21158    where
21159        T: std::iter::IntoIterator<Item = V>,
21160        V: std::convert::Into<crate::model::SystemParameter>,
21161    {
21162        use std::iter::Iterator;
21163        self.parameters = v.into_iter().map(|i| i.into()).collect();
21164        self
21165    }
21166}
21167
21168impl wkt::message::Message for SystemParameterRule {
21169    fn typename() -> &'static str {
21170        "type.googleapis.com/google.api.SystemParameterRule"
21171    }
21172}
21173
21174#[doc(hidden)]
21175impl<'de> serde::de::Deserialize<'de> for SystemParameterRule {
21176    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21177    where
21178        D: serde::Deserializer<'de>,
21179    {
21180        #[allow(non_camel_case_types)]
21181        #[doc(hidden)]
21182        #[derive(PartialEq, Eq, Hash)]
21183        enum __FieldTag {
21184            __selector,
21185            __parameters,
21186            Unknown(std::string::String),
21187        }
21188        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21189            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21190            where
21191                D: serde::Deserializer<'de>,
21192            {
21193                struct Visitor;
21194                impl<'de> serde::de::Visitor<'de> for Visitor {
21195                    type Value = __FieldTag;
21196                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21197                        formatter.write_str("a field name for SystemParameterRule")
21198                    }
21199                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21200                    where
21201                        E: serde::de::Error,
21202                    {
21203                        use std::result::Result::Ok;
21204                        use std::string::ToString;
21205                        match value {
21206                            "selector" => Ok(__FieldTag::__selector),
21207                            "parameters" => Ok(__FieldTag::__parameters),
21208                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21209                        }
21210                    }
21211                }
21212                deserializer.deserialize_identifier(Visitor)
21213            }
21214        }
21215        struct Visitor;
21216        impl<'de> serde::de::Visitor<'de> for Visitor {
21217            type Value = SystemParameterRule;
21218            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21219                formatter.write_str("struct SystemParameterRule")
21220            }
21221            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21222            where
21223                A: serde::de::MapAccess<'de>,
21224            {
21225                #[allow(unused_imports)]
21226                use serde::de::Error;
21227                use std::option::Option::Some;
21228                let mut fields = std::collections::HashSet::new();
21229                let mut result = Self::Value::new();
21230                while let Some(tag) = map.next_key::<__FieldTag>()? {
21231                    #[allow(clippy::match_single_binding)]
21232                    match tag {
21233                        __FieldTag::__selector => {
21234                            if !fields.insert(__FieldTag::__selector) {
21235                                return std::result::Result::Err(A::Error::duplicate_field(
21236                                    "multiple values for selector",
21237                                ));
21238                            }
21239                            result.selector = map
21240                                .next_value::<std::option::Option<std::string::String>>()?
21241                                .unwrap_or_default();
21242                        }
21243                        __FieldTag::__parameters => {
21244                            if !fields.insert(__FieldTag::__parameters) {
21245                                return std::result::Result::Err(A::Error::duplicate_field(
21246                                    "multiple values for parameters",
21247                                ));
21248                            }
21249                            result.parameters =
21250                                map.next_value::<std::option::Option<
21251                                    std::vec::Vec<crate::model::SystemParameter>,
21252                                >>()?
21253                                .unwrap_or_default();
21254                        }
21255                        __FieldTag::Unknown(key) => {
21256                            let value = map.next_value::<serde_json::Value>()?;
21257                            result._unknown_fields.insert(key, value);
21258                        }
21259                    }
21260                }
21261                std::result::Result::Ok(result)
21262            }
21263        }
21264        deserializer.deserialize_any(Visitor)
21265    }
21266}
21267
21268#[doc(hidden)]
21269impl serde::ser::Serialize for SystemParameterRule {
21270    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21271    where
21272        S: serde::ser::Serializer,
21273    {
21274        use serde::ser::SerializeMap;
21275        #[allow(unused_imports)]
21276        use std::option::Option::Some;
21277        let mut state = serializer.serialize_map(std::option::Option::None)?;
21278        if !self.selector.is_empty() {
21279            state.serialize_entry("selector", &self.selector)?;
21280        }
21281        if !self.parameters.is_empty() {
21282            state.serialize_entry("parameters", &self.parameters)?;
21283        }
21284        if !self._unknown_fields.is_empty() {
21285            for (key, value) in self._unknown_fields.iter() {
21286                state.serialize_entry(key, &value)?;
21287            }
21288        }
21289        state.end()
21290    }
21291}
21292
21293impl std::fmt::Debug for SystemParameterRule {
21294    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21295        let mut debug_struct = f.debug_struct("SystemParameterRule");
21296        debug_struct.field("selector", &self.selector);
21297        debug_struct.field("parameters", &self.parameters);
21298        if !self._unknown_fields.is_empty() {
21299            debug_struct.field("_unknown_fields", &self._unknown_fields);
21300        }
21301        debug_struct.finish()
21302    }
21303}
21304
21305/// Define a parameter's name and location. The parameter may be passed as either
21306/// an HTTP header or a URL query parameter, and if both are passed the behavior
21307/// is implementation-dependent.
21308#[derive(Clone, Default, PartialEq)]
21309#[non_exhaustive]
21310pub struct SystemParameter {
21311    /// Define the name of the parameter, such as "api_key" . It is case sensitive.
21312    pub name: std::string::String,
21313
21314    /// Define the HTTP header name to use for the parameter. It is case
21315    /// insensitive.
21316    pub http_header: std::string::String,
21317
21318    /// Define the URL query parameter name to use for the parameter. It is case
21319    /// sensitive.
21320    pub url_query_parameter: std::string::String,
21321
21322    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21323}
21324
21325impl SystemParameter {
21326    pub fn new() -> Self {
21327        std::default::Default::default()
21328    }
21329
21330    /// Sets the value of [name][crate::model::SystemParameter::name].
21331    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21332        self.name = v.into();
21333        self
21334    }
21335
21336    /// Sets the value of [http_header][crate::model::SystemParameter::http_header].
21337    pub fn set_http_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21338        self.http_header = v.into();
21339        self
21340    }
21341
21342    /// Sets the value of [url_query_parameter][crate::model::SystemParameter::url_query_parameter].
21343    pub fn set_url_query_parameter<T: std::convert::Into<std::string::String>>(
21344        mut self,
21345        v: T,
21346    ) -> Self {
21347        self.url_query_parameter = v.into();
21348        self
21349    }
21350}
21351
21352impl wkt::message::Message for SystemParameter {
21353    fn typename() -> &'static str {
21354        "type.googleapis.com/google.api.SystemParameter"
21355    }
21356}
21357
21358#[doc(hidden)]
21359impl<'de> serde::de::Deserialize<'de> for SystemParameter {
21360    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21361    where
21362        D: serde::Deserializer<'de>,
21363    {
21364        #[allow(non_camel_case_types)]
21365        #[doc(hidden)]
21366        #[derive(PartialEq, Eq, Hash)]
21367        enum __FieldTag {
21368            __name,
21369            __http_header,
21370            __url_query_parameter,
21371            Unknown(std::string::String),
21372        }
21373        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21374            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21375            where
21376                D: serde::Deserializer<'de>,
21377            {
21378                struct Visitor;
21379                impl<'de> serde::de::Visitor<'de> for Visitor {
21380                    type Value = __FieldTag;
21381                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21382                        formatter.write_str("a field name for SystemParameter")
21383                    }
21384                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21385                    where
21386                        E: serde::de::Error,
21387                    {
21388                        use std::result::Result::Ok;
21389                        use std::string::ToString;
21390                        match value {
21391                            "name" => Ok(__FieldTag::__name),
21392                            "httpHeader" => Ok(__FieldTag::__http_header),
21393                            "http_header" => Ok(__FieldTag::__http_header),
21394                            "urlQueryParameter" => Ok(__FieldTag::__url_query_parameter),
21395                            "url_query_parameter" => Ok(__FieldTag::__url_query_parameter),
21396                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21397                        }
21398                    }
21399                }
21400                deserializer.deserialize_identifier(Visitor)
21401            }
21402        }
21403        struct Visitor;
21404        impl<'de> serde::de::Visitor<'de> for Visitor {
21405            type Value = SystemParameter;
21406            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21407                formatter.write_str("struct SystemParameter")
21408            }
21409            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21410            where
21411                A: serde::de::MapAccess<'de>,
21412            {
21413                #[allow(unused_imports)]
21414                use serde::de::Error;
21415                use std::option::Option::Some;
21416                let mut fields = std::collections::HashSet::new();
21417                let mut result = Self::Value::new();
21418                while let Some(tag) = map.next_key::<__FieldTag>()? {
21419                    #[allow(clippy::match_single_binding)]
21420                    match tag {
21421                        __FieldTag::__name => {
21422                            if !fields.insert(__FieldTag::__name) {
21423                                return std::result::Result::Err(A::Error::duplicate_field(
21424                                    "multiple values for name",
21425                                ));
21426                            }
21427                            result.name = map
21428                                .next_value::<std::option::Option<std::string::String>>()?
21429                                .unwrap_or_default();
21430                        }
21431                        __FieldTag::__http_header => {
21432                            if !fields.insert(__FieldTag::__http_header) {
21433                                return std::result::Result::Err(A::Error::duplicate_field(
21434                                    "multiple values for http_header",
21435                                ));
21436                            }
21437                            result.http_header = map
21438                                .next_value::<std::option::Option<std::string::String>>()?
21439                                .unwrap_or_default();
21440                        }
21441                        __FieldTag::__url_query_parameter => {
21442                            if !fields.insert(__FieldTag::__url_query_parameter) {
21443                                return std::result::Result::Err(A::Error::duplicate_field(
21444                                    "multiple values for url_query_parameter",
21445                                ));
21446                            }
21447                            result.url_query_parameter = map
21448                                .next_value::<std::option::Option<std::string::String>>()?
21449                                .unwrap_or_default();
21450                        }
21451                        __FieldTag::Unknown(key) => {
21452                            let value = map.next_value::<serde_json::Value>()?;
21453                            result._unknown_fields.insert(key, value);
21454                        }
21455                    }
21456                }
21457                std::result::Result::Ok(result)
21458            }
21459        }
21460        deserializer.deserialize_any(Visitor)
21461    }
21462}
21463
21464#[doc(hidden)]
21465impl serde::ser::Serialize for SystemParameter {
21466    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21467    where
21468        S: serde::ser::Serializer,
21469    {
21470        use serde::ser::SerializeMap;
21471        #[allow(unused_imports)]
21472        use std::option::Option::Some;
21473        let mut state = serializer.serialize_map(std::option::Option::None)?;
21474        if !self.name.is_empty() {
21475            state.serialize_entry("name", &self.name)?;
21476        }
21477        if !self.http_header.is_empty() {
21478            state.serialize_entry("httpHeader", &self.http_header)?;
21479        }
21480        if !self.url_query_parameter.is_empty() {
21481            state.serialize_entry("urlQueryParameter", &self.url_query_parameter)?;
21482        }
21483        if !self._unknown_fields.is_empty() {
21484            for (key, value) in self._unknown_fields.iter() {
21485                state.serialize_entry(key, &value)?;
21486            }
21487        }
21488        state.end()
21489    }
21490}
21491
21492impl std::fmt::Debug for SystemParameter {
21493    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21494        let mut debug_struct = f.debug_struct("SystemParameter");
21495        debug_struct.field("name", &self.name);
21496        debug_struct.field("http_header", &self.http_header);
21497        debug_struct.field("url_query_parameter", &self.url_query_parameter);
21498        if !self._unknown_fields.is_empty() {
21499            debug_struct.field("_unknown_fields", &self._unknown_fields);
21500        }
21501        debug_struct.finish()
21502    }
21503}
21504
21505/// Configuration controlling usage of a service.
21506#[derive(Clone, Default, PartialEq)]
21507#[non_exhaustive]
21508pub struct Usage {
21509    /// Requirements that must be satisfied before a consumer project can use the
21510    /// service. Each requirement is of the form <service.name>/\<requirement-id\>;
21511    /// for example 'serviceusage.googleapis.com/billing-enabled'.
21512    ///
21513    /// For Google APIs, a Terms of Service requirement must be included here.
21514    /// Google Cloud APIs must include "serviceusage.googleapis.com/tos/cloud".
21515    /// Other Google APIs should include
21516    /// "serviceusage.googleapis.com/tos/universal". Additional ToS can be
21517    /// included based on the business needs.
21518    pub requirements: std::vec::Vec<std::string::String>,
21519
21520    /// A list of usage rules that apply to individual API methods.
21521    ///
21522    /// **NOTE:** All service configuration rules follow "last one wins" order.
21523    pub rules: std::vec::Vec<crate::model::UsageRule>,
21524
21525    /// The full resource name of a channel used for sending notifications to the
21526    /// service producer.
21527    ///
21528    /// Google Service Management currently only supports
21529    /// [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification
21530    /// channel. To use Google Cloud Pub/Sub as the channel, this must be the name
21531    /// of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format
21532    /// documented in <https://cloud.google.com/pubsub/docs/overview>.
21533    pub producer_notification_channel: std::string::String,
21534
21535    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21536}
21537
21538impl Usage {
21539    pub fn new() -> Self {
21540        std::default::Default::default()
21541    }
21542
21543    /// Sets the value of [requirements][crate::model::Usage::requirements].
21544    pub fn set_requirements<T, V>(mut self, v: T) -> Self
21545    where
21546        T: std::iter::IntoIterator<Item = V>,
21547        V: std::convert::Into<std::string::String>,
21548    {
21549        use std::iter::Iterator;
21550        self.requirements = v.into_iter().map(|i| i.into()).collect();
21551        self
21552    }
21553
21554    /// Sets the value of [rules][crate::model::Usage::rules].
21555    pub fn set_rules<T, V>(mut self, v: T) -> Self
21556    where
21557        T: std::iter::IntoIterator<Item = V>,
21558        V: std::convert::Into<crate::model::UsageRule>,
21559    {
21560        use std::iter::Iterator;
21561        self.rules = v.into_iter().map(|i| i.into()).collect();
21562        self
21563    }
21564
21565    /// Sets the value of [producer_notification_channel][crate::model::Usage::producer_notification_channel].
21566    pub fn set_producer_notification_channel<T: std::convert::Into<std::string::String>>(
21567        mut self,
21568        v: T,
21569    ) -> Self {
21570        self.producer_notification_channel = v.into();
21571        self
21572    }
21573}
21574
21575impl wkt::message::Message for Usage {
21576    fn typename() -> &'static str {
21577        "type.googleapis.com/google.api.Usage"
21578    }
21579}
21580
21581#[doc(hidden)]
21582impl<'de> serde::de::Deserialize<'de> for Usage {
21583    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21584    where
21585        D: serde::Deserializer<'de>,
21586    {
21587        #[allow(non_camel_case_types)]
21588        #[doc(hidden)]
21589        #[derive(PartialEq, Eq, Hash)]
21590        enum __FieldTag {
21591            __requirements,
21592            __rules,
21593            __producer_notification_channel,
21594            Unknown(std::string::String),
21595        }
21596        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21597            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21598            where
21599                D: serde::Deserializer<'de>,
21600            {
21601                struct Visitor;
21602                impl<'de> serde::de::Visitor<'de> for Visitor {
21603                    type Value = __FieldTag;
21604                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21605                        formatter.write_str("a field name for Usage")
21606                    }
21607                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21608                    where
21609                        E: serde::de::Error,
21610                    {
21611                        use std::result::Result::Ok;
21612                        use std::string::ToString;
21613                        match value {
21614                            "requirements" => Ok(__FieldTag::__requirements),
21615                            "rules" => Ok(__FieldTag::__rules),
21616                            "producerNotificationChannel" => {
21617                                Ok(__FieldTag::__producer_notification_channel)
21618                            }
21619                            "producer_notification_channel" => {
21620                                Ok(__FieldTag::__producer_notification_channel)
21621                            }
21622                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21623                        }
21624                    }
21625                }
21626                deserializer.deserialize_identifier(Visitor)
21627            }
21628        }
21629        struct Visitor;
21630        impl<'de> serde::de::Visitor<'de> for Visitor {
21631            type Value = Usage;
21632            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21633                formatter.write_str("struct Usage")
21634            }
21635            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21636            where
21637                A: serde::de::MapAccess<'de>,
21638            {
21639                #[allow(unused_imports)]
21640                use serde::de::Error;
21641                use std::option::Option::Some;
21642                let mut fields = std::collections::HashSet::new();
21643                let mut result = Self::Value::new();
21644                while let Some(tag) = map.next_key::<__FieldTag>()? {
21645                    #[allow(clippy::match_single_binding)]
21646                    match tag {
21647                        __FieldTag::__requirements => {
21648                            if !fields.insert(__FieldTag::__requirements) {
21649                                return std::result::Result::Err(A::Error::duplicate_field(
21650                                    "multiple values for requirements",
21651                                ));
21652                            }
21653                            result.requirements = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
21654                        }
21655                        __FieldTag::__rules => {
21656                            if !fields.insert(__FieldTag::__rules) {
21657                                return std::result::Result::Err(A::Error::duplicate_field(
21658                                    "multiple values for rules",
21659                                ));
21660                            }
21661                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::UsageRule>>>()?.unwrap_or_default();
21662                        }
21663                        __FieldTag::__producer_notification_channel => {
21664                            if !fields.insert(__FieldTag::__producer_notification_channel) {
21665                                return std::result::Result::Err(A::Error::duplicate_field(
21666                                    "multiple values for producer_notification_channel",
21667                                ));
21668                            }
21669                            result.producer_notification_channel = map
21670                                .next_value::<std::option::Option<std::string::String>>()?
21671                                .unwrap_or_default();
21672                        }
21673                        __FieldTag::Unknown(key) => {
21674                            let value = map.next_value::<serde_json::Value>()?;
21675                            result._unknown_fields.insert(key, value);
21676                        }
21677                    }
21678                }
21679                std::result::Result::Ok(result)
21680            }
21681        }
21682        deserializer.deserialize_any(Visitor)
21683    }
21684}
21685
21686#[doc(hidden)]
21687impl serde::ser::Serialize for Usage {
21688    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21689    where
21690        S: serde::ser::Serializer,
21691    {
21692        use serde::ser::SerializeMap;
21693        #[allow(unused_imports)]
21694        use std::option::Option::Some;
21695        let mut state = serializer.serialize_map(std::option::Option::None)?;
21696        if !self.requirements.is_empty() {
21697            state.serialize_entry("requirements", &self.requirements)?;
21698        }
21699        if !self.rules.is_empty() {
21700            state.serialize_entry("rules", &self.rules)?;
21701        }
21702        if !self.producer_notification_channel.is_empty() {
21703            state.serialize_entry(
21704                "producerNotificationChannel",
21705                &self.producer_notification_channel,
21706            )?;
21707        }
21708        if !self._unknown_fields.is_empty() {
21709            for (key, value) in self._unknown_fields.iter() {
21710                state.serialize_entry(key, &value)?;
21711            }
21712        }
21713        state.end()
21714    }
21715}
21716
21717impl std::fmt::Debug for Usage {
21718    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21719        let mut debug_struct = f.debug_struct("Usage");
21720        debug_struct.field("requirements", &self.requirements);
21721        debug_struct.field("rules", &self.rules);
21722        debug_struct.field(
21723            "producer_notification_channel",
21724            &self.producer_notification_channel,
21725        );
21726        if !self._unknown_fields.is_empty() {
21727            debug_struct.field("_unknown_fields", &self._unknown_fields);
21728        }
21729        debug_struct.finish()
21730    }
21731}
21732
21733/// Usage configuration rules for the service.
21734///
21735/// NOTE: Under development.
21736///
21737/// Use this rule to configure unregistered calls for the service. Unregistered
21738/// calls are calls that do not contain consumer project identity.
21739/// (Example: calls that do not contain an API key).
21740/// By default, API methods do not allow unregistered calls, and each method call
21741/// must be identified by a consumer project identity. Use this rule to
21742/// allow/disallow unregistered calls.
21743///
21744/// Example of an API that wants to allow unregistered calls for entire service.
21745///
21746/// ```norust
21747/// usage:
21748///   rules:
21749///   - selector: "*"
21750///     allow_unregistered_calls: true
21751/// ```
21752///
21753/// Example of a method that wants to allow unregistered calls.
21754///
21755/// ```norust
21756/// usage:
21757///   rules:
21758///   - selector: "google.example.library.v1.LibraryService.CreateBook"
21759///     allow_unregistered_calls: true
21760/// ```
21761#[derive(Clone, Default, PartialEq)]
21762#[non_exhaustive]
21763pub struct UsageRule {
21764    /// Selects the methods to which this rule applies. Use '*' to indicate all
21765    /// methods in all APIs.
21766    ///
21767    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
21768    /// details.
21769    ///
21770    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
21771    pub selector: std::string::String,
21772
21773    /// If true, the selected method allows unregistered calls, e.g. calls
21774    /// that don't identify any user or application.
21775    pub allow_unregistered_calls: bool,
21776
21777    /// If true, the selected method should skip service control and the control
21778    /// plane features, such as quota and billing, will not be available.
21779    /// This flag is used by Google Cloud Endpoints to bypass checks for internal
21780    /// methods, such as service health check methods.
21781    pub skip_service_control: bool,
21782
21783    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21784}
21785
21786impl UsageRule {
21787    pub fn new() -> Self {
21788        std::default::Default::default()
21789    }
21790
21791    /// Sets the value of [selector][crate::model::UsageRule::selector].
21792    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21793        self.selector = v.into();
21794        self
21795    }
21796
21797    /// Sets the value of [allow_unregistered_calls][crate::model::UsageRule::allow_unregistered_calls].
21798    pub fn set_allow_unregistered_calls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
21799        self.allow_unregistered_calls = v.into();
21800        self
21801    }
21802
21803    /// Sets the value of [skip_service_control][crate::model::UsageRule::skip_service_control].
21804    pub fn set_skip_service_control<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
21805        self.skip_service_control = v.into();
21806        self
21807    }
21808}
21809
21810impl wkt::message::Message for UsageRule {
21811    fn typename() -> &'static str {
21812        "type.googleapis.com/google.api.UsageRule"
21813    }
21814}
21815
21816#[doc(hidden)]
21817impl<'de> serde::de::Deserialize<'de> for UsageRule {
21818    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21819    where
21820        D: serde::Deserializer<'de>,
21821    {
21822        #[allow(non_camel_case_types)]
21823        #[doc(hidden)]
21824        #[derive(PartialEq, Eq, Hash)]
21825        enum __FieldTag {
21826            __selector,
21827            __allow_unregistered_calls,
21828            __skip_service_control,
21829            Unknown(std::string::String),
21830        }
21831        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21832            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21833            where
21834                D: serde::Deserializer<'de>,
21835            {
21836                struct Visitor;
21837                impl<'de> serde::de::Visitor<'de> for Visitor {
21838                    type Value = __FieldTag;
21839                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21840                        formatter.write_str("a field name for UsageRule")
21841                    }
21842                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21843                    where
21844                        E: serde::de::Error,
21845                    {
21846                        use std::result::Result::Ok;
21847                        use std::string::ToString;
21848                        match value {
21849                            "selector" => Ok(__FieldTag::__selector),
21850                            "allowUnregisteredCalls" => Ok(__FieldTag::__allow_unregistered_calls),
21851                            "allow_unregistered_calls" => {
21852                                Ok(__FieldTag::__allow_unregistered_calls)
21853                            }
21854                            "skipServiceControl" => Ok(__FieldTag::__skip_service_control),
21855                            "skip_service_control" => Ok(__FieldTag::__skip_service_control),
21856                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21857                        }
21858                    }
21859                }
21860                deserializer.deserialize_identifier(Visitor)
21861            }
21862        }
21863        struct Visitor;
21864        impl<'de> serde::de::Visitor<'de> for Visitor {
21865            type Value = UsageRule;
21866            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21867                formatter.write_str("struct UsageRule")
21868            }
21869            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21870            where
21871                A: serde::de::MapAccess<'de>,
21872            {
21873                #[allow(unused_imports)]
21874                use serde::de::Error;
21875                use std::option::Option::Some;
21876                let mut fields = std::collections::HashSet::new();
21877                let mut result = Self::Value::new();
21878                while let Some(tag) = map.next_key::<__FieldTag>()? {
21879                    #[allow(clippy::match_single_binding)]
21880                    match tag {
21881                        __FieldTag::__selector => {
21882                            if !fields.insert(__FieldTag::__selector) {
21883                                return std::result::Result::Err(A::Error::duplicate_field(
21884                                    "multiple values for selector",
21885                                ));
21886                            }
21887                            result.selector = map
21888                                .next_value::<std::option::Option<std::string::String>>()?
21889                                .unwrap_or_default();
21890                        }
21891                        __FieldTag::__allow_unregistered_calls => {
21892                            if !fields.insert(__FieldTag::__allow_unregistered_calls) {
21893                                return std::result::Result::Err(A::Error::duplicate_field(
21894                                    "multiple values for allow_unregistered_calls",
21895                                ));
21896                            }
21897                            result.allow_unregistered_calls = map
21898                                .next_value::<std::option::Option<bool>>()?
21899                                .unwrap_or_default();
21900                        }
21901                        __FieldTag::__skip_service_control => {
21902                            if !fields.insert(__FieldTag::__skip_service_control) {
21903                                return std::result::Result::Err(A::Error::duplicate_field(
21904                                    "multiple values for skip_service_control",
21905                                ));
21906                            }
21907                            result.skip_service_control = map
21908                                .next_value::<std::option::Option<bool>>()?
21909                                .unwrap_or_default();
21910                        }
21911                        __FieldTag::Unknown(key) => {
21912                            let value = map.next_value::<serde_json::Value>()?;
21913                            result._unknown_fields.insert(key, value);
21914                        }
21915                    }
21916                }
21917                std::result::Result::Ok(result)
21918            }
21919        }
21920        deserializer.deserialize_any(Visitor)
21921    }
21922}
21923
21924#[doc(hidden)]
21925impl serde::ser::Serialize for UsageRule {
21926    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21927    where
21928        S: serde::ser::Serializer,
21929    {
21930        use serde::ser::SerializeMap;
21931        #[allow(unused_imports)]
21932        use std::option::Option::Some;
21933        let mut state = serializer.serialize_map(std::option::Option::None)?;
21934        if !self.selector.is_empty() {
21935            state.serialize_entry("selector", &self.selector)?;
21936        }
21937        if !wkt::internal::is_default(&self.allow_unregistered_calls) {
21938            state.serialize_entry("allowUnregisteredCalls", &self.allow_unregistered_calls)?;
21939        }
21940        if !wkt::internal::is_default(&self.skip_service_control) {
21941            state.serialize_entry("skipServiceControl", &self.skip_service_control)?;
21942        }
21943        if !self._unknown_fields.is_empty() {
21944            for (key, value) in self._unknown_fields.iter() {
21945                state.serialize_entry(key, &value)?;
21946            }
21947        }
21948        state.end()
21949    }
21950}
21951
21952impl std::fmt::Debug for UsageRule {
21953    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21954        let mut debug_struct = f.debug_struct("UsageRule");
21955        debug_struct.field("selector", &self.selector);
21956        debug_struct.field("allow_unregistered_calls", &self.allow_unregistered_calls);
21957        debug_struct.field("skip_service_control", &self.skip_service_control);
21958        if !self._unknown_fields.is_empty() {
21959            debug_struct.field("_unknown_fields", &self._unknown_fields);
21960        }
21961        debug_struct.finish()
21962    }
21963}
21964
21965/// `Visibility` restricts service consumer's access to service elements,
21966/// such as whether an application can call a visibility-restricted method.
21967/// The restriction is expressed by applying visibility labels on service
21968/// elements. The visibility labels are elsewhere linked to service consumers.
21969///
21970/// A service can define multiple visibility labels, but a service consumer
21971/// should be granted at most one visibility label. Multiple visibility
21972/// labels for a single service consumer are not supported.
21973///
21974/// If an element and all its parents have no visibility label, its visibility
21975/// is unconditionally granted.
21976///
21977/// Example:
21978///
21979/// ```norust
21980/// visibility:
21981///   rules:
21982///   - selector: google.calendar.Calendar.EnhancedSearch
21983///     restriction: PREVIEW
21984///   - selector: google.calendar.Calendar.Delegate
21985///     restriction: INTERNAL
21986/// ```
21987///
21988/// Here, all methods are publicly visible except for the restricted methods
21989/// EnhancedSearch and Delegate.
21990#[derive(Clone, Default, PartialEq)]
21991#[non_exhaustive]
21992pub struct Visibility {
21993    /// A list of visibility rules that apply to individual API elements.
21994    ///
21995    /// **NOTE:** All service configuration rules follow "last one wins" order.
21996    pub rules: std::vec::Vec<crate::model::VisibilityRule>,
21997
21998    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21999}
22000
22001impl Visibility {
22002    pub fn new() -> Self {
22003        std::default::Default::default()
22004    }
22005
22006    /// Sets the value of [rules][crate::model::Visibility::rules].
22007    pub fn set_rules<T, V>(mut self, v: T) -> Self
22008    where
22009        T: std::iter::IntoIterator<Item = V>,
22010        V: std::convert::Into<crate::model::VisibilityRule>,
22011    {
22012        use std::iter::Iterator;
22013        self.rules = v.into_iter().map(|i| i.into()).collect();
22014        self
22015    }
22016}
22017
22018impl wkt::message::Message for Visibility {
22019    fn typename() -> &'static str {
22020        "type.googleapis.com/google.api.Visibility"
22021    }
22022}
22023
22024#[doc(hidden)]
22025impl<'de> serde::de::Deserialize<'de> for Visibility {
22026    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22027    where
22028        D: serde::Deserializer<'de>,
22029    {
22030        #[allow(non_camel_case_types)]
22031        #[doc(hidden)]
22032        #[derive(PartialEq, Eq, Hash)]
22033        enum __FieldTag {
22034            __rules,
22035            Unknown(std::string::String),
22036        }
22037        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
22038            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22039            where
22040                D: serde::Deserializer<'de>,
22041            {
22042                struct Visitor;
22043                impl<'de> serde::de::Visitor<'de> for Visitor {
22044                    type Value = __FieldTag;
22045                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
22046                        formatter.write_str("a field name for Visibility")
22047                    }
22048                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
22049                    where
22050                        E: serde::de::Error,
22051                    {
22052                        use std::result::Result::Ok;
22053                        use std::string::ToString;
22054                        match value {
22055                            "rules" => Ok(__FieldTag::__rules),
22056                            _ => Ok(__FieldTag::Unknown(value.to_string())),
22057                        }
22058                    }
22059                }
22060                deserializer.deserialize_identifier(Visitor)
22061            }
22062        }
22063        struct Visitor;
22064        impl<'de> serde::de::Visitor<'de> for Visitor {
22065            type Value = Visibility;
22066            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
22067                formatter.write_str("struct Visibility")
22068            }
22069            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
22070            where
22071                A: serde::de::MapAccess<'de>,
22072            {
22073                #[allow(unused_imports)]
22074                use serde::de::Error;
22075                use std::option::Option::Some;
22076                let mut fields = std::collections::HashSet::new();
22077                let mut result = Self::Value::new();
22078                while let Some(tag) = map.next_key::<__FieldTag>()? {
22079                    #[allow(clippy::match_single_binding)]
22080                    match tag {
22081                        __FieldTag::__rules => {
22082                            if !fields.insert(__FieldTag::__rules) {
22083                                return std::result::Result::Err(A::Error::duplicate_field(
22084                                    "multiple values for rules",
22085                                ));
22086                            }
22087                            result.rules =
22088                                map.next_value::<std::option::Option<
22089                                    std::vec::Vec<crate::model::VisibilityRule>,
22090                                >>()?
22091                                .unwrap_or_default();
22092                        }
22093                        __FieldTag::Unknown(key) => {
22094                            let value = map.next_value::<serde_json::Value>()?;
22095                            result._unknown_fields.insert(key, value);
22096                        }
22097                    }
22098                }
22099                std::result::Result::Ok(result)
22100            }
22101        }
22102        deserializer.deserialize_any(Visitor)
22103    }
22104}
22105
22106#[doc(hidden)]
22107impl serde::ser::Serialize for Visibility {
22108    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22109    where
22110        S: serde::ser::Serializer,
22111    {
22112        use serde::ser::SerializeMap;
22113        #[allow(unused_imports)]
22114        use std::option::Option::Some;
22115        let mut state = serializer.serialize_map(std::option::Option::None)?;
22116        if !self.rules.is_empty() {
22117            state.serialize_entry("rules", &self.rules)?;
22118        }
22119        if !self._unknown_fields.is_empty() {
22120            for (key, value) in self._unknown_fields.iter() {
22121                state.serialize_entry(key, &value)?;
22122            }
22123        }
22124        state.end()
22125    }
22126}
22127
22128impl std::fmt::Debug for Visibility {
22129    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22130        let mut debug_struct = f.debug_struct("Visibility");
22131        debug_struct.field("rules", &self.rules);
22132        if !self._unknown_fields.is_empty() {
22133            debug_struct.field("_unknown_fields", &self._unknown_fields);
22134        }
22135        debug_struct.finish()
22136    }
22137}
22138
22139/// A visibility rule provides visibility configuration for an individual API
22140/// element.
22141#[derive(Clone, Default, PartialEq)]
22142#[non_exhaustive]
22143pub struct VisibilityRule {
22144    /// Selects methods, messages, fields, enums, etc. to which this rule applies.
22145    ///
22146    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
22147    /// details.
22148    ///
22149    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
22150    pub selector: std::string::String,
22151
22152    /// A comma-separated list of visibility labels that apply to the `selector`.
22153    /// Any of the listed labels can be used to grant the visibility.
22154    ///
22155    /// If a rule has multiple labels, removing one of the labels but not all of
22156    /// them can break clients.
22157    ///
22158    /// Example:
22159    ///
22160    /// ```norust
22161    /// visibility:
22162    ///   rules:
22163    ///   - selector: google.calendar.Calendar.EnhancedSearch
22164    ///     restriction: INTERNAL, PREVIEW
22165    /// ```
22166    ///
22167    /// Removing INTERNAL from this restriction will break clients that rely on
22168    /// this method and only had access to it through INTERNAL.
22169    pub restriction: std::string::String,
22170
22171    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
22172}
22173
22174impl VisibilityRule {
22175    pub fn new() -> Self {
22176        std::default::Default::default()
22177    }
22178
22179    /// Sets the value of [selector][crate::model::VisibilityRule::selector].
22180    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
22181        self.selector = v.into();
22182        self
22183    }
22184
22185    /// Sets the value of [restriction][crate::model::VisibilityRule::restriction].
22186    pub fn set_restriction<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
22187        self.restriction = v.into();
22188        self
22189    }
22190}
22191
22192impl wkt::message::Message for VisibilityRule {
22193    fn typename() -> &'static str {
22194        "type.googleapis.com/google.api.VisibilityRule"
22195    }
22196}
22197
22198#[doc(hidden)]
22199impl<'de> serde::de::Deserialize<'de> for VisibilityRule {
22200    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22201    where
22202        D: serde::Deserializer<'de>,
22203    {
22204        #[allow(non_camel_case_types)]
22205        #[doc(hidden)]
22206        #[derive(PartialEq, Eq, Hash)]
22207        enum __FieldTag {
22208            __selector,
22209            __restriction,
22210            Unknown(std::string::String),
22211        }
22212        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
22213            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22214            where
22215                D: serde::Deserializer<'de>,
22216            {
22217                struct Visitor;
22218                impl<'de> serde::de::Visitor<'de> for Visitor {
22219                    type Value = __FieldTag;
22220                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
22221                        formatter.write_str("a field name for VisibilityRule")
22222                    }
22223                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
22224                    where
22225                        E: serde::de::Error,
22226                    {
22227                        use std::result::Result::Ok;
22228                        use std::string::ToString;
22229                        match value {
22230                            "selector" => Ok(__FieldTag::__selector),
22231                            "restriction" => Ok(__FieldTag::__restriction),
22232                            _ => Ok(__FieldTag::Unknown(value.to_string())),
22233                        }
22234                    }
22235                }
22236                deserializer.deserialize_identifier(Visitor)
22237            }
22238        }
22239        struct Visitor;
22240        impl<'de> serde::de::Visitor<'de> for Visitor {
22241            type Value = VisibilityRule;
22242            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
22243                formatter.write_str("struct VisibilityRule")
22244            }
22245            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
22246            where
22247                A: serde::de::MapAccess<'de>,
22248            {
22249                #[allow(unused_imports)]
22250                use serde::de::Error;
22251                use std::option::Option::Some;
22252                let mut fields = std::collections::HashSet::new();
22253                let mut result = Self::Value::new();
22254                while let Some(tag) = map.next_key::<__FieldTag>()? {
22255                    #[allow(clippy::match_single_binding)]
22256                    match tag {
22257                        __FieldTag::__selector => {
22258                            if !fields.insert(__FieldTag::__selector) {
22259                                return std::result::Result::Err(A::Error::duplicate_field(
22260                                    "multiple values for selector",
22261                                ));
22262                            }
22263                            result.selector = map
22264                                .next_value::<std::option::Option<std::string::String>>()?
22265                                .unwrap_or_default();
22266                        }
22267                        __FieldTag::__restriction => {
22268                            if !fields.insert(__FieldTag::__restriction) {
22269                                return std::result::Result::Err(A::Error::duplicate_field(
22270                                    "multiple values for restriction",
22271                                ));
22272                            }
22273                            result.restriction = map
22274                                .next_value::<std::option::Option<std::string::String>>()?
22275                                .unwrap_or_default();
22276                        }
22277                        __FieldTag::Unknown(key) => {
22278                            let value = map.next_value::<serde_json::Value>()?;
22279                            result._unknown_fields.insert(key, value);
22280                        }
22281                    }
22282                }
22283                std::result::Result::Ok(result)
22284            }
22285        }
22286        deserializer.deserialize_any(Visitor)
22287    }
22288}
22289
22290#[doc(hidden)]
22291impl serde::ser::Serialize for VisibilityRule {
22292    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22293    where
22294        S: serde::ser::Serializer,
22295    {
22296        use serde::ser::SerializeMap;
22297        #[allow(unused_imports)]
22298        use std::option::Option::Some;
22299        let mut state = serializer.serialize_map(std::option::Option::None)?;
22300        if !self.selector.is_empty() {
22301            state.serialize_entry("selector", &self.selector)?;
22302        }
22303        if !self.restriction.is_empty() {
22304            state.serialize_entry("restriction", &self.restriction)?;
22305        }
22306        if !self._unknown_fields.is_empty() {
22307            for (key, value) in self._unknown_fields.iter() {
22308                state.serialize_entry(key, &value)?;
22309            }
22310        }
22311        state.end()
22312    }
22313}
22314
22315impl std::fmt::Debug for VisibilityRule {
22316    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22317        let mut debug_struct = f.debug_struct("VisibilityRule");
22318        debug_struct.field("selector", &self.selector);
22319        debug_struct.field("restriction", &self.restriction);
22320        if !self._unknown_fields.is_empty() {
22321            debug_struct.field("_unknown_fields", &self._unknown_fields);
22322        }
22323        debug_struct.finish()
22324    }
22325}
22326
22327/// The organization for which the client libraries are being published.
22328/// Affects the url where generated docs are published, etc.
22329///
22330/// # Working with unknown values
22331///
22332/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22333/// additional enum variants at any time. Adding new variants is not considered
22334/// a breaking change. Applications should write their code in anticipation of:
22335///
22336/// - New values appearing in future releases of the client library, **and**
22337/// - New values received dynamically, without application changes.
22338///
22339/// Please consult the [Working with enums] section in the user guide for some
22340/// guidelines.
22341///
22342/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22343#[derive(Clone, Debug, PartialEq)]
22344#[non_exhaustive]
22345pub enum ClientLibraryOrganization {
22346    /// Not useful.
22347    Unspecified,
22348    /// Google Cloud Platform Org.
22349    Cloud,
22350    /// Ads (Advertising) Org.
22351    Ads,
22352    /// Photos Org.
22353    Photos,
22354    /// Street View Org.
22355    StreetView,
22356    /// Shopping Org.
22357    Shopping,
22358    /// Geo Org.
22359    Geo,
22360    /// Generative AI - <https://developers.generativeai.google>
22361    GenerativeAi,
22362    /// If set, the enum was initialized with an unknown value.
22363    ///
22364    /// Applications can examine the value using [ClientLibraryOrganization::value] or
22365    /// [ClientLibraryOrganization::name].
22366    UnknownValue(client_library_organization::UnknownValue),
22367}
22368
22369#[doc(hidden)]
22370pub mod client_library_organization {
22371    #[allow(unused_imports)]
22372    use super::*;
22373    #[derive(Clone, Debug, PartialEq)]
22374    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22375}
22376
22377impl ClientLibraryOrganization {
22378    /// Gets the enum value.
22379    ///
22380    /// Returns `None` if the enum contains an unknown value deserialized from
22381    /// the string representation of enums.
22382    pub fn value(&self) -> std::option::Option<i32> {
22383        match self {
22384            Self::Unspecified => std::option::Option::Some(0),
22385            Self::Cloud => std::option::Option::Some(1),
22386            Self::Ads => std::option::Option::Some(2),
22387            Self::Photos => std::option::Option::Some(3),
22388            Self::StreetView => std::option::Option::Some(4),
22389            Self::Shopping => std::option::Option::Some(5),
22390            Self::Geo => std::option::Option::Some(6),
22391            Self::GenerativeAi => std::option::Option::Some(7),
22392            Self::UnknownValue(u) => u.0.value(),
22393        }
22394    }
22395
22396    /// Gets the enum value as a string.
22397    ///
22398    /// Returns `None` if the enum contains an unknown value deserialized from
22399    /// the integer representation of enums.
22400    pub fn name(&self) -> std::option::Option<&str> {
22401        match self {
22402            Self::Unspecified => {
22403                std::option::Option::Some("CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED")
22404            }
22405            Self::Cloud => std::option::Option::Some("CLOUD"),
22406            Self::Ads => std::option::Option::Some("ADS"),
22407            Self::Photos => std::option::Option::Some("PHOTOS"),
22408            Self::StreetView => std::option::Option::Some("STREET_VIEW"),
22409            Self::Shopping => std::option::Option::Some("SHOPPING"),
22410            Self::Geo => std::option::Option::Some("GEO"),
22411            Self::GenerativeAi => std::option::Option::Some("GENERATIVE_AI"),
22412            Self::UnknownValue(u) => u.0.name(),
22413        }
22414    }
22415}
22416
22417impl std::default::Default for ClientLibraryOrganization {
22418    fn default() -> Self {
22419        use std::convert::From;
22420        Self::from(0)
22421    }
22422}
22423
22424impl std::fmt::Display for ClientLibraryOrganization {
22425    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22426        wkt::internal::display_enum(f, self.name(), self.value())
22427    }
22428}
22429
22430impl std::convert::From<i32> for ClientLibraryOrganization {
22431    fn from(value: i32) -> Self {
22432        match value {
22433            0 => Self::Unspecified,
22434            1 => Self::Cloud,
22435            2 => Self::Ads,
22436            3 => Self::Photos,
22437            4 => Self::StreetView,
22438            5 => Self::Shopping,
22439            6 => Self::Geo,
22440            7 => Self::GenerativeAi,
22441            _ => Self::UnknownValue(client_library_organization::UnknownValue(
22442                wkt::internal::UnknownEnumValue::Integer(value),
22443            )),
22444        }
22445    }
22446}
22447
22448impl std::convert::From<&str> for ClientLibraryOrganization {
22449    fn from(value: &str) -> Self {
22450        use std::string::ToString;
22451        match value {
22452            "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED" => Self::Unspecified,
22453            "CLOUD" => Self::Cloud,
22454            "ADS" => Self::Ads,
22455            "PHOTOS" => Self::Photos,
22456            "STREET_VIEW" => Self::StreetView,
22457            "SHOPPING" => Self::Shopping,
22458            "GEO" => Self::Geo,
22459            "GENERATIVE_AI" => Self::GenerativeAi,
22460            _ => Self::UnknownValue(client_library_organization::UnknownValue(
22461                wkt::internal::UnknownEnumValue::String(value.to_string()),
22462            )),
22463        }
22464    }
22465}
22466
22467impl serde::ser::Serialize for ClientLibraryOrganization {
22468    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22469    where
22470        S: serde::Serializer,
22471    {
22472        match self {
22473            Self::Unspecified => serializer.serialize_i32(0),
22474            Self::Cloud => serializer.serialize_i32(1),
22475            Self::Ads => serializer.serialize_i32(2),
22476            Self::Photos => serializer.serialize_i32(3),
22477            Self::StreetView => serializer.serialize_i32(4),
22478            Self::Shopping => serializer.serialize_i32(5),
22479            Self::Geo => serializer.serialize_i32(6),
22480            Self::GenerativeAi => serializer.serialize_i32(7),
22481            Self::UnknownValue(u) => u.0.serialize(serializer),
22482        }
22483    }
22484}
22485
22486impl<'de> serde::de::Deserialize<'de> for ClientLibraryOrganization {
22487    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22488    where
22489        D: serde::Deserializer<'de>,
22490    {
22491        deserializer.deserialize_any(
22492            wkt::internal::EnumVisitor::<ClientLibraryOrganization>::new(
22493                ".google.api.ClientLibraryOrganization",
22494            ),
22495        )
22496    }
22497}
22498
22499/// To where should client libraries be published?
22500///
22501/// # Working with unknown values
22502///
22503/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22504/// additional enum variants at any time. Adding new variants is not considered
22505/// a breaking change. Applications should write their code in anticipation of:
22506///
22507/// - New values appearing in future releases of the client library, **and**
22508/// - New values received dynamically, without application changes.
22509///
22510/// Please consult the [Working with enums] section in the user guide for some
22511/// guidelines.
22512///
22513/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22514#[derive(Clone, Debug, PartialEq)]
22515#[non_exhaustive]
22516pub enum ClientLibraryDestination {
22517    /// Client libraries will neither be generated nor published to package
22518    /// managers.
22519    Unspecified,
22520    /// Generate the client library in a repo under github.com/googleapis,
22521    /// but don't publish it to package managers.
22522    Github,
22523    /// Publish the library to package managers like nuget.org and npmjs.com.
22524    PackageManager,
22525    /// If set, the enum was initialized with an unknown value.
22526    ///
22527    /// Applications can examine the value using [ClientLibraryDestination::value] or
22528    /// [ClientLibraryDestination::name].
22529    UnknownValue(client_library_destination::UnknownValue),
22530}
22531
22532#[doc(hidden)]
22533pub mod client_library_destination {
22534    #[allow(unused_imports)]
22535    use super::*;
22536    #[derive(Clone, Debug, PartialEq)]
22537    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22538}
22539
22540impl ClientLibraryDestination {
22541    /// Gets the enum value.
22542    ///
22543    /// Returns `None` if the enum contains an unknown value deserialized from
22544    /// the string representation of enums.
22545    pub fn value(&self) -> std::option::Option<i32> {
22546        match self {
22547            Self::Unspecified => std::option::Option::Some(0),
22548            Self::Github => std::option::Option::Some(10),
22549            Self::PackageManager => std::option::Option::Some(20),
22550            Self::UnknownValue(u) => u.0.value(),
22551        }
22552    }
22553
22554    /// Gets the enum value as a string.
22555    ///
22556    /// Returns `None` if the enum contains an unknown value deserialized from
22557    /// the integer representation of enums.
22558    pub fn name(&self) -> std::option::Option<&str> {
22559        match self {
22560            Self::Unspecified => {
22561                std::option::Option::Some("CLIENT_LIBRARY_DESTINATION_UNSPECIFIED")
22562            }
22563            Self::Github => std::option::Option::Some("GITHUB"),
22564            Self::PackageManager => std::option::Option::Some("PACKAGE_MANAGER"),
22565            Self::UnknownValue(u) => u.0.name(),
22566        }
22567    }
22568}
22569
22570impl std::default::Default for ClientLibraryDestination {
22571    fn default() -> Self {
22572        use std::convert::From;
22573        Self::from(0)
22574    }
22575}
22576
22577impl std::fmt::Display for ClientLibraryDestination {
22578    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22579        wkt::internal::display_enum(f, self.name(), self.value())
22580    }
22581}
22582
22583impl std::convert::From<i32> for ClientLibraryDestination {
22584    fn from(value: i32) -> Self {
22585        match value {
22586            0 => Self::Unspecified,
22587            10 => Self::Github,
22588            20 => Self::PackageManager,
22589            _ => Self::UnknownValue(client_library_destination::UnknownValue(
22590                wkt::internal::UnknownEnumValue::Integer(value),
22591            )),
22592        }
22593    }
22594}
22595
22596impl std::convert::From<&str> for ClientLibraryDestination {
22597    fn from(value: &str) -> Self {
22598        use std::string::ToString;
22599        match value {
22600            "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED" => Self::Unspecified,
22601            "GITHUB" => Self::Github,
22602            "PACKAGE_MANAGER" => Self::PackageManager,
22603            _ => Self::UnknownValue(client_library_destination::UnknownValue(
22604                wkt::internal::UnknownEnumValue::String(value.to_string()),
22605            )),
22606        }
22607    }
22608}
22609
22610impl serde::ser::Serialize for ClientLibraryDestination {
22611    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22612    where
22613        S: serde::Serializer,
22614    {
22615        match self {
22616            Self::Unspecified => serializer.serialize_i32(0),
22617            Self::Github => serializer.serialize_i32(10),
22618            Self::PackageManager => serializer.serialize_i32(20),
22619            Self::UnknownValue(u) => u.0.serialize(serializer),
22620        }
22621    }
22622}
22623
22624impl<'de> serde::de::Deserialize<'de> for ClientLibraryDestination {
22625    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22626    where
22627        D: serde::Deserializer<'de>,
22628    {
22629        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ClientLibraryDestination>::new(
22630            ".google.api.ClientLibraryDestination",
22631        ))
22632    }
22633}
22634
22635/// Classifies set of possible modifications to an object in the service
22636/// configuration.
22637///
22638/// # Working with unknown values
22639///
22640/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22641/// additional enum variants at any time. Adding new variants is not considered
22642/// a breaking change. Applications should write their code in anticipation of:
22643///
22644/// - New values appearing in future releases of the client library, **and**
22645/// - New values received dynamically, without application changes.
22646///
22647/// Please consult the [Working with enums] section in the user guide for some
22648/// guidelines.
22649///
22650/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22651#[derive(Clone, Debug, PartialEq)]
22652#[non_exhaustive]
22653pub enum ChangeType {
22654    /// No value was provided.
22655    Unspecified,
22656    /// The changed object exists in the 'new' service configuration, but not
22657    /// in the 'old' service configuration.
22658    Added,
22659    /// The changed object exists in the 'old' service configuration, but not
22660    /// in the 'new' service configuration.
22661    Removed,
22662    /// The changed object exists in both service configurations, but its value
22663    /// is different.
22664    Modified,
22665    /// If set, the enum was initialized with an unknown value.
22666    ///
22667    /// Applications can examine the value using [ChangeType::value] or
22668    /// [ChangeType::name].
22669    UnknownValue(change_type::UnknownValue),
22670}
22671
22672#[doc(hidden)]
22673pub mod change_type {
22674    #[allow(unused_imports)]
22675    use super::*;
22676    #[derive(Clone, Debug, PartialEq)]
22677    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22678}
22679
22680impl ChangeType {
22681    /// Gets the enum value.
22682    ///
22683    /// Returns `None` if the enum contains an unknown value deserialized from
22684    /// the string representation of enums.
22685    pub fn value(&self) -> std::option::Option<i32> {
22686        match self {
22687            Self::Unspecified => std::option::Option::Some(0),
22688            Self::Added => std::option::Option::Some(1),
22689            Self::Removed => std::option::Option::Some(2),
22690            Self::Modified => std::option::Option::Some(3),
22691            Self::UnknownValue(u) => u.0.value(),
22692        }
22693    }
22694
22695    /// Gets the enum value as a string.
22696    ///
22697    /// Returns `None` if the enum contains an unknown value deserialized from
22698    /// the integer representation of enums.
22699    pub fn name(&self) -> std::option::Option<&str> {
22700        match self {
22701            Self::Unspecified => std::option::Option::Some("CHANGE_TYPE_UNSPECIFIED"),
22702            Self::Added => std::option::Option::Some("ADDED"),
22703            Self::Removed => std::option::Option::Some("REMOVED"),
22704            Self::Modified => std::option::Option::Some("MODIFIED"),
22705            Self::UnknownValue(u) => u.0.name(),
22706        }
22707    }
22708}
22709
22710impl std::default::Default for ChangeType {
22711    fn default() -> Self {
22712        use std::convert::From;
22713        Self::from(0)
22714    }
22715}
22716
22717impl std::fmt::Display for ChangeType {
22718    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22719        wkt::internal::display_enum(f, self.name(), self.value())
22720    }
22721}
22722
22723impl std::convert::From<i32> for ChangeType {
22724    fn from(value: i32) -> Self {
22725        match value {
22726            0 => Self::Unspecified,
22727            1 => Self::Added,
22728            2 => Self::Removed,
22729            3 => Self::Modified,
22730            _ => Self::UnknownValue(change_type::UnknownValue(
22731                wkt::internal::UnknownEnumValue::Integer(value),
22732            )),
22733        }
22734    }
22735}
22736
22737impl std::convert::From<&str> for ChangeType {
22738    fn from(value: &str) -> Self {
22739        use std::string::ToString;
22740        match value {
22741            "CHANGE_TYPE_UNSPECIFIED" => Self::Unspecified,
22742            "ADDED" => Self::Added,
22743            "REMOVED" => Self::Removed,
22744            "MODIFIED" => Self::Modified,
22745            _ => Self::UnknownValue(change_type::UnknownValue(
22746                wkt::internal::UnknownEnumValue::String(value.to_string()),
22747            )),
22748        }
22749    }
22750}
22751
22752impl serde::ser::Serialize for ChangeType {
22753    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22754    where
22755        S: serde::Serializer,
22756    {
22757        match self {
22758            Self::Unspecified => serializer.serialize_i32(0),
22759            Self::Added => serializer.serialize_i32(1),
22760            Self::Removed => serializer.serialize_i32(2),
22761            Self::Modified => serializer.serialize_i32(3),
22762            Self::UnknownValue(u) => u.0.serialize(serializer),
22763        }
22764    }
22765}
22766
22767impl<'de> serde::de::Deserialize<'de> for ChangeType {
22768    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22769    where
22770        D: serde::Deserializer<'de>,
22771    {
22772        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ChangeType>::new(
22773            ".google.api.ChangeType",
22774        ))
22775    }
22776}
22777
22778/// Defines the supported values for `google.rpc.ErrorInfo.reason` for the
22779/// `googleapis.com` error domain. This error domain is reserved for [Service
22780/// Infrastructure](https://cloud.google.com/service-infrastructure/docs/overview).
22781/// For each error info of this domain, the metadata key "service" refers to the
22782/// logical identifier of an API service, such as "pubsub.googleapis.com". The
22783/// "consumer" refers to the entity that consumes an API Service. It typically is
22784/// a Google project that owns the client application or the server resource,
22785/// such as "projects/123". Other metadata keys are specific to each error
22786/// reason. For more information, see the definition of the specific error
22787/// reason.
22788///
22789/// # Working with unknown values
22790///
22791/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22792/// additional enum variants at any time. Adding new variants is not considered
22793/// a breaking change. Applications should write their code in anticipation of:
22794///
22795/// - New values appearing in future releases of the client library, **and**
22796/// - New values received dynamically, without application changes.
22797///
22798/// Please consult the [Working with enums] section in the user guide for some
22799/// guidelines.
22800///
22801/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22802#[derive(Clone, Debug, PartialEq)]
22803#[non_exhaustive]
22804pub enum ErrorReason {
22805    /// Do not use this default value.
22806    Unspecified,
22807    /// The request is calling a disabled service for a consumer.
22808    ///
22809    /// Example of an ErrorInfo when the consumer "projects/123" contacting
22810    /// "pubsub.googleapis.com" service which is disabled:
22811    ///
22812    /// ```norust
22813    /// { "reason": "SERVICE_DISABLED",
22814    ///   "domain": "googleapis.com",
22815    ///   "metadata": {
22816    ///     "consumer": "projects/123",
22817    ///     "service": "pubsub.googleapis.com"
22818    ///   }
22819    /// }
22820    /// ```
22821    ///
22822    /// This response indicates the "pubsub.googleapis.com" has been disabled in
22823    /// "projects/123".
22824    ServiceDisabled,
22825    /// The request whose associated billing account is disabled.
22826    ///
22827    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
22828    /// "pubsub.googleapis.com" service because the associated billing account is
22829    /// disabled:
22830    ///
22831    /// ```norust
22832    /// { "reason": "BILLING_DISABLED",
22833    ///   "domain": "googleapis.com",
22834    ///   "metadata": {
22835    ///     "consumer": "projects/123",
22836    ///     "service": "pubsub.googleapis.com"
22837    ///   }
22838    /// }
22839    /// ```
22840    ///
22841    /// This response indicates the billing account associated has been disabled.
22842    BillingDisabled,
22843    /// The request is denied because the provided [API
22844    /// key](https://cloud.google.com/docs/authentication/api-keys) is invalid. It
22845    /// may be in a bad format, cannot be found, or has been expired).
22846    ///
22847    /// Example of an ErrorInfo when the request is contacting
22848    /// "storage.googleapis.com" service with an invalid API key:
22849    ///
22850    /// ```norust
22851    /// { "reason": "API_KEY_INVALID",
22852    ///   "domain": "googleapis.com",
22853    ///   "metadata": {
22854    ///     "service": "storage.googleapis.com",
22855    ///   }
22856    /// }
22857    /// ```
22858    ApiKeyInvalid,
22859    /// The request is denied because it violates [API key API
22860    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_api_restrictions).
22861    ///
22862    /// Example of an ErrorInfo when the consumer "projects/123" fails to call the
22863    /// "storage.googleapis.com" service because this service is restricted in the
22864    /// API key:
22865    ///
22866    /// ```norust
22867    /// { "reason": "API_KEY_SERVICE_BLOCKED",
22868    ///   "domain": "googleapis.com",
22869    ///   "metadata": {
22870    ///     "consumer": "projects/123",
22871    ///     "service": "storage.googleapis.com"
22872    ///   }
22873    /// }
22874    /// ```
22875    ApiKeyServiceBlocked,
22876    /// The request is denied because it violates [API key HTTP
22877    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions).
22878    ///
22879    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
22880    /// "storage.googleapis.com" service because the http referrer of the request
22881    /// violates API key HTTP restrictions:
22882    ///
22883    /// ```norust
22884    /// { "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
22885    ///   "domain": "googleapis.com",
22886    ///   "metadata": {
22887    ///     "consumer": "projects/123",
22888    ///     "service": "storage.googleapis.com",
22889    ///   }
22890    /// }
22891    /// ```
22892    ApiKeyHttpReferrerBlocked,
22893    /// The request is denied because it violates [API key IP address
22894    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
22895    ///
22896    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
22897    /// "storage.googleapis.com" service because the caller IP of the request
22898    /// violates API key IP address restrictions:
22899    ///
22900    /// ```norust
22901    /// { "reason": "API_KEY_IP_ADDRESS_BLOCKED",
22902    ///   "domain": "googleapis.com",
22903    ///   "metadata": {
22904    ///     "consumer": "projects/123",
22905    ///     "service": "storage.googleapis.com",
22906    ///   }
22907    /// }
22908    /// ```
22909    ApiKeyIpAddressBlocked,
22910    /// The request is denied because it violates [API key Android application
22911    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
22912    ///
22913    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
22914    /// "storage.googleapis.com" service because the request from the Android apps
22915    /// violates the API key Android application restrictions:
22916    ///
22917    /// ```norust
22918    /// { "reason": "API_KEY_ANDROID_APP_BLOCKED",
22919    ///   "domain": "googleapis.com",
22920    ///   "metadata": {
22921    ///     "consumer": "projects/123",
22922    ///     "service": "storage.googleapis.com"
22923    ///   }
22924    /// }
22925    /// ```
22926    ApiKeyAndroidAppBlocked,
22927    /// The request is denied because it violates [API key iOS application
22928    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
22929    ///
22930    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
22931    /// "storage.googleapis.com" service because the request from the iOS apps
22932    /// violates the API key iOS application restrictions:
22933    ///
22934    /// ```norust
22935    /// { "reason": "API_KEY_IOS_APP_BLOCKED",
22936    ///   "domain": "googleapis.com",
22937    ///   "metadata": {
22938    ///     "consumer": "projects/123",
22939    ///     "service": "storage.googleapis.com"
22940    ///   }
22941    /// }
22942    /// ```
22943    ApiKeyIosAppBlocked,
22944    /// The request is denied because there is not enough rate quota for the
22945    /// consumer.
22946    ///
22947    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
22948    /// "pubsub.googleapis.com" service because consumer's rate quota usage has
22949    /// reached the maximum value set for the quota limit
22950    /// "ReadsPerMinutePerProject" on the quota metric
22951    /// "pubsub.googleapis.com/read_requests":
22952    ///
22953    /// ```norust
22954    /// { "reason": "RATE_LIMIT_EXCEEDED",
22955    ///   "domain": "googleapis.com",
22956    ///   "metadata": {
22957    ///     "consumer": "projects/123",
22958    ///     "service": "pubsub.googleapis.com",
22959    ///     "quota_metric": "pubsub.googleapis.com/read_requests",
22960    ///     "quota_limit": "ReadsPerMinutePerProject"
22961    ///   }
22962    /// }
22963    /// ```
22964    ///
22965    /// Example of an ErrorInfo when the consumer "projects/123" checks quota on
22966    /// the service "dataflow.googleapis.com" and hits the organization quota
22967    /// limit "DefaultRequestsPerMinutePerOrganization" on the metric
22968    /// "dataflow.googleapis.com/default_requests".
22969    ///
22970    /// ```norust
22971    /// { "reason": "RATE_LIMIT_EXCEEDED",
22972    ///   "domain": "googleapis.com",
22973    ///   "metadata": {
22974    ///     "consumer": "projects/123",
22975    ///     "service": "dataflow.googleapis.com",
22976    ///     "quota_metric": "dataflow.googleapis.com/default_requests",
22977    ///     "quota_limit": "DefaultRequestsPerMinutePerOrganization"
22978    ///   }
22979    /// }
22980    /// ```
22981    RateLimitExceeded,
22982    /// The request is denied because there is not enough resource quota for the
22983    /// consumer.
22984    ///
22985    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
22986    /// "compute.googleapis.com" service because consumer's resource quota usage
22987    /// has reached the maximum value set for the quota limit "VMsPerProject"
22988    /// on the quota metric "compute.googleapis.com/vms":
22989    ///
22990    /// ```norust
22991    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
22992    ///   "domain": "googleapis.com",
22993    ///   "metadata": {
22994    ///     "consumer": "projects/123",
22995    ///     "service": "compute.googleapis.com",
22996    ///     "quota_metric": "compute.googleapis.com/vms",
22997    ///     "quota_limit": "VMsPerProject"
22998    ///   }
22999    /// }
23000    /// ```
23001    ///
23002    /// Example of an ErrorInfo when the consumer "projects/123" checks resource
23003    /// quota on the service "dataflow.googleapis.com" and hits the organization
23004    /// quota limit "jobs-per-organization" on the metric
23005    /// "dataflow.googleapis.com/job_count".
23006    ///
23007    /// ```norust
23008    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
23009    ///   "domain": "googleapis.com",
23010    ///   "metadata": {
23011    ///     "consumer": "projects/123",
23012    ///     "service": "dataflow.googleapis.com",
23013    ///     "quota_metric": "dataflow.googleapis.com/job_count",
23014    ///     "quota_limit": "jobs-per-organization"
23015    ///   }
23016    /// }
23017    /// ```
23018    ResourceQuotaExceeded,
23019    /// The request whose associated billing account address is in a tax restricted
23020    /// location, violates the local tax restrictions when creating resources in
23021    /// the restricted region.
23022    ///
23023    /// Example of an ErrorInfo when creating the Cloud Storage Bucket in the
23024    /// container "projects/123" under a tax restricted region
23025    /// "locations/asia-northeast3":
23026    ///
23027    /// ```norust
23028    /// { "reason": "LOCATION_TAX_POLICY_VIOLATED",
23029    ///   "domain": "googleapis.com",
23030    ///   "metadata": {
23031    ///     "consumer": "projects/123",
23032    ///     "service": "storage.googleapis.com",
23033    ///     "location": "locations/asia-northeast3"
23034    ///   }
23035    /// }
23036    /// ```
23037    ///
23038    /// This response indicates creating the Cloud Storage Bucket in
23039    /// "locations/asia-northeast3" violates the location tax restriction.
23040    LocationTaxPolicyViolated,
23041    /// The request is denied because the caller does not have required permission
23042    /// on the user project "projects/123" or the user project is invalid. For more
23043    /// information, check the [userProject System
23044    /// Parameters](https://cloud.google.com/apis/docs/system-parameters).
23045    ///
23046    /// Example of an ErrorInfo when the caller is calling Cloud Storage service
23047    /// with insufficient permissions on the user project:
23048    ///
23049    /// ```norust
23050    /// { "reason": "USER_PROJECT_DENIED",
23051    ///   "domain": "googleapis.com",
23052    ///   "metadata": {
23053    ///     "consumer": "projects/123",
23054    ///     "service": "storage.googleapis.com"
23055    ///   }
23056    /// }
23057    /// ```
23058    UserProjectDenied,
23059    /// The request is denied because the consumer "projects/123" is suspended due
23060    /// to Terms of Service(Tos) violations. Check [Project suspension
23061    /// guidelines](https://cloud.google.com/resource-manager/docs/project-suspension-guidelines)
23062    /// for more information.
23063    ///
23064    /// Example of an ErrorInfo when calling Cloud Storage service with the
23065    /// suspended consumer "projects/123":
23066    ///
23067    /// ```norust
23068    /// { "reason": "CONSUMER_SUSPENDED",
23069    ///   "domain": "googleapis.com",
23070    ///   "metadata": {
23071    ///     "consumer": "projects/123",
23072    ///     "service": "storage.googleapis.com"
23073    ///   }
23074    /// }
23075    /// ```
23076    ConsumerSuspended,
23077    /// The request is denied because the associated consumer is invalid. It may be
23078    /// in a bad format, cannot be found, or have been deleted.
23079    ///
23080    /// Example of an ErrorInfo when calling Cloud Storage service with the
23081    /// invalid consumer "projects/123":
23082    ///
23083    /// ```norust
23084    /// { "reason": "CONSUMER_INVALID",
23085    ///   "domain": "googleapis.com",
23086    ///   "metadata": {
23087    ///     "consumer": "projects/123",
23088    ///     "service": "storage.googleapis.com"
23089    ///   }
23090    /// }
23091    /// ```
23092    ConsumerInvalid,
23093    /// The request is denied because it violates [VPC Service
23094    /// Controls](https://cloud.google.com/vpc-service-controls/docs/overview).
23095    /// The 'uid' field is a random generated identifier that customer can use it
23096    /// to search the audit log for a request rejected by VPC Service Controls. For
23097    /// more information, please refer [VPC Service Controls
23098    /// Troubleshooting](https://cloud.google.com/vpc-service-controls/docs/troubleshooting#unique-id)
23099    ///
23100    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
23101    /// Cloud Storage service because the request is prohibited by the VPC Service
23102    /// Controls.
23103    ///
23104    /// ```norust
23105    /// { "reason": "SECURITY_POLICY_VIOLATED",
23106    ///   "domain": "googleapis.com",
23107    ///   "metadata": {
23108    ///     "uid": "123456789abcde",
23109    ///     "consumer": "projects/123",
23110    ///     "service": "storage.googleapis.com"
23111    ///   }
23112    /// }
23113    /// ```
23114    SecurityPolicyViolated,
23115    /// The request is denied because the provided access token has expired.
23116    ///
23117    /// Example of an ErrorInfo when the request is calling Cloud Storage service
23118    /// with an expired access token:
23119    ///
23120    /// ```norust
23121    /// { "reason": "ACCESS_TOKEN_EXPIRED",
23122    ///   "domain": "googleapis.com",
23123    ///   "metadata": {
23124    ///     "service": "storage.googleapis.com",
23125    ///     "method": "google.storage.v1.Storage.GetObject"
23126    ///   }
23127    /// }
23128    /// ```
23129    AccessTokenExpired,
23130    /// The request is denied because the provided access token doesn't have at
23131    /// least one of the acceptable scopes required for the API. Please check
23132    /// [OAuth 2.0 Scopes for Google
23133    /// APIs](https://developers.google.com/identity/protocols/oauth2/scopes) for
23134    /// the list of the OAuth 2.0 scopes that you might need to request to access
23135    /// the API.
23136    ///
23137    /// Example of an ErrorInfo when the request is calling Cloud Storage service
23138    /// with an access token that is missing required scopes:
23139    ///
23140    /// ```norust
23141    /// { "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
23142    ///   "domain": "googleapis.com",
23143    ///   "metadata": {
23144    ///     "service": "storage.googleapis.com",
23145    ///     "method": "google.storage.v1.Storage.GetObject"
23146    ///   }
23147    /// }
23148    /// ```
23149    AccessTokenScopeInsufficient,
23150    /// The request is denied because the account associated with the provided
23151    /// access token is in an invalid state, such as disabled or deleted.
23152    /// For more information, see <https://cloud.google.com/docs/authentication>.
23153    ///
23154    /// Warning: For privacy reasons, the server may not be able to disclose the
23155    /// email address for some accounts. The client MUST NOT depend on the
23156    /// availability of the `email` attribute.
23157    ///
23158    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
23159    /// an access token that is associated with a disabled or deleted [service
23160    /// account](http://cloud/iam/docs/service-accounts):
23161    ///
23162    /// ```norust
23163    /// { "reason": "ACCOUNT_STATE_INVALID",
23164    ///   "domain": "googleapis.com",
23165    ///   "metadata": {
23166    ///     "service": "storage.googleapis.com",
23167    ///     "method": "google.storage.v1.Storage.GetObject",
23168    ///     "email": "user@123.iam.gserviceaccount.com"
23169    ///   }
23170    /// }
23171    /// ```
23172    AccountStateInvalid,
23173    /// The request is denied because the type of the provided access token is not
23174    /// supported by the API being called.
23175    ///
23176    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
23177    /// an unsupported token type.
23178    ///
23179    /// ```norust
23180    /// { "reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
23181    ///   "domain": "googleapis.com",
23182    ///   "metadata": {
23183    ///     "service": "storage.googleapis.com",
23184    ///     "method": "google.storage.v1.Storage.GetObject"
23185    ///   }
23186    /// }
23187    /// ```
23188    AccessTokenTypeUnsupported,
23189    /// The request is denied because the request doesn't have any authentication
23190    /// credentials. For more information regarding the supported authentication
23191    /// strategies for Google Cloud APIs, see
23192    /// <https://cloud.google.com/docs/authentication>.
23193    ///
23194    /// Example of an ErrorInfo when the request is to the Cloud Storage API
23195    /// without any authentication credentials.
23196    ///
23197    /// ```norust
23198    /// { "reason": "CREDENTIALS_MISSING",
23199    ///   "domain": "googleapis.com",
23200    ///   "metadata": {
23201    ///     "service": "storage.googleapis.com",
23202    ///     "method": "google.storage.v1.Storage.GetObject"
23203    ///   }
23204    /// }
23205    /// ```
23206    CredentialsMissing,
23207    /// The request is denied because the provided project owning the resource
23208    /// which acts as the [API
23209    /// consumer](https://cloud.google.com/apis/design/glossary#api_consumer) is
23210    /// invalid. It may be in a bad format or empty.
23211    ///
23212    /// Example of an ErrorInfo when the request is to the Cloud Functions API,
23213    /// but the offered resource project in the request in a bad format which can't
23214    /// perform the ListFunctions method.
23215    ///
23216    /// ```norust
23217    /// { "reason": "RESOURCE_PROJECT_INVALID",
23218    ///   "domain": "googleapis.com",
23219    ///   "metadata": {
23220    ///     "service": "cloudfunctions.googleapis.com",
23221    ///     "method":
23222    ///     "google.cloud.functions.v1.CloudFunctionsService.ListFunctions"
23223    ///   }
23224    /// }
23225    /// ```
23226    ResourceProjectInvalid,
23227    /// The request is denied because the provided session cookie is missing,
23228    /// invalid or failed to decode.
23229    ///
23230    /// Example of an ErrorInfo when the request is calling Cloud Storage service
23231    /// with a SID cookie which can't be decoded.
23232    ///
23233    /// ```norust
23234    /// { "reason": "SESSION_COOKIE_INVALID",
23235    ///   "domain": "googleapis.com",
23236    ///   "metadata": {
23237    ///     "service": "storage.googleapis.com",
23238    ///     "method": "google.storage.v1.Storage.GetObject",
23239    ///     "cookie": "SID"
23240    ///   }
23241    /// }
23242    /// ```
23243    SessionCookieInvalid,
23244    /// The request is denied because the user is from a Google Workspace customer
23245    /// that blocks their users from accessing a particular service.
23246    ///
23247    /// Example scenario: <https://support.google.com/a/answer/9197205?hl=en>
23248    ///
23249    /// Example of an ErrorInfo when access to Google Cloud Storage service is
23250    /// blocked by the Google Workspace administrator:
23251    ///
23252    /// ```norust
23253    /// { "reason": "USER_BLOCKED_BY_ADMIN",
23254    ///   "domain": "googleapis.com",
23255    ///   "metadata": {
23256    ///     "service": "storage.googleapis.com",
23257    ///     "method": "google.storage.v1.Storage.GetObject",
23258    ///   }
23259    /// }
23260    /// ```
23261    UserBlockedByAdmin,
23262    /// The request is denied because the resource service usage is restricted
23263    /// by administrators according to the organization policy constraint.
23264    /// For more information see
23265    /// <https://cloud.google.com/resource-manager/docs/organization-policy/restricting-services>.
23266    ///
23267    /// Example of an ErrorInfo when access to Google Cloud Storage service is
23268    /// restricted by Resource Usage Restriction policy:
23269    ///
23270    /// ```norust
23271    /// { "reason": "RESOURCE_USAGE_RESTRICTION_VIOLATED",
23272    ///   "domain": "googleapis.com",
23273    ///   "metadata": {
23274    ///     "consumer": "projects/project-123",
23275    ///     "service": "storage.googleapis.com"
23276    ///   }
23277    /// }
23278    /// ```
23279    ResourceUsageRestrictionViolated,
23280    /// Unimplemented. Do not use.
23281    ///
23282    /// The request is denied because it contains unsupported system parameters in
23283    /// URL query parameters or HTTP headers. For more information,
23284    /// see <https://cloud.google.com/apis/docs/system-parameters>
23285    ///
23286    /// Example of an ErrorInfo when access "pubsub.googleapis.com" service with
23287    /// a request header of "x-goog-user-ip":
23288    ///
23289    /// ```norust
23290    /// { "reason": "SYSTEM_PARAMETER_UNSUPPORTED",
23291    ///   "domain": "googleapis.com",
23292    ///   "metadata": {
23293    ///     "service": "pubsub.googleapis.com"
23294    ///     "parameter": "x-goog-user-ip"
23295    ///   }
23296    /// }
23297    /// ```
23298    SystemParameterUnsupported,
23299    /// The request is denied because it violates Org Restriction: the requested
23300    /// resource does not belong to allowed organizations specified in
23301    /// "X-Goog-Allowed-Resources" header.
23302    ///
23303    /// Example of an ErrorInfo when accessing a GCP resource that is restricted by
23304    /// Org Restriction for "pubsub.googleapis.com" service.
23305    ///
23306    /// {
23307    /// reason: "ORG_RESTRICTION_VIOLATION"
23308    /// domain: "googleapis.com"
23309    /// metadata {
23310    /// "consumer":"projects/123456"
23311    /// "service": "pubsub.googleapis.com"
23312    /// }
23313    /// }
23314    OrgRestrictionViolation,
23315    /// The request is denied because "X-Goog-Allowed-Resources" header is in a bad
23316    /// format.
23317    ///
23318    /// Example of an ErrorInfo when
23319    /// accessing "pubsub.googleapis.com" service with an invalid
23320    /// "X-Goog-Allowed-Resources" request header.
23321    ///
23322    /// {
23323    /// reason: "ORG_RESTRICTION_HEADER_INVALID"
23324    /// domain: "googleapis.com"
23325    /// metadata {
23326    /// "consumer":"projects/123456"
23327    /// "service": "pubsub.googleapis.com"
23328    /// }
23329    /// }
23330    OrgRestrictionHeaderInvalid,
23331    /// Unimplemented. Do not use.
23332    ///
23333    /// The request is calling a service that is not visible to the consumer.
23334    ///
23335    /// Example of an ErrorInfo when the consumer "projects/123" contacting
23336    /// "pubsub.googleapis.com" service which is not visible to the consumer.
23337    ///
23338    /// ```norust
23339    /// { "reason": "SERVICE_NOT_VISIBLE",
23340    ///   "domain": "googleapis.com",
23341    ///   "metadata": {
23342    ///     "consumer": "projects/123",
23343    ///     "service": "pubsub.googleapis.com"
23344    ///   }
23345    /// }
23346    /// ```
23347    ///
23348    /// This response indicates the "pubsub.googleapis.com" is not visible to
23349    /// "projects/123" (or it may not exist).
23350    ServiceNotVisible,
23351    /// The request is related to a project for which GCP access is suspended.
23352    ///
23353    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
23354    /// "pubsub.googleapis.com" service because GCP access is suspended:
23355    ///
23356    /// ```norust
23357    /// { "reason": "GCP_SUSPENDED",
23358    ///   "domain": "googleapis.com",
23359    ///   "metadata": {
23360    ///     "consumer": "projects/123",
23361    ///     "service": "pubsub.googleapis.com"
23362    ///   }
23363    /// }
23364    /// ```
23365    ///
23366    /// This response indicates the associated GCP account has been suspended.
23367    GcpSuspended,
23368    /// The request violates the location policies when creating resources in
23369    /// the restricted region.
23370    ///
23371    /// Example of an ErrorInfo when creating the Cloud Storage Bucket by
23372    /// "projects/123" for service storage.googleapis.com:
23373    ///
23374    /// ```norust
23375    /// { "reason": "LOCATION_POLICY_VIOLATED",
23376    ///   "domain": "googleapis.com",
23377    ///   "metadata": {
23378    ///     "consumer": "projects/123",
23379    ///     "service": "storage.googleapis.com",
23380    ///   }
23381    /// }
23382    /// ```
23383    ///
23384    /// This response indicates creating the Cloud Storage Bucket in
23385    /// "locations/asia-northeast3" violates at least one location policy.
23386    /// The troubleshooting guidance is provided in the Help links.
23387    LocationPolicyViolated,
23388    /// The request is denied because origin request header is missing.
23389    ///
23390    /// Example of an ErrorInfo when
23391    /// accessing "pubsub.googleapis.com" service with an empty "Origin" request
23392    /// header.
23393    ///
23394    /// {
23395    /// reason: "MISSING_ORIGIN"
23396    /// domain: "googleapis.com"
23397    /// metadata {
23398    /// "consumer":"projects/123456"
23399    /// "service": "pubsub.googleapis.com"
23400    /// }
23401    /// }
23402    MissingOrigin,
23403    /// The request is denied because the request contains more than one credential
23404    /// type that are individually acceptable, but not together. The customer
23405    /// should retry their request with only one set of credentials.
23406    ///
23407    /// Example of an ErrorInfo when
23408    /// accessing "pubsub.googleapis.com" service with overloaded credentials.
23409    ///
23410    /// {
23411    /// reason: "OVERLOADED_CREDENTIALS"
23412    /// domain: "googleapis.com"
23413    /// metadata {
23414    /// "consumer":"projects/123456"
23415    /// "service": "pubsub.googleapis.com"
23416    /// }
23417    /// }
23418    OverloadedCredentials,
23419    /// If set, the enum was initialized with an unknown value.
23420    ///
23421    /// Applications can examine the value using [ErrorReason::value] or
23422    /// [ErrorReason::name].
23423    UnknownValue(error_reason::UnknownValue),
23424}
23425
23426#[doc(hidden)]
23427pub mod error_reason {
23428    #[allow(unused_imports)]
23429    use super::*;
23430    #[derive(Clone, Debug, PartialEq)]
23431    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
23432}
23433
23434impl ErrorReason {
23435    /// Gets the enum value.
23436    ///
23437    /// Returns `None` if the enum contains an unknown value deserialized from
23438    /// the string representation of enums.
23439    pub fn value(&self) -> std::option::Option<i32> {
23440        match self {
23441            Self::Unspecified => std::option::Option::Some(0),
23442            Self::ServiceDisabled => std::option::Option::Some(1),
23443            Self::BillingDisabled => std::option::Option::Some(2),
23444            Self::ApiKeyInvalid => std::option::Option::Some(3),
23445            Self::ApiKeyServiceBlocked => std::option::Option::Some(4),
23446            Self::ApiKeyHttpReferrerBlocked => std::option::Option::Some(7),
23447            Self::ApiKeyIpAddressBlocked => std::option::Option::Some(8),
23448            Self::ApiKeyAndroidAppBlocked => std::option::Option::Some(9),
23449            Self::ApiKeyIosAppBlocked => std::option::Option::Some(13),
23450            Self::RateLimitExceeded => std::option::Option::Some(5),
23451            Self::ResourceQuotaExceeded => std::option::Option::Some(6),
23452            Self::LocationTaxPolicyViolated => std::option::Option::Some(10),
23453            Self::UserProjectDenied => std::option::Option::Some(11),
23454            Self::ConsumerSuspended => std::option::Option::Some(12),
23455            Self::ConsumerInvalid => std::option::Option::Some(14),
23456            Self::SecurityPolicyViolated => std::option::Option::Some(15),
23457            Self::AccessTokenExpired => std::option::Option::Some(16),
23458            Self::AccessTokenScopeInsufficient => std::option::Option::Some(17),
23459            Self::AccountStateInvalid => std::option::Option::Some(18),
23460            Self::AccessTokenTypeUnsupported => std::option::Option::Some(19),
23461            Self::CredentialsMissing => std::option::Option::Some(20),
23462            Self::ResourceProjectInvalid => std::option::Option::Some(21),
23463            Self::SessionCookieInvalid => std::option::Option::Some(23),
23464            Self::UserBlockedByAdmin => std::option::Option::Some(24),
23465            Self::ResourceUsageRestrictionViolated => std::option::Option::Some(25),
23466            Self::SystemParameterUnsupported => std::option::Option::Some(26),
23467            Self::OrgRestrictionViolation => std::option::Option::Some(27),
23468            Self::OrgRestrictionHeaderInvalid => std::option::Option::Some(28),
23469            Self::ServiceNotVisible => std::option::Option::Some(29),
23470            Self::GcpSuspended => std::option::Option::Some(30),
23471            Self::LocationPolicyViolated => std::option::Option::Some(31),
23472            Self::MissingOrigin => std::option::Option::Some(33),
23473            Self::OverloadedCredentials => std::option::Option::Some(34),
23474            Self::UnknownValue(u) => u.0.value(),
23475        }
23476    }
23477
23478    /// Gets the enum value as a string.
23479    ///
23480    /// Returns `None` if the enum contains an unknown value deserialized from
23481    /// the integer representation of enums.
23482    pub fn name(&self) -> std::option::Option<&str> {
23483        match self {
23484            Self::Unspecified => std::option::Option::Some("ERROR_REASON_UNSPECIFIED"),
23485            Self::ServiceDisabled => std::option::Option::Some("SERVICE_DISABLED"),
23486            Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
23487            Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
23488            Self::ApiKeyServiceBlocked => std::option::Option::Some("API_KEY_SERVICE_BLOCKED"),
23489            Self::ApiKeyHttpReferrerBlocked => {
23490                std::option::Option::Some("API_KEY_HTTP_REFERRER_BLOCKED")
23491            }
23492            Self::ApiKeyIpAddressBlocked => std::option::Option::Some("API_KEY_IP_ADDRESS_BLOCKED"),
23493            Self::ApiKeyAndroidAppBlocked => {
23494                std::option::Option::Some("API_KEY_ANDROID_APP_BLOCKED")
23495            }
23496            Self::ApiKeyIosAppBlocked => std::option::Option::Some("API_KEY_IOS_APP_BLOCKED"),
23497            Self::RateLimitExceeded => std::option::Option::Some("RATE_LIMIT_EXCEEDED"),
23498            Self::ResourceQuotaExceeded => std::option::Option::Some("RESOURCE_QUOTA_EXCEEDED"),
23499            Self::LocationTaxPolicyViolated => {
23500                std::option::Option::Some("LOCATION_TAX_POLICY_VIOLATED")
23501            }
23502            Self::UserProjectDenied => std::option::Option::Some("USER_PROJECT_DENIED"),
23503            Self::ConsumerSuspended => std::option::Option::Some("CONSUMER_SUSPENDED"),
23504            Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
23505            Self::SecurityPolicyViolated => std::option::Option::Some("SECURITY_POLICY_VIOLATED"),
23506            Self::AccessTokenExpired => std::option::Option::Some("ACCESS_TOKEN_EXPIRED"),
23507            Self::AccessTokenScopeInsufficient => {
23508                std::option::Option::Some("ACCESS_TOKEN_SCOPE_INSUFFICIENT")
23509            }
23510            Self::AccountStateInvalid => std::option::Option::Some("ACCOUNT_STATE_INVALID"),
23511            Self::AccessTokenTypeUnsupported => {
23512                std::option::Option::Some("ACCESS_TOKEN_TYPE_UNSUPPORTED")
23513            }
23514            Self::CredentialsMissing => std::option::Option::Some("CREDENTIALS_MISSING"),
23515            Self::ResourceProjectInvalid => std::option::Option::Some("RESOURCE_PROJECT_INVALID"),
23516            Self::SessionCookieInvalid => std::option::Option::Some("SESSION_COOKIE_INVALID"),
23517            Self::UserBlockedByAdmin => std::option::Option::Some("USER_BLOCKED_BY_ADMIN"),
23518            Self::ResourceUsageRestrictionViolated => {
23519                std::option::Option::Some("RESOURCE_USAGE_RESTRICTION_VIOLATED")
23520            }
23521            Self::SystemParameterUnsupported => {
23522                std::option::Option::Some("SYSTEM_PARAMETER_UNSUPPORTED")
23523            }
23524            Self::OrgRestrictionViolation => std::option::Option::Some("ORG_RESTRICTION_VIOLATION"),
23525            Self::OrgRestrictionHeaderInvalid => {
23526                std::option::Option::Some("ORG_RESTRICTION_HEADER_INVALID")
23527            }
23528            Self::ServiceNotVisible => std::option::Option::Some("SERVICE_NOT_VISIBLE"),
23529            Self::GcpSuspended => std::option::Option::Some("GCP_SUSPENDED"),
23530            Self::LocationPolicyViolated => std::option::Option::Some("LOCATION_POLICY_VIOLATED"),
23531            Self::MissingOrigin => std::option::Option::Some("MISSING_ORIGIN"),
23532            Self::OverloadedCredentials => std::option::Option::Some("OVERLOADED_CREDENTIALS"),
23533            Self::UnknownValue(u) => u.0.name(),
23534        }
23535    }
23536}
23537
23538impl std::default::Default for ErrorReason {
23539    fn default() -> Self {
23540        use std::convert::From;
23541        Self::from(0)
23542    }
23543}
23544
23545impl std::fmt::Display for ErrorReason {
23546    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
23547        wkt::internal::display_enum(f, self.name(), self.value())
23548    }
23549}
23550
23551impl std::convert::From<i32> for ErrorReason {
23552    fn from(value: i32) -> Self {
23553        match value {
23554            0 => Self::Unspecified,
23555            1 => Self::ServiceDisabled,
23556            2 => Self::BillingDisabled,
23557            3 => Self::ApiKeyInvalid,
23558            4 => Self::ApiKeyServiceBlocked,
23559            5 => Self::RateLimitExceeded,
23560            6 => Self::ResourceQuotaExceeded,
23561            7 => Self::ApiKeyHttpReferrerBlocked,
23562            8 => Self::ApiKeyIpAddressBlocked,
23563            9 => Self::ApiKeyAndroidAppBlocked,
23564            10 => Self::LocationTaxPolicyViolated,
23565            11 => Self::UserProjectDenied,
23566            12 => Self::ConsumerSuspended,
23567            13 => Self::ApiKeyIosAppBlocked,
23568            14 => Self::ConsumerInvalid,
23569            15 => Self::SecurityPolicyViolated,
23570            16 => Self::AccessTokenExpired,
23571            17 => Self::AccessTokenScopeInsufficient,
23572            18 => Self::AccountStateInvalid,
23573            19 => Self::AccessTokenTypeUnsupported,
23574            20 => Self::CredentialsMissing,
23575            21 => Self::ResourceProjectInvalid,
23576            23 => Self::SessionCookieInvalid,
23577            24 => Self::UserBlockedByAdmin,
23578            25 => Self::ResourceUsageRestrictionViolated,
23579            26 => Self::SystemParameterUnsupported,
23580            27 => Self::OrgRestrictionViolation,
23581            28 => Self::OrgRestrictionHeaderInvalid,
23582            29 => Self::ServiceNotVisible,
23583            30 => Self::GcpSuspended,
23584            31 => Self::LocationPolicyViolated,
23585            33 => Self::MissingOrigin,
23586            34 => Self::OverloadedCredentials,
23587            _ => Self::UnknownValue(error_reason::UnknownValue(
23588                wkt::internal::UnknownEnumValue::Integer(value),
23589            )),
23590        }
23591    }
23592}
23593
23594impl std::convert::From<&str> for ErrorReason {
23595    fn from(value: &str) -> Self {
23596        use std::string::ToString;
23597        match value {
23598            "ERROR_REASON_UNSPECIFIED" => Self::Unspecified,
23599            "SERVICE_DISABLED" => Self::ServiceDisabled,
23600            "BILLING_DISABLED" => Self::BillingDisabled,
23601            "API_KEY_INVALID" => Self::ApiKeyInvalid,
23602            "API_KEY_SERVICE_BLOCKED" => Self::ApiKeyServiceBlocked,
23603            "API_KEY_HTTP_REFERRER_BLOCKED" => Self::ApiKeyHttpReferrerBlocked,
23604            "API_KEY_IP_ADDRESS_BLOCKED" => Self::ApiKeyIpAddressBlocked,
23605            "API_KEY_ANDROID_APP_BLOCKED" => Self::ApiKeyAndroidAppBlocked,
23606            "API_KEY_IOS_APP_BLOCKED" => Self::ApiKeyIosAppBlocked,
23607            "RATE_LIMIT_EXCEEDED" => Self::RateLimitExceeded,
23608            "RESOURCE_QUOTA_EXCEEDED" => Self::ResourceQuotaExceeded,
23609            "LOCATION_TAX_POLICY_VIOLATED" => Self::LocationTaxPolicyViolated,
23610            "USER_PROJECT_DENIED" => Self::UserProjectDenied,
23611            "CONSUMER_SUSPENDED" => Self::ConsumerSuspended,
23612            "CONSUMER_INVALID" => Self::ConsumerInvalid,
23613            "SECURITY_POLICY_VIOLATED" => Self::SecurityPolicyViolated,
23614            "ACCESS_TOKEN_EXPIRED" => Self::AccessTokenExpired,
23615            "ACCESS_TOKEN_SCOPE_INSUFFICIENT" => Self::AccessTokenScopeInsufficient,
23616            "ACCOUNT_STATE_INVALID" => Self::AccountStateInvalid,
23617            "ACCESS_TOKEN_TYPE_UNSUPPORTED" => Self::AccessTokenTypeUnsupported,
23618            "CREDENTIALS_MISSING" => Self::CredentialsMissing,
23619            "RESOURCE_PROJECT_INVALID" => Self::ResourceProjectInvalid,
23620            "SESSION_COOKIE_INVALID" => Self::SessionCookieInvalid,
23621            "USER_BLOCKED_BY_ADMIN" => Self::UserBlockedByAdmin,
23622            "RESOURCE_USAGE_RESTRICTION_VIOLATED" => Self::ResourceUsageRestrictionViolated,
23623            "SYSTEM_PARAMETER_UNSUPPORTED" => Self::SystemParameterUnsupported,
23624            "ORG_RESTRICTION_VIOLATION" => Self::OrgRestrictionViolation,
23625            "ORG_RESTRICTION_HEADER_INVALID" => Self::OrgRestrictionHeaderInvalid,
23626            "SERVICE_NOT_VISIBLE" => Self::ServiceNotVisible,
23627            "GCP_SUSPENDED" => Self::GcpSuspended,
23628            "LOCATION_POLICY_VIOLATED" => Self::LocationPolicyViolated,
23629            "MISSING_ORIGIN" => Self::MissingOrigin,
23630            "OVERLOADED_CREDENTIALS" => Self::OverloadedCredentials,
23631            _ => Self::UnknownValue(error_reason::UnknownValue(
23632                wkt::internal::UnknownEnumValue::String(value.to_string()),
23633            )),
23634        }
23635    }
23636}
23637
23638impl serde::ser::Serialize for ErrorReason {
23639    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
23640    where
23641        S: serde::Serializer,
23642    {
23643        match self {
23644            Self::Unspecified => serializer.serialize_i32(0),
23645            Self::ServiceDisabled => serializer.serialize_i32(1),
23646            Self::BillingDisabled => serializer.serialize_i32(2),
23647            Self::ApiKeyInvalid => serializer.serialize_i32(3),
23648            Self::ApiKeyServiceBlocked => serializer.serialize_i32(4),
23649            Self::ApiKeyHttpReferrerBlocked => serializer.serialize_i32(7),
23650            Self::ApiKeyIpAddressBlocked => serializer.serialize_i32(8),
23651            Self::ApiKeyAndroidAppBlocked => serializer.serialize_i32(9),
23652            Self::ApiKeyIosAppBlocked => serializer.serialize_i32(13),
23653            Self::RateLimitExceeded => serializer.serialize_i32(5),
23654            Self::ResourceQuotaExceeded => serializer.serialize_i32(6),
23655            Self::LocationTaxPolicyViolated => serializer.serialize_i32(10),
23656            Self::UserProjectDenied => serializer.serialize_i32(11),
23657            Self::ConsumerSuspended => serializer.serialize_i32(12),
23658            Self::ConsumerInvalid => serializer.serialize_i32(14),
23659            Self::SecurityPolicyViolated => serializer.serialize_i32(15),
23660            Self::AccessTokenExpired => serializer.serialize_i32(16),
23661            Self::AccessTokenScopeInsufficient => serializer.serialize_i32(17),
23662            Self::AccountStateInvalid => serializer.serialize_i32(18),
23663            Self::AccessTokenTypeUnsupported => serializer.serialize_i32(19),
23664            Self::CredentialsMissing => serializer.serialize_i32(20),
23665            Self::ResourceProjectInvalid => serializer.serialize_i32(21),
23666            Self::SessionCookieInvalid => serializer.serialize_i32(23),
23667            Self::UserBlockedByAdmin => serializer.serialize_i32(24),
23668            Self::ResourceUsageRestrictionViolated => serializer.serialize_i32(25),
23669            Self::SystemParameterUnsupported => serializer.serialize_i32(26),
23670            Self::OrgRestrictionViolation => serializer.serialize_i32(27),
23671            Self::OrgRestrictionHeaderInvalid => serializer.serialize_i32(28),
23672            Self::ServiceNotVisible => serializer.serialize_i32(29),
23673            Self::GcpSuspended => serializer.serialize_i32(30),
23674            Self::LocationPolicyViolated => serializer.serialize_i32(31),
23675            Self::MissingOrigin => serializer.serialize_i32(33),
23676            Self::OverloadedCredentials => serializer.serialize_i32(34),
23677            Self::UnknownValue(u) => u.0.serialize(serializer),
23678        }
23679    }
23680}
23681
23682impl<'de> serde::de::Deserialize<'de> for ErrorReason {
23683    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
23684    where
23685        D: serde::Deserializer<'de>,
23686    {
23687        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ErrorReason>::new(
23688            ".google.api.ErrorReason",
23689        ))
23690    }
23691}
23692
23693/// An indicator of the behavior of a given field (for example, that a field
23694/// is required in requests, or given as output but ignored as input).
23695/// This **does not** change the behavior in protocol buffers itself; it only
23696/// denotes the behavior and may affect how API tooling handles the field.
23697///
23698/// Note: This enum **may** receive new values in the future.
23699///
23700/// # Working with unknown values
23701///
23702/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
23703/// additional enum variants at any time. Adding new variants is not considered
23704/// a breaking change. Applications should write their code in anticipation of:
23705///
23706/// - New values appearing in future releases of the client library, **and**
23707/// - New values received dynamically, without application changes.
23708///
23709/// Please consult the [Working with enums] section in the user guide for some
23710/// guidelines.
23711///
23712/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
23713#[derive(Clone, Debug, PartialEq)]
23714#[non_exhaustive]
23715pub enum FieldBehavior {
23716    /// Conventional default for enums. Do not use this.
23717    Unspecified,
23718    /// Specifically denotes a field as optional.
23719    /// While all fields in protocol buffers are optional, this may be specified
23720    /// for emphasis if appropriate.
23721    Optional,
23722    /// Denotes a field as required.
23723    /// This indicates that the field **must** be provided as part of the request,
23724    /// and failure to do so will cause an error (usually `INVALID_ARGUMENT`).
23725    Required,
23726    /// Denotes a field as output only.
23727    /// This indicates that the field is provided in responses, but including the
23728    /// field in a request does nothing (the server *must* ignore it and
23729    /// *must not* throw an error as a result of the field's presence).
23730    OutputOnly,
23731    /// Denotes a field as input only.
23732    /// This indicates that the field is provided in requests, and the
23733    /// corresponding field is not included in output.
23734    InputOnly,
23735    /// Denotes a field as immutable.
23736    /// This indicates that the field may be set once in a request to create a
23737    /// resource, but may not be changed thereafter.
23738    Immutable,
23739    /// Denotes that a (repeated) field is an unordered list.
23740    /// This indicates that the service may provide the elements of the list
23741    /// in any arbitrary  order, rather than the order the user originally
23742    /// provided. Additionally, the list's order may or may not be stable.
23743    UnorderedList,
23744    /// Denotes that this field returns a non-empty default value if not set.
23745    /// This indicates that if the user provides the empty value in a request,
23746    /// a non-empty value will be returned. The user will not be aware of what
23747    /// non-empty value to expect.
23748    NonEmptyDefault,
23749    /// Denotes that the field in a resource (a message annotated with
23750    /// google.api.resource) is used in the resource name to uniquely identify the
23751    /// resource. For AIP-compliant APIs, this should only be applied to the
23752    /// `name` field on the resource.
23753    ///
23754    /// This behavior should not be applied to references to other resources within
23755    /// the message.
23756    ///
23757    /// The identifier field of resources often have different field behavior
23758    /// depending on the request it is embedded in (e.g. for Create methods name
23759    /// is optional and unused, while for Update methods it is required). Instead
23760    /// of method-specific annotations, only `IDENTIFIER` is required.
23761    Identifier,
23762    /// If set, the enum was initialized with an unknown value.
23763    ///
23764    /// Applications can examine the value using [FieldBehavior::value] or
23765    /// [FieldBehavior::name].
23766    UnknownValue(field_behavior::UnknownValue),
23767}
23768
23769#[doc(hidden)]
23770pub mod field_behavior {
23771    #[allow(unused_imports)]
23772    use super::*;
23773    #[derive(Clone, Debug, PartialEq)]
23774    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
23775}
23776
23777impl FieldBehavior {
23778    /// Gets the enum value.
23779    ///
23780    /// Returns `None` if the enum contains an unknown value deserialized from
23781    /// the string representation of enums.
23782    pub fn value(&self) -> std::option::Option<i32> {
23783        match self {
23784            Self::Unspecified => std::option::Option::Some(0),
23785            Self::Optional => std::option::Option::Some(1),
23786            Self::Required => std::option::Option::Some(2),
23787            Self::OutputOnly => std::option::Option::Some(3),
23788            Self::InputOnly => std::option::Option::Some(4),
23789            Self::Immutable => std::option::Option::Some(5),
23790            Self::UnorderedList => std::option::Option::Some(6),
23791            Self::NonEmptyDefault => std::option::Option::Some(7),
23792            Self::Identifier => std::option::Option::Some(8),
23793            Self::UnknownValue(u) => u.0.value(),
23794        }
23795    }
23796
23797    /// Gets the enum value as a string.
23798    ///
23799    /// Returns `None` if the enum contains an unknown value deserialized from
23800    /// the integer representation of enums.
23801    pub fn name(&self) -> std::option::Option<&str> {
23802        match self {
23803            Self::Unspecified => std::option::Option::Some("FIELD_BEHAVIOR_UNSPECIFIED"),
23804            Self::Optional => std::option::Option::Some("OPTIONAL"),
23805            Self::Required => std::option::Option::Some("REQUIRED"),
23806            Self::OutputOnly => std::option::Option::Some("OUTPUT_ONLY"),
23807            Self::InputOnly => std::option::Option::Some("INPUT_ONLY"),
23808            Self::Immutable => std::option::Option::Some("IMMUTABLE"),
23809            Self::UnorderedList => std::option::Option::Some("UNORDERED_LIST"),
23810            Self::NonEmptyDefault => std::option::Option::Some("NON_EMPTY_DEFAULT"),
23811            Self::Identifier => std::option::Option::Some("IDENTIFIER"),
23812            Self::UnknownValue(u) => u.0.name(),
23813        }
23814    }
23815}
23816
23817impl std::default::Default for FieldBehavior {
23818    fn default() -> Self {
23819        use std::convert::From;
23820        Self::from(0)
23821    }
23822}
23823
23824impl std::fmt::Display for FieldBehavior {
23825    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
23826        wkt::internal::display_enum(f, self.name(), self.value())
23827    }
23828}
23829
23830impl std::convert::From<i32> for FieldBehavior {
23831    fn from(value: i32) -> Self {
23832        match value {
23833            0 => Self::Unspecified,
23834            1 => Self::Optional,
23835            2 => Self::Required,
23836            3 => Self::OutputOnly,
23837            4 => Self::InputOnly,
23838            5 => Self::Immutable,
23839            6 => Self::UnorderedList,
23840            7 => Self::NonEmptyDefault,
23841            8 => Self::Identifier,
23842            _ => Self::UnknownValue(field_behavior::UnknownValue(
23843                wkt::internal::UnknownEnumValue::Integer(value),
23844            )),
23845        }
23846    }
23847}
23848
23849impl std::convert::From<&str> for FieldBehavior {
23850    fn from(value: &str) -> Self {
23851        use std::string::ToString;
23852        match value {
23853            "FIELD_BEHAVIOR_UNSPECIFIED" => Self::Unspecified,
23854            "OPTIONAL" => Self::Optional,
23855            "REQUIRED" => Self::Required,
23856            "OUTPUT_ONLY" => Self::OutputOnly,
23857            "INPUT_ONLY" => Self::InputOnly,
23858            "IMMUTABLE" => Self::Immutable,
23859            "UNORDERED_LIST" => Self::UnorderedList,
23860            "NON_EMPTY_DEFAULT" => Self::NonEmptyDefault,
23861            "IDENTIFIER" => Self::Identifier,
23862            _ => Self::UnknownValue(field_behavior::UnknownValue(
23863                wkt::internal::UnknownEnumValue::String(value.to_string()),
23864            )),
23865        }
23866    }
23867}
23868
23869impl serde::ser::Serialize for FieldBehavior {
23870    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
23871    where
23872        S: serde::Serializer,
23873    {
23874        match self {
23875            Self::Unspecified => serializer.serialize_i32(0),
23876            Self::Optional => serializer.serialize_i32(1),
23877            Self::Required => serializer.serialize_i32(2),
23878            Self::OutputOnly => serializer.serialize_i32(3),
23879            Self::InputOnly => serializer.serialize_i32(4),
23880            Self::Immutable => serializer.serialize_i32(5),
23881            Self::UnorderedList => serializer.serialize_i32(6),
23882            Self::NonEmptyDefault => serializer.serialize_i32(7),
23883            Self::Identifier => serializer.serialize_i32(8),
23884            Self::UnknownValue(u) => u.0.serialize(serializer),
23885        }
23886    }
23887}
23888
23889impl<'de> serde::de::Deserialize<'de> for FieldBehavior {
23890    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
23891    where
23892        D: serde::Deserializer<'de>,
23893    {
23894        deserializer.deserialize_any(wkt::internal::EnumVisitor::<FieldBehavior>::new(
23895            ".google.api.FieldBehavior",
23896        ))
23897    }
23898}
23899
23900/// The launch stage as defined by [Google Cloud Platform
23901/// Launch Stages](https://cloud.google.com/terms/launch-stages).
23902///
23903/// # Working with unknown values
23904///
23905/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
23906/// additional enum variants at any time. Adding new variants is not considered
23907/// a breaking change. Applications should write their code in anticipation of:
23908///
23909/// - New values appearing in future releases of the client library, **and**
23910/// - New values received dynamically, without application changes.
23911///
23912/// Please consult the [Working with enums] section in the user guide for some
23913/// guidelines.
23914///
23915/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
23916#[derive(Clone, Debug, PartialEq)]
23917#[non_exhaustive]
23918pub enum LaunchStage {
23919    /// Do not use this default value.
23920    Unspecified,
23921    /// The feature is not yet implemented. Users can not use it.
23922    Unimplemented,
23923    /// Prelaunch features are hidden from users and are only visible internally.
23924    Prelaunch,
23925    /// Early Access features are limited to a closed group of testers. To use
23926    /// these features, you must sign up in advance and sign a Trusted Tester
23927    /// agreement (which includes confidentiality provisions). These features may
23928    /// be unstable, changed in backward-incompatible ways, and are not
23929    /// guaranteed to be released.
23930    EarlyAccess,
23931    /// Alpha is a limited availability test for releases before they are cleared
23932    /// for widespread use. By Alpha, all significant design issues are resolved
23933    /// and we are in the process of verifying functionality. Alpha customers
23934    /// need to apply for access, agree to applicable terms, and have their
23935    /// projects allowlisted. Alpha releases don't have to be feature complete,
23936    /// no SLAs are provided, and there are no technical support obligations, but
23937    /// they will be far enough along that customers can actually use them in
23938    /// test environments or for limited-use tests -- just like they would in
23939    /// normal production cases.
23940    Alpha,
23941    /// Beta is the point at which we are ready to open a release for any
23942    /// customer to use. There are no SLA or technical support obligations in a
23943    /// Beta release. Products will be complete from a feature perspective, but
23944    /// may have some open outstanding issues. Beta releases are suitable for
23945    /// limited production use cases.
23946    Beta,
23947    /// GA features are open to all developers and are considered stable and
23948    /// fully qualified for production use.
23949    Ga,
23950    /// Deprecated features are scheduled to be shut down and removed. For more
23951    /// information, see the "Deprecation Policy" section of our [Terms of
23952    /// Service](https://cloud.google.com/terms/)
23953    /// and the [Google Cloud Platform Subject to the Deprecation
23954    /// Policy](https://cloud.google.com/terms/deprecation) documentation.
23955    Deprecated,
23956    /// If set, the enum was initialized with an unknown value.
23957    ///
23958    /// Applications can examine the value using [LaunchStage::value] or
23959    /// [LaunchStage::name].
23960    UnknownValue(launch_stage::UnknownValue),
23961}
23962
23963#[doc(hidden)]
23964pub mod launch_stage {
23965    #[allow(unused_imports)]
23966    use super::*;
23967    #[derive(Clone, Debug, PartialEq)]
23968    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
23969}
23970
23971impl LaunchStage {
23972    /// Gets the enum value.
23973    ///
23974    /// Returns `None` if the enum contains an unknown value deserialized from
23975    /// the string representation of enums.
23976    pub fn value(&self) -> std::option::Option<i32> {
23977        match self {
23978            Self::Unspecified => std::option::Option::Some(0),
23979            Self::Unimplemented => std::option::Option::Some(6),
23980            Self::Prelaunch => std::option::Option::Some(7),
23981            Self::EarlyAccess => std::option::Option::Some(1),
23982            Self::Alpha => std::option::Option::Some(2),
23983            Self::Beta => std::option::Option::Some(3),
23984            Self::Ga => std::option::Option::Some(4),
23985            Self::Deprecated => std::option::Option::Some(5),
23986            Self::UnknownValue(u) => u.0.value(),
23987        }
23988    }
23989
23990    /// Gets the enum value as a string.
23991    ///
23992    /// Returns `None` if the enum contains an unknown value deserialized from
23993    /// the integer representation of enums.
23994    pub fn name(&self) -> std::option::Option<&str> {
23995        match self {
23996            Self::Unspecified => std::option::Option::Some("LAUNCH_STAGE_UNSPECIFIED"),
23997            Self::Unimplemented => std::option::Option::Some("UNIMPLEMENTED"),
23998            Self::Prelaunch => std::option::Option::Some("PRELAUNCH"),
23999            Self::EarlyAccess => std::option::Option::Some("EARLY_ACCESS"),
24000            Self::Alpha => std::option::Option::Some("ALPHA"),
24001            Self::Beta => std::option::Option::Some("BETA"),
24002            Self::Ga => std::option::Option::Some("GA"),
24003            Self::Deprecated => std::option::Option::Some("DEPRECATED"),
24004            Self::UnknownValue(u) => u.0.name(),
24005        }
24006    }
24007}
24008
24009impl std::default::Default for LaunchStage {
24010    fn default() -> Self {
24011        use std::convert::From;
24012        Self::from(0)
24013    }
24014}
24015
24016impl std::fmt::Display for LaunchStage {
24017    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
24018        wkt::internal::display_enum(f, self.name(), self.value())
24019    }
24020}
24021
24022impl std::convert::From<i32> for LaunchStage {
24023    fn from(value: i32) -> Self {
24024        match value {
24025            0 => Self::Unspecified,
24026            1 => Self::EarlyAccess,
24027            2 => Self::Alpha,
24028            3 => Self::Beta,
24029            4 => Self::Ga,
24030            5 => Self::Deprecated,
24031            6 => Self::Unimplemented,
24032            7 => Self::Prelaunch,
24033            _ => Self::UnknownValue(launch_stage::UnknownValue(
24034                wkt::internal::UnknownEnumValue::Integer(value),
24035            )),
24036        }
24037    }
24038}
24039
24040impl std::convert::From<&str> for LaunchStage {
24041    fn from(value: &str) -> Self {
24042        use std::string::ToString;
24043        match value {
24044            "LAUNCH_STAGE_UNSPECIFIED" => Self::Unspecified,
24045            "UNIMPLEMENTED" => Self::Unimplemented,
24046            "PRELAUNCH" => Self::Prelaunch,
24047            "EARLY_ACCESS" => Self::EarlyAccess,
24048            "ALPHA" => Self::Alpha,
24049            "BETA" => Self::Beta,
24050            "GA" => Self::Ga,
24051            "DEPRECATED" => Self::Deprecated,
24052            _ => Self::UnknownValue(launch_stage::UnknownValue(
24053                wkt::internal::UnknownEnumValue::String(value.to_string()),
24054            )),
24055        }
24056    }
24057}
24058
24059impl serde::ser::Serialize for LaunchStage {
24060    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
24061    where
24062        S: serde::Serializer,
24063    {
24064        match self {
24065            Self::Unspecified => serializer.serialize_i32(0),
24066            Self::Unimplemented => serializer.serialize_i32(6),
24067            Self::Prelaunch => serializer.serialize_i32(7),
24068            Self::EarlyAccess => serializer.serialize_i32(1),
24069            Self::Alpha => serializer.serialize_i32(2),
24070            Self::Beta => serializer.serialize_i32(3),
24071            Self::Ga => serializer.serialize_i32(4),
24072            Self::Deprecated => serializer.serialize_i32(5),
24073            Self::UnknownValue(u) => u.0.serialize(serializer),
24074        }
24075    }
24076}
24077
24078impl<'de> serde::de::Deserialize<'de> for LaunchStage {
24079    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
24080    where
24081        D: serde::Deserializer<'de>,
24082    {
24083        deserializer.deserialize_any(wkt::internal::EnumVisitor::<LaunchStage>::new(
24084            ".google.api.LaunchStage",
24085        ))
24086    }
24087}