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, Debug, 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
212/// Authentication rules for the service.
213///
214/// By default, if a method has any authentication requirements, every request
215/// must include a valid credential matching one of the requirements.
216/// It's an error to include more than one kind of credential in a single
217/// request.
218///
219/// If a method doesn't have any auth requirements, request credentials will be
220/// ignored.
221#[derive(Clone, Debug, Default, PartialEq)]
222#[non_exhaustive]
223pub struct AuthenticationRule {
224    /// Selects the methods to which this rule applies.
225    ///
226    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
227    /// details.
228    ///
229    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
230    pub selector: std::string::String,
231
232    /// The requirements for OAuth credentials.
233    pub oauth: std::option::Option<crate::model::OAuthRequirements>,
234
235    /// If true, the service accepts API keys without any other credential.
236    /// This flag only applies to HTTP and gRPC requests.
237    pub allow_without_credential: bool,
238
239    /// Requirements for additional authentication providers.
240    pub requirements: std::vec::Vec<crate::model::AuthRequirement>,
241
242    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
243}
244
245impl AuthenticationRule {
246    pub fn new() -> Self {
247        std::default::Default::default()
248    }
249
250    /// Sets the value of [selector][crate::model::AuthenticationRule::selector].
251    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
252        self.selector = v.into();
253        self
254    }
255
256    /// Sets the value of [oauth][crate::model::AuthenticationRule::oauth].
257    pub fn set_oauth<T>(mut self, v: T) -> Self
258    where
259        T: std::convert::Into<crate::model::OAuthRequirements>,
260    {
261        self.oauth = std::option::Option::Some(v.into());
262        self
263    }
264
265    /// Sets or clears the value of [oauth][crate::model::AuthenticationRule::oauth].
266    pub fn set_or_clear_oauth<T>(mut self, v: std::option::Option<T>) -> Self
267    where
268        T: std::convert::Into<crate::model::OAuthRequirements>,
269    {
270        self.oauth = v.map(|x| x.into());
271        self
272    }
273
274    /// Sets the value of [allow_without_credential][crate::model::AuthenticationRule::allow_without_credential].
275    pub fn set_allow_without_credential<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
276        self.allow_without_credential = v.into();
277        self
278    }
279
280    /// Sets the value of [requirements][crate::model::AuthenticationRule::requirements].
281    pub fn set_requirements<T, V>(mut self, v: T) -> Self
282    where
283        T: std::iter::IntoIterator<Item = V>,
284        V: std::convert::Into<crate::model::AuthRequirement>,
285    {
286        use std::iter::Iterator;
287        self.requirements = v.into_iter().map(|i| i.into()).collect();
288        self
289    }
290}
291
292impl wkt::message::Message for AuthenticationRule {
293    fn typename() -> &'static str {
294        "type.googleapis.com/google.api.AuthenticationRule"
295    }
296}
297
298#[doc(hidden)]
299impl<'de> serde::de::Deserialize<'de> for AuthenticationRule {
300    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
301    where
302        D: serde::Deserializer<'de>,
303    {
304        #[allow(non_camel_case_types)]
305        #[doc(hidden)]
306        #[derive(PartialEq, Eq, Hash)]
307        enum __FieldTag {
308            __selector,
309            __oauth,
310            __allow_without_credential,
311            __requirements,
312            Unknown(std::string::String),
313        }
314        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
315            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
316            where
317                D: serde::Deserializer<'de>,
318            {
319                struct Visitor;
320                impl<'de> serde::de::Visitor<'de> for Visitor {
321                    type Value = __FieldTag;
322                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
323                        formatter.write_str("a field name for AuthenticationRule")
324                    }
325                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
326                    where
327                        E: serde::de::Error,
328                    {
329                        use std::result::Result::Ok;
330                        use std::string::ToString;
331                        match value {
332                            "selector" => Ok(__FieldTag::__selector),
333                            "oauth" => Ok(__FieldTag::__oauth),
334                            "allowWithoutCredential" => Ok(__FieldTag::__allow_without_credential),
335                            "allow_without_credential" => {
336                                Ok(__FieldTag::__allow_without_credential)
337                            }
338                            "requirements" => Ok(__FieldTag::__requirements),
339                            _ => Ok(__FieldTag::Unknown(value.to_string())),
340                        }
341                    }
342                }
343                deserializer.deserialize_identifier(Visitor)
344            }
345        }
346        struct Visitor;
347        impl<'de> serde::de::Visitor<'de> for Visitor {
348            type Value = AuthenticationRule;
349            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
350                formatter.write_str("struct AuthenticationRule")
351            }
352            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
353            where
354                A: serde::de::MapAccess<'de>,
355            {
356                #[allow(unused_imports)]
357                use serde::de::Error;
358                use std::option::Option::Some;
359                let mut fields = std::collections::HashSet::new();
360                let mut result = Self::Value::new();
361                while let Some(tag) = map.next_key::<__FieldTag>()? {
362                    #[allow(clippy::match_single_binding)]
363                    match tag {
364                        __FieldTag::__selector => {
365                            if !fields.insert(__FieldTag::__selector) {
366                                return std::result::Result::Err(A::Error::duplicate_field(
367                                    "multiple values for selector",
368                                ));
369                            }
370                            result.selector = map
371                                .next_value::<std::option::Option<std::string::String>>()?
372                                .unwrap_or_default();
373                        }
374                        __FieldTag::__oauth => {
375                            if !fields.insert(__FieldTag::__oauth) {
376                                return std::result::Result::Err(A::Error::duplicate_field(
377                                    "multiple values for oauth",
378                                ));
379                            }
380                            result.oauth = map
381                                .next_value::<std::option::Option<crate::model::OAuthRequirements>>(
382                                )?;
383                        }
384                        __FieldTag::__allow_without_credential => {
385                            if !fields.insert(__FieldTag::__allow_without_credential) {
386                                return std::result::Result::Err(A::Error::duplicate_field(
387                                    "multiple values for allow_without_credential",
388                                ));
389                            }
390                            result.allow_without_credential = map
391                                .next_value::<std::option::Option<bool>>()?
392                                .unwrap_or_default();
393                        }
394                        __FieldTag::__requirements => {
395                            if !fields.insert(__FieldTag::__requirements) {
396                                return std::result::Result::Err(A::Error::duplicate_field(
397                                    "multiple values for requirements",
398                                ));
399                            }
400                            result.requirements =
401                                map.next_value::<std::option::Option<
402                                    std::vec::Vec<crate::model::AuthRequirement>,
403                                >>()?
404                                .unwrap_or_default();
405                        }
406                        __FieldTag::Unknown(key) => {
407                            let value = map.next_value::<serde_json::Value>()?;
408                            result._unknown_fields.insert(key, value);
409                        }
410                    }
411                }
412                std::result::Result::Ok(result)
413            }
414        }
415        deserializer.deserialize_any(Visitor)
416    }
417}
418
419#[doc(hidden)]
420impl serde::ser::Serialize for AuthenticationRule {
421    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
422    where
423        S: serde::ser::Serializer,
424    {
425        use serde::ser::SerializeMap;
426        #[allow(unused_imports)]
427        use std::option::Option::Some;
428        let mut state = serializer.serialize_map(std::option::Option::None)?;
429        if !self.selector.is_empty() {
430            state.serialize_entry("selector", &self.selector)?;
431        }
432        if self.oauth.is_some() {
433            state.serialize_entry("oauth", &self.oauth)?;
434        }
435        if !wkt::internal::is_default(&self.allow_without_credential) {
436            state.serialize_entry("allowWithoutCredential", &self.allow_without_credential)?;
437        }
438        if !self.requirements.is_empty() {
439            state.serialize_entry("requirements", &self.requirements)?;
440        }
441        if !self._unknown_fields.is_empty() {
442            for (key, value) in self._unknown_fields.iter() {
443                state.serialize_entry(key, &value)?;
444            }
445        }
446        state.end()
447    }
448}
449
450/// Specifies a location to extract JWT from an API request.
451#[derive(Clone, Debug, Default, PartialEq)]
452#[non_exhaustive]
453pub struct JwtLocation {
454    /// The value prefix. The value format is "value_prefix{token}"
455    /// Only applies to "in" header type. Must be empty for "in" query type.
456    /// If not empty, the header value has to match (case sensitive) this prefix.
457    /// If not matched, JWT will not be extracted. If matched, JWT will be
458    /// extracted after the prefix is removed.
459    ///
460    /// For example, for "Authorization: Bearer {JWT}",
461    /// value_prefix="Bearer " with a space at the end.
462    pub value_prefix: std::string::String,
463
464    pub r#in: std::option::Option<crate::model::jwt_location::In>,
465
466    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
467}
468
469impl JwtLocation {
470    pub fn new() -> Self {
471        std::default::Default::default()
472    }
473
474    /// Sets the value of [value_prefix][crate::model::JwtLocation::value_prefix].
475    pub fn set_value_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
476        self.value_prefix = v.into();
477        self
478    }
479
480    /// Sets the value of [r#in][crate::model::JwtLocation::in].
481    ///
482    /// Note that all the setters affecting `r#in` are mutually
483    /// exclusive.
484    pub fn set_in<T: std::convert::Into<std::option::Option<crate::model::jwt_location::In>>>(
485        mut self,
486        v: T,
487    ) -> Self {
488        self.r#in = v.into();
489        self
490    }
491
492    /// The value of [r#in][crate::model::JwtLocation::r#in]
493    /// if it holds a `Header`, `None` if the field is not set or
494    /// holds a different branch.
495    pub fn header(&self) -> std::option::Option<&std::string::String> {
496        #[allow(unreachable_patterns)]
497        self.r#in.as_ref().and_then(|v| match v {
498            crate::model::jwt_location::In::Header(v) => std::option::Option::Some(v),
499            _ => std::option::Option::None,
500        })
501    }
502
503    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
504    /// to hold a `Header`.
505    ///
506    /// Note that all the setters affecting `r#in` are
507    /// mutually exclusive.
508    pub fn set_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
509        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Header(v.into()));
510        self
511    }
512
513    /// The value of [r#in][crate::model::JwtLocation::r#in]
514    /// if it holds a `Query`, `None` if the field is not set or
515    /// holds a different branch.
516    pub fn query(&self) -> std::option::Option<&std::string::String> {
517        #[allow(unreachable_patterns)]
518        self.r#in.as_ref().and_then(|v| match v {
519            crate::model::jwt_location::In::Query(v) => std::option::Option::Some(v),
520            _ => std::option::Option::None,
521        })
522    }
523
524    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
525    /// to hold a `Query`.
526    ///
527    /// Note that all the setters affecting `r#in` are
528    /// mutually exclusive.
529    pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
530        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Query(v.into()));
531        self
532    }
533
534    /// The value of [r#in][crate::model::JwtLocation::r#in]
535    /// if it holds a `Cookie`, `None` if the field is not set or
536    /// holds a different branch.
537    pub fn cookie(&self) -> std::option::Option<&std::string::String> {
538        #[allow(unreachable_patterns)]
539        self.r#in.as_ref().and_then(|v| match v {
540            crate::model::jwt_location::In::Cookie(v) => std::option::Option::Some(v),
541            _ => std::option::Option::None,
542        })
543    }
544
545    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
546    /// to hold a `Cookie`.
547    ///
548    /// Note that all the setters affecting `r#in` are
549    /// mutually exclusive.
550    pub fn set_cookie<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
551        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Cookie(v.into()));
552        self
553    }
554}
555
556impl wkt::message::Message for JwtLocation {
557    fn typename() -> &'static str {
558        "type.googleapis.com/google.api.JwtLocation"
559    }
560}
561
562#[doc(hidden)]
563impl<'de> serde::de::Deserialize<'de> for JwtLocation {
564    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
565    where
566        D: serde::Deserializer<'de>,
567    {
568        #[allow(non_camel_case_types)]
569        #[doc(hidden)]
570        #[derive(PartialEq, Eq, Hash)]
571        enum __FieldTag {
572            __header,
573            __query,
574            __cookie,
575            __value_prefix,
576            Unknown(std::string::String),
577        }
578        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
579            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
580            where
581                D: serde::Deserializer<'de>,
582            {
583                struct Visitor;
584                impl<'de> serde::de::Visitor<'de> for Visitor {
585                    type Value = __FieldTag;
586                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
587                        formatter.write_str("a field name for JwtLocation")
588                    }
589                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
590                    where
591                        E: serde::de::Error,
592                    {
593                        use std::result::Result::Ok;
594                        use std::string::ToString;
595                        match value {
596                            "header" => Ok(__FieldTag::__header),
597                            "query" => Ok(__FieldTag::__query),
598                            "cookie" => Ok(__FieldTag::__cookie),
599                            "valuePrefix" => Ok(__FieldTag::__value_prefix),
600                            "value_prefix" => Ok(__FieldTag::__value_prefix),
601                            _ => Ok(__FieldTag::Unknown(value.to_string())),
602                        }
603                    }
604                }
605                deserializer.deserialize_identifier(Visitor)
606            }
607        }
608        struct Visitor;
609        impl<'de> serde::de::Visitor<'de> for Visitor {
610            type Value = JwtLocation;
611            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
612                formatter.write_str("struct JwtLocation")
613            }
614            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
615            where
616                A: serde::de::MapAccess<'de>,
617            {
618                #[allow(unused_imports)]
619                use serde::de::Error;
620                use std::option::Option::Some;
621                let mut fields = std::collections::HashSet::new();
622                let mut result = Self::Value::new();
623                while let Some(tag) = map.next_key::<__FieldTag>()? {
624                    #[allow(clippy::match_single_binding)]
625                    match tag {
626                        __FieldTag::__header => {
627                            if !fields.insert(__FieldTag::__header) {
628                                return std::result::Result::Err(A::Error::duplicate_field(
629                                    "multiple values for header",
630                                ));
631                            }
632                            if result.r#in.is_some() {
633                                return std::result::Result::Err(A::Error::duplicate_field(
634                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.header, latest field was header",
635                                ));
636                            }
637                            result.r#in =
638                                std::option::Option::Some(crate::model::jwt_location::In::Header(
639                                    map.next_value::<std::option::Option<std::string::String>>()?
640                                        .unwrap_or_default(),
641                                ));
642                        }
643                        __FieldTag::__query => {
644                            if !fields.insert(__FieldTag::__query) {
645                                return std::result::Result::Err(A::Error::duplicate_field(
646                                    "multiple values for query",
647                                ));
648                            }
649                            if result.r#in.is_some() {
650                                return std::result::Result::Err(A::Error::duplicate_field(
651                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.query, latest field was query",
652                                ));
653                            }
654                            result.r#in =
655                                std::option::Option::Some(crate::model::jwt_location::In::Query(
656                                    map.next_value::<std::option::Option<std::string::String>>()?
657                                        .unwrap_or_default(),
658                                ));
659                        }
660                        __FieldTag::__cookie => {
661                            if !fields.insert(__FieldTag::__cookie) {
662                                return std::result::Result::Err(A::Error::duplicate_field(
663                                    "multiple values for cookie",
664                                ));
665                            }
666                            if result.r#in.is_some() {
667                                return std::result::Result::Err(A::Error::duplicate_field(
668                                    "multiple values for `r#in`, a oneof with full ID .google.api.JwtLocation.cookie, latest field was cookie",
669                                ));
670                            }
671                            result.r#in =
672                                std::option::Option::Some(crate::model::jwt_location::In::Cookie(
673                                    map.next_value::<std::option::Option<std::string::String>>()?
674                                        .unwrap_or_default(),
675                                ));
676                        }
677                        __FieldTag::__value_prefix => {
678                            if !fields.insert(__FieldTag::__value_prefix) {
679                                return std::result::Result::Err(A::Error::duplicate_field(
680                                    "multiple values for value_prefix",
681                                ));
682                            }
683                            result.value_prefix = map
684                                .next_value::<std::option::Option<std::string::String>>()?
685                                .unwrap_or_default();
686                        }
687                        __FieldTag::Unknown(key) => {
688                            let value = map.next_value::<serde_json::Value>()?;
689                            result._unknown_fields.insert(key, value);
690                        }
691                    }
692                }
693                std::result::Result::Ok(result)
694            }
695        }
696        deserializer.deserialize_any(Visitor)
697    }
698}
699
700#[doc(hidden)]
701impl serde::ser::Serialize for JwtLocation {
702    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
703    where
704        S: serde::ser::Serializer,
705    {
706        use serde::ser::SerializeMap;
707        #[allow(unused_imports)]
708        use std::option::Option::Some;
709        let mut state = serializer.serialize_map(std::option::Option::None)?;
710        if let Some(value) = self.header() {
711            state.serialize_entry("header", value)?;
712        }
713        if let Some(value) = self.query() {
714            state.serialize_entry("query", value)?;
715        }
716        if let Some(value) = self.cookie() {
717            state.serialize_entry("cookie", value)?;
718        }
719        if !self.value_prefix.is_empty() {
720            state.serialize_entry("valuePrefix", &self.value_prefix)?;
721        }
722        if !self._unknown_fields.is_empty() {
723            for (key, value) in self._unknown_fields.iter() {
724                state.serialize_entry(key, &value)?;
725            }
726        }
727        state.end()
728    }
729}
730
731/// Defines additional types related to [JwtLocation].
732pub mod jwt_location {
733    #[allow(unused_imports)]
734    use super::*;
735
736    #[derive(Clone, Debug, PartialEq)]
737    #[non_exhaustive]
738    pub enum In {
739        /// Specifies HTTP header name to extract JWT token.
740        Header(std::string::String),
741        /// Specifies URL query parameter name to extract JWT token.
742        Query(std::string::String),
743        /// Specifies cookie name to extract JWT token.
744        Cookie(std::string::String),
745    }
746}
747
748/// Configuration for an authentication provider, including support for
749/// [JSON Web Token
750/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
751#[derive(Clone, Debug, Default, PartialEq)]
752#[non_exhaustive]
753pub struct AuthProvider {
754    /// The unique identifier of the auth provider. It will be referred to by
755    /// `AuthRequirement.provider_id`.
756    ///
757    /// Example: "bookstore_auth".
758    pub id: std::string::String,
759
760    /// Identifies the principal that issued the JWT. See
761    /// <https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1>
762    /// Usually a URL or an email address.
763    ///
764    /// Example: <https://securetoken.google.com>
765    /// Example: 1234567-compute@developer.gserviceaccount.com
766    pub issuer: std::string::String,
767
768    /// URL of the provider's public key set to validate signature of the JWT. See
769    /// [OpenID
770    /// Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
771    /// Optional if the key set document:
772    ///
773    /// - can be retrieved from
774    ///   [OpenID
775    ///   Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
776    ///   of the issuer.
777    /// - can be inferred from the email domain of the issuer (e.g. a Google
778    ///   service account).
779    ///
780    /// Example: <https://www.googleapis.com/oauth2/v1/certs>
781    pub jwks_uri: std::string::String,
782
783    /// The list of JWT
784    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
785    /// that are allowed to access. A JWT containing any of these audiences will
786    /// be accepted. When this setting is absent, JWTs with audiences:
787    ///
788    /// - "https://[service.name]/[google.protobuf.Api.name]"
789    /// - "https://[service.name]/"
790    ///   will be accepted.
791    ///   For example, if no audiences are in the setting, LibraryService API will
792    ///   accept JWTs with the following audiences:
793    ///
794    /// <https://library-example.googleapis.com/google.example.library.v1.LibraryService>
795    ///
796    /// - <https://library-example.googleapis.com/>
797    ///
798    /// Example:
799    ///
800    /// ```norust
801    /// audiences: bookstore_android.apps.googleusercontent.com,
802    ///            bookstore_web.apps.googleusercontent.com
803    /// ```
804    pub audiences: std::string::String,
805
806    /// Redirect URL if JWT token is required but not present or is expired.
807    /// Implement authorizationUrl of securityDefinitions in OpenAPI spec.
808    pub authorization_url: std::string::String,
809
810    /// Defines the locations to extract the JWT.  For now it is only used by the
811    /// Cloud Endpoints to store the OpenAPI extension [x-google-jwt-locations]
812    /// (<https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-jwt-locations>)
813    ///
814    /// JWT locations can be one of HTTP headers, URL query parameters or
815    /// cookies. The rule is that the first match wins.
816    ///
817    /// If not specified,  default to use following 3 locations:
818    ///
819    /// 1. Authorization: Bearer
820    /// 1. x-goog-iap-jwt-assertion
821    /// 1. access_token query parameter
822    ///
823    /// Default locations can be specified as followings:
824    /// jwt_locations:
825    ///
826    /// - header: Authorization
827    ///   value_prefix: "Bearer "
828    /// - header: x-goog-iap-jwt-assertion
829    /// - query: access_token
830    pub jwt_locations: std::vec::Vec<crate::model::JwtLocation>,
831
832    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
833}
834
835impl AuthProvider {
836    pub fn new() -> Self {
837        std::default::Default::default()
838    }
839
840    /// Sets the value of [id][crate::model::AuthProvider::id].
841    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
842        self.id = v.into();
843        self
844    }
845
846    /// Sets the value of [issuer][crate::model::AuthProvider::issuer].
847    pub fn set_issuer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
848        self.issuer = v.into();
849        self
850    }
851
852    /// Sets the value of [jwks_uri][crate::model::AuthProvider::jwks_uri].
853    pub fn set_jwks_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
854        self.jwks_uri = v.into();
855        self
856    }
857
858    /// Sets the value of [audiences][crate::model::AuthProvider::audiences].
859    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
860        self.audiences = v.into();
861        self
862    }
863
864    /// Sets the value of [authorization_url][crate::model::AuthProvider::authorization_url].
865    pub fn set_authorization_url<T: std::convert::Into<std::string::String>>(
866        mut self,
867        v: T,
868    ) -> Self {
869        self.authorization_url = v.into();
870        self
871    }
872
873    /// Sets the value of [jwt_locations][crate::model::AuthProvider::jwt_locations].
874    pub fn set_jwt_locations<T, V>(mut self, v: T) -> Self
875    where
876        T: std::iter::IntoIterator<Item = V>,
877        V: std::convert::Into<crate::model::JwtLocation>,
878    {
879        use std::iter::Iterator;
880        self.jwt_locations = v.into_iter().map(|i| i.into()).collect();
881        self
882    }
883}
884
885impl wkt::message::Message for AuthProvider {
886    fn typename() -> &'static str {
887        "type.googleapis.com/google.api.AuthProvider"
888    }
889}
890
891#[doc(hidden)]
892impl<'de> serde::de::Deserialize<'de> for AuthProvider {
893    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
894    where
895        D: serde::Deserializer<'de>,
896    {
897        #[allow(non_camel_case_types)]
898        #[doc(hidden)]
899        #[derive(PartialEq, Eq, Hash)]
900        enum __FieldTag {
901            __id,
902            __issuer,
903            __jwks_uri,
904            __audiences,
905            __authorization_url,
906            __jwt_locations,
907            Unknown(std::string::String),
908        }
909        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
910            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
911            where
912                D: serde::Deserializer<'de>,
913            {
914                struct Visitor;
915                impl<'de> serde::de::Visitor<'de> for Visitor {
916                    type Value = __FieldTag;
917                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
918                        formatter.write_str("a field name for AuthProvider")
919                    }
920                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
921                    where
922                        E: serde::de::Error,
923                    {
924                        use std::result::Result::Ok;
925                        use std::string::ToString;
926                        match value {
927                            "id" => Ok(__FieldTag::__id),
928                            "issuer" => Ok(__FieldTag::__issuer),
929                            "jwksUri" => Ok(__FieldTag::__jwks_uri),
930                            "jwks_uri" => Ok(__FieldTag::__jwks_uri),
931                            "audiences" => Ok(__FieldTag::__audiences),
932                            "authorizationUrl" => Ok(__FieldTag::__authorization_url),
933                            "authorization_url" => Ok(__FieldTag::__authorization_url),
934                            "jwtLocations" => Ok(__FieldTag::__jwt_locations),
935                            "jwt_locations" => Ok(__FieldTag::__jwt_locations),
936                            _ => Ok(__FieldTag::Unknown(value.to_string())),
937                        }
938                    }
939                }
940                deserializer.deserialize_identifier(Visitor)
941            }
942        }
943        struct Visitor;
944        impl<'de> serde::de::Visitor<'de> for Visitor {
945            type Value = AuthProvider;
946            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
947                formatter.write_str("struct AuthProvider")
948            }
949            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
950            where
951                A: serde::de::MapAccess<'de>,
952            {
953                #[allow(unused_imports)]
954                use serde::de::Error;
955                use std::option::Option::Some;
956                let mut fields = std::collections::HashSet::new();
957                let mut result = Self::Value::new();
958                while let Some(tag) = map.next_key::<__FieldTag>()? {
959                    #[allow(clippy::match_single_binding)]
960                    match tag {
961                        __FieldTag::__id => {
962                            if !fields.insert(__FieldTag::__id) {
963                                return std::result::Result::Err(A::Error::duplicate_field(
964                                    "multiple values for id",
965                                ));
966                            }
967                            result.id = map
968                                .next_value::<std::option::Option<std::string::String>>()?
969                                .unwrap_or_default();
970                        }
971                        __FieldTag::__issuer => {
972                            if !fields.insert(__FieldTag::__issuer) {
973                                return std::result::Result::Err(A::Error::duplicate_field(
974                                    "multiple values for issuer",
975                                ));
976                            }
977                            result.issuer = map
978                                .next_value::<std::option::Option<std::string::String>>()?
979                                .unwrap_or_default();
980                        }
981                        __FieldTag::__jwks_uri => {
982                            if !fields.insert(__FieldTag::__jwks_uri) {
983                                return std::result::Result::Err(A::Error::duplicate_field(
984                                    "multiple values for jwks_uri",
985                                ));
986                            }
987                            result.jwks_uri = map
988                                .next_value::<std::option::Option<std::string::String>>()?
989                                .unwrap_or_default();
990                        }
991                        __FieldTag::__audiences => {
992                            if !fields.insert(__FieldTag::__audiences) {
993                                return std::result::Result::Err(A::Error::duplicate_field(
994                                    "multiple values for audiences",
995                                ));
996                            }
997                            result.audiences = map
998                                .next_value::<std::option::Option<std::string::String>>()?
999                                .unwrap_or_default();
1000                        }
1001                        __FieldTag::__authorization_url => {
1002                            if !fields.insert(__FieldTag::__authorization_url) {
1003                                return std::result::Result::Err(A::Error::duplicate_field(
1004                                    "multiple values for authorization_url",
1005                                ));
1006                            }
1007                            result.authorization_url = map
1008                                .next_value::<std::option::Option<std::string::String>>()?
1009                                .unwrap_or_default();
1010                        }
1011                        __FieldTag::__jwt_locations => {
1012                            if !fields.insert(__FieldTag::__jwt_locations) {
1013                                return std::result::Result::Err(A::Error::duplicate_field(
1014                                    "multiple values for jwt_locations",
1015                                ));
1016                            }
1017                            result.jwt_locations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::JwtLocation>>>()?.unwrap_or_default();
1018                        }
1019                        __FieldTag::Unknown(key) => {
1020                            let value = map.next_value::<serde_json::Value>()?;
1021                            result._unknown_fields.insert(key, value);
1022                        }
1023                    }
1024                }
1025                std::result::Result::Ok(result)
1026            }
1027        }
1028        deserializer.deserialize_any(Visitor)
1029    }
1030}
1031
1032#[doc(hidden)]
1033impl serde::ser::Serialize for AuthProvider {
1034    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1035    where
1036        S: serde::ser::Serializer,
1037    {
1038        use serde::ser::SerializeMap;
1039        #[allow(unused_imports)]
1040        use std::option::Option::Some;
1041        let mut state = serializer.serialize_map(std::option::Option::None)?;
1042        if !self.id.is_empty() {
1043            state.serialize_entry("id", &self.id)?;
1044        }
1045        if !self.issuer.is_empty() {
1046            state.serialize_entry("issuer", &self.issuer)?;
1047        }
1048        if !self.jwks_uri.is_empty() {
1049            state.serialize_entry("jwksUri", &self.jwks_uri)?;
1050        }
1051        if !self.audiences.is_empty() {
1052            state.serialize_entry("audiences", &self.audiences)?;
1053        }
1054        if !self.authorization_url.is_empty() {
1055            state.serialize_entry("authorizationUrl", &self.authorization_url)?;
1056        }
1057        if !self.jwt_locations.is_empty() {
1058            state.serialize_entry("jwtLocations", &self.jwt_locations)?;
1059        }
1060        if !self._unknown_fields.is_empty() {
1061            for (key, value) in self._unknown_fields.iter() {
1062                state.serialize_entry(key, &value)?;
1063            }
1064        }
1065        state.end()
1066    }
1067}
1068
1069/// OAuth scopes are a way to define data and permissions on data. For example,
1070/// there are scopes defined for "Read-only access to Google Calendar" and
1071/// "Access to Cloud Platform". Users can consent to a scope for an application,
1072/// giving it permission to access that data on their behalf.
1073///
1074/// OAuth scope specifications should be fairly coarse grained; a user will need
1075/// to see and understand the text description of what your scope means.
1076///
1077/// In most cases: use one or at most two OAuth scopes for an entire family of
1078/// products. If your product has multiple APIs, you should probably be sharing
1079/// the OAuth scope across all of those APIs.
1080///
1081/// When you need finer grained OAuth consent screens: talk with your product
1082/// management about how developers will use them in practice.
1083///
1084/// Please note that even though each of the canonical scopes is enough for a
1085/// request to be accepted and passed to the backend, a request can still fail
1086/// due to the backend requiring additional scopes or permissions.
1087#[derive(Clone, Debug, Default, PartialEq)]
1088#[non_exhaustive]
1089pub struct OAuthRequirements {
1090    /// The list of publicly documented OAuth scopes that are allowed access. An
1091    /// OAuth token containing any of these scopes will be accepted.
1092    ///
1093    /// Example:
1094    ///
1095    /// ```norust
1096    ///  canonical_scopes: https://www.googleapis.com/auth/calendar,
1097    ///                    https://www.googleapis.com/auth/calendar.read
1098    /// ```
1099    pub canonical_scopes: std::string::String,
1100
1101    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1102}
1103
1104impl OAuthRequirements {
1105    pub fn new() -> Self {
1106        std::default::Default::default()
1107    }
1108
1109    /// Sets the value of [canonical_scopes][crate::model::OAuthRequirements::canonical_scopes].
1110    pub fn set_canonical_scopes<T: std::convert::Into<std::string::String>>(
1111        mut self,
1112        v: T,
1113    ) -> Self {
1114        self.canonical_scopes = v.into();
1115        self
1116    }
1117}
1118
1119impl wkt::message::Message for OAuthRequirements {
1120    fn typename() -> &'static str {
1121        "type.googleapis.com/google.api.OAuthRequirements"
1122    }
1123}
1124
1125#[doc(hidden)]
1126impl<'de> serde::de::Deserialize<'de> for OAuthRequirements {
1127    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1128    where
1129        D: serde::Deserializer<'de>,
1130    {
1131        #[allow(non_camel_case_types)]
1132        #[doc(hidden)]
1133        #[derive(PartialEq, Eq, Hash)]
1134        enum __FieldTag {
1135            __canonical_scopes,
1136            Unknown(std::string::String),
1137        }
1138        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1139            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1140            where
1141                D: serde::Deserializer<'de>,
1142            {
1143                struct Visitor;
1144                impl<'de> serde::de::Visitor<'de> for Visitor {
1145                    type Value = __FieldTag;
1146                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1147                        formatter.write_str("a field name for OAuthRequirements")
1148                    }
1149                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1150                    where
1151                        E: serde::de::Error,
1152                    {
1153                        use std::result::Result::Ok;
1154                        use std::string::ToString;
1155                        match value {
1156                            "canonicalScopes" => Ok(__FieldTag::__canonical_scopes),
1157                            "canonical_scopes" => Ok(__FieldTag::__canonical_scopes),
1158                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1159                        }
1160                    }
1161                }
1162                deserializer.deserialize_identifier(Visitor)
1163            }
1164        }
1165        struct Visitor;
1166        impl<'de> serde::de::Visitor<'de> for Visitor {
1167            type Value = OAuthRequirements;
1168            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1169                formatter.write_str("struct OAuthRequirements")
1170            }
1171            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1172            where
1173                A: serde::de::MapAccess<'de>,
1174            {
1175                #[allow(unused_imports)]
1176                use serde::de::Error;
1177                use std::option::Option::Some;
1178                let mut fields = std::collections::HashSet::new();
1179                let mut result = Self::Value::new();
1180                while let Some(tag) = map.next_key::<__FieldTag>()? {
1181                    #[allow(clippy::match_single_binding)]
1182                    match tag {
1183                        __FieldTag::__canonical_scopes => {
1184                            if !fields.insert(__FieldTag::__canonical_scopes) {
1185                                return std::result::Result::Err(A::Error::duplicate_field(
1186                                    "multiple values for canonical_scopes",
1187                                ));
1188                            }
1189                            result.canonical_scopes = map
1190                                .next_value::<std::option::Option<std::string::String>>()?
1191                                .unwrap_or_default();
1192                        }
1193                        __FieldTag::Unknown(key) => {
1194                            let value = map.next_value::<serde_json::Value>()?;
1195                            result._unknown_fields.insert(key, value);
1196                        }
1197                    }
1198                }
1199                std::result::Result::Ok(result)
1200            }
1201        }
1202        deserializer.deserialize_any(Visitor)
1203    }
1204}
1205
1206#[doc(hidden)]
1207impl serde::ser::Serialize for OAuthRequirements {
1208    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1209    where
1210        S: serde::ser::Serializer,
1211    {
1212        use serde::ser::SerializeMap;
1213        #[allow(unused_imports)]
1214        use std::option::Option::Some;
1215        let mut state = serializer.serialize_map(std::option::Option::None)?;
1216        if !self.canonical_scopes.is_empty() {
1217            state.serialize_entry("canonicalScopes", &self.canonical_scopes)?;
1218        }
1219        if !self._unknown_fields.is_empty() {
1220            for (key, value) in self._unknown_fields.iter() {
1221                state.serialize_entry(key, &value)?;
1222            }
1223        }
1224        state.end()
1225    }
1226}
1227
1228/// User-defined authentication requirements, including support for
1229/// [JSON Web Token
1230/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
1231#[derive(Clone, Debug, Default, PartialEq)]
1232#[non_exhaustive]
1233pub struct AuthRequirement {
1234    /// [id][google.api.AuthProvider.id] from authentication provider.
1235    ///
1236    /// Example:
1237    ///
1238    /// ```norust
1239    /// provider_id: bookstore_auth
1240    /// ```
1241    ///
1242    /// [google.api.AuthProvider.id]: crate::model::AuthProvider::id
1243    pub provider_id: std::string::String,
1244
1245    /// NOTE: This will be deprecated soon, once AuthProvider.audiences is
1246    /// implemented and accepted in all the runtime components.
1247    ///
1248    /// The list of JWT
1249    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
1250    /// that are allowed to access. A JWT containing any of these audiences will
1251    /// be accepted. When this setting is absent, only JWTs with audience
1252    /// "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
1253    /// will be accepted. For example, if no audiences are in the setting,
1254    /// LibraryService API will only accept JWTs with the following audience
1255    /// `https://library-example.googleapis.com/google.example.library.v1.LibraryService`.
1256    ///
1257    /// Example:
1258    ///
1259    /// ```norust
1260    /// audiences: bookstore_android.apps.googleusercontent.com,
1261    ///            bookstore_web.apps.googleusercontent.com
1262    /// ```
1263    ///
1264    /// [google.api.Service.name]: crate::model::Service::name
1265    /// [google.protobuf.Api.name]: wkt::Api::name
1266    pub audiences: std::string::String,
1267
1268    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1269}
1270
1271impl AuthRequirement {
1272    pub fn new() -> Self {
1273        std::default::Default::default()
1274    }
1275
1276    /// Sets the value of [provider_id][crate::model::AuthRequirement::provider_id].
1277    pub fn set_provider_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1278        self.provider_id = v.into();
1279        self
1280    }
1281
1282    /// Sets the value of [audiences][crate::model::AuthRequirement::audiences].
1283    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1284        self.audiences = v.into();
1285        self
1286    }
1287}
1288
1289impl wkt::message::Message for AuthRequirement {
1290    fn typename() -> &'static str {
1291        "type.googleapis.com/google.api.AuthRequirement"
1292    }
1293}
1294
1295#[doc(hidden)]
1296impl<'de> serde::de::Deserialize<'de> for AuthRequirement {
1297    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1298    where
1299        D: serde::Deserializer<'de>,
1300    {
1301        #[allow(non_camel_case_types)]
1302        #[doc(hidden)]
1303        #[derive(PartialEq, Eq, Hash)]
1304        enum __FieldTag {
1305            __provider_id,
1306            __audiences,
1307            Unknown(std::string::String),
1308        }
1309        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1310            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1311            where
1312                D: serde::Deserializer<'de>,
1313            {
1314                struct Visitor;
1315                impl<'de> serde::de::Visitor<'de> for Visitor {
1316                    type Value = __FieldTag;
1317                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1318                        formatter.write_str("a field name for AuthRequirement")
1319                    }
1320                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1321                    where
1322                        E: serde::de::Error,
1323                    {
1324                        use std::result::Result::Ok;
1325                        use std::string::ToString;
1326                        match value {
1327                            "providerId" => Ok(__FieldTag::__provider_id),
1328                            "provider_id" => Ok(__FieldTag::__provider_id),
1329                            "audiences" => Ok(__FieldTag::__audiences),
1330                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1331                        }
1332                    }
1333                }
1334                deserializer.deserialize_identifier(Visitor)
1335            }
1336        }
1337        struct Visitor;
1338        impl<'de> serde::de::Visitor<'de> for Visitor {
1339            type Value = AuthRequirement;
1340            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1341                formatter.write_str("struct AuthRequirement")
1342            }
1343            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1344            where
1345                A: serde::de::MapAccess<'de>,
1346            {
1347                #[allow(unused_imports)]
1348                use serde::de::Error;
1349                use std::option::Option::Some;
1350                let mut fields = std::collections::HashSet::new();
1351                let mut result = Self::Value::new();
1352                while let Some(tag) = map.next_key::<__FieldTag>()? {
1353                    #[allow(clippy::match_single_binding)]
1354                    match tag {
1355                        __FieldTag::__provider_id => {
1356                            if !fields.insert(__FieldTag::__provider_id) {
1357                                return std::result::Result::Err(A::Error::duplicate_field(
1358                                    "multiple values for provider_id",
1359                                ));
1360                            }
1361                            result.provider_id = map
1362                                .next_value::<std::option::Option<std::string::String>>()?
1363                                .unwrap_or_default();
1364                        }
1365                        __FieldTag::__audiences => {
1366                            if !fields.insert(__FieldTag::__audiences) {
1367                                return std::result::Result::Err(A::Error::duplicate_field(
1368                                    "multiple values for audiences",
1369                                ));
1370                            }
1371                            result.audiences = map
1372                                .next_value::<std::option::Option<std::string::String>>()?
1373                                .unwrap_or_default();
1374                        }
1375                        __FieldTag::Unknown(key) => {
1376                            let value = map.next_value::<serde_json::Value>()?;
1377                            result._unknown_fields.insert(key, value);
1378                        }
1379                    }
1380                }
1381                std::result::Result::Ok(result)
1382            }
1383        }
1384        deserializer.deserialize_any(Visitor)
1385    }
1386}
1387
1388#[doc(hidden)]
1389impl serde::ser::Serialize for AuthRequirement {
1390    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1391    where
1392        S: serde::ser::Serializer,
1393    {
1394        use serde::ser::SerializeMap;
1395        #[allow(unused_imports)]
1396        use std::option::Option::Some;
1397        let mut state = serializer.serialize_map(std::option::Option::None)?;
1398        if !self.provider_id.is_empty() {
1399            state.serialize_entry("providerId", &self.provider_id)?;
1400        }
1401        if !self.audiences.is_empty() {
1402            state.serialize_entry("audiences", &self.audiences)?;
1403        }
1404        if !self._unknown_fields.is_empty() {
1405            for (key, value) in self._unknown_fields.iter() {
1406                state.serialize_entry(key, &value)?;
1407            }
1408        }
1409        state.end()
1410    }
1411}
1412
1413/// `Backend` defines the backend configuration for a service.
1414#[derive(Clone, Debug, Default, PartialEq)]
1415#[non_exhaustive]
1416pub struct Backend {
1417    /// A list of API backend rules that apply to individual API methods.
1418    ///
1419    /// **NOTE:** All service configuration rules follow "last one wins" order.
1420    pub rules: std::vec::Vec<crate::model::BackendRule>,
1421
1422    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1423}
1424
1425impl Backend {
1426    pub fn new() -> Self {
1427        std::default::Default::default()
1428    }
1429
1430    /// Sets the value of [rules][crate::model::Backend::rules].
1431    pub fn set_rules<T, V>(mut self, v: T) -> Self
1432    where
1433        T: std::iter::IntoIterator<Item = V>,
1434        V: std::convert::Into<crate::model::BackendRule>,
1435    {
1436        use std::iter::Iterator;
1437        self.rules = v.into_iter().map(|i| i.into()).collect();
1438        self
1439    }
1440}
1441
1442impl wkt::message::Message for Backend {
1443    fn typename() -> &'static str {
1444        "type.googleapis.com/google.api.Backend"
1445    }
1446}
1447
1448#[doc(hidden)]
1449impl<'de> serde::de::Deserialize<'de> for Backend {
1450    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1451    where
1452        D: serde::Deserializer<'de>,
1453    {
1454        #[allow(non_camel_case_types)]
1455        #[doc(hidden)]
1456        #[derive(PartialEq, Eq, Hash)]
1457        enum __FieldTag {
1458            __rules,
1459            Unknown(std::string::String),
1460        }
1461        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1462            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1463            where
1464                D: serde::Deserializer<'de>,
1465            {
1466                struct Visitor;
1467                impl<'de> serde::de::Visitor<'de> for Visitor {
1468                    type Value = __FieldTag;
1469                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1470                        formatter.write_str("a field name for Backend")
1471                    }
1472                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1473                    where
1474                        E: serde::de::Error,
1475                    {
1476                        use std::result::Result::Ok;
1477                        use std::string::ToString;
1478                        match value {
1479                            "rules" => Ok(__FieldTag::__rules),
1480                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1481                        }
1482                    }
1483                }
1484                deserializer.deserialize_identifier(Visitor)
1485            }
1486        }
1487        struct Visitor;
1488        impl<'de> serde::de::Visitor<'de> for Visitor {
1489            type Value = Backend;
1490            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1491                formatter.write_str("struct Backend")
1492            }
1493            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1494            where
1495                A: serde::de::MapAccess<'de>,
1496            {
1497                #[allow(unused_imports)]
1498                use serde::de::Error;
1499                use std::option::Option::Some;
1500                let mut fields = std::collections::HashSet::new();
1501                let mut result = Self::Value::new();
1502                while let Some(tag) = map.next_key::<__FieldTag>()? {
1503                    #[allow(clippy::match_single_binding)]
1504                    match tag {
1505                        __FieldTag::__rules => {
1506                            if !fields.insert(__FieldTag::__rules) {
1507                                return std::result::Result::Err(A::Error::duplicate_field(
1508                                    "multiple values for rules",
1509                                ));
1510                            }
1511                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::BackendRule>>>()?.unwrap_or_default();
1512                        }
1513                        __FieldTag::Unknown(key) => {
1514                            let value = map.next_value::<serde_json::Value>()?;
1515                            result._unknown_fields.insert(key, value);
1516                        }
1517                    }
1518                }
1519                std::result::Result::Ok(result)
1520            }
1521        }
1522        deserializer.deserialize_any(Visitor)
1523    }
1524}
1525
1526#[doc(hidden)]
1527impl serde::ser::Serialize for Backend {
1528    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1529    where
1530        S: serde::ser::Serializer,
1531    {
1532        use serde::ser::SerializeMap;
1533        #[allow(unused_imports)]
1534        use std::option::Option::Some;
1535        let mut state = serializer.serialize_map(std::option::Option::None)?;
1536        if !self.rules.is_empty() {
1537            state.serialize_entry("rules", &self.rules)?;
1538        }
1539        if !self._unknown_fields.is_empty() {
1540            for (key, value) in self._unknown_fields.iter() {
1541                state.serialize_entry(key, &value)?;
1542            }
1543        }
1544        state.end()
1545    }
1546}
1547
1548/// A backend rule provides configuration for an individual API element.
1549#[derive(Clone, Debug, Default, PartialEq)]
1550#[non_exhaustive]
1551pub struct BackendRule {
1552    /// Selects the methods to which this rule applies.
1553    ///
1554    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
1555    /// details.
1556    ///
1557    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
1558    pub selector: std::string::String,
1559
1560    /// The address of the API backend.
1561    ///
1562    /// The scheme is used to determine the backend protocol and security.
1563    /// The following schemes are accepted:
1564    ///
1565    /// SCHEME        PROTOCOL    SECURITY
1566    /// http://       HTTP        None
1567    /// https://      HTTP        TLS
1568    /// grpc://       gRPC        None
1569    /// grpcs://      gRPC        TLS
1570    ///
1571    /// It is recommended to explicitly include a scheme. Leaving out the scheme
1572    /// may cause constrasting behaviors across platforms.
1573    ///
1574    /// If the port is unspecified, the default is:
1575    ///
1576    /// - 80 for schemes without TLS
1577    /// - 443 for schemes with TLS
1578    ///
1579    /// For HTTP backends, use [protocol][google.api.BackendRule.protocol]
1580    /// to specify the protocol version.
1581    ///
1582    /// [google.api.BackendRule.protocol]: crate::model::BackendRule::protocol
1583    pub address: std::string::String,
1584
1585    /// The number of seconds to wait for a response from a request. The default
1586    /// varies based on the request protocol and deployment environment.
1587    pub deadline: f64,
1588
1589    /// Deprecated, do not use.
1590    #[deprecated]
1591    pub min_deadline: f64,
1592
1593    /// The number of seconds to wait for the completion of a long running
1594    /// operation. The default is no deadline.
1595    pub operation_deadline: f64,
1596
1597    pub path_translation: crate::model::backend_rule::PathTranslation,
1598
1599    /// The protocol used for sending a request to the backend.
1600    /// The supported values are "http/1.1" and "h2".
1601    ///
1602    /// The default value is inferred from the scheme in the
1603    /// [address][google.api.BackendRule.address] field:
1604    ///
1605    /// SCHEME        PROTOCOL
1606    /// http://       http/1.1
1607    /// https://      http/1.1
1608    /// grpc://       h2
1609    /// grpcs://      h2
1610    ///
1611    /// For secure HTTP backends (https://) that support HTTP/2, set this field
1612    /// to "h2" for improved performance.
1613    ///
1614    /// Configuring this field to non-default values is only supported for secure
1615    /// HTTP backends. This field will be ignored for all other backends.
1616    ///
1617    /// See
1618    /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
1619    /// for more details on the supported values.
1620    ///
1621    /// [google.api.BackendRule.address]: crate::model::BackendRule::address
1622    pub protocol: std::string::String,
1623
1624    /// The map between request protocol and the backend address.
1625    pub overrides_by_request_protocol:
1626        std::collections::HashMap<std::string::String, crate::model::BackendRule>,
1627
1628    /// Authentication settings used by the backend.
1629    ///
1630    /// These are typically used to provide service management functionality to
1631    /// a backend served on a publicly-routable URL. The `authentication`
1632    /// details should match the authentication behavior used by the backend.
1633    ///
1634    /// For example, specifying `jwt_audience` implies that the backend expects
1635    /// authentication via a JWT.
1636    ///
1637    /// When authentication is unspecified, the resulting behavior is the same
1638    /// as `disable_auth` set to `true`.
1639    ///
1640    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
1641    /// JWT ID token.
1642    pub authentication: std::option::Option<crate::model::backend_rule::Authentication>,
1643
1644    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1645}
1646
1647impl BackendRule {
1648    pub fn new() -> Self {
1649        std::default::Default::default()
1650    }
1651
1652    /// Sets the value of [selector][crate::model::BackendRule::selector].
1653    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1654        self.selector = v.into();
1655        self
1656    }
1657
1658    /// Sets the value of [address][crate::model::BackendRule::address].
1659    pub fn set_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1660        self.address = v.into();
1661        self
1662    }
1663
1664    /// Sets the value of [deadline][crate::model::BackendRule::deadline].
1665    pub fn set_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1666        self.deadline = v.into();
1667        self
1668    }
1669
1670    /// Sets the value of [min_deadline][crate::model::BackendRule::min_deadline].
1671    #[deprecated]
1672    pub fn set_min_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1673        self.min_deadline = v.into();
1674        self
1675    }
1676
1677    /// Sets the value of [operation_deadline][crate::model::BackendRule::operation_deadline].
1678    pub fn set_operation_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1679        self.operation_deadline = v.into();
1680        self
1681    }
1682
1683    /// Sets the value of [path_translation][crate::model::BackendRule::path_translation].
1684    pub fn set_path_translation<
1685        T: std::convert::Into<crate::model::backend_rule::PathTranslation>,
1686    >(
1687        mut self,
1688        v: T,
1689    ) -> Self {
1690        self.path_translation = v.into();
1691        self
1692    }
1693
1694    /// Sets the value of [protocol][crate::model::BackendRule::protocol].
1695    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1696        self.protocol = v.into();
1697        self
1698    }
1699
1700    /// Sets the value of [overrides_by_request_protocol][crate::model::BackendRule::overrides_by_request_protocol].
1701    pub fn set_overrides_by_request_protocol<T, K, V>(mut self, v: T) -> Self
1702    where
1703        T: std::iter::IntoIterator<Item = (K, V)>,
1704        K: std::convert::Into<std::string::String>,
1705        V: std::convert::Into<crate::model::BackendRule>,
1706    {
1707        use std::iter::Iterator;
1708        self.overrides_by_request_protocol =
1709            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1710        self
1711    }
1712
1713    /// Sets the value of [authentication][crate::model::BackendRule::authentication].
1714    ///
1715    /// Note that all the setters affecting `authentication` are mutually
1716    /// exclusive.
1717    pub fn set_authentication<
1718        T: std::convert::Into<std::option::Option<crate::model::backend_rule::Authentication>>,
1719    >(
1720        mut self,
1721        v: T,
1722    ) -> Self {
1723        self.authentication = v.into();
1724        self
1725    }
1726
1727    /// The value of [authentication][crate::model::BackendRule::authentication]
1728    /// if it holds a `JwtAudience`, `None` if the field is not set or
1729    /// holds a different branch.
1730    pub fn jwt_audience(&self) -> std::option::Option<&std::string::String> {
1731        #[allow(unreachable_patterns)]
1732        self.authentication.as_ref().and_then(|v| match v {
1733            crate::model::backend_rule::Authentication::JwtAudience(v) => {
1734                std::option::Option::Some(v)
1735            }
1736            _ => std::option::Option::None,
1737        })
1738    }
1739
1740    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
1741    /// to hold a `JwtAudience`.
1742    ///
1743    /// Note that all the setters affecting `authentication` are
1744    /// mutually exclusive.
1745    pub fn set_jwt_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1746        self.authentication = std::option::Option::Some(
1747            crate::model::backend_rule::Authentication::JwtAudience(v.into()),
1748        );
1749        self
1750    }
1751
1752    /// The value of [authentication][crate::model::BackendRule::authentication]
1753    /// if it holds a `DisableAuth`, `None` if the field is not set or
1754    /// holds a different branch.
1755    pub fn disable_auth(&self) -> std::option::Option<&bool> {
1756        #[allow(unreachable_patterns)]
1757        self.authentication.as_ref().and_then(|v| match v {
1758            crate::model::backend_rule::Authentication::DisableAuth(v) => {
1759                std::option::Option::Some(v)
1760            }
1761            _ => std::option::Option::None,
1762        })
1763    }
1764
1765    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
1766    /// to hold a `DisableAuth`.
1767    ///
1768    /// Note that all the setters affecting `authentication` are
1769    /// mutually exclusive.
1770    pub fn set_disable_auth<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1771        self.authentication = std::option::Option::Some(
1772            crate::model::backend_rule::Authentication::DisableAuth(v.into()),
1773        );
1774        self
1775    }
1776}
1777
1778impl wkt::message::Message for BackendRule {
1779    fn typename() -> &'static str {
1780        "type.googleapis.com/google.api.BackendRule"
1781    }
1782}
1783
1784#[doc(hidden)]
1785impl<'de> serde::de::Deserialize<'de> for BackendRule {
1786    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1787    where
1788        D: serde::Deserializer<'de>,
1789    {
1790        #[allow(non_camel_case_types)]
1791        #[doc(hidden)]
1792        #[derive(PartialEq, Eq, Hash)]
1793        enum __FieldTag {
1794            __selector,
1795            __address,
1796            __deadline,
1797            __min_deadline,
1798            __operation_deadline,
1799            __path_translation,
1800            __jwt_audience,
1801            __disable_auth,
1802            __protocol,
1803            __overrides_by_request_protocol,
1804            Unknown(std::string::String),
1805        }
1806        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1807            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1808            where
1809                D: serde::Deserializer<'de>,
1810            {
1811                struct Visitor;
1812                impl<'de> serde::de::Visitor<'de> for Visitor {
1813                    type Value = __FieldTag;
1814                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1815                        formatter.write_str("a field name for BackendRule")
1816                    }
1817                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1818                    where
1819                        E: serde::de::Error,
1820                    {
1821                        use std::result::Result::Ok;
1822                        use std::string::ToString;
1823                        match value {
1824                            "selector" => Ok(__FieldTag::__selector),
1825                            "address" => Ok(__FieldTag::__address),
1826                            "deadline" => Ok(__FieldTag::__deadline),
1827                            "minDeadline" => Ok(__FieldTag::__min_deadline),
1828                            "min_deadline" => Ok(__FieldTag::__min_deadline),
1829                            "operationDeadline" => Ok(__FieldTag::__operation_deadline),
1830                            "operation_deadline" => Ok(__FieldTag::__operation_deadline),
1831                            "pathTranslation" => Ok(__FieldTag::__path_translation),
1832                            "path_translation" => Ok(__FieldTag::__path_translation),
1833                            "jwtAudience" => Ok(__FieldTag::__jwt_audience),
1834                            "jwt_audience" => Ok(__FieldTag::__jwt_audience),
1835                            "disableAuth" => Ok(__FieldTag::__disable_auth),
1836                            "disable_auth" => Ok(__FieldTag::__disable_auth),
1837                            "protocol" => Ok(__FieldTag::__protocol),
1838                            "overridesByRequestProtocol" => {
1839                                Ok(__FieldTag::__overrides_by_request_protocol)
1840                            }
1841                            "overrides_by_request_protocol" => {
1842                                Ok(__FieldTag::__overrides_by_request_protocol)
1843                            }
1844                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1845                        }
1846                    }
1847                }
1848                deserializer.deserialize_identifier(Visitor)
1849            }
1850        }
1851        struct Visitor;
1852        impl<'de> serde::de::Visitor<'de> for Visitor {
1853            type Value = BackendRule;
1854            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1855                formatter.write_str("struct BackendRule")
1856            }
1857            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1858            where
1859                A: serde::de::MapAccess<'de>,
1860            {
1861                #[allow(unused_imports)]
1862                use serde::de::Error;
1863                use std::option::Option::Some;
1864                let mut fields = std::collections::HashSet::new();
1865                let mut result = Self::Value::new();
1866                while let Some(tag) = map.next_key::<__FieldTag>()? {
1867                    #[allow(clippy::match_single_binding)]
1868                    match tag {
1869                        __FieldTag::__selector => {
1870                            if !fields.insert(__FieldTag::__selector) {
1871                                return std::result::Result::Err(A::Error::duplicate_field(
1872                                    "multiple values for selector",
1873                                ));
1874                            }
1875                            result.selector = map
1876                                .next_value::<std::option::Option<std::string::String>>()?
1877                                .unwrap_or_default();
1878                        }
1879                        __FieldTag::__address => {
1880                            if !fields.insert(__FieldTag::__address) {
1881                                return std::result::Result::Err(A::Error::duplicate_field(
1882                                    "multiple values for address",
1883                                ));
1884                            }
1885                            result.address = map
1886                                .next_value::<std::option::Option<std::string::String>>()?
1887                                .unwrap_or_default();
1888                        }
1889                        __FieldTag::__deadline => {
1890                            if !fields.insert(__FieldTag::__deadline) {
1891                                return std::result::Result::Err(A::Error::duplicate_field(
1892                                    "multiple values for deadline",
1893                                ));
1894                            }
1895                            struct __With(std::option::Option<f64>);
1896                            impl<'de> serde::de::Deserialize<'de> for __With {
1897                                fn deserialize<D>(
1898                                    deserializer: D,
1899                                ) -> std::result::Result<Self, D::Error>
1900                                where
1901                                    D: serde::de::Deserializer<'de>,
1902                                {
1903                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1904                                }
1905                            }
1906                            result.deadline = map.next_value::<__With>()?.0.unwrap_or_default();
1907                        }
1908                        __FieldTag::__min_deadline => {
1909                            if !fields.insert(__FieldTag::__min_deadline) {
1910                                return std::result::Result::Err(A::Error::duplicate_field(
1911                                    "multiple values for min_deadline",
1912                                ));
1913                            }
1914                            struct __With(std::option::Option<f64>);
1915                            impl<'de> serde::de::Deserialize<'de> for __With {
1916                                fn deserialize<D>(
1917                                    deserializer: D,
1918                                ) -> std::result::Result<Self, D::Error>
1919                                where
1920                                    D: serde::de::Deserializer<'de>,
1921                                {
1922                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1923                                }
1924                            }
1925                            result.min_deadline = map.next_value::<__With>()?.0.unwrap_or_default();
1926                        }
1927                        __FieldTag::__operation_deadline => {
1928                            if !fields.insert(__FieldTag::__operation_deadline) {
1929                                return std::result::Result::Err(A::Error::duplicate_field(
1930                                    "multiple values for operation_deadline",
1931                                ));
1932                            }
1933                            struct __With(std::option::Option<f64>);
1934                            impl<'de> serde::de::Deserialize<'de> for __With {
1935                                fn deserialize<D>(
1936                                    deserializer: D,
1937                                ) -> std::result::Result<Self, D::Error>
1938                                where
1939                                    D: serde::de::Deserializer<'de>,
1940                                {
1941                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1942                                }
1943                            }
1944                            result.operation_deadline =
1945                                map.next_value::<__With>()?.0.unwrap_or_default();
1946                        }
1947                        __FieldTag::__path_translation => {
1948                            if !fields.insert(__FieldTag::__path_translation) {
1949                                return std::result::Result::Err(A::Error::duplicate_field(
1950                                    "multiple values for path_translation",
1951                                ));
1952                            }
1953                            result.path_translation =
1954                                map.next_value::<std::option::Option<
1955                                    crate::model::backend_rule::PathTranslation,
1956                                >>()?
1957                                .unwrap_or_default();
1958                        }
1959                        __FieldTag::__jwt_audience => {
1960                            if !fields.insert(__FieldTag::__jwt_audience) {
1961                                return std::result::Result::Err(A::Error::duplicate_field(
1962                                    "multiple values for jwt_audience",
1963                                ));
1964                            }
1965                            if result.authentication.is_some() {
1966                                return std::result::Result::Err(A::Error::duplicate_field(
1967                                    "multiple values for `authentication`, a oneof with full ID .google.api.BackendRule.jwt_audience, latest field was jwtAudience",
1968                                ));
1969                            }
1970                            result.authentication = std::option::Option::Some(
1971                                crate::model::backend_rule::Authentication::JwtAudience(
1972                                    map.next_value::<std::option::Option<std::string::String>>()?
1973                                        .unwrap_or_default(),
1974                                ),
1975                            );
1976                        }
1977                        __FieldTag::__disable_auth => {
1978                            if !fields.insert(__FieldTag::__disable_auth) {
1979                                return std::result::Result::Err(A::Error::duplicate_field(
1980                                    "multiple values for disable_auth",
1981                                ));
1982                            }
1983                            if result.authentication.is_some() {
1984                                return std::result::Result::Err(A::Error::duplicate_field(
1985                                    "multiple values for `authentication`, a oneof with full ID .google.api.BackendRule.disable_auth, latest field was disableAuth",
1986                                ));
1987                            }
1988                            result.authentication = std::option::Option::Some(
1989                                crate::model::backend_rule::Authentication::DisableAuth(
1990                                    map.next_value::<std::option::Option<bool>>()?
1991                                        .unwrap_or_default(),
1992                                ),
1993                            );
1994                        }
1995                        __FieldTag::__protocol => {
1996                            if !fields.insert(__FieldTag::__protocol) {
1997                                return std::result::Result::Err(A::Error::duplicate_field(
1998                                    "multiple values for protocol",
1999                                ));
2000                            }
2001                            result.protocol = map
2002                                .next_value::<std::option::Option<std::string::String>>()?
2003                                .unwrap_or_default();
2004                        }
2005                        __FieldTag::__overrides_by_request_protocol => {
2006                            if !fields.insert(__FieldTag::__overrides_by_request_protocol) {
2007                                return std::result::Result::Err(A::Error::duplicate_field(
2008                                    "multiple values for overrides_by_request_protocol",
2009                                ));
2010                            }
2011                            result.overrides_by_request_protocol = map
2012                                .next_value::<std::option::Option<
2013                                    std::collections::HashMap<
2014                                        std::string::String,
2015                                        crate::model::BackendRule,
2016                                    >,
2017                                >>()?
2018                                .unwrap_or_default();
2019                        }
2020                        __FieldTag::Unknown(key) => {
2021                            let value = map.next_value::<serde_json::Value>()?;
2022                            result._unknown_fields.insert(key, value);
2023                        }
2024                    }
2025                }
2026                std::result::Result::Ok(result)
2027            }
2028        }
2029        deserializer.deserialize_any(Visitor)
2030    }
2031}
2032
2033#[doc(hidden)]
2034impl serde::ser::Serialize for BackendRule {
2035    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2036    where
2037        S: serde::ser::Serializer,
2038    {
2039        use serde::ser::SerializeMap;
2040        #[allow(unused_imports)]
2041        use std::option::Option::Some;
2042        let mut state = serializer.serialize_map(std::option::Option::None)?;
2043        if !self.selector.is_empty() {
2044            state.serialize_entry("selector", &self.selector)?;
2045        }
2046        if !self.address.is_empty() {
2047            state.serialize_entry("address", &self.address)?;
2048        }
2049        if !wkt::internal::is_default(&self.deadline) {
2050            struct __With<'a>(&'a f64);
2051            impl<'a> serde::ser::Serialize for __With<'a> {
2052                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2053                where
2054                    S: serde::ser::Serializer,
2055                {
2056                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2057                }
2058            }
2059            state.serialize_entry("deadline", &__With(&self.deadline))?;
2060        }
2061        if !wkt::internal::is_default(&self.min_deadline) {
2062            struct __With<'a>(&'a f64);
2063            impl<'a> serde::ser::Serialize for __With<'a> {
2064                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2065                where
2066                    S: serde::ser::Serializer,
2067                {
2068                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2069                }
2070            }
2071            state.serialize_entry("minDeadline", &__With(&self.min_deadline))?;
2072        }
2073        if !wkt::internal::is_default(&self.operation_deadline) {
2074            struct __With<'a>(&'a f64);
2075            impl<'a> serde::ser::Serialize for __With<'a> {
2076                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2077                where
2078                    S: serde::ser::Serializer,
2079                {
2080                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2081                }
2082            }
2083            state.serialize_entry("operationDeadline", &__With(&self.operation_deadline))?;
2084        }
2085        if !wkt::internal::is_default(&self.path_translation) {
2086            state.serialize_entry("pathTranslation", &self.path_translation)?;
2087        }
2088        if let Some(value) = self.jwt_audience() {
2089            state.serialize_entry("jwtAudience", value)?;
2090        }
2091        if let Some(value) = self.disable_auth() {
2092            state.serialize_entry("disableAuth", value)?;
2093        }
2094        if !self.protocol.is_empty() {
2095            state.serialize_entry("protocol", &self.protocol)?;
2096        }
2097        if !self.overrides_by_request_protocol.is_empty() {
2098            state.serialize_entry(
2099                "overridesByRequestProtocol",
2100                &self.overrides_by_request_protocol,
2101            )?;
2102        }
2103        if !self._unknown_fields.is_empty() {
2104            for (key, value) in self._unknown_fields.iter() {
2105                state.serialize_entry(key, &value)?;
2106            }
2107        }
2108        state.end()
2109    }
2110}
2111
2112/// Defines additional types related to [BackendRule].
2113pub mod backend_rule {
2114    #[allow(unused_imports)]
2115    use super::*;
2116
2117    /// Path Translation specifies how to combine the backend address with the
2118    /// request path in order to produce the appropriate forwarding URL for the
2119    /// request.
2120    ///
2121    /// Path Translation is applicable only to HTTP-based backends. Backends which
2122    /// do not accept requests over HTTP/HTTPS should leave `path_translation`
2123    /// unspecified.
2124    ///
2125    /// # Working with unknown values
2126    ///
2127    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2128    /// additional enum variants at any time. Adding new variants is not considered
2129    /// a breaking change. Applications should write their code in anticipation of:
2130    ///
2131    /// - New values appearing in future releases of the client library, **and**
2132    /// - New values received dynamically, without application changes.
2133    ///
2134    /// Please consult the [Working with enums] section in the user guide for some
2135    /// guidelines.
2136    ///
2137    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2138    #[derive(Clone, Debug, PartialEq)]
2139    #[non_exhaustive]
2140    pub enum PathTranslation {
2141        Unspecified,
2142        /// Use the backend address as-is, with no modification to the path. If the
2143        /// URL pattern contains variables, the variable names and values will be
2144        /// appended to the query string. If a query string parameter and a URL
2145        /// pattern variable have the same name, this may result in duplicate keys in
2146        /// the query string.
2147        ///
2148        /// # Examples
2149        ///
2150        /// Given the following operation config:
2151        ///
2152        /// ```norust
2153        /// Method path:        /api/company/{cid}/user/{uid}
2154        /// Backend address:    https://example.cloudfunctions.net/getUser
2155        /// ```
2156        ///
2157        /// Requests to the following request paths will call the backend at the
2158        /// translated path:
2159        ///
2160        /// ```norust
2161        /// Request path: /api/company/widgetworks/user/johndoe
2162        /// Translated:
2163        /// https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe
2164        ///
2165        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
2166        /// Translated:
2167        /// https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe
2168        /// ```
2169        ConstantAddress,
2170        /// The request path will be appended to the backend address.
2171        ///
2172        /// # Examples
2173        ///
2174        /// Given the following operation config:
2175        ///
2176        /// ```norust
2177        /// Method path:        /api/company/{cid}/user/{uid}
2178        /// Backend address:    https://example.appspot.com
2179        /// ```
2180        ///
2181        /// Requests to the following request paths will call the backend at the
2182        /// translated path:
2183        ///
2184        /// ```norust
2185        /// Request path: /api/company/widgetworks/user/johndoe
2186        /// Translated:
2187        /// https://example.appspot.com/api/company/widgetworks/user/johndoe
2188        ///
2189        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
2190        /// Translated:
2191        /// https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST
2192        /// ```
2193        AppendPathToAddress,
2194        /// If set, the enum was initialized with an unknown value.
2195        ///
2196        /// Applications can examine the value using [PathTranslation::value] or
2197        /// [PathTranslation::name].
2198        UnknownValue(path_translation::UnknownValue),
2199    }
2200
2201    #[doc(hidden)]
2202    pub mod path_translation {
2203        #[allow(unused_imports)]
2204        use super::*;
2205        #[derive(Clone, Debug, PartialEq)]
2206        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2207    }
2208
2209    impl PathTranslation {
2210        /// Gets the enum value.
2211        ///
2212        /// Returns `None` if the enum contains an unknown value deserialized from
2213        /// the string representation of enums.
2214        pub fn value(&self) -> std::option::Option<i32> {
2215            match self {
2216                Self::Unspecified => std::option::Option::Some(0),
2217                Self::ConstantAddress => std::option::Option::Some(1),
2218                Self::AppendPathToAddress => std::option::Option::Some(2),
2219                Self::UnknownValue(u) => u.0.value(),
2220            }
2221        }
2222
2223        /// Gets the enum value as a string.
2224        ///
2225        /// Returns `None` if the enum contains an unknown value deserialized from
2226        /// the integer representation of enums.
2227        pub fn name(&self) -> std::option::Option<&str> {
2228            match self {
2229                Self::Unspecified => std::option::Option::Some("PATH_TRANSLATION_UNSPECIFIED"),
2230                Self::ConstantAddress => std::option::Option::Some("CONSTANT_ADDRESS"),
2231                Self::AppendPathToAddress => std::option::Option::Some("APPEND_PATH_TO_ADDRESS"),
2232                Self::UnknownValue(u) => u.0.name(),
2233            }
2234        }
2235    }
2236
2237    impl std::default::Default for PathTranslation {
2238        fn default() -> Self {
2239            use std::convert::From;
2240            Self::from(0)
2241        }
2242    }
2243
2244    impl std::fmt::Display for PathTranslation {
2245        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2246            wkt::internal::display_enum(f, self.name(), self.value())
2247        }
2248    }
2249
2250    impl std::convert::From<i32> for PathTranslation {
2251        fn from(value: i32) -> Self {
2252            match value {
2253                0 => Self::Unspecified,
2254                1 => Self::ConstantAddress,
2255                2 => Self::AppendPathToAddress,
2256                _ => Self::UnknownValue(path_translation::UnknownValue(
2257                    wkt::internal::UnknownEnumValue::Integer(value),
2258                )),
2259            }
2260        }
2261    }
2262
2263    impl std::convert::From<&str> for PathTranslation {
2264        fn from(value: &str) -> Self {
2265            use std::string::ToString;
2266            match value {
2267                "PATH_TRANSLATION_UNSPECIFIED" => Self::Unspecified,
2268                "CONSTANT_ADDRESS" => Self::ConstantAddress,
2269                "APPEND_PATH_TO_ADDRESS" => Self::AppendPathToAddress,
2270                _ => Self::UnknownValue(path_translation::UnknownValue(
2271                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2272                )),
2273            }
2274        }
2275    }
2276
2277    impl serde::ser::Serialize for PathTranslation {
2278        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2279        where
2280            S: serde::Serializer,
2281        {
2282            match self {
2283                Self::Unspecified => serializer.serialize_i32(0),
2284                Self::ConstantAddress => serializer.serialize_i32(1),
2285                Self::AppendPathToAddress => serializer.serialize_i32(2),
2286                Self::UnknownValue(u) => u.0.serialize(serializer),
2287            }
2288        }
2289    }
2290
2291    impl<'de> serde::de::Deserialize<'de> for PathTranslation {
2292        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2293        where
2294            D: serde::Deserializer<'de>,
2295        {
2296            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PathTranslation>::new(
2297                ".google.api.BackendRule.PathTranslation",
2298            ))
2299        }
2300    }
2301
2302    /// Authentication settings used by the backend.
2303    ///
2304    /// These are typically used to provide service management functionality to
2305    /// a backend served on a publicly-routable URL. The `authentication`
2306    /// details should match the authentication behavior used by the backend.
2307    ///
2308    /// For example, specifying `jwt_audience` implies that the backend expects
2309    /// authentication via a JWT.
2310    ///
2311    /// When authentication is unspecified, the resulting behavior is the same
2312    /// as `disable_auth` set to `true`.
2313    ///
2314    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
2315    /// JWT ID token.
2316    #[derive(Clone, Debug, PartialEq)]
2317    #[non_exhaustive]
2318    pub enum Authentication {
2319        /// The JWT audience is used when generating a JWT ID token for the backend.
2320        /// This ID token will be added in the HTTP "authorization" header, and sent
2321        /// to the backend.
2322        JwtAudience(std::string::String),
2323        /// When disable_auth is true, a JWT ID token won't be generated and the
2324        /// original "Authorization" HTTP header will be preserved. If the header is
2325        /// used to carry the original token and is expected by the backend, this
2326        /// field must be set to true to preserve the header.
2327        DisableAuth(bool),
2328    }
2329}
2330
2331/// Billing related configuration of the service.
2332///
2333/// The following example shows how to configure monitored resources and metrics
2334/// for billing, `consumer_destinations` is the only supported destination and
2335/// the monitored resources need at least one label key
2336/// `cloud.googleapis.com/location` to indicate the location of the billing
2337/// usage, using different monitored resources between monitoring and billing is
2338/// recommended so they can be evolved independently:
2339///
2340/// ```norust
2341/// monitored_resources:
2342/// - type: library.googleapis.com/billing_branch
2343///   labels:
2344///   - key: cloud.googleapis.com/location
2345///     description: |
2346///       Predefined label to support billing location restriction.
2347///   - key: city
2348///     description: |
2349///       Custom label to define the city where the library branch is located
2350///       in.
2351///   - key: name
2352///     description: Custom label to define the name of the library branch.
2353/// metrics:
2354/// - name: library.googleapis.com/book/borrowed_count
2355///   metric_kind: DELTA
2356///   value_type: INT64
2357///   unit: "1"
2358/// billing:
2359///   consumer_destinations:
2360///   - monitored_resource: library.googleapis.com/billing_branch
2361///     metrics:
2362///     - library.googleapis.com/book/borrowed_count
2363/// ```
2364#[derive(Clone, Debug, Default, PartialEq)]
2365#[non_exhaustive]
2366pub struct Billing {
2367    /// Billing configurations for sending metrics to the consumer project.
2368    /// There can be multiple consumer destinations per service, each one must have
2369    /// a different monitored resource type. A metric can be used in at most
2370    /// one consumer destination.
2371    pub consumer_destinations: std::vec::Vec<crate::model::billing::BillingDestination>,
2372
2373    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2374}
2375
2376impl Billing {
2377    pub fn new() -> Self {
2378        std::default::Default::default()
2379    }
2380
2381    /// Sets the value of [consumer_destinations][crate::model::Billing::consumer_destinations].
2382    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
2383    where
2384        T: std::iter::IntoIterator<Item = V>,
2385        V: std::convert::Into<crate::model::billing::BillingDestination>,
2386    {
2387        use std::iter::Iterator;
2388        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
2389        self
2390    }
2391}
2392
2393impl wkt::message::Message for Billing {
2394    fn typename() -> &'static str {
2395        "type.googleapis.com/google.api.Billing"
2396    }
2397}
2398
2399#[doc(hidden)]
2400impl<'de> serde::de::Deserialize<'de> for Billing {
2401    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2402    where
2403        D: serde::Deserializer<'de>,
2404    {
2405        #[allow(non_camel_case_types)]
2406        #[doc(hidden)]
2407        #[derive(PartialEq, Eq, Hash)]
2408        enum __FieldTag {
2409            __consumer_destinations,
2410            Unknown(std::string::String),
2411        }
2412        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2413            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2414            where
2415                D: serde::Deserializer<'de>,
2416            {
2417                struct Visitor;
2418                impl<'de> serde::de::Visitor<'de> for Visitor {
2419                    type Value = __FieldTag;
2420                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2421                        formatter.write_str("a field name for Billing")
2422                    }
2423                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2424                    where
2425                        E: serde::de::Error,
2426                    {
2427                        use std::result::Result::Ok;
2428                        use std::string::ToString;
2429                        match value {
2430                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
2431                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
2432                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2433                        }
2434                    }
2435                }
2436                deserializer.deserialize_identifier(Visitor)
2437            }
2438        }
2439        struct Visitor;
2440        impl<'de> serde::de::Visitor<'de> for Visitor {
2441            type Value = Billing;
2442            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2443                formatter.write_str("struct Billing")
2444            }
2445            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2446            where
2447                A: serde::de::MapAccess<'de>,
2448            {
2449                #[allow(unused_imports)]
2450                use serde::de::Error;
2451                use std::option::Option::Some;
2452                let mut fields = std::collections::HashSet::new();
2453                let mut result = Self::Value::new();
2454                while let Some(tag) = map.next_key::<__FieldTag>()? {
2455                    #[allow(clippy::match_single_binding)]
2456                    match tag {
2457                        __FieldTag::__consumer_destinations => {
2458                            if !fields.insert(__FieldTag::__consumer_destinations) {
2459                                return std::result::Result::Err(A::Error::duplicate_field(
2460                                    "multiple values for consumer_destinations",
2461                                ));
2462                            }
2463                            result.consumer_destinations = map
2464                                .next_value::<std::option::Option<
2465                                    std::vec::Vec<crate::model::billing::BillingDestination>,
2466                                >>()?
2467                                .unwrap_or_default();
2468                        }
2469                        __FieldTag::Unknown(key) => {
2470                            let value = map.next_value::<serde_json::Value>()?;
2471                            result._unknown_fields.insert(key, value);
2472                        }
2473                    }
2474                }
2475                std::result::Result::Ok(result)
2476            }
2477        }
2478        deserializer.deserialize_any(Visitor)
2479    }
2480}
2481
2482#[doc(hidden)]
2483impl serde::ser::Serialize for Billing {
2484    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2485    where
2486        S: serde::ser::Serializer,
2487    {
2488        use serde::ser::SerializeMap;
2489        #[allow(unused_imports)]
2490        use std::option::Option::Some;
2491        let mut state = serializer.serialize_map(std::option::Option::None)?;
2492        if !self.consumer_destinations.is_empty() {
2493            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
2494        }
2495        if !self._unknown_fields.is_empty() {
2496            for (key, value) in self._unknown_fields.iter() {
2497                state.serialize_entry(key, &value)?;
2498            }
2499        }
2500        state.end()
2501    }
2502}
2503
2504/// Defines additional types related to [Billing].
2505pub mod billing {
2506    #[allow(unused_imports)]
2507    use super::*;
2508
2509    /// Configuration of a specific billing destination (Currently only support
2510    /// bill against consumer project).
2511    #[derive(Clone, Debug, Default, PartialEq)]
2512    #[non_exhaustive]
2513    pub struct BillingDestination {
2514        /// The monitored resource type. The type must be defined in
2515        /// [Service.monitored_resources][google.api.Service.monitored_resources]
2516        /// section.
2517        ///
2518        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
2519        pub monitored_resource: std::string::String,
2520
2521        /// Names of the metrics to report to this billing destination.
2522        /// Each name must be defined in
2523        /// [Service.metrics][google.api.Service.metrics] section.
2524        ///
2525        /// [google.api.Service.metrics]: crate::model::Service::metrics
2526        pub metrics: std::vec::Vec<std::string::String>,
2527
2528        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2529    }
2530
2531    impl BillingDestination {
2532        pub fn new() -> Self {
2533            std::default::Default::default()
2534        }
2535
2536        /// Sets the value of [monitored_resource][crate::model::billing::BillingDestination::monitored_resource].
2537        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
2538            mut self,
2539            v: T,
2540        ) -> Self {
2541            self.monitored_resource = v.into();
2542            self
2543        }
2544
2545        /// Sets the value of [metrics][crate::model::billing::BillingDestination::metrics].
2546        pub fn set_metrics<T, V>(mut self, v: T) -> Self
2547        where
2548            T: std::iter::IntoIterator<Item = V>,
2549            V: std::convert::Into<std::string::String>,
2550        {
2551            use std::iter::Iterator;
2552            self.metrics = v.into_iter().map(|i| i.into()).collect();
2553            self
2554        }
2555    }
2556
2557    impl wkt::message::Message for BillingDestination {
2558        fn typename() -> &'static str {
2559            "type.googleapis.com/google.api.Billing.BillingDestination"
2560        }
2561    }
2562
2563    #[doc(hidden)]
2564    impl<'de> serde::de::Deserialize<'de> for BillingDestination {
2565        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2566        where
2567            D: serde::Deserializer<'de>,
2568        {
2569            #[allow(non_camel_case_types)]
2570            #[doc(hidden)]
2571            #[derive(PartialEq, Eq, Hash)]
2572            enum __FieldTag {
2573                __monitored_resource,
2574                __metrics,
2575                Unknown(std::string::String),
2576            }
2577            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2578                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2579                where
2580                    D: serde::Deserializer<'de>,
2581                {
2582                    struct Visitor;
2583                    impl<'de> serde::de::Visitor<'de> for Visitor {
2584                        type Value = __FieldTag;
2585                        fn expecting(
2586                            &self,
2587                            formatter: &mut std::fmt::Formatter,
2588                        ) -> std::fmt::Result {
2589                            formatter.write_str("a field name for BillingDestination")
2590                        }
2591                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2592                        where
2593                            E: serde::de::Error,
2594                        {
2595                            use std::result::Result::Ok;
2596                            use std::string::ToString;
2597                            match value {
2598                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
2599                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
2600                                "metrics" => Ok(__FieldTag::__metrics),
2601                                _ => Ok(__FieldTag::Unknown(value.to_string())),
2602                            }
2603                        }
2604                    }
2605                    deserializer.deserialize_identifier(Visitor)
2606                }
2607            }
2608            struct Visitor;
2609            impl<'de> serde::de::Visitor<'de> for Visitor {
2610                type Value = BillingDestination;
2611                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2612                    formatter.write_str("struct BillingDestination")
2613                }
2614                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2615                where
2616                    A: serde::de::MapAccess<'de>,
2617                {
2618                    #[allow(unused_imports)]
2619                    use serde::de::Error;
2620                    use std::option::Option::Some;
2621                    let mut fields = std::collections::HashSet::new();
2622                    let mut result = Self::Value::new();
2623                    while let Some(tag) = map.next_key::<__FieldTag>()? {
2624                        #[allow(clippy::match_single_binding)]
2625                        match tag {
2626                            __FieldTag::__monitored_resource => {
2627                                if !fields.insert(__FieldTag::__monitored_resource) {
2628                                    return std::result::Result::Err(A::Error::duplicate_field(
2629                                        "multiple values for monitored_resource",
2630                                    ));
2631                                }
2632                                result.monitored_resource = map
2633                                    .next_value::<std::option::Option<std::string::String>>()?
2634                                    .unwrap_or_default();
2635                            }
2636                            __FieldTag::__metrics => {
2637                                if !fields.insert(__FieldTag::__metrics) {
2638                                    return std::result::Result::Err(A::Error::duplicate_field(
2639                                        "multiple values for metrics",
2640                                    ));
2641                                }
2642                                result.metrics = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
2643                            }
2644                            __FieldTag::Unknown(key) => {
2645                                let value = map.next_value::<serde_json::Value>()?;
2646                                result._unknown_fields.insert(key, value);
2647                            }
2648                        }
2649                    }
2650                    std::result::Result::Ok(result)
2651                }
2652            }
2653            deserializer.deserialize_any(Visitor)
2654        }
2655    }
2656
2657    #[doc(hidden)]
2658    impl serde::ser::Serialize for BillingDestination {
2659        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2660        where
2661            S: serde::ser::Serializer,
2662        {
2663            use serde::ser::SerializeMap;
2664            #[allow(unused_imports)]
2665            use std::option::Option::Some;
2666            let mut state = serializer.serialize_map(std::option::Option::None)?;
2667            if !self.monitored_resource.is_empty() {
2668                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
2669            }
2670            if !self.metrics.is_empty() {
2671                state.serialize_entry("metrics", &self.metrics)?;
2672            }
2673            if !self._unknown_fields.is_empty() {
2674                for (key, value) in self._unknown_fields.iter() {
2675                    state.serialize_entry(key, &value)?;
2676                }
2677            }
2678            state.end()
2679        }
2680    }
2681}
2682
2683/// Required information for every language.
2684#[derive(Clone, Debug, Default, PartialEq)]
2685#[non_exhaustive]
2686pub struct CommonLanguageSettings {
2687    /// Link to automatically generated reference documentation.  Example:
2688    /// <https://cloud.google.com/nodejs/docs/reference/asset/latest>
2689    #[deprecated]
2690    pub reference_docs_uri: std::string::String,
2691
2692    /// The destination where API teams want this client library to be published.
2693    pub destinations: std::vec::Vec<crate::model::ClientLibraryDestination>,
2694
2695    /// Configuration for which RPCs should be generated in the GAPIC client.
2696    pub selective_gapic_generation: std::option::Option<crate::model::SelectiveGapicGeneration>,
2697
2698    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2699}
2700
2701impl CommonLanguageSettings {
2702    pub fn new() -> Self {
2703        std::default::Default::default()
2704    }
2705
2706    /// Sets the value of [reference_docs_uri][crate::model::CommonLanguageSettings::reference_docs_uri].
2707    #[deprecated]
2708    pub fn set_reference_docs_uri<T: std::convert::Into<std::string::String>>(
2709        mut self,
2710        v: T,
2711    ) -> Self {
2712        self.reference_docs_uri = v.into();
2713        self
2714    }
2715
2716    /// Sets the value of [destinations][crate::model::CommonLanguageSettings::destinations].
2717    pub fn set_destinations<T, V>(mut self, v: T) -> Self
2718    where
2719        T: std::iter::IntoIterator<Item = V>,
2720        V: std::convert::Into<crate::model::ClientLibraryDestination>,
2721    {
2722        use std::iter::Iterator;
2723        self.destinations = v.into_iter().map(|i| i.into()).collect();
2724        self
2725    }
2726
2727    /// Sets the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
2728    pub fn set_selective_gapic_generation<T>(mut self, v: T) -> Self
2729    where
2730        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
2731    {
2732        self.selective_gapic_generation = std::option::Option::Some(v.into());
2733        self
2734    }
2735
2736    /// Sets or clears the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
2737    pub fn set_or_clear_selective_gapic_generation<T>(mut self, v: std::option::Option<T>) -> Self
2738    where
2739        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
2740    {
2741        self.selective_gapic_generation = v.map(|x| x.into());
2742        self
2743    }
2744}
2745
2746impl wkt::message::Message for CommonLanguageSettings {
2747    fn typename() -> &'static str {
2748        "type.googleapis.com/google.api.CommonLanguageSettings"
2749    }
2750}
2751
2752#[doc(hidden)]
2753impl<'de> serde::de::Deserialize<'de> for CommonLanguageSettings {
2754    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2755    where
2756        D: serde::Deserializer<'de>,
2757    {
2758        #[allow(non_camel_case_types)]
2759        #[doc(hidden)]
2760        #[derive(PartialEq, Eq, Hash)]
2761        enum __FieldTag {
2762            __reference_docs_uri,
2763            __destinations,
2764            __selective_gapic_generation,
2765            Unknown(std::string::String),
2766        }
2767        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2768            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2769            where
2770                D: serde::Deserializer<'de>,
2771            {
2772                struct Visitor;
2773                impl<'de> serde::de::Visitor<'de> for Visitor {
2774                    type Value = __FieldTag;
2775                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2776                        formatter.write_str("a field name for CommonLanguageSettings")
2777                    }
2778                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2779                    where
2780                        E: serde::de::Error,
2781                    {
2782                        use std::result::Result::Ok;
2783                        use std::string::ToString;
2784                        match value {
2785                            "referenceDocsUri" => Ok(__FieldTag::__reference_docs_uri),
2786                            "reference_docs_uri" => Ok(__FieldTag::__reference_docs_uri),
2787                            "destinations" => Ok(__FieldTag::__destinations),
2788                            "selectiveGapicGeneration" => {
2789                                Ok(__FieldTag::__selective_gapic_generation)
2790                            }
2791                            "selective_gapic_generation" => {
2792                                Ok(__FieldTag::__selective_gapic_generation)
2793                            }
2794                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2795                        }
2796                    }
2797                }
2798                deserializer.deserialize_identifier(Visitor)
2799            }
2800        }
2801        struct Visitor;
2802        impl<'de> serde::de::Visitor<'de> for Visitor {
2803            type Value = CommonLanguageSettings;
2804            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2805                formatter.write_str("struct CommonLanguageSettings")
2806            }
2807            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2808            where
2809                A: serde::de::MapAccess<'de>,
2810            {
2811                #[allow(unused_imports)]
2812                use serde::de::Error;
2813                use std::option::Option::Some;
2814                let mut fields = std::collections::HashSet::new();
2815                let mut result = Self::Value::new();
2816                while let Some(tag) = map.next_key::<__FieldTag>()? {
2817                    #[allow(clippy::match_single_binding)]
2818                    match tag {
2819                        __FieldTag::__reference_docs_uri => {
2820                            if !fields.insert(__FieldTag::__reference_docs_uri) {
2821                                return std::result::Result::Err(A::Error::duplicate_field(
2822                                    "multiple values for reference_docs_uri",
2823                                ));
2824                            }
2825                            result.reference_docs_uri = map
2826                                .next_value::<std::option::Option<std::string::String>>()?
2827                                .unwrap_or_default();
2828                        }
2829                        __FieldTag::__destinations => {
2830                            if !fields.insert(__FieldTag::__destinations) {
2831                                return std::result::Result::Err(A::Error::duplicate_field(
2832                                    "multiple values for destinations",
2833                                ));
2834                            }
2835                            result.destinations = map
2836                                .next_value::<std::option::Option<
2837                                    std::vec::Vec<crate::model::ClientLibraryDestination>,
2838                                >>()?
2839                                .unwrap_or_default();
2840                        }
2841                        __FieldTag::__selective_gapic_generation => {
2842                            if !fields.insert(__FieldTag::__selective_gapic_generation) {
2843                                return std::result::Result::Err(A::Error::duplicate_field(
2844                                    "multiple values for selective_gapic_generation",
2845                                ));
2846                            }
2847                            result.selective_gapic_generation = map.next_value::<std::option::Option<crate::model::SelectiveGapicGeneration>>()?
2848                                ;
2849                        }
2850                        __FieldTag::Unknown(key) => {
2851                            let value = map.next_value::<serde_json::Value>()?;
2852                            result._unknown_fields.insert(key, value);
2853                        }
2854                    }
2855                }
2856                std::result::Result::Ok(result)
2857            }
2858        }
2859        deserializer.deserialize_any(Visitor)
2860    }
2861}
2862
2863#[doc(hidden)]
2864impl serde::ser::Serialize for CommonLanguageSettings {
2865    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2866    where
2867        S: serde::ser::Serializer,
2868    {
2869        use serde::ser::SerializeMap;
2870        #[allow(unused_imports)]
2871        use std::option::Option::Some;
2872        let mut state = serializer.serialize_map(std::option::Option::None)?;
2873        if !self.reference_docs_uri.is_empty() {
2874            state.serialize_entry("referenceDocsUri", &self.reference_docs_uri)?;
2875        }
2876        if !self.destinations.is_empty() {
2877            state.serialize_entry("destinations", &self.destinations)?;
2878        }
2879        if self.selective_gapic_generation.is_some() {
2880            state.serialize_entry("selectiveGapicGeneration", &self.selective_gapic_generation)?;
2881        }
2882        if !self._unknown_fields.is_empty() {
2883            for (key, value) in self._unknown_fields.iter() {
2884                state.serialize_entry(key, &value)?;
2885            }
2886        }
2887        state.end()
2888    }
2889}
2890
2891/// Details about how and where to publish client libraries.
2892#[derive(Clone, Debug, Default, PartialEq)]
2893#[non_exhaustive]
2894pub struct ClientLibrarySettings {
2895    /// Version of the API to apply these settings to. This is the full protobuf
2896    /// package for the API, ending in the version element.
2897    /// Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1".
2898    pub version: std::string::String,
2899
2900    /// Launch stage of this version of the API.
2901    pub launch_stage: crate::model::LaunchStage,
2902
2903    /// When using transport=rest, the client request will encode enums as
2904    /// numbers rather than strings.
2905    pub rest_numeric_enums: bool,
2906
2907    /// Settings for legacy Java features, supported in the Service YAML.
2908    pub java_settings: std::option::Option<crate::model::JavaSettings>,
2909
2910    /// Settings for C++ client libraries.
2911    pub cpp_settings: std::option::Option<crate::model::CppSettings>,
2912
2913    /// Settings for PHP client libraries.
2914    pub php_settings: std::option::Option<crate::model::PhpSettings>,
2915
2916    /// Settings for Python client libraries.
2917    pub python_settings: std::option::Option<crate::model::PythonSettings>,
2918
2919    /// Settings for Node client libraries.
2920    pub node_settings: std::option::Option<crate::model::NodeSettings>,
2921
2922    /// Settings for .NET client libraries.
2923    pub dotnet_settings: std::option::Option<crate::model::DotnetSettings>,
2924
2925    /// Settings for Ruby client libraries.
2926    pub ruby_settings: std::option::Option<crate::model::RubySettings>,
2927
2928    /// Settings for Go client libraries.
2929    pub go_settings: std::option::Option<crate::model::GoSettings>,
2930
2931    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2932}
2933
2934impl ClientLibrarySettings {
2935    pub fn new() -> Self {
2936        std::default::Default::default()
2937    }
2938
2939    /// Sets the value of [version][crate::model::ClientLibrarySettings::version].
2940    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2941        self.version = v.into();
2942        self
2943    }
2944
2945    /// Sets the value of [launch_stage][crate::model::ClientLibrarySettings::launch_stage].
2946    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
2947        mut self,
2948        v: T,
2949    ) -> Self {
2950        self.launch_stage = v.into();
2951        self
2952    }
2953
2954    /// Sets the value of [rest_numeric_enums][crate::model::ClientLibrarySettings::rest_numeric_enums].
2955    pub fn set_rest_numeric_enums<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2956        self.rest_numeric_enums = v.into();
2957        self
2958    }
2959
2960    /// Sets the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
2961    pub fn set_java_settings<T>(mut self, v: T) -> Self
2962    where
2963        T: std::convert::Into<crate::model::JavaSettings>,
2964    {
2965        self.java_settings = std::option::Option::Some(v.into());
2966        self
2967    }
2968
2969    /// Sets or clears the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
2970    pub fn set_or_clear_java_settings<T>(mut self, v: std::option::Option<T>) -> Self
2971    where
2972        T: std::convert::Into<crate::model::JavaSettings>,
2973    {
2974        self.java_settings = v.map(|x| x.into());
2975        self
2976    }
2977
2978    /// Sets the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
2979    pub fn set_cpp_settings<T>(mut self, v: T) -> Self
2980    where
2981        T: std::convert::Into<crate::model::CppSettings>,
2982    {
2983        self.cpp_settings = std::option::Option::Some(v.into());
2984        self
2985    }
2986
2987    /// Sets or clears the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
2988    pub fn set_or_clear_cpp_settings<T>(mut self, v: std::option::Option<T>) -> Self
2989    where
2990        T: std::convert::Into<crate::model::CppSettings>,
2991    {
2992        self.cpp_settings = v.map(|x| x.into());
2993        self
2994    }
2995
2996    /// Sets the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
2997    pub fn set_php_settings<T>(mut self, v: T) -> Self
2998    where
2999        T: std::convert::Into<crate::model::PhpSettings>,
3000    {
3001        self.php_settings = std::option::Option::Some(v.into());
3002        self
3003    }
3004
3005    /// Sets or clears the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
3006    pub fn set_or_clear_php_settings<T>(mut self, v: std::option::Option<T>) -> Self
3007    where
3008        T: std::convert::Into<crate::model::PhpSettings>,
3009    {
3010        self.php_settings = v.map(|x| x.into());
3011        self
3012    }
3013
3014    /// Sets the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
3015    pub fn set_python_settings<T>(mut self, v: T) -> Self
3016    where
3017        T: std::convert::Into<crate::model::PythonSettings>,
3018    {
3019        self.python_settings = std::option::Option::Some(v.into());
3020        self
3021    }
3022
3023    /// Sets or clears the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
3024    pub fn set_or_clear_python_settings<T>(mut self, v: std::option::Option<T>) -> Self
3025    where
3026        T: std::convert::Into<crate::model::PythonSettings>,
3027    {
3028        self.python_settings = v.map(|x| x.into());
3029        self
3030    }
3031
3032    /// Sets the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
3033    pub fn set_node_settings<T>(mut self, v: T) -> Self
3034    where
3035        T: std::convert::Into<crate::model::NodeSettings>,
3036    {
3037        self.node_settings = std::option::Option::Some(v.into());
3038        self
3039    }
3040
3041    /// Sets or clears the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
3042    pub fn set_or_clear_node_settings<T>(mut self, v: std::option::Option<T>) -> Self
3043    where
3044        T: std::convert::Into<crate::model::NodeSettings>,
3045    {
3046        self.node_settings = v.map(|x| x.into());
3047        self
3048    }
3049
3050    /// Sets the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
3051    pub fn set_dotnet_settings<T>(mut self, v: T) -> Self
3052    where
3053        T: std::convert::Into<crate::model::DotnetSettings>,
3054    {
3055        self.dotnet_settings = std::option::Option::Some(v.into());
3056        self
3057    }
3058
3059    /// Sets or clears the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
3060    pub fn set_or_clear_dotnet_settings<T>(mut self, v: std::option::Option<T>) -> Self
3061    where
3062        T: std::convert::Into<crate::model::DotnetSettings>,
3063    {
3064        self.dotnet_settings = v.map(|x| x.into());
3065        self
3066    }
3067
3068    /// Sets the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
3069    pub fn set_ruby_settings<T>(mut self, v: T) -> Self
3070    where
3071        T: std::convert::Into<crate::model::RubySettings>,
3072    {
3073        self.ruby_settings = std::option::Option::Some(v.into());
3074        self
3075    }
3076
3077    /// Sets or clears the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
3078    pub fn set_or_clear_ruby_settings<T>(mut self, v: std::option::Option<T>) -> Self
3079    where
3080        T: std::convert::Into<crate::model::RubySettings>,
3081    {
3082        self.ruby_settings = v.map(|x| x.into());
3083        self
3084    }
3085
3086    /// Sets the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
3087    pub fn set_go_settings<T>(mut self, v: T) -> Self
3088    where
3089        T: std::convert::Into<crate::model::GoSettings>,
3090    {
3091        self.go_settings = std::option::Option::Some(v.into());
3092        self
3093    }
3094
3095    /// Sets or clears the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
3096    pub fn set_or_clear_go_settings<T>(mut self, v: std::option::Option<T>) -> Self
3097    where
3098        T: std::convert::Into<crate::model::GoSettings>,
3099    {
3100        self.go_settings = v.map(|x| x.into());
3101        self
3102    }
3103}
3104
3105impl wkt::message::Message for ClientLibrarySettings {
3106    fn typename() -> &'static str {
3107        "type.googleapis.com/google.api.ClientLibrarySettings"
3108    }
3109}
3110
3111#[doc(hidden)]
3112impl<'de> serde::de::Deserialize<'de> for ClientLibrarySettings {
3113    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3114    where
3115        D: serde::Deserializer<'de>,
3116    {
3117        #[allow(non_camel_case_types)]
3118        #[doc(hidden)]
3119        #[derive(PartialEq, Eq, Hash)]
3120        enum __FieldTag {
3121            __version,
3122            __launch_stage,
3123            __rest_numeric_enums,
3124            __java_settings,
3125            __cpp_settings,
3126            __php_settings,
3127            __python_settings,
3128            __node_settings,
3129            __dotnet_settings,
3130            __ruby_settings,
3131            __go_settings,
3132            Unknown(std::string::String),
3133        }
3134        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3135            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3136            where
3137                D: serde::Deserializer<'de>,
3138            {
3139                struct Visitor;
3140                impl<'de> serde::de::Visitor<'de> for Visitor {
3141                    type Value = __FieldTag;
3142                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3143                        formatter.write_str("a field name for ClientLibrarySettings")
3144                    }
3145                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3146                    where
3147                        E: serde::de::Error,
3148                    {
3149                        use std::result::Result::Ok;
3150                        use std::string::ToString;
3151                        match value {
3152                            "version" => Ok(__FieldTag::__version),
3153                            "launchStage" => Ok(__FieldTag::__launch_stage),
3154                            "launch_stage" => Ok(__FieldTag::__launch_stage),
3155                            "restNumericEnums" => Ok(__FieldTag::__rest_numeric_enums),
3156                            "rest_numeric_enums" => Ok(__FieldTag::__rest_numeric_enums),
3157                            "javaSettings" => Ok(__FieldTag::__java_settings),
3158                            "java_settings" => Ok(__FieldTag::__java_settings),
3159                            "cppSettings" => Ok(__FieldTag::__cpp_settings),
3160                            "cpp_settings" => Ok(__FieldTag::__cpp_settings),
3161                            "phpSettings" => Ok(__FieldTag::__php_settings),
3162                            "php_settings" => Ok(__FieldTag::__php_settings),
3163                            "pythonSettings" => Ok(__FieldTag::__python_settings),
3164                            "python_settings" => Ok(__FieldTag::__python_settings),
3165                            "nodeSettings" => Ok(__FieldTag::__node_settings),
3166                            "node_settings" => Ok(__FieldTag::__node_settings),
3167                            "dotnetSettings" => Ok(__FieldTag::__dotnet_settings),
3168                            "dotnet_settings" => Ok(__FieldTag::__dotnet_settings),
3169                            "rubySettings" => Ok(__FieldTag::__ruby_settings),
3170                            "ruby_settings" => Ok(__FieldTag::__ruby_settings),
3171                            "goSettings" => Ok(__FieldTag::__go_settings),
3172                            "go_settings" => Ok(__FieldTag::__go_settings),
3173                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3174                        }
3175                    }
3176                }
3177                deserializer.deserialize_identifier(Visitor)
3178            }
3179        }
3180        struct Visitor;
3181        impl<'de> serde::de::Visitor<'de> for Visitor {
3182            type Value = ClientLibrarySettings;
3183            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3184                formatter.write_str("struct ClientLibrarySettings")
3185            }
3186            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3187            where
3188                A: serde::de::MapAccess<'de>,
3189            {
3190                #[allow(unused_imports)]
3191                use serde::de::Error;
3192                use std::option::Option::Some;
3193                let mut fields = std::collections::HashSet::new();
3194                let mut result = Self::Value::new();
3195                while let Some(tag) = map.next_key::<__FieldTag>()? {
3196                    #[allow(clippy::match_single_binding)]
3197                    match tag {
3198                        __FieldTag::__version => {
3199                            if !fields.insert(__FieldTag::__version) {
3200                                return std::result::Result::Err(A::Error::duplicate_field(
3201                                    "multiple values for version",
3202                                ));
3203                            }
3204                            result.version = map
3205                                .next_value::<std::option::Option<std::string::String>>()?
3206                                .unwrap_or_default();
3207                        }
3208                        __FieldTag::__launch_stage => {
3209                            if !fields.insert(__FieldTag::__launch_stage) {
3210                                return std::result::Result::Err(A::Error::duplicate_field(
3211                                    "multiple values for launch_stage",
3212                                ));
3213                            }
3214                            result.launch_stage = map
3215                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
3216                                .unwrap_or_default();
3217                        }
3218                        __FieldTag::__rest_numeric_enums => {
3219                            if !fields.insert(__FieldTag::__rest_numeric_enums) {
3220                                return std::result::Result::Err(A::Error::duplicate_field(
3221                                    "multiple values for rest_numeric_enums",
3222                                ));
3223                            }
3224                            result.rest_numeric_enums = map
3225                                .next_value::<std::option::Option<bool>>()?
3226                                .unwrap_or_default();
3227                        }
3228                        __FieldTag::__java_settings => {
3229                            if !fields.insert(__FieldTag::__java_settings) {
3230                                return std::result::Result::Err(A::Error::duplicate_field(
3231                                    "multiple values for java_settings",
3232                                ));
3233                            }
3234                            result.java_settings = map
3235                                .next_value::<std::option::Option<crate::model::JavaSettings>>()?;
3236                        }
3237                        __FieldTag::__cpp_settings => {
3238                            if !fields.insert(__FieldTag::__cpp_settings) {
3239                                return std::result::Result::Err(A::Error::duplicate_field(
3240                                    "multiple values for cpp_settings",
3241                                ));
3242                            }
3243                            result.cpp_settings =
3244                                map.next_value::<std::option::Option<crate::model::CppSettings>>()?;
3245                        }
3246                        __FieldTag::__php_settings => {
3247                            if !fields.insert(__FieldTag::__php_settings) {
3248                                return std::result::Result::Err(A::Error::duplicate_field(
3249                                    "multiple values for php_settings",
3250                                ));
3251                            }
3252                            result.php_settings =
3253                                map.next_value::<std::option::Option<crate::model::PhpSettings>>()?;
3254                        }
3255                        __FieldTag::__python_settings => {
3256                            if !fields.insert(__FieldTag::__python_settings) {
3257                                return std::result::Result::Err(A::Error::duplicate_field(
3258                                    "multiple values for python_settings",
3259                                ));
3260                            }
3261                            result.python_settings = map
3262                                .next_value::<std::option::Option<crate::model::PythonSettings>>(
3263                                )?;
3264                        }
3265                        __FieldTag::__node_settings => {
3266                            if !fields.insert(__FieldTag::__node_settings) {
3267                                return std::result::Result::Err(A::Error::duplicate_field(
3268                                    "multiple values for node_settings",
3269                                ));
3270                            }
3271                            result.node_settings = map
3272                                .next_value::<std::option::Option<crate::model::NodeSettings>>()?;
3273                        }
3274                        __FieldTag::__dotnet_settings => {
3275                            if !fields.insert(__FieldTag::__dotnet_settings) {
3276                                return std::result::Result::Err(A::Error::duplicate_field(
3277                                    "multiple values for dotnet_settings",
3278                                ));
3279                            }
3280                            result.dotnet_settings = map
3281                                .next_value::<std::option::Option<crate::model::DotnetSettings>>(
3282                                )?;
3283                        }
3284                        __FieldTag::__ruby_settings => {
3285                            if !fields.insert(__FieldTag::__ruby_settings) {
3286                                return std::result::Result::Err(A::Error::duplicate_field(
3287                                    "multiple values for ruby_settings",
3288                                ));
3289                            }
3290                            result.ruby_settings = map
3291                                .next_value::<std::option::Option<crate::model::RubySettings>>()?;
3292                        }
3293                        __FieldTag::__go_settings => {
3294                            if !fields.insert(__FieldTag::__go_settings) {
3295                                return std::result::Result::Err(A::Error::duplicate_field(
3296                                    "multiple values for go_settings",
3297                                ));
3298                            }
3299                            result.go_settings =
3300                                map.next_value::<std::option::Option<crate::model::GoSettings>>()?;
3301                        }
3302                        __FieldTag::Unknown(key) => {
3303                            let value = map.next_value::<serde_json::Value>()?;
3304                            result._unknown_fields.insert(key, value);
3305                        }
3306                    }
3307                }
3308                std::result::Result::Ok(result)
3309            }
3310        }
3311        deserializer.deserialize_any(Visitor)
3312    }
3313}
3314
3315#[doc(hidden)]
3316impl serde::ser::Serialize for ClientLibrarySettings {
3317    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3318    where
3319        S: serde::ser::Serializer,
3320    {
3321        use serde::ser::SerializeMap;
3322        #[allow(unused_imports)]
3323        use std::option::Option::Some;
3324        let mut state = serializer.serialize_map(std::option::Option::None)?;
3325        if !self.version.is_empty() {
3326            state.serialize_entry("version", &self.version)?;
3327        }
3328        if !wkt::internal::is_default(&self.launch_stage) {
3329            state.serialize_entry("launchStage", &self.launch_stage)?;
3330        }
3331        if !wkt::internal::is_default(&self.rest_numeric_enums) {
3332            state.serialize_entry("restNumericEnums", &self.rest_numeric_enums)?;
3333        }
3334        if self.java_settings.is_some() {
3335            state.serialize_entry("javaSettings", &self.java_settings)?;
3336        }
3337        if self.cpp_settings.is_some() {
3338            state.serialize_entry("cppSettings", &self.cpp_settings)?;
3339        }
3340        if self.php_settings.is_some() {
3341            state.serialize_entry("phpSettings", &self.php_settings)?;
3342        }
3343        if self.python_settings.is_some() {
3344            state.serialize_entry("pythonSettings", &self.python_settings)?;
3345        }
3346        if self.node_settings.is_some() {
3347            state.serialize_entry("nodeSettings", &self.node_settings)?;
3348        }
3349        if self.dotnet_settings.is_some() {
3350            state.serialize_entry("dotnetSettings", &self.dotnet_settings)?;
3351        }
3352        if self.ruby_settings.is_some() {
3353            state.serialize_entry("rubySettings", &self.ruby_settings)?;
3354        }
3355        if self.go_settings.is_some() {
3356            state.serialize_entry("goSettings", &self.go_settings)?;
3357        }
3358        if !self._unknown_fields.is_empty() {
3359            for (key, value) in self._unknown_fields.iter() {
3360                state.serialize_entry(key, &value)?;
3361            }
3362        }
3363        state.end()
3364    }
3365}
3366
3367/// This message configures the settings for publishing [Google Cloud Client
3368/// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
3369/// generated from the service config.
3370#[derive(Clone, Debug, Default, PartialEq)]
3371#[non_exhaustive]
3372pub struct Publishing {
3373    /// A list of API method settings, e.g. the behavior for methods that use the
3374    /// long-running operation pattern.
3375    pub method_settings: std::vec::Vec<crate::model::MethodSettings>,
3376
3377    /// Link to a *public* URI where users can report issues.  Example:
3378    /// <https://issuetracker.google.com/issues/new?component=190865&template=1161103>
3379    pub new_issue_uri: std::string::String,
3380
3381    /// Link to product home page.  Example:
3382    /// <https://cloud.google.com/asset-inventory/docs/overview>
3383    pub documentation_uri: std::string::String,
3384
3385    /// Used as a tracking tag when collecting data about the APIs developer
3386    /// relations artifacts like docs, packages delivered to package managers,
3387    /// etc.  Example: "speech".
3388    pub api_short_name: std::string::String,
3389
3390    /// GitHub label to apply to issues and pull requests opened for this API.
3391    pub github_label: std::string::String,
3392
3393    /// GitHub teams to be added to CODEOWNERS in the directory in GitHub
3394    /// containing source code for the client libraries for this API.
3395    pub codeowner_github_teams: std::vec::Vec<std::string::String>,
3396
3397    /// A prefix used in sample code when demarking regions to be included in
3398    /// documentation.
3399    pub doc_tag_prefix: std::string::String,
3400
3401    /// For whom the client library is being published.
3402    pub organization: crate::model::ClientLibraryOrganization,
3403
3404    /// Client library settings.  If the same version string appears multiple
3405    /// times in this list, then the last one wins.  Settings from earlier
3406    /// settings with the same version string are discarded.
3407    pub library_settings: std::vec::Vec<crate::model::ClientLibrarySettings>,
3408
3409    /// Optional link to proto reference documentation.  Example:
3410    /// <https://cloud.google.com/pubsub/lite/docs/reference/rpc>
3411    pub proto_reference_documentation_uri: std::string::String,
3412
3413    /// Optional link to REST reference documentation.  Example:
3414    /// <https://cloud.google.com/pubsub/lite/docs/reference/rest>
3415    pub rest_reference_documentation_uri: std::string::String,
3416
3417    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3418}
3419
3420impl Publishing {
3421    pub fn new() -> Self {
3422        std::default::Default::default()
3423    }
3424
3425    /// Sets the value of [method_settings][crate::model::Publishing::method_settings].
3426    pub fn set_method_settings<T, V>(mut self, v: T) -> Self
3427    where
3428        T: std::iter::IntoIterator<Item = V>,
3429        V: std::convert::Into<crate::model::MethodSettings>,
3430    {
3431        use std::iter::Iterator;
3432        self.method_settings = v.into_iter().map(|i| i.into()).collect();
3433        self
3434    }
3435
3436    /// Sets the value of [new_issue_uri][crate::model::Publishing::new_issue_uri].
3437    pub fn set_new_issue_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3438        self.new_issue_uri = v.into();
3439        self
3440    }
3441
3442    /// Sets the value of [documentation_uri][crate::model::Publishing::documentation_uri].
3443    pub fn set_documentation_uri<T: std::convert::Into<std::string::String>>(
3444        mut self,
3445        v: T,
3446    ) -> Self {
3447        self.documentation_uri = v.into();
3448        self
3449    }
3450
3451    /// Sets the value of [api_short_name][crate::model::Publishing::api_short_name].
3452    pub fn set_api_short_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3453        self.api_short_name = v.into();
3454        self
3455    }
3456
3457    /// Sets the value of [github_label][crate::model::Publishing::github_label].
3458    pub fn set_github_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3459        self.github_label = v.into();
3460        self
3461    }
3462
3463    /// Sets the value of [codeowner_github_teams][crate::model::Publishing::codeowner_github_teams].
3464    pub fn set_codeowner_github_teams<T, V>(mut self, v: T) -> Self
3465    where
3466        T: std::iter::IntoIterator<Item = V>,
3467        V: std::convert::Into<std::string::String>,
3468    {
3469        use std::iter::Iterator;
3470        self.codeowner_github_teams = v.into_iter().map(|i| i.into()).collect();
3471        self
3472    }
3473
3474    /// Sets the value of [doc_tag_prefix][crate::model::Publishing::doc_tag_prefix].
3475    pub fn set_doc_tag_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3476        self.doc_tag_prefix = v.into();
3477        self
3478    }
3479
3480    /// Sets the value of [organization][crate::model::Publishing::organization].
3481    pub fn set_organization<T: std::convert::Into<crate::model::ClientLibraryOrganization>>(
3482        mut self,
3483        v: T,
3484    ) -> Self {
3485        self.organization = v.into();
3486        self
3487    }
3488
3489    /// Sets the value of [library_settings][crate::model::Publishing::library_settings].
3490    pub fn set_library_settings<T, V>(mut self, v: T) -> Self
3491    where
3492        T: std::iter::IntoIterator<Item = V>,
3493        V: std::convert::Into<crate::model::ClientLibrarySettings>,
3494    {
3495        use std::iter::Iterator;
3496        self.library_settings = v.into_iter().map(|i| i.into()).collect();
3497        self
3498    }
3499
3500    /// Sets the value of [proto_reference_documentation_uri][crate::model::Publishing::proto_reference_documentation_uri].
3501    pub fn set_proto_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
3502        mut self,
3503        v: T,
3504    ) -> Self {
3505        self.proto_reference_documentation_uri = v.into();
3506        self
3507    }
3508
3509    /// Sets the value of [rest_reference_documentation_uri][crate::model::Publishing::rest_reference_documentation_uri].
3510    pub fn set_rest_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
3511        mut self,
3512        v: T,
3513    ) -> Self {
3514        self.rest_reference_documentation_uri = v.into();
3515        self
3516    }
3517}
3518
3519impl wkt::message::Message for Publishing {
3520    fn typename() -> &'static str {
3521        "type.googleapis.com/google.api.Publishing"
3522    }
3523}
3524
3525#[doc(hidden)]
3526impl<'de> serde::de::Deserialize<'de> for Publishing {
3527    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3528    where
3529        D: serde::Deserializer<'de>,
3530    {
3531        #[allow(non_camel_case_types)]
3532        #[doc(hidden)]
3533        #[derive(PartialEq, Eq, Hash)]
3534        enum __FieldTag {
3535            __method_settings,
3536            __new_issue_uri,
3537            __documentation_uri,
3538            __api_short_name,
3539            __github_label,
3540            __codeowner_github_teams,
3541            __doc_tag_prefix,
3542            __organization,
3543            __library_settings,
3544            __proto_reference_documentation_uri,
3545            __rest_reference_documentation_uri,
3546            Unknown(std::string::String),
3547        }
3548        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3549            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3550            where
3551                D: serde::Deserializer<'de>,
3552            {
3553                struct Visitor;
3554                impl<'de> serde::de::Visitor<'de> for Visitor {
3555                    type Value = __FieldTag;
3556                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3557                        formatter.write_str("a field name for Publishing")
3558                    }
3559                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3560                    where
3561                        E: serde::de::Error,
3562                    {
3563                        use std::result::Result::Ok;
3564                        use std::string::ToString;
3565                        match value {
3566                            "methodSettings" => Ok(__FieldTag::__method_settings),
3567                            "method_settings" => Ok(__FieldTag::__method_settings),
3568                            "newIssueUri" => Ok(__FieldTag::__new_issue_uri),
3569                            "new_issue_uri" => Ok(__FieldTag::__new_issue_uri),
3570                            "documentationUri" => Ok(__FieldTag::__documentation_uri),
3571                            "documentation_uri" => Ok(__FieldTag::__documentation_uri),
3572                            "apiShortName" => Ok(__FieldTag::__api_short_name),
3573                            "api_short_name" => Ok(__FieldTag::__api_short_name),
3574                            "githubLabel" => Ok(__FieldTag::__github_label),
3575                            "github_label" => Ok(__FieldTag::__github_label),
3576                            "codeownerGithubTeams" => Ok(__FieldTag::__codeowner_github_teams),
3577                            "codeowner_github_teams" => Ok(__FieldTag::__codeowner_github_teams),
3578                            "docTagPrefix" => Ok(__FieldTag::__doc_tag_prefix),
3579                            "doc_tag_prefix" => Ok(__FieldTag::__doc_tag_prefix),
3580                            "organization" => Ok(__FieldTag::__organization),
3581                            "librarySettings" => Ok(__FieldTag::__library_settings),
3582                            "library_settings" => Ok(__FieldTag::__library_settings),
3583                            "protoReferenceDocumentationUri" => {
3584                                Ok(__FieldTag::__proto_reference_documentation_uri)
3585                            }
3586                            "proto_reference_documentation_uri" => {
3587                                Ok(__FieldTag::__proto_reference_documentation_uri)
3588                            }
3589                            "restReferenceDocumentationUri" => {
3590                                Ok(__FieldTag::__rest_reference_documentation_uri)
3591                            }
3592                            "rest_reference_documentation_uri" => {
3593                                Ok(__FieldTag::__rest_reference_documentation_uri)
3594                            }
3595                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3596                        }
3597                    }
3598                }
3599                deserializer.deserialize_identifier(Visitor)
3600            }
3601        }
3602        struct Visitor;
3603        impl<'de> serde::de::Visitor<'de> for Visitor {
3604            type Value = Publishing;
3605            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3606                formatter.write_str("struct Publishing")
3607            }
3608            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3609            where
3610                A: serde::de::MapAccess<'de>,
3611            {
3612                #[allow(unused_imports)]
3613                use serde::de::Error;
3614                use std::option::Option::Some;
3615                let mut fields = std::collections::HashSet::new();
3616                let mut result = Self::Value::new();
3617                while let Some(tag) = map.next_key::<__FieldTag>()? {
3618                    #[allow(clippy::match_single_binding)]
3619                    match tag {
3620                        __FieldTag::__method_settings => {
3621                            if !fields.insert(__FieldTag::__method_settings) {
3622                                return std::result::Result::Err(A::Error::duplicate_field(
3623                                    "multiple values for method_settings",
3624                                ));
3625                            }
3626                            result.method_settings =
3627                                map.next_value::<std::option::Option<
3628                                    std::vec::Vec<crate::model::MethodSettings>,
3629                                >>()?
3630                                .unwrap_or_default();
3631                        }
3632                        __FieldTag::__new_issue_uri => {
3633                            if !fields.insert(__FieldTag::__new_issue_uri) {
3634                                return std::result::Result::Err(A::Error::duplicate_field(
3635                                    "multiple values for new_issue_uri",
3636                                ));
3637                            }
3638                            result.new_issue_uri = map
3639                                .next_value::<std::option::Option<std::string::String>>()?
3640                                .unwrap_or_default();
3641                        }
3642                        __FieldTag::__documentation_uri => {
3643                            if !fields.insert(__FieldTag::__documentation_uri) {
3644                                return std::result::Result::Err(A::Error::duplicate_field(
3645                                    "multiple values for documentation_uri",
3646                                ));
3647                            }
3648                            result.documentation_uri = map
3649                                .next_value::<std::option::Option<std::string::String>>()?
3650                                .unwrap_or_default();
3651                        }
3652                        __FieldTag::__api_short_name => {
3653                            if !fields.insert(__FieldTag::__api_short_name) {
3654                                return std::result::Result::Err(A::Error::duplicate_field(
3655                                    "multiple values for api_short_name",
3656                                ));
3657                            }
3658                            result.api_short_name = map
3659                                .next_value::<std::option::Option<std::string::String>>()?
3660                                .unwrap_or_default();
3661                        }
3662                        __FieldTag::__github_label => {
3663                            if !fields.insert(__FieldTag::__github_label) {
3664                                return std::result::Result::Err(A::Error::duplicate_field(
3665                                    "multiple values for github_label",
3666                                ));
3667                            }
3668                            result.github_label = map
3669                                .next_value::<std::option::Option<std::string::String>>()?
3670                                .unwrap_or_default();
3671                        }
3672                        __FieldTag::__codeowner_github_teams => {
3673                            if !fields.insert(__FieldTag::__codeowner_github_teams) {
3674                                return std::result::Result::Err(A::Error::duplicate_field(
3675                                    "multiple values for codeowner_github_teams",
3676                                ));
3677                            }
3678                            result.codeowner_github_teams = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
3679                        }
3680                        __FieldTag::__doc_tag_prefix => {
3681                            if !fields.insert(__FieldTag::__doc_tag_prefix) {
3682                                return std::result::Result::Err(A::Error::duplicate_field(
3683                                    "multiple values for doc_tag_prefix",
3684                                ));
3685                            }
3686                            result.doc_tag_prefix = map
3687                                .next_value::<std::option::Option<std::string::String>>()?
3688                                .unwrap_or_default();
3689                        }
3690                        __FieldTag::__organization => {
3691                            if !fields.insert(__FieldTag::__organization) {
3692                                return std::result::Result::Err(A::Error::duplicate_field(
3693                                    "multiple values for organization",
3694                                ));
3695                            }
3696                            result.organization = map.next_value::<std::option::Option<crate::model::ClientLibraryOrganization>>()?.unwrap_or_default();
3697                        }
3698                        __FieldTag::__library_settings => {
3699                            if !fields.insert(__FieldTag::__library_settings) {
3700                                return std::result::Result::Err(A::Error::duplicate_field(
3701                                    "multiple values for library_settings",
3702                                ));
3703                            }
3704                            result.library_settings = map
3705                                .next_value::<std::option::Option<
3706                                    std::vec::Vec<crate::model::ClientLibrarySettings>,
3707                                >>()?
3708                                .unwrap_or_default();
3709                        }
3710                        __FieldTag::__proto_reference_documentation_uri => {
3711                            if !fields.insert(__FieldTag::__proto_reference_documentation_uri) {
3712                                return std::result::Result::Err(A::Error::duplicate_field(
3713                                    "multiple values for proto_reference_documentation_uri",
3714                                ));
3715                            }
3716                            result.proto_reference_documentation_uri = map
3717                                .next_value::<std::option::Option<std::string::String>>()?
3718                                .unwrap_or_default();
3719                        }
3720                        __FieldTag::__rest_reference_documentation_uri => {
3721                            if !fields.insert(__FieldTag::__rest_reference_documentation_uri) {
3722                                return std::result::Result::Err(A::Error::duplicate_field(
3723                                    "multiple values for rest_reference_documentation_uri",
3724                                ));
3725                            }
3726                            result.rest_reference_documentation_uri = map
3727                                .next_value::<std::option::Option<std::string::String>>()?
3728                                .unwrap_or_default();
3729                        }
3730                        __FieldTag::Unknown(key) => {
3731                            let value = map.next_value::<serde_json::Value>()?;
3732                            result._unknown_fields.insert(key, value);
3733                        }
3734                    }
3735                }
3736                std::result::Result::Ok(result)
3737            }
3738        }
3739        deserializer.deserialize_any(Visitor)
3740    }
3741}
3742
3743#[doc(hidden)]
3744impl serde::ser::Serialize for Publishing {
3745    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3746    where
3747        S: serde::ser::Serializer,
3748    {
3749        use serde::ser::SerializeMap;
3750        #[allow(unused_imports)]
3751        use std::option::Option::Some;
3752        let mut state = serializer.serialize_map(std::option::Option::None)?;
3753        if !self.method_settings.is_empty() {
3754            state.serialize_entry("methodSettings", &self.method_settings)?;
3755        }
3756        if !self.new_issue_uri.is_empty() {
3757            state.serialize_entry("newIssueUri", &self.new_issue_uri)?;
3758        }
3759        if !self.documentation_uri.is_empty() {
3760            state.serialize_entry("documentationUri", &self.documentation_uri)?;
3761        }
3762        if !self.api_short_name.is_empty() {
3763            state.serialize_entry("apiShortName", &self.api_short_name)?;
3764        }
3765        if !self.github_label.is_empty() {
3766            state.serialize_entry("githubLabel", &self.github_label)?;
3767        }
3768        if !self.codeowner_github_teams.is_empty() {
3769            state.serialize_entry("codeownerGithubTeams", &self.codeowner_github_teams)?;
3770        }
3771        if !self.doc_tag_prefix.is_empty() {
3772            state.serialize_entry("docTagPrefix", &self.doc_tag_prefix)?;
3773        }
3774        if !wkt::internal::is_default(&self.organization) {
3775            state.serialize_entry("organization", &self.organization)?;
3776        }
3777        if !self.library_settings.is_empty() {
3778            state.serialize_entry("librarySettings", &self.library_settings)?;
3779        }
3780        if !self.proto_reference_documentation_uri.is_empty() {
3781            state.serialize_entry(
3782                "protoReferenceDocumentationUri",
3783                &self.proto_reference_documentation_uri,
3784            )?;
3785        }
3786        if !self.rest_reference_documentation_uri.is_empty() {
3787            state.serialize_entry(
3788                "restReferenceDocumentationUri",
3789                &self.rest_reference_documentation_uri,
3790            )?;
3791        }
3792        if !self._unknown_fields.is_empty() {
3793            for (key, value) in self._unknown_fields.iter() {
3794                state.serialize_entry(key, &value)?;
3795            }
3796        }
3797        state.end()
3798    }
3799}
3800
3801/// Settings for Java client libraries.
3802#[derive(Clone, Debug, Default, PartialEq)]
3803#[non_exhaustive]
3804pub struct JavaSettings {
3805    /// The package name to use in Java. Clobbers the java_package option
3806    /// set in the protobuf. This should be used **only** by APIs
3807    /// who have already set the language_settings.java.package_name" field
3808    /// in gapic.yaml. API teams should use the protobuf java_package option
3809    /// where possible.
3810    ///
3811    /// Example of a YAML configuration::
3812    ///
3813    /// publishing:
3814    /// java_settings:
3815    /// library_package: com.google.cloud.pubsub.v1
3816    pub library_package: std::string::String,
3817
3818    /// Configure the Java class name to use instead of the service's for its
3819    /// corresponding generated GAPIC client. Keys are fully-qualified
3820    /// service names as they appear in the protobuf (including the full
3821    /// the language_settings.java.interface_names" field in gapic.yaml. API
3822    /// teams should otherwise use the service name as it appears in the
3823    /// protobuf.
3824    ///
3825    /// Example of a YAML configuration::
3826    ///
3827    /// publishing:
3828    /// java_settings:
3829    /// service_class_names:
3830    /// - google.pubsub.v1.Publisher: TopicAdmin
3831    /// - google.pubsub.v1.Subscriber: SubscriptionAdmin
3832    pub service_class_names: std::collections::HashMap<std::string::String, std::string::String>,
3833
3834    /// Some settings.
3835    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
3836
3837    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3838}
3839
3840impl JavaSettings {
3841    pub fn new() -> Self {
3842        std::default::Default::default()
3843    }
3844
3845    /// Sets the value of [library_package][crate::model::JavaSettings::library_package].
3846    pub fn set_library_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3847        self.library_package = v.into();
3848        self
3849    }
3850
3851    /// Sets the value of [service_class_names][crate::model::JavaSettings::service_class_names].
3852    pub fn set_service_class_names<T, K, V>(mut self, v: T) -> Self
3853    where
3854        T: std::iter::IntoIterator<Item = (K, V)>,
3855        K: std::convert::Into<std::string::String>,
3856        V: std::convert::Into<std::string::String>,
3857    {
3858        use std::iter::Iterator;
3859        self.service_class_names = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3860        self
3861    }
3862
3863    /// Sets the value of [common][crate::model::JavaSettings::common].
3864    pub fn set_common<T>(mut self, v: T) -> Self
3865    where
3866        T: std::convert::Into<crate::model::CommonLanguageSettings>,
3867    {
3868        self.common = std::option::Option::Some(v.into());
3869        self
3870    }
3871
3872    /// Sets or clears the value of [common][crate::model::JavaSettings::common].
3873    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
3874    where
3875        T: std::convert::Into<crate::model::CommonLanguageSettings>,
3876    {
3877        self.common = v.map(|x| x.into());
3878        self
3879    }
3880}
3881
3882impl wkt::message::Message for JavaSettings {
3883    fn typename() -> &'static str {
3884        "type.googleapis.com/google.api.JavaSettings"
3885    }
3886}
3887
3888#[doc(hidden)]
3889impl<'de> serde::de::Deserialize<'de> for JavaSettings {
3890    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3891    where
3892        D: serde::Deserializer<'de>,
3893    {
3894        #[allow(non_camel_case_types)]
3895        #[doc(hidden)]
3896        #[derive(PartialEq, Eq, Hash)]
3897        enum __FieldTag {
3898            __library_package,
3899            __service_class_names,
3900            __common,
3901            Unknown(std::string::String),
3902        }
3903        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3904            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3905            where
3906                D: serde::Deserializer<'de>,
3907            {
3908                struct Visitor;
3909                impl<'de> serde::de::Visitor<'de> for Visitor {
3910                    type Value = __FieldTag;
3911                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3912                        formatter.write_str("a field name for JavaSettings")
3913                    }
3914                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3915                    where
3916                        E: serde::de::Error,
3917                    {
3918                        use std::result::Result::Ok;
3919                        use std::string::ToString;
3920                        match value {
3921                            "libraryPackage" => Ok(__FieldTag::__library_package),
3922                            "library_package" => Ok(__FieldTag::__library_package),
3923                            "serviceClassNames" => Ok(__FieldTag::__service_class_names),
3924                            "service_class_names" => Ok(__FieldTag::__service_class_names),
3925                            "common" => Ok(__FieldTag::__common),
3926                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3927                        }
3928                    }
3929                }
3930                deserializer.deserialize_identifier(Visitor)
3931            }
3932        }
3933        struct Visitor;
3934        impl<'de> serde::de::Visitor<'de> for Visitor {
3935            type Value = JavaSettings;
3936            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3937                formatter.write_str("struct JavaSettings")
3938            }
3939            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3940            where
3941                A: serde::de::MapAccess<'de>,
3942            {
3943                #[allow(unused_imports)]
3944                use serde::de::Error;
3945                use std::option::Option::Some;
3946                let mut fields = std::collections::HashSet::new();
3947                let mut result = Self::Value::new();
3948                while let Some(tag) = map.next_key::<__FieldTag>()? {
3949                    #[allow(clippy::match_single_binding)]
3950                    match tag {
3951                        __FieldTag::__library_package => {
3952                            if !fields.insert(__FieldTag::__library_package) {
3953                                return std::result::Result::Err(A::Error::duplicate_field(
3954                                    "multiple values for library_package",
3955                                ));
3956                            }
3957                            result.library_package = map
3958                                .next_value::<std::option::Option<std::string::String>>()?
3959                                .unwrap_or_default();
3960                        }
3961                        __FieldTag::__service_class_names => {
3962                            if !fields.insert(__FieldTag::__service_class_names) {
3963                                return std::result::Result::Err(A::Error::duplicate_field(
3964                                    "multiple values for service_class_names",
3965                                ));
3966                            }
3967                            result.service_class_names = map
3968                                .next_value::<std::option::Option<
3969                                    std::collections::HashMap<
3970                                        std::string::String,
3971                                        std::string::String,
3972                                    >,
3973                                >>()?
3974                                .unwrap_or_default();
3975                        }
3976                        __FieldTag::__common => {
3977                            if !fields.insert(__FieldTag::__common) {
3978                                return std::result::Result::Err(A::Error::duplicate_field(
3979                                    "multiple values for common",
3980                                ));
3981                            }
3982                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
3983                                ;
3984                        }
3985                        __FieldTag::Unknown(key) => {
3986                            let value = map.next_value::<serde_json::Value>()?;
3987                            result._unknown_fields.insert(key, value);
3988                        }
3989                    }
3990                }
3991                std::result::Result::Ok(result)
3992            }
3993        }
3994        deserializer.deserialize_any(Visitor)
3995    }
3996}
3997
3998#[doc(hidden)]
3999impl serde::ser::Serialize for JavaSettings {
4000    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4001    where
4002        S: serde::ser::Serializer,
4003    {
4004        use serde::ser::SerializeMap;
4005        #[allow(unused_imports)]
4006        use std::option::Option::Some;
4007        let mut state = serializer.serialize_map(std::option::Option::None)?;
4008        if !self.library_package.is_empty() {
4009            state.serialize_entry("libraryPackage", &self.library_package)?;
4010        }
4011        if !self.service_class_names.is_empty() {
4012            state.serialize_entry("serviceClassNames", &self.service_class_names)?;
4013        }
4014        if self.common.is_some() {
4015            state.serialize_entry("common", &self.common)?;
4016        }
4017        if !self._unknown_fields.is_empty() {
4018            for (key, value) in self._unknown_fields.iter() {
4019                state.serialize_entry(key, &value)?;
4020            }
4021        }
4022        state.end()
4023    }
4024}
4025
4026/// Settings for C++ client libraries.
4027#[derive(Clone, Debug, Default, PartialEq)]
4028#[non_exhaustive]
4029pub struct CppSettings {
4030    /// Some settings.
4031    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4032
4033    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4034}
4035
4036impl CppSettings {
4037    pub fn new() -> Self {
4038        std::default::Default::default()
4039    }
4040
4041    /// Sets the value of [common][crate::model::CppSettings::common].
4042    pub fn set_common<T>(mut self, v: T) -> Self
4043    where
4044        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4045    {
4046        self.common = std::option::Option::Some(v.into());
4047        self
4048    }
4049
4050    /// Sets or clears the value of [common][crate::model::CppSettings::common].
4051    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4052    where
4053        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4054    {
4055        self.common = v.map(|x| x.into());
4056        self
4057    }
4058}
4059
4060impl wkt::message::Message for CppSettings {
4061    fn typename() -> &'static str {
4062        "type.googleapis.com/google.api.CppSettings"
4063    }
4064}
4065
4066#[doc(hidden)]
4067impl<'de> serde::de::Deserialize<'de> for CppSettings {
4068    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4069    where
4070        D: serde::Deserializer<'de>,
4071    {
4072        #[allow(non_camel_case_types)]
4073        #[doc(hidden)]
4074        #[derive(PartialEq, Eq, Hash)]
4075        enum __FieldTag {
4076            __common,
4077            Unknown(std::string::String),
4078        }
4079        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4080            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4081            where
4082                D: serde::Deserializer<'de>,
4083            {
4084                struct Visitor;
4085                impl<'de> serde::de::Visitor<'de> for Visitor {
4086                    type Value = __FieldTag;
4087                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4088                        formatter.write_str("a field name for CppSettings")
4089                    }
4090                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4091                    where
4092                        E: serde::de::Error,
4093                    {
4094                        use std::result::Result::Ok;
4095                        use std::string::ToString;
4096                        match value {
4097                            "common" => Ok(__FieldTag::__common),
4098                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4099                        }
4100                    }
4101                }
4102                deserializer.deserialize_identifier(Visitor)
4103            }
4104        }
4105        struct Visitor;
4106        impl<'de> serde::de::Visitor<'de> for Visitor {
4107            type Value = CppSettings;
4108            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4109                formatter.write_str("struct CppSettings")
4110            }
4111            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4112            where
4113                A: serde::de::MapAccess<'de>,
4114            {
4115                #[allow(unused_imports)]
4116                use serde::de::Error;
4117                use std::option::Option::Some;
4118                let mut fields = std::collections::HashSet::new();
4119                let mut result = Self::Value::new();
4120                while let Some(tag) = map.next_key::<__FieldTag>()? {
4121                    #[allow(clippy::match_single_binding)]
4122                    match tag {
4123                        __FieldTag::__common => {
4124                            if !fields.insert(__FieldTag::__common) {
4125                                return std::result::Result::Err(A::Error::duplicate_field(
4126                                    "multiple values for common",
4127                                ));
4128                            }
4129                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4130                                ;
4131                        }
4132                        __FieldTag::Unknown(key) => {
4133                            let value = map.next_value::<serde_json::Value>()?;
4134                            result._unknown_fields.insert(key, value);
4135                        }
4136                    }
4137                }
4138                std::result::Result::Ok(result)
4139            }
4140        }
4141        deserializer.deserialize_any(Visitor)
4142    }
4143}
4144
4145#[doc(hidden)]
4146impl serde::ser::Serialize for CppSettings {
4147    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4148    where
4149        S: serde::ser::Serializer,
4150    {
4151        use serde::ser::SerializeMap;
4152        #[allow(unused_imports)]
4153        use std::option::Option::Some;
4154        let mut state = serializer.serialize_map(std::option::Option::None)?;
4155        if self.common.is_some() {
4156            state.serialize_entry("common", &self.common)?;
4157        }
4158        if !self._unknown_fields.is_empty() {
4159            for (key, value) in self._unknown_fields.iter() {
4160                state.serialize_entry(key, &value)?;
4161            }
4162        }
4163        state.end()
4164    }
4165}
4166
4167/// Settings for Php client libraries.
4168#[derive(Clone, Debug, Default, PartialEq)]
4169#[non_exhaustive]
4170pub struct PhpSettings {
4171    /// Some settings.
4172    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4173
4174    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4175}
4176
4177impl PhpSettings {
4178    pub fn new() -> Self {
4179        std::default::Default::default()
4180    }
4181
4182    /// Sets the value of [common][crate::model::PhpSettings::common].
4183    pub fn set_common<T>(mut self, v: T) -> Self
4184    where
4185        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4186    {
4187        self.common = std::option::Option::Some(v.into());
4188        self
4189    }
4190
4191    /// Sets or clears the value of [common][crate::model::PhpSettings::common].
4192    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4193    where
4194        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4195    {
4196        self.common = v.map(|x| x.into());
4197        self
4198    }
4199}
4200
4201impl wkt::message::Message for PhpSettings {
4202    fn typename() -> &'static str {
4203        "type.googleapis.com/google.api.PhpSettings"
4204    }
4205}
4206
4207#[doc(hidden)]
4208impl<'de> serde::de::Deserialize<'de> for PhpSettings {
4209    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4210    where
4211        D: serde::Deserializer<'de>,
4212    {
4213        #[allow(non_camel_case_types)]
4214        #[doc(hidden)]
4215        #[derive(PartialEq, Eq, Hash)]
4216        enum __FieldTag {
4217            __common,
4218            Unknown(std::string::String),
4219        }
4220        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4221            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4222            where
4223                D: serde::Deserializer<'de>,
4224            {
4225                struct Visitor;
4226                impl<'de> serde::de::Visitor<'de> for Visitor {
4227                    type Value = __FieldTag;
4228                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4229                        formatter.write_str("a field name for PhpSettings")
4230                    }
4231                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4232                    where
4233                        E: serde::de::Error,
4234                    {
4235                        use std::result::Result::Ok;
4236                        use std::string::ToString;
4237                        match value {
4238                            "common" => Ok(__FieldTag::__common),
4239                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4240                        }
4241                    }
4242                }
4243                deserializer.deserialize_identifier(Visitor)
4244            }
4245        }
4246        struct Visitor;
4247        impl<'de> serde::de::Visitor<'de> for Visitor {
4248            type Value = PhpSettings;
4249            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4250                formatter.write_str("struct PhpSettings")
4251            }
4252            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4253            where
4254                A: serde::de::MapAccess<'de>,
4255            {
4256                #[allow(unused_imports)]
4257                use serde::de::Error;
4258                use std::option::Option::Some;
4259                let mut fields = std::collections::HashSet::new();
4260                let mut result = Self::Value::new();
4261                while let Some(tag) = map.next_key::<__FieldTag>()? {
4262                    #[allow(clippy::match_single_binding)]
4263                    match tag {
4264                        __FieldTag::__common => {
4265                            if !fields.insert(__FieldTag::__common) {
4266                                return std::result::Result::Err(A::Error::duplicate_field(
4267                                    "multiple values for common",
4268                                ));
4269                            }
4270                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4271                                ;
4272                        }
4273                        __FieldTag::Unknown(key) => {
4274                            let value = map.next_value::<serde_json::Value>()?;
4275                            result._unknown_fields.insert(key, value);
4276                        }
4277                    }
4278                }
4279                std::result::Result::Ok(result)
4280            }
4281        }
4282        deserializer.deserialize_any(Visitor)
4283    }
4284}
4285
4286#[doc(hidden)]
4287impl serde::ser::Serialize for PhpSettings {
4288    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4289    where
4290        S: serde::ser::Serializer,
4291    {
4292        use serde::ser::SerializeMap;
4293        #[allow(unused_imports)]
4294        use std::option::Option::Some;
4295        let mut state = serializer.serialize_map(std::option::Option::None)?;
4296        if self.common.is_some() {
4297            state.serialize_entry("common", &self.common)?;
4298        }
4299        if !self._unknown_fields.is_empty() {
4300            for (key, value) in self._unknown_fields.iter() {
4301                state.serialize_entry(key, &value)?;
4302            }
4303        }
4304        state.end()
4305    }
4306}
4307
4308/// Settings for Python client libraries.
4309#[derive(Clone, Debug, Default, PartialEq)]
4310#[non_exhaustive]
4311pub struct PythonSettings {
4312    /// Some settings.
4313    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4314
4315    /// Experimental features to be included during client library generation.
4316    pub experimental_features:
4317        std::option::Option<crate::model::python_settings::ExperimentalFeatures>,
4318
4319    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4320}
4321
4322impl PythonSettings {
4323    pub fn new() -> Self {
4324        std::default::Default::default()
4325    }
4326
4327    /// Sets the value of [common][crate::model::PythonSettings::common].
4328    pub fn set_common<T>(mut self, v: T) -> Self
4329    where
4330        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4331    {
4332        self.common = std::option::Option::Some(v.into());
4333        self
4334    }
4335
4336    /// Sets or clears the value of [common][crate::model::PythonSettings::common].
4337    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4338    where
4339        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4340    {
4341        self.common = v.map(|x| x.into());
4342        self
4343    }
4344
4345    /// Sets the value of [experimental_features][crate::model::PythonSettings::experimental_features].
4346    pub fn set_experimental_features<T>(mut self, v: T) -> Self
4347    where
4348        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
4349    {
4350        self.experimental_features = std::option::Option::Some(v.into());
4351        self
4352    }
4353
4354    /// Sets or clears the value of [experimental_features][crate::model::PythonSettings::experimental_features].
4355    pub fn set_or_clear_experimental_features<T>(mut self, v: std::option::Option<T>) -> Self
4356    where
4357        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
4358    {
4359        self.experimental_features = v.map(|x| x.into());
4360        self
4361    }
4362}
4363
4364impl wkt::message::Message for PythonSettings {
4365    fn typename() -> &'static str {
4366        "type.googleapis.com/google.api.PythonSettings"
4367    }
4368}
4369
4370#[doc(hidden)]
4371impl<'de> serde::de::Deserialize<'de> for PythonSettings {
4372    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4373    where
4374        D: serde::Deserializer<'de>,
4375    {
4376        #[allow(non_camel_case_types)]
4377        #[doc(hidden)]
4378        #[derive(PartialEq, Eq, Hash)]
4379        enum __FieldTag {
4380            __common,
4381            __experimental_features,
4382            Unknown(std::string::String),
4383        }
4384        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4385            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4386            where
4387                D: serde::Deserializer<'de>,
4388            {
4389                struct Visitor;
4390                impl<'de> serde::de::Visitor<'de> for Visitor {
4391                    type Value = __FieldTag;
4392                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4393                        formatter.write_str("a field name for PythonSettings")
4394                    }
4395                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4396                    where
4397                        E: serde::de::Error,
4398                    {
4399                        use std::result::Result::Ok;
4400                        use std::string::ToString;
4401                        match value {
4402                            "common" => Ok(__FieldTag::__common),
4403                            "experimentalFeatures" => Ok(__FieldTag::__experimental_features),
4404                            "experimental_features" => Ok(__FieldTag::__experimental_features),
4405                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4406                        }
4407                    }
4408                }
4409                deserializer.deserialize_identifier(Visitor)
4410            }
4411        }
4412        struct Visitor;
4413        impl<'de> serde::de::Visitor<'de> for Visitor {
4414            type Value = PythonSettings;
4415            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4416                formatter.write_str("struct PythonSettings")
4417            }
4418            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4419            where
4420                A: serde::de::MapAccess<'de>,
4421            {
4422                #[allow(unused_imports)]
4423                use serde::de::Error;
4424                use std::option::Option::Some;
4425                let mut fields = std::collections::HashSet::new();
4426                let mut result = Self::Value::new();
4427                while let Some(tag) = map.next_key::<__FieldTag>()? {
4428                    #[allow(clippy::match_single_binding)]
4429                    match tag {
4430                        __FieldTag::__common => {
4431                            if !fields.insert(__FieldTag::__common) {
4432                                return std::result::Result::Err(A::Error::duplicate_field(
4433                                    "multiple values for common",
4434                                ));
4435                            }
4436                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4437                                ;
4438                        }
4439                        __FieldTag::__experimental_features => {
4440                            if !fields.insert(__FieldTag::__experimental_features) {
4441                                return std::result::Result::Err(A::Error::duplicate_field(
4442                                    "multiple values for experimental_features",
4443                                ));
4444                            }
4445                            result.experimental_features = map.next_value::<std::option::Option<
4446                                crate::model::python_settings::ExperimentalFeatures,
4447                            >>()?;
4448                        }
4449                        __FieldTag::Unknown(key) => {
4450                            let value = map.next_value::<serde_json::Value>()?;
4451                            result._unknown_fields.insert(key, value);
4452                        }
4453                    }
4454                }
4455                std::result::Result::Ok(result)
4456            }
4457        }
4458        deserializer.deserialize_any(Visitor)
4459    }
4460}
4461
4462#[doc(hidden)]
4463impl serde::ser::Serialize for PythonSettings {
4464    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4465    where
4466        S: serde::ser::Serializer,
4467    {
4468        use serde::ser::SerializeMap;
4469        #[allow(unused_imports)]
4470        use std::option::Option::Some;
4471        let mut state = serializer.serialize_map(std::option::Option::None)?;
4472        if self.common.is_some() {
4473            state.serialize_entry("common", &self.common)?;
4474        }
4475        if self.experimental_features.is_some() {
4476            state.serialize_entry("experimentalFeatures", &self.experimental_features)?;
4477        }
4478        if !self._unknown_fields.is_empty() {
4479            for (key, value) in self._unknown_fields.iter() {
4480                state.serialize_entry(key, &value)?;
4481            }
4482        }
4483        state.end()
4484    }
4485}
4486
4487/// Defines additional types related to [PythonSettings].
4488pub mod python_settings {
4489    #[allow(unused_imports)]
4490    use super::*;
4491
4492    /// Experimental features to be included during client library generation.
4493    /// These fields will be deprecated once the feature graduates and is enabled
4494    /// by default.
4495    #[derive(Clone, Debug, Default, PartialEq)]
4496    #[non_exhaustive]
4497    pub struct ExperimentalFeatures {
4498        /// Enables generation of asynchronous REST clients if `rest` transport is
4499        /// enabled. By default, asynchronous REST clients will not be generated.
4500        /// This feature will be enabled by default 1 month after launching the
4501        /// feature in preview packages.
4502        pub rest_async_io_enabled: bool,
4503
4504        /// Enables generation of protobuf code using new types that are more
4505        /// Pythonic which are included in `protobuf>=5.29.x`. This feature will be
4506        /// enabled by default 1 month after launching the feature in preview
4507        /// packages.
4508        pub protobuf_pythonic_types_enabled: bool,
4509
4510        /// Disables generation of an unversioned Python package for this client
4511        /// library. This means that the module names will need to be versioned in
4512        /// import statements. For example `import google.cloud.library_v2` instead
4513        /// of `import google.cloud.library`.
4514        pub unversioned_package_disabled: bool,
4515
4516        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4517    }
4518
4519    impl ExperimentalFeatures {
4520        pub fn new() -> Self {
4521            std::default::Default::default()
4522        }
4523
4524        /// Sets the value of [rest_async_io_enabled][crate::model::python_settings::ExperimentalFeatures::rest_async_io_enabled].
4525        pub fn set_rest_async_io_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4526            self.rest_async_io_enabled = v.into();
4527            self
4528        }
4529
4530        /// Sets the value of [protobuf_pythonic_types_enabled][crate::model::python_settings::ExperimentalFeatures::protobuf_pythonic_types_enabled].
4531        pub fn set_protobuf_pythonic_types_enabled<T: std::convert::Into<bool>>(
4532            mut self,
4533            v: T,
4534        ) -> Self {
4535            self.protobuf_pythonic_types_enabled = v.into();
4536            self
4537        }
4538
4539        /// Sets the value of [unversioned_package_disabled][crate::model::python_settings::ExperimentalFeatures::unversioned_package_disabled].
4540        pub fn set_unversioned_package_disabled<T: std::convert::Into<bool>>(
4541            mut self,
4542            v: T,
4543        ) -> Self {
4544            self.unversioned_package_disabled = v.into();
4545            self
4546        }
4547    }
4548
4549    impl wkt::message::Message for ExperimentalFeatures {
4550        fn typename() -> &'static str {
4551            "type.googleapis.com/google.api.PythonSettings.ExperimentalFeatures"
4552        }
4553    }
4554
4555    #[doc(hidden)]
4556    impl<'de> serde::de::Deserialize<'de> for ExperimentalFeatures {
4557        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4558        where
4559            D: serde::Deserializer<'de>,
4560        {
4561            #[allow(non_camel_case_types)]
4562            #[doc(hidden)]
4563            #[derive(PartialEq, Eq, Hash)]
4564            enum __FieldTag {
4565                __rest_async_io_enabled,
4566                __protobuf_pythonic_types_enabled,
4567                __unversioned_package_disabled,
4568                Unknown(std::string::String),
4569            }
4570            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4571                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4572                where
4573                    D: serde::Deserializer<'de>,
4574                {
4575                    struct Visitor;
4576                    impl<'de> serde::de::Visitor<'de> for Visitor {
4577                        type Value = __FieldTag;
4578                        fn expecting(
4579                            &self,
4580                            formatter: &mut std::fmt::Formatter,
4581                        ) -> std::fmt::Result {
4582                            formatter.write_str("a field name for ExperimentalFeatures")
4583                        }
4584                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4585                        where
4586                            E: serde::de::Error,
4587                        {
4588                            use std::result::Result::Ok;
4589                            use std::string::ToString;
4590                            match value {
4591                                "restAsyncIoEnabled" => Ok(__FieldTag::__rest_async_io_enabled),
4592                                "rest_async_io_enabled" => Ok(__FieldTag::__rest_async_io_enabled),
4593                                "protobufPythonicTypesEnabled" => {
4594                                    Ok(__FieldTag::__protobuf_pythonic_types_enabled)
4595                                }
4596                                "protobuf_pythonic_types_enabled" => {
4597                                    Ok(__FieldTag::__protobuf_pythonic_types_enabled)
4598                                }
4599                                "unversionedPackageDisabled" => {
4600                                    Ok(__FieldTag::__unversioned_package_disabled)
4601                                }
4602                                "unversioned_package_disabled" => {
4603                                    Ok(__FieldTag::__unversioned_package_disabled)
4604                                }
4605                                _ => Ok(__FieldTag::Unknown(value.to_string())),
4606                            }
4607                        }
4608                    }
4609                    deserializer.deserialize_identifier(Visitor)
4610                }
4611            }
4612            struct Visitor;
4613            impl<'de> serde::de::Visitor<'de> for Visitor {
4614                type Value = ExperimentalFeatures;
4615                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4616                    formatter.write_str("struct ExperimentalFeatures")
4617                }
4618                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4619                where
4620                    A: serde::de::MapAccess<'de>,
4621                {
4622                    #[allow(unused_imports)]
4623                    use serde::de::Error;
4624                    use std::option::Option::Some;
4625                    let mut fields = std::collections::HashSet::new();
4626                    let mut result = Self::Value::new();
4627                    while let Some(tag) = map.next_key::<__FieldTag>()? {
4628                        #[allow(clippy::match_single_binding)]
4629                        match tag {
4630                            __FieldTag::__rest_async_io_enabled => {
4631                                if !fields.insert(__FieldTag::__rest_async_io_enabled) {
4632                                    return std::result::Result::Err(A::Error::duplicate_field(
4633                                        "multiple values for rest_async_io_enabled",
4634                                    ));
4635                                }
4636                                result.rest_async_io_enabled = map
4637                                    .next_value::<std::option::Option<bool>>()?
4638                                    .unwrap_or_default();
4639                            }
4640                            __FieldTag::__protobuf_pythonic_types_enabled => {
4641                                if !fields.insert(__FieldTag::__protobuf_pythonic_types_enabled) {
4642                                    return std::result::Result::Err(A::Error::duplicate_field(
4643                                        "multiple values for protobuf_pythonic_types_enabled",
4644                                    ));
4645                                }
4646                                result.protobuf_pythonic_types_enabled = map
4647                                    .next_value::<std::option::Option<bool>>()?
4648                                    .unwrap_or_default();
4649                            }
4650                            __FieldTag::__unversioned_package_disabled => {
4651                                if !fields.insert(__FieldTag::__unversioned_package_disabled) {
4652                                    return std::result::Result::Err(A::Error::duplicate_field(
4653                                        "multiple values for unversioned_package_disabled",
4654                                    ));
4655                                }
4656                                result.unversioned_package_disabled = map
4657                                    .next_value::<std::option::Option<bool>>()?
4658                                    .unwrap_or_default();
4659                            }
4660                            __FieldTag::Unknown(key) => {
4661                                let value = map.next_value::<serde_json::Value>()?;
4662                                result._unknown_fields.insert(key, value);
4663                            }
4664                        }
4665                    }
4666                    std::result::Result::Ok(result)
4667                }
4668            }
4669            deserializer.deserialize_any(Visitor)
4670        }
4671    }
4672
4673    #[doc(hidden)]
4674    impl serde::ser::Serialize for ExperimentalFeatures {
4675        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4676        where
4677            S: serde::ser::Serializer,
4678        {
4679            use serde::ser::SerializeMap;
4680            #[allow(unused_imports)]
4681            use std::option::Option::Some;
4682            let mut state = serializer.serialize_map(std::option::Option::None)?;
4683            if !wkt::internal::is_default(&self.rest_async_io_enabled) {
4684                state.serialize_entry("restAsyncIoEnabled", &self.rest_async_io_enabled)?;
4685            }
4686            if !wkt::internal::is_default(&self.protobuf_pythonic_types_enabled) {
4687                state.serialize_entry(
4688                    "protobufPythonicTypesEnabled",
4689                    &self.protobuf_pythonic_types_enabled,
4690                )?;
4691            }
4692            if !wkt::internal::is_default(&self.unversioned_package_disabled) {
4693                state.serialize_entry(
4694                    "unversionedPackageDisabled",
4695                    &self.unversioned_package_disabled,
4696                )?;
4697            }
4698            if !self._unknown_fields.is_empty() {
4699                for (key, value) in self._unknown_fields.iter() {
4700                    state.serialize_entry(key, &value)?;
4701                }
4702            }
4703            state.end()
4704        }
4705    }
4706}
4707
4708/// Settings for Node client libraries.
4709#[derive(Clone, Debug, Default, PartialEq)]
4710#[non_exhaustive]
4711pub struct NodeSettings {
4712    /// Some settings.
4713    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4714
4715    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4716}
4717
4718impl NodeSettings {
4719    pub fn new() -> Self {
4720        std::default::Default::default()
4721    }
4722
4723    /// Sets the value of [common][crate::model::NodeSettings::common].
4724    pub fn set_common<T>(mut self, v: T) -> Self
4725    where
4726        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4727    {
4728        self.common = std::option::Option::Some(v.into());
4729        self
4730    }
4731
4732    /// Sets or clears the value of [common][crate::model::NodeSettings::common].
4733    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4734    where
4735        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4736    {
4737        self.common = v.map(|x| x.into());
4738        self
4739    }
4740}
4741
4742impl wkt::message::Message for NodeSettings {
4743    fn typename() -> &'static str {
4744        "type.googleapis.com/google.api.NodeSettings"
4745    }
4746}
4747
4748#[doc(hidden)]
4749impl<'de> serde::de::Deserialize<'de> for NodeSettings {
4750    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4751    where
4752        D: serde::Deserializer<'de>,
4753    {
4754        #[allow(non_camel_case_types)]
4755        #[doc(hidden)]
4756        #[derive(PartialEq, Eq, Hash)]
4757        enum __FieldTag {
4758            __common,
4759            Unknown(std::string::String),
4760        }
4761        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4762            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4763            where
4764                D: serde::Deserializer<'de>,
4765            {
4766                struct Visitor;
4767                impl<'de> serde::de::Visitor<'de> for Visitor {
4768                    type Value = __FieldTag;
4769                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4770                        formatter.write_str("a field name for NodeSettings")
4771                    }
4772                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4773                    where
4774                        E: serde::de::Error,
4775                    {
4776                        use std::result::Result::Ok;
4777                        use std::string::ToString;
4778                        match value {
4779                            "common" => Ok(__FieldTag::__common),
4780                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4781                        }
4782                    }
4783                }
4784                deserializer.deserialize_identifier(Visitor)
4785            }
4786        }
4787        struct Visitor;
4788        impl<'de> serde::de::Visitor<'de> for Visitor {
4789            type Value = NodeSettings;
4790            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4791                formatter.write_str("struct NodeSettings")
4792            }
4793            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4794            where
4795                A: serde::de::MapAccess<'de>,
4796            {
4797                #[allow(unused_imports)]
4798                use serde::de::Error;
4799                use std::option::Option::Some;
4800                let mut fields = std::collections::HashSet::new();
4801                let mut result = Self::Value::new();
4802                while let Some(tag) = map.next_key::<__FieldTag>()? {
4803                    #[allow(clippy::match_single_binding)]
4804                    match tag {
4805                        __FieldTag::__common => {
4806                            if !fields.insert(__FieldTag::__common) {
4807                                return std::result::Result::Err(A::Error::duplicate_field(
4808                                    "multiple values for common",
4809                                ));
4810                            }
4811                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
4812                                ;
4813                        }
4814                        __FieldTag::Unknown(key) => {
4815                            let value = map.next_value::<serde_json::Value>()?;
4816                            result._unknown_fields.insert(key, value);
4817                        }
4818                    }
4819                }
4820                std::result::Result::Ok(result)
4821            }
4822        }
4823        deserializer.deserialize_any(Visitor)
4824    }
4825}
4826
4827#[doc(hidden)]
4828impl serde::ser::Serialize for NodeSettings {
4829    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4830    where
4831        S: serde::ser::Serializer,
4832    {
4833        use serde::ser::SerializeMap;
4834        #[allow(unused_imports)]
4835        use std::option::Option::Some;
4836        let mut state = serializer.serialize_map(std::option::Option::None)?;
4837        if self.common.is_some() {
4838            state.serialize_entry("common", &self.common)?;
4839        }
4840        if !self._unknown_fields.is_empty() {
4841            for (key, value) in self._unknown_fields.iter() {
4842                state.serialize_entry(key, &value)?;
4843            }
4844        }
4845        state.end()
4846    }
4847}
4848
4849/// Settings for Dotnet client libraries.
4850#[derive(Clone, Debug, Default, PartialEq)]
4851#[non_exhaustive]
4852pub struct DotnetSettings {
4853    /// Some settings.
4854    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
4855
4856    /// Map from original service names to renamed versions.
4857    /// This is used when the default generated types
4858    /// would cause a naming conflict. (Neither name is
4859    /// fully-qualified.)
4860    /// Example: Subscriber to SubscriberServiceApi.
4861    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,
4862
4863    /// Map from full resource types to the effective short name
4864    /// for the resource. This is used when otherwise resource
4865    /// named from different services would cause naming collisions.
4866    /// Example entry:
4867    /// "datalabeling.googleapis.com/Dataset": "DataLabelingDataset"
4868    pub renamed_resources: std::collections::HashMap<std::string::String, std::string::String>,
4869
4870    /// List of full resource types to ignore during generation.
4871    /// This is typically used for API-specific Location resources,
4872    /// which should be handled by the generator as if they were actually
4873    /// the common Location resources.
4874    /// Example entry: "documentai.googleapis.com/Location"
4875    pub ignored_resources: std::vec::Vec<std::string::String>,
4876
4877    /// Namespaces which must be aliased in snippets due to
4878    /// a known (but non-generator-predictable) naming collision
4879    pub forced_namespace_aliases: std::vec::Vec<std::string::String>,
4880
4881    /// Method signatures (in the form "service.method(signature)")
4882    /// which are provided separately, so shouldn't be generated.
4883    /// Snippets *calling* these methods are still generated, however.
4884    pub handwritten_signatures: std::vec::Vec<std::string::String>,
4885
4886    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4887}
4888
4889impl DotnetSettings {
4890    pub fn new() -> Self {
4891        std::default::Default::default()
4892    }
4893
4894    /// Sets the value of [common][crate::model::DotnetSettings::common].
4895    pub fn set_common<T>(mut self, v: T) -> Self
4896    where
4897        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4898    {
4899        self.common = std::option::Option::Some(v.into());
4900        self
4901    }
4902
4903    /// Sets or clears the value of [common][crate::model::DotnetSettings::common].
4904    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
4905    where
4906        T: std::convert::Into<crate::model::CommonLanguageSettings>,
4907    {
4908        self.common = v.map(|x| x.into());
4909        self
4910    }
4911
4912    /// Sets the value of [renamed_services][crate::model::DotnetSettings::renamed_services].
4913    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
4914    where
4915        T: std::iter::IntoIterator<Item = (K, V)>,
4916        K: std::convert::Into<std::string::String>,
4917        V: std::convert::Into<std::string::String>,
4918    {
4919        use std::iter::Iterator;
4920        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4921        self
4922    }
4923
4924    /// Sets the value of [renamed_resources][crate::model::DotnetSettings::renamed_resources].
4925    pub fn set_renamed_resources<T, K, V>(mut self, v: T) -> Self
4926    where
4927        T: std::iter::IntoIterator<Item = (K, V)>,
4928        K: std::convert::Into<std::string::String>,
4929        V: std::convert::Into<std::string::String>,
4930    {
4931        use std::iter::Iterator;
4932        self.renamed_resources = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4933        self
4934    }
4935
4936    /// Sets the value of [ignored_resources][crate::model::DotnetSettings::ignored_resources].
4937    pub fn set_ignored_resources<T, V>(mut self, v: T) -> Self
4938    where
4939        T: std::iter::IntoIterator<Item = V>,
4940        V: std::convert::Into<std::string::String>,
4941    {
4942        use std::iter::Iterator;
4943        self.ignored_resources = v.into_iter().map(|i| i.into()).collect();
4944        self
4945    }
4946
4947    /// Sets the value of [forced_namespace_aliases][crate::model::DotnetSettings::forced_namespace_aliases].
4948    pub fn set_forced_namespace_aliases<T, V>(mut self, v: T) -> Self
4949    where
4950        T: std::iter::IntoIterator<Item = V>,
4951        V: std::convert::Into<std::string::String>,
4952    {
4953        use std::iter::Iterator;
4954        self.forced_namespace_aliases = v.into_iter().map(|i| i.into()).collect();
4955        self
4956    }
4957
4958    /// Sets the value of [handwritten_signatures][crate::model::DotnetSettings::handwritten_signatures].
4959    pub fn set_handwritten_signatures<T, V>(mut self, v: T) -> Self
4960    where
4961        T: std::iter::IntoIterator<Item = V>,
4962        V: std::convert::Into<std::string::String>,
4963    {
4964        use std::iter::Iterator;
4965        self.handwritten_signatures = v.into_iter().map(|i| i.into()).collect();
4966        self
4967    }
4968}
4969
4970impl wkt::message::Message for DotnetSettings {
4971    fn typename() -> &'static str {
4972        "type.googleapis.com/google.api.DotnetSettings"
4973    }
4974}
4975
4976#[doc(hidden)]
4977impl<'de> serde::de::Deserialize<'de> for DotnetSettings {
4978    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4979    where
4980        D: serde::Deserializer<'de>,
4981    {
4982        #[allow(non_camel_case_types)]
4983        #[doc(hidden)]
4984        #[derive(PartialEq, Eq, Hash)]
4985        enum __FieldTag {
4986            __common,
4987            __renamed_services,
4988            __renamed_resources,
4989            __ignored_resources,
4990            __forced_namespace_aliases,
4991            __handwritten_signatures,
4992            Unknown(std::string::String),
4993        }
4994        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4995            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4996            where
4997                D: serde::Deserializer<'de>,
4998            {
4999                struct Visitor;
5000                impl<'de> serde::de::Visitor<'de> for Visitor {
5001                    type Value = __FieldTag;
5002                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5003                        formatter.write_str("a field name for DotnetSettings")
5004                    }
5005                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5006                    where
5007                        E: serde::de::Error,
5008                    {
5009                        use std::result::Result::Ok;
5010                        use std::string::ToString;
5011                        match value {
5012                            "common" => Ok(__FieldTag::__common),
5013                            "renamedServices" => Ok(__FieldTag::__renamed_services),
5014                            "renamed_services" => Ok(__FieldTag::__renamed_services),
5015                            "renamedResources" => Ok(__FieldTag::__renamed_resources),
5016                            "renamed_resources" => Ok(__FieldTag::__renamed_resources),
5017                            "ignoredResources" => Ok(__FieldTag::__ignored_resources),
5018                            "ignored_resources" => Ok(__FieldTag::__ignored_resources),
5019                            "forcedNamespaceAliases" => Ok(__FieldTag::__forced_namespace_aliases),
5020                            "forced_namespace_aliases" => {
5021                                Ok(__FieldTag::__forced_namespace_aliases)
5022                            }
5023                            "handwrittenSignatures" => Ok(__FieldTag::__handwritten_signatures),
5024                            "handwritten_signatures" => Ok(__FieldTag::__handwritten_signatures),
5025                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5026                        }
5027                    }
5028                }
5029                deserializer.deserialize_identifier(Visitor)
5030            }
5031        }
5032        struct Visitor;
5033        impl<'de> serde::de::Visitor<'de> for Visitor {
5034            type Value = DotnetSettings;
5035            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5036                formatter.write_str("struct DotnetSettings")
5037            }
5038            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5039            where
5040                A: serde::de::MapAccess<'de>,
5041            {
5042                #[allow(unused_imports)]
5043                use serde::de::Error;
5044                use std::option::Option::Some;
5045                let mut fields = std::collections::HashSet::new();
5046                let mut result = Self::Value::new();
5047                while let Some(tag) = map.next_key::<__FieldTag>()? {
5048                    #[allow(clippy::match_single_binding)]
5049                    match tag {
5050                        __FieldTag::__common => {
5051                            if !fields.insert(__FieldTag::__common) {
5052                                return std::result::Result::Err(A::Error::duplicate_field(
5053                                    "multiple values for common",
5054                                ));
5055                            }
5056                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5057                                ;
5058                        }
5059                        __FieldTag::__renamed_services => {
5060                            if !fields.insert(__FieldTag::__renamed_services) {
5061                                return std::result::Result::Err(A::Error::duplicate_field(
5062                                    "multiple values for renamed_services",
5063                                ));
5064                            }
5065                            result.renamed_services = map
5066                                .next_value::<std::option::Option<
5067                                    std::collections::HashMap<
5068                                        std::string::String,
5069                                        std::string::String,
5070                                    >,
5071                                >>()?
5072                                .unwrap_or_default();
5073                        }
5074                        __FieldTag::__renamed_resources => {
5075                            if !fields.insert(__FieldTag::__renamed_resources) {
5076                                return std::result::Result::Err(A::Error::duplicate_field(
5077                                    "multiple values for renamed_resources",
5078                                ));
5079                            }
5080                            result.renamed_resources = map
5081                                .next_value::<std::option::Option<
5082                                    std::collections::HashMap<
5083                                        std::string::String,
5084                                        std::string::String,
5085                                    >,
5086                                >>()?
5087                                .unwrap_or_default();
5088                        }
5089                        __FieldTag::__ignored_resources => {
5090                            if !fields.insert(__FieldTag::__ignored_resources) {
5091                                return std::result::Result::Err(A::Error::duplicate_field(
5092                                    "multiple values for ignored_resources",
5093                                ));
5094                            }
5095                            result.ignored_resources = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5096                        }
5097                        __FieldTag::__forced_namespace_aliases => {
5098                            if !fields.insert(__FieldTag::__forced_namespace_aliases) {
5099                                return std::result::Result::Err(A::Error::duplicate_field(
5100                                    "multiple values for forced_namespace_aliases",
5101                                ));
5102                            }
5103                            result.forced_namespace_aliases = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5104                        }
5105                        __FieldTag::__handwritten_signatures => {
5106                            if !fields.insert(__FieldTag::__handwritten_signatures) {
5107                                return std::result::Result::Err(A::Error::duplicate_field(
5108                                    "multiple values for handwritten_signatures",
5109                                ));
5110                            }
5111                            result.handwritten_signatures = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5112                        }
5113                        __FieldTag::Unknown(key) => {
5114                            let value = map.next_value::<serde_json::Value>()?;
5115                            result._unknown_fields.insert(key, value);
5116                        }
5117                    }
5118                }
5119                std::result::Result::Ok(result)
5120            }
5121        }
5122        deserializer.deserialize_any(Visitor)
5123    }
5124}
5125
5126#[doc(hidden)]
5127impl serde::ser::Serialize for DotnetSettings {
5128    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5129    where
5130        S: serde::ser::Serializer,
5131    {
5132        use serde::ser::SerializeMap;
5133        #[allow(unused_imports)]
5134        use std::option::Option::Some;
5135        let mut state = serializer.serialize_map(std::option::Option::None)?;
5136        if self.common.is_some() {
5137            state.serialize_entry("common", &self.common)?;
5138        }
5139        if !self.renamed_services.is_empty() {
5140            state.serialize_entry("renamedServices", &self.renamed_services)?;
5141        }
5142        if !self.renamed_resources.is_empty() {
5143            state.serialize_entry("renamedResources", &self.renamed_resources)?;
5144        }
5145        if !self.ignored_resources.is_empty() {
5146            state.serialize_entry("ignoredResources", &self.ignored_resources)?;
5147        }
5148        if !self.forced_namespace_aliases.is_empty() {
5149            state.serialize_entry("forcedNamespaceAliases", &self.forced_namespace_aliases)?;
5150        }
5151        if !self.handwritten_signatures.is_empty() {
5152            state.serialize_entry("handwrittenSignatures", &self.handwritten_signatures)?;
5153        }
5154        if !self._unknown_fields.is_empty() {
5155            for (key, value) in self._unknown_fields.iter() {
5156                state.serialize_entry(key, &value)?;
5157            }
5158        }
5159        state.end()
5160    }
5161}
5162
5163/// Settings for Ruby client libraries.
5164#[derive(Clone, Debug, Default, PartialEq)]
5165#[non_exhaustive]
5166pub struct RubySettings {
5167    /// Some settings.
5168    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
5169
5170    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5171}
5172
5173impl RubySettings {
5174    pub fn new() -> Self {
5175        std::default::Default::default()
5176    }
5177
5178    /// Sets the value of [common][crate::model::RubySettings::common].
5179    pub fn set_common<T>(mut self, v: T) -> Self
5180    where
5181        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5182    {
5183        self.common = std::option::Option::Some(v.into());
5184        self
5185    }
5186
5187    /// Sets or clears the value of [common][crate::model::RubySettings::common].
5188    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
5189    where
5190        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5191    {
5192        self.common = v.map(|x| x.into());
5193        self
5194    }
5195}
5196
5197impl wkt::message::Message for RubySettings {
5198    fn typename() -> &'static str {
5199        "type.googleapis.com/google.api.RubySettings"
5200    }
5201}
5202
5203#[doc(hidden)]
5204impl<'de> serde::de::Deserialize<'de> for RubySettings {
5205    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5206    where
5207        D: serde::Deserializer<'de>,
5208    {
5209        #[allow(non_camel_case_types)]
5210        #[doc(hidden)]
5211        #[derive(PartialEq, Eq, Hash)]
5212        enum __FieldTag {
5213            __common,
5214            Unknown(std::string::String),
5215        }
5216        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5217            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5218            where
5219                D: serde::Deserializer<'de>,
5220            {
5221                struct Visitor;
5222                impl<'de> serde::de::Visitor<'de> for Visitor {
5223                    type Value = __FieldTag;
5224                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5225                        formatter.write_str("a field name for RubySettings")
5226                    }
5227                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5228                    where
5229                        E: serde::de::Error,
5230                    {
5231                        use std::result::Result::Ok;
5232                        use std::string::ToString;
5233                        match value {
5234                            "common" => Ok(__FieldTag::__common),
5235                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5236                        }
5237                    }
5238                }
5239                deserializer.deserialize_identifier(Visitor)
5240            }
5241        }
5242        struct Visitor;
5243        impl<'de> serde::de::Visitor<'de> for Visitor {
5244            type Value = RubySettings;
5245            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5246                formatter.write_str("struct RubySettings")
5247            }
5248            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5249            where
5250                A: serde::de::MapAccess<'de>,
5251            {
5252                #[allow(unused_imports)]
5253                use serde::de::Error;
5254                use std::option::Option::Some;
5255                let mut fields = std::collections::HashSet::new();
5256                let mut result = Self::Value::new();
5257                while let Some(tag) = map.next_key::<__FieldTag>()? {
5258                    #[allow(clippy::match_single_binding)]
5259                    match tag {
5260                        __FieldTag::__common => {
5261                            if !fields.insert(__FieldTag::__common) {
5262                                return std::result::Result::Err(A::Error::duplicate_field(
5263                                    "multiple values for common",
5264                                ));
5265                            }
5266                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5267                                ;
5268                        }
5269                        __FieldTag::Unknown(key) => {
5270                            let value = map.next_value::<serde_json::Value>()?;
5271                            result._unknown_fields.insert(key, value);
5272                        }
5273                    }
5274                }
5275                std::result::Result::Ok(result)
5276            }
5277        }
5278        deserializer.deserialize_any(Visitor)
5279    }
5280}
5281
5282#[doc(hidden)]
5283impl serde::ser::Serialize for RubySettings {
5284    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5285    where
5286        S: serde::ser::Serializer,
5287    {
5288        use serde::ser::SerializeMap;
5289        #[allow(unused_imports)]
5290        use std::option::Option::Some;
5291        let mut state = serializer.serialize_map(std::option::Option::None)?;
5292        if self.common.is_some() {
5293            state.serialize_entry("common", &self.common)?;
5294        }
5295        if !self._unknown_fields.is_empty() {
5296            for (key, value) in self._unknown_fields.iter() {
5297                state.serialize_entry(key, &value)?;
5298            }
5299        }
5300        state.end()
5301    }
5302}
5303
5304/// Settings for Go client libraries.
5305#[derive(Clone, Debug, Default, PartialEq)]
5306#[non_exhaustive]
5307pub struct GoSettings {
5308    /// Some settings.
5309    pub common: std::option::Option<crate::model::CommonLanguageSettings>,
5310
5311    /// Map of service names to renamed services. Keys are the package relative
5312    /// service names and values are the name to be used for the service client
5313    /// and call options.
5314    ///
5315    /// publishing:
5316    /// go_settings:
5317    /// renamed_services:
5318    /// Publisher: TopicAdmin
5319    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,
5320
5321    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5322}
5323
5324impl GoSettings {
5325    pub fn new() -> Self {
5326        std::default::Default::default()
5327    }
5328
5329    /// Sets the value of [common][crate::model::GoSettings::common].
5330    pub fn set_common<T>(mut self, v: T) -> Self
5331    where
5332        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5333    {
5334        self.common = std::option::Option::Some(v.into());
5335        self
5336    }
5337
5338    /// Sets or clears the value of [common][crate::model::GoSettings::common].
5339    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
5340    where
5341        T: std::convert::Into<crate::model::CommonLanguageSettings>,
5342    {
5343        self.common = v.map(|x| x.into());
5344        self
5345    }
5346
5347    /// Sets the value of [renamed_services][crate::model::GoSettings::renamed_services].
5348    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
5349    where
5350        T: std::iter::IntoIterator<Item = (K, V)>,
5351        K: std::convert::Into<std::string::String>,
5352        V: std::convert::Into<std::string::String>,
5353    {
5354        use std::iter::Iterator;
5355        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5356        self
5357    }
5358}
5359
5360impl wkt::message::Message for GoSettings {
5361    fn typename() -> &'static str {
5362        "type.googleapis.com/google.api.GoSettings"
5363    }
5364}
5365
5366#[doc(hidden)]
5367impl<'de> serde::de::Deserialize<'de> for GoSettings {
5368    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5369    where
5370        D: serde::Deserializer<'de>,
5371    {
5372        #[allow(non_camel_case_types)]
5373        #[doc(hidden)]
5374        #[derive(PartialEq, Eq, Hash)]
5375        enum __FieldTag {
5376            __common,
5377            __renamed_services,
5378            Unknown(std::string::String),
5379        }
5380        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5381            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5382            where
5383                D: serde::Deserializer<'de>,
5384            {
5385                struct Visitor;
5386                impl<'de> serde::de::Visitor<'de> for Visitor {
5387                    type Value = __FieldTag;
5388                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5389                        formatter.write_str("a field name for GoSettings")
5390                    }
5391                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5392                    where
5393                        E: serde::de::Error,
5394                    {
5395                        use std::result::Result::Ok;
5396                        use std::string::ToString;
5397                        match value {
5398                            "common" => Ok(__FieldTag::__common),
5399                            "renamedServices" => Ok(__FieldTag::__renamed_services),
5400                            "renamed_services" => Ok(__FieldTag::__renamed_services),
5401                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5402                        }
5403                    }
5404                }
5405                deserializer.deserialize_identifier(Visitor)
5406            }
5407        }
5408        struct Visitor;
5409        impl<'de> serde::de::Visitor<'de> for Visitor {
5410            type Value = GoSettings;
5411            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5412                formatter.write_str("struct GoSettings")
5413            }
5414            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5415            where
5416                A: serde::de::MapAccess<'de>,
5417            {
5418                #[allow(unused_imports)]
5419                use serde::de::Error;
5420                use std::option::Option::Some;
5421                let mut fields = std::collections::HashSet::new();
5422                let mut result = Self::Value::new();
5423                while let Some(tag) = map.next_key::<__FieldTag>()? {
5424                    #[allow(clippy::match_single_binding)]
5425                    match tag {
5426                        __FieldTag::__common => {
5427                            if !fields.insert(__FieldTag::__common) {
5428                                return std::result::Result::Err(A::Error::duplicate_field(
5429                                    "multiple values for common",
5430                                ));
5431                            }
5432                            result.common = map.next_value::<std::option::Option<crate::model::CommonLanguageSettings>>()?
5433                                ;
5434                        }
5435                        __FieldTag::__renamed_services => {
5436                            if !fields.insert(__FieldTag::__renamed_services) {
5437                                return std::result::Result::Err(A::Error::duplicate_field(
5438                                    "multiple values for renamed_services",
5439                                ));
5440                            }
5441                            result.renamed_services = map
5442                                .next_value::<std::option::Option<
5443                                    std::collections::HashMap<
5444                                        std::string::String,
5445                                        std::string::String,
5446                                    >,
5447                                >>()?
5448                                .unwrap_or_default();
5449                        }
5450                        __FieldTag::Unknown(key) => {
5451                            let value = map.next_value::<serde_json::Value>()?;
5452                            result._unknown_fields.insert(key, value);
5453                        }
5454                    }
5455                }
5456                std::result::Result::Ok(result)
5457            }
5458        }
5459        deserializer.deserialize_any(Visitor)
5460    }
5461}
5462
5463#[doc(hidden)]
5464impl serde::ser::Serialize for GoSettings {
5465    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5466    where
5467        S: serde::ser::Serializer,
5468    {
5469        use serde::ser::SerializeMap;
5470        #[allow(unused_imports)]
5471        use std::option::Option::Some;
5472        let mut state = serializer.serialize_map(std::option::Option::None)?;
5473        if self.common.is_some() {
5474            state.serialize_entry("common", &self.common)?;
5475        }
5476        if !self.renamed_services.is_empty() {
5477            state.serialize_entry("renamedServices", &self.renamed_services)?;
5478        }
5479        if !self._unknown_fields.is_empty() {
5480            for (key, value) in self._unknown_fields.iter() {
5481                state.serialize_entry(key, &value)?;
5482            }
5483        }
5484        state.end()
5485    }
5486}
5487
5488/// Describes the generator configuration for a method.
5489#[derive(Clone, Debug, Default, PartialEq)]
5490#[non_exhaustive]
5491pub struct MethodSettings {
5492    /// The fully qualified name of the method, for which the options below apply.
5493    /// This is used to find the method to apply the options.
5494    ///
5495    /// Example:
5496    ///
5497    /// ```norust
5498    /// publishing:
5499    ///   method_settings:
5500    ///   - selector: google.storage.control.v2.StorageControl.CreateFolder
5501    ///     # method settings for CreateFolder...
5502    /// ```
5503    pub selector: std::string::String,
5504
5505    /// Describes settings to use for long-running operations when generating
5506    /// API methods for RPCs. Complements RPCs that use the annotations in
5507    /// google/longrunning/operations.proto.
5508    ///
5509    /// Example of a YAML configuration::
5510    ///
5511    /// ```norust
5512    /// publishing:
5513    ///   method_settings:
5514    ///   - selector: google.cloud.speech.v2.Speech.BatchRecognize
5515    ///     long_running:
5516    ///       initial_poll_delay: 60s # 1 minute
5517    ///       poll_delay_multiplier: 1.5
5518    ///       max_poll_delay: 360s # 6 minutes
5519    ///       total_poll_timeout: 54000s # 90 minutes
5520    /// ```
5521    pub long_running: std::option::Option<crate::model::method_settings::LongRunning>,
5522
5523    /// List of top-level fields of the request message, that should be
5524    /// automatically populated by the client libraries based on their
5525    /// (google.api.field_info).format. Currently supported format: UUID4.
5526    ///
5527    /// Example of a YAML configuration:
5528    ///
5529    /// ```norust
5530    /// publishing:
5531    ///   method_settings:
5532    ///   - selector: google.example.v1.ExampleService.CreateExample
5533    ///     auto_populated_fields:
5534    ///     - request_id
5535    /// ```
5536    pub auto_populated_fields: std::vec::Vec<std::string::String>,
5537
5538    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5539}
5540
5541impl MethodSettings {
5542    pub fn new() -> Self {
5543        std::default::Default::default()
5544    }
5545
5546    /// Sets the value of [selector][crate::model::MethodSettings::selector].
5547    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5548        self.selector = v.into();
5549        self
5550    }
5551
5552    /// Sets the value of [long_running][crate::model::MethodSettings::long_running].
5553    pub fn set_long_running<T>(mut self, v: T) -> Self
5554    where
5555        T: std::convert::Into<crate::model::method_settings::LongRunning>,
5556    {
5557        self.long_running = std::option::Option::Some(v.into());
5558        self
5559    }
5560
5561    /// Sets or clears the value of [long_running][crate::model::MethodSettings::long_running].
5562    pub fn set_or_clear_long_running<T>(mut self, v: std::option::Option<T>) -> Self
5563    where
5564        T: std::convert::Into<crate::model::method_settings::LongRunning>,
5565    {
5566        self.long_running = v.map(|x| x.into());
5567        self
5568    }
5569
5570    /// Sets the value of [auto_populated_fields][crate::model::MethodSettings::auto_populated_fields].
5571    pub fn set_auto_populated_fields<T, V>(mut self, v: T) -> Self
5572    where
5573        T: std::iter::IntoIterator<Item = V>,
5574        V: std::convert::Into<std::string::String>,
5575    {
5576        use std::iter::Iterator;
5577        self.auto_populated_fields = v.into_iter().map(|i| i.into()).collect();
5578        self
5579    }
5580}
5581
5582impl wkt::message::Message for MethodSettings {
5583    fn typename() -> &'static str {
5584        "type.googleapis.com/google.api.MethodSettings"
5585    }
5586}
5587
5588#[doc(hidden)]
5589impl<'de> serde::de::Deserialize<'de> for MethodSettings {
5590    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5591    where
5592        D: serde::Deserializer<'de>,
5593    {
5594        #[allow(non_camel_case_types)]
5595        #[doc(hidden)]
5596        #[derive(PartialEq, Eq, Hash)]
5597        enum __FieldTag {
5598            __selector,
5599            __long_running,
5600            __auto_populated_fields,
5601            Unknown(std::string::String),
5602        }
5603        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5604            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5605            where
5606                D: serde::Deserializer<'de>,
5607            {
5608                struct Visitor;
5609                impl<'de> serde::de::Visitor<'de> for Visitor {
5610                    type Value = __FieldTag;
5611                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5612                        formatter.write_str("a field name for MethodSettings")
5613                    }
5614                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5615                    where
5616                        E: serde::de::Error,
5617                    {
5618                        use std::result::Result::Ok;
5619                        use std::string::ToString;
5620                        match value {
5621                            "selector" => Ok(__FieldTag::__selector),
5622                            "longRunning" => Ok(__FieldTag::__long_running),
5623                            "long_running" => Ok(__FieldTag::__long_running),
5624                            "autoPopulatedFields" => Ok(__FieldTag::__auto_populated_fields),
5625                            "auto_populated_fields" => Ok(__FieldTag::__auto_populated_fields),
5626                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5627                        }
5628                    }
5629                }
5630                deserializer.deserialize_identifier(Visitor)
5631            }
5632        }
5633        struct Visitor;
5634        impl<'de> serde::de::Visitor<'de> for Visitor {
5635            type Value = MethodSettings;
5636            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5637                formatter.write_str("struct MethodSettings")
5638            }
5639            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5640            where
5641                A: serde::de::MapAccess<'de>,
5642            {
5643                #[allow(unused_imports)]
5644                use serde::de::Error;
5645                use std::option::Option::Some;
5646                let mut fields = std::collections::HashSet::new();
5647                let mut result = Self::Value::new();
5648                while let Some(tag) = map.next_key::<__FieldTag>()? {
5649                    #[allow(clippy::match_single_binding)]
5650                    match tag {
5651                        __FieldTag::__selector => {
5652                            if !fields.insert(__FieldTag::__selector) {
5653                                return std::result::Result::Err(A::Error::duplicate_field(
5654                                    "multiple values for selector",
5655                                ));
5656                            }
5657                            result.selector = map
5658                                .next_value::<std::option::Option<std::string::String>>()?
5659                                .unwrap_or_default();
5660                        }
5661                        __FieldTag::__long_running => {
5662                            if !fields.insert(__FieldTag::__long_running) {
5663                                return std::result::Result::Err(A::Error::duplicate_field(
5664                                    "multiple values for long_running",
5665                                ));
5666                            }
5667                            result.long_running = map.next_value::<std::option::Option<crate::model::method_settings::LongRunning>>()?
5668                                ;
5669                        }
5670                        __FieldTag::__auto_populated_fields => {
5671                            if !fields.insert(__FieldTag::__auto_populated_fields) {
5672                                return std::result::Result::Err(A::Error::duplicate_field(
5673                                    "multiple values for auto_populated_fields",
5674                                ));
5675                            }
5676                            result.auto_populated_fields = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
5677                        }
5678                        __FieldTag::Unknown(key) => {
5679                            let value = map.next_value::<serde_json::Value>()?;
5680                            result._unknown_fields.insert(key, value);
5681                        }
5682                    }
5683                }
5684                std::result::Result::Ok(result)
5685            }
5686        }
5687        deserializer.deserialize_any(Visitor)
5688    }
5689}
5690
5691#[doc(hidden)]
5692impl serde::ser::Serialize for MethodSettings {
5693    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5694    where
5695        S: serde::ser::Serializer,
5696    {
5697        use serde::ser::SerializeMap;
5698        #[allow(unused_imports)]
5699        use std::option::Option::Some;
5700        let mut state = serializer.serialize_map(std::option::Option::None)?;
5701        if !self.selector.is_empty() {
5702            state.serialize_entry("selector", &self.selector)?;
5703        }
5704        if self.long_running.is_some() {
5705            state.serialize_entry("longRunning", &self.long_running)?;
5706        }
5707        if !self.auto_populated_fields.is_empty() {
5708            state.serialize_entry("autoPopulatedFields", &self.auto_populated_fields)?;
5709        }
5710        if !self._unknown_fields.is_empty() {
5711            for (key, value) in self._unknown_fields.iter() {
5712                state.serialize_entry(key, &value)?;
5713            }
5714        }
5715        state.end()
5716    }
5717}
5718
5719/// Defines additional types related to [MethodSettings].
5720pub mod method_settings {
5721    #[allow(unused_imports)]
5722    use super::*;
5723
5724    /// Describes settings to use when generating API methods that use the
5725    /// long-running operation pattern.
5726    /// All default values below are from those used in the client library
5727    /// generators (e.g.
5728    /// [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)).
5729    #[derive(Clone, Debug, Default, PartialEq)]
5730    #[non_exhaustive]
5731    pub struct LongRunning {
5732        /// Initial delay after which the first poll request will be made.
5733        /// Default value: 5 seconds.
5734        pub initial_poll_delay: std::option::Option<wkt::Duration>,
5735
5736        /// Multiplier to gradually increase delay between subsequent polls until it
5737        /// reaches max_poll_delay.
5738        /// Default value: 1.5.
5739        pub poll_delay_multiplier: f32,
5740
5741        /// Maximum time between two subsequent poll requests.
5742        /// Default value: 45 seconds.
5743        pub max_poll_delay: std::option::Option<wkt::Duration>,
5744
5745        /// Total polling timeout.
5746        /// Default value: 5 minutes.
5747        pub total_poll_timeout: std::option::Option<wkt::Duration>,
5748
5749        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5750    }
5751
5752    impl LongRunning {
5753        pub fn new() -> Self {
5754            std::default::Default::default()
5755        }
5756
5757        /// Sets the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
5758        pub fn set_initial_poll_delay<T>(mut self, v: T) -> Self
5759        where
5760            T: std::convert::Into<wkt::Duration>,
5761        {
5762            self.initial_poll_delay = std::option::Option::Some(v.into());
5763            self
5764        }
5765
5766        /// Sets or clears the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
5767        pub fn set_or_clear_initial_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
5768        where
5769            T: std::convert::Into<wkt::Duration>,
5770        {
5771            self.initial_poll_delay = v.map(|x| x.into());
5772            self
5773        }
5774
5775        /// Sets the value of [poll_delay_multiplier][crate::model::method_settings::LongRunning::poll_delay_multiplier].
5776        pub fn set_poll_delay_multiplier<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
5777            self.poll_delay_multiplier = v.into();
5778            self
5779        }
5780
5781        /// Sets the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
5782        pub fn set_max_poll_delay<T>(mut self, v: T) -> Self
5783        where
5784            T: std::convert::Into<wkt::Duration>,
5785        {
5786            self.max_poll_delay = std::option::Option::Some(v.into());
5787            self
5788        }
5789
5790        /// Sets or clears the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
5791        pub fn set_or_clear_max_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
5792        where
5793            T: std::convert::Into<wkt::Duration>,
5794        {
5795            self.max_poll_delay = v.map(|x| x.into());
5796            self
5797        }
5798
5799        /// Sets the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
5800        pub fn set_total_poll_timeout<T>(mut self, v: T) -> Self
5801        where
5802            T: std::convert::Into<wkt::Duration>,
5803        {
5804            self.total_poll_timeout = std::option::Option::Some(v.into());
5805            self
5806        }
5807
5808        /// Sets or clears the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
5809        pub fn set_or_clear_total_poll_timeout<T>(mut self, v: std::option::Option<T>) -> Self
5810        where
5811            T: std::convert::Into<wkt::Duration>,
5812        {
5813            self.total_poll_timeout = v.map(|x| x.into());
5814            self
5815        }
5816    }
5817
5818    impl wkt::message::Message for LongRunning {
5819        fn typename() -> &'static str {
5820            "type.googleapis.com/google.api.MethodSettings.LongRunning"
5821        }
5822    }
5823
5824    #[doc(hidden)]
5825    impl<'de> serde::de::Deserialize<'de> for LongRunning {
5826        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5827        where
5828            D: serde::Deserializer<'de>,
5829        {
5830            #[allow(non_camel_case_types)]
5831            #[doc(hidden)]
5832            #[derive(PartialEq, Eq, Hash)]
5833            enum __FieldTag {
5834                __initial_poll_delay,
5835                __poll_delay_multiplier,
5836                __max_poll_delay,
5837                __total_poll_timeout,
5838                Unknown(std::string::String),
5839            }
5840            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5841                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5842                where
5843                    D: serde::Deserializer<'de>,
5844                {
5845                    struct Visitor;
5846                    impl<'de> serde::de::Visitor<'de> for Visitor {
5847                        type Value = __FieldTag;
5848                        fn expecting(
5849                            &self,
5850                            formatter: &mut std::fmt::Formatter,
5851                        ) -> std::fmt::Result {
5852                            formatter.write_str("a field name for LongRunning")
5853                        }
5854                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5855                        where
5856                            E: serde::de::Error,
5857                        {
5858                            use std::result::Result::Ok;
5859                            use std::string::ToString;
5860                            match value {
5861                                "initialPollDelay" => Ok(__FieldTag::__initial_poll_delay),
5862                                "initial_poll_delay" => Ok(__FieldTag::__initial_poll_delay),
5863                                "pollDelayMultiplier" => Ok(__FieldTag::__poll_delay_multiplier),
5864                                "poll_delay_multiplier" => Ok(__FieldTag::__poll_delay_multiplier),
5865                                "maxPollDelay" => Ok(__FieldTag::__max_poll_delay),
5866                                "max_poll_delay" => Ok(__FieldTag::__max_poll_delay),
5867                                "totalPollTimeout" => Ok(__FieldTag::__total_poll_timeout),
5868                                "total_poll_timeout" => Ok(__FieldTag::__total_poll_timeout),
5869                                _ => Ok(__FieldTag::Unknown(value.to_string())),
5870                            }
5871                        }
5872                    }
5873                    deserializer.deserialize_identifier(Visitor)
5874                }
5875            }
5876            struct Visitor;
5877            impl<'de> serde::de::Visitor<'de> for Visitor {
5878                type Value = LongRunning;
5879                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5880                    formatter.write_str("struct LongRunning")
5881                }
5882                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5883                where
5884                    A: serde::de::MapAccess<'de>,
5885                {
5886                    #[allow(unused_imports)]
5887                    use serde::de::Error;
5888                    use std::option::Option::Some;
5889                    let mut fields = std::collections::HashSet::new();
5890                    let mut result = Self::Value::new();
5891                    while let Some(tag) = map.next_key::<__FieldTag>()? {
5892                        #[allow(clippy::match_single_binding)]
5893                        match tag {
5894                            __FieldTag::__initial_poll_delay => {
5895                                if !fields.insert(__FieldTag::__initial_poll_delay) {
5896                                    return std::result::Result::Err(A::Error::duplicate_field(
5897                                        "multiple values for initial_poll_delay",
5898                                    ));
5899                                }
5900                                result.initial_poll_delay =
5901                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
5902                            }
5903                            __FieldTag::__poll_delay_multiplier => {
5904                                if !fields.insert(__FieldTag::__poll_delay_multiplier) {
5905                                    return std::result::Result::Err(A::Error::duplicate_field(
5906                                        "multiple values for poll_delay_multiplier",
5907                                    ));
5908                                }
5909                                struct __With(std::option::Option<f32>);
5910                                impl<'de> serde::de::Deserialize<'de> for __With {
5911                                    fn deserialize<D>(
5912                                        deserializer: D,
5913                                    ) -> std::result::Result<Self, D::Error>
5914                                    where
5915                                        D: serde::de::Deserializer<'de>,
5916                                    {
5917                                        serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
5918                                    }
5919                                }
5920                                result.poll_delay_multiplier =
5921                                    map.next_value::<__With>()?.0.unwrap_or_default();
5922                            }
5923                            __FieldTag::__max_poll_delay => {
5924                                if !fields.insert(__FieldTag::__max_poll_delay) {
5925                                    return std::result::Result::Err(A::Error::duplicate_field(
5926                                        "multiple values for max_poll_delay",
5927                                    ));
5928                                }
5929                                result.max_poll_delay =
5930                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
5931                            }
5932                            __FieldTag::__total_poll_timeout => {
5933                                if !fields.insert(__FieldTag::__total_poll_timeout) {
5934                                    return std::result::Result::Err(A::Error::duplicate_field(
5935                                        "multiple values for total_poll_timeout",
5936                                    ));
5937                                }
5938                                result.total_poll_timeout =
5939                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
5940                            }
5941                            __FieldTag::Unknown(key) => {
5942                                let value = map.next_value::<serde_json::Value>()?;
5943                                result._unknown_fields.insert(key, value);
5944                            }
5945                        }
5946                    }
5947                    std::result::Result::Ok(result)
5948                }
5949            }
5950            deserializer.deserialize_any(Visitor)
5951        }
5952    }
5953
5954    #[doc(hidden)]
5955    impl serde::ser::Serialize for LongRunning {
5956        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5957        where
5958            S: serde::ser::Serializer,
5959        {
5960            use serde::ser::SerializeMap;
5961            #[allow(unused_imports)]
5962            use std::option::Option::Some;
5963            let mut state = serializer.serialize_map(std::option::Option::None)?;
5964            if self.initial_poll_delay.is_some() {
5965                state.serialize_entry("initialPollDelay", &self.initial_poll_delay)?;
5966            }
5967            if !wkt::internal::is_default(&self.poll_delay_multiplier) {
5968                struct __With<'a>(&'a f32);
5969                impl<'a> serde::ser::Serialize for __With<'a> {
5970                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5971                    where
5972                        S: serde::ser::Serializer,
5973                    {
5974                        serde_with::As::<wkt::internal::F32>::serialize(self.0, serializer)
5975                    }
5976                }
5977                state
5978                    .serialize_entry("pollDelayMultiplier", &__With(&self.poll_delay_multiplier))?;
5979            }
5980            if self.max_poll_delay.is_some() {
5981                state.serialize_entry("maxPollDelay", &self.max_poll_delay)?;
5982            }
5983            if self.total_poll_timeout.is_some() {
5984                state.serialize_entry("totalPollTimeout", &self.total_poll_timeout)?;
5985            }
5986            if !self._unknown_fields.is_empty() {
5987                for (key, value) in self._unknown_fields.iter() {
5988                    state.serialize_entry(key, &value)?;
5989                }
5990            }
5991            state.end()
5992        }
5993    }
5994}
5995
5996/// This message is used to configure the generation of a subset of the RPCs in
5997/// a service for client libraries.
5998#[derive(Clone, Debug, Default, PartialEq)]
5999#[non_exhaustive]
6000pub struct SelectiveGapicGeneration {
6001    /// An allowlist of the fully qualified names of RPCs that should be included
6002    /// on public client surfaces.
6003    pub methods: std::vec::Vec<std::string::String>,
6004
6005    /// Setting this to true indicates to the client generators that methods
6006    /// that would be excluded from the generation should instead be generated
6007    /// in a way that indicates these methods should not be consumed by
6008    /// end users. How this is expressed is up to individual language
6009    /// implementations to decide. Some examples may be: added annotations,
6010    /// obfuscated identifiers, or other language idiomatic patterns.
6011    pub generate_omitted_as_internal: bool,
6012
6013    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6014}
6015
6016impl SelectiveGapicGeneration {
6017    pub fn new() -> Self {
6018        std::default::Default::default()
6019    }
6020
6021    /// Sets the value of [methods][crate::model::SelectiveGapicGeneration::methods].
6022    pub fn set_methods<T, V>(mut self, v: T) -> Self
6023    where
6024        T: std::iter::IntoIterator<Item = V>,
6025        V: std::convert::Into<std::string::String>,
6026    {
6027        use std::iter::Iterator;
6028        self.methods = v.into_iter().map(|i| i.into()).collect();
6029        self
6030    }
6031
6032    /// Sets the value of [generate_omitted_as_internal][crate::model::SelectiveGapicGeneration::generate_omitted_as_internal].
6033    pub fn set_generate_omitted_as_internal<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6034        self.generate_omitted_as_internal = v.into();
6035        self
6036    }
6037}
6038
6039impl wkt::message::Message for SelectiveGapicGeneration {
6040    fn typename() -> &'static str {
6041        "type.googleapis.com/google.api.SelectiveGapicGeneration"
6042    }
6043}
6044
6045#[doc(hidden)]
6046impl<'de> serde::de::Deserialize<'de> for SelectiveGapicGeneration {
6047    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6048    where
6049        D: serde::Deserializer<'de>,
6050    {
6051        #[allow(non_camel_case_types)]
6052        #[doc(hidden)]
6053        #[derive(PartialEq, Eq, Hash)]
6054        enum __FieldTag {
6055            __methods,
6056            __generate_omitted_as_internal,
6057            Unknown(std::string::String),
6058        }
6059        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6060            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6061            where
6062                D: serde::Deserializer<'de>,
6063            {
6064                struct Visitor;
6065                impl<'de> serde::de::Visitor<'de> for Visitor {
6066                    type Value = __FieldTag;
6067                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6068                        formatter.write_str("a field name for SelectiveGapicGeneration")
6069                    }
6070                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6071                    where
6072                        E: serde::de::Error,
6073                    {
6074                        use std::result::Result::Ok;
6075                        use std::string::ToString;
6076                        match value {
6077                            "methods" => Ok(__FieldTag::__methods),
6078                            "generateOmittedAsInternal" => {
6079                                Ok(__FieldTag::__generate_omitted_as_internal)
6080                            }
6081                            "generate_omitted_as_internal" => {
6082                                Ok(__FieldTag::__generate_omitted_as_internal)
6083                            }
6084                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6085                        }
6086                    }
6087                }
6088                deserializer.deserialize_identifier(Visitor)
6089            }
6090        }
6091        struct Visitor;
6092        impl<'de> serde::de::Visitor<'de> for Visitor {
6093            type Value = SelectiveGapicGeneration;
6094            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6095                formatter.write_str("struct SelectiveGapicGeneration")
6096            }
6097            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6098            where
6099                A: serde::de::MapAccess<'de>,
6100            {
6101                #[allow(unused_imports)]
6102                use serde::de::Error;
6103                use std::option::Option::Some;
6104                let mut fields = std::collections::HashSet::new();
6105                let mut result = Self::Value::new();
6106                while let Some(tag) = map.next_key::<__FieldTag>()? {
6107                    #[allow(clippy::match_single_binding)]
6108                    match tag {
6109                        __FieldTag::__methods => {
6110                            if !fields.insert(__FieldTag::__methods) {
6111                                return std::result::Result::Err(A::Error::duplicate_field(
6112                                    "multiple values for methods",
6113                                ));
6114                            }
6115                            result.methods = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6116                        }
6117                        __FieldTag::__generate_omitted_as_internal => {
6118                            if !fields.insert(__FieldTag::__generate_omitted_as_internal) {
6119                                return std::result::Result::Err(A::Error::duplicate_field(
6120                                    "multiple values for generate_omitted_as_internal",
6121                                ));
6122                            }
6123                            result.generate_omitted_as_internal = map
6124                                .next_value::<std::option::Option<bool>>()?
6125                                .unwrap_or_default();
6126                        }
6127                        __FieldTag::Unknown(key) => {
6128                            let value = map.next_value::<serde_json::Value>()?;
6129                            result._unknown_fields.insert(key, value);
6130                        }
6131                    }
6132                }
6133                std::result::Result::Ok(result)
6134            }
6135        }
6136        deserializer.deserialize_any(Visitor)
6137    }
6138}
6139
6140#[doc(hidden)]
6141impl serde::ser::Serialize for SelectiveGapicGeneration {
6142    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6143    where
6144        S: serde::ser::Serializer,
6145    {
6146        use serde::ser::SerializeMap;
6147        #[allow(unused_imports)]
6148        use std::option::Option::Some;
6149        let mut state = serializer.serialize_map(std::option::Option::None)?;
6150        if !self.methods.is_empty() {
6151            state.serialize_entry("methods", &self.methods)?;
6152        }
6153        if !wkt::internal::is_default(&self.generate_omitted_as_internal) {
6154            state.serialize_entry(
6155                "generateOmittedAsInternal",
6156                &self.generate_omitted_as_internal,
6157            )?;
6158        }
6159        if !self._unknown_fields.is_empty() {
6160            for (key, value) in self._unknown_fields.iter() {
6161                state.serialize_entry(key, &value)?;
6162            }
6163        }
6164        state.end()
6165    }
6166}
6167
6168/// Output generated from semantically comparing two versions of a service
6169/// configuration.
6170///
6171/// Includes detailed information about a field that have changed with
6172/// applicable advice about potential consequences for the change, such as
6173/// backwards-incompatibility.
6174#[derive(Clone, Debug, Default, PartialEq)]
6175#[non_exhaustive]
6176pub struct ConfigChange {
6177    /// Object hierarchy path to the change, with levels separated by a '.'
6178    /// character. For repeated fields, an applicable unique identifier field is
6179    /// used for the index (usually selector, name, or id). For maps, the term
6180    /// 'key' is used. If the field has no unique identifier, the numeric index
6181    /// is used.
6182    /// Examples:
6183    ///
6184    /// - visibility.rules[selector=="google.LibraryService.ListBooks"].restriction
6185    /// - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value
6186    /// - logging.producer_destinations[0]
6187    pub element: std::string::String,
6188
6189    /// Value of the changed object in the old Service configuration,
6190    /// in JSON format. This field will not be populated if ChangeType == ADDED.
6191    pub old_value: std::string::String,
6192
6193    /// Value of the changed object in the new Service configuration,
6194    /// in JSON format. This field will not be populated if ChangeType == REMOVED.
6195    pub new_value: std::string::String,
6196
6197    /// The type for this change, either ADDED, REMOVED, or MODIFIED.
6198    pub change_type: crate::model::ChangeType,
6199
6200    /// Collection of advice provided for this change, useful for determining the
6201    /// possible impact of this change.
6202    pub advices: std::vec::Vec<crate::model::Advice>,
6203
6204    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6205}
6206
6207impl ConfigChange {
6208    pub fn new() -> Self {
6209        std::default::Default::default()
6210    }
6211
6212    /// Sets the value of [element][crate::model::ConfigChange::element].
6213    pub fn set_element<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6214        self.element = v.into();
6215        self
6216    }
6217
6218    /// Sets the value of [old_value][crate::model::ConfigChange::old_value].
6219    pub fn set_old_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6220        self.old_value = v.into();
6221        self
6222    }
6223
6224    /// Sets the value of [new_value][crate::model::ConfigChange::new_value].
6225    pub fn set_new_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6226        self.new_value = v.into();
6227        self
6228    }
6229
6230    /// Sets the value of [change_type][crate::model::ConfigChange::change_type].
6231    pub fn set_change_type<T: std::convert::Into<crate::model::ChangeType>>(
6232        mut self,
6233        v: T,
6234    ) -> Self {
6235        self.change_type = v.into();
6236        self
6237    }
6238
6239    /// Sets the value of [advices][crate::model::ConfigChange::advices].
6240    pub fn set_advices<T, V>(mut self, v: T) -> Self
6241    where
6242        T: std::iter::IntoIterator<Item = V>,
6243        V: std::convert::Into<crate::model::Advice>,
6244    {
6245        use std::iter::Iterator;
6246        self.advices = v.into_iter().map(|i| i.into()).collect();
6247        self
6248    }
6249}
6250
6251impl wkt::message::Message for ConfigChange {
6252    fn typename() -> &'static str {
6253        "type.googleapis.com/google.api.ConfigChange"
6254    }
6255}
6256
6257#[doc(hidden)]
6258impl<'de> serde::de::Deserialize<'de> for ConfigChange {
6259    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6260    where
6261        D: serde::Deserializer<'de>,
6262    {
6263        #[allow(non_camel_case_types)]
6264        #[doc(hidden)]
6265        #[derive(PartialEq, Eq, Hash)]
6266        enum __FieldTag {
6267            __element,
6268            __old_value,
6269            __new_value,
6270            __change_type,
6271            __advices,
6272            Unknown(std::string::String),
6273        }
6274        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6275            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6276            where
6277                D: serde::Deserializer<'de>,
6278            {
6279                struct Visitor;
6280                impl<'de> serde::de::Visitor<'de> for Visitor {
6281                    type Value = __FieldTag;
6282                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6283                        formatter.write_str("a field name for ConfigChange")
6284                    }
6285                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6286                    where
6287                        E: serde::de::Error,
6288                    {
6289                        use std::result::Result::Ok;
6290                        use std::string::ToString;
6291                        match value {
6292                            "element" => Ok(__FieldTag::__element),
6293                            "oldValue" => Ok(__FieldTag::__old_value),
6294                            "old_value" => Ok(__FieldTag::__old_value),
6295                            "newValue" => Ok(__FieldTag::__new_value),
6296                            "new_value" => Ok(__FieldTag::__new_value),
6297                            "changeType" => Ok(__FieldTag::__change_type),
6298                            "change_type" => Ok(__FieldTag::__change_type),
6299                            "advices" => Ok(__FieldTag::__advices),
6300                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6301                        }
6302                    }
6303                }
6304                deserializer.deserialize_identifier(Visitor)
6305            }
6306        }
6307        struct Visitor;
6308        impl<'de> serde::de::Visitor<'de> for Visitor {
6309            type Value = ConfigChange;
6310            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6311                formatter.write_str("struct ConfigChange")
6312            }
6313            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6314            where
6315                A: serde::de::MapAccess<'de>,
6316            {
6317                #[allow(unused_imports)]
6318                use serde::de::Error;
6319                use std::option::Option::Some;
6320                let mut fields = std::collections::HashSet::new();
6321                let mut result = Self::Value::new();
6322                while let Some(tag) = map.next_key::<__FieldTag>()? {
6323                    #[allow(clippy::match_single_binding)]
6324                    match tag {
6325                        __FieldTag::__element => {
6326                            if !fields.insert(__FieldTag::__element) {
6327                                return std::result::Result::Err(A::Error::duplicate_field(
6328                                    "multiple values for element",
6329                                ));
6330                            }
6331                            result.element = map
6332                                .next_value::<std::option::Option<std::string::String>>()?
6333                                .unwrap_or_default();
6334                        }
6335                        __FieldTag::__old_value => {
6336                            if !fields.insert(__FieldTag::__old_value) {
6337                                return std::result::Result::Err(A::Error::duplicate_field(
6338                                    "multiple values for old_value",
6339                                ));
6340                            }
6341                            result.old_value = map
6342                                .next_value::<std::option::Option<std::string::String>>()?
6343                                .unwrap_or_default();
6344                        }
6345                        __FieldTag::__new_value => {
6346                            if !fields.insert(__FieldTag::__new_value) {
6347                                return std::result::Result::Err(A::Error::duplicate_field(
6348                                    "multiple values for new_value",
6349                                ));
6350                            }
6351                            result.new_value = map
6352                                .next_value::<std::option::Option<std::string::String>>()?
6353                                .unwrap_or_default();
6354                        }
6355                        __FieldTag::__change_type => {
6356                            if !fields.insert(__FieldTag::__change_type) {
6357                                return std::result::Result::Err(A::Error::duplicate_field(
6358                                    "multiple values for change_type",
6359                                ));
6360                            }
6361                            result.change_type = map
6362                                .next_value::<std::option::Option<crate::model::ChangeType>>()?
6363                                .unwrap_or_default();
6364                        }
6365                        __FieldTag::__advices => {
6366                            if !fields.insert(__FieldTag::__advices) {
6367                                return std::result::Result::Err(A::Error::duplicate_field(
6368                                    "multiple values for advices",
6369                                ));
6370                            }
6371                            result.advices = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Advice>>>()?.unwrap_or_default();
6372                        }
6373                        __FieldTag::Unknown(key) => {
6374                            let value = map.next_value::<serde_json::Value>()?;
6375                            result._unknown_fields.insert(key, value);
6376                        }
6377                    }
6378                }
6379                std::result::Result::Ok(result)
6380            }
6381        }
6382        deserializer.deserialize_any(Visitor)
6383    }
6384}
6385
6386#[doc(hidden)]
6387impl serde::ser::Serialize for ConfigChange {
6388    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6389    where
6390        S: serde::ser::Serializer,
6391    {
6392        use serde::ser::SerializeMap;
6393        #[allow(unused_imports)]
6394        use std::option::Option::Some;
6395        let mut state = serializer.serialize_map(std::option::Option::None)?;
6396        if !self.element.is_empty() {
6397            state.serialize_entry("element", &self.element)?;
6398        }
6399        if !self.old_value.is_empty() {
6400            state.serialize_entry("oldValue", &self.old_value)?;
6401        }
6402        if !self.new_value.is_empty() {
6403            state.serialize_entry("newValue", &self.new_value)?;
6404        }
6405        if !wkt::internal::is_default(&self.change_type) {
6406            state.serialize_entry("changeType", &self.change_type)?;
6407        }
6408        if !self.advices.is_empty() {
6409            state.serialize_entry("advices", &self.advices)?;
6410        }
6411        if !self._unknown_fields.is_empty() {
6412            for (key, value) in self._unknown_fields.iter() {
6413                state.serialize_entry(key, &value)?;
6414            }
6415        }
6416        state.end()
6417    }
6418}
6419
6420/// Generated advice about this change, used for providing more
6421/// information about how a change will affect the existing service.
6422#[derive(Clone, Debug, Default, PartialEq)]
6423#[non_exhaustive]
6424pub struct Advice {
6425    /// Useful description for why this advice was applied and what actions should
6426    /// be taken to mitigate any implied risks.
6427    pub description: std::string::String,
6428
6429    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6430}
6431
6432impl Advice {
6433    pub fn new() -> Self {
6434        std::default::Default::default()
6435    }
6436
6437    /// Sets the value of [description][crate::model::Advice::description].
6438    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6439        self.description = v.into();
6440        self
6441    }
6442}
6443
6444impl wkt::message::Message for Advice {
6445    fn typename() -> &'static str {
6446        "type.googleapis.com/google.api.Advice"
6447    }
6448}
6449
6450#[doc(hidden)]
6451impl<'de> serde::de::Deserialize<'de> for Advice {
6452    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6453    where
6454        D: serde::Deserializer<'de>,
6455    {
6456        #[allow(non_camel_case_types)]
6457        #[doc(hidden)]
6458        #[derive(PartialEq, Eq, Hash)]
6459        enum __FieldTag {
6460            __description,
6461            Unknown(std::string::String),
6462        }
6463        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6464            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6465            where
6466                D: serde::Deserializer<'de>,
6467            {
6468                struct Visitor;
6469                impl<'de> serde::de::Visitor<'de> for Visitor {
6470                    type Value = __FieldTag;
6471                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6472                        formatter.write_str("a field name for Advice")
6473                    }
6474                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6475                    where
6476                        E: serde::de::Error,
6477                    {
6478                        use std::result::Result::Ok;
6479                        use std::string::ToString;
6480                        match value {
6481                            "description" => Ok(__FieldTag::__description),
6482                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6483                        }
6484                    }
6485                }
6486                deserializer.deserialize_identifier(Visitor)
6487            }
6488        }
6489        struct Visitor;
6490        impl<'de> serde::de::Visitor<'de> for Visitor {
6491            type Value = Advice;
6492            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6493                formatter.write_str("struct Advice")
6494            }
6495            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6496            where
6497                A: serde::de::MapAccess<'de>,
6498            {
6499                #[allow(unused_imports)]
6500                use serde::de::Error;
6501                use std::option::Option::Some;
6502                let mut fields = std::collections::HashSet::new();
6503                let mut result = Self::Value::new();
6504                while let Some(tag) = map.next_key::<__FieldTag>()? {
6505                    #[allow(clippy::match_single_binding)]
6506                    match tag {
6507                        __FieldTag::__description => {
6508                            if !fields.insert(__FieldTag::__description) {
6509                                return std::result::Result::Err(A::Error::duplicate_field(
6510                                    "multiple values for description",
6511                                ));
6512                            }
6513                            result.description = map
6514                                .next_value::<std::option::Option<std::string::String>>()?
6515                                .unwrap_or_default();
6516                        }
6517                        __FieldTag::Unknown(key) => {
6518                            let value = map.next_value::<serde_json::Value>()?;
6519                            result._unknown_fields.insert(key, value);
6520                        }
6521                    }
6522                }
6523                std::result::Result::Ok(result)
6524            }
6525        }
6526        deserializer.deserialize_any(Visitor)
6527    }
6528}
6529
6530#[doc(hidden)]
6531impl serde::ser::Serialize for Advice {
6532    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6533    where
6534        S: serde::ser::Serializer,
6535    {
6536        use serde::ser::SerializeMap;
6537        #[allow(unused_imports)]
6538        use std::option::Option::Some;
6539        let mut state = serializer.serialize_map(std::option::Option::None)?;
6540        if !self.description.is_empty() {
6541            state.serialize_entry("description", &self.description)?;
6542        }
6543        if !self._unknown_fields.is_empty() {
6544            for (key, value) in self._unknown_fields.iter() {
6545                state.serialize_entry(key, &value)?;
6546            }
6547        }
6548        state.end()
6549    }
6550}
6551
6552/// A descriptor for defining project properties for a service. One service may
6553/// have many consumer projects, and the service may want to behave differently
6554/// depending on some properties on the project. For example, a project may be
6555/// associated with a school, or a business, or a government agency, a business
6556/// type property on the project may affect how a service responds to the client.
6557/// This descriptor defines which properties are allowed to be set on a project.
6558///
6559/// Example:
6560///
6561/// ```norust
6562/// project_properties:
6563///   properties:
6564///   - name: NO_WATERMARK
6565///     type: BOOL
6566///     description: Allows usage of the API without watermarks.
6567///   - name: EXTENDED_TILE_CACHE_PERIOD
6568///     type: INT64
6569/// ```
6570#[derive(Clone, Debug, Default, PartialEq)]
6571#[non_exhaustive]
6572pub struct ProjectProperties {
6573    /// List of per consumer project-specific properties.
6574    pub properties: std::vec::Vec<crate::model::Property>,
6575
6576    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6577}
6578
6579impl ProjectProperties {
6580    pub fn new() -> Self {
6581        std::default::Default::default()
6582    }
6583
6584    /// Sets the value of [properties][crate::model::ProjectProperties::properties].
6585    pub fn set_properties<T, V>(mut self, v: T) -> Self
6586    where
6587        T: std::iter::IntoIterator<Item = V>,
6588        V: std::convert::Into<crate::model::Property>,
6589    {
6590        use std::iter::Iterator;
6591        self.properties = v.into_iter().map(|i| i.into()).collect();
6592        self
6593    }
6594}
6595
6596impl wkt::message::Message for ProjectProperties {
6597    fn typename() -> &'static str {
6598        "type.googleapis.com/google.api.ProjectProperties"
6599    }
6600}
6601
6602#[doc(hidden)]
6603impl<'de> serde::de::Deserialize<'de> for ProjectProperties {
6604    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6605    where
6606        D: serde::Deserializer<'de>,
6607    {
6608        #[allow(non_camel_case_types)]
6609        #[doc(hidden)]
6610        #[derive(PartialEq, Eq, Hash)]
6611        enum __FieldTag {
6612            __properties,
6613            Unknown(std::string::String),
6614        }
6615        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6616            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6617            where
6618                D: serde::Deserializer<'de>,
6619            {
6620                struct Visitor;
6621                impl<'de> serde::de::Visitor<'de> for Visitor {
6622                    type Value = __FieldTag;
6623                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6624                        formatter.write_str("a field name for ProjectProperties")
6625                    }
6626                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6627                    where
6628                        E: serde::de::Error,
6629                    {
6630                        use std::result::Result::Ok;
6631                        use std::string::ToString;
6632                        match value {
6633                            "properties" => Ok(__FieldTag::__properties),
6634                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6635                        }
6636                    }
6637                }
6638                deserializer.deserialize_identifier(Visitor)
6639            }
6640        }
6641        struct Visitor;
6642        impl<'de> serde::de::Visitor<'de> for Visitor {
6643            type Value = ProjectProperties;
6644            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6645                formatter.write_str("struct ProjectProperties")
6646            }
6647            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6648            where
6649                A: serde::de::MapAccess<'de>,
6650            {
6651                #[allow(unused_imports)]
6652                use serde::de::Error;
6653                use std::option::Option::Some;
6654                let mut fields = std::collections::HashSet::new();
6655                let mut result = Self::Value::new();
6656                while let Some(tag) = map.next_key::<__FieldTag>()? {
6657                    #[allow(clippy::match_single_binding)]
6658                    match tag {
6659                        __FieldTag::__properties => {
6660                            if !fields.insert(__FieldTag::__properties) {
6661                                return std::result::Result::Err(A::Error::duplicate_field(
6662                                    "multiple values for properties",
6663                                ));
6664                            }
6665                            result.properties = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Property>>>()?.unwrap_or_default();
6666                        }
6667                        __FieldTag::Unknown(key) => {
6668                            let value = map.next_value::<serde_json::Value>()?;
6669                            result._unknown_fields.insert(key, value);
6670                        }
6671                    }
6672                }
6673                std::result::Result::Ok(result)
6674            }
6675        }
6676        deserializer.deserialize_any(Visitor)
6677    }
6678}
6679
6680#[doc(hidden)]
6681impl serde::ser::Serialize for ProjectProperties {
6682    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6683    where
6684        S: serde::ser::Serializer,
6685    {
6686        use serde::ser::SerializeMap;
6687        #[allow(unused_imports)]
6688        use std::option::Option::Some;
6689        let mut state = serializer.serialize_map(std::option::Option::None)?;
6690        if !self.properties.is_empty() {
6691            state.serialize_entry("properties", &self.properties)?;
6692        }
6693        if !self._unknown_fields.is_empty() {
6694            for (key, value) in self._unknown_fields.iter() {
6695                state.serialize_entry(key, &value)?;
6696            }
6697        }
6698        state.end()
6699    }
6700}
6701
6702/// Defines project properties.
6703///
6704/// API services can define properties that can be assigned to consumer projects
6705/// so that backends can perform response customization without having to make
6706/// additional calls or maintain additional storage. For example, Maps API
6707/// defines properties that controls map tile cache period, or whether to embed a
6708/// watermark in a result.
6709///
6710/// These values can be set via API producer console. Only API providers can
6711/// define and set these properties.
6712#[derive(Clone, Debug, Default, PartialEq)]
6713#[non_exhaustive]
6714pub struct Property {
6715    /// The name of the property (a.k.a key).
6716    pub name: std::string::String,
6717
6718    /// The type of this property.
6719    pub r#type: crate::model::property::PropertyType,
6720
6721    /// The description of the property
6722    pub description: std::string::String,
6723
6724    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6725}
6726
6727impl Property {
6728    pub fn new() -> Self {
6729        std::default::Default::default()
6730    }
6731
6732    /// Sets the value of [name][crate::model::Property::name].
6733    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6734        self.name = v.into();
6735        self
6736    }
6737
6738    /// Sets the value of [r#type][crate::model::Property::type].
6739    pub fn set_type<T: std::convert::Into<crate::model::property::PropertyType>>(
6740        mut self,
6741        v: T,
6742    ) -> Self {
6743        self.r#type = v.into();
6744        self
6745    }
6746
6747    /// Sets the value of [description][crate::model::Property::description].
6748    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6749        self.description = v.into();
6750        self
6751    }
6752}
6753
6754impl wkt::message::Message for Property {
6755    fn typename() -> &'static str {
6756        "type.googleapis.com/google.api.Property"
6757    }
6758}
6759
6760#[doc(hidden)]
6761impl<'de> serde::de::Deserialize<'de> for Property {
6762    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6763    where
6764        D: serde::Deserializer<'de>,
6765    {
6766        #[allow(non_camel_case_types)]
6767        #[doc(hidden)]
6768        #[derive(PartialEq, Eq, Hash)]
6769        enum __FieldTag {
6770            __name,
6771            __type,
6772            __description,
6773            Unknown(std::string::String),
6774        }
6775        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6776            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6777            where
6778                D: serde::Deserializer<'de>,
6779            {
6780                struct Visitor;
6781                impl<'de> serde::de::Visitor<'de> for Visitor {
6782                    type Value = __FieldTag;
6783                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6784                        formatter.write_str("a field name for Property")
6785                    }
6786                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6787                    where
6788                        E: serde::de::Error,
6789                    {
6790                        use std::result::Result::Ok;
6791                        use std::string::ToString;
6792                        match value {
6793                            "name" => Ok(__FieldTag::__name),
6794                            "type" => Ok(__FieldTag::__type),
6795                            "description" => Ok(__FieldTag::__description),
6796                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6797                        }
6798                    }
6799                }
6800                deserializer.deserialize_identifier(Visitor)
6801            }
6802        }
6803        struct Visitor;
6804        impl<'de> serde::de::Visitor<'de> for Visitor {
6805            type Value = Property;
6806            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6807                formatter.write_str("struct Property")
6808            }
6809            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6810            where
6811                A: serde::de::MapAccess<'de>,
6812            {
6813                #[allow(unused_imports)]
6814                use serde::de::Error;
6815                use std::option::Option::Some;
6816                let mut fields = std::collections::HashSet::new();
6817                let mut result = Self::Value::new();
6818                while let Some(tag) = map.next_key::<__FieldTag>()? {
6819                    #[allow(clippy::match_single_binding)]
6820                    match tag {
6821                        __FieldTag::__name => {
6822                            if !fields.insert(__FieldTag::__name) {
6823                                return std::result::Result::Err(A::Error::duplicate_field(
6824                                    "multiple values for name",
6825                                ));
6826                            }
6827                            result.name = map
6828                                .next_value::<std::option::Option<std::string::String>>()?
6829                                .unwrap_or_default();
6830                        }
6831                        __FieldTag::__type => {
6832                            if !fields.insert(__FieldTag::__type) {
6833                                return std::result::Result::Err(A::Error::duplicate_field(
6834                                    "multiple values for type",
6835                                ));
6836                            }
6837                            result.r#type = map.next_value::<std::option::Option<crate::model::property::PropertyType>>()?.unwrap_or_default();
6838                        }
6839                        __FieldTag::__description => {
6840                            if !fields.insert(__FieldTag::__description) {
6841                                return std::result::Result::Err(A::Error::duplicate_field(
6842                                    "multiple values for description",
6843                                ));
6844                            }
6845                            result.description = map
6846                                .next_value::<std::option::Option<std::string::String>>()?
6847                                .unwrap_or_default();
6848                        }
6849                        __FieldTag::Unknown(key) => {
6850                            let value = map.next_value::<serde_json::Value>()?;
6851                            result._unknown_fields.insert(key, value);
6852                        }
6853                    }
6854                }
6855                std::result::Result::Ok(result)
6856            }
6857        }
6858        deserializer.deserialize_any(Visitor)
6859    }
6860}
6861
6862#[doc(hidden)]
6863impl serde::ser::Serialize for Property {
6864    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6865    where
6866        S: serde::ser::Serializer,
6867    {
6868        use serde::ser::SerializeMap;
6869        #[allow(unused_imports)]
6870        use std::option::Option::Some;
6871        let mut state = serializer.serialize_map(std::option::Option::None)?;
6872        if !self.name.is_empty() {
6873            state.serialize_entry("name", &self.name)?;
6874        }
6875        if !wkt::internal::is_default(&self.r#type) {
6876            state.serialize_entry("type", &self.r#type)?;
6877        }
6878        if !self.description.is_empty() {
6879            state.serialize_entry("description", &self.description)?;
6880        }
6881        if !self._unknown_fields.is_empty() {
6882            for (key, value) in self._unknown_fields.iter() {
6883                state.serialize_entry(key, &value)?;
6884            }
6885        }
6886        state.end()
6887    }
6888}
6889
6890/// Defines additional types related to [Property].
6891pub mod property {
6892    #[allow(unused_imports)]
6893    use super::*;
6894
6895    /// Supported data type of the property values
6896    ///
6897    /// # Working with unknown values
6898    ///
6899    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6900    /// additional enum variants at any time. Adding new variants is not considered
6901    /// a breaking change. Applications should write their code in anticipation of:
6902    ///
6903    /// - New values appearing in future releases of the client library, **and**
6904    /// - New values received dynamically, without application changes.
6905    ///
6906    /// Please consult the [Working with enums] section in the user guide for some
6907    /// guidelines.
6908    ///
6909    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6910    #[derive(Clone, Debug, PartialEq)]
6911    #[non_exhaustive]
6912    pub enum PropertyType {
6913        /// The type is unspecified, and will result in an error.
6914        Unspecified,
6915        /// The type is `int64`.
6916        Int64,
6917        /// The type is `bool`.
6918        Bool,
6919        /// The type is `string`.
6920        String,
6921        /// The type is 'double'.
6922        Double,
6923        /// If set, the enum was initialized with an unknown value.
6924        ///
6925        /// Applications can examine the value using [PropertyType::value] or
6926        /// [PropertyType::name].
6927        UnknownValue(property_type::UnknownValue),
6928    }
6929
6930    #[doc(hidden)]
6931    pub mod property_type {
6932        #[allow(unused_imports)]
6933        use super::*;
6934        #[derive(Clone, Debug, PartialEq)]
6935        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6936    }
6937
6938    impl PropertyType {
6939        /// Gets the enum value.
6940        ///
6941        /// Returns `None` if the enum contains an unknown value deserialized from
6942        /// the string representation of enums.
6943        pub fn value(&self) -> std::option::Option<i32> {
6944            match self {
6945                Self::Unspecified => std::option::Option::Some(0),
6946                Self::Int64 => std::option::Option::Some(1),
6947                Self::Bool => std::option::Option::Some(2),
6948                Self::String => std::option::Option::Some(3),
6949                Self::Double => std::option::Option::Some(4),
6950                Self::UnknownValue(u) => u.0.value(),
6951            }
6952        }
6953
6954        /// Gets the enum value as a string.
6955        ///
6956        /// Returns `None` if the enum contains an unknown value deserialized from
6957        /// the integer representation of enums.
6958        pub fn name(&self) -> std::option::Option<&str> {
6959            match self {
6960                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
6961                Self::Int64 => std::option::Option::Some("INT64"),
6962                Self::Bool => std::option::Option::Some("BOOL"),
6963                Self::String => std::option::Option::Some("STRING"),
6964                Self::Double => std::option::Option::Some("DOUBLE"),
6965                Self::UnknownValue(u) => u.0.name(),
6966            }
6967        }
6968    }
6969
6970    impl std::default::Default for PropertyType {
6971        fn default() -> Self {
6972            use std::convert::From;
6973            Self::from(0)
6974        }
6975    }
6976
6977    impl std::fmt::Display for PropertyType {
6978        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6979            wkt::internal::display_enum(f, self.name(), self.value())
6980        }
6981    }
6982
6983    impl std::convert::From<i32> for PropertyType {
6984        fn from(value: i32) -> Self {
6985            match value {
6986                0 => Self::Unspecified,
6987                1 => Self::Int64,
6988                2 => Self::Bool,
6989                3 => Self::String,
6990                4 => Self::Double,
6991                _ => Self::UnknownValue(property_type::UnknownValue(
6992                    wkt::internal::UnknownEnumValue::Integer(value),
6993                )),
6994            }
6995        }
6996    }
6997
6998    impl std::convert::From<&str> for PropertyType {
6999        fn from(value: &str) -> Self {
7000            use std::string::ToString;
7001            match value {
7002                "UNSPECIFIED" => Self::Unspecified,
7003                "INT64" => Self::Int64,
7004                "BOOL" => Self::Bool,
7005                "STRING" => Self::String,
7006                "DOUBLE" => Self::Double,
7007                _ => Self::UnknownValue(property_type::UnknownValue(
7008                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7009                )),
7010            }
7011        }
7012    }
7013
7014    impl serde::ser::Serialize for PropertyType {
7015        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7016        where
7017            S: serde::Serializer,
7018        {
7019            match self {
7020                Self::Unspecified => serializer.serialize_i32(0),
7021                Self::Int64 => serializer.serialize_i32(1),
7022                Self::Bool => serializer.serialize_i32(2),
7023                Self::String => serializer.serialize_i32(3),
7024                Self::Double => serializer.serialize_i32(4),
7025                Self::UnknownValue(u) => u.0.serialize(serializer),
7026            }
7027        }
7028    }
7029
7030    impl<'de> serde::de::Deserialize<'de> for PropertyType {
7031        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7032        where
7033            D: serde::Deserializer<'de>,
7034        {
7035            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PropertyType>::new(
7036                ".google.api.Property.PropertyType",
7037            ))
7038        }
7039    }
7040}
7041
7042/// `Context` defines which contexts an API requests.
7043///
7044/// Example:
7045///
7046/// ```norust
7047/// context:
7048///   rules:
7049///   - selector: "*"
7050///     requested:
7051///     - google.rpc.context.ProjectContext
7052///     - google.rpc.context.OriginContext
7053/// ```
7054///
7055/// The above specifies that all methods in the API request
7056/// `google.rpc.context.ProjectContext` and
7057/// `google.rpc.context.OriginContext`.
7058///
7059/// Available context types are defined in package
7060/// `google.rpc.context`.
7061///
7062/// This also provides mechanism to allowlist any protobuf message extension that
7063/// can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
7064/// “x-goog-ext-<extension_id>-jspb” format. For example, list any service
7065/// specific protobuf types that can appear in grpc metadata as follows in your
7066/// yaml file:
7067///
7068/// Example:
7069///
7070/// ```norust
7071/// context:
7072///   rules:
7073///    - selector: "google.example.library.v1.LibraryService.CreateBook"
7074///      allowed_request_extensions:
7075///      - google.foo.v1.NewExtension
7076///      allowed_response_extensions:
7077///      - google.foo.v1.NewExtension
7078/// ```
7079///
7080/// You can also specify extension ID instead of fully qualified extension name
7081/// here.
7082#[derive(Clone, Debug, Default, PartialEq)]
7083#[non_exhaustive]
7084pub struct Context {
7085    /// A list of RPC context rules that apply to individual API methods.
7086    ///
7087    /// **NOTE:** All service configuration rules follow "last one wins" order.
7088    pub rules: std::vec::Vec<crate::model::ContextRule>,
7089
7090    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7091}
7092
7093impl Context {
7094    pub fn new() -> Self {
7095        std::default::Default::default()
7096    }
7097
7098    /// Sets the value of [rules][crate::model::Context::rules].
7099    pub fn set_rules<T, V>(mut self, v: T) -> Self
7100    where
7101        T: std::iter::IntoIterator<Item = V>,
7102        V: std::convert::Into<crate::model::ContextRule>,
7103    {
7104        use std::iter::Iterator;
7105        self.rules = v.into_iter().map(|i| i.into()).collect();
7106        self
7107    }
7108}
7109
7110impl wkt::message::Message for Context {
7111    fn typename() -> &'static str {
7112        "type.googleapis.com/google.api.Context"
7113    }
7114}
7115
7116#[doc(hidden)]
7117impl<'de> serde::de::Deserialize<'de> for Context {
7118    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7119    where
7120        D: serde::Deserializer<'de>,
7121    {
7122        #[allow(non_camel_case_types)]
7123        #[doc(hidden)]
7124        #[derive(PartialEq, Eq, Hash)]
7125        enum __FieldTag {
7126            __rules,
7127            Unknown(std::string::String),
7128        }
7129        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7130            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7131            where
7132                D: serde::Deserializer<'de>,
7133            {
7134                struct Visitor;
7135                impl<'de> serde::de::Visitor<'de> for Visitor {
7136                    type Value = __FieldTag;
7137                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7138                        formatter.write_str("a field name for Context")
7139                    }
7140                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7141                    where
7142                        E: serde::de::Error,
7143                    {
7144                        use std::result::Result::Ok;
7145                        use std::string::ToString;
7146                        match value {
7147                            "rules" => Ok(__FieldTag::__rules),
7148                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7149                        }
7150                    }
7151                }
7152                deserializer.deserialize_identifier(Visitor)
7153            }
7154        }
7155        struct Visitor;
7156        impl<'de> serde::de::Visitor<'de> for Visitor {
7157            type Value = Context;
7158            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7159                formatter.write_str("struct Context")
7160            }
7161            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7162            where
7163                A: serde::de::MapAccess<'de>,
7164            {
7165                #[allow(unused_imports)]
7166                use serde::de::Error;
7167                use std::option::Option::Some;
7168                let mut fields = std::collections::HashSet::new();
7169                let mut result = Self::Value::new();
7170                while let Some(tag) = map.next_key::<__FieldTag>()? {
7171                    #[allow(clippy::match_single_binding)]
7172                    match tag {
7173                        __FieldTag::__rules => {
7174                            if !fields.insert(__FieldTag::__rules) {
7175                                return std::result::Result::Err(A::Error::duplicate_field(
7176                                    "multiple values for rules",
7177                                ));
7178                            }
7179                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ContextRule>>>()?.unwrap_or_default();
7180                        }
7181                        __FieldTag::Unknown(key) => {
7182                            let value = map.next_value::<serde_json::Value>()?;
7183                            result._unknown_fields.insert(key, value);
7184                        }
7185                    }
7186                }
7187                std::result::Result::Ok(result)
7188            }
7189        }
7190        deserializer.deserialize_any(Visitor)
7191    }
7192}
7193
7194#[doc(hidden)]
7195impl serde::ser::Serialize for Context {
7196    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7197    where
7198        S: serde::ser::Serializer,
7199    {
7200        use serde::ser::SerializeMap;
7201        #[allow(unused_imports)]
7202        use std::option::Option::Some;
7203        let mut state = serializer.serialize_map(std::option::Option::None)?;
7204        if !self.rules.is_empty() {
7205            state.serialize_entry("rules", &self.rules)?;
7206        }
7207        if !self._unknown_fields.is_empty() {
7208            for (key, value) in self._unknown_fields.iter() {
7209                state.serialize_entry(key, &value)?;
7210            }
7211        }
7212        state.end()
7213    }
7214}
7215
7216/// A context rule provides information about the context for an individual API
7217/// element.
7218#[derive(Clone, Debug, Default, PartialEq)]
7219#[non_exhaustive]
7220pub struct ContextRule {
7221    /// Selects the methods to which this rule applies.
7222    ///
7223    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
7224    /// details.
7225    ///
7226    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
7227    pub selector: std::string::String,
7228
7229    /// A list of full type names of requested contexts, only the requested context
7230    /// will be made available to the backend.
7231    pub requested: std::vec::Vec<std::string::String>,
7232
7233    /// A list of full type names of provided contexts. It is used to support
7234    /// propagating HTTP headers and ETags from the response extension.
7235    pub provided: std::vec::Vec<std::string::String>,
7236
7237    /// A list of full type names or extension IDs of extensions allowed in grpc
7238    /// side channel from client to backend.
7239    pub allowed_request_extensions: std::vec::Vec<std::string::String>,
7240
7241    /// A list of full type names or extension IDs of extensions allowed in grpc
7242    /// side channel from backend to client.
7243    pub allowed_response_extensions: std::vec::Vec<std::string::String>,
7244
7245    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7246}
7247
7248impl ContextRule {
7249    pub fn new() -> Self {
7250        std::default::Default::default()
7251    }
7252
7253    /// Sets the value of [selector][crate::model::ContextRule::selector].
7254    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7255        self.selector = v.into();
7256        self
7257    }
7258
7259    /// Sets the value of [requested][crate::model::ContextRule::requested].
7260    pub fn set_requested<T, V>(mut self, v: T) -> Self
7261    where
7262        T: std::iter::IntoIterator<Item = V>,
7263        V: std::convert::Into<std::string::String>,
7264    {
7265        use std::iter::Iterator;
7266        self.requested = v.into_iter().map(|i| i.into()).collect();
7267        self
7268    }
7269
7270    /// Sets the value of [provided][crate::model::ContextRule::provided].
7271    pub fn set_provided<T, V>(mut self, v: T) -> Self
7272    where
7273        T: std::iter::IntoIterator<Item = V>,
7274        V: std::convert::Into<std::string::String>,
7275    {
7276        use std::iter::Iterator;
7277        self.provided = v.into_iter().map(|i| i.into()).collect();
7278        self
7279    }
7280
7281    /// Sets the value of [allowed_request_extensions][crate::model::ContextRule::allowed_request_extensions].
7282    pub fn set_allowed_request_extensions<T, V>(mut self, v: T) -> Self
7283    where
7284        T: std::iter::IntoIterator<Item = V>,
7285        V: std::convert::Into<std::string::String>,
7286    {
7287        use std::iter::Iterator;
7288        self.allowed_request_extensions = v.into_iter().map(|i| i.into()).collect();
7289        self
7290    }
7291
7292    /// Sets the value of [allowed_response_extensions][crate::model::ContextRule::allowed_response_extensions].
7293    pub fn set_allowed_response_extensions<T, V>(mut self, v: T) -> Self
7294    where
7295        T: std::iter::IntoIterator<Item = V>,
7296        V: std::convert::Into<std::string::String>,
7297    {
7298        use std::iter::Iterator;
7299        self.allowed_response_extensions = v.into_iter().map(|i| i.into()).collect();
7300        self
7301    }
7302}
7303
7304impl wkt::message::Message for ContextRule {
7305    fn typename() -> &'static str {
7306        "type.googleapis.com/google.api.ContextRule"
7307    }
7308}
7309
7310#[doc(hidden)]
7311impl<'de> serde::de::Deserialize<'de> for ContextRule {
7312    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7313    where
7314        D: serde::Deserializer<'de>,
7315    {
7316        #[allow(non_camel_case_types)]
7317        #[doc(hidden)]
7318        #[derive(PartialEq, Eq, Hash)]
7319        enum __FieldTag {
7320            __selector,
7321            __requested,
7322            __provided,
7323            __allowed_request_extensions,
7324            __allowed_response_extensions,
7325            Unknown(std::string::String),
7326        }
7327        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7328            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7329            where
7330                D: serde::Deserializer<'de>,
7331            {
7332                struct Visitor;
7333                impl<'de> serde::de::Visitor<'de> for Visitor {
7334                    type Value = __FieldTag;
7335                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7336                        formatter.write_str("a field name for ContextRule")
7337                    }
7338                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7339                    where
7340                        E: serde::de::Error,
7341                    {
7342                        use std::result::Result::Ok;
7343                        use std::string::ToString;
7344                        match value {
7345                            "selector" => Ok(__FieldTag::__selector),
7346                            "requested" => Ok(__FieldTag::__requested),
7347                            "provided" => Ok(__FieldTag::__provided),
7348                            "allowedRequestExtensions" => {
7349                                Ok(__FieldTag::__allowed_request_extensions)
7350                            }
7351                            "allowed_request_extensions" => {
7352                                Ok(__FieldTag::__allowed_request_extensions)
7353                            }
7354                            "allowedResponseExtensions" => {
7355                                Ok(__FieldTag::__allowed_response_extensions)
7356                            }
7357                            "allowed_response_extensions" => {
7358                                Ok(__FieldTag::__allowed_response_extensions)
7359                            }
7360                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7361                        }
7362                    }
7363                }
7364                deserializer.deserialize_identifier(Visitor)
7365            }
7366        }
7367        struct Visitor;
7368        impl<'de> serde::de::Visitor<'de> for Visitor {
7369            type Value = ContextRule;
7370            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7371                formatter.write_str("struct ContextRule")
7372            }
7373            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7374            where
7375                A: serde::de::MapAccess<'de>,
7376            {
7377                #[allow(unused_imports)]
7378                use serde::de::Error;
7379                use std::option::Option::Some;
7380                let mut fields = std::collections::HashSet::new();
7381                let mut result = Self::Value::new();
7382                while let Some(tag) = map.next_key::<__FieldTag>()? {
7383                    #[allow(clippy::match_single_binding)]
7384                    match tag {
7385                        __FieldTag::__selector => {
7386                            if !fields.insert(__FieldTag::__selector) {
7387                                return std::result::Result::Err(A::Error::duplicate_field(
7388                                    "multiple values for selector",
7389                                ));
7390                            }
7391                            result.selector = map
7392                                .next_value::<std::option::Option<std::string::String>>()?
7393                                .unwrap_or_default();
7394                        }
7395                        __FieldTag::__requested => {
7396                            if !fields.insert(__FieldTag::__requested) {
7397                                return std::result::Result::Err(A::Error::duplicate_field(
7398                                    "multiple values for requested",
7399                                ));
7400                            }
7401                            result.requested = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7402                        }
7403                        __FieldTag::__provided => {
7404                            if !fields.insert(__FieldTag::__provided) {
7405                                return std::result::Result::Err(A::Error::duplicate_field(
7406                                    "multiple values for provided",
7407                                ));
7408                            }
7409                            result.provided = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7410                        }
7411                        __FieldTag::__allowed_request_extensions => {
7412                            if !fields.insert(__FieldTag::__allowed_request_extensions) {
7413                                return std::result::Result::Err(A::Error::duplicate_field(
7414                                    "multiple values for allowed_request_extensions",
7415                                ));
7416                            }
7417                            result.allowed_request_extensions = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7418                        }
7419                        __FieldTag::__allowed_response_extensions => {
7420                            if !fields.insert(__FieldTag::__allowed_response_extensions) {
7421                                return std::result::Result::Err(A::Error::duplicate_field(
7422                                    "multiple values for allowed_response_extensions",
7423                                ));
7424                            }
7425                            result.allowed_response_extensions = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7426                        }
7427                        __FieldTag::Unknown(key) => {
7428                            let value = map.next_value::<serde_json::Value>()?;
7429                            result._unknown_fields.insert(key, value);
7430                        }
7431                    }
7432                }
7433                std::result::Result::Ok(result)
7434            }
7435        }
7436        deserializer.deserialize_any(Visitor)
7437    }
7438}
7439
7440#[doc(hidden)]
7441impl serde::ser::Serialize for ContextRule {
7442    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7443    where
7444        S: serde::ser::Serializer,
7445    {
7446        use serde::ser::SerializeMap;
7447        #[allow(unused_imports)]
7448        use std::option::Option::Some;
7449        let mut state = serializer.serialize_map(std::option::Option::None)?;
7450        if !self.selector.is_empty() {
7451            state.serialize_entry("selector", &self.selector)?;
7452        }
7453        if !self.requested.is_empty() {
7454            state.serialize_entry("requested", &self.requested)?;
7455        }
7456        if !self.provided.is_empty() {
7457            state.serialize_entry("provided", &self.provided)?;
7458        }
7459        if !self.allowed_request_extensions.is_empty() {
7460            state.serialize_entry("allowedRequestExtensions", &self.allowed_request_extensions)?;
7461        }
7462        if !self.allowed_response_extensions.is_empty() {
7463            state.serialize_entry(
7464                "allowedResponseExtensions",
7465                &self.allowed_response_extensions,
7466            )?;
7467        }
7468        if !self._unknown_fields.is_empty() {
7469            for (key, value) in self._unknown_fields.iter() {
7470                state.serialize_entry(key, &value)?;
7471            }
7472        }
7473        state.end()
7474    }
7475}
7476
7477/// Selects and configures the service controller used by the service.
7478///
7479/// Example:
7480///
7481/// ```norust
7482/// control:
7483///   environment: servicecontrol.googleapis.com
7484/// ```
7485#[derive(Clone, Debug, Default, PartialEq)]
7486#[non_exhaustive]
7487pub struct Control {
7488    /// The service controller environment to use. If empty, no control plane
7489    /// feature (like quota and billing) will be enabled. The recommended value for
7490    /// most services is servicecontrol.googleapis.com
7491    pub environment: std::string::String,
7492
7493    /// Defines policies applying to the API methods of the service.
7494    pub method_policies: std::vec::Vec<crate::model::MethodPolicy>,
7495
7496    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7497}
7498
7499impl Control {
7500    pub fn new() -> Self {
7501        std::default::Default::default()
7502    }
7503
7504    /// Sets the value of [environment][crate::model::Control::environment].
7505    pub fn set_environment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7506        self.environment = v.into();
7507        self
7508    }
7509
7510    /// Sets the value of [method_policies][crate::model::Control::method_policies].
7511    pub fn set_method_policies<T, V>(mut self, v: T) -> Self
7512    where
7513        T: std::iter::IntoIterator<Item = V>,
7514        V: std::convert::Into<crate::model::MethodPolicy>,
7515    {
7516        use std::iter::Iterator;
7517        self.method_policies = v.into_iter().map(|i| i.into()).collect();
7518        self
7519    }
7520}
7521
7522impl wkt::message::Message for Control {
7523    fn typename() -> &'static str {
7524        "type.googleapis.com/google.api.Control"
7525    }
7526}
7527
7528#[doc(hidden)]
7529impl<'de> serde::de::Deserialize<'de> for Control {
7530    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7531    where
7532        D: serde::Deserializer<'de>,
7533    {
7534        #[allow(non_camel_case_types)]
7535        #[doc(hidden)]
7536        #[derive(PartialEq, Eq, Hash)]
7537        enum __FieldTag {
7538            __environment,
7539            __method_policies,
7540            Unknown(std::string::String),
7541        }
7542        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7543            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7544            where
7545                D: serde::Deserializer<'de>,
7546            {
7547                struct Visitor;
7548                impl<'de> serde::de::Visitor<'de> for Visitor {
7549                    type Value = __FieldTag;
7550                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7551                        formatter.write_str("a field name for Control")
7552                    }
7553                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7554                    where
7555                        E: serde::de::Error,
7556                    {
7557                        use std::result::Result::Ok;
7558                        use std::string::ToString;
7559                        match value {
7560                            "environment" => Ok(__FieldTag::__environment),
7561                            "methodPolicies" => Ok(__FieldTag::__method_policies),
7562                            "method_policies" => Ok(__FieldTag::__method_policies),
7563                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7564                        }
7565                    }
7566                }
7567                deserializer.deserialize_identifier(Visitor)
7568            }
7569        }
7570        struct Visitor;
7571        impl<'de> serde::de::Visitor<'de> for Visitor {
7572            type Value = Control;
7573            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7574                formatter.write_str("struct Control")
7575            }
7576            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7577            where
7578                A: serde::de::MapAccess<'de>,
7579            {
7580                #[allow(unused_imports)]
7581                use serde::de::Error;
7582                use std::option::Option::Some;
7583                let mut fields = std::collections::HashSet::new();
7584                let mut result = Self::Value::new();
7585                while let Some(tag) = map.next_key::<__FieldTag>()? {
7586                    #[allow(clippy::match_single_binding)]
7587                    match tag {
7588                        __FieldTag::__environment => {
7589                            if !fields.insert(__FieldTag::__environment) {
7590                                return std::result::Result::Err(A::Error::duplicate_field(
7591                                    "multiple values for environment",
7592                                ));
7593                            }
7594                            result.environment = map
7595                                .next_value::<std::option::Option<std::string::String>>()?
7596                                .unwrap_or_default();
7597                        }
7598                        __FieldTag::__method_policies => {
7599                            if !fields.insert(__FieldTag::__method_policies) {
7600                                return std::result::Result::Err(A::Error::duplicate_field(
7601                                    "multiple values for method_policies",
7602                                ));
7603                            }
7604                            result.method_policies = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MethodPolicy>>>()?.unwrap_or_default();
7605                        }
7606                        __FieldTag::Unknown(key) => {
7607                            let value = map.next_value::<serde_json::Value>()?;
7608                            result._unknown_fields.insert(key, value);
7609                        }
7610                    }
7611                }
7612                std::result::Result::Ok(result)
7613            }
7614        }
7615        deserializer.deserialize_any(Visitor)
7616    }
7617}
7618
7619#[doc(hidden)]
7620impl serde::ser::Serialize for Control {
7621    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7622    where
7623        S: serde::ser::Serializer,
7624    {
7625        use serde::ser::SerializeMap;
7626        #[allow(unused_imports)]
7627        use std::option::Option::Some;
7628        let mut state = serializer.serialize_map(std::option::Option::None)?;
7629        if !self.environment.is_empty() {
7630            state.serialize_entry("environment", &self.environment)?;
7631        }
7632        if !self.method_policies.is_empty() {
7633            state.serialize_entry("methodPolicies", &self.method_policies)?;
7634        }
7635        if !self._unknown_fields.is_empty() {
7636            for (key, value) in self._unknown_fields.iter() {
7637                state.serialize_entry(key, &value)?;
7638            }
7639        }
7640        state.end()
7641    }
7642}
7643
7644/// `Distribution` contains summary statistics for a population of values. It
7645/// optionally contains a histogram representing the distribution of those values
7646/// across a set of buckets.
7647///
7648/// The summary statistics are the count, mean, sum of the squared deviation from
7649/// the mean, the minimum, and the maximum of the set of population of values.
7650/// The histogram is based on a sequence of buckets and gives a count of values
7651/// that fall into each bucket. The boundaries of the buckets are given either
7652/// explicitly or by formulas for buckets of fixed or exponentially increasing
7653/// widths.
7654///
7655/// Although it is not forbidden, it is generally a bad idea to include
7656/// non-finite values (infinities or NaNs) in the population of values, as this
7657/// will render the `mean` and `sum_of_squared_deviation` fields meaningless.
7658#[derive(Clone, Debug, Default, PartialEq)]
7659#[non_exhaustive]
7660pub struct Distribution {
7661    /// The number of values in the population. Must be non-negative. This value
7662    /// must equal the sum of the values in `bucket_counts` if a histogram is
7663    /// provided.
7664    pub count: i64,
7665
7666    /// The arithmetic mean of the values in the population. If `count` is zero
7667    /// then this field must be zero.
7668    pub mean: f64,
7669
7670    /// The sum of squared deviations from the mean of the values in the
7671    /// population. For values x_i this is:
7672    ///
7673    /// ```norust
7674    /// Sum[i=1..n]((x_i - mean)^2)
7675    /// ```
7676    ///
7677    /// Knuth, "The Art of Computer Programming", Vol. 2, page 232, 3rd edition
7678    /// describes Welford's method for accumulating this sum in one pass.
7679    ///
7680    /// If `count` is zero then this field must be zero.
7681    pub sum_of_squared_deviation: f64,
7682
7683    /// If specified, contains the range of the population values. The field
7684    /// must not be present if the `count` is zero.
7685    pub range: std::option::Option<crate::model::distribution::Range>,
7686
7687    /// Defines the histogram bucket boundaries. If the distribution does not
7688    /// contain a histogram, then omit this field.
7689    pub bucket_options: std::option::Option<crate::model::distribution::BucketOptions>,
7690
7691    /// The number of values in each bucket of the histogram, as described in
7692    /// `bucket_options`. If the distribution does not have a histogram, then omit
7693    /// this field. If there is a histogram, then the sum of the values in
7694    /// `bucket_counts` must equal the value in the `count` field of the
7695    /// distribution.
7696    ///
7697    /// If present, `bucket_counts` should contain N values, where N is the number
7698    /// of buckets specified in `bucket_options`. If you supply fewer than N
7699    /// values, the remaining values are assumed to be 0.
7700    ///
7701    /// The order of the values in `bucket_counts` follows the bucket numbering
7702    /// schemes described for the three bucket types. The first value must be the
7703    /// count for the underflow bucket (number 0). The next N-2 values are the
7704    /// counts for the finite buckets (number 1 through N-2). The N'th value in
7705    /// `bucket_counts` is the count for the overflow bucket (number N-1).
7706    pub bucket_counts: std::vec::Vec<i64>,
7707
7708    /// Must be in increasing order of `value` field.
7709    pub exemplars: std::vec::Vec<crate::model::distribution::Exemplar>,
7710
7711    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7712}
7713
7714impl Distribution {
7715    pub fn new() -> Self {
7716        std::default::Default::default()
7717    }
7718
7719    /// Sets the value of [count][crate::model::Distribution::count].
7720    pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7721        self.count = v.into();
7722        self
7723    }
7724
7725    /// Sets the value of [mean][crate::model::Distribution::mean].
7726    pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7727        self.mean = v.into();
7728        self
7729    }
7730
7731    /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
7732    pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7733        self.sum_of_squared_deviation = v.into();
7734        self
7735    }
7736
7737    /// Sets the value of [range][crate::model::Distribution::range].
7738    pub fn set_range<T>(mut self, v: T) -> Self
7739    where
7740        T: std::convert::Into<crate::model::distribution::Range>,
7741    {
7742        self.range = std::option::Option::Some(v.into());
7743        self
7744    }
7745
7746    /// Sets or clears the value of [range][crate::model::Distribution::range].
7747    pub fn set_or_clear_range<T>(mut self, v: std::option::Option<T>) -> Self
7748    where
7749        T: std::convert::Into<crate::model::distribution::Range>,
7750    {
7751        self.range = v.map(|x| x.into());
7752        self
7753    }
7754
7755    /// Sets the value of [bucket_options][crate::model::Distribution::bucket_options].
7756    pub fn set_bucket_options<T>(mut self, v: T) -> Self
7757    where
7758        T: std::convert::Into<crate::model::distribution::BucketOptions>,
7759    {
7760        self.bucket_options = std::option::Option::Some(v.into());
7761        self
7762    }
7763
7764    /// Sets or clears the value of [bucket_options][crate::model::Distribution::bucket_options].
7765    pub fn set_or_clear_bucket_options<T>(mut self, v: std::option::Option<T>) -> Self
7766    where
7767        T: std::convert::Into<crate::model::distribution::BucketOptions>,
7768    {
7769        self.bucket_options = v.map(|x| x.into());
7770        self
7771    }
7772
7773    /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
7774    pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
7775    where
7776        T: std::iter::IntoIterator<Item = V>,
7777        V: std::convert::Into<i64>,
7778    {
7779        use std::iter::Iterator;
7780        self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
7781        self
7782    }
7783
7784    /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
7785    pub fn set_exemplars<T, V>(mut self, v: T) -> Self
7786    where
7787        T: std::iter::IntoIterator<Item = V>,
7788        V: std::convert::Into<crate::model::distribution::Exemplar>,
7789    {
7790        use std::iter::Iterator;
7791        self.exemplars = v.into_iter().map(|i| i.into()).collect();
7792        self
7793    }
7794}
7795
7796impl wkt::message::Message for Distribution {
7797    fn typename() -> &'static str {
7798        "type.googleapis.com/google.api.Distribution"
7799    }
7800}
7801
7802#[doc(hidden)]
7803impl<'de> serde::de::Deserialize<'de> for Distribution {
7804    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7805    where
7806        D: serde::Deserializer<'de>,
7807    {
7808        #[allow(non_camel_case_types)]
7809        #[doc(hidden)]
7810        #[derive(PartialEq, Eq, Hash)]
7811        enum __FieldTag {
7812            __count,
7813            __mean,
7814            __sum_of_squared_deviation,
7815            __range,
7816            __bucket_options,
7817            __bucket_counts,
7818            __exemplars,
7819            Unknown(std::string::String),
7820        }
7821        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7822            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7823            where
7824                D: serde::Deserializer<'de>,
7825            {
7826                struct Visitor;
7827                impl<'de> serde::de::Visitor<'de> for Visitor {
7828                    type Value = __FieldTag;
7829                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7830                        formatter.write_str("a field name for Distribution")
7831                    }
7832                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7833                    where
7834                        E: serde::de::Error,
7835                    {
7836                        use std::result::Result::Ok;
7837                        use std::string::ToString;
7838                        match value {
7839                            "count" => Ok(__FieldTag::__count),
7840                            "mean" => Ok(__FieldTag::__mean),
7841                            "sumOfSquaredDeviation" => Ok(__FieldTag::__sum_of_squared_deviation),
7842                            "sum_of_squared_deviation" => {
7843                                Ok(__FieldTag::__sum_of_squared_deviation)
7844                            }
7845                            "range" => Ok(__FieldTag::__range),
7846                            "bucketOptions" => Ok(__FieldTag::__bucket_options),
7847                            "bucket_options" => Ok(__FieldTag::__bucket_options),
7848                            "bucketCounts" => Ok(__FieldTag::__bucket_counts),
7849                            "bucket_counts" => Ok(__FieldTag::__bucket_counts),
7850                            "exemplars" => Ok(__FieldTag::__exemplars),
7851                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7852                        }
7853                    }
7854                }
7855                deserializer.deserialize_identifier(Visitor)
7856            }
7857        }
7858        struct Visitor;
7859        impl<'de> serde::de::Visitor<'de> for Visitor {
7860            type Value = Distribution;
7861            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7862                formatter.write_str("struct Distribution")
7863            }
7864            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7865            where
7866                A: serde::de::MapAccess<'de>,
7867            {
7868                #[allow(unused_imports)]
7869                use serde::de::Error;
7870                use std::option::Option::Some;
7871                let mut fields = std::collections::HashSet::new();
7872                let mut result = Self::Value::new();
7873                while let Some(tag) = map.next_key::<__FieldTag>()? {
7874                    #[allow(clippy::match_single_binding)]
7875                    match tag {
7876                        __FieldTag::__count => {
7877                            if !fields.insert(__FieldTag::__count) {
7878                                return std::result::Result::Err(A::Error::duplicate_field(
7879                                    "multiple values for count",
7880                                ));
7881                            }
7882                            struct __With(std::option::Option<i64>);
7883                            impl<'de> serde::de::Deserialize<'de> for __With {
7884                                fn deserialize<D>(
7885                                    deserializer: D,
7886                                ) -> std::result::Result<Self, D::Error>
7887                                where
7888                                    D: serde::de::Deserializer<'de>,
7889                                {
7890                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7891                                }
7892                            }
7893                            result.count = map.next_value::<__With>()?.0.unwrap_or_default();
7894                        }
7895                        __FieldTag::__mean => {
7896                            if !fields.insert(__FieldTag::__mean) {
7897                                return std::result::Result::Err(A::Error::duplicate_field(
7898                                    "multiple values for mean",
7899                                ));
7900                            }
7901                            struct __With(std::option::Option<f64>);
7902                            impl<'de> serde::de::Deserialize<'de> for __With {
7903                                fn deserialize<D>(
7904                                    deserializer: D,
7905                                ) -> std::result::Result<Self, D::Error>
7906                                where
7907                                    D: serde::de::Deserializer<'de>,
7908                                {
7909                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
7910                                }
7911                            }
7912                            result.mean = map.next_value::<__With>()?.0.unwrap_or_default();
7913                        }
7914                        __FieldTag::__sum_of_squared_deviation => {
7915                            if !fields.insert(__FieldTag::__sum_of_squared_deviation) {
7916                                return std::result::Result::Err(A::Error::duplicate_field(
7917                                    "multiple values for sum_of_squared_deviation",
7918                                ));
7919                            }
7920                            struct __With(std::option::Option<f64>);
7921                            impl<'de> serde::de::Deserialize<'de> for __With {
7922                                fn deserialize<D>(
7923                                    deserializer: D,
7924                                ) -> std::result::Result<Self, D::Error>
7925                                where
7926                                    D: serde::de::Deserializer<'de>,
7927                                {
7928                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
7929                                }
7930                            }
7931                            result.sum_of_squared_deviation =
7932                                map.next_value::<__With>()?.0.unwrap_or_default();
7933                        }
7934                        __FieldTag::__range => {
7935                            if !fields.insert(__FieldTag::__range) {
7936                                return std::result::Result::Err(A::Error::duplicate_field(
7937                                    "multiple values for range",
7938                                ));
7939                            }
7940                            result.range = map.next_value::<std::option::Option<crate::model::distribution::Range>>()?
7941                                ;
7942                        }
7943                        __FieldTag::__bucket_options => {
7944                            if !fields.insert(__FieldTag::__bucket_options) {
7945                                return std::result::Result::Err(A::Error::duplicate_field(
7946                                    "multiple values for bucket_options",
7947                                ));
7948                            }
7949                            result.bucket_options = map.next_value::<std::option::Option<crate::model::distribution::BucketOptions>>()?
7950                                ;
7951                        }
7952                        __FieldTag::__bucket_counts => {
7953                            if !fields.insert(__FieldTag::__bucket_counts) {
7954                                return std::result::Result::Err(A::Error::duplicate_field(
7955                                    "multiple values for bucket_counts",
7956                                ));
7957                            }
7958                            struct __With(std::option::Option<std::vec::Vec<i64>>);
7959                            impl<'de> serde::de::Deserialize<'de> for __With {
7960                                fn deserialize<D>(
7961                                    deserializer: D,
7962                                ) -> std::result::Result<Self, D::Error>
7963                                where
7964                                    D: serde::de::Deserializer<'de>,
7965                                {
7966                                    serde_with::As::<
7967                                        std::option::Option<std::vec::Vec<wkt::internal::I64>>,
7968                                    >::deserialize(deserializer)
7969                                    .map(__With)
7970                                }
7971                            }
7972                            result.bucket_counts =
7973                                map.next_value::<__With>()?.0.unwrap_or_default();
7974                        }
7975                        __FieldTag::__exemplars => {
7976                            if !fields.insert(__FieldTag::__exemplars) {
7977                                return std::result::Result::Err(A::Error::duplicate_field(
7978                                    "multiple values for exemplars",
7979                                ));
7980                            }
7981                            result.exemplars = map
7982                                .next_value::<std::option::Option<
7983                                    std::vec::Vec<crate::model::distribution::Exemplar>,
7984                                >>()?
7985                                .unwrap_or_default();
7986                        }
7987                        __FieldTag::Unknown(key) => {
7988                            let value = map.next_value::<serde_json::Value>()?;
7989                            result._unknown_fields.insert(key, value);
7990                        }
7991                    }
7992                }
7993                std::result::Result::Ok(result)
7994            }
7995        }
7996        deserializer.deserialize_any(Visitor)
7997    }
7998}
7999
8000#[doc(hidden)]
8001impl serde::ser::Serialize for Distribution {
8002    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8003    where
8004        S: serde::ser::Serializer,
8005    {
8006        use serde::ser::SerializeMap;
8007        #[allow(unused_imports)]
8008        use std::option::Option::Some;
8009        let mut state = serializer.serialize_map(std::option::Option::None)?;
8010        if !wkt::internal::is_default(&self.count) {
8011            struct __With<'a>(&'a i64);
8012            impl<'a> serde::ser::Serialize for __With<'a> {
8013                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8014                where
8015                    S: serde::ser::Serializer,
8016                {
8017                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
8018                }
8019            }
8020            state.serialize_entry("count", &__With(&self.count))?;
8021        }
8022        if !wkt::internal::is_default(&self.mean) {
8023            struct __With<'a>(&'a f64);
8024            impl<'a> serde::ser::Serialize for __With<'a> {
8025                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8026                where
8027                    S: serde::ser::Serializer,
8028                {
8029                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8030                }
8031            }
8032            state.serialize_entry("mean", &__With(&self.mean))?;
8033        }
8034        if !wkt::internal::is_default(&self.sum_of_squared_deviation) {
8035            struct __With<'a>(&'a f64);
8036            impl<'a> serde::ser::Serialize for __With<'a> {
8037                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8038                where
8039                    S: serde::ser::Serializer,
8040                {
8041                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8042                }
8043            }
8044            state.serialize_entry(
8045                "sumOfSquaredDeviation",
8046                &__With(&self.sum_of_squared_deviation),
8047            )?;
8048        }
8049        if self.range.is_some() {
8050            state.serialize_entry("range", &self.range)?;
8051        }
8052        if self.bucket_options.is_some() {
8053            state.serialize_entry("bucketOptions", &self.bucket_options)?;
8054        }
8055        if !self.bucket_counts.is_empty() {
8056            struct __With<'a>(&'a std::vec::Vec<i64>);
8057            impl<'a> serde::ser::Serialize for __With<'a> {
8058                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8059                where
8060                    S: serde::ser::Serializer,
8061                {
8062                    serde_with::As::<std::vec::Vec<wkt::internal::I64>>::serialize(
8063                        self.0, serializer,
8064                    )
8065                }
8066            }
8067            state.serialize_entry("bucketCounts", &__With(&self.bucket_counts))?;
8068        }
8069        if !self.exemplars.is_empty() {
8070            state.serialize_entry("exemplars", &self.exemplars)?;
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
8081/// Defines additional types related to [Distribution].
8082pub mod distribution {
8083    #[allow(unused_imports)]
8084    use super::*;
8085
8086    /// The range of the population values.
8087    #[derive(Clone, Debug, Default, PartialEq)]
8088    #[non_exhaustive]
8089    pub struct Range {
8090        /// The minimum of the population values.
8091        pub min: f64,
8092
8093        /// The maximum of the population values.
8094        pub max: f64,
8095
8096        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8097    }
8098
8099    impl Range {
8100        pub fn new() -> Self {
8101            std::default::Default::default()
8102        }
8103
8104        /// Sets the value of [min][crate::model::distribution::Range::min].
8105        pub fn set_min<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8106            self.min = v.into();
8107            self
8108        }
8109
8110        /// Sets the value of [max][crate::model::distribution::Range::max].
8111        pub fn set_max<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8112            self.max = v.into();
8113            self
8114        }
8115    }
8116
8117    impl wkt::message::Message for Range {
8118        fn typename() -> &'static str {
8119            "type.googleapis.com/google.api.Distribution.Range"
8120        }
8121    }
8122
8123    #[doc(hidden)]
8124    impl<'de> serde::de::Deserialize<'de> for Range {
8125        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8126        where
8127            D: serde::Deserializer<'de>,
8128        {
8129            #[allow(non_camel_case_types)]
8130            #[doc(hidden)]
8131            #[derive(PartialEq, Eq, Hash)]
8132            enum __FieldTag {
8133                __min,
8134                __max,
8135                Unknown(std::string::String),
8136            }
8137            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8138                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8139                where
8140                    D: serde::Deserializer<'de>,
8141                {
8142                    struct Visitor;
8143                    impl<'de> serde::de::Visitor<'de> for Visitor {
8144                        type Value = __FieldTag;
8145                        fn expecting(
8146                            &self,
8147                            formatter: &mut std::fmt::Formatter,
8148                        ) -> std::fmt::Result {
8149                            formatter.write_str("a field name for Range")
8150                        }
8151                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8152                        where
8153                            E: serde::de::Error,
8154                        {
8155                            use std::result::Result::Ok;
8156                            use std::string::ToString;
8157                            match value {
8158                                "min" => Ok(__FieldTag::__min),
8159                                "max" => Ok(__FieldTag::__max),
8160                                _ => Ok(__FieldTag::Unknown(value.to_string())),
8161                            }
8162                        }
8163                    }
8164                    deserializer.deserialize_identifier(Visitor)
8165                }
8166            }
8167            struct Visitor;
8168            impl<'de> serde::de::Visitor<'de> for Visitor {
8169                type Value = Range;
8170                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8171                    formatter.write_str("struct Range")
8172                }
8173                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8174                where
8175                    A: serde::de::MapAccess<'de>,
8176                {
8177                    #[allow(unused_imports)]
8178                    use serde::de::Error;
8179                    use std::option::Option::Some;
8180                    let mut fields = std::collections::HashSet::new();
8181                    let mut result = Self::Value::new();
8182                    while let Some(tag) = map.next_key::<__FieldTag>()? {
8183                        #[allow(clippy::match_single_binding)]
8184                        match tag {
8185                            __FieldTag::__min => {
8186                                if !fields.insert(__FieldTag::__min) {
8187                                    return std::result::Result::Err(A::Error::duplicate_field(
8188                                        "multiple values for min",
8189                                    ));
8190                                }
8191                                struct __With(std::option::Option<f64>);
8192                                impl<'de> serde::de::Deserialize<'de> for __With {
8193                                    fn deserialize<D>(
8194                                        deserializer: D,
8195                                    ) -> std::result::Result<Self, D::Error>
8196                                    where
8197                                        D: serde::de::Deserializer<'de>,
8198                                    {
8199                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8200                                    }
8201                                }
8202                                result.min = map.next_value::<__With>()?.0.unwrap_or_default();
8203                            }
8204                            __FieldTag::__max => {
8205                                if !fields.insert(__FieldTag::__max) {
8206                                    return std::result::Result::Err(A::Error::duplicate_field(
8207                                        "multiple values for max",
8208                                    ));
8209                                }
8210                                struct __With(std::option::Option<f64>);
8211                                impl<'de> serde::de::Deserialize<'de> for __With {
8212                                    fn deserialize<D>(
8213                                        deserializer: D,
8214                                    ) -> std::result::Result<Self, D::Error>
8215                                    where
8216                                        D: serde::de::Deserializer<'de>,
8217                                    {
8218                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8219                                    }
8220                                }
8221                                result.max = map.next_value::<__With>()?.0.unwrap_or_default();
8222                            }
8223                            __FieldTag::Unknown(key) => {
8224                                let value = map.next_value::<serde_json::Value>()?;
8225                                result._unknown_fields.insert(key, value);
8226                            }
8227                        }
8228                    }
8229                    std::result::Result::Ok(result)
8230                }
8231            }
8232            deserializer.deserialize_any(Visitor)
8233        }
8234    }
8235
8236    #[doc(hidden)]
8237    impl serde::ser::Serialize for Range {
8238        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8239        where
8240            S: serde::ser::Serializer,
8241        {
8242            use serde::ser::SerializeMap;
8243            #[allow(unused_imports)]
8244            use std::option::Option::Some;
8245            let mut state = serializer.serialize_map(std::option::Option::None)?;
8246            if !wkt::internal::is_default(&self.min) {
8247                struct __With<'a>(&'a f64);
8248                impl<'a> serde::ser::Serialize for __With<'a> {
8249                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8250                    where
8251                        S: serde::ser::Serializer,
8252                    {
8253                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8254                    }
8255                }
8256                state.serialize_entry("min", &__With(&self.min))?;
8257            }
8258            if !wkt::internal::is_default(&self.max) {
8259                struct __With<'a>(&'a f64);
8260                impl<'a> serde::ser::Serialize for __With<'a> {
8261                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8262                    where
8263                        S: serde::ser::Serializer,
8264                    {
8265                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8266                    }
8267                }
8268                state.serialize_entry("max", &__With(&self.max))?;
8269            }
8270            if !self._unknown_fields.is_empty() {
8271                for (key, value) in self._unknown_fields.iter() {
8272                    state.serialize_entry(key, &value)?;
8273                }
8274            }
8275            state.end()
8276        }
8277    }
8278
8279    /// `BucketOptions` describes the bucket boundaries used to create a histogram
8280    /// for the distribution. The buckets can be in a linear sequence, an
8281    /// exponential sequence, or each bucket can be specified explicitly.
8282    /// `BucketOptions` does not include the number of values in each bucket.
8283    ///
8284    /// A bucket has an inclusive lower bound and exclusive upper bound for the
8285    /// values that are counted for that bucket. The upper bound of a bucket must
8286    /// be strictly greater than the lower bound. The sequence of N buckets for a
8287    /// distribution consists of an underflow bucket (number 0), zero or more
8288    /// finite buckets (number 1 through N - 2) and an overflow bucket (number N -
8289    /// 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the
8290    /// same as the upper bound of bucket i - 1. The buckets span the whole range
8291    /// of finite values: lower bound of the underflow bucket is -infinity and the
8292    /// upper bound of the overflow bucket is +infinity. The finite buckets are
8293    /// so-called because both bounds are finite.
8294    #[derive(Clone, Debug, Default, PartialEq)]
8295    #[non_exhaustive]
8296    pub struct BucketOptions {
8297        /// Exactly one of these three fields must be set.
8298        pub options: std::option::Option<crate::model::distribution::bucket_options::Options>,
8299
8300        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8301    }
8302
8303    impl BucketOptions {
8304        pub fn new() -> Self {
8305            std::default::Default::default()
8306        }
8307
8308        /// Sets the value of [options][crate::model::distribution::BucketOptions::options].
8309        ///
8310        /// Note that all the setters affecting `options` are mutually
8311        /// exclusive.
8312        pub fn set_options<
8313            T: std::convert::Into<
8314                    std::option::Option<crate::model::distribution::bucket_options::Options>,
8315                >,
8316        >(
8317            mut self,
8318            v: T,
8319        ) -> Self {
8320            self.options = v.into();
8321            self
8322        }
8323
8324        /// The value of [options][crate::model::distribution::BucketOptions::options]
8325        /// if it holds a `LinearBuckets`, `None` if the field is not set or
8326        /// holds a different branch.
8327        pub fn linear_buckets(
8328            &self,
8329        ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::bucket_options::Linear>>
8330        {
8331            #[allow(unreachable_patterns)]
8332            self.options.as_ref().and_then(|v| match v {
8333                crate::model::distribution::bucket_options::Options::LinearBuckets(v) => {
8334                    std::option::Option::Some(v)
8335                }
8336                _ => std::option::Option::None,
8337            })
8338        }
8339
8340        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8341        /// to hold a `LinearBuckets`.
8342        ///
8343        /// Note that all the setters affecting `options` are
8344        /// mutually exclusive.
8345        pub fn set_linear_buckets<
8346            T: std::convert::Into<std::boxed::Box<crate::model::distribution::bucket_options::Linear>>,
8347        >(
8348            mut self,
8349            v: T,
8350        ) -> Self {
8351            self.options = std::option::Option::Some(
8352                crate::model::distribution::bucket_options::Options::LinearBuckets(v.into()),
8353            );
8354            self
8355        }
8356
8357        /// The value of [options][crate::model::distribution::BucketOptions::options]
8358        /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
8359        /// holds a different branch.
8360        pub fn exponential_buckets(
8361            &self,
8362        ) -> std::option::Option<
8363            &std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
8364        > {
8365            #[allow(unreachable_patterns)]
8366            self.options.as_ref().and_then(|v| match v {
8367                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v) => {
8368                    std::option::Option::Some(v)
8369                }
8370                _ => std::option::Option::None,
8371            })
8372        }
8373
8374        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8375        /// to hold a `ExponentialBuckets`.
8376        ///
8377        /// Note that all the setters affecting `options` are
8378        /// mutually exclusive.
8379        pub fn set_exponential_buckets<
8380            T: std::convert::Into<
8381                    std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
8382                >,
8383        >(
8384            mut self,
8385            v: T,
8386        ) -> Self {
8387            self.options = std::option::Option::Some(
8388                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v.into()),
8389            );
8390            self
8391        }
8392
8393        /// The value of [options][crate::model::distribution::BucketOptions::options]
8394        /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
8395        /// holds a different branch.
8396        pub fn explicit_buckets(
8397            &self,
8398        ) -> std::option::Option<
8399            &std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
8400        > {
8401            #[allow(unreachable_patterns)]
8402            self.options.as_ref().and_then(|v| match v {
8403                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v) => {
8404                    std::option::Option::Some(v)
8405                }
8406                _ => std::option::Option::None,
8407            })
8408        }
8409
8410        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
8411        /// to hold a `ExplicitBuckets`.
8412        ///
8413        /// Note that all the setters affecting `options` are
8414        /// mutually exclusive.
8415        pub fn set_explicit_buckets<
8416            T: std::convert::Into<
8417                    std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
8418                >,
8419        >(
8420            mut self,
8421            v: T,
8422        ) -> Self {
8423            self.options = std::option::Option::Some(
8424                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v.into()),
8425            );
8426            self
8427        }
8428    }
8429
8430    impl wkt::message::Message for BucketOptions {
8431        fn typename() -> &'static str {
8432            "type.googleapis.com/google.api.Distribution.BucketOptions"
8433        }
8434    }
8435
8436    #[doc(hidden)]
8437    impl<'de> serde::de::Deserialize<'de> for BucketOptions {
8438        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8439        where
8440            D: serde::Deserializer<'de>,
8441        {
8442            #[allow(non_camel_case_types)]
8443            #[doc(hidden)]
8444            #[derive(PartialEq, Eq, Hash)]
8445            enum __FieldTag {
8446                __linear_buckets,
8447                __exponential_buckets,
8448                __explicit_buckets,
8449                Unknown(std::string::String),
8450            }
8451            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8452                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8453                where
8454                    D: serde::Deserializer<'de>,
8455                {
8456                    struct Visitor;
8457                    impl<'de> serde::de::Visitor<'de> for Visitor {
8458                        type Value = __FieldTag;
8459                        fn expecting(
8460                            &self,
8461                            formatter: &mut std::fmt::Formatter,
8462                        ) -> std::fmt::Result {
8463                            formatter.write_str("a field name for BucketOptions")
8464                        }
8465                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8466                        where
8467                            E: serde::de::Error,
8468                        {
8469                            use std::result::Result::Ok;
8470                            use std::string::ToString;
8471                            match value {
8472                                "linearBuckets" => Ok(__FieldTag::__linear_buckets),
8473                                "linear_buckets" => Ok(__FieldTag::__linear_buckets),
8474                                "exponentialBuckets" => Ok(__FieldTag::__exponential_buckets),
8475                                "exponential_buckets" => Ok(__FieldTag::__exponential_buckets),
8476                                "explicitBuckets" => Ok(__FieldTag::__explicit_buckets),
8477                                "explicit_buckets" => Ok(__FieldTag::__explicit_buckets),
8478                                _ => Ok(__FieldTag::Unknown(value.to_string())),
8479                            }
8480                        }
8481                    }
8482                    deserializer.deserialize_identifier(Visitor)
8483                }
8484            }
8485            struct Visitor;
8486            impl<'de> serde::de::Visitor<'de> for Visitor {
8487                type Value = BucketOptions;
8488                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8489                    formatter.write_str("struct BucketOptions")
8490                }
8491                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8492                where
8493                    A: serde::de::MapAccess<'de>,
8494                {
8495                    #[allow(unused_imports)]
8496                    use serde::de::Error;
8497                    use std::option::Option::Some;
8498                    let mut fields = std::collections::HashSet::new();
8499                    let mut result = Self::Value::new();
8500                    while let Some(tag) = map.next_key::<__FieldTag>()? {
8501                        #[allow(clippy::match_single_binding)]
8502                        match tag {
8503                            __FieldTag::__linear_buckets => {
8504                                if !fields.insert(__FieldTag::__linear_buckets) {
8505                                    return std::result::Result::Err(A::Error::duplicate_field(
8506                                        "multiple values for linear_buckets",
8507                                    ));
8508                                }
8509                                if result.options.is_some() {
8510                                    return std::result::Result::Err(A::Error::duplicate_field(
8511                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.linear_buckets, latest field was linearBuckets",
8512                                    ));
8513                                }
8514                                result.options = std::option::Option::Some(
8515                                    crate::model::distribution::bucket_options::Options::LinearBuckets(
8516                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Linear>>>()?.unwrap_or_default()
8517                                    ),
8518                                );
8519                            }
8520                            __FieldTag::__exponential_buckets => {
8521                                if !fields.insert(__FieldTag::__exponential_buckets) {
8522                                    return std::result::Result::Err(A::Error::duplicate_field(
8523                                        "multiple values for exponential_buckets",
8524                                    ));
8525                                }
8526                                if result.options.is_some() {
8527                                    return std::result::Result::Err(A::Error::duplicate_field(
8528                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.exponential_buckets, latest field was exponentialBuckets",
8529                                    ));
8530                                }
8531                                result.options = std::option::Option::Some(
8532                                    crate::model::distribution::bucket_options::Options::ExponentialBuckets(
8533                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Exponential>>>()?.unwrap_or_default()
8534                                    ),
8535                                );
8536                            }
8537                            __FieldTag::__explicit_buckets => {
8538                                if !fields.insert(__FieldTag::__explicit_buckets) {
8539                                    return std::result::Result::Err(A::Error::duplicate_field(
8540                                        "multiple values for explicit_buckets",
8541                                    ));
8542                                }
8543                                if result.options.is_some() {
8544                                    return std::result::Result::Err(A::Error::duplicate_field(
8545                                        "multiple values for `options`, a oneof with full ID .google.api.Distribution.BucketOptions.explicit_buckets, latest field was explicitBuckets",
8546                                    ));
8547                                }
8548                                result.options = std::option::Option::Some(
8549                                    crate::model::distribution::bucket_options::Options::ExplicitBuckets(
8550                                        map.next_value::<std::option::Option<std::boxed::Box<crate::model::distribution::bucket_options::Explicit>>>()?.unwrap_or_default()
8551                                    ),
8552                                );
8553                            }
8554                            __FieldTag::Unknown(key) => {
8555                                let value = map.next_value::<serde_json::Value>()?;
8556                                result._unknown_fields.insert(key, value);
8557                            }
8558                        }
8559                    }
8560                    std::result::Result::Ok(result)
8561                }
8562            }
8563            deserializer.deserialize_any(Visitor)
8564        }
8565    }
8566
8567    #[doc(hidden)]
8568    impl serde::ser::Serialize for BucketOptions {
8569        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8570        where
8571            S: serde::ser::Serializer,
8572        {
8573            use serde::ser::SerializeMap;
8574            #[allow(unused_imports)]
8575            use std::option::Option::Some;
8576            let mut state = serializer.serialize_map(std::option::Option::None)?;
8577            if let Some(value) = self.linear_buckets() {
8578                state.serialize_entry("linearBuckets", value)?;
8579            }
8580            if let Some(value) = self.exponential_buckets() {
8581                state.serialize_entry("exponentialBuckets", value)?;
8582            }
8583            if let Some(value) = self.explicit_buckets() {
8584                state.serialize_entry("explicitBuckets", value)?;
8585            }
8586            if !self._unknown_fields.is_empty() {
8587                for (key, value) in self._unknown_fields.iter() {
8588                    state.serialize_entry(key, &value)?;
8589                }
8590            }
8591            state.end()
8592        }
8593    }
8594
8595    /// Defines additional types related to [BucketOptions].
8596    pub mod bucket_options {
8597        #[allow(unused_imports)]
8598        use super::*;
8599
8600        /// Specifies a linear sequence of buckets that all have the same width
8601        /// (except overflow and underflow). Each bucket represents a constant
8602        /// absolute uncertainty on the specific value in the bucket.
8603        ///
8604        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
8605        /// following boundaries:
8606        ///
8607        /// Upper bound (0 <= i < N-1):     offset + (width * i).
8608        ///
8609        /// Lower bound (1 <= i < N):       offset + (width * (i - 1)).
8610        #[derive(Clone, Debug, Default, PartialEq)]
8611        #[non_exhaustive]
8612        pub struct Linear {
8613            /// Must be greater than 0.
8614            pub num_finite_buckets: i32,
8615
8616            /// Must be greater than 0.
8617            pub width: f64,
8618
8619            /// Lower bound of the first bucket.
8620            pub offset: f64,
8621
8622            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8623        }
8624
8625        impl Linear {
8626            pub fn new() -> Self {
8627                std::default::Default::default()
8628            }
8629
8630            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Linear::num_finite_buckets].
8631            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8632                self.num_finite_buckets = v.into();
8633                self
8634            }
8635
8636            /// Sets the value of [width][crate::model::distribution::bucket_options::Linear::width].
8637            pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8638                self.width = v.into();
8639                self
8640            }
8641
8642            /// Sets the value of [offset][crate::model::distribution::bucket_options::Linear::offset].
8643            pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8644                self.offset = v.into();
8645                self
8646            }
8647        }
8648
8649        impl wkt::message::Message for Linear {
8650            fn typename() -> &'static str {
8651                "type.googleapis.com/google.api.Distribution.BucketOptions.Linear"
8652            }
8653        }
8654
8655        #[doc(hidden)]
8656        impl<'de> serde::de::Deserialize<'de> for Linear {
8657            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8658            where
8659                D: serde::Deserializer<'de>,
8660            {
8661                #[allow(non_camel_case_types)]
8662                #[doc(hidden)]
8663                #[derive(PartialEq, Eq, Hash)]
8664                enum __FieldTag {
8665                    __num_finite_buckets,
8666                    __width,
8667                    __offset,
8668                    Unknown(std::string::String),
8669                }
8670                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8671                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8672                    where
8673                        D: serde::Deserializer<'de>,
8674                    {
8675                        struct Visitor;
8676                        impl<'de> serde::de::Visitor<'de> for Visitor {
8677                            type Value = __FieldTag;
8678                            fn expecting(
8679                                &self,
8680                                formatter: &mut std::fmt::Formatter,
8681                            ) -> std::fmt::Result {
8682                                formatter.write_str("a field name for Linear")
8683                            }
8684                            fn visit_str<E>(
8685                                self,
8686                                value: &str,
8687                            ) -> std::result::Result<Self::Value, E>
8688                            where
8689                                E: serde::de::Error,
8690                            {
8691                                use std::result::Result::Ok;
8692                                use std::string::ToString;
8693                                match value {
8694                                    "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
8695                                    "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
8696                                    "width" => Ok(__FieldTag::__width),
8697                                    "offset" => Ok(__FieldTag::__offset),
8698                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
8699                                }
8700                            }
8701                        }
8702                        deserializer.deserialize_identifier(Visitor)
8703                    }
8704                }
8705                struct Visitor;
8706                impl<'de> serde::de::Visitor<'de> for Visitor {
8707                    type Value = Linear;
8708                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8709                        formatter.write_str("struct Linear")
8710                    }
8711                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8712                    where
8713                        A: serde::de::MapAccess<'de>,
8714                    {
8715                        #[allow(unused_imports)]
8716                        use serde::de::Error;
8717                        use std::option::Option::Some;
8718                        let mut fields = std::collections::HashSet::new();
8719                        let mut result = Self::Value::new();
8720                        while let Some(tag) = map.next_key::<__FieldTag>()? {
8721                            #[allow(clippy::match_single_binding)]
8722                            match tag {
8723                                __FieldTag::__num_finite_buckets => {
8724                                    if !fields.insert(__FieldTag::__num_finite_buckets) {
8725                                        return std::result::Result::Err(
8726                                            A::Error::duplicate_field(
8727                                                "multiple values for num_finite_buckets",
8728                                            ),
8729                                        );
8730                                    }
8731                                    struct __With(std::option::Option<i32>);
8732                                    impl<'de> serde::de::Deserialize<'de> for __With {
8733                                        fn deserialize<D>(
8734                                            deserializer: D,
8735                                        ) -> std::result::Result<Self, D::Error>
8736                                        where
8737                                            D: serde::de::Deserializer<'de>,
8738                                        {
8739                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
8740                                        }
8741                                    }
8742                                    result.num_finite_buckets =
8743                                        map.next_value::<__With>()?.0.unwrap_or_default();
8744                                }
8745                                __FieldTag::__width => {
8746                                    if !fields.insert(__FieldTag::__width) {
8747                                        return std::result::Result::Err(
8748                                            A::Error::duplicate_field("multiple values for width"),
8749                                        );
8750                                    }
8751                                    struct __With(std::option::Option<f64>);
8752                                    impl<'de> serde::de::Deserialize<'de> for __With {
8753                                        fn deserialize<D>(
8754                                            deserializer: D,
8755                                        ) -> std::result::Result<Self, D::Error>
8756                                        where
8757                                            D: serde::de::Deserializer<'de>,
8758                                        {
8759                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8760                                        }
8761                                    }
8762                                    result.width =
8763                                        map.next_value::<__With>()?.0.unwrap_or_default();
8764                                }
8765                                __FieldTag::__offset => {
8766                                    if !fields.insert(__FieldTag::__offset) {
8767                                        return std::result::Result::Err(
8768                                            A::Error::duplicate_field("multiple values for offset"),
8769                                        );
8770                                    }
8771                                    struct __With(std::option::Option<f64>);
8772                                    impl<'de> serde::de::Deserialize<'de> for __With {
8773                                        fn deserialize<D>(
8774                                            deserializer: D,
8775                                        ) -> std::result::Result<Self, D::Error>
8776                                        where
8777                                            D: serde::de::Deserializer<'de>,
8778                                        {
8779                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
8780                                        }
8781                                    }
8782                                    result.offset =
8783                                        map.next_value::<__With>()?.0.unwrap_or_default();
8784                                }
8785                                __FieldTag::Unknown(key) => {
8786                                    let value = map.next_value::<serde_json::Value>()?;
8787                                    result._unknown_fields.insert(key, value);
8788                                }
8789                            }
8790                        }
8791                        std::result::Result::Ok(result)
8792                    }
8793                }
8794                deserializer.deserialize_any(Visitor)
8795            }
8796        }
8797
8798        #[doc(hidden)]
8799        impl serde::ser::Serialize for Linear {
8800            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8801            where
8802                S: serde::ser::Serializer,
8803            {
8804                use serde::ser::SerializeMap;
8805                #[allow(unused_imports)]
8806                use std::option::Option::Some;
8807                let mut state = serializer.serialize_map(std::option::Option::None)?;
8808                if !wkt::internal::is_default(&self.num_finite_buckets) {
8809                    struct __With<'a>(&'a i32);
8810                    impl<'a> serde::ser::Serialize for __With<'a> {
8811                        fn serialize<S>(
8812                            &self,
8813                            serializer: S,
8814                        ) -> std::result::Result<S::Ok, S::Error>
8815                        where
8816                            S: serde::ser::Serializer,
8817                        {
8818                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
8819                        }
8820                    }
8821                    state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
8822                }
8823                if !wkt::internal::is_default(&self.width) {
8824                    struct __With<'a>(&'a f64);
8825                    impl<'a> serde::ser::Serialize for __With<'a> {
8826                        fn serialize<S>(
8827                            &self,
8828                            serializer: S,
8829                        ) -> std::result::Result<S::Ok, S::Error>
8830                        where
8831                            S: serde::ser::Serializer,
8832                        {
8833                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8834                        }
8835                    }
8836                    state.serialize_entry("width", &__With(&self.width))?;
8837                }
8838                if !wkt::internal::is_default(&self.offset) {
8839                    struct __With<'a>(&'a f64);
8840                    impl<'a> serde::ser::Serialize for __With<'a> {
8841                        fn serialize<S>(
8842                            &self,
8843                            serializer: S,
8844                        ) -> std::result::Result<S::Ok, S::Error>
8845                        where
8846                            S: serde::ser::Serializer,
8847                        {
8848                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
8849                        }
8850                    }
8851                    state.serialize_entry("offset", &__With(&self.offset))?;
8852                }
8853                if !self._unknown_fields.is_empty() {
8854                    for (key, value) in self._unknown_fields.iter() {
8855                        state.serialize_entry(key, &value)?;
8856                    }
8857                }
8858                state.end()
8859            }
8860        }
8861
8862        /// Specifies an exponential sequence of buckets that have a width that is
8863        /// proportional to the value of the lower bound. Each bucket represents a
8864        /// constant relative uncertainty on a specific value in the bucket.
8865        ///
8866        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
8867        /// following boundaries:
8868        ///
8869        /// Upper bound (0 <= i < N-1):     scale * (growth_factor ^ i).
8870        ///
8871        /// Lower bound (1 <= i < N):       scale * (growth_factor ^ (i - 1)).
8872        #[derive(Clone, Debug, Default, PartialEq)]
8873        #[non_exhaustive]
8874        pub struct Exponential {
8875            /// Must be greater than 0.
8876            pub num_finite_buckets: i32,
8877
8878            /// Must be greater than 1.
8879            pub growth_factor: f64,
8880
8881            /// Must be greater than 0.
8882            pub scale: f64,
8883
8884            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8885        }
8886
8887        impl Exponential {
8888            pub fn new() -> Self {
8889                std::default::Default::default()
8890            }
8891
8892            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Exponential::num_finite_buckets].
8893            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8894                self.num_finite_buckets = v.into();
8895                self
8896            }
8897
8898            /// Sets the value of [growth_factor][crate::model::distribution::bucket_options::Exponential::growth_factor].
8899            pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8900                self.growth_factor = v.into();
8901                self
8902            }
8903
8904            /// Sets the value of [scale][crate::model::distribution::bucket_options::Exponential::scale].
8905            pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8906                self.scale = v.into();
8907                self
8908            }
8909        }
8910
8911        impl wkt::message::Message for Exponential {
8912            fn typename() -> &'static str {
8913                "type.googleapis.com/google.api.Distribution.BucketOptions.Exponential"
8914            }
8915        }
8916
8917        #[doc(hidden)]
8918        impl<'de> serde::de::Deserialize<'de> for Exponential {
8919            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8920            where
8921                D: serde::Deserializer<'de>,
8922            {
8923                #[allow(non_camel_case_types)]
8924                #[doc(hidden)]
8925                #[derive(PartialEq, Eq, Hash)]
8926                enum __FieldTag {
8927                    __num_finite_buckets,
8928                    __growth_factor,
8929                    __scale,
8930                    Unknown(std::string::String),
8931                }
8932                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8933                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8934                    where
8935                        D: serde::Deserializer<'de>,
8936                    {
8937                        struct Visitor;
8938                        impl<'de> serde::de::Visitor<'de> for Visitor {
8939                            type Value = __FieldTag;
8940                            fn expecting(
8941                                &self,
8942                                formatter: &mut std::fmt::Formatter,
8943                            ) -> std::fmt::Result {
8944                                formatter.write_str("a field name for Exponential")
8945                            }
8946                            fn visit_str<E>(
8947                                self,
8948                                value: &str,
8949                            ) -> std::result::Result<Self::Value, E>
8950                            where
8951                                E: serde::de::Error,
8952                            {
8953                                use std::result::Result::Ok;
8954                                use std::string::ToString;
8955                                match value {
8956                                    "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
8957                                    "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
8958                                    "growthFactor" => Ok(__FieldTag::__growth_factor),
8959                                    "growth_factor" => Ok(__FieldTag::__growth_factor),
8960                                    "scale" => Ok(__FieldTag::__scale),
8961                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
8962                                }
8963                            }
8964                        }
8965                        deserializer.deserialize_identifier(Visitor)
8966                    }
8967                }
8968                struct Visitor;
8969                impl<'de> serde::de::Visitor<'de> for Visitor {
8970                    type Value = Exponential;
8971                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8972                        formatter.write_str("struct Exponential")
8973                    }
8974                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8975                    where
8976                        A: serde::de::MapAccess<'de>,
8977                    {
8978                        #[allow(unused_imports)]
8979                        use serde::de::Error;
8980                        use std::option::Option::Some;
8981                        let mut fields = std::collections::HashSet::new();
8982                        let mut result = Self::Value::new();
8983                        while let Some(tag) = map.next_key::<__FieldTag>()? {
8984                            #[allow(clippy::match_single_binding)]
8985                            match tag {
8986                                __FieldTag::__num_finite_buckets => {
8987                                    if !fields.insert(__FieldTag::__num_finite_buckets) {
8988                                        return std::result::Result::Err(
8989                                            A::Error::duplicate_field(
8990                                                "multiple values for num_finite_buckets",
8991                                            ),
8992                                        );
8993                                    }
8994                                    struct __With(std::option::Option<i32>);
8995                                    impl<'de> serde::de::Deserialize<'de> for __With {
8996                                        fn deserialize<D>(
8997                                            deserializer: D,
8998                                        ) -> std::result::Result<Self, D::Error>
8999                                        where
9000                                            D: serde::de::Deserializer<'de>,
9001                                        {
9002                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
9003                                        }
9004                                    }
9005                                    result.num_finite_buckets =
9006                                        map.next_value::<__With>()?.0.unwrap_or_default();
9007                                }
9008                                __FieldTag::__growth_factor => {
9009                                    if !fields.insert(__FieldTag::__growth_factor) {
9010                                        return std::result::Result::Err(
9011                                            A::Error::duplicate_field(
9012                                                "multiple values for growth_factor",
9013                                            ),
9014                                        );
9015                                    }
9016                                    struct __With(std::option::Option<f64>);
9017                                    impl<'de> serde::de::Deserialize<'de> for __With {
9018                                        fn deserialize<D>(
9019                                            deserializer: D,
9020                                        ) -> std::result::Result<Self, D::Error>
9021                                        where
9022                                            D: serde::de::Deserializer<'de>,
9023                                        {
9024                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9025                                        }
9026                                    }
9027                                    result.growth_factor =
9028                                        map.next_value::<__With>()?.0.unwrap_or_default();
9029                                }
9030                                __FieldTag::__scale => {
9031                                    if !fields.insert(__FieldTag::__scale) {
9032                                        return std::result::Result::Err(
9033                                            A::Error::duplicate_field("multiple values for scale"),
9034                                        );
9035                                    }
9036                                    struct __With(std::option::Option<f64>);
9037                                    impl<'de> serde::de::Deserialize<'de> for __With {
9038                                        fn deserialize<D>(
9039                                            deserializer: D,
9040                                        ) -> std::result::Result<Self, D::Error>
9041                                        where
9042                                            D: serde::de::Deserializer<'de>,
9043                                        {
9044                                            serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9045                                        }
9046                                    }
9047                                    result.scale =
9048                                        map.next_value::<__With>()?.0.unwrap_or_default();
9049                                }
9050                                __FieldTag::Unknown(key) => {
9051                                    let value = map.next_value::<serde_json::Value>()?;
9052                                    result._unknown_fields.insert(key, value);
9053                                }
9054                            }
9055                        }
9056                        std::result::Result::Ok(result)
9057                    }
9058                }
9059                deserializer.deserialize_any(Visitor)
9060            }
9061        }
9062
9063        #[doc(hidden)]
9064        impl serde::ser::Serialize for Exponential {
9065            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9066            where
9067                S: serde::ser::Serializer,
9068            {
9069                use serde::ser::SerializeMap;
9070                #[allow(unused_imports)]
9071                use std::option::Option::Some;
9072                let mut state = serializer.serialize_map(std::option::Option::None)?;
9073                if !wkt::internal::is_default(&self.num_finite_buckets) {
9074                    struct __With<'a>(&'a i32);
9075                    impl<'a> serde::ser::Serialize for __With<'a> {
9076                        fn serialize<S>(
9077                            &self,
9078                            serializer: S,
9079                        ) -> std::result::Result<S::Ok, S::Error>
9080                        where
9081                            S: serde::ser::Serializer,
9082                        {
9083                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
9084                        }
9085                    }
9086                    state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
9087                }
9088                if !wkt::internal::is_default(&self.growth_factor) {
9089                    struct __With<'a>(&'a f64);
9090                    impl<'a> serde::ser::Serialize for __With<'a> {
9091                        fn serialize<S>(
9092                            &self,
9093                            serializer: S,
9094                        ) -> std::result::Result<S::Ok, S::Error>
9095                        where
9096                            S: serde::ser::Serializer,
9097                        {
9098                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9099                        }
9100                    }
9101                    state.serialize_entry("growthFactor", &__With(&self.growth_factor))?;
9102                }
9103                if !wkt::internal::is_default(&self.scale) {
9104                    struct __With<'a>(&'a f64);
9105                    impl<'a> serde::ser::Serialize for __With<'a> {
9106                        fn serialize<S>(
9107                            &self,
9108                            serializer: S,
9109                        ) -> std::result::Result<S::Ok, S::Error>
9110                        where
9111                            S: serde::ser::Serializer,
9112                        {
9113                            serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9114                        }
9115                    }
9116                    state.serialize_entry("scale", &__With(&self.scale))?;
9117                }
9118                if !self._unknown_fields.is_empty() {
9119                    for (key, value) in self._unknown_fields.iter() {
9120                        state.serialize_entry(key, &value)?;
9121                    }
9122                }
9123                state.end()
9124            }
9125        }
9126
9127        /// Specifies a set of buckets with arbitrary widths.
9128        ///
9129        /// There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following
9130        /// boundaries:
9131        ///
9132        /// Upper bound (0 <= i < N-1):     bounds[i]
9133        /// Lower bound (1 <= i < N);       bounds[i - 1]
9134        ///
9135        /// The `bounds` field must contain at least one element. If `bounds` has
9136        /// only one element, then there are no finite buckets, and that single
9137        /// element is the common boundary of the overflow and underflow buckets.
9138        #[derive(Clone, Debug, Default, PartialEq)]
9139        #[non_exhaustive]
9140        pub struct Explicit {
9141            /// The values must be monotonically increasing.
9142            pub bounds: std::vec::Vec<f64>,
9143
9144            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9145        }
9146
9147        impl Explicit {
9148            pub fn new() -> Self {
9149                std::default::Default::default()
9150            }
9151
9152            /// Sets the value of [bounds][crate::model::distribution::bucket_options::Explicit::bounds].
9153            pub fn set_bounds<T, V>(mut self, v: T) -> Self
9154            where
9155                T: std::iter::IntoIterator<Item = V>,
9156                V: std::convert::Into<f64>,
9157            {
9158                use std::iter::Iterator;
9159                self.bounds = v.into_iter().map(|i| i.into()).collect();
9160                self
9161            }
9162        }
9163
9164        impl wkt::message::Message for Explicit {
9165            fn typename() -> &'static str {
9166                "type.googleapis.com/google.api.Distribution.BucketOptions.Explicit"
9167            }
9168        }
9169
9170        #[doc(hidden)]
9171        impl<'de> serde::de::Deserialize<'de> for Explicit {
9172            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9173            where
9174                D: serde::Deserializer<'de>,
9175            {
9176                #[allow(non_camel_case_types)]
9177                #[doc(hidden)]
9178                #[derive(PartialEq, Eq, Hash)]
9179                enum __FieldTag {
9180                    __bounds,
9181                    Unknown(std::string::String),
9182                }
9183                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9184                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9185                    where
9186                        D: serde::Deserializer<'de>,
9187                    {
9188                        struct Visitor;
9189                        impl<'de> serde::de::Visitor<'de> for Visitor {
9190                            type Value = __FieldTag;
9191                            fn expecting(
9192                                &self,
9193                                formatter: &mut std::fmt::Formatter,
9194                            ) -> std::fmt::Result {
9195                                formatter.write_str("a field name for Explicit")
9196                            }
9197                            fn visit_str<E>(
9198                                self,
9199                                value: &str,
9200                            ) -> std::result::Result<Self::Value, E>
9201                            where
9202                                E: serde::de::Error,
9203                            {
9204                                use std::result::Result::Ok;
9205                                use std::string::ToString;
9206                                match value {
9207                                    "bounds" => Ok(__FieldTag::__bounds),
9208                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
9209                                }
9210                            }
9211                        }
9212                        deserializer.deserialize_identifier(Visitor)
9213                    }
9214                }
9215                struct Visitor;
9216                impl<'de> serde::de::Visitor<'de> for Visitor {
9217                    type Value = Explicit;
9218                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9219                        formatter.write_str("struct Explicit")
9220                    }
9221                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9222                    where
9223                        A: serde::de::MapAccess<'de>,
9224                    {
9225                        #[allow(unused_imports)]
9226                        use serde::de::Error;
9227                        use std::option::Option::Some;
9228                        let mut fields = std::collections::HashSet::new();
9229                        let mut result = Self::Value::new();
9230                        while let Some(tag) = map.next_key::<__FieldTag>()? {
9231                            #[allow(clippy::match_single_binding)]
9232                            match tag {
9233                                __FieldTag::__bounds => {
9234                                    if !fields.insert(__FieldTag::__bounds) {
9235                                        return std::result::Result::Err(
9236                                            A::Error::duplicate_field("multiple values for bounds"),
9237                                        );
9238                                    }
9239                                    struct __With(std::option::Option<std::vec::Vec<f64>>);
9240                                    impl<'de> serde::de::Deserialize<'de> for __With {
9241                                        fn deserialize<D>(
9242                                            deserializer: D,
9243                                        ) -> std::result::Result<Self, D::Error>
9244                                        where
9245                                            D: serde::de::Deserializer<'de>,
9246                                        {
9247                                            serde_with::As::<
9248                                                std::option::Option<
9249                                                    std::vec::Vec<wkt::internal::F64>,
9250                                                >,
9251                                            >::deserialize(
9252                                                deserializer
9253                                            )
9254                                            .map(__With)
9255                                        }
9256                                    }
9257                                    result.bounds =
9258                                        map.next_value::<__With>()?.0.unwrap_or_default();
9259                                }
9260                                __FieldTag::Unknown(key) => {
9261                                    let value = map.next_value::<serde_json::Value>()?;
9262                                    result._unknown_fields.insert(key, value);
9263                                }
9264                            }
9265                        }
9266                        std::result::Result::Ok(result)
9267                    }
9268                }
9269                deserializer.deserialize_any(Visitor)
9270            }
9271        }
9272
9273        #[doc(hidden)]
9274        impl serde::ser::Serialize for Explicit {
9275            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9276            where
9277                S: serde::ser::Serializer,
9278            {
9279                use serde::ser::SerializeMap;
9280                #[allow(unused_imports)]
9281                use std::option::Option::Some;
9282                let mut state = serializer.serialize_map(std::option::Option::None)?;
9283                if !self.bounds.is_empty() {
9284                    struct __With<'a>(&'a std::vec::Vec<f64>);
9285                    impl<'a> serde::ser::Serialize for __With<'a> {
9286                        fn serialize<S>(
9287                            &self,
9288                            serializer: S,
9289                        ) -> std::result::Result<S::Ok, S::Error>
9290                        where
9291                            S: serde::ser::Serializer,
9292                        {
9293                            serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
9294                                self.0, serializer,
9295                            )
9296                        }
9297                    }
9298                    state.serialize_entry("bounds", &__With(&self.bounds))?;
9299                }
9300                if !self._unknown_fields.is_empty() {
9301                    for (key, value) in self._unknown_fields.iter() {
9302                        state.serialize_entry(key, &value)?;
9303                    }
9304                }
9305                state.end()
9306            }
9307        }
9308
9309        /// Exactly one of these three fields must be set.
9310        #[derive(Clone, Debug, PartialEq)]
9311        #[non_exhaustive]
9312        pub enum Options {
9313            /// The linear bucket.
9314            LinearBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Linear>),
9315            /// The exponential buckets.
9316            ExponentialBuckets(
9317                std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
9318            ),
9319            /// The explicit buckets.
9320            ExplicitBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Explicit>),
9321        }
9322    }
9323
9324    /// Exemplars are example points that may be used to annotate aggregated
9325    /// distribution values. They are metadata that gives information about a
9326    /// particular value added to a Distribution bucket, such as a trace ID that
9327    /// was active when a value was added. They may contain further information,
9328    /// such as a example values and timestamps, origin, etc.
9329    #[derive(Clone, Debug, Default, PartialEq)]
9330    #[non_exhaustive]
9331    pub struct Exemplar {
9332        /// Value of the exemplar point. This value determines to which bucket the
9333        /// exemplar belongs.
9334        pub value: f64,
9335
9336        /// The observation (sampling) time of the above value.
9337        pub timestamp: std::option::Option<wkt::Timestamp>,
9338
9339        /// Contextual information about the example value. Examples are:
9340        ///
9341        /// Trace: type.googleapis.com/google.monitoring.v3.SpanContext
9342        ///
9343        /// Literal string: type.googleapis.com/google.protobuf.StringValue
9344        ///
9345        /// Labels dropped during aggregation:
9346        /// type.googleapis.com/google.monitoring.v3.DroppedLabels
9347        ///
9348        /// There may be only a single attachment of any given message type in a
9349        /// single exemplar, and this is enforced by the system.
9350        pub attachments: std::vec::Vec<wkt::Any>,
9351
9352        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9353    }
9354
9355    impl Exemplar {
9356        pub fn new() -> Self {
9357            std::default::Default::default()
9358        }
9359
9360        /// Sets the value of [value][crate::model::distribution::Exemplar::value].
9361        pub fn set_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9362            self.value = v.into();
9363            self
9364        }
9365
9366        /// Sets the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
9367        pub fn set_timestamp<T>(mut self, v: T) -> Self
9368        where
9369            T: std::convert::Into<wkt::Timestamp>,
9370        {
9371            self.timestamp = std::option::Option::Some(v.into());
9372            self
9373        }
9374
9375        /// Sets or clears the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
9376        pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
9377        where
9378            T: std::convert::Into<wkt::Timestamp>,
9379        {
9380            self.timestamp = v.map(|x| x.into());
9381            self
9382        }
9383
9384        /// Sets the value of [attachments][crate::model::distribution::Exemplar::attachments].
9385        pub fn set_attachments<T, V>(mut self, v: T) -> Self
9386        where
9387            T: std::iter::IntoIterator<Item = V>,
9388            V: std::convert::Into<wkt::Any>,
9389        {
9390            use std::iter::Iterator;
9391            self.attachments = v.into_iter().map(|i| i.into()).collect();
9392            self
9393        }
9394    }
9395
9396    impl wkt::message::Message for Exemplar {
9397        fn typename() -> &'static str {
9398            "type.googleapis.com/google.api.Distribution.Exemplar"
9399        }
9400    }
9401
9402    #[doc(hidden)]
9403    impl<'de> serde::de::Deserialize<'de> for Exemplar {
9404        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9405        where
9406            D: serde::Deserializer<'de>,
9407        {
9408            #[allow(non_camel_case_types)]
9409            #[doc(hidden)]
9410            #[derive(PartialEq, Eq, Hash)]
9411            enum __FieldTag {
9412                __value,
9413                __timestamp,
9414                __attachments,
9415                Unknown(std::string::String),
9416            }
9417            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9418                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9419                where
9420                    D: serde::Deserializer<'de>,
9421                {
9422                    struct Visitor;
9423                    impl<'de> serde::de::Visitor<'de> for Visitor {
9424                        type Value = __FieldTag;
9425                        fn expecting(
9426                            &self,
9427                            formatter: &mut std::fmt::Formatter,
9428                        ) -> std::fmt::Result {
9429                            formatter.write_str("a field name for Exemplar")
9430                        }
9431                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9432                        where
9433                            E: serde::de::Error,
9434                        {
9435                            use std::result::Result::Ok;
9436                            use std::string::ToString;
9437                            match value {
9438                                "value" => Ok(__FieldTag::__value),
9439                                "timestamp" => Ok(__FieldTag::__timestamp),
9440                                "attachments" => Ok(__FieldTag::__attachments),
9441                                _ => Ok(__FieldTag::Unknown(value.to_string())),
9442                            }
9443                        }
9444                    }
9445                    deserializer.deserialize_identifier(Visitor)
9446                }
9447            }
9448            struct Visitor;
9449            impl<'de> serde::de::Visitor<'de> for Visitor {
9450                type Value = Exemplar;
9451                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9452                    formatter.write_str("struct Exemplar")
9453                }
9454                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9455                where
9456                    A: serde::de::MapAccess<'de>,
9457                {
9458                    #[allow(unused_imports)]
9459                    use serde::de::Error;
9460                    use std::option::Option::Some;
9461                    let mut fields = std::collections::HashSet::new();
9462                    let mut result = Self::Value::new();
9463                    while let Some(tag) = map.next_key::<__FieldTag>()? {
9464                        #[allow(clippy::match_single_binding)]
9465                        match tag {
9466                            __FieldTag::__value => {
9467                                if !fields.insert(__FieldTag::__value) {
9468                                    return std::result::Result::Err(A::Error::duplicate_field(
9469                                        "multiple values for value",
9470                                    ));
9471                                }
9472                                struct __With(std::option::Option<f64>);
9473                                impl<'de> serde::de::Deserialize<'de> for __With {
9474                                    fn deserialize<D>(
9475                                        deserializer: D,
9476                                    ) -> std::result::Result<Self, D::Error>
9477                                    where
9478                                        D: serde::de::Deserializer<'de>,
9479                                    {
9480                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9481                                    }
9482                                }
9483                                result.value = map.next_value::<__With>()?.0.unwrap_or_default();
9484                            }
9485                            __FieldTag::__timestamp => {
9486                                if !fields.insert(__FieldTag::__timestamp) {
9487                                    return std::result::Result::Err(A::Error::duplicate_field(
9488                                        "multiple values for timestamp",
9489                                    ));
9490                                }
9491                                result.timestamp =
9492                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
9493                            }
9494                            __FieldTag::__attachments => {
9495                                if !fields.insert(__FieldTag::__attachments) {
9496                                    return std::result::Result::Err(A::Error::duplicate_field(
9497                                        "multiple values for attachments",
9498                                    ));
9499                                }
9500                                result.attachments = map
9501                                    .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
9502                                    .unwrap_or_default();
9503                            }
9504                            __FieldTag::Unknown(key) => {
9505                                let value = map.next_value::<serde_json::Value>()?;
9506                                result._unknown_fields.insert(key, value);
9507                            }
9508                        }
9509                    }
9510                    std::result::Result::Ok(result)
9511                }
9512            }
9513            deserializer.deserialize_any(Visitor)
9514        }
9515    }
9516
9517    #[doc(hidden)]
9518    impl serde::ser::Serialize for Exemplar {
9519        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9520        where
9521            S: serde::ser::Serializer,
9522        {
9523            use serde::ser::SerializeMap;
9524            #[allow(unused_imports)]
9525            use std::option::Option::Some;
9526            let mut state = serializer.serialize_map(std::option::Option::None)?;
9527            if !wkt::internal::is_default(&self.value) {
9528                struct __With<'a>(&'a f64);
9529                impl<'a> serde::ser::Serialize for __With<'a> {
9530                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9531                    where
9532                        S: serde::ser::Serializer,
9533                    {
9534                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9535                    }
9536                }
9537                state.serialize_entry("value", &__With(&self.value))?;
9538            }
9539            if self.timestamp.is_some() {
9540                state.serialize_entry("timestamp", &self.timestamp)?;
9541            }
9542            if !self.attachments.is_empty() {
9543                state.serialize_entry("attachments", &self.attachments)?;
9544            }
9545            if !self._unknown_fields.is_empty() {
9546                for (key, value) in self._unknown_fields.iter() {
9547                    state.serialize_entry(key, &value)?;
9548                }
9549            }
9550            state.end()
9551        }
9552    }
9553}
9554
9555/// `Documentation` provides the information for describing a service.
9556///
9557/// Example:
9558///
9559/// Documentation is provided in markdown syntax. In addition to
9560/// standard markdown features, definition lists, tables and fenced
9561/// code blocks are supported. Section headers can be provided and are
9562/// interpreted relative to the section nesting of the context where
9563/// a documentation fragment is embedded.
9564///
9565/// Documentation from the IDL is merged with documentation defined
9566/// via the config at normalization time, where documentation provided
9567/// by config rules overrides IDL provided.
9568///
9569/// A number of constructs specific to the API platform are supported
9570/// in documentation text.
9571///
9572/// In order to reference a proto element, the following
9573/// notation can be used:
9574///
9575/// To override the display text used for the link, this can be used:
9576///
9577/// Text can be excluded from doc using the following notation:
9578///
9579/// A few directives are available in documentation. Note that
9580/// directives must appear on a single line to be properly
9581/// identified. The `include` directive includes a markdown file from
9582/// an external source:
9583///
9584/// The `resource_for` directive marks a message to be the resource of
9585/// a collection in REST view. If it is not specified, tools attempt
9586/// to infer the resource from the operations in a collection:
9587///
9588/// The directive `suppress_warning` does not directly affect documentation
9589/// and is documented together with service config validation.
9590#[derive(Clone, Debug, Default, PartialEq)]
9591#[non_exhaustive]
9592pub struct Documentation {
9593    /// A short description of what the service does. The summary must be plain
9594    /// text. It becomes the overview of the service displayed in Google Cloud
9595    /// Console.
9596    /// NOTE: This field is equivalent to the standard field `description`.
9597    pub summary: std::string::String,
9598
9599    /// The top level pages for the documentation set.
9600    pub pages: std::vec::Vec<crate::model::Page>,
9601
9602    /// A list of documentation rules that apply to individual API elements.
9603    ///
9604    /// **NOTE:** All service configuration rules follow "last one wins" order.
9605    pub rules: std::vec::Vec<crate::model::DocumentationRule>,
9606
9607    /// The URL to the root of documentation.
9608    pub documentation_root_url: std::string::String,
9609
9610    /// Specifies the service root url if the default one (the service name
9611    /// from the yaml file) is not suitable. This can be seen in any fully
9612    /// specified service urls as well as sections that show a base that other
9613    /// urls are relative to.
9614    pub service_root_url: std::string::String,
9615
9616    /// Declares a single overview page. For example:
9617    ///
9618    /// This is a shortcut for the following declaration (using pages style):
9619    ///
9620    /// Note: you cannot specify both `overview` field and `pages` field.
9621    pub overview: std::string::String,
9622
9623    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9624}
9625
9626impl Documentation {
9627    pub fn new() -> Self {
9628        std::default::Default::default()
9629    }
9630
9631    /// Sets the value of [summary][crate::model::Documentation::summary].
9632    pub fn set_summary<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9633        self.summary = v.into();
9634        self
9635    }
9636
9637    /// Sets the value of [pages][crate::model::Documentation::pages].
9638    pub fn set_pages<T, V>(mut self, v: T) -> Self
9639    where
9640        T: std::iter::IntoIterator<Item = V>,
9641        V: std::convert::Into<crate::model::Page>,
9642    {
9643        use std::iter::Iterator;
9644        self.pages = v.into_iter().map(|i| i.into()).collect();
9645        self
9646    }
9647
9648    /// Sets the value of [rules][crate::model::Documentation::rules].
9649    pub fn set_rules<T, V>(mut self, v: T) -> Self
9650    where
9651        T: std::iter::IntoIterator<Item = V>,
9652        V: std::convert::Into<crate::model::DocumentationRule>,
9653    {
9654        use std::iter::Iterator;
9655        self.rules = v.into_iter().map(|i| i.into()).collect();
9656        self
9657    }
9658
9659    /// Sets the value of [documentation_root_url][crate::model::Documentation::documentation_root_url].
9660    pub fn set_documentation_root_url<T: std::convert::Into<std::string::String>>(
9661        mut self,
9662        v: T,
9663    ) -> Self {
9664        self.documentation_root_url = v.into();
9665        self
9666    }
9667
9668    /// Sets the value of [service_root_url][crate::model::Documentation::service_root_url].
9669    pub fn set_service_root_url<T: std::convert::Into<std::string::String>>(
9670        mut self,
9671        v: T,
9672    ) -> Self {
9673        self.service_root_url = v.into();
9674        self
9675    }
9676
9677    /// Sets the value of [overview][crate::model::Documentation::overview].
9678    pub fn set_overview<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9679        self.overview = v.into();
9680        self
9681    }
9682}
9683
9684impl wkt::message::Message for Documentation {
9685    fn typename() -> &'static str {
9686        "type.googleapis.com/google.api.Documentation"
9687    }
9688}
9689
9690#[doc(hidden)]
9691impl<'de> serde::de::Deserialize<'de> for Documentation {
9692    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9693    where
9694        D: serde::Deserializer<'de>,
9695    {
9696        #[allow(non_camel_case_types)]
9697        #[doc(hidden)]
9698        #[derive(PartialEq, Eq, Hash)]
9699        enum __FieldTag {
9700            __summary,
9701            __pages,
9702            __rules,
9703            __documentation_root_url,
9704            __service_root_url,
9705            __overview,
9706            Unknown(std::string::String),
9707        }
9708        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9709            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9710            where
9711                D: serde::Deserializer<'de>,
9712            {
9713                struct Visitor;
9714                impl<'de> serde::de::Visitor<'de> for Visitor {
9715                    type Value = __FieldTag;
9716                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9717                        formatter.write_str("a field name for Documentation")
9718                    }
9719                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9720                    where
9721                        E: serde::de::Error,
9722                    {
9723                        use std::result::Result::Ok;
9724                        use std::string::ToString;
9725                        match value {
9726                            "summary" => Ok(__FieldTag::__summary),
9727                            "pages" => Ok(__FieldTag::__pages),
9728                            "rules" => Ok(__FieldTag::__rules),
9729                            "documentationRootUrl" => Ok(__FieldTag::__documentation_root_url),
9730                            "documentation_root_url" => Ok(__FieldTag::__documentation_root_url),
9731                            "serviceRootUrl" => Ok(__FieldTag::__service_root_url),
9732                            "service_root_url" => Ok(__FieldTag::__service_root_url),
9733                            "overview" => Ok(__FieldTag::__overview),
9734                            _ => Ok(__FieldTag::Unknown(value.to_string())),
9735                        }
9736                    }
9737                }
9738                deserializer.deserialize_identifier(Visitor)
9739            }
9740        }
9741        struct Visitor;
9742        impl<'de> serde::de::Visitor<'de> for Visitor {
9743            type Value = Documentation;
9744            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9745                formatter.write_str("struct Documentation")
9746            }
9747            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9748            where
9749                A: serde::de::MapAccess<'de>,
9750            {
9751                #[allow(unused_imports)]
9752                use serde::de::Error;
9753                use std::option::Option::Some;
9754                let mut fields = std::collections::HashSet::new();
9755                let mut result = Self::Value::new();
9756                while let Some(tag) = map.next_key::<__FieldTag>()? {
9757                    #[allow(clippy::match_single_binding)]
9758                    match tag {
9759                        __FieldTag::__summary => {
9760                            if !fields.insert(__FieldTag::__summary) {
9761                                return std::result::Result::Err(A::Error::duplicate_field(
9762                                    "multiple values for summary",
9763                                ));
9764                            }
9765                            result.summary = map
9766                                .next_value::<std::option::Option<std::string::String>>()?
9767                                .unwrap_or_default();
9768                        }
9769                        __FieldTag::__pages => {
9770                            if !fields.insert(__FieldTag::__pages) {
9771                                return std::result::Result::Err(A::Error::duplicate_field(
9772                                    "multiple values for pages",
9773                                ));
9774                            }
9775                            result.pages = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Page>>>()?.unwrap_or_default();
9776                        }
9777                        __FieldTag::__rules => {
9778                            if !fields.insert(__FieldTag::__rules) {
9779                                return std::result::Result::Err(A::Error::duplicate_field(
9780                                    "multiple values for rules",
9781                                ));
9782                            }
9783                            result.rules =
9784                                map.next_value::<std::option::Option<
9785                                    std::vec::Vec<crate::model::DocumentationRule>,
9786                                >>()?
9787                                .unwrap_or_default();
9788                        }
9789                        __FieldTag::__documentation_root_url => {
9790                            if !fields.insert(__FieldTag::__documentation_root_url) {
9791                                return std::result::Result::Err(A::Error::duplicate_field(
9792                                    "multiple values for documentation_root_url",
9793                                ));
9794                            }
9795                            result.documentation_root_url = map
9796                                .next_value::<std::option::Option<std::string::String>>()?
9797                                .unwrap_or_default();
9798                        }
9799                        __FieldTag::__service_root_url => {
9800                            if !fields.insert(__FieldTag::__service_root_url) {
9801                                return std::result::Result::Err(A::Error::duplicate_field(
9802                                    "multiple values for service_root_url",
9803                                ));
9804                            }
9805                            result.service_root_url = map
9806                                .next_value::<std::option::Option<std::string::String>>()?
9807                                .unwrap_or_default();
9808                        }
9809                        __FieldTag::__overview => {
9810                            if !fields.insert(__FieldTag::__overview) {
9811                                return std::result::Result::Err(A::Error::duplicate_field(
9812                                    "multiple values for overview",
9813                                ));
9814                            }
9815                            result.overview = map
9816                                .next_value::<std::option::Option<std::string::String>>()?
9817                                .unwrap_or_default();
9818                        }
9819                        __FieldTag::Unknown(key) => {
9820                            let value = map.next_value::<serde_json::Value>()?;
9821                            result._unknown_fields.insert(key, value);
9822                        }
9823                    }
9824                }
9825                std::result::Result::Ok(result)
9826            }
9827        }
9828        deserializer.deserialize_any(Visitor)
9829    }
9830}
9831
9832#[doc(hidden)]
9833impl serde::ser::Serialize for Documentation {
9834    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9835    where
9836        S: serde::ser::Serializer,
9837    {
9838        use serde::ser::SerializeMap;
9839        #[allow(unused_imports)]
9840        use std::option::Option::Some;
9841        let mut state = serializer.serialize_map(std::option::Option::None)?;
9842        if !self.summary.is_empty() {
9843            state.serialize_entry("summary", &self.summary)?;
9844        }
9845        if !self.pages.is_empty() {
9846            state.serialize_entry("pages", &self.pages)?;
9847        }
9848        if !self.rules.is_empty() {
9849            state.serialize_entry("rules", &self.rules)?;
9850        }
9851        if !self.documentation_root_url.is_empty() {
9852            state.serialize_entry("documentationRootUrl", &self.documentation_root_url)?;
9853        }
9854        if !self.service_root_url.is_empty() {
9855            state.serialize_entry("serviceRootUrl", &self.service_root_url)?;
9856        }
9857        if !self.overview.is_empty() {
9858            state.serialize_entry("overview", &self.overview)?;
9859        }
9860        if !self._unknown_fields.is_empty() {
9861            for (key, value) in self._unknown_fields.iter() {
9862                state.serialize_entry(key, &value)?;
9863            }
9864        }
9865        state.end()
9866    }
9867}
9868
9869/// A documentation rule provides information about individual API elements.
9870#[derive(Clone, Debug, Default, PartialEq)]
9871#[non_exhaustive]
9872pub struct DocumentationRule {
9873    /// The selector is a comma-separated list of patterns for any element such as
9874    /// a method, a field, an enum value. Each pattern is a qualified name of the
9875    /// element which may end in "*", indicating a wildcard. Wildcards are only
9876    /// allowed at the end and for a whole component of the qualified name,
9877    /// i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". A wildcard will match
9878    /// one or more components. To specify a default for all applicable elements,
9879    /// the whole pattern "*" is used.
9880    pub selector: std::string::String,
9881
9882    /// Description of the selected proto element (e.g. a message, a method, a
9883    /// 'service' definition, or a field). Defaults to leading & trailing comments
9884    /// taken from the proto source definition of the proto element.
9885    pub description: std::string::String,
9886
9887    /// Deprecation description of the selected element(s). It can be provided if
9888    /// an element is marked as `deprecated`.
9889    pub deprecation_description: std::string::String,
9890
9891    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9892}
9893
9894impl DocumentationRule {
9895    pub fn new() -> Self {
9896        std::default::Default::default()
9897    }
9898
9899    /// Sets the value of [selector][crate::model::DocumentationRule::selector].
9900    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9901        self.selector = v.into();
9902        self
9903    }
9904
9905    /// Sets the value of [description][crate::model::DocumentationRule::description].
9906    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9907        self.description = v.into();
9908        self
9909    }
9910
9911    /// Sets the value of [deprecation_description][crate::model::DocumentationRule::deprecation_description].
9912    pub fn set_deprecation_description<T: std::convert::Into<std::string::String>>(
9913        mut self,
9914        v: T,
9915    ) -> Self {
9916        self.deprecation_description = v.into();
9917        self
9918    }
9919}
9920
9921impl wkt::message::Message for DocumentationRule {
9922    fn typename() -> &'static str {
9923        "type.googleapis.com/google.api.DocumentationRule"
9924    }
9925}
9926
9927#[doc(hidden)]
9928impl<'de> serde::de::Deserialize<'de> for DocumentationRule {
9929    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9930    where
9931        D: serde::Deserializer<'de>,
9932    {
9933        #[allow(non_camel_case_types)]
9934        #[doc(hidden)]
9935        #[derive(PartialEq, Eq, Hash)]
9936        enum __FieldTag {
9937            __selector,
9938            __description,
9939            __deprecation_description,
9940            Unknown(std::string::String),
9941        }
9942        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9943            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9944            where
9945                D: serde::Deserializer<'de>,
9946            {
9947                struct Visitor;
9948                impl<'de> serde::de::Visitor<'de> for Visitor {
9949                    type Value = __FieldTag;
9950                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9951                        formatter.write_str("a field name for DocumentationRule")
9952                    }
9953                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9954                    where
9955                        E: serde::de::Error,
9956                    {
9957                        use std::result::Result::Ok;
9958                        use std::string::ToString;
9959                        match value {
9960                            "selector" => Ok(__FieldTag::__selector),
9961                            "description" => Ok(__FieldTag::__description),
9962                            "deprecationDescription" => Ok(__FieldTag::__deprecation_description),
9963                            "deprecation_description" => Ok(__FieldTag::__deprecation_description),
9964                            _ => Ok(__FieldTag::Unknown(value.to_string())),
9965                        }
9966                    }
9967                }
9968                deserializer.deserialize_identifier(Visitor)
9969            }
9970        }
9971        struct Visitor;
9972        impl<'de> serde::de::Visitor<'de> for Visitor {
9973            type Value = DocumentationRule;
9974            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9975                formatter.write_str("struct DocumentationRule")
9976            }
9977            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9978            where
9979                A: serde::de::MapAccess<'de>,
9980            {
9981                #[allow(unused_imports)]
9982                use serde::de::Error;
9983                use std::option::Option::Some;
9984                let mut fields = std::collections::HashSet::new();
9985                let mut result = Self::Value::new();
9986                while let Some(tag) = map.next_key::<__FieldTag>()? {
9987                    #[allow(clippy::match_single_binding)]
9988                    match tag {
9989                        __FieldTag::__selector => {
9990                            if !fields.insert(__FieldTag::__selector) {
9991                                return std::result::Result::Err(A::Error::duplicate_field(
9992                                    "multiple values for selector",
9993                                ));
9994                            }
9995                            result.selector = map
9996                                .next_value::<std::option::Option<std::string::String>>()?
9997                                .unwrap_or_default();
9998                        }
9999                        __FieldTag::__description => {
10000                            if !fields.insert(__FieldTag::__description) {
10001                                return std::result::Result::Err(A::Error::duplicate_field(
10002                                    "multiple values for description",
10003                                ));
10004                            }
10005                            result.description = map
10006                                .next_value::<std::option::Option<std::string::String>>()?
10007                                .unwrap_or_default();
10008                        }
10009                        __FieldTag::__deprecation_description => {
10010                            if !fields.insert(__FieldTag::__deprecation_description) {
10011                                return std::result::Result::Err(A::Error::duplicate_field(
10012                                    "multiple values for deprecation_description",
10013                                ));
10014                            }
10015                            result.deprecation_description = map
10016                                .next_value::<std::option::Option<std::string::String>>()?
10017                                .unwrap_or_default();
10018                        }
10019                        __FieldTag::Unknown(key) => {
10020                            let value = map.next_value::<serde_json::Value>()?;
10021                            result._unknown_fields.insert(key, value);
10022                        }
10023                    }
10024                }
10025                std::result::Result::Ok(result)
10026            }
10027        }
10028        deserializer.deserialize_any(Visitor)
10029    }
10030}
10031
10032#[doc(hidden)]
10033impl serde::ser::Serialize for DocumentationRule {
10034    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10035    where
10036        S: serde::ser::Serializer,
10037    {
10038        use serde::ser::SerializeMap;
10039        #[allow(unused_imports)]
10040        use std::option::Option::Some;
10041        let mut state = serializer.serialize_map(std::option::Option::None)?;
10042        if !self.selector.is_empty() {
10043            state.serialize_entry("selector", &self.selector)?;
10044        }
10045        if !self.description.is_empty() {
10046            state.serialize_entry("description", &self.description)?;
10047        }
10048        if !self.deprecation_description.is_empty() {
10049            state.serialize_entry("deprecationDescription", &self.deprecation_description)?;
10050        }
10051        if !self._unknown_fields.is_empty() {
10052            for (key, value) in self._unknown_fields.iter() {
10053                state.serialize_entry(key, &value)?;
10054            }
10055        }
10056        state.end()
10057    }
10058}
10059
10060/// Represents a documentation page. A page can contain subpages to represent
10061/// nested documentation set structure.
10062#[derive(Clone, Debug, Default, PartialEq)]
10063#[non_exhaustive]
10064pub struct Page {
10065    /// The name of the page. It will be used as an identity of the page to
10066    /// generate URI of the page, text of the link to this page in navigation,
10067    /// etc. The full page name (start from the root page name to this page
10068    /// concatenated with `.`) can be used as reference to the page in your
10069    /// documentation. For example:
10070    ///
10071    /// You can reference `Java` page using Markdown reference link syntax:
10072    /// `[Java][Tutorial.Java]`.
10073    pub name: std::string::String,
10074
10075    /// The Markdown content of the page. You can use ```(== include {path}
10076    /// ==)``` to include content from a Markdown file. The content can be used
10077    /// to produce the documentation page such as HTML format page.
10078    pub content: std::string::String,
10079
10080    /// Subpages of this page. The order of subpages specified here will be
10081    /// honored in the generated docset.
10082    pub subpages: std::vec::Vec<crate::model::Page>,
10083
10084    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10085}
10086
10087impl Page {
10088    pub fn new() -> Self {
10089        std::default::Default::default()
10090    }
10091
10092    /// Sets the value of [name][crate::model::Page::name].
10093    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10094        self.name = v.into();
10095        self
10096    }
10097
10098    /// Sets the value of [content][crate::model::Page::content].
10099    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10100        self.content = v.into();
10101        self
10102    }
10103
10104    /// Sets the value of [subpages][crate::model::Page::subpages].
10105    pub fn set_subpages<T, V>(mut self, v: T) -> Self
10106    where
10107        T: std::iter::IntoIterator<Item = V>,
10108        V: std::convert::Into<crate::model::Page>,
10109    {
10110        use std::iter::Iterator;
10111        self.subpages = v.into_iter().map(|i| i.into()).collect();
10112        self
10113    }
10114}
10115
10116impl wkt::message::Message for Page {
10117    fn typename() -> &'static str {
10118        "type.googleapis.com/google.api.Page"
10119    }
10120}
10121
10122#[doc(hidden)]
10123impl<'de> serde::de::Deserialize<'de> for Page {
10124    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10125    where
10126        D: serde::Deserializer<'de>,
10127    {
10128        #[allow(non_camel_case_types)]
10129        #[doc(hidden)]
10130        #[derive(PartialEq, Eq, Hash)]
10131        enum __FieldTag {
10132            __name,
10133            __content,
10134            __subpages,
10135            Unknown(std::string::String),
10136        }
10137        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10138            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10139            where
10140                D: serde::Deserializer<'de>,
10141            {
10142                struct Visitor;
10143                impl<'de> serde::de::Visitor<'de> for Visitor {
10144                    type Value = __FieldTag;
10145                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10146                        formatter.write_str("a field name for Page")
10147                    }
10148                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10149                    where
10150                        E: serde::de::Error,
10151                    {
10152                        use std::result::Result::Ok;
10153                        use std::string::ToString;
10154                        match value {
10155                            "name" => Ok(__FieldTag::__name),
10156                            "content" => Ok(__FieldTag::__content),
10157                            "subpages" => Ok(__FieldTag::__subpages),
10158                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10159                        }
10160                    }
10161                }
10162                deserializer.deserialize_identifier(Visitor)
10163            }
10164        }
10165        struct Visitor;
10166        impl<'de> serde::de::Visitor<'de> for Visitor {
10167            type Value = Page;
10168            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10169                formatter.write_str("struct Page")
10170            }
10171            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10172            where
10173                A: serde::de::MapAccess<'de>,
10174            {
10175                #[allow(unused_imports)]
10176                use serde::de::Error;
10177                use std::option::Option::Some;
10178                let mut fields = std::collections::HashSet::new();
10179                let mut result = Self::Value::new();
10180                while let Some(tag) = map.next_key::<__FieldTag>()? {
10181                    #[allow(clippy::match_single_binding)]
10182                    match tag {
10183                        __FieldTag::__name => {
10184                            if !fields.insert(__FieldTag::__name) {
10185                                return std::result::Result::Err(A::Error::duplicate_field(
10186                                    "multiple values for name",
10187                                ));
10188                            }
10189                            result.name = map
10190                                .next_value::<std::option::Option<std::string::String>>()?
10191                                .unwrap_or_default();
10192                        }
10193                        __FieldTag::__content => {
10194                            if !fields.insert(__FieldTag::__content) {
10195                                return std::result::Result::Err(A::Error::duplicate_field(
10196                                    "multiple values for content",
10197                                ));
10198                            }
10199                            result.content = map
10200                                .next_value::<std::option::Option<std::string::String>>()?
10201                                .unwrap_or_default();
10202                        }
10203                        __FieldTag::__subpages => {
10204                            if !fields.insert(__FieldTag::__subpages) {
10205                                return std::result::Result::Err(A::Error::duplicate_field(
10206                                    "multiple values for subpages",
10207                                ));
10208                            }
10209                            result.subpages = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Page>>>()?.unwrap_or_default();
10210                        }
10211                        __FieldTag::Unknown(key) => {
10212                            let value = map.next_value::<serde_json::Value>()?;
10213                            result._unknown_fields.insert(key, value);
10214                        }
10215                    }
10216                }
10217                std::result::Result::Ok(result)
10218            }
10219        }
10220        deserializer.deserialize_any(Visitor)
10221    }
10222}
10223
10224#[doc(hidden)]
10225impl serde::ser::Serialize for Page {
10226    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10227    where
10228        S: serde::ser::Serializer,
10229    {
10230        use serde::ser::SerializeMap;
10231        #[allow(unused_imports)]
10232        use std::option::Option::Some;
10233        let mut state = serializer.serialize_map(std::option::Option::None)?;
10234        if !self.name.is_empty() {
10235            state.serialize_entry("name", &self.name)?;
10236        }
10237        if !self.content.is_empty() {
10238            state.serialize_entry("content", &self.content)?;
10239        }
10240        if !self.subpages.is_empty() {
10241            state.serialize_entry("subpages", &self.subpages)?;
10242        }
10243        if !self._unknown_fields.is_empty() {
10244            for (key, value) in self._unknown_fields.iter() {
10245                state.serialize_entry(key, &value)?;
10246            }
10247        }
10248        state.end()
10249    }
10250}
10251
10252/// `Endpoint` describes a network address of a service that serves a set of
10253/// APIs. It is commonly known as a service endpoint. A service may expose
10254/// any number of service endpoints, and all service endpoints share the same
10255/// service definition, such as quota limits and monitoring metrics.
10256///
10257/// Example:
10258///
10259/// ```norust
10260/// type: google.api.Service
10261/// name: library-example.googleapis.com
10262/// endpoints:
10263///   # Declares network address `https://library-example.googleapis.com`
10264///   # for service `library-example.googleapis.com`. The `https` scheme
10265///   # is implicit for all service endpoints. Other schemes may be
10266///   # supported in the future.
10267/// - name: library-example.googleapis.com
10268///   allow_cors: false
10269/// - name: content-staging-library-example.googleapis.com
10270///   # Allows HTTP OPTIONS calls to be passed to the API frontend, for it
10271///   # to decide whether the subsequent cross-origin request is allowed
10272///   # to proceed.
10273///   allow_cors: true
10274/// ```
10275#[derive(Clone, Debug, Default, PartialEq)]
10276#[non_exhaustive]
10277pub struct Endpoint {
10278    /// The canonical name of this endpoint.
10279    pub name: std::string::String,
10280
10281    /// Aliases for this endpoint, these will be served by the same UrlMap as the
10282    /// parent endpoint, and will be provisioned in the GCP stack for the Regional
10283    /// Endpoints.
10284    pub aliases: std::vec::Vec<std::string::String>,
10285
10286    /// The specification of an Internet routable address of API frontend that will
10287    /// handle requests to this [API
10288    /// Endpoint](https://cloud.google.com/apis/design/glossary). It should be
10289    /// either a valid IPv4 address or a fully-qualified domain name. For example,
10290    /// "8.8.8.8" or "myservice.appspot.com".
10291    pub target: std::string::String,
10292
10293    /// Allowing
10294    /// [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka
10295    /// cross-domain traffic, would allow the backends served from this endpoint to
10296    /// receive and respond to HTTP OPTIONS requests. The response will be used by
10297    /// the browser to determine whether the subsequent cross-origin request is
10298    /// allowed to proceed.
10299    pub allow_cors: bool,
10300
10301    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10302}
10303
10304impl Endpoint {
10305    pub fn new() -> Self {
10306        std::default::Default::default()
10307    }
10308
10309    /// Sets the value of [name][crate::model::Endpoint::name].
10310    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10311        self.name = v.into();
10312        self
10313    }
10314
10315    /// Sets the value of [aliases][crate::model::Endpoint::aliases].
10316    pub fn set_aliases<T, V>(mut self, v: T) -> Self
10317    where
10318        T: std::iter::IntoIterator<Item = V>,
10319        V: std::convert::Into<std::string::String>,
10320    {
10321        use std::iter::Iterator;
10322        self.aliases = v.into_iter().map(|i| i.into()).collect();
10323        self
10324    }
10325
10326    /// Sets the value of [target][crate::model::Endpoint::target].
10327    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10328        self.target = v.into();
10329        self
10330    }
10331
10332    /// Sets the value of [allow_cors][crate::model::Endpoint::allow_cors].
10333    pub fn set_allow_cors<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10334        self.allow_cors = v.into();
10335        self
10336    }
10337}
10338
10339impl wkt::message::Message for Endpoint {
10340    fn typename() -> &'static str {
10341        "type.googleapis.com/google.api.Endpoint"
10342    }
10343}
10344
10345#[doc(hidden)]
10346impl<'de> serde::de::Deserialize<'de> for Endpoint {
10347    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10348    where
10349        D: serde::Deserializer<'de>,
10350    {
10351        #[allow(non_camel_case_types)]
10352        #[doc(hidden)]
10353        #[derive(PartialEq, Eq, Hash)]
10354        enum __FieldTag {
10355            __name,
10356            __aliases,
10357            __target,
10358            __allow_cors,
10359            Unknown(std::string::String),
10360        }
10361        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10362            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10363            where
10364                D: serde::Deserializer<'de>,
10365            {
10366                struct Visitor;
10367                impl<'de> serde::de::Visitor<'de> for Visitor {
10368                    type Value = __FieldTag;
10369                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10370                        formatter.write_str("a field name for Endpoint")
10371                    }
10372                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10373                    where
10374                        E: serde::de::Error,
10375                    {
10376                        use std::result::Result::Ok;
10377                        use std::string::ToString;
10378                        match value {
10379                            "name" => Ok(__FieldTag::__name),
10380                            "aliases" => Ok(__FieldTag::__aliases),
10381                            "target" => Ok(__FieldTag::__target),
10382                            "allowCors" => Ok(__FieldTag::__allow_cors),
10383                            "allow_cors" => Ok(__FieldTag::__allow_cors),
10384                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10385                        }
10386                    }
10387                }
10388                deserializer.deserialize_identifier(Visitor)
10389            }
10390        }
10391        struct Visitor;
10392        impl<'de> serde::de::Visitor<'de> for Visitor {
10393            type Value = Endpoint;
10394            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10395                formatter.write_str("struct Endpoint")
10396            }
10397            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10398            where
10399                A: serde::de::MapAccess<'de>,
10400            {
10401                #[allow(unused_imports)]
10402                use serde::de::Error;
10403                use std::option::Option::Some;
10404                let mut fields = std::collections::HashSet::new();
10405                let mut result = Self::Value::new();
10406                while let Some(tag) = map.next_key::<__FieldTag>()? {
10407                    #[allow(clippy::match_single_binding)]
10408                    match tag {
10409                        __FieldTag::__name => {
10410                            if !fields.insert(__FieldTag::__name) {
10411                                return std::result::Result::Err(A::Error::duplicate_field(
10412                                    "multiple values for name",
10413                                ));
10414                            }
10415                            result.name = map
10416                                .next_value::<std::option::Option<std::string::String>>()?
10417                                .unwrap_or_default();
10418                        }
10419                        __FieldTag::__aliases => {
10420                            if !fields.insert(__FieldTag::__aliases) {
10421                                return std::result::Result::Err(A::Error::duplicate_field(
10422                                    "multiple values for aliases",
10423                                ));
10424                            }
10425                            result.aliases = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
10426                        }
10427                        __FieldTag::__target => {
10428                            if !fields.insert(__FieldTag::__target) {
10429                                return std::result::Result::Err(A::Error::duplicate_field(
10430                                    "multiple values for target",
10431                                ));
10432                            }
10433                            result.target = map
10434                                .next_value::<std::option::Option<std::string::String>>()?
10435                                .unwrap_or_default();
10436                        }
10437                        __FieldTag::__allow_cors => {
10438                            if !fields.insert(__FieldTag::__allow_cors) {
10439                                return std::result::Result::Err(A::Error::duplicate_field(
10440                                    "multiple values for allow_cors",
10441                                ));
10442                            }
10443                            result.allow_cors = map
10444                                .next_value::<std::option::Option<bool>>()?
10445                                .unwrap_or_default();
10446                        }
10447                        __FieldTag::Unknown(key) => {
10448                            let value = map.next_value::<serde_json::Value>()?;
10449                            result._unknown_fields.insert(key, value);
10450                        }
10451                    }
10452                }
10453                std::result::Result::Ok(result)
10454            }
10455        }
10456        deserializer.deserialize_any(Visitor)
10457    }
10458}
10459
10460#[doc(hidden)]
10461impl serde::ser::Serialize for Endpoint {
10462    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10463    where
10464        S: serde::ser::Serializer,
10465    {
10466        use serde::ser::SerializeMap;
10467        #[allow(unused_imports)]
10468        use std::option::Option::Some;
10469        let mut state = serializer.serialize_map(std::option::Option::None)?;
10470        if !self.name.is_empty() {
10471            state.serialize_entry("name", &self.name)?;
10472        }
10473        if !self.aliases.is_empty() {
10474            state.serialize_entry("aliases", &self.aliases)?;
10475        }
10476        if !self.target.is_empty() {
10477            state.serialize_entry("target", &self.target)?;
10478        }
10479        if !wkt::internal::is_default(&self.allow_cors) {
10480            state.serialize_entry("allowCors", &self.allow_cors)?;
10481        }
10482        if !self._unknown_fields.is_empty() {
10483            for (key, value) in self._unknown_fields.iter() {
10484                state.serialize_entry(key, &value)?;
10485            }
10486        }
10487        state.end()
10488    }
10489}
10490
10491/// Rich semantic information of an API field beyond basic typing.
10492#[derive(Clone, Debug, Default, PartialEq)]
10493#[non_exhaustive]
10494pub struct FieldInfo {
10495    /// The standard format of a field value. This does not explicitly configure
10496    /// any API consumer, just documents the API's format for the field it is
10497    /// applied to.
10498    pub format: crate::model::field_info::Format,
10499
10500    /// The type(s) that the annotated, generic field may represent.
10501    ///
10502    /// Currently, this must only be used on fields of type `google.protobuf.Any`.
10503    /// Supporting other generic types may be considered in the future.
10504    pub referenced_types: std::vec::Vec<crate::model::TypeReference>,
10505
10506    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10507}
10508
10509impl FieldInfo {
10510    pub fn new() -> Self {
10511        std::default::Default::default()
10512    }
10513
10514    /// Sets the value of [format][crate::model::FieldInfo::format].
10515    pub fn set_format<T: std::convert::Into<crate::model::field_info::Format>>(
10516        mut self,
10517        v: T,
10518    ) -> Self {
10519        self.format = v.into();
10520        self
10521    }
10522
10523    /// Sets the value of [referenced_types][crate::model::FieldInfo::referenced_types].
10524    pub fn set_referenced_types<T, V>(mut self, v: T) -> Self
10525    where
10526        T: std::iter::IntoIterator<Item = V>,
10527        V: std::convert::Into<crate::model::TypeReference>,
10528    {
10529        use std::iter::Iterator;
10530        self.referenced_types = v.into_iter().map(|i| i.into()).collect();
10531        self
10532    }
10533}
10534
10535impl wkt::message::Message for FieldInfo {
10536    fn typename() -> &'static str {
10537        "type.googleapis.com/google.api.FieldInfo"
10538    }
10539}
10540
10541#[doc(hidden)]
10542impl<'de> serde::de::Deserialize<'de> for FieldInfo {
10543    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10544    where
10545        D: serde::Deserializer<'de>,
10546    {
10547        #[allow(non_camel_case_types)]
10548        #[doc(hidden)]
10549        #[derive(PartialEq, Eq, Hash)]
10550        enum __FieldTag {
10551            __format,
10552            __referenced_types,
10553            Unknown(std::string::String),
10554        }
10555        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10556            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10557            where
10558                D: serde::Deserializer<'de>,
10559            {
10560                struct Visitor;
10561                impl<'de> serde::de::Visitor<'de> for Visitor {
10562                    type Value = __FieldTag;
10563                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10564                        formatter.write_str("a field name for FieldInfo")
10565                    }
10566                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10567                    where
10568                        E: serde::de::Error,
10569                    {
10570                        use std::result::Result::Ok;
10571                        use std::string::ToString;
10572                        match value {
10573                            "format" => Ok(__FieldTag::__format),
10574                            "referencedTypes" => Ok(__FieldTag::__referenced_types),
10575                            "referenced_types" => Ok(__FieldTag::__referenced_types),
10576                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10577                        }
10578                    }
10579                }
10580                deserializer.deserialize_identifier(Visitor)
10581            }
10582        }
10583        struct Visitor;
10584        impl<'de> serde::de::Visitor<'de> for Visitor {
10585            type Value = FieldInfo;
10586            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10587                formatter.write_str("struct FieldInfo")
10588            }
10589            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10590            where
10591                A: serde::de::MapAccess<'de>,
10592            {
10593                #[allow(unused_imports)]
10594                use serde::de::Error;
10595                use std::option::Option::Some;
10596                let mut fields = std::collections::HashSet::new();
10597                let mut result = Self::Value::new();
10598                while let Some(tag) = map.next_key::<__FieldTag>()? {
10599                    #[allow(clippy::match_single_binding)]
10600                    match tag {
10601                        __FieldTag::__format => {
10602                            if !fields.insert(__FieldTag::__format) {
10603                                return std::result::Result::Err(A::Error::duplicate_field(
10604                                    "multiple values for format",
10605                                ));
10606                            }
10607                            result.format = map.next_value::<std::option::Option<crate::model::field_info::Format>>()?.unwrap_or_default();
10608                        }
10609                        __FieldTag::__referenced_types => {
10610                            if !fields.insert(__FieldTag::__referenced_types) {
10611                                return std::result::Result::Err(A::Error::duplicate_field(
10612                                    "multiple values for referenced_types",
10613                                ));
10614                            }
10615                            result.referenced_types = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TypeReference>>>()?.unwrap_or_default();
10616                        }
10617                        __FieldTag::Unknown(key) => {
10618                            let value = map.next_value::<serde_json::Value>()?;
10619                            result._unknown_fields.insert(key, value);
10620                        }
10621                    }
10622                }
10623                std::result::Result::Ok(result)
10624            }
10625        }
10626        deserializer.deserialize_any(Visitor)
10627    }
10628}
10629
10630#[doc(hidden)]
10631impl serde::ser::Serialize for FieldInfo {
10632    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10633    where
10634        S: serde::ser::Serializer,
10635    {
10636        use serde::ser::SerializeMap;
10637        #[allow(unused_imports)]
10638        use std::option::Option::Some;
10639        let mut state = serializer.serialize_map(std::option::Option::None)?;
10640        if !wkt::internal::is_default(&self.format) {
10641            state.serialize_entry("format", &self.format)?;
10642        }
10643        if !self.referenced_types.is_empty() {
10644            state.serialize_entry("referencedTypes", &self.referenced_types)?;
10645        }
10646        if !self._unknown_fields.is_empty() {
10647            for (key, value) in self._unknown_fields.iter() {
10648                state.serialize_entry(key, &value)?;
10649            }
10650        }
10651        state.end()
10652    }
10653}
10654
10655/// Defines additional types related to [FieldInfo].
10656pub mod field_info {
10657    #[allow(unused_imports)]
10658    use super::*;
10659
10660    /// The standard format of a field value. The supported formats are all backed
10661    /// by either an RFC defined by the IETF or a Google-defined AIP.
10662    ///
10663    /// # Working with unknown values
10664    ///
10665    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10666    /// additional enum variants at any time. Adding new variants is not considered
10667    /// a breaking change. Applications should write their code in anticipation of:
10668    ///
10669    /// - New values appearing in future releases of the client library, **and**
10670    /// - New values received dynamically, without application changes.
10671    ///
10672    /// Please consult the [Working with enums] section in the user guide for some
10673    /// guidelines.
10674    ///
10675    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10676    #[derive(Clone, Debug, PartialEq)]
10677    #[non_exhaustive]
10678    pub enum Format {
10679        /// Default, unspecified value.
10680        Unspecified,
10681        /// Universally Unique Identifier, version 4, value as defined by
10682        /// <https://datatracker.ietf.org/doc/html/rfc4122>. The value may be
10683        /// normalized to entirely lowercase letters. For example, the value
10684        /// `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to
10685        /// `f47ac10b-58cc-0372-8567-0e02b2c3d479`.
10686        Uuid4,
10687        /// Internet Protocol v4 value as defined by [RFC
10688        /// 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be
10689        /// condensed, with leading zeros in each octet stripped. For example,
10690        /// `001.022.233.040` would be condensed to `1.22.233.40`.
10691        Ipv4,
10692        /// Internet Protocol v6 value as defined by [RFC
10693        /// 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be
10694        /// normalized to entirely lowercase letters with zeros compressed, following
10695        /// [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example,
10696        /// the value `2001:0DB8:0::0` would be normalized to `2001:db8::`.
10697        Ipv6,
10698        /// An IP address in either v4 or v6 format as described by the individual
10699        /// values defined herein. See the comments on the IPV4 and IPV6 types for
10700        /// allowed normalizations of each.
10701        Ipv4OrIpv6,
10702        /// If set, the enum was initialized with an unknown value.
10703        ///
10704        /// Applications can examine the value using [Format::value] or
10705        /// [Format::name].
10706        UnknownValue(format::UnknownValue),
10707    }
10708
10709    #[doc(hidden)]
10710    pub mod format {
10711        #[allow(unused_imports)]
10712        use super::*;
10713        #[derive(Clone, Debug, PartialEq)]
10714        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10715    }
10716
10717    impl Format {
10718        /// Gets the enum value.
10719        ///
10720        /// Returns `None` if the enum contains an unknown value deserialized from
10721        /// the string representation of enums.
10722        pub fn value(&self) -> std::option::Option<i32> {
10723            match self {
10724                Self::Unspecified => std::option::Option::Some(0),
10725                Self::Uuid4 => std::option::Option::Some(1),
10726                Self::Ipv4 => std::option::Option::Some(2),
10727                Self::Ipv6 => std::option::Option::Some(3),
10728                Self::Ipv4OrIpv6 => std::option::Option::Some(4),
10729                Self::UnknownValue(u) => u.0.value(),
10730            }
10731        }
10732
10733        /// Gets the enum value as a string.
10734        ///
10735        /// Returns `None` if the enum contains an unknown value deserialized from
10736        /// the integer representation of enums.
10737        pub fn name(&self) -> std::option::Option<&str> {
10738            match self {
10739                Self::Unspecified => std::option::Option::Some("FORMAT_UNSPECIFIED"),
10740                Self::Uuid4 => std::option::Option::Some("UUID4"),
10741                Self::Ipv4 => std::option::Option::Some("IPV4"),
10742                Self::Ipv6 => std::option::Option::Some("IPV6"),
10743                Self::Ipv4OrIpv6 => std::option::Option::Some("IPV4_OR_IPV6"),
10744                Self::UnknownValue(u) => u.0.name(),
10745            }
10746        }
10747    }
10748
10749    impl std::default::Default for Format {
10750        fn default() -> Self {
10751            use std::convert::From;
10752            Self::from(0)
10753        }
10754    }
10755
10756    impl std::fmt::Display for Format {
10757        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10758            wkt::internal::display_enum(f, self.name(), self.value())
10759        }
10760    }
10761
10762    impl std::convert::From<i32> for Format {
10763        fn from(value: i32) -> Self {
10764            match value {
10765                0 => Self::Unspecified,
10766                1 => Self::Uuid4,
10767                2 => Self::Ipv4,
10768                3 => Self::Ipv6,
10769                4 => Self::Ipv4OrIpv6,
10770                _ => Self::UnknownValue(format::UnknownValue(
10771                    wkt::internal::UnknownEnumValue::Integer(value),
10772                )),
10773            }
10774        }
10775    }
10776
10777    impl std::convert::From<&str> for Format {
10778        fn from(value: &str) -> Self {
10779            use std::string::ToString;
10780            match value {
10781                "FORMAT_UNSPECIFIED" => Self::Unspecified,
10782                "UUID4" => Self::Uuid4,
10783                "IPV4" => Self::Ipv4,
10784                "IPV6" => Self::Ipv6,
10785                "IPV4_OR_IPV6" => Self::Ipv4OrIpv6,
10786                _ => Self::UnknownValue(format::UnknownValue(
10787                    wkt::internal::UnknownEnumValue::String(value.to_string()),
10788                )),
10789            }
10790        }
10791    }
10792
10793    impl serde::ser::Serialize for Format {
10794        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10795        where
10796            S: serde::Serializer,
10797        {
10798            match self {
10799                Self::Unspecified => serializer.serialize_i32(0),
10800                Self::Uuid4 => serializer.serialize_i32(1),
10801                Self::Ipv4 => serializer.serialize_i32(2),
10802                Self::Ipv6 => serializer.serialize_i32(3),
10803                Self::Ipv4OrIpv6 => serializer.serialize_i32(4),
10804                Self::UnknownValue(u) => u.0.serialize(serializer),
10805            }
10806        }
10807    }
10808
10809    impl<'de> serde::de::Deserialize<'de> for Format {
10810        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10811        where
10812            D: serde::Deserializer<'de>,
10813        {
10814            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Format>::new(
10815                ".google.api.FieldInfo.Format",
10816            ))
10817        }
10818    }
10819}
10820
10821/// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo].
10822///
10823/// [google.api.FieldInfo]: crate::model::FieldInfo
10824#[derive(Clone, Debug, Default, PartialEq)]
10825#[non_exhaustive]
10826pub struct TypeReference {
10827    /// The name of the type that the annotated, generic field may represent.
10828    /// If the type is in the same protobuf package, the value can be the simple
10829    /// message name e.g., `"MyMessage"`. Otherwise, the value must be the
10830    /// fully-qualified message name e.g., `"google.library.v1.Book"`.
10831    ///
10832    /// If the type(s) are unknown to the service (e.g. the field accepts generic
10833    /// user input), use the wildcard `"*"` to denote this behavior.
10834    ///
10835    /// See [AIP-202](https://google.aip.dev/202#type-references) for more details.
10836    pub type_name: std::string::String,
10837
10838    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10839}
10840
10841impl TypeReference {
10842    pub fn new() -> Self {
10843        std::default::Default::default()
10844    }
10845
10846    /// Sets the value of [type_name][crate::model::TypeReference::type_name].
10847    pub fn set_type_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10848        self.type_name = v.into();
10849        self
10850    }
10851}
10852
10853impl wkt::message::Message for TypeReference {
10854    fn typename() -> &'static str {
10855        "type.googleapis.com/google.api.TypeReference"
10856    }
10857}
10858
10859#[doc(hidden)]
10860impl<'de> serde::de::Deserialize<'de> for TypeReference {
10861    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10862    where
10863        D: serde::Deserializer<'de>,
10864    {
10865        #[allow(non_camel_case_types)]
10866        #[doc(hidden)]
10867        #[derive(PartialEq, Eq, Hash)]
10868        enum __FieldTag {
10869            __type_name,
10870            Unknown(std::string::String),
10871        }
10872        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10873            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10874            where
10875                D: serde::Deserializer<'de>,
10876            {
10877                struct Visitor;
10878                impl<'de> serde::de::Visitor<'de> for Visitor {
10879                    type Value = __FieldTag;
10880                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10881                        formatter.write_str("a field name for TypeReference")
10882                    }
10883                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10884                    where
10885                        E: serde::de::Error,
10886                    {
10887                        use std::result::Result::Ok;
10888                        use std::string::ToString;
10889                        match value {
10890                            "typeName" => Ok(__FieldTag::__type_name),
10891                            "type_name" => Ok(__FieldTag::__type_name),
10892                            _ => Ok(__FieldTag::Unknown(value.to_string())),
10893                        }
10894                    }
10895                }
10896                deserializer.deserialize_identifier(Visitor)
10897            }
10898        }
10899        struct Visitor;
10900        impl<'de> serde::de::Visitor<'de> for Visitor {
10901            type Value = TypeReference;
10902            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10903                formatter.write_str("struct TypeReference")
10904            }
10905            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10906            where
10907                A: serde::de::MapAccess<'de>,
10908            {
10909                #[allow(unused_imports)]
10910                use serde::de::Error;
10911                use std::option::Option::Some;
10912                let mut fields = std::collections::HashSet::new();
10913                let mut result = Self::Value::new();
10914                while let Some(tag) = map.next_key::<__FieldTag>()? {
10915                    #[allow(clippy::match_single_binding)]
10916                    match tag {
10917                        __FieldTag::__type_name => {
10918                            if !fields.insert(__FieldTag::__type_name) {
10919                                return std::result::Result::Err(A::Error::duplicate_field(
10920                                    "multiple values for type_name",
10921                                ));
10922                            }
10923                            result.type_name = map
10924                                .next_value::<std::option::Option<std::string::String>>()?
10925                                .unwrap_or_default();
10926                        }
10927                        __FieldTag::Unknown(key) => {
10928                            let value = map.next_value::<serde_json::Value>()?;
10929                            result._unknown_fields.insert(key, value);
10930                        }
10931                    }
10932                }
10933                std::result::Result::Ok(result)
10934            }
10935        }
10936        deserializer.deserialize_any(Visitor)
10937    }
10938}
10939
10940#[doc(hidden)]
10941impl serde::ser::Serialize for TypeReference {
10942    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10943    where
10944        S: serde::ser::Serializer,
10945    {
10946        use serde::ser::SerializeMap;
10947        #[allow(unused_imports)]
10948        use std::option::Option::Some;
10949        let mut state = serializer.serialize_map(std::option::Option::None)?;
10950        if !self.type_name.is_empty() {
10951            state.serialize_entry("typeName", &self.type_name)?;
10952        }
10953        if !self._unknown_fields.is_empty() {
10954            for (key, value) in self._unknown_fields.iter() {
10955                state.serialize_entry(key, &value)?;
10956            }
10957        }
10958        state.end()
10959    }
10960}
10961
10962/// Defines the HTTP configuration for an API service. It contains a list of
10963/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
10964/// to one or more HTTP REST API methods.
10965///
10966/// [google.api.HttpRule]: crate::model::HttpRule
10967#[derive(Clone, Debug, Default, PartialEq)]
10968#[non_exhaustive]
10969pub struct Http {
10970    /// A list of HTTP configuration rules that apply to individual API methods.
10971    ///
10972    /// **NOTE:** All service configuration rules follow "last one wins" order.
10973    pub rules: std::vec::Vec<crate::model::HttpRule>,
10974
10975    /// When set to true, URL path parameters will be fully URI-decoded except in
10976    /// cases of single segment matches in reserved expansion, where "%2F" will be
10977    /// left encoded.
10978    ///
10979    /// The default behavior is to not decode RFC 6570 reserved characters in multi
10980    /// segment matches.
10981    pub fully_decode_reserved_expansion: bool,
10982
10983    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10984}
10985
10986impl Http {
10987    pub fn new() -> Self {
10988        std::default::Default::default()
10989    }
10990
10991    /// Sets the value of [rules][crate::model::Http::rules].
10992    pub fn set_rules<T, V>(mut self, v: T) -> Self
10993    where
10994        T: std::iter::IntoIterator<Item = V>,
10995        V: std::convert::Into<crate::model::HttpRule>,
10996    {
10997        use std::iter::Iterator;
10998        self.rules = v.into_iter().map(|i| i.into()).collect();
10999        self
11000    }
11001
11002    /// Sets the value of [fully_decode_reserved_expansion][crate::model::Http::fully_decode_reserved_expansion].
11003    pub fn set_fully_decode_reserved_expansion<T: std::convert::Into<bool>>(
11004        mut self,
11005        v: T,
11006    ) -> Self {
11007        self.fully_decode_reserved_expansion = v.into();
11008        self
11009    }
11010}
11011
11012impl wkt::message::Message for Http {
11013    fn typename() -> &'static str {
11014        "type.googleapis.com/google.api.Http"
11015    }
11016}
11017
11018#[doc(hidden)]
11019impl<'de> serde::de::Deserialize<'de> for Http {
11020    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11021    where
11022        D: serde::Deserializer<'de>,
11023    {
11024        #[allow(non_camel_case_types)]
11025        #[doc(hidden)]
11026        #[derive(PartialEq, Eq, Hash)]
11027        enum __FieldTag {
11028            __rules,
11029            __fully_decode_reserved_expansion,
11030            Unknown(std::string::String),
11031        }
11032        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11033            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11034            where
11035                D: serde::Deserializer<'de>,
11036            {
11037                struct Visitor;
11038                impl<'de> serde::de::Visitor<'de> for Visitor {
11039                    type Value = __FieldTag;
11040                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11041                        formatter.write_str("a field name for Http")
11042                    }
11043                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11044                    where
11045                        E: serde::de::Error,
11046                    {
11047                        use std::result::Result::Ok;
11048                        use std::string::ToString;
11049                        match value {
11050                            "rules" => Ok(__FieldTag::__rules),
11051                            "fullyDecodeReservedExpansion" => {
11052                                Ok(__FieldTag::__fully_decode_reserved_expansion)
11053                            }
11054                            "fully_decode_reserved_expansion" => {
11055                                Ok(__FieldTag::__fully_decode_reserved_expansion)
11056                            }
11057                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11058                        }
11059                    }
11060                }
11061                deserializer.deserialize_identifier(Visitor)
11062            }
11063        }
11064        struct Visitor;
11065        impl<'de> serde::de::Visitor<'de> for Visitor {
11066            type Value = Http;
11067            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11068                formatter.write_str("struct Http")
11069            }
11070            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11071            where
11072                A: serde::de::MapAccess<'de>,
11073            {
11074                #[allow(unused_imports)]
11075                use serde::de::Error;
11076                use std::option::Option::Some;
11077                let mut fields = std::collections::HashSet::new();
11078                let mut result = Self::Value::new();
11079                while let Some(tag) = map.next_key::<__FieldTag>()? {
11080                    #[allow(clippy::match_single_binding)]
11081                    match tag {
11082                        __FieldTag::__rules => {
11083                            if !fields.insert(__FieldTag::__rules) {
11084                                return std::result::Result::Err(A::Error::duplicate_field(
11085                                    "multiple values for rules",
11086                                ));
11087                            }
11088                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpRule>>>()?.unwrap_or_default();
11089                        }
11090                        __FieldTag::__fully_decode_reserved_expansion => {
11091                            if !fields.insert(__FieldTag::__fully_decode_reserved_expansion) {
11092                                return std::result::Result::Err(A::Error::duplicate_field(
11093                                    "multiple values for fully_decode_reserved_expansion",
11094                                ));
11095                            }
11096                            result.fully_decode_reserved_expansion = map
11097                                .next_value::<std::option::Option<bool>>()?
11098                                .unwrap_or_default();
11099                        }
11100                        __FieldTag::Unknown(key) => {
11101                            let value = map.next_value::<serde_json::Value>()?;
11102                            result._unknown_fields.insert(key, value);
11103                        }
11104                    }
11105                }
11106                std::result::Result::Ok(result)
11107            }
11108        }
11109        deserializer.deserialize_any(Visitor)
11110    }
11111}
11112
11113#[doc(hidden)]
11114impl serde::ser::Serialize for Http {
11115    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11116    where
11117        S: serde::ser::Serializer,
11118    {
11119        use serde::ser::SerializeMap;
11120        #[allow(unused_imports)]
11121        use std::option::Option::Some;
11122        let mut state = serializer.serialize_map(std::option::Option::None)?;
11123        if !self.rules.is_empty() {
11124            state.serialize_entry("rules", &self.rules)?;
11125        }
11126        if !wkt::internal::is_default(&self.fully_decode_reserved_expansion) {
11127            state.serialize_entry(
11128                "fullyDecodeReservedExpansion",
11129                &self.fully_decode_reserved_expansion,
11130            )?;
11131        }
11132        if !self._unknown_fields.is_empty() {
11133            for (key, value) in self._unknown_fields.iter() {
11134                state.serialize_entry(key, &value)?;
11135            }
11136        }
11137        state.end()
11138    }
11139}
11140
11141/// gRPC Transcoding
11142///
11143/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
11144/// more HTTP REST endpoints. It allows developers to build a single API service
11145/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
11146/// APIs](https://github.com/googleapis/googleapis),
11147/// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC
11148/// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),
11149/// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature
11150/// and use it for large scale production services.
11151///
11152/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
11153/// how different portions of the gRPC request message are mapped to the URL
11154/// path, URL query parameters, and HTTP request body. It also controls how the
11155/// gRPC response message is mapped to the HTTP response body. `HttpRule` is
11156/// typically specified as an `google.api.http` annotation on the gRPC method.
11157///
11158/// Each mapping specifies a URL path template and an HTTP method. The path
11159/// template may refer to one or more fields in the gRPC request message, as long
11160/// as each field is a non-repeated field with a primitive (non-message) type.
11161/// The path template controls how fields of the request message are mapped to
11162/// the URL path.
11163///
11164/// Example:
11165///
11166/// ```norust
11167/// service Messaging {
11168///   rpc GetMessage(GetMessageRequest) returns (Message) {
11169///     option (google.api.http) = {
11170///         get: "/v1/{name=messages/*}"
11171///     };
11172///   }
11173/// }
11174/// message GetMessageRequest {
11175///   string name = 1; // Mapped to URL path.
11176/// }
11177/// message Message {
11178///   string text = 1; // The resource content.
11179/// }
11180/// ```
11181///
11182/// This enables an HTTP REST to gRPC mapping as below:
11183///
11184/// - HTTP: `GET /v1/messages/123456`
11185/// - gRPC: `GetMessage(name: "messages/123456")`
11186///
11187/// Any fields in the request message which are not bound by the path template
11188/// automatically become HTTP query parameters if there is no HTTP request body.
11189/// For example:
11190///
11191/// ```norust
11192/// service Messaging {
11193///   rpc GetMessage(GetMessageRequest) returns (Message) {
11194///     option (google.api.http) = {
11195///         get:"/v1/messages/{message_id}"
11196///     };
11197///   }
11198/// }
11199/// message GetMessageRequest {
11200///   message SubMessage {
11201///     string subfield = 1;
11202///   }
11203///   string message_id = 1; // Mapped to URL path.
11204///   int64 revision = 2;    // Mapped to URL query parameter `revision`.
11205///   SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`.
11206/// }
11207/// ```
11208///
11209/// This enables a HTTP JSON to RPC mapping as below:
11210///
11211/// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo`
11212/// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub:
11213///   SubMessage(subfield: "foo"))`
11214///
11215/// Note that fields which are mapped to URL query parameters must have a
11216/// primitive type or a repeated primitive type or a non-repeated message type.
11217/// In the case of a repeated type, the parameter can be repeated in the URL
11218/// as `...?param=A&param=B`. In the case of a message type, each field of the
11219/// message is mapped to a separate parameter, such as
11220/// `...?foo.a=A&foo.b=B&foo.c=C`.
11221///
11222/// For HTTP methods that allow a request body, the `body` field
11223/// specifies the mapping. Consider a REST update method on the
11224/// message resource collection:
11225///
11226/// ```norust
11227/// service Messaging {
11228///   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
11229///     option (google.api.http) = {
11230///       patch: "/v1/messages/{message_id}"
11231///       body: "message"
11232///     };
11233///   }
11234/// }
11235/// message UpdateMessageRequest {
11236///   string message_id = 1; // mapped to the URL
11237///   Message message = 2;   // mapped to the body
11238/// }
11239/// ```
11240///
11241/// The following HTTP JSON to RPC mapping is enabled, where the
11242/// representation of the JSON in the request body is determined by
11243/// protos JSON encoding:
11244///
11245/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
11246/// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
11247///
11248/// The special name `*` can be used in the body mapping to define that
11249/// every field not bound by the path template should be mapped to the
11250/// request body.  This enables the following alternative definition of
11251/// the update method:
11252///
11253/// ```norust
11254/// service Messaging {
11255///   rpc UpdateMessage(Message) returns (Message) {
11256///     option (google.api.http) = {
11257///       patch: "/v1/messages/{message_id}"
11258///       body: "*"
11259///     };
11260///   }
11261/// }
11262/// message Message {
11263///   string message_id = 1;
11264///   string text = 2;
11265/// }
11266/// ```
11267///
11268/// The following HTTP JSON to RPC mapping is enabled:
11269///
11270/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
11271/// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")`
11272///
11273/// Note that when using `*` in the body mapping, it is not possible to
11274/// have HTTP parameters, as all fields not bound by the path end in
11275/// the body. This makes this option more rarely used in practice when
11276/// defining REST APIs. The common usage of `*` is in custom methods
11277/// which don't use the URL at all for transferring data.
11278///
11279/// It is possible to define multiple HTTP methods for one RPC by using
11280/// the `additional_bindings` option. Example:
11281///
11282/// ```norust
11283/// service Messaging {
11284///   rpc GetMessage(GetMessageRequest) returns (Message) {
11285///     option (google.api.http) = {
11286///       get: "/v1/messages/{message_id}"
11287///       additional_bindings {
11288///         get: "/v1/users/{user_id}/messages/{message_id}"
11289///       }
11290///     };
11291///   }
11292/// }
11293/// message GetMessageRequest {
11294///   string message_id = 1;
11295///   string user_id = 2;
11296/// }
11297/// ```
11298///
11299/// This enables the following two alternative HTTP JSON to RPC mappings:
11300///
11301/// - HTTP: `GET /v1/messages/123456`
11302///
11303/// - gRPC: `GetMessage(message_id: "123456")`
11304///
11305/// - HTTP: `GET /v1/users/me/messages/123456`
11306///
11307/// - gRPC: `GetMessage(user_id: "me" message_id: "123456")`
11308///
11309///
11310/// Rules for HTTP mapping
11311///
11312/// 1. Leaf request fields (recursive expansion nested messages in the request
11313///    message) are classified into three categories:
11314///    - Fields referred by the path template. They are passed via the URL path.
11315///    - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
11316///      are passed via the HTTP
11317///      request body.
11318///    - All other fields are passed via the URL query parameters, and the
11319///      parameter name is the field path in the request message. A repeated
11320///      field can be represented as multiple query parameters under the same
11321///      name.
11322/// 1. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
11323///    query parameter, all fields
11324///    are passed via URL path and HTTP request body.
11325/// 1. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
11326///    request body, all
11327///    fields are passed via URL path and URL query parameters.
11328///
11329/// Path template syntax
11330///
11331/// ```norust
11332/// Template = "/" Segments [ Verb ] ;
11333/// Segments = Segment { "/" Segment } ;
11334/// Segment  = "*" | "**" | LITERAL | Variable ;
11335/// Variable = "{" FieldPath [ "=" Segments ] "}" ;
11336/// FieldPath = IDENT { "." IDENT } ;
11337/// Verb     = ":" LITERAL ;
11338/// ```
11339///
11340/// The syntax `*` matches a single URL path segment. The syntax `**` matches
11341/// zero or more URL path segments, which must be the last part of the URL path
11342/// except the `Verb`.
11343///
11344/// The syntax `Variable` matches part of the URL path as specified by its
11345/// template. A variable template must not contain other variables. If a variable
11346/// matches a single path segment, its template may be omitted, e.g. `{var}`
11347/// is equivalent to `{var=*}`.
11348///
11349/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
11350/// contains any reserved character, such characters should be percent-encoded
11351/// before the matching.
11352///
11353/// If a variable contains exactly one path segment, such as `"{var}"` or
11354/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
11355/// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The
11356/// server side does the reverse decoding. Such variables show up in the
11357/// [Discovery
11358/// Document](https://developers.google.com/discovery/v1/reference/apis) as
11359/// `{var}`.
11360///
11361/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
11362/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
11363/// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.
11364/// The server side does the reverse decoding, except "%2F" and "%2f" are left
11365/// unchanged. Such variables show up in the
11366/// [Discovery
11367/// Document](https://developers.google.com/discovery/v1/reference/apis) as
11368/// `{+var}`.
11369///
11370/// Using gRPC API Service Configuration
11371///
11372/// gRPC API Service Configuration (service config) is a configuration language
11373/// for configuring a gRPC service to become a user-facing product. The
11374/// service config is simply the YAML representation of the `google.api.Service`
11375/// proto message.
11376///
11377/// As an alternative to annotating your proto file, you can configure gRPC
11378/// transcoding in your service config YAML files. You do this by specifying a
11379/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
11380/// effect as the proto annotation. This can be particularly useful if you
11381/// have a proto that is reused in multiple services. Note that any transcoding
11382/// specified in the service config will override any matching transcoding
11383/// configuration in the proto.
11384///
11385/// The following example selects a gRPC method and applies an `HttpRule` to it:
11386///
11387/// ```norust
11388/// http:
11389///   rules:
11390///     - selector: example.v1.Messaging.GetMessage
11391///       get: /v1/messages/{message_id}/{sub.subfield}
11392/// ```
11393///
11394/// Special notes
11395///
11396/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
11397/// proto to JSON conversion must follow the [proto3
11398/// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).
11399///
11400/// While the single segment variable follows the semantics of
11401/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String
11402/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
11403/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
11404/// does not expand special characters like `?` and `#`, which would lead
11405/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
11406/// for multi segment variables.
11407///
11408/// The path variables **must not** refer to any repeated or mapped field,
11409/// because client libraries are not capable of handling such variable expansion.
11410///
11411/// The path variables **must not** capture the leading "/" character. The reason
11412/// is that the most common use case "{var}" does not capture the leading "/"
11413/// character. For consistency, all path variables must share the same behavior.
11414///
11415/// Repeated message fields must not be mapped to URL query parameters, because
11416/// no client library can support such complicated mapping.
11417///
11418/// If an API needs to use a JSON array for request or response body, it can map
11419/// the request or response body to a repeated field. However, some gRPC
11420/// Transcoding implementations may not support this feature.
11421///
11422/// [google.api.HttpRule.body]: crate::model::HttpRule::body
11423#[derive(Clone, Debug, Default, PartialEq)]
11424#[non_exhaustive]
11425pub struct HttpRule {
11426    /// Selects a method to which this rule applies.
11427    ///
11428    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
11429    /// details.
11430    ///
11431    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
11432    pub selector: std::string::String,
11433
11434    /// The name of the request field whose value is mapped to the HTTP request
11435    /// body, or `*` for mapping all request fields not captured by the path
11436    /// pattern to the HTTP body, or omitted for not having any HTTP request body.
11437    ///
11438    /// NOTE: the referred field must be present at the top-level of the request
11439    /// message type.
11440    pub body: std::string::String,
11441
11442    /// Optional. The name of the response field whose value is mapped to the HTTP
11443    /// response body. When omitted, the entire response message will be used
11444    /// as the HTTP response body.
11445    ///
11446    /// NOTE: The referred field must be present at the top-level of the response
11447    /// message type.
11448    pub response_body: std::string::String,
11449
11450    /// Additional HTTP bindings for the selector. Nested bindings must
11451    /// not contain an `additional_bindings` field themselves (that is,
11452    /// the nesting may only be one level deep).
11453    pub additional_bindings: std::vec::Vec<crate::model::HttpRule>,
11454
11455    /// Determines the URL pattern is matched by this rules. This pattern can be
11456    /// used with any of the {get|put|post|delete|patch} methods. A custom method
11457    /// can be defined using the 'custom' field.
11458    pub pattern: std::option::Option<crate::model::http_rule::Pattern>,
11459
11460    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11461}
11462
11463impl HttpRule {
11464    pub fn new() -> Self {
11465        std::default::Default::default()
11466    }
11467
11468    /// Sets the value of [selector][crate::model::HttpRule::selector].
11469    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11470        self.selector = v.into();
11471        self
11472    }
11473
11474    /// Sets the value of [body][crate::model::HttpRule::body].
11475    pub fn set_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11476        self.body = v.into();
11477        self
11478    }
11479
11480    /// Sets the value of [response_body][crate::model::HttpRule::response_body].
11481    pub fn set_response_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11482        self.response_body = v.into();
11483        self
11484    }
11485
11486    /// Sets the value of [additional_bindings][crate::model::HttpRule::additional_bindings].
11487    pub fn set_additional_bindings<T, V>(mut self, v: T) -> Self
11488    where
11489        T: std::iter::IntoIterator<Item = V>,
11490        V: std::convert::Into<crate::model::HttpRule>,
11491    {
11492        use std::iter::Iterator;
11493        self.additional_bindings = v.into_iter().map(|i| i.into()).collect();
11494        self
11495    }
11496
11497    /// Sets the value of [pattern][crate::model::HttpRule::pattern].
11498    ///
11499    /// Note that all the setters affecting `pattern` are mutually
11500    /// exclusive.
11501    pub fn set_pattern<
11502        T: std::convert::Into<std::option::Option<crate::model::http_rule::Pattern>>,
11503    >(
11504        mut self,
11505        v: T,
11506    ) -> Self {
11507        self.pattern = v.into();
11508        self
11509    }
11510
11511    /// The value of [pattern][crate::model::HttpRule::pattern]
11512    /// if it holds a `Get`, `None` if the field is not set or
11513    /// holds a different branch.
11514    pub fn get(&self) -> std::option::Option<&std::string::String> {
11515        #[allow(unreachable_patterns)]
11516        self.pattern.as_ref().and_then(|v| match v {
11517            crate::model::http_rule::Pattern::Get(v) => std::option::Option::Some(v),
11518            _ => std::option::Option::None,
11519        })
11520    }
11521
11522    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11523    /// to hold a `Get`.
11524    ///
11525    /// Note that all the setters affecting `pattern` are
11526    /// mutually exclusive.
11527    pub fn set_get<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11528        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Get(v.into()));
11529        self
11530    }
11531
11532    /// The value of [pattern][crate::model::HttpRule::pattern]
11533    /// if it holds a `Put`, `None` if the field is not set or
11534    /// holds a different branch.
11535    pub fn put(&self) -> std::option::Option<&std::string::String> {
11536        #[allow(unreachable_patterns)]
11537        self.pattern.as_ref().and_then(|v| match v {
11538            crate::model::http_rule::Pattern::Put(v) => std::option::Option::Some(v),
11539            _ => std::option::Option::None,
11540        })
11541    }
11542
11543    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11544    /// to hold a `Put`.
11545    ///
11546    /// Note that all the setters affecting `pattern` are
11547    /// mutually exclusive.
11548    pub fn set_put<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11549        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Put(v.into()));
11550        self
11551    }
11552
11553    /// The value of [pattern][crate::model::HttpRule::pattern]
11554    /// if it holds a `Post`, `None` if the field is not set or
11555    /// holds a different branch.
11556    pub fn post(&self) -> std::option::Option<&std::string::String> {
11557        #[allow(unreachable_patterns)]
11558        self.pattern.as_ref().and_then(|v| match v {
11559            crate::model::http_rule::Pattern::Post(v) => std::option::Option::Some(v),
11560            _ => std::option::Option::None,
11561        })
11562    }
11563
11564    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11565    /// to hold a `Post`.
11566    ///
11567    /// Note that all the setters affecting `pattern` are
11568    /// mutually exclusive.
11569    pub fn set_post<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11570        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Post(v.into()));
11571        self
11572    }
11573
11574    /// The value of [pattern][crate::model::HttpRule::pattern]
11575    /// if it holds a `Delete`, `None` if the field is not set or
11576    /// holds a different branch.
11577    pub fn delete(&self) -> std::option::Option<&std::string::String> {
11578        #[allow(unreachable_patterns)]
11579        self.pattern.as_ref().and_then(|v| match v {
11580            crate::model::http_rule::Pattern::Delete(v) => std::option::Option::Some(v),
11581            _ => std::option::Option::None,
11582        })
11583    }
11584
11585    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11586    /// to hold a `Delete`.
11587    ///
11588    /// Note that all the setters affecting `pattern` are
11589    /// mutually exclusive.
11590    pub fn set_delete<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11591        self.pattern =
11592            std::option::Option::Some(crate::model::http_rule::Pattern::Delete(v.into()));
11593        self
11594    }
11595
11596    /// The value of [pattern][crate::model::HttpRule::pattern]
11597    /// if it holds a `Patch`, `None` if the field is not set or
11598    /// holds a different branch.
11599    pub fn patch(&self) -> std::option::Option<&std::string::String> {
11600        #[allow(unreachable_patterns)]
11601        self.pattern.as_ref().and_then(|v| match v {
11602            crate::model::http_rule::Pattern::Patch(v) => std::option::Option::Some(v),
11603            _ => std::option::Option::None,
11604        })
11605    }
11606
11607    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11608    /// to hold a `Patch`.
11609    ///
11610    /// Note that all the setters affecting `pattern` are
11611    /// mutually exclusive.
11612    pub fn set_patch<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11613        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Patch(v.into()));
11614        self
11615    }
11616
11617    /// The value of [pattern][crate::model::HttpRule::pattern]
11618    /// if it holds a `Custom`, `None` if the field is not set or
11619    /// holds a different branch.
11620    pub fn custom(&self) -> std::option::Option<&std::boxed::Box<crate::model::CustomHttpPattern>> {
11621        #[allow(unreachable_patterns)]
11622        self.pattern.as_ref().and_then(|v| match v {
11623            crate::model::http_rule::Pattern::Custom(v) => std::option::Option::Some(v),
11624            _ => std::option::Option::None,
11625        })
11626    }
11627
11628    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
11629    /// to hold a `Custom`.
11630    ///
11631    /// Note that all the setters affecting `pattern` are
11632    /// mutually exclusive.
11633    pub fn set_custom<T: std::convert::Into<std::boxed::Box<crate::model::CustomHttpPattern>>>(
11634        mut self,
11635        v: T,
11636    ) -> Self {
11637        self.pattern =
11638            std::option::Option::Some(crate::model::http_rule::Pattern::Custom(v.into()));
11639        self
11640    }
11641}
11642
11643impl wkt::message::Message for HttpRule {
11644    fn typename() -> &'static str {
11645        "type.googleapis.com/google.api.HttpRule"
11646    }
11647}
11648
11649#[doc(hidden)]
11650impl<'de> serde::de::Deserialize<'de> for HttpRule {
11651    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11652    where
11653        D: serde::Deserializer<'de>,
11654    {
11655        #[allow(non_camel_case_types)]
11656        #[doc(hidden)]
11657        #[derive(PartialEq, Eq, Hash)]
11658        enum __FieldTag {
11659            __selector,
11660            __get,
11661            __put,
11662            __post,
11663            __delete,
11664            __patch,
11665            __custom,
11666            __body,
11667            __response_body,
11668            __additional_bindings,
11669            Unknown(std::string::String),
11670        }
11671        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11672            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11673            where
11674                D: serde::Deserializer<'de>,
11675            {
11676                struct Visitor;
11677                impl<'de> serde::de::Visitor<'de> for Visitor {
11678                    type Value = __FieldTag;
11679                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11680                        formatter.write_str("a field name for HttpRule")
11681                    }
11682                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11683                    where
11684                        E: serde::de::Error,
11685                    {
11686                        use std::result::Result::Ok;
11687                        use std::string::ToString;
11688                        match value {
11689                            "selector" => Ok(__FieldTag::__selector),
11690                            "get" => Ok(__FieldTag::__get),
11691                            "put" => Ok(__FieldTag::__put),
11692                            "post" => Ok(__FieldTag::__post),
11693                            "delete" => Ok(__FieldTag::__delete),
11694                            "patch" => Ok(__FieldTag::__patch),
11695                            "custom" => Ok(__FieldTag::__custom),
11696                            "body" => Ok(__FieldTag::__body),
11697                            "responseBody" => Ok(__FieldTag::__response_body),
11698                            "response_body" => Ok(__FieldTag::__response_body),
11699                            "additionalBindings" => Ok(__FieldTag::__additional_bindings),
11700                            "additional_bindings" => Ok(__FieldTag::__additional_bindings),
11701                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11702                        }
11703                    }
11704                }
11705                deserializer.deserialize_identifier(Visitor)
11706            }
11707        }
11708        struct Visitor;
11709        impl<'de> serde::de::Visitor<'de> for Visitor {
11710            type Value = HttpRule;
11711            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11712                formatter.write_str("struct HttpRule")
11713            }
11714            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11715            where
11716                A: serde::de::MapAccess<'de>,
11717            {
11718                #[allow(unused_imports)]
11719                use serde::de::Error;
11720                use std::option::Option::Some;
11721                let mut fields = std::collections::HashSet::new();
11722                let mut result = Self::Value::new();
11723                while let Some(tag) = map.next_key::<__FieldTag>()? {
11724                    #[allow(clippy::match_single_binding)]
11725                    match tag {
11726                        __FieldTag::__selector => {
11727                            if !fields.insert(__FieldTag::__selector) {
11728                                return std::result::Result::Err(A::Error::duplicate_field(
11729                                    "multiple values for selector",
11730                                ));
11731                            }
11732                            result.selector = map
11733                                .next_value::<std::option::Option<std::string::String>>()?
11734                                .unwrap_or_default();
11735                        }
11736                        __FieldTag::__get => {
11737                            if !fields.insert(__FieldTag::__get) {
11738                                return std::result::Result::Err(A::Error::duplicate_field(
11739                                    "multiple values for get",
11740                                ));
11741                            }
11742                            if result.pattern.is_some() {
11743                                return std::result::Result::Err(A::Error::duplicate_field(
11744                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.get, latest field was get",
11745                                ));
11746                            }
11747                            result.pattern =
11748                                std::option::Option::Some(crate::model::http_rule::Pattern::Get(
11749                                    map.next_value::<std::option::Option<std::string::String>>()?
11750                                        .unwrap_or_default(),
11751                                ));
11752                        }
11753                        __FieldTag::__put => {
11754                            if !fields.insert(__FieldTag::__put) {
11755                                return std::result::Result::Err(A::Error::duplicate_field(
11756                                    "multiple values for put",
11757                                ));
11758                            }
11759                            if result.pattern.is_some() {
11760                                return std::result::Result::Err(A::Error::duplicate_field(
11761                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.put, latest field was put",
11762                                ));
11763                            }
11764                            result.pattern =
11765                                std::option::Option::Some(crate::model::http_rule::Pattern::Put(
11766                                    map.next_value::<std::option::Option<std::string::String>>()?
11767                                        .unwrap_or_default(),
11768                                ));
11769                        }
11770                        __FieldTag::__post => {
11771                            if !fields.insert(__FieldTag::__post) {
11772                                return std::result::Result::Err(A::Error::duplicate_field(
11773                                    "multiple values for post",
11774                                ));
11775                            }
11776                            if result.pattern.is_some() {
11777                                return std::result::Result::Err(A::Error::duplicate_field(
11778                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.post, latest field was post",
11779                                ));
11780                            }
11781                            result.pattern =
11782                                std::option::Option::Some(crate::model::http_rule::Pattern::Post(
11783                                    map.next_value::<std::option::Option<std::string::String>>()?
11784                                        .unwrap_or_default(),
11785                                ));
11786                        }
11787                        __FieldTag::__delete => {
11788                            if !fields.insert(__FieldTag::__delete) {
11789                                return std::result::Result::Err(A::Error::duplicate_field(
11790                                    "multiple values for delete",
11791                                ));
11792                            }
11793                            if result.pattern.is_some() {
11794                                return std::result::Result::Err(A::Error::duplicate_field(
11795                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.delete, latest field was delete",
11796                                ));
11797                            }
11798                            result.pattern = std::option::Option::Some(
11799                                crate::model::http_rule::Pattern::Delete(
11800                                    map.next_value::<std::option::Option<std::string::String>>()?
11801                                        .unwrap_or_default(),
11802                                ),
11803                            );
11804                        }
11805                        __FieldTag::__patch => {
11806                            if !fields.insert(__FieldTag::__patch) {
11807                                return std::result::Result::Err(A::Error::duplicate_field(
11808                                    "multiple values for patch",
11809                                ));
11810                            }
11811                            if result.pattern.is_some() {
11812                                return std::result::Result::Err(A::Error::duplicate_field(
11813                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.patch, latest field was patch",
11814                                ));
11815                            }
11816                            result.pattern =
11817                                std::option::Option::Some(crate::model::http_rule::Pattern::Patch(
11818                                    map.next_value::<std::option::Option<std::string::String>>()?
11819                                        .unwrap_or_default(),
11820                                ));
11821                        }
11822                        __FieldTag::__custom => {
11823                            if !fields.insert(__FieldTag::__custom) {
11824                                return std::result::Result::Err(A::Error::duplicate_field(
11825                                    "multiple values for custom",
11826                                ));
11827                            }
11828                            if result.pattern.is_some() {
11829                                return std::result::Result::Err(A::Error::duplicate_field(
11830                                    "multiple values for `pattern`, a oneof with full ID .google.api.HttpRule.custom, latest field was custom",
11831                                ));
11832                            }
11833                            result.pattern = std::option::Option::Some(
11834                                crate::model::http_rule::Pattern::Custom(
11835                                    map.next_value::<std::option::Option<
11836                                        std::boxed::Box<crate::model::CustomHttpPattern>,
11837                                    >>()?
11838                                    .unwrap_or_default(),
11839                                ),
11840                            );
11841                        }
11842                        __FieldTag::__body => {
11843                            if !fields.insert(__FieldTag::__body) {
11844                                return std::result::Result::Err(A::Error::duplicate_field(
11845                                    "multiple values for body",
11846                                ));
11847                            }
11848                            result.body = map
11849                                .next_value::<std::option::Option<std::string::String>>()?
11850                                .unwrap_or_default();
11851                        }
11852                        __FieldTag::__response_body => {
11853                            if !fields.insert(__FieldTag::__response_body) {
11854                                return std::result::Result::Err(A::Error::duplicate_field(
11855                                    "multiple values for response_body",
11856                                ));
11857                            }
11858                            result.response_body = map
11859                                .next_value::<std::option::Option<std::string::String>>()?
11860                                .unwrap_or_default();
11861                        }
11862                        __FieldTag::__additional_bindings => {
11863                            if !fields.insert(__FieldTag::__additional_bindings) {
11864                                return std::result::Result::Err(A::Error::duplicate_field(
11865                                    "multiple values for additional_bindings",
11866                                ));
11867                            }
11868                            result.additional_bindings = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpRule>>>()?.unwrap_or_default();
11869                        }
11870                        __FieldTag::Unknown(key) => {
11871                            let value = map.next_value::<serde_json::Value>()?;
11872                            result._unknown_fields.insert(key, value);
11873                        }
11874                    }
11875                }
11876                std::result::Result::Ok(result)
11877            }
11878        }
11879        deserializer.deserialize_any(Visitor)
11880    }
11881}
11882
11883#[doc(hidden)]
11884impl serde::ser::Serialize for HttpRule {
11885    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11886    where
11887        S: serde::ser::Serializer,
11888    {
11889        use serde::ser::SerializeMap;
11890        #[allow(unused_imports)]
11891        use std::option::Option::Some;
11892        let mut state = serializer.serialize_map(std::option::Option::None)?;
11893        if !self.selector.is_empty() {
11894            state.serialize_entry("selector", &self.selector)?;
11895        }
11896        if let Some(value) = self.get() {
11897            state.serialize_entry("get", value)?;
11898        }
11899        if let Some(value) = self.put() {
11900            state.serialize_entry("put", value)?;
11901        }
11902        if let Some(value) = self.post() {
11903            state.serialize_entry("post", value)?;
11904        }
11905        if let Some(value) = self.delete() {
11906            state.serialize_entry("delete", value)?;
11907        }
11908        if let Some(value) = self.patch() {
11909            state.serialize_entry("patch", value)?;
11910        }
11911        if let Some(value) = self.custom() {
11912            state.serialize_entry("custom", value)?;
11913        }
11914        if !self.body.is_empty() {
11915            state.serialize_entry("body", &self.body)?;
11916        }
11917        if !self.response_body.is_empty() {
11918            state.serialize_entry("responseBody", &self.response_body)?;
11919        }
11920        if !self.additional_bindings.is_empty() {
11921            state.serialize_entry("additionalBindings", &self.additional_bindings)?;
11922        }
11923        if !self._unknown_fields.is_empty() {
11924            for (key, value) in self._unknown_fields.iter() {
11925                state.serialize_entry(key, &value)?;
11926            }
11927        }
11928        state.end()
11929    }
11930}
11931
11932/// Defines additional types related to [HttpRule].
11933pub mod http_rule {
11934    #[allow(unused_imports)]
11935    use super::*;
11936
11937    /// Determines the URL pattern is matched by this rules. This pattern can be
11938    /// used with any of the {get|put|post|delete|patch} methods. A custom method
11939    /// can be defined using the 'custom' field.
11940    #[derive(Clone, Debug, PartialEq)]
11941    #[non_exhaustive]
11942    pub enum Pattern {
11943        /// Maps to HTTP GET. Used for listing and getting information about
11944        /// resources.
11945        Get(std::string::String),
11946        /// Maps to HTTP PUT. Used for replacing a resource.
11947        Put(std::string::String),
11948        /// Maps to HTTP POST. Used for creating a resource or performing an action.
11949        Post(std::string::String),
11950        /// Maps to HTTP DELETE. Used for deleting a resource.
11951        Delete(std::string::String),
11952        /// Maps to HTTP PATCH. Used for updating a resource.
11953        Patch(std::string::String),
11954        /// The custom pattern is used for specifying an HTTP method that is not
11955        /// included in the `pattern` field, such as HEAD, or "*" to leave the
11956        /// HTTP method unspecified for this rule. The wild-card rule is useful
11957        /// for services that provide content to Web (HTML) clients.
11958        Custom(std::boxed::Box<crate::model::CustomHttpPattern>),
11959    }
11960}
11961
11962/// A custom pattern is used for defining custom HTTP verb.
11963#[derive(Clone, Debug, Default, PartialEq)]
11964#[non_exhaustive]
11965pub struct CustomHttpPattern {
11966    /// The name of this custom HTTP verb.
11967    pub kind: std::string::String,
11968
11969    /// The path matched by this custom verb.
11970    pub path: std::string::String,
11971
11972    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11973}
11974
11975impl CustomHttpPattern {
11976    pub fn new() -> Self {
11977        std::default::Default::default()
11978    }
11979
11980    /// Sets the value of [kind][crate::model::CustomHttpPattern::kind].
11981    pub fn set_kind<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11982        self.kind = v.into();
11983        self
11984    }
11985
11986    /// Sets the value of [path][crate::model::CustomHttpPattern::path].
11987    pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11988        self.path = v.into();
11989        self
11990    }
11991}
11992
11993impl wkt::message::Message for CustomHttpPattern {
11994    fn typename() -> &'static str {
11995        "type.googleapis.com/google.api.CustomHttpPattern"
11996    }
11997}
11998
11999#[doc(hidden)]
12000impl<'de> serde::de::Deserialize<'de> for CustomHttpPattern {
12001    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12002    where
12003        D: serde::Deserializer<'de>,
12004    {
12005        #[allow(non_camel_case_types)]
12006        #[doc(hidden)]
12007        #[derive(PartialEq, Eq, Hash)]
12008        enum __FieldTag {
12009            __kind,
12010            __path,
12011            Unknown(std::string::String),
12012        }
12013        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12014            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12015            where
12016                D: serde::Deserializer<'de>,
12017            {
12018                struct Visitor;
12019                impl<'de> serde::de::Visitor<'de> for Visitor {
12020                    type Value = __FieldTag;
12021                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12022                        formatter.write_str("a field name for CustomHttpPattern")
12023                    }
12024                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12025                    where
12026                        E: serde::de::Error,
12027                    {
12028                        use std::result::Result::Ok;
12029                        use std::string::ToString;
12030                        match value {
12031                            "kind" => Ok(__FieldTag::__kind),
12032                            "path" => Ok(__FieldTag::__path),
12033                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12034                        }
12035                    }
12036                }
12037                deserializer.deserialize_identifier(Visitor)
12038            }
12039        }
12040        struct Visitor;
12041        impl<'de> serde::de::Visitor<'de> for Visitor {
12042            type Value = CustomHttpPattern;
12043            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12044                formatter.write_str("struct CustomHttpPattern")
12045            }
12046            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12047            where
12048                A: serde::de::MapAccess<'de>,
12049            {
12050                #[allow(unused_imports)]
12051                use serde::de::Error;
12052                use std::option::Option::Some;
12053                let mut fields = std::collections::HashSet::new();
12054                let mut result = Self::Value::new();
12055                while let Some(tag) = map.next_key::<__FieldTag>()? {
12056                    #[allow(clippy::match_single_binding)]
12057                    match tag {
12058                        __FieldTag::__kind => {
12059                            if !fields.insert(__FieldTag::__kind) {
12060                                return std::result::Result::Err(A::Error::duplicate_field(
12061                                    "multiple values for kind",
12062                                ));
12063                            }
12064                            result.kind = map
12065                                .next_value::<std::option::Option<std::string::String>>()?
12066                                .unwrap_or_default();
12067                        }
12068                        __FieldTag::__path => {
12069                            if !fields.insert(__FieldTag::__path) {
12070                                return std::result::Result::Err(A::Error::duplicate_field(
12071                                    "multiple values for path",
12072                                ));
12073                            }
12074                            result.path = map
12075                                .next_value::<std::option::Option<std::string::String>>()?
12076                                .unwrap_or_default();
12077                        }
12078                        __FieldTag::Unknown(key) => {
12079                            let value = map.next_value::<serde_json::Value>()?;
12080                            result._unknown_fields.insert(key, value);
12081                        }
12082                    }
12083                }
12084                std::result::Result::Ok(result)
12085            }
12086        }
12087        deserializer.deserialize_any(Visitor)
12088    }
12089}
12090
12091#[doc(hidden)]
12092impl serde::ser::Serialize for CustomHttpPattern {
12093    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12094    where
12095        S: serde::ser::Serializer,
12096    {
12097        use serde::ser::SerializeMap;
12098        #[allow(unused_imports)]
12099        use std::option::Option::Some;
12100        let mut state = serializer.serialize_map(std::option::Option::None)?;
12101        if !self.kind.is_empty() {
12102            state.serialize_entry("kind", &self.kind)?;
12103        }
12104        if !self.path.is_empty() {
12105            state.serialize_entry("path", &self.path)?;
12106        }
12107        if !self._unknown_fields.is_empty() {
12108            for (key, value) in self._unknown_fields.iter() {
12109                state.serialize_entry(key, &value)?;
12110            }
12111        }
12112        state.end()
12113    }
12114}
12115
12116/// Message that represents an arbitrary HTTP body. It should only be used for
12117/// payload formats that can't be represented as JSON, such as raw binary or
12118/// an HTML page.
12119///
12120/// This message can be used both in streaming and non-streaming API methods in
12121/// the request as well as the response.
12122///
12123/// It can be used as a top-level request field, which is convenient if one
12124/// wants to extract parameters from either the URL or HTTP template into the
12125/// request fields and also want access to the raw HTTP body.
12126///
12127/// Example:
12128///
12129/// ```norust
12130/// message GetResourceRequest {
12131///   // A unique request id.
12132///   string request_id = 1;
12133///
12134///   // The raw HTTP body is bound to this field.
12135///   google.api.HttpBody http_body = 2;
12136///
12137/// }
12138///
12139/// service ResourceService {
12140///   rpc GetResource(GetResourceRequest)
12141///     returns (google.api.HttpBody);
12142///   rpc UpdateResource(google.api.HttpBody)
12143///     returns (google.protobuf.Empty);
12144///
12145/// }
12146/// ```
12147///
12148/// Example with streaming methods:
12149///
12150/// ```norust
12151/// service CaldavService {
12152///   rpc GetCalendar(stream google.api.HttpBody)
12153///     returns (stream google.api.HttpBody);
12154///   rpc UpdateCalendar(stream google.api.HttpBody)
12155///     returns (stream google.api.HttpBody);
12156///
12157/// }
12158/// ```
12159///
12160/// Use of this type only changes how the request and response bodies are
12161/// handled, all other features will continue to work unchanged.
12162#[derive(Clone, Debug, Default, PartialEq)]
12163#[non_exhaustive]
12164pub struct HttpBody {
12165    /// The HTTP Content-Type header value specifying the content type of the body.
12166    pub content_type: std::string::String,
12167
12168    /// The HTTP request/response body as raw binary.
12169    pub data: ::bytes::Bytes,
12170
12171    /// Application specific response metadata. Must be set in the first response
12172    /// for streaming APIs.
12173    pub extensions: std::vec::Vec<wkt::Any>,
12174
12175    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12176}
12177
12178impl HttpBody {
12179    pub fn new() -> Self {
12180        std::default::Default::default()
12181    }
12182
12183    /// Sets the value of [content_type][crate::model::HttpBody::content_type].
12184    pub fn set_content_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12185        self.content_type = v.into();
12186        self
12187    }
12188
12189    /// Sets the value of [data][crate::model::HttpBody::data].
12190    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
12191        self.data = v.into();
12192        self
12193    }
12194
12195    /// Sets the value of [extensions][crate::model::HttpBody::extensions].
12196    pub fn set_extensions<T, V>(mut self, v: T) -> Self
12197    where
12198        T: std::iter::IntoIterator<Item = V>,
12199        V: std::convert::Into<wkt::Any>,
12200    {
12201        use std::iter::Iterator;
12202        self.extensions = v.into_iter().map(|i| i.into()).collect();
12203        self
12204    }
12205}
12206
12207impl wkt::message::Message for HttpBody {
12208    fn typename() -> &'static str {
12209        "type.googleapis.com/google.api.HttpBody"
12210    }
12211}
12212
12213#[doc(hidden)]
12214impl<'de> serde::de::Deserialize<'de> for HttpBody {
12215    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12216    where
12217        D: serde::Deserializer<'de>,
12218    {
12219        #[allow(non_camel_case_types)]
12220        #[doc(hidden)]
12221        #[derive(PartialEq, Eq, Hash)]
12222        enum __FieldTag {
12223            __content_type,
12224            __data,
12225            __extensions,
12226            Unknown(std::string::String),
12227        }
12228        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12229            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12230            where
12231                D: serde::Deserializer<'de>,
12232            {
12233                struct Visitor;
12234                impl<'de> serde::de::Visitor<'de> for Visitor {
12235                    type Value = __FieldTag;
12236                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12237                        formatter.write_str("a field name for HttpBody")
12238                    }
12239                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12240                    where
12241                        E: serde::de::Error,
12242                    {
12243                        use std::result::Result::Ok;
12244                        use std::string::ToString;
12245                        match value {
12246                            "contentType" => Ok(__FieldTag::__content_type),
12247                            "content_type" => Ok(__FieldTag::__content_type),
12248                            "data" => Ok(__FieldTag::__data),
12249                            "extensions" => Ok(__FieldTag::__extensions),
12250                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12251                        }
12252                    }
12253                }
12254                deserializer.deserialize_identifier(Visitor)
12255            }
12256        }
12257        struct Visitor;
12258        impl<'de> serde::de::Visitor<'de> for Visitor {
12259            type Value = HttpBody;
12260            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12261                formatter.write_str("struct HttpBody")
12262            }
12263            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12264            where
12265                A: serde::de::MapAccess<'de>,
12266            {
12267                #[allow(unused_imports)]
12268                use serde::de::Error;
12269                use std::option::Option::Some;
12270                let mut fields = std::collections::HashSet::new();
12271                let mut result = Self::Value::new();
12272                while let Some(tag) = map.next_key::<__FieldTag>()? {
12273                    #[allow(clippy::match_single_binding)]
12274                    match tag {
12275                        __FieldTag::__content_type => {
12276                            if !fields.insert(__FieldTag::__content_type) {
12277                                return std::result::Result::Err(A::Error::duplicate_field(
12278                                    "multiple values for content_type",
12279                                ));
12280                            }
12281                            result.content_type = map
12282                                .next_value::<std::option::Option<std::string::String>>()?
12283                                .unwrap_or_default();
12284                        }
12285                        __FieldTag::__data => {
12286                            if !fields.insert(__FieldTag::__data) {
12287                                return std::result::Result::Err(A::Error::duplicate_field(
12288                                    "multiple values for data",
12289                                ));
12290                            }
12291                            struct __With(std::option::Option<::bytes::Bytes>);
12292                            impl<'de> serde::de::Deserialize<'de> for __With {
12293                                fn deserialize<D>(
12294                                    deserializer: D,
12295                                ) -> std::result::Result<Self, D::Error>
12296                                where
12297                                    D: serde::de::Deserializer<'de>,
12298                                {
12299                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
12300                                }
12301                            }
12302                            result.data = map.next_value::<__With>()?.0.unwrap_or_default();
12303                        }
12304                        __FieldTag::__extensions => {
12305                            if !fields.insert(__FieldTag::__extensions) {
12306                                return std::result::Result::Err(A::Error::duplicate_field(
12307                                    "multiple values for extensions",
12308                                ));
12309                            }
12310                            result.extensions = map
12311                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
12312                                .unwrap_or_default();
12313                        }
12314                        __FieldTag::Unknown(key) => {
12315                            let value = map.next_value::<serde_json::Value>()?;
12316                            result._unknown_fields.insert(key, value);
12317                        }
12318                    }
12319                }
12320                std::result::Result::Ok(result)
12321            }
12322        }
12323        deserializer.deserialize_any(Visitor)
12324    }
12325}
12326
12327#[doc(hidden)]
12328impl serde::ser::Serialize for HttpBody {
12329    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12330    where
12331        S: serde::ser::Serializer,
12332    {
12333        use serde::ser::SerializeMap;
12334        #[allow(unused_imports)]
12335        use std::option::Option::Some;
12336        let mut state = serializer.serialize_map(std::option::Option::None)?;
12337        if !self.content_type.is_empty() {
12338            state.serialize_entry("contentType", &self.content_type)?;
12339        }
12340        if !self.data.is_empty() {
12341            struct __With<'a>(&'a ::bytes::Bytes);
12342            impl<'a> serde::ser::Serialize for __With<'a> {
12343                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12344                where
12345                    S: serde::ser::Serializer,
12346                {
12347                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
12348                }
12349            }
12350            state.serialize_entry("data", &__With(&self.data))?;
12351        }
12352        if !self.extensions.is_empty() {
12353            state.serialize_entry("extensions", &self.extensions)?;
12354        }
12355        if !self._unknown_fields.is_empty() {
12356            for (key, value) in self._unknown_fields.iter() {
12357                state.serialize_entry(key, &value)?;
12358            }
12359        }
12360        state.end()
12361    }
12362}
12363
12364/// A description of a label.
12365#[derive(Clone, Debug, Default, PartialEq)]
12366#[non_exhaustive]
12367pub struct LabelDescriptor {
12368    /// The label key.
12369    pub key: std::string::String,
12370
12371    /// The type of data that can be assigned to the label.
12372    pub value_type: crate::model::label_descriptor::ValueType,
12373
12374    /// A human-readable description for the label.
12375    pub description: std::string::String,
12376
12377    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12378}
12379
12380impl LabelDescriptor {
12381    pub fn new() -> Self {
12382        std::default::Default::default()
12383    }
12384
12385    /// Sets the value of [key][crate::model::LabelDescriptor::key].
12386    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12387        self.key = v.into();
12388        self
12389    }
12390
12391    /// Sets the value of [value_type][crate::model::LabelDescriptor::value_type].
12392    pub fn set_value_type<T: std::convert::Into<crate::model::label_descriptor::ValueType>>(
12393        mut self,
12394        v: T,
12395    ) -> Self {
12396        self.value_type = v.into();
12397        self
12398    }
12399
12400    /// Sets the value of [description][crate::model::LabelDescriptor::description].
12401    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12402        self.description = v.into();
12403        self
12404    }
12405}
12406
12407impl wkt::message::Message for LabelDescriptor {
12408    fn typename() -> &'static str {
12409        "type.googleapis.com/google.api.LabelDescriptor"
12410    }
12411}
12412
12413#[doc(hidden)]
12414impl<'de> serde::de::Deserialize<'de> for LabelDescriptor {
12415    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12416    where
12417        D: serde::Deserializer<'de>,
12418    {
12419        #[allow(non_camel_case_types)]
12420        #[doc(hidden)]
12421        #[derive(PartialEq, Eq, Hash)]
12422        enum __FieldTag {
12423            __key,
12424            __value_type,
12425            __description,
12426            Unknown(std::string::String),
12427        }
12428        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12429            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12430            where
12431                D: serde::Deserializer<'de>,
12432            {
12433                struct Visitor;
12434                impl<'de> serde::de::Visitor<'de> for Visitor {
12435                    type Value = __FieldTag;
12436                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12437                        formatter.write_str("a field name for LabelDescriptor")
12438                    }
12439                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12440                    where
12441                        E: serde::de::Error,
12442                    {
12443                        use std::result::Result::Ok;
12444                        use std::string::ToString;
12445                        match value {
12446                            "key" => Ok(__FieldTag::__key),
12447                            "valueType" => Ok(__FieldTag::__value_type),
12448                            "value_type" => Ok(__FieldTag::__value_type),
12449                            "description" => Ok(__FieldTag::__description),
12450                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12451                        }
12452                    }
12453                }
12454                deserializer.deserialize_identifier(Visitor)
12455            }
12456        }
12457        struct Visitor;
12458        impl<'de> serde::de::Visitor<'de> for Visitor {
12459            type Value = LabelDescriptor;
12460            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12461                formatter.write_str("struct LabelDescriptor")
12462            }
12463            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12464            where
12465                A: serde::de::MapAccess<'de>,
12466            {
12467                #[allow(unused_imports)]
12468                use serde::de::Error;
12469                use std::option::Option::Some;
12470                let mut fields = std::collections::HashSet::new();
12471                let mut result = Self::Value::new();
12472                while let Some(tag) = map.next_key::<__FieldTag>()? {
12473                    #[allow(clippy::match_single_binding)]
12474                    match tag {
12475                        __FieldTag::__key => {
12476                            if !fields.insert(__FieldTag::__key) {
12477                                return std::result::Result::Err(A::Error::duplicate_field(
12478                                    "multiple values for key",
12479                                ));
12480                            }
12481                            result.key = map
12482                                .next_value::<std::option::Option<std::string::String>>()?
12483                                .unwrap_or_default();
12484                        }
12485                        __FieldTag::__value_type => {
12486                            if !fields.insert(__FieldTag::__value_type) {
12487                                return std::result::Result::Err(A::Error::duplicate_field(
12488                                    "multiple values for value_type",
12489                                ));
12490                            }
12491                            result.value_type = map.next_value::<std::option::Option<crate::model::label_descriptor::ValueType>>()?.unwrap_or_default();
12492                        }
12493                        __FieldTag::__description => {
12494                            if !fields.insert(__FieldTag::__description) {
12495                                return std::result::Result::Err(A::Error::duplicate_field(
12496                                    "multiple values for description",
12497                                ));
12498                            }
12499                            result.description = map
12500                                .next_value::<std::option::Option<std::string::String>>()?
12501                                .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 LabelDescriptor {
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.key.is_empty() {
12527            state.serialize_entry("key", &self.key)?;
12528        }
12529        if !wkt::internal::is_default(&self.value_type) {
12530            state.serialize_entry("valueType", &self.value_type)?;
12531        }
12532        if !self.description.is_empty() {
12533            state.serialize_entry("description", &self.description)?;
12534        }
12535        if !self._unknown_fields.is_empty() {
12536            for (key, value) in self._unknown_fields.iter() {
12537                state.serialize_entry(key, &value)?;
12538            }
12539        }
12540        state.end()
12541    }
12542}
12543
12544/// Defines additional types related to [LabelDescriptor].
12545pub mod label_descriptor {
12546    #[allow(unused_imports)]
12547    use super::*;
12548
12549    /// Value types that can be used as label values.
12550    ///
12551    /// # Working with unknown values
12552    ///
12553    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
12554    /// additional enum variants at any time. Adding new variants is not considered
12555    /// a breaking change. Applications should write their code in anticipation of:
12556    ///
12557    /// - New values appearing in future releases of the client library, **and**
12558    /// - New values received dynamically, without application changes.
12559    ///
12560    /// Please consult the [Working with enums] section in the user guide for some
12561    /// guidelines.
12562    ///
12563    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
12564    #[derive(Clone, Debug, PartialEq)]
12565    #[non_exhaustive]
12566    pub enum ValueType {
12567        /// A variable-length string. This is the default.
12568        String,
12569        /// Boolean; true or false.
12570        Bool,
12571        /// A 64-bit signed integer.
12572        Int64,
12573        /// If set, the enum was initialized with an unknown value.
12574        ///
12575        /// Applications can examine the value using [ValueType::value] or
12576        /// [ValueType::name].
12577        UnknownValue(value_type::UnknownValue),
12578    }
12579
12580    #[doc(hidden)]
12581    pub mod value_type {
12582        #[allow(unused_imports)]
12583        use super::*;
12584        #[derive(Clone, Debug, PartialEq)]
12585        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
12586    }
12587
12588    impl ValueType {
12589        /// Gets the enum value.
12590        ///
12591        /// Returns `None` if the enum contains an unknown value deserialized from
12592        /// the string representation of enums.
12593        pub fn value(&self) -> std::option::Option<i32> {
12594            match self {
12595                Self::String => std::option::Option::Some(0),
12596                Self::Bool => std::option::Option::Some(1),
12597                Self::Int64 => std::option::Option::Some(2),
12598                Self::UnknownValue(u) => u.0.value(),
12599            }
12600        }
12601
12602        /// Gets the enum value as a string.
12603        ///
12604        /// Returns `None` if the enum contains an unknown value deserialized from
12605        /// the integer representation of enums.
12606        pub fn name(&self) -> std::option::Option<&str> {
12607            match self {
12608                Self::String => std::option::Option::Some("STRING"),
12609                Self::Bool => std::option::Option::Some("BOOL"),
12610                Self::Int64 => std::option::Option::Some("INT64"),
12611                Self::UnknownValue(u) => u.0.name(),
12612            }
12613        }
12614    }
12615
12616    impl std::default::Default for ValueType {
12617        fn default() -> Self {
12618            use std::convert::From;
12619            Self::from(0)
12620        }
12621    }
12622
12623    impl std::fmt::Display for ValueType {
12624        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
12625            wkt::internal::display_enum(f, self.name(), self.value())
12626        }
12627    }
12628
12629    impl std::convert::From<i32> for ValueType {
12630        fn from(value: i32) -> Self {
12631            match value {
12632                0 => Self::String,
12633                1 => Self::Bool,
12634                2 => Self::Int64,
12635                _ => Self::UnknownValue(value_type::UnknownValue(
12636                    wkt::internal::UnknownEnumValue::Integer(value),
12637                )),
12638            }
12639        }
12640    }
12641
12642    impl std::convert::From<&str> for ValueType {
12643        fn from(value: &str) -> Self {
12644            use std::string::ToString;
12645            match value {
12646                "STRING" => Self::String,
12647                "BOOL" => Self::Bool,
12648                "INT64" => Self::Int64,
12649                _ => Self::UnknownValue(value_type::UnknownValue(
12650                    wkt::internal::UnknownEnumValue::String(value.to_string()),
12651                )),
12652            }
12653        }
12654    }
12655
12656    impl serde::ser::Serialize for ValueType {
12657        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12658        where
12659            S: serde::Serializer,
12660        {
12661            match self {
12662                Self::String => serializer.serialize_i32(0),
12663                Self::Bool => serializer.serialize_i32(1),
12664                Self::Int64 => serializer.serialize_i32(2),
12665                Self::UnknownValue(u) => u.0.serialize(serializer),
12666            }
12667        }
12668    }
12669
12670    impl<'de> serde::de::Deserialize<'de> for ValueType {
12671        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12672        where
12673            D: serde::Deserializer<'de>,
12674        {
12675            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
12676                ".google.api.LabelDescriptor.ValueType",
12677            ))
12678        }
12679    }
12680}
12681
12682/// A description of a log type. Example in YAML format:
12683///
12684/// ```norust
12685/// - name: library.googleapis.com/activity_history
12686///   description: The history of borrowing and returning library items.
12687///   display_name: Activity
12688///   labels:
12689///   - key: /customer_id
12690///     description: Identifier of a library customer
12691/// ```
12692#[derive(Clone, Debug, Default, PartialEq)]
12693#[non_exhaustive]
12694pub struct LogDescriptor {
12695    /// The name of the log. It must be less than 512 characters long and can
12696    /// include the following characters: upper- and lower-case alphanumeric
12697    /// characters [A-Za-z0-9], and punctuation characters including
12698    /// slash, underscore, hyphen, period [/_-.].
12699    pub name: std::string::String,
12700
12701    /// The set of labels that are available to describe a specific log entry.
12702    /// Runtime requests that contain labels not specified here are
12703    /// considered invalid.
12704    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
12705
12706    /// A human-readable description of this log. This information appears in
12707    /// the documentation and can contain details.
12708    pub description: std::string::String,
12709
12710    /// The human-readable name for this log. This information appears on
12711    /// the user interface and should be concise.
12712    pub display_name: std::string::String,
12713
12714    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12715}
12716
12717impl LogDescriptor {
12718    pub fn new() -> Self {
12719        std::default::Default::default()
12720    }
12721
12722    /// Sets the value of [name][crate::model::LogDescriptor::name].
12723    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12724        self.name = v.into();
12725        self
12726    }
12727
12728    /// Sets the value of [labels][crate::model::LogDescriptor::labels].
12729    pub fn set_labels<T, V>(mut self, v: T) -> Self
12730    where
12731        T: std::iter::IntoIterator<Item = V>,
12732        V: std::convert::Into<crate::model::LabelDescriptor>,
12733    {
12734        use std::iter::Iterator;
12735        self.labels = v.into_iter().map(|i| i.into()).collect();
12736        self
12737    }
12738
12739    /// Sets the value of [description][crate::model::LogDescriptor::description].
12740    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12741        self.description = v.into();
12742        self
12743    }
12744
12745    /// Sets the value of [display_name][crate::model::LogDescriptor::display_name].
12746    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12747        self.display_name = v.into();
12748        self
12749    }
12750}
12751
12752impl wkt::message::Message for LogDescriptor {
12753    fn typename() -> &'static str {
12754        "type.googleapis.com/google.api.LogDescriptor"
12755    }
12756}
12757
12758#[doc(hidden)]
12759impl<'de> serde::de::Deserialize<'de> for LogDescriptor {
12760    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12761    where
12762        D: serde::Deserializer<'de>,
12763    {
12764        #[allow(non_camel_case_types)]
12765        #[doc(hidden)]
12766        #[derive(PartialEq, Eq, Hash)]
12767        enum __FieldTag {
12768            __name,
12769            __labels,
12770            __description,
12771            __display_name,
12772            Unknown(std::string::String),
12773        }
12774        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12775            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12776            where
12777                D: serde::Deserializer<'de>,
12778            {
12779                struct Visitor;
12780                impl<'de> serde::de::Visitor<'de> for Visitor {
12781                    type Value = __FieldTag;
12782                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12783                        formatter.write_str("a field name for LogDescriptor")
12784                    }
12785                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12786                    where
12787                        E: serde::de::Error,
12788                    {
12789                        use std::result::Result::Ok;
12790                        use std::string::ToString;
12791                        match value {
12792                            "name" => Ok(__FieldTag::__name),
12793                            "labels" => Ok(__FieldTag::__labels),
12794                            "description" => Ok(__FieldTag::__description),
12795                            "displayName" => Ok(__FieldTag::__display_name),
12796                            "display_name" => Ok(__FieldTag::__display_name),
12797                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12798                        }
12799                    }
12800                }
12801                deserializer.deserialize_identifier(Visitor)
12802            }
12803        }
12804        struct Visitor;
12805        impl<'de> serde::de::Visitor<'de> for Visitor {
12806            type Value = LogDescriptor;
12807            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12808                formatter.write_str("struct LogDescriptor")
12809            }
12810            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12811            where
12812                A: serde::de::MapAccess<'de>,
12813            {
12814                #[allow(unused_imports)]
12815                use serde::de::Error;
12816                use std::option::Option::Some;
12817                let mut fields = std::collections::HashSet::new();
12818                let mut result = Self::Value::new();
12819                while let Some(tag) = map.next_key::<__FieldTag>()? {
12820                    #[allow(clippy::match_single_binding)]
12821                    match tag {
12822                        __FieldTag::__name => {
12823                            if !fields.insert(__FieldTag::__name) {
12824                                return std::result::Result::Err(A::Error::duplicate_field(
12825                                    "multiple values for name",
12826                                ));
12827                            }
12828                            result.name = map
12829                                .next_value::<std::option::Option<std::string::String>>()?
12830                                .unwrap_or_default();
12831                        }
12832                        __FieldTag::__labels => {
12833                            if !fields.insert(__FieldTag::__labels) {
12834                                return std::result::Result::Err(A::Error::duplicate_field(
12835                                    "multiple values for labels",
12836                                ));
12837                            }
12838                            result.labels =
12839                                map.next_value::<std::option::Option<
12840                                    std::vec::Vec<crate::model::LabelDescriptor>,
12841                                >>()?
12842                                .unwrap_or_default();
12843                        }
12844                        __FieldTag::__description => {
12845                            if !fields.insert(__FieldTag::__description) {
12846                                return std::result::Result::Err(A::Error::duplicate_field(
12847                                    "multiple values for description",
12848                                ));
12849                            }
12850                            result.description = map
12851                                .next_value::<std::option::Option<std::string::String>>()?
12852                                .unwrap_or_default();
12853                        }
12854                        __FieldTag::__display_name => {
12855                            if !fields.insert(__FieldTag::__display_name) {
12856                                return std::result::Result::Err(A::Error::duplicate_field(
12857                                    "multiple values for display_name",
12858                                ));
12859                            }
12860                            result.display_name = map
12861                                .next_value::<std::option::Option<std::string::String>>()?
12862                                .unwrap_or_default();
12863                        }
12864                        __FieldTag::Unknown(key) => {
12865                            let value = map.next_value::<serde_json::Value>()?;
12866                            result._unknown_fields.insert(key, value);
12867                        }
12868                    }
12869                }
12870                std::result::Result::Ok(result)
12871            }
12872        }
12873        deserializer.deserialize_any(Visitor)
12874    }
12875}
12876
12877#[doc(hidden)]
12878impl serde::ser::Serialize for LogDescriptor {
12879    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12880    where
12881        S: serde::ser::Serializer,
12882    {
12883        use serde::ser::SerializeMap;
12884        #[allow(unused_imports)]
12885        use std::option::Option::Some;
12886        let mut state = serializer.serialize_map(std::option::Option::None)?;
12887        if !self.name.is_empty() {
12888            state.serialize_entry("name", &self.name)?;
12889        }
12890        if !self.labels.is_empty() {
12891            state.serialize_entry("labels", &self.labels)?;
12892        }
12893        if !self.description.is_empty() {
12894            state.serialize_entry("description", &self.description)?;
12895        }
12896        if !self.display_name.is_empty() {
12897            state.serialize_entry("displayName", &self.display_name)?;
12898        }
12899        if !self._unknown_fields.is_empty() {
12900            for (key, value) in self._unknown_fields.iter() {
12901                state.serialize_entry(key, &value)?;
12902            }
12903        }
12904        state.end()
12905    }
12906}
12907
12908/// Logging configuration of the service.
12909///
12910/// The following example shows how to configure logs to be sent to the
12911/// producer and consumer projects. In the example, the `activity_history`
12912/// log is sent to both the producer and consumer projects, whereas the
12913/// `purchase_history` log is only sent to the producer project.
12914///
12915/// ```norust
12916/// monitored_resources:
12917/// - type: library.googleapis.com/branch
12918///   labels:
12919///   - key: /city
12920///     description: The city where the library branch is located in.
12921///   - key: /name
12922///     description: The name of the branch.
12923/// logs:
12924/// - name: activity_history
12925///   labels:
12926///   - key: /customer_id
12927/// - name: purchase_history
12928/// logging:
12929///   producer_destinations:
12930///   - monitored_resource: library.googleapis.com/branch
12931///     logs:
12932///     - activity_history
12933///     - purchase_history
12934///   consumer_destinations:
12935///   - monitored_resource: library.googleapis.com/branch
12936///     logs:
12937///     - activity_history
12938/// ```
12939#[derive(Clone, Debug, Default, PartialEq)]
12940#[non_exhaustive]
12941pub struct Logging {
12942    /// Logging configurations for sending logs to the producer project.
12943    /// There can be multiple producer destinations, each one must have a
12944    /// different monitored resource type. A log can be used in at most
12945    /// one producer destination.
12946    pub producer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,
12947
12948    /// Logging configurations for sending logs to the consumer project.
12949    /// There can be multiple consumer destinations, each one must have a
12950    /// different monitored resource type. A log can be used in at most
12951    /// one consumer destination.
12952    pub consumer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,
12953
12954    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12955}
12956
12957impl Logging {
12958    pub fn new() -> Self {
12959        std::default::Default::default()
12960    }
12961
12962    /// Sets the value of [producer_destinations][crate::model::Logging::producer_destinations].
12963    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
12964    where
12965        T: std::iter::IntoIterator<Item = V>,
12966        V: std::convert::Into<crate::model::logging::LoggingDestination>,
12967    {
12968        use std::iter::Iterator;
12969        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
12970        self
12971    }
12972
12973    /// Sets the value of [consumer_destinations][crate::model::Logging::consumer_destinations].
12974    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
12975    where
12976        T: std::iter::IntoIterator<Item = V>,
12977        V: std::convert::Into<crate::model::logging::LoggingDestination>,
12978    {
12979        use std::iter::Iterator;
12980        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
12981        self
12982    }
12983}
12984
12985impl wkt::message::Message for Logging {
12986    fn typename() -> &'static str {
12987        "type.googleapis.com/google.api.Logging"
12988    }
12989}
12990
12991#[doc(hidden)]
12992impl<'de> serde::de::Deserialize<'de> for Logging {
12993    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12994    where
12995        D: serde::Deserializer<'de>,
12996    {
12997        #[allow(non_camel_case_types)]
12998        #[doc(hidden)]
12999        #[derive(PartialEq, Eq, Hash)]
13000        enum __FieldTag {
13001            __producer_destinations,
13002            __consumer_destinations,
13003            Unknown(std::string::String),
13004        }
13005        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13006            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13007            where
13008                D: serde::Deserializer<'de>,
13009            {
13010                struct Visitor;
13011                impl<'de> serde::de::Visitor<'de> for Visitor {
13012                    type Value = __FieldTag;
13013                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13014                        formatter.write_str("a field name for Logging")
13015                    }
13016                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13017                    where
13018                        E: serde::de::Error,
13019                    {
13020                        use std::result::Result::Ok;
13021                        use std::string::ToString;
13022                        match value {
13023                            "producerDestinations" => Ok(__FieldTag::__producer_destinations),
13024                            "producer_destinations" => Ok(__FieldTag::__producer_destinations),
13025                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
13026                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
13027                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13028                        }
13029                    }
13030                }
13031                deserializer.deserialize_identifier(Visitor)
13032            }
13033        }
13034        struct Visitor;
13035        impl<'de> serde::de::Visitor<'de> for Visitor {
13036            type Value = Logging;
13037            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13038                formatter.write_str("struct Logging")
13039            }
13040            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13041            where
13042                A: serde::de::MapAccess<'de>,
13043            {
13044                #[allow(unused_imports)]
13045                use serde::de::Error;
13046                use std::option::Option::Some;
13047                let mut fields = std::collections::HashSet::new();
13048                let mut result = Self::Value::new();
13049                while let Some(tag) = map.next_key::<__FieldTag>()? {
13050                    #[allow(clippy::match_single_binding)]
13051                    match tag {
13052                        __FieldTag::__producer_destinations => {
13053                            if !fields.insert(__FieldTag::__producer_destinations) {
13054                                return std::result::Result::Err(A::Error::duplicate_field(
13055                                    "multiple values for producer_destinations",
13056                                ));
13057                            }
13058                            result.producer_destinations = map
13059                                .next_value::<std::option::Option<
13060                                    std::vec::Vec<crate::model::logging::LoggingDestination>,
13061                                >>()?
13062                                .unwrap_or_default();
13063                        }
13064                        __FieldTag::__consumer_destinations => {
13065                            if !fields.insert(__FieldTag::__consumer_destinations) {
13066                                return std::result::Result::Err(A::Error::duplicate_field(
13067                                    "multiple values for consumer_destinations",
13068                                ));
13069                            }
13070                            result.consumer_destinations = map
13071                                .next_value::<std::option::Option<
13072                                    std::vec::Vec<crate::model::logging::LoggingDestination>,
13073                                >>()?
13074                                .unwrap_or_default();
13075                        }
13076                        __FieldTag::Unknown(key) => {
13077                            let value = map.next_value::<serde_json::Value>()?;
13078                            result._unknown_fields.insert(key, value);
13079                        }
13080                    }
13081                }
13082                std::result::Result::Ok(result)
13083            }
13084        }
13085        deserializer.deserialize_any(Visitor)
13086    }
13087}
13088
13089#[doc(hidden)]
13090impl serde::ser::Serialize for Logging {
13091    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13092    where
13093        S: serde::ser::Serializer,
13094    {
13095        use serde::ser::SerializeMap;
13096        #[allow(unused_imports)]
13097        use std::option::Option::Some;
13098        let mut state = serializer.serialize_map(std::option::Option::None)?;
13099        if !self.producer_destinations.is_empty() {
13100            state.serialize_entry("producerDestinations", &self.producer_destinations)?;
13101        }
13102        if !self.consumer_destinations.is_empty() {
13103            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
13104        }
13105        if !self._unknown_fields.is_empty() {
13106            for (key, value) in self._unknown_fields.iter() {
13107                state.serialize_entry(key, &value)?;
13108            }
13109        }
13110        state.end()
13111    }
13112}
13113
13114/// Defines additional types related to [Logging].
13115pub mod logging {
13116    #[allow(unused_imports)]
13117    use super::*;
13118
13119    /// Configuration of a specific logging destination (the producer project
13120    /// or the consumer project).
13121    #[derive(Clone, Debug, Default, PartialEq)]
13122    #[non_exhaustive]
13123    pub struct LoggingDestination {
13124        /// The monitored resource type. The type must be defined in the
13125        /// [Service.monitored_resources][google.api.Service.monitored_resources]
13126        /// section.
13127        ///
13128        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
13129        pub monitored_resource: std::string::String,
13130
13131        /// Names of the logs to be sent to this destination. Each name must
13132        /// be defined in the [Service.logs][google.api.Service.logs] section. If the
13133        /// log name is not a domain scoped name, it will be automatically prefixed
13134        /// with the service name followed by "/".
13135        ///
13136        /// [google.api.Service.logs]: crate::model::Service::logs
13137        pub logs: std::vec::Vec<std::string::String>,
13138
13139        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13140    }
13141
13142    impl LoggingDestination {
13143        pub fn new() -> Self {
13144            std::default::Default::default()
13145        }
13146
13147        /// Sets the value of [monitored_resource][crate::model::logging::LoggingDestination::monitored_resource].
13148        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
13149            mut self,
13150            v: T,
13151        ) -> Self {
13152            self.monitored_resource = v.into();
13153            self
13154        }
13155
13156        /// Sets the value of [logs][crate::model::logging::LoggingDestination::logs].
13157        pub fn set_logs<T, V>(mut self, v: T) -> Self
13158        where
13159            T: std::iter::IntoIterator<Item = V>,
13160            V: std::convert::Into<std::string::String>,
13161        {
13162            use std::iter::Iterator;
13163            self.logs = v.into_iter().map(|i| i.into()).collect();
13164            self
13165        }
13166    }
13167
13168    impl wkt::message::Message for LoggingDestination {
13169        fn typename() -> &'static str {
13170            "type.googleapis.com/google.api.Logging.LoggingDestination"
13171        }
13172    }
13173
13174    #[doc(hidden)]
13175    impl<'de> serde::de::Deserialize<'de> for LoggingDestination {
13176        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13177        where
13178            D: serde::Deserializer<'de>,
13179        {
13180            #[allow(non_camel_case_types)]
13181            #[doc(hidden)]
13182            #[derive(PartialEq, Eq, Hash)]
13183            enum __FieldTag {
13184                __monitored_resource,
13185                __logs,
13186                Unknown(std::string::String),
13187            }
13188            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13189                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13190                where
13191                    D: serde::Deserializer<'de>,
13192                {
13193                    struct Visitor;
13194                    impl<'de> serde::de::Visitor<'de> for Visitor {
13195                        type Value = __FieldTag;
13196                        fn expecting(
13197                            &self,
13198                            formatter: &mut std::fmt::Formatter,
13199                        ) -> std::fmt::Result {
13200                            formatter.write_str("a field name for LoggingDestination")
13201                        }
13202                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13203                        where
13204                            E: serde::de::Error,
13205                        {
13206                            use std::result::Result::Ok;
13207                            use std::string::ToString;
13208                            match value {
13209                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
13210                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
13211                                "logs" => Ok(__FieldTag::__logs),
13212                                _ => Ok(__FieldTag::Unknown(value.to_string())),
13213                            }
13214                        }
13215                    }
13216                    deserializer.deserialize_identifier(Visitor)
13217                }
13218            }
13219            struct Visitor;
13220            impl<'de> serde::de::Visitor<'de> for Visitor {
13221                type Value = LoggingDestination;
13222                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13223                    formatter.write_str("struct LoggingDestination")
13224                }
13225                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13226                where
13227                    A: serde::de::MapAccess<'de>,
13228                {
13229                    #[allow(unused_imports)]
13230                    use serde::de::Error;
13231                    use std::option::Option::Some;
13232                    let mut fields = std::collections::HashSet::new();
13233                    let mut result = Self::Value::new();
13234                    while let Some(tag) = map.next_key::<__FieldTag>()? {
13235                        #[allow(clippy::match_single_binding)]
13236                        match tag {
13237                            __FieldTag::__monitored_resource => {
13238                                if !fields.insert(__FieldTag::__monitored_resource) {
13239                                    return std::result::Result::Err(A::Error::duplicate_field(
13240                                        "multiple values for monitored_resource",
13241                                    ));
13242                                }
13243                                result.monitored_resource = map
13244                                    .next_value::<std::option::Option<std::string::String>>()?
13245                                    .unwrap_or_default();
13246                            }
13247                            __FieldTag::__logs => {
13248                                if !fields.insert(__FieldTag::__logs) {
13249                                    return std::result::Result::Err(A::Error::duplicate_field(
13250                                        "multiple values for logs",
13251                                    ));
13252                                }
13253                                result.logs = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
13254                            }
13255                            __FieldTag::Unknown(key) => {
13256                                let value = map.next_value::<serde_json::Value>()?;
13257                                result._unknown_fields.insert(key, value);
13258                            }
13259                        }
13260                    }
13261                    std::result::Result::Ok(result)
13262                }
13263            }
13264            deserializer.deserialize_any(Visitor)
13265        }
13266    }
13267
13268    #[doc(hidden)]
13269    impl serde::ser::Serialize for LoggingDestination {
13270        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13271        where
13272            S: serde::ser::Serializer,
13273        {
13274            use serde::ser::SerializeMap;
13275            #[allow(unused_imports)]
13276            use std::option::Option::Some;
13277            let mut state = serializer.serialize_map(std::option::Option::None)?;
13278            if !self.monitored_resource.is_empty() {
13279                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
13280            }
13281            if !self.logs.is_empty() {
13282                state.serialize_entry("logs", &self.logs)?;
13283            }
13284            if !self._unknown_fields.is_empty() {
13285                for (key, value) in self._unknown_fields.iter() {
13286                    state.serialize_entry(key, &value)?;
13287                }
13288            }
13289            state.end()
13290        }
13291    }
13292}
13293
13294/// Defines a metric type and its schema. Once a metric descriptor is created,
13295/// deleting or altering it stops data collection and makes the metric type's
13296/// existing data unusable.
13297#[derive(Clone, Debug, Default, PartialEq)]
13298#[non_exhaustive]
13299pub struct MetricDescriptor {
13300    /// The resource name of the metric descriptor.
13301    pub name: std::string::String,
13302
13303    /// The metric type, including its DNS name prefix. The type is not
13304    /// URL-encoded. All user-defined metric types have the DNS name
13305    /// `custom.googleapis.com` or `external.googleapis.com`. Metric types should
13306    /// use a natural hierarchical grouping. For example:
13307    ///
13308    /// ```norust
13309    /// "custom.googleapis.com/invoice/paid/amount"
13310    /// "external.googleapis.com/prometheus/up"
13311    /// "appengine.googleapis.com/http/server/response_latencies"
13312    /// ```
13313    pub r#type: std::string::String,
13314
13315    /// The set of labels that can be used to describe a specific
13316    /// instance of this metric type. For example, the
13317    /// `appengine.googleapis.com/http/server/response_latencies` metric
13318    /// type has a label for the HTTP response code, `response_code`, so
13319    /// you can look at latencies for successful responses or just
13320    /// for responses that failed.
13321    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
13322
13323    /// Whether the metric records instantaneous values, changes to a value, etc.
13324    /// Some combinations of `metric_kind` and `value_type` might not be supported.
13325    pub metric_kind: crate::model::metric_descriptor::MetricKind,
13326
13327    /// Whether the measurement is an integer, a floating-point number, etc.
13328    /// Some combinations of `metric_kind` and `value_type` might not be supported.
13329    pub value_type: crate::model::metric_descriptor::ValueType,
13330
13331    /// The units in which the metric value is reported. It is only applicable
13332    /// if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit`
13333    /// defines the representation of the stored metric values.
13334    ///
13335    /// Different systems might scale the values to be more easily displayed (so a
13336    /// value of `0.02kBy` _might_ be displayed as `20By`, and a value of
13337    /// `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is
13338    /// `kBy`, then the value of the metric is always in thousands of bytes, no
13339    /// matter how it might be displayed.
13340    ///
13341    /// If you want a custom metric to record the exact number of CPU-seconds used
13342    /// by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is
13343    /// `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005
13344    /// CPU-seconds, then the value is written as `12005`.
13345    ///
13346    /// Alternatively, if you want a custom metric to record data in a more
13347    /// granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is
13348    /// `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`),
13349    /// or use `Kis{CPU}` and write `11.723` (which is `12005/1024`).
13350    ///
13351    /// The supported units are a subset of [The Unified Code for Units of
13352    /// Measure](https://unitsofmeasure.org/ucum.html) standard:
13353    ///
13354    /// **Basic units (UNIT)**
13355    ///
13356    /// * `bit`   bit
13357    /// * `By`    byte
13358    /// * `s`     second
13359    /// * `min`   minute
13360    /// * `h`     hour
13361    /// * `d`     day
13362    /// * `1`     dimensionless
13363    ///
13364    /// **Prefixes (PREFIX)**
13365    ///
13366    /// * `k`     kilo    (10^3)
13367    ///
13368    /// * `M`     mega    (10^6)
13369    ///
13370    /// * `G`     giga    (10^9)
13371    ///
13372    /// * `T`     tera    (10^12)
13373    ///
13374    /// * `P`     peta    (10^15)
13375    ///
13376    /// * `E`     exa     (10^18)
13377    ///
13378    /// * `Z`     zetta   (10^21)
13379    ///
13380    /// * `Y`     yotta   (10^24)
13381    ///
13382    /// * `m`     milli   (10^-3)
13383    ///
13384    /// * `u`     micro   (10^-6)
13385    ///
13386    /// * `n`     nano    (10^-9)
13387    ///
13388    /// * `p`     pico    (10^-12)
13389    ///
13390    /// * `f`     femto   (10^-15)
13391    ///
13392    /// * `a`     atto    (10^-18)
13393    ///
13394    /// * `z`     zepto   (10^-21)
13395    ///
13396    /// * `y`     yocto   (10^-24)
13397    ///
13398    /// * `Ki`    kibi    (2^10)
13399    ///
13400    /// * `Mi`    mebi    (2^20)
13401    ///
13402    /// * `Gi`    gibi    (2^30)
13403    ///
13404    /// * `Ti`    tebi    (2^40)
13405    ///
13406    /// * `Pi`    pebi    (2^50)
13407    ///
13408    ///
13409    /// **Grammar**
13410    ///
13411    /// The grammar also includes these connectors:
13412    ///
13413    /// * `/`    division or ratio (as an infix operator). For examples,
13414    ///   `kBy/{email}` or `MiBy/10ms` (although you should almost never
13415    ///   have `/s` in a metric `unit`; rates should always be computed at
13416    ///   query time from the underlying cumulative or delta value).
13417    /// * `.`    multiplication or composition (as an infix operator). For
13418    ///   examples, `GBy.d` or `k{watt}.h`.
13419    ///
13420    /// The grammar for a unit is as follows:
13421    ///
13422    /// ```norust
13423    /// Expression = Component { "." Component } { "/" Component } ;
13424    ///
13425    /// Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ]
13426    ///           | Annotation
13427    ///           | "1"
13428    ///           ;
13429    ///
13430    /// Annotation = "{" NAME "}" ;
13431    /// ```
13432    ///
13433    /// Notes:
13434    ///
13435    /// * `Annotation` is just a comment if it follows a `UNIT`. If the annotation
13436    ///   is used alone, then the unit is equivalent to `1`. For examples,
13437    ///   `{request}/s == 1/s`, `By{transmitted}/s == By/s`.
13438    /// * `NAME` is a sequence of non-blank printable ASCII characters not
13439    ///   containing `{` or `}`.
13440    /// * `1` represents a unitary [dimensionless
13441    ///   unit](https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such
13442    ///   as in `1/s`. It is typically used when none of the basic units are
13443    ///   appropriate. For example, "new users per day" can be represented as
13444    ///   `1/d` or `{new-users}/d` (and a metric value `5` would mean "5 new
13445    ///   users). Alternatively, "thousands of page views per day" would be
13446    ///   represented as `1000/d` or `k1/d` or `k{page_views}/d` (and a metric
13447    ///   value of `5.3` would mean "5300 page views per day").
13448    /// * `%` represents dimensionless value of 1/100, and annotates values giving
13449    ///   a percentage (so the metric values are typically in the range of 0..100,
13450    ///   and a metric value `3` means "3 percent").
13451    /// * `10^2.%` indicates a metric contains a ratio, typically in the range
13452    ///   0..1, that will be multiplied by 100 and displayed as a percentage
13453    ///   (so a metric value `0.03` means "3 percent").
13454    pub unit: std::string::String,
13455
13456    /// A detailed description of the metric, which can be used in documentation.
13457    pub description: std::string::String,
13458
13459    /// A concise name for the metric, which can be displayed in user interfaces.
13460    /// Use sentence case without an ending period, for example "Request count".
13461    /// This field is optional but it is recommended to be set for any metrics
13462    /// associated with user-visible concepts, such as Quota.
13463    pub display_name: std::string::String,
13464
13465    /// Optional. Metadata which can be used to guide usage of the metric.
13466    pub metadata: std::option::Option<crate::model::metric_descriptor::MetricDescriptorMetadata>,
13467
13468    /// Optional. The launch stage of the metric definition.
13469    pub launch_stage: crate::model::LaunchStage,
13470
13471    /// Read-only. If present, then a [time
13472    /// series][google.monitoring.v3.TimeSeries], which is identified partially by
13473    /// a metric type and a
13474    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor], that
13475    /// is associated with this metric type can only be associated with one of the
13476    /// monitored resource types listed here.
13477    ///
13478    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
13479    pub monitored_resource_types: std::vec::Vec<std::string::String>,
13480
13481    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13482}
13483
13484impl MetricDescriptor {
13485    pub fn new() -> Self {
13486        std::default::Default::default()
13487    }
13488
13489    /// Sets the value of [name][crate::model::MetricDescriptor::name].
13490    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13491        self.name = v.into();
13492        self
13493    }
13494
13495    /// Sets the value of [r#type][crate::model::MetricDescriptor::type].
13496    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13497        self.r#type = v.into();
13498        self
13499    }
13500
13501    /// Sets the value of [labels][crate::model::MetricDescriptor::labels].
13502    pub fn set_labels<T, V>(mut self, v: T) -> Self
13503    where
13504        T: std::iter::IntoIterator<Item = V>,
13505        V: std::convert::Into<crate::model::LabelDescriptor>,
13506    {
13507        use std::iter::Iterator;
13508        self.labels = v.into_iter().map(|i| i.into()).collect();
13509        self
13510    }
13511
13512    /// Sets the value of [metric_kind][crate::model::MetricDescriptor::metric_kind].
13513    pub fn set_metric_kind<T: std::convert::Into<crate::model::metric_descriptor::MetricKind>>(
13514        mut self,
13515        v: T,
13516    ) -> Self {
13517        self.metric_kind = v.into();
13518        self
13519    }
13520
13521    /// Sets the value of [value_type][crate::model::MetricDescriptor::value_type].
13522    pub fn set_value_type<T: std::convert::Into<crate::model::metric_descriptor::ValueType>>(
13523        mut self,
13524        v: T,
13525    ) -> Self {
13526        self.value_type = v.into();
13527        self
13528    }
13529
13530    /// Sets the value of [unit][crate::model::MetricDescriptor::unit].
13531    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13532        self.unit = v.into();
13533        self
13534    }
13535
13536    /// Sets the value of [description][crate::model::MetricDescriptor::description].
13537    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13538        self.description = v.into();
13539        self
13540    }
13541
13542    /// Sets the value of [display_name][crate::model::MetricDescriptor::display_name].
13543    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13544        self.display_name = v.into();
13545        self
13546    }
13547
13548    /// Sets the value of [metadata][crate::model::MetricDescriptor::metadata].
13549    pub fn set_metadata<T>(mut self, v: T) -> Self
13550    where
13551        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
13552    {
13553        self.metadata = std::option::Option::Some(v.into());
13554        self
13555    }
13556
13557    /// Sets or clears the value of [metadata][crate::model::MetricDescriptor::metadata].
13558    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
13559    where
13560        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
13561    {
13562        self.metadata = v.map(|x| x.into());
13563        self
13564    }
13565
13566    /// Sets the value of [launch_stage][crate::model::MetricDescriptor::launch_stage].
13567    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
13568        mut self,
13569        v: T,
13570    ) -> Self {
13571        self.launch_stage = v.into();
13572        self
13573    }
13574
13575    /// Sets the value of [monitored_resource_types][crate::model::MetricDescriptor::monitored_resource_types].
13576    pub fn set_monitored_resource_types<T, V>(mut self, v: T) -> Self
13577    where
13578        T: std::iter::IntoIterator<Item = V>,
13579        V: std::convert::Into<std::string::String>,
13580    {
13581        use std::iter::Iterator;
13582        self.monitored_resource_types = v.into_iter().map(|i| i.into()).collect();
13583        self
13584    }
13585}
13586
13587impl wkt::message::Message for MetricDescriptor {
13588    fn typename() -> &'static str {
13589        "type.googleapis.com/google.api.MetricDescriptor"
13590    }
13591}
13592
13593#[doc(hidden)]
13594impl<'de> serde::de::Deserialize<'de> for MetricDescriptor {
13595    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13596    where
13597        D: serde::Deserializer<'de>,
13598    {
13599        #[allow(non_camel_case_types)]
13600        #[doc(hidden)]
13601        #[derive(PartialEq, Eq, Hash)]
13602        enum __FieldTag {
13603            __name,
13604            __type,
13605            __labels,
13606            __metric_kind,
13607            __value_type,
13608            __unit,
13609            __description,
13610            __display_name,
13611            __metadata,
13612            __launch_stage,
13613            __monitored_resource_types,
13614            Unknown(std::string::String),
13615        }
13616        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13617            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13618            where
13619                D: serde::Deserializer<'de>,
13620            {
13621                struct Visitor;
13622                impl<'de> serde::de::Visitor<'de> for Visitor {
13623                    type Value = __FieldTag;
13624                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13625                        formatter.write_str("a field name for MetricDescriptor")
13626                    }
13627                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13628                    where
13629                        E: serde::de::Error,
13630                    {
13631                        use std::result::Result::Ok;
13632                        use std::string::ToString;
13633                        match value {
13634                            "name" => Ok(__FieldTag::__name),
13635                            "type" => Ok(__FieldTag::__type),
13636                            "labels" => Ok(__FieldTag::__labels),
13637                            "metricKind" => Ok(__FieldTag::__metric_kind),
13638                            "metric_kind" => Ok(__FieldTag::__metric_kind),
13639                            "valueType" => Ok(__FieldTag::__value_type),
13640                            "value_type" => Ok(__FieldTag::__value_type),
13641                            "unit" => Ok(__FieldTag::__unit),
13642                            "description" => Ok(__FieldTag::__description),
13643                            "displayName" => Ok(__FieldTag::__display_name),
13644                            "display_name" => Ok(__FieldTag::__display_name),
13645                            "metadata" => Ok(__FieldTag::__metadata),
13646                            "launchStage" => Ok(__FieldTag::__launch_stage),
13647                            "launch_stage" => Ok(__FieldTag::__launch_stage),
13648                            "monitoredResourceTypes" => Ok(__FieldTag::__monitored_resource_types),
13649                            "monitored_resource_types" => {
13650                                Ok(__FieldTag::__monitored_resource_types)
13651                            }
13652                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13653                        }
13654                    }
13655                }
13656                deserializer.deserialize_identifier(Visitor)
13657            }
13658        }
13659        struct Visitor;
13660        impl<'de> serde::de::Visitor<'de> for Visitor {
13661            type Value = MetricDescriptor;
13662            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13663                formatter.write_str("struct MetricDescriptor")
13664            }
13665            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13666            where
13667                A: serde::de::MapAccess<'de>,
13668            {
13669                #[allow(unused_imports)]
13670                use serde::de::Error;
13671                use std::option::Option::Some;
13672                let mut fields = std::collections::HashSet::new();
13673                let mut result = Self::Value::new();
13674                while let Some(tag) = map.next_key::<__FieldTag>()? {
13675                    #[allow(clippy::match_single_binding)]
13676                    match tag {
13677                        __FieldTag::__name => {
13678                            if !fields.insert(__FieldTag::__name) {
13679                                return std::result::Result::Err(A::Error::duplicate_field(
13680                                    "multiple values for name",
13681                                ));
13682                            }
13683                            result.name = map
13684                                .next_value::<std::option::Option<std::string::String>>()?
13685                                .unwrap_or_default();
13686                        }
13687                        __FieldTag::__type => {
13688                            if !fields.insert(__FieldTag::__type) {
13689                                return std::result::Result::Err(A::Error::duplicate_field(
13690                                    "multiple values for type",
13691                                ));
13692                            }
13693                            result.r#type = map
13694                                .next_value::<std::option::Option<std::string::String>>()?
13695                                .unwrap_or_default();
13696                        }
13697                        __FieldTag::__labels => {
13698                            if !fields.insert(__FieldTag::__labels) {
13699                                return std::result::Result::Err(A::Error::duplicate_field(
13700                                    "multiple values for labels",
13701                                ));
13702                            }
13703                            result.labels =
13704                                map.next_value::<std::option::Option<
13705                                    std::vec::Vec<crate::model::LabelDescriptor>,
13706                                >>()?
13707                                .unwrap_or_default();
13708                        }
13709                        __FieldTag::__metric_kind => {
13710                            if !fields.insert(__FieldTag::__metric_kind) {
13711                                return std::result::Result::Err(A::Error::duplicate_field(
13712                                    "multiple values for metric_kind",
13713                                ));
13714                            }
13715                            result.metric_kind =
13716                                map.next_value::<std::option::Option<
13717                                    crate::model::metric_descriptor::MetricKind,
13718                                >>()?
13719                                .unwrap_or_default();
13720                        }
13721                        __FieldTag::__value_type => {
13722                            if !fields.insert(__FieldTag::__value_type) {
13723                                return std::result::Result::Err(A::Error::duplicate_field(
13724                                    "multiple values for value_type",
13725                                ));
13726                            }
13727                            result.value_type = map.next_value::<std::option::Option<crate::model::metric_descriptor::ValueType>>()?.unwrap_or_default();
13728                        }
13729                        __FieldTag::__unit => {
13730                            if !fields.insert(__FieldTag::__unit) {
13731                                return std::result::Result::Err(A::Error::duplicate_field(
13732                                    "multiple values for unit",
13733                                ));
13734                            }
13735                            result.unit = map
13736                                .next_value::<std::option::Option<std::string::String>>()?
13737                                .unwrap_or_default();
13738                        }
13739                        __FieldTag::__description => {
13740                            if !fields.insert(__FieldTag::__description) {
13741                                return std::result::Result::Err(A::Error::duplicate_field(
13742                                    "multiple values for description",
13743                                ));
13744                            }
13745                            result.description = map
13746                                .next_value::<std::option::Option<std::string::String>>()?
13747                                .unwrap_or_default();
13748                        }
13749                        __FieldTag::__display_name => {
13750                            if !fields.insert(__FieldTag::__display_name) {
13751                                return std::result::Result::Err(A::Error::duplicate_field(
13752                                    "multiple values for display_name",
13753                                ));
13754                            }
13755                            result.display_name = map
13756                                .next_value::<std::option::Option<std::string::String>>()?
13757                                .unwrap_or_default();
13758                        }
13759                        __FieldTag::__metadata => {
13760                            if !fields.insert(__FieldTag::__metadata) {
13761                                return std::result::Result::Err(A::Error::duplicate_field(
13762                                    "multiple values for metadata",
13763                                ));
13764                            }
13765                            result.metadata = map.next_value::<std::option::Option<
13766                                crate::model::metric_descriptor::MetricDescriptorMetadata,
13767                            >>()?;
13768                        }
13769                        __FieldTag::__launch_stage => {
13770                            if !fields.insert(__FieldTag::__launch_stage) {
13771                                return std::result::Result::Err(A::Error::duplicate_field(
13772                                    "multiple values for launch_stage",
13773                                ));
13774                            }
13775                            result.launch_stage = map
13776                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
13777                                .unwrap_or_default();
13778                        }
13779                        __FieldTag::__monitored_resource_types => {
13780                            if !fields.insert(__FieldTag::__monitored_resource_types) {
13781                                return std::result::Result::Err(A::Error::duplicate_field(
13782                                    "multiple values for monitored_resource_types",
13783                                ));
13784                            }
13785                            result.monitored_resource_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
13786                        }
13787                        __FieldTag::Unknown(key) => {
13788                            let value = map.next_value::<serde_json::Value>()?;
13789                            result._unknown_fields.insert(key, value);
13790                        }
13791                    }
13792                }
13793                std::result::Result::Ok(result)
13794            }
13795        }
13796        deserializer.deserialize_any(Visitor)
13797    }
13798}
13799
13800#[doc(hidden)]
13801impl serde::ser::Serialize for MetricDescriptor {
13802    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13803    where
13804        S: serde::ser::Serializer,
13805    {
13806        use serde::ser::SerializeMap;
13807        #[allow(unused_imports)]
13808        use std::option::Option::Some;
13809        let mut state = serializer.serialize_map(std::option::Option::None)?;
13810        if !self.name.is_empty() {
13811            state.serialize_entry("name", &self.name)?;
13812        }
13813        if !self.r#type.is_empty() {
13814            state.serialize_entry("type", &self.r#type)?;
13815        }
13816        if !self.labels.is_empty() {
13817            state.serialize_entry("labels", &self.labels)?;
13818        }
13819        if !wkt::internal::is_default(&self.metric_kind) {
13820            state.serialize_entry("metricKind", &self.metric_kind)?;
13821        }
13822        if !wkt::internal::is_default(&self.value_type) {
13823            state.serialize_entry("valueType", &self.value_type)?;
13824        }
13825        if !self.unit.is_empty() {
13826            state.serialize_entry("unit", &self.unit)?;
13827        }
13828        if !self.description.is_empty() {
13829            state.serialize_entry("description", &self.description)?;
13830        }
13831        if !self.display_name.is_empty() {
13832            state.serialize_entry("displayName", &self.display_name)?;
13833        }
13834        if self.metadata.is_some() {
13835            state.serialize_entry("metadata", &self.metadata)?;
13836        }
13837        if !wkt::internal::is_default(&self.launch_stage) {
13838            state.serialize_entry("launchStage", &self.launch_stage)?;
13839        }
13840        if !self.monitored_resource_types.is_empty() {
13841            state.serialize_entry("monitoredResourceTypes", &self.monitored_resource_types)?;
13842        }
13843        if !self._unknown_fields.is_empty() {
13844            for (key, value) in self._unknown_fields.iter() {
13845                state.serialize_entry(key, &value)?;
13846            }
13847        }
13848        state.end()
13849    }
13850}
13851
13852/// Defines additional types related to [MetricDescriptor].
13853pub mod metric_descriptor {
13854    #[allow(unused_imports)]
13855    use super::*;
13856
13857    /// Additional annotations that can be used to guide the usage of a metric.
13858    #[derive(Clone, Debug, Default, PartialEq)]
13859    #[non_exhaustive]
13860    pub struct MetricDescriptorMetadata {
13861
13862        /// Deprecated. Must use the
13863        /// [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage]
13864        /// instead.
13865        ///
13866        /// [google.api.MetricDescriptor.launch_stage]: crate::model::MetricDescriptor::launch_stage
13867        #[deprecated]
13868        pub launch_stage: crate::model::LaunchStage,
13869
13870        /// The sampling period of metric data points. For metrics which are written
13871        /// periodically, consecutive data points are stored at this time interval,
13872        /// excluding data loss due to errors. Metrics with a higher granularity have
13873        /// a smaller sampling period.
13874        pub sample_period: std::option::Option<wkt::Duration>,
13875
13876        /// The delay of data points caused by ingestion. Data points older than this
13877        /// age are guaranteed to be ingested and available to be read, excluding
13878        /// data loss due to errors.
13879        pub ingest_delay: std::option::Option<wkt::Duration>,
13880
13881        /// The scope of the timeseries data of the metric.
13882        pub time_series_resource_hierarchy_level: std::vec::Vec<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>,
13883
13884        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13885    }
13886
13887    impl MetricDescriptorMetadata {
13888        pub fn new() -> Self {
13889            std::default::Default::default()
13890        }
13891
13892        /// Sets the value of [launch_stage][crate::model::metric_descriptor::MetricDescriptorMetadata::launch_stage].
13893        #[deprecated]
13894        pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
13895            mut self,
13896            v: T,
13897        ) -> Self {
13898            self.launch_stage = v.into();
13899            self
13900        }
13901
13902        /// Sets the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
13903        pub fn set_sample_period<T>(mut self, v: T) -> Self
13904        where
13905            T: std::convert::Into<wkt::Duration>,
13906        {
13907            self.sample_period = std::option::Option::Some(v.into());
13908            self
13909        }
13910
13911        /// Sets or clears the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
13912        pub fn set_or_clear_sample_period<T>(mut self, v: std::option::Option<T>) -> Self
13913        where
13914            T: std::convert::Into<wkt::Duration>,
13915        {
13916            self.sample_period = v.map(|x| x.into());
13917            self
13918        }
13919
13920        /// Sets the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
13921        pub fn set_ingest_delay<T>(mut self, v: T) -> Self
13922        where
13923            T: std::convert::Into<wkt::Duration>,
13924        {
13925            self.ingest_delay = std::option::Option::Some(v.into());
13926            self
13927        }
13928
13929        /// Sets or clears the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
13930        pub fn set_or_clear_ingest_delay<T>(mut self, v: std::option::Option<T>) -> Self
13931        where
13932            T: std::convert::Into<wkt::Duration>,
13933        {
13934            self.ingest_delay = v.map(|x| x.into());
13935            self
13936        }
13937
13938        /// Sets the value of [time_series_resource_hierarchy_level][crate::model::metric_descriptor::MetricDescriptorMetadata::time_series_resource_hierarchy_level].
13939        pub fn set_time_series_resource_hierarchy_level<T, V>(mut self, v: T) -> Self
13940        where
13941            T: std::iter::IntoIterator<Item = V>,
13942            V: std::convert::Into<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>
13943        {
13944            use std::iter::Iterator;
13945            self.time_series_resource_hierarchy_level = v.into_iter().map(|i| i.into()).collect();
13946            self
13947        }
13948    }
13949
13950    impl wkt::message::Message for MetricDescriptorMetadata {
13951        fn typename() -> &'static str {
13952            "type.googleapis.com/google.api.MetricDescriptor.MetricDescriptorMetadata"
13953        }
13954    }
13955
13956    #[doc(hidden)]
13957    impl<'de> serde::de::Deserialize<'de> for MetricDescriptorMetadata {
13958        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13959        where
13960            D: serde::Deserializer<'de>,
13961        {
13962            #[allow(non_camel_case_types)]
13963            #[doc(hidden)]
13964            #[derive(PartialEq, Eq, Hash)]
13965            enum __FieldTag {
13966                __launch_stage,
13967                __sample_period,
13968                __ingest_delay,
13969                __time_series_resource_hierarchy_level,
13970                Unknown(std::string::String),
13971            }
13972            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13973                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13974                where
13975                    D: serde::Deserializer<'de>,
13976                {
13977                    struct Visitor;
13978                    impl<'de> serde::de::Visitor<'de> for Visitor {
13979                        type Value = __FieldTag;
13980                        fn expecting(
13981                            &self,
13982                            formatter: &mut std::fmt::Formatter,
13983                        ) -> std::fmt::Result {
13984                            formatter.write_str("a field name for MetricDescriptorMetadata")
13985                        }
13986                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13987                        where
13988                            E: serde::de::Error,
13989                        {
13990                            use std::result::Result::Ok;
13991                            use std::string::ToString;
13992                            match value {
13993                                "launchStage" => Ok(__FieldTag::__launch_stage),
13994                                "launch_stage" => Ok(__FieldTag::__launch_stage),
13995                                "samplePeriod" => Ok(__FieldTag::__sample_period),
13996                                "sample_period" => Ok(__FieldTag::__sample_period),
13997                                "ingestDelay" => Ok(__FieldTag::__ingest_delay),
13998                                "ingest_delay" => Ok(__FieldTag::__ingest_delay),
13999                                "timeSeriesResourceHierarchyLevel" => {
14000                                    Ok(__FieldTag::__time_series_resource_hierarchy_level)
14001                                }
14002                                "time_series_resource_hierarchy_level" => {
14003                                    Ok(__FieldTag::__time_series_resource_hierarchy_level)
14004                                }
14005                                _ => Ok(__FieldTag::Unknown(value.to_string())),
14006                            }
14007                        }
14008                    }
14009                    deserializer.deserialize_identifier(Visitor)
14010                }
14011            }
14012            struct Visitor;
14013            impl<'de> serde::de::Visitor<'de> for Visitor {
14014                type Value = MetricDescriptorMetadata;
14015                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14016                    formatter.write_str("struct MetricDescriptorMetadata")
14017                }
14018                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14019                where
14020                    A: serde::de::MapAccess<'de>,
14021                {
14022                    #[allow(unused_imports)]
14023                    use serde::de::Error;
14024                    use std::option::Option::Some;
14025                    let mut fields = std::collections::HashSet::new();
14026                    let mut result = Self::Value::new();
14027                    while let Some(tag) = map.next_key::<__FieldTag>()? {
14028                        #[allow(clippy::match_single_binding)]
14029                        match tag {
14030                            __FieldTag::__launch_stage => {
14031                                if !fields.insert(__FieldTag::__launch_stage) {
14032                                    return std::result::Result::Err(A::Error::duplicate_field(
14033                                        "multiple values for launch_stage",
14034                                    ));
14035                                }
14036                                result.launch_stage = map
14037                                    .next_value::<std::option::Option<crate::model::LaunchStage>>()?
14038                                    .unwrap_or_default();
14039                            }
14040                            __FieldTag::__sample_period => {
14041                                if !fields.insert(__FieldTag::__sample_period) {
14042                                    return std::result::Result::Err(A::Error::duplicate_field(
14043                                        "multiple values for sample_period",
14044                                    ));
14045                                }
14046                                result.sample_period =
14047                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14048                            }
14049                            __FieldTag::__ingest_delay => {
14050                                if !fields.insert(__FieldTag::__ingest_delay) {
14051                                    return std::result::Result::Err(A::Error::duplicate_field(
14052                                        "multiple values for ingest_delay",
14053                                    ));
14054                                }
14055                                result.ingest_delay =
14056                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14057                            }
14058                            __FieldTag::__time_series_resource_hierarchy_level => {
14059                                if !fields
14060                                    .insert(__FieldTag::__time_series_resource_hierarchy_level)
14061                                {
14062                                    return std::result::Result::Err(A::Error::duplicate_field(
14063                                        "multiple values for time_series_resource_hierarchy_level",
14064                                    ));
14065                                }
14066                                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();
14067                            }
14068                            __FieldTag::Unknown(key) => {
14069                                let value = map.next_value::<serde_json::Value>()?;
14070                                result._unknown_fields.insert(key, value);
14071                            }
14072                        }
14073                    }
14074                    std::result::Result::Ok(result)
14075                }
14076            }
14077            deserializer.deserialize_any(Visitor)
14078        }
14079    }
14080
14081    #[doc(hidden)]
14082    impl serde::ser::Serialize for MetricDescriptorMetadata {
14083        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14084        where
14085            S: serde::ser::Serializer,
14086        {
14087            use serde::ser::SerializeMap;
14088            #[allow(unused_imports)]
14089            use std::option::Option::Some;
14090            let mut state = serializer.serialize_map(std::option::Option::None)?;
14091            if !wkt::internal::is_default(&self.launch_stage) {
14092                state.serialize_entry("launchStage", &self.launch_stage)?;
14093            }
14094            if self.sample_period.is_some() {
14095                state.serialize_entry("samplePeriod", &self.sample_period)?;
14096            }
14097            if self.ingest_delay.is_some() {
14098                state.serialize_entry("ingestDelay", &self.ingest_delay)?;
14099            }
14100            if !self.time_series_resource_hierarchy_level.is_empty() {
14101                state.serialize_entry(
14102                    "timeSeriesResourceHierarchyLevel",
14103                    &self.time_series_resource_hierarchy_level,
14104                )?;
14105            }
14106            if !self._unknown_fields.is_empty() {
14107                for (key, value) in self._unknown_fields.iter() {
14108                    state.serialize_entry(key, &value)?;
14109                }
14110            }
14111            state.end()
14112        }
14113    }
14114
14115    /// Defines additional types related to [MetricDescriptorMetadata].
14116    pub mod metric_descriptor_metadata {
14117        #[allow(unused_imports)]
14118        use super::*;
14119
14120        /// The resource hierarchy level of the timeseries data of a metric.
14121        ///
14122        /// # Working with unknown values
14123        ///
14124        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
14125        /// additional enum variants at any time. Adding new variants is not considered
14126        /// a breaking change. Applications should write their code in anticipation of:
14127        ///
14128        /// - New values appearing in future releases of the client library, **and**
14129        /// - New values received dynamically, without application changes.
14130        ///
14131        /// Please consult the [Working with enums] section in the user guide for some
14132        /// guidelines.
14133        ///
14134        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
14135        #[derive(Clone, Debug, PartialEq)]
14136        #[non_exhaustive]
14137        pub enum TimeSeriesResourceHierarchyLevel {
14138            /// Do not use this default value.
14139            Unspecified,
14140            /// Scopes a metric to a project.
14141            Project,
14142            /// Scopes a metric to an organization.
14143            Organization,
14144            /// Scopes a metric to a folder.
14145            Folder,
14146            /// If set, the enum was initialized with an unknown value.
14147            ///
14148            /// Applications can examine the value using [TimeSeriesResourceHierarchyLevel::value] or
14149            /// [TimeSeriesResourceHierarchyLevel::name].
14150            UnknownValue(time_series_resource_hierarchy_level::UnknownValue),
14151        }
14152
14153        #[doc(hidden)]
14154        pub mod time_series_resource_hierarchy_level {
14155            #[allow(unused_imports)]
14156            use super::*;
14157            #[derive(Clone, Debug, PartialEq)]
14158            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
14159        }
14160
14161        impl TimeSeriesResourceHierarchyLevel {
14162            /// Gets the enum value.
14163            ///
14164            /// Returns `None` if the enum contains an unknown value deserialized from
14165            /// the string representation of enums.
14166            pub fn value(&self) -> std::option::Option<i32> {
14167                match self {
14168                    Self::Unspecified => std::option::Option::Some(0),
14169                    Self::Project => std::option::Option::Some(1),
14170                    Self::Organization => std::option::Option::Some(2),
14171                    Self::Folder => std::option::Option::Some(3),
14172                    Self::UnknownValue(u) => u.0.value(),
14173                }
14174            }
14175
14176            /// Gets the enum value as a string.
14177            ///
14178            /// Returns `None` if the enum contains an unknown value deserialized from
14179            /// the integer representation of enums.
14180            pub fn name(&self) -> std::option::Option<&str> {
14181                match self {
14182                    Self::Unspecified => std::option::Option::Some(
14183                        "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED",
14184                    ),
14185                    Self::Project => std::option::Option::Some("PROJECT"),
14186                    Self::Organization => std::option::Option::Some("ORGANIZATION"),
14187                    Self::Folder => std::option::Option::Some("FOLDER"),
14188                    Self::UnknownValue(u) => u.0.name(),
14189                }
14190            }
14191        }
14192
14193        impl std::default::Default for TimeSeriesResourceHierarchyLevel {
14194            fn default() -> Self {
14195                use std::convert::From;
14196                Self::from(0)
14197            }
14198        }
14199
14200        impl std::fmt::Display for TimeSeriesResourceHierarchyLevel {
14201            fn fmt(
14202                &self,
14203                f: &mut std::fmt::Formatter<'_>,
14204            ) -> std::result::Result<(), std::fmt::Error> {
14205                wkt::internal::display_enum(f, self.name(), self.value())
14206            }
14207        }
14208
14209        impl std::convert::From<i32> for TimeSeriesResourceHierarchyLevel {
14210            fn from(value: i32) -> Self {
14211                match value {
14212                    0 => Self::Unspecified,
14213                    1 => Self::Project,
14214                    2 => Self::Organization,
14215                    3 => Self::Folder,
14216                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
14217                        wkt::internal::UnknownEnumValue::Integer(value),
14218                    )),
14219                }
14220            }
14221        }
14222
14223        impl std::convert::From<&str> for TimeSeriesResourceHierarchyLevel {
14224            fn from(value: &str) -> Self {
14225                use std::string::ToString;
14226                match value {
14227                    "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED" => Self::Unspecified,
14228                    "PROJECT" => Self::Project,
14229                    "ORGANIZATION" => Self::Organization,
14230                    "FOLDER" => Self::Folder,
14231                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
14232                        wkt::internal::UnknownEnumValue::String(value.to_string()),
14233                    )),
14234                }
14235            }
14236        }
14237
14238        impl serde::ser::Serialize for TimeSeriesResourceHierarchyLevel {
14239            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14240            where
14241                S: serde::Serializer,
14242            {
14243                match self {
14244                    Self::Unspecified => serializer.serialize_i32(0),
14245                    Self::Project => serializer.serialize_i32(1),
14246                    Self::Organization => serializer.serialize_i32(2),
14247                    Self::Folder => serializer.serialize_i32(3),
14248                    Self::UnknownValue(u) => u.0.serialize(serializer),
14249                }
14250            }
14251        }
14252
14253        impl<'de> serde::de::Deserialize<'de> for TimeSeriesResourceHierarchyLevel {
14254            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14255            where
14256                D: serde::Deserializer<'de>,
14257            {
14258                deserializer.deserialize_any(wkt::internal::EnumVisitor::<TimeSeriesResourceHierarchyLevel>::new(
14259                    ".google.api.MetricDescriptor.MetricDescriptorMetadata.TimeSeriesResourceHierarchyLevel"))
14260            }
14261        }
14262    }
14263
14264    /// The kind of measurement. It describes how the data is reported.
14265    /// For information on setting the start time and end time based on
14266    /// the MetricKind, see [TimeInterval][google.monitoring.v3.TimeInterval].
14267    ///
14268    /// # Working with unknown values
14269    ///
14270    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
14271    /// additional enum variants at any time. Adding new variants is not considered
14272    /// a breaking change. Applications should write their code in anticipation of:
14273    ///
14274    /// - New values appearing in future releases of the client library, **and**
14275    /// - New values received dynamically, without application changes.
14276    ///
14277    /// Please consult the [Working with enums] section in the user guide for some
14278    /// guidelines.
14279    ///
14280    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
14281    #[derive(Clone, Debug, PartialEq)]
14282    #[non_exhaustive]
14283    pub enum MetricKind {
14284        /// Do not use this default value.
14285        Unspecified,
14286        /// An instantaneous measurement of a value.
14287        Gauge,
14288        /// The change in a value during a time interval.
14289        Delta,
14290        /// A value accumulated over a time interval.  Cumulative
14291        /// measurements in a time series should have the same start time
14292        /// and increasing end times, until an event resets the cumulative
14293        /// value to zero and sets a new start time for the following
14294        /// points.
14295        Cumulative,
14296        /// If set, the enum was initialized with an unknown value.
14297        ///
14298        /// Applications can examine the value using [MetricKind::value] or
14299        /// [MetricKind::name].
14300        UnknownValue(metric_kind::UnknownValue),
14301    }
14302
14303    #[doc(hidden)]
14304    pub mod metric_kind {
14305        #[allow(unused_imports)]
14306        use super::*;
14307        #[derive(Clone, Debug, PartialEq)]
14308        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
14309    }
14310
14311    impl MetricKind {
14312        /// Gets the enum value.
14313        ///
14314        /// Returns `None` if the enum contains an unknown value deserialized from
14315        /// the string representation of enums.
14316        pub fn value(&self) -> std::option::Option<i32> {
14317            match self {
14318                Self::Unspecified => std::option::Option::Some(0),
14319                Self::Gauge => std::option::Option::Some(1),
14320                Self::Delta => std::option::Option::Some(2),
14321                Self::Cumulative => std::option::Option::Some(3),
14322                Self::UnknownValue(u) => u.0.value(),
14323            }
14324        }
14325
14326        /// Gets the enum value as a string.
14327        ///
14328        /// Returns `None` if the enum contains an unknown value deserialized from
14329        /// the integer representation of enums.
14330        pub fn name(&self) -> std::option::Option<&str> {
14331            match self {
14332                Self::Unspecified => std::option::Option::Some("METRIC_KIND_UNSPECIFIED"),
14333                Self::Gauge => std::option::Option::Some("GAUGE"),
14334                Self::Delta => std::option::Option::Some("DELTA"),
14335                Self::Cumulative => std::option::Option::Some("CUMULATIVE"),
14336                Self::UnknownValue(u) => u.0.name(),
14337            }
14338        }
14339    }
14340
14341    impl std::default::Default for MetricKind {
14342        fn default() -> Self {
14343            use std::convert::From;
14344            Self::from(0)
14345        }
14346    }
14347
14348    impl std::fmt::Display for MetricKind {
14349        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
14350            wkt::internal::display_enum(f, self.name(), self.value())
14351        }
14352    }
14353
14354    impl std::convert::From<i32> for MetricKind {
14355        fn from(value: i32) -> Self {
14356            match value {
14357                0 => Self::Unspecified,
14358                1 => Self::Gauge,
14359                2 => Self::Delta,
14360                3 => Self::Cumulative,
14361                _ => Self::UnknownValue(metric_kind::UnknownValue(
14362                    wkt::internal::UnknownEnumValue::Integer(value),
14363                )),
14364            }
14365        }
14366    }
14367
14368    impl std::convert::From<&str> for MetricKind {
14369        fn from(value: &str) -> Self {
14370            use std::string::ToString;
14371            match value {
14372                "METRIC_KIND_UNSPECIFIED" => Self::Unspecified,
14373                "GAUGE" => Self::Gauge,
14374                "DELTA" => Self::Delta,
14375                "CUMULATIVE" => Self::Cumulative,
14376                _ => Self::UnknownValue(metric_kind::UnknownValue(
14377                    wkt::internal::UnknownEnumValue::String(value.to_string()),
14378                )),
14379            }
14380        }
14381    }
14382
14383    impl serde::ser::Serialize for MetricKind {
14384        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14385        where
14386            S: serde::Serializer,
14387        {
14388            match self {
14389                Self::Unspecified => serializer.serialize_i32(0),
14390                Self::Gauge => serializer.serialize_i32(1),
14391                Self::Delta => serializer.serialize_i32(2),
14392                Self::Cumulative => serializer.serialize_i32(3),
14393                Self::UnknownValue(u) => u.0.serialize(serializer),
14394            }
14395        }
14396    }
14397
14398    impl<'de> serde::de::Deserialize<'de> for MetricKind {
14399        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14400        where
14401            D: serde::Deserializer<'de>,
14402        {
14403            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MetricKind>::new(
14404                ".google.api.MetricDescriptor.MetricKind",
14405            ))
14406        }
14407    }
14408
14409    /// The value type of a metric.
14410    ///
14411    /// # Working with unknown values
14412    ///
14413    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
14414    /// additional enum variants at any time. Adding new variants is not considered
14415    /// a breaking change. Applications should write their code in anticipation of:
14416    ///
14417    /// - New values appearing in future releases of the client library, **and**
14418    /// - New values received dynamically, without application changes.
14419    ///
14420    /// Please consult the [Working with enums] section in the user guide for some
14421    /// guidelines.
14422    ///
14423    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
14424    #[derive(Clone, Debug, PartialEq)]
14425    #[non_exhaustive]
14426    pub enum ValueType {
14427        /// Do not use this default value.
14428        Unspecified,
14429        /// The value is a boolean.
14430        /// This value type can be used only if the metric kind is `GAUGE`.
14431        Bool,
14432        /// The value is a signed 64-bit integer.
14433        Int64,
14434        /// The value is a double precision floating point number.
14435        Double,
14436        /// The value is a text string.
14437        /// This value type can be used only if the metric kind is `GAUGE`.
14438        String,
14439        /// The value is a [`Distribution`][google.api.Distribution].
14440        ///
14441        /// [google.api.Distribution]: crate::model::Distribution
14442        Distribution,
14443        /// The value is money.
14444        Money,
14445        /// If set, the enum was initialized with an unknown value.
14446        ///
14447        /// Applications can examine the value using [ValueType::value] or
14448        /// [ValueType::name].
14449        UnknownValue(value_type::UnknownValue),
14450    }
14451
14452    #[doc(hidden)]
14453    pub mod value_type {
14454        #[allow(unused_imports)]
14455        use super::*;
14456        #[derive(Clone, Debug, PartialEq)]
14457        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
14458    }
14459
14460    impl ValueType {
14461        /// Gets the enum value.
14462        ///
14463        /// Returns `None` if the enum contains an unknown value deserialized from
14464        /// the string representation of enums.
14465        pub fn value(&self) -> std::option::Option<i32> {
14466            match self {
14467                Self::Unspecified => std::option::Option::Some(0),
14468                Self::Bool => std::option::Option::Some(1),
14469                Self::Int64 => std::option::Option::Some(2),
14470                Self::Double => std::option::Option::Some(3),
14471                Self::String => std::option::Option::Some(4),
14472                Self::Distribution => std::option::Option::Some(5),
14473                Self::Money => std::option::Option::Some(6),
14474                Self::UnknownValue(u) => u.0.value(),
14475            }
14476        }
14477
14478        /// Gets the enum value as a string.
14479        ///
14480        /// Returns `None` if the enum contains an unknown value deserialized from
14481        /// the integer representation of enums.
14482        pub fn name(&self) -> std::option::Option<&str> {
14483            match self {
14484                Self::Unspecified => std::option::Option::Some("VALUE_TYPE_UNSPECIFIED"),
14485                Self::Bool => std::option::Option::Some("BOOL"),
14486                Self::Int64 => std::option::Option::Some("INT64"),
14487                Self::Double => std::option::Option::Some("DOUBLE"),
14488                Self::String => std::option::Option::Some("STRING"),
14489                Self::Distribution => std::option::Option::Some("DISTRIBUTION"),
14490                Self::Money => std::option::Option::Some("MONEY"),
14491                Self::UnknownValue(u) => u.0.name(),
14492            }
14493        }
14494    }
14495
14496    impl std::default::Default for ValueType {
14497        fn default() -> Self {
14498            use std::convert::From;
14499            Self::from(0)
14500        }
14501    }
14502
14503    impl std::fmt::Display for ValueType {
14504        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
14505            wkt::internal::display_enum(f, self.name(), self.value())
14506        }
14507    }
14508
14509    impl std::convert::From<i32> for ValueType {
14510        fn from(value: i32) -> Self {
14511            match value {
14512                0 => Self::Unspecified,
14513                1 => Self::Bool,
14514                2 => Self::Int64,
14515                3 => Self::Double,
14516                4 => Self::String,
14517                5 => Self::Distribution,
14518                6 => Self::Money,
14519                _ => Self::UnknownValue(value_type::UnknownValue(
14520                    wkt::internal::UnknownEnumValue::Integer(value),
14521                )),
14522            }
14523        }
14524    }
14525
14526    impl std::convert::From<&str> for ValueType {
14527        fn from(value: &str) -> Self {
14528            use std::string::ToString;
14529            match value {
14530                "VALUE_TYPE_UNSPECIFIED" => Self::Unspecified,
14531                "BOOL" => Self::Bool,
14532                "INT64" => Self::Int64,
14533                "DOUBLE" => Self::Double,
14534                "STRING" => Self::String,
14535                "DISTRIBUTION" => Self::Distribution,
14536                "MONEY" => Self::Money,
14537                _ => Self::UnknownValue(value_type::UnknownValue(
14538                    wkt::internal::UnknownEnumValue::String(value.to_string()),
14539                )),
14540            }
14541        }
14542    }
14543
14544    impl serde::ser::Serialize for ValueType {
14545        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14546        where
14547            S: serde::Serializer,
14548        {
14549            match self {
14550                Self::Unspecified => serializer.serialize_i32(0),
14551                Self::Bool => serializer.serialize_i32(1),
14552                Self::Int64 => serializer.serialize_i32(2),
14553                Self::Double => serializer.serialize_i32(3),
14554                Self::String => serializer.serialize_i32(4),
14555                Self::Distribution => serializer.serialize_i32(5),
14556                Self::Money => serializer.serialize_i32(6),
14557                Self::UnknownValue(u) => u.0.serialize(serializer),
14558            }
14559        }
14560    }
14561
14562    impl<'de> serde::de::Deserialize<'de> for ValueType {
14563        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14564        where
14565            D: serde::Deserializer<'de>,
14566        {
14567            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
14568                ".google.api.MetricDescriptor.ValueType",
14569            ))
14570        }
14571    }
14572}
14573
14574/// A specific metric, identified by specifying values for all of the
14575/// labels of a [`MetricDescriptor`][google.api.MetricDescriptor].
14576///
14577/// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
14578#[derive(Clone, Debug, Default, PartialEq)]
14579#[non_exhaustive]
14580pub struct Metric {
14581    /// An existing metric type, see
14582    /// [google.api.MetricDescriptor][google.api.MetricDescriptor]. For example,
14583    /// `custom.googleapis.com/invoice/paid/amount`.
14584    ///
14585    /// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
14586    pub r#type: std::string::String,
14587
14588    /// The set of label values that uniquely identify this metric. All
14589    /// labels listed in the `MetricDescriptor` must be assigned values.
14590    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
14591
14592    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14593}
14594
14595impl Metric {
14596    pub fn new() -> Self {
14597        std::default::Default::default()
14598    }
14599
14600    /// Sets the value of [r#type][crate::model::Metric::type].
14601    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14602        self.r#type = v.into();
14603        self
14604    }
14605
14606    /// Sets the value of [labels][crate::model::Metric::labels].
14607    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
14608    where
14609        T: std::iter::IntoIterator<Item = (K, V)>,
14610        K: std::convert::Into<std::string::String>,
14611        V: std::convert::Into<std::string::String>,
14612    {
14613        use std::iter::Iterator;
14614        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
14615        self
14616    }
14617}
14618
14619impl wkt::message::Message for Metric {
14620    fn typename() -> &'static str {
14621        "type.googleapis.com/google.api.Metric"
14622    }
14623}
14624
14625#[doc(hidden)]
14626impl<'de> serde::de::Deserialize<'de> for Metric {
14627    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14628    where
14629        D: serde::Deserializer<'de>,
14630    {
14631        #[allow(non_camel_case_types)]
14632        #[doc(hidden)]
14633        #[derive(PartialEq, Eq, Hash)]
14634        enum __FieldTag {
14635            __type,
14636            __labels,
14637            Unknown(std::string::String),
14638        }
14639        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14640            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14641            where
14642                D: serde::Deserializer<'de>,
14643            {
14644                struct Visitor;
14645                impl<'de> serde::de::Visitor<'de> for Visitor {
14646                    type Value = __FieldTag;
14647                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14648                        formatter.write_str("a field name for Metric")
14649                    }
14650                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14651                    where
14652                        E: serde::de::Error,
14653                    {
14654                        use std::result::Result::Ok;
14655                        use std::string::ToString;
14656                        match value {
14657                            "type" => Ok(__FieldTag::__type),
14658                            "labels" => Ok(__FieldTag::__labels),
14659                            _ => Ok(__FieldTag::Unknown(value.to_string())),
14660                        }
14661                    }
14662                }
14663                deserializer.deserialize_identifier(Visitor)
14664            }
14665        }
14666        struct Visitor;
14667        impl<'de> serde::de::Visitor<'de> for Visitor {
14668            type Value = Metric;
14669            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14670                formatter.write_str("struct Metric")
14671            }
14672            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14673            where
14674                A: serde::de::MapAccess<'de>,
14675            {
14676                #[allow(unused_imports)]
14677                use serde::de::Error;
14678                use std::option::Option::Some;
14679                let mut fields = std::collections::HashSet::new();
14680                let mut result = Self::Value::new();
14681                while let Some(tag) = map.next_key::<__FieldTag>()? {
14682                    #[allow(clippy::match_single_binding)]
14683                    match tag {
14684                        __FieldTag::__type => {
14685                            if !fields.insert(__FieldTag::__type) {
14686                                return std::result::Result::Err(A::Error::duplicate_field(
14687                                    "multiple values for type",
14688                                ));
14689                            }
14690                            result.r#type = map
14691                                .next_value::<std::option::Option<std::string::String>>()?
14692                                .unwrap_or_default();
14693                        }
14694                        __FieldTag::__labels => {
14695                            if !fields.insert(__FieldTag::__labels) {
14696                                return std::result::Result::Err(A::Error::duplicate_field(
14697                                    "multiple values for labels",
14698                                ));
14699                            }
14700                            result.labels = map
14701                                .next_value::<std::option::Option<
14702                                    std::collections::HashMap<
14703                                        std::string::String,
14704                                        std::string::String,
14705                                    >,
14706                                >>()?
14707                                .unwrap_or_default();
14708                        }
14709                        __FieldTag::Unknown(key) => {
14710                            let value = map.next_value::<serde_json::Value>()?;
14711                            result._unknown_fields.insert(key, value);
14712                        }
14713                    }
14714                }
14715                std::result::Result::Ok(result)
14716            }
14717        }
14718        deserializer.deserialize_any(Visitor)
14719    }
14720}
14721
14722#[doc(hidden)]
14723impl serde::ser::Serialize for Metric {
14724    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14725    where
14726        S: serde::ser::Serializer,
14727    {
14728        use serde::ser::SerializeMap;
14729        #[allow(unused_imports)]
14730        use std::option::Option::Some;
14731        let mut state = serializer.serialize_map(std::option::Option::None)?;
14732        if !self.r#type.is_empty() {
14733            state.serialize_entry("type", &self.r#type)?;
14734        }
14735        if !self.labels.is_empty() {
14736            state.serialize_entry("labels", &self.labels)?;
14737        }
14738        if !self._unknown_fields.is_empty() {
14739            for (key, value) in self._unknown_fields.iter() {
14740                state.serialize_entry(key, &value)?;
14741            }
14742        }
14743        state.end()
14744    }
14745}
14746
14747/// An object that describes the schema of a
14748/// [MonitoredResource][google.api.MonitoredResource] object using a type name
14749/// and a set of labels.  For example, the monitored resource descriptor for
14750/// Google Compute Engine VM instances has a type of
14751/// `"gce_instance"` and specifies the use of the labels `"instance_id"` and
14752/// `"zone"` to identify particular VM instances.
14753///
14754/// Different APIs can support different monitored resource types. APIs generally
14755/// provide a `list` method that returns the monitored resource descriptors used
14756/// by the API.
14757///
14758/// [google.api.MonitoredResource]: crate::model::MonitoredResource
14759#[derive(Clone, Debug, Default, PartialEq)]
14760#[non_exhaustive]
14761pub struct MonitoredResourceDescriptor {
14762    /// Optional. The resource name of the monitored resource descriptor:
14763    /// `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where
14764    /// {type} is the value of the `type` field in this object and
14765    /// {project_id} is a project ID that provides API-specific context for
14766    /// accessing the type.  APIs that do not use project information can use the
14767    /// resource name format `"monitoredResourceDescriptors/{type}"`.
14768    pub name: std::string::String,
14769
14770    /// Required. The monitored resource type. For example, the type
14771    /// `"cloudsql_database"` represents databases in Google Cloud SQL.
14772    /// For a list of types, see [Monitored resource
14773    /// types](https://cloud.google.com/monitoring/api/resources)
14774    /// and [Logging resource
14775    /// types](https://cloud.google.com/logging/docs/api/v2/resource-list).
14776    pub r#type: std::string::String,
14777
14778    /// Optional. A concise name for the monitored resource type that might be
14779    /// displayed in user interfaces. It should be a Title Cased Noun Phrase,
14780    /// without any article or other determiners. For example,
14781    /// `"Google Cloud SQL Database"`.
14782    pub display_name: std::string::String,
14783
14784    /// Optional. A detailed description of the monitored resource type that might
14785    /// be used in documentation.
14786    pub description: std::string::String,
14787
14788    /// Required. A set of labels used to describe instances of this monitored
14789    /// resource type. For example, an individual Google Cloud SQL database is
14790    /// identified by values for the labels `"database_id"` and `"zone"`.
14791    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,
14792
14793    /// Optional. The launch stage of the monitored resource definition.
14794    pub launch_stage: crate::model::LaunchStage,
14795
14796    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14797}
14798
14799impl MonitoredResourceDescriptor {
14800    pub fn new() -> Self {
14801        std::default::Default::default()
14802    }
14803
14804    /// Sets the value of [name][crate::model::MonitoredResourceDescriptor::name].
14805    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14806        self.name = v.into();
14807        self
14808    }
14809
14810    /// Sets the value of [r#type][crate::model::MonitoredResourceDescriptor::type].
14811    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14812        self.r#type = v.into();
14813        self
14814    }
14815
14816    /// Sets the value of [display_name][crate::model::MonitoredResourceDescriptor::display_name].
14817    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14818        self.display_name = v.into();
14819        self
14820    }
14821
14822    /// Sets the value of [description][crate::model::MonitoredResourceDescriptor::description].
14823    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14824        self.description = v.into();
14825        self
14826    }
14827
14828    /// Sets the value of [labels][crate::model::MonitoredResourceDescriptor::labels].
14829    pub fn set_labels<T, V>(mut self, v: T) -> Self
14830    where
14831        T: std::iter::IntoIterator<Item = V>,
14832        V: std::convert::Into<crate::model::LabelDescriptor>,
14833    {
14834        use std::iter::Iterator;
14835        self.labels = v.into_iter().map(|i| i.into()).collect();
14836        self
14837    }
14838
14839    /// Sets the value of [launch_stage][crate::model::MonitoredResourceDescriptor::launch_stage].
14840    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
14841        mut self,
14842        v: T,
14843    ) -> Self {
14844        self.launch_stage = v.into();
14845        self
14846    }
14847}
14848
14849impl wkt::message::Message for MonitoredResourceDescriptor {
14850    fn typename() -> &'static str {
14851        "type.googleapis.com/google.api.MonitoredResourceDescriptor"
14852    }
14853}
14854
14855#[doc(hidden)]
14856impl<'de> serde::de::Deserialize<'de> for MonitoredResourceDescriptor {
14857    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14858    where
14859        D: serde::Deserializer<'de>,
14860    {
14861        #[allow(non_camel_case_types)]
14862        #[doc(hidden)]
14863        #[derive(PartialEq, Eq, Hash)]
14864        enum __FieldTag {
14865            __name,
14866            __type,
14867            __display_name,
14868            __description,
14869            __labels,
14870            __launch_stage,
14871            Unknown(std::string::String),
14872        }
14873        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14874            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14875            where
14876                D: serde::Deserializer<'de>,
14877            {
14878                struct Visitor;
14879                impl<'de> serde::de::Visitor<'de> for Visitor {
14880                    type Value = __FieldTag;
14881                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14882                        formatter.write_str("a field name for MonitoredResourceDescriptor")
14883                    }
14884                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14885                    where
14886                        E: serde::de::Error,
14887                    {
14888                        use std::result::Result::Ok;
14889                        use std::string::ToString;
14890                        match value {
14891                            "name" => Ok(__FieldTag::__name),
14892                            "type" => Ok(__FieldTag::__type),
14893                            "displayName" => Ok(__FieldTag::__display_name),
14894                            "display_name" => Ok(__FieldTag::__display_name),
14895                            "description" => Ok(__FieldTag::__description),
14896                            "labels" => Ok(__FieldTag::__labels),
14897                            "launchStage" => Ok(__FieldTag::__launch_stage),
14898                            "launch_stage" => Ok(__FieldTag::__launch_stage),
14899                            _ => Ok(__FieldTag::Unknown(value.to_string())),
14900                        }
14901                    }
14902                }
14903                deserializer.deserialize_identifier(Visitor)
14904            }
14905        }
14906        struct Visitor;
14907        impl<'de> serde::de::Visitor<'de> for Visitor {
14908            type Value = MonitoredResourceDescriptor;
14909            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14910                formatter.write_str("struct MonitoredResourceDescriptor")
14911            }
14912            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14913            where
14914                A: serde::de::MapAccess<'de>,
14915            {
14916                #[allow(unused_imports)]
14917                use serde::de::Error;
14918                use std::option::Option::Some;
14919                let mut fields = std::collections::HashSet::new();
14920                let mut result = Self::Value::new();
14921                while let Some(tag) = map.next_key::<__FieldTag>()? {
14922                    #[allow(clippy::match_single_binding)]
14923                    match tag {
14924                        __FieldTag::__name => {
14925                            if !fields.insert(__FieldTag::__name) {
14926                                return std::result::Result::Err(A::Error::duplicate_field(
14927                                    "multiple values for name",
14928                                ));
14929                            }
14930                            result.name = map
14931                                .next_value::<std::option::Option<std::string::String>>()?
14932                                .unwrap_or_default();
14933                        }
14934                        __FieldTag::__type => {
14935                            if !fields.insert(__FieldTag::__type) {
14936                                return std::result::Result::Err(A::Error::duplicate_field(
14937                                    "multiple values for type",
14938                                ));
14939                            }
14940                            result.r#type = map
14941                                .next_value::<std::option::Option<std::string::String>>()?
14942                                .unwrap_or_default();
14943                        }
14944                        __FieldTag::__display_name => {
14945                            if !fields.insert(__FieldTag::__display_name) {
14946                                return std::result::Result::Err(A::Error::duplicate_field(
14947                                    "multiple values for display_name",
14948                                ));
14949                            }
14950                            result.display_name = map
14951                                .next_value::<std::option::Option<std::string::String>>()?
14952                                .unwrap_or_default();
14953                        }
14954                        __FieldTag::__description => {
14955                            if !fields.insert(__FieldTag::__description) {
14956                                return std::result::Result::Err(A::Error::duplicate_field(
14957                                    "multiple values for description",
14958                                ));
14959                            }
14960                            result.description = map
14961                                .next_value::<std::option::Option<std::string::String>>()?
14962                                .unwrap_or_default();
14963                        }
14964                        __FieldTag::__labels => {
14965                            if !fields.insert(__FieldTag::__labels) {
14966                                return std::result::Result::Err(A::Error::duplicate_field(
14967                                    "multiple values for labels",
14968                                ));
14969                            }
14970                            result.labels =
14971                                map.next_value::<std::option::Option<
14972                                    std::vec::Vec<crate::model::LabelDescriptor>,
14973                                >>()?
14974                                .unwrap_or_default();
14975                        }
14976                        __FieldTag::__launch_stage => {
14977                            if !fields.insert(__FieldTag::__launch_stage) {
14978                                return std::result::Result::Err(A::Error::duplicate_field(
14979                                    "multiple values for launch_stage",
14980                                ));
14981                            }
14982                            result.launch_stage = map
14983                                .next_value::<std::option::Option<crate::model::LaunchStage>>()?
14984                                .unwrap_or_default();
14985                        }
14986                        __FieldTag::Unknown(key) => {
14987                            let value = map.next_value::<serde_json::Value>()?;
14988                            result._unknown_fields.insert(key, value);
14989                        }
14990                    }
14991                }
14992                std::result::Result::Ok(result)
14993            }
14994        }
14995        deserializer.deserialize_any(Visitor)
14996    }
14997}
14998
14999#[doc(hidden)]
15000impl serde::ser::Serialize for MonitoredResourceDescriptor {
15001    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15002    where
15003        S: serde::ser::Serializer,
15004    {
15005        use serde::ser::SerializeMap;
15006        #[allow(unused_imports)]
15007        use std::option::Option::Some;
15008        let mut state = serializer.serialize_map(std::option::Option::None)?;
15009        if !self.name.is_empty() {
15010            state.serialize_entry("name", &self.name)?;
15011        }
15012        if !self.r#type.is_empty() {
15013            state.serialize_entry("type", &self.r#type)?;
15014        }
15015        if !self.display_name.is_empty() {
15016            state.serialize_entry("displayName", &self.display_name)?;
15017        }
15018        if !self.description.is_empty() {
15019            state.serialize_entry("description", &self.description)?;
15020        }
15021        if !self.labels.is_empty() {
15022            state.serialize_entry("labels", &self.labels)?;
15023        }
15024        if !wkt::internal::is_default(&self.launch_stage) {
15025            state.serialize_entry("launchStage", &self.launch_stage)?;
15026        }
15027        if !self._unknown_fields.is_empty() {
15028            for (key, value) in self._unknown_fields.iter() {
15029                state.serialize_entry(key, &value)?;
15030            }
15031        }
15032        state.end()
15033    }
15034}
15035
15036/// An object representing a resource that can be used for monitoring, logging,
15037/// billing, or other purposes. Examples include virtual machine instances,
15038/// databases, and storage devices such as disks. The `type` field identifies a
15039/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object
15040/// that describes the resource's schema. Information in the `labels` field
15041/// identifies the actual resource and its attributes according to the schema.
15042/// For example, a particular Compute Engine VM instance could be represented by
15043/// the following object, because the
15044/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for
15045/// `"gce_instance"` has labels
15046/// `"project_id"`, `"instance_id"` and `"zone"`:
15047///
15048/// ```norust
15049/// { "type": "gce_instance",
15050///   "labels": { "project_id": "my-project",
15051///               "instance_id": "12345678901234",
15052///               "zone": "us-central1-a" }}
15053/// ```
15054///
15055/// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
15056#[derive(Clone, Debug, Default, PartialEq)]
15057#[non_exhaustive]
15058pub struct MonitoredResource {
15059    /// Required. The monitored resource type. This field must match
15060    /// the `type` field of a
15061    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor]
15062    /// object. For example, the type of a Compute Engine VM instance is
15063    /// `gce_instance`. Some descriptors include the service name in the type; for
15064    /// example, the type of a Datastream stream is
15065    /// `datastream.googleapis.com/Stream`.
15066    ///
15067    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
15068    pub r#type: std::string::String,
15069
15070    /// Required. Values for all of the labels listed in the associated monitored
15071    /// resource descriptor. For example, Compute Engine VM instances use the
15072    /// labels `"project_id"`, `"instance_id"`, and `"zone"`.
15073    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
15074
15075    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15076}
15077
15078impl MonitoredResource {
15079    pub fn new() -> Self {
15080        std::default::Default::default()
15081    }
15082
15083    /// Sets the value of [r#type][crate::model::MonitoredResource::type].
15084    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15085        self.r#type = v.into();
15086        self
15087    }
15088
15089    /// Sets the value of [labels][crate::model::MonitoredResource::labels].
15090    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
15091    where
15092        T: std::iter::IntoIterator<Item = (K, V)>,
15093        K: std::convert::Into<std::string::String>,
15094        V: std::convert::Into<std::string::String>,
15095    {
15096        use std::iter::Iterator;
15097        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15098        self
15099    }
15100}
15101
15102impl wkt::message::Message for MonitoredResource {
15103    fn typename() -> &'static str {
15104        "type.googleapis.com/google.api.MonitoredResource"
15105    }
15106}
15107
15108#[doc(hidden)]
15109impl<'de> serde::de::Deserialize<'de> for MonitoredResource {
15110    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15111    where
15112        D: serde::Deserializer<'de>,
15113    {
15114        #[allow(non_camel_case_types)]
15115        #[doc(hidden)]
15116        #[derive(PartialEq, Eq, Hash)]
15117        enum __FieldTag {
15118            __type,
15119            __labels,
15120            Unknown(std::string::String),
15121        }
15122        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15123            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15124            where
15125                D: serde::Deserializer<'de>,
15126            {
15127                struct Visitor;
15128                impl<'de> serde::de::Visitor<'de> for Visitor {
15129                    type Value = __FieldTag;
15130                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15131                        formatter.write_str("a field name for MonitoredResource")
15132                    }
15133                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15134                    where
15135                        E: serde::de::Error,
15136                    {
15137                        use std::result::Result::Ok;
15138                        use std::string::ToString;
15139                        match value {
15140                            "type" => Ok(__FieldTag::__type),
15141                            "labels" => Ok(__FieldTag::__labels),
15142                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15143                        }
15144                    }
15145                }
15146                deserializer.deserialize_identifier(Visitor)
15147            }
15148        }
15149        struct Visitor;
15150        impl<'de> serde::de::Visitor<'de> for Visitor {
15151            type Value = MonitoredResource;
15152            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15153                formatter.write_str("struct MonitoredResource")
15154            }
15155            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15156            where
15157                A: serde::de::MapAccess<'de>,
15158            {
15159                #[allow(unused_imports)]
15160                use serde::de::Error;
15161                use std::option::Option::Some;
15162                let mut fields = std::collections::HashSet::new();
15163                let mut result = Self::Value::new();
15164                while let Some(tag) = map.next_key::<__FieldTag>()? {
15165                    #[allow(clippy::match_single_binding)]
15166                    match tag {
15167                        __FieldTag::__type => {
15168                            if !fields.insert(__FieldTag::__type) {
15169                                return std::result::Result::Err(A::Error::duplicate_field(
15170                                    "multiple values for type",
15171                                ));
15172                            }
15173                            result.r#type = map
15174                                .next_value::<std::option::Option<std::string::String>>()?
15175                                .unwrap_or_default();
15176                        }
15177                        __FieldTag::__labels => {
15178                            if !fields.insert(__FieldTag::__labels) {
15179                                return std::result::Result::Err(A::Error::duplicate_field(
15180                                    "multiple values for labels",
15181                                ));
15182                            }
15183                            result.labels = map
15184                                .next_value::<std::option::Option<
15185                                    std::collections::HashMap<
15186                                        std::string::String,
15187                                        std::string::String,
15188                                    >,
15189                                >>()?
15190                                .unwrap_or_default();
15191                        }
15192                        __FieldTag::Unknown(key) => {
15193                            let value = map.next_value::<serde_json::Value>()?;
15194                            result._unknown_fields.insert(key, value);
15195                        }
15196                    }
15197                }
15198                std::result::Result::Ok(result)
15199            }
15200        }
15201        deserializer.deserialize_any(Visitor)
15202    }
15203}
15204
15205#[doc(hidden)]
15206impl serde::ser::Serialize for MonitoredResource {
15207    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15208    where
15209        S: serde::ser::Serializer,
15210    {
15211        use serde::ser::SerializeMap;
15212        #[allow(unused_imports)]
15213        use std::option::Option::Some;
15214        let mut state = serializer.serialize_map(std::option::Option::None)?;
15215        if !self.r#type.is_empty() {
15216            state.serialize_entry("type", &self.r#type)?;
15217        }
15218        if !self.labels.is_empty() {
15219            state.serialize_entry("labels", &self.labels)?;
15220        }
15221        if !self._unknown_fields.is_empty() {
15222            for (key, value) in self._unknown_fields.iter() {
15223                state.serialize_entry(key, &value)?;
15224            }
15225        }
15226        state.end()
15227    }
15228}
15229
15230/// Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource]
15231/// object. [MonitoredResource][google.api.MonitoredResource] objects contain the
15232/// minimum set of information to uniquely identify a monitored resource
15233/// instance. There is some other useful auxiliary metadata. Monitoring and
15234/// Logging use an ingestion pipeline to extract metadata for cloud resources of
15235/// all types, and store the metadata in this message.
15236///
15237/// [google.api.MonitoredResource]: crate::model::MonitoredResource
15238#[derive(Clone, Debug, Default, PartialEq)]
15239#[non_exhaustive]
15240pub struct MonitoredResourceMetadata {
15241    /// Output only. Values for predefined system metadata labels.
15242    /// System labels are a kind of metadata extracted by Google, including
15243    /// "machine_image", "vpc", "subnet_id",
15244    /// "security_group", "name", etc.
15245    /// System label values can be only strings, Boolean values, or a list of
15246    /// strings. For example:
15247    ///
15248    /// ```norust
15249    /// { "name": "my-test-instance",
15250    ///   "security_group": ["a", "b", "c"],
15251    ///   "spot_instance": false }
15252    /// ```
15253    pub system_labels: std::option::Option<wkt::Struct>,
15254
15255    /// Output only. A map of user-defined metadata labels.
15256    pub user_labels: std::collections::HashMap<std::string::String, std::string::String>,
15257
15258    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15259}
15260
15261impl MonitoredResourceMetadata {
15262    pub fn new() -> Self {
15263        std::default::Default::default()
15264    }
15265
15266    /// Sets the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
15267    pub fn set_system_labels<T>(mut self, v: T) -> Self
15268    where
15269        T: std::convert::Into<wkt::Struct>,
15270    {
15271        self.system_labels = std::option::Option::Some(v.into());
15272        self
15273    }
15274
15275    /// Sets or clears the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
15276    pub fn set_or_clear_system_labels<T>(mut self, v: std::option::Option<T>) -> Self
15277    where
15278        T: std::convert::Into<wkt::Struct>,
15279    {
15280        self.system_labels = v.map(|x| x.into());
15281        self
15282    }
15283
15284    /// Sets the value of [user_labels][crate::model::MonitoredResourceMetadata::user_labels].
15285    pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
15286    where
15287        T: std::iter::IntoIterator<Item = (K, V)>,
15288        K: std::convert::Into<std::string::String>,
15289        V: std::convert::Into<std::string::String>,
15290    {
15291        use std::iter::Iterator;
15292        self.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15293        self
15294    }
15295}
15296
15297impl wkt::message::Message for MonitoredResourceMetadata {
15298    fn typename() -> &'static str {
15299        "type.googleapis.com/google.api.MonitoredResourceMetadata"
15300    }
15301}
15302
15303#[doc(hidden)]
15304impl<'de> serde::de::Deserialize<'de> for MonitoredResourceMetadata {
15305    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15306    where
15307        D: serde::Deserializer<'de>,
15308    {
15309        #[allow(non_camel_case_types)]
15310        #[doc(hidden)]
15311        #[derive(PartialEq, Eq, Hash)]
15312        enum __FieldTag {
15313            __system_labels,
15314            __user_labels,
15315            Unknown(std::string::String),
15316        }
15317        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15318            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15319            where
15320                D: serde::Deserializer<'de>,
15321            {
15322                struct Visitor;
15323                impl<'de> serde::de::Visitor<'de> for Visitor {
15324                    type Value = __FieldTag;
15325                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15326                        formatter.write_str("a field name for MonitoredResourceMetadata")
15327                    }
15328                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15329                    where
15330                        E: serde::de::Error,
15331                    {
15332                        use std::result::Result::Ok;
15333                        use std::string::ToString;
15334                        match value {
15335                            "systemLabels" => Ok(__FieldTag::__system_labels),
15336                            "system_labels" => Ok(__FieldTag::__system_labels),
15337                            "userLabels" => Ok(__FieldTag::__user_labels),
15338                            "user_labels" => Ok(__FieldTag::__user_labels),
15339                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15340                        }
15341                    }
15342                }
15343                deserializer.deserialize_identifier(Visitor)
15344            }
15345        }
15346        struct Visitor;
15347        impl<'de> serde::de::Visitor<'de> for Visitor {
15348            type Value = MonitoredResourceMetadata;
15349            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15350                formatter.write_str("struct MonitoredResourceMetadata")
15351            }
15352            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15353            where
15354                A: serde::de::MapAccess<'de>,
15355            {
15356                #[allow(unused_imports)]
15357                use serde::de::Error;
15358                use std::option::Option::Some;
15359                let mut fields = std::collections::HashSet::new();
15360                let mut result = Self::Value::new();
15361                while let Some(tag) = map.next_key::<__FieldTag>()? {
15362                    #[allow(clippy::match_single_binding)]
15363                    match tag {
15364                        __FieldTag::__system_labels => {
15365                            if !fields.insert(__FieldTag::__system_labels) {
15366                                return std::result::Result::Err(A::Error::duplicate_field(
15367                                    "multiple values for system_labels",
15368                                ));
15369                            }
15370                            result.system_labels =
15371                                map.next_value::<std::option::Option<wkt::Struct>>()?;
15372                        }
15373                        __FieldTag::__user_labels => {
15374                            if !fields.insert(__FieldTag::__user_labels) {
15375                                return std::result::Result::Err(A::Error::duplicate_field(
15376                                    "multiple values for user_labels",
15377                                ));
15378                            }
15379                            result.user_labels = map
15380                                .next_value::<std::option::Option<
15381                                    std::collections::HashMap<
15382                                        std::string::String,
15383                                        std::string::String,
15384                                    >,
15385                                >>()?
15386                                .unwrap_or_default();
15387                        }
15388                        __FieldTag::Unknown(key) => {
15389                            let value = map.next_value::<serde_json::Value>()?;
15390                            result._unknown_fields.insert(key, value);
15391                        }
15392                    }
15393                }
15394                std::result::Result::Ok(result)
15395            }
15396        }
15397        deserializer.deserialize_any(Visitor)
15398    }
15399}
15400
15401#[doc(hidden)]
15402impl serde::ser::Serialize for MonitoredResourceMetadata {
15403    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15404    where
15405        S: serde::ser::Serializer,
15406    {
15407        use serde::ser::SerializeMap;
15408        #[allow(unused_imports)]
15409        use std::option::Option::Some;
15410        let mut state = serializer.serialize_map(std::option::Option::None)?;
15411        if self.system_labels.is_some() {
15412            state.serialize_entry("systemLabels", &self.system_labels)?;
15413        }
15414        if !self.user_labels.is_empty() {
15415            state.serialize_entry("userLabels", &self.user_labels)?;
15416        }
15417        if !self._unknown_fields.is_empty() {
15418            for (key, value) in self._unknown_fields.iter() {
15419                state.serialize_entry(key, &value)?;
15420            }
15421        }
15422        state.end()
15423    }
15424}
15425
15426/// Monitoring configuration of the service.
15427///
15428/// The example below shows how to configure monitored resources and metrics
15429/// for monitoring. In the example, a monitored resource and two metrics are
15430/// defined. The `library.googleapis.com/book/returned_count` metric is sent
15431/// to both producer and consumer projects, whereas the
15432/// `library.googleapis.com/book/num_overdue` metric is only sent to the
15433/// consumer project.
15434///
15435/// ```norust
15436/// monitored_resources:
15437/// - type: library.googleapis.com/Branch
15438///   display_name: "Library Branch"
15439///   description: "A branch of a library."
15440///   launch_stage: GA
15441///   labels:
15442///   - key: resource_container
15443///     description: "The Cloud container (ie. project id) for the Branch."
15444///   - key: location
15445///     description: "The location of the library branch."
15446///   - key: branch_id
15447///     description: "The id of the branch."
15448/// metrics:
15449/// - name: library.googleapis.com/book/returned_count
15450///   display_name: "Books Returned"
15451///   description: "The count of books that have been returned."
15452///   launch_stage: GA
15453///   metric_kind: DELTA
15454///   value_type: INT64
15455///   unit: "1"
15456///   labels:
15457///   - key: customer_id
15458///     description: "The id of the customer."
15459/// - name: library.googleapis.com/book/num_overdue
15460///   display_name: "Books Overdue"
15461///   description: "The current number of overdue books."
15462///   launch_stage: GA
15463///   metric_kind: GAUGE
15464///   value_type: INT64
15465///   unit: "1"
15466///   labels:
15467///   - key: customer_id
15468///     description: "The id of the customer."
15469/// monitoring:
15470///   producer_destinations:
15471///   - monitored_resource: library.googleapis.com/Branch
15472///     metrics:
15473///     - library.googleapis.com/book/returned_count
15474///   consumer_destinations:
15475///   - monitored_resource: library.googleapis.com/Branch
15476///     metrics:
15477///     - library.googleapis.com/book/returned_count
15478///     - library.googleapis.com/book/num_overdue
15479/// ```
15480#[derive(Clone, Debug, Default, PartialEq)]
15481#[non_exhaustive]
15482pub struct Monitoring {
15483    /// Monitoring configurations for sending metrics to the producer project.
15484    /// There can be multiple producer destinations. A monitored resource type may
15485    /// appear in multiple monitoring destinations if different aggregations are
15486    /// needed for different sets of metrics associated with that monitored
15487    /// resource type. A monitored resource and metric pair may only be used once
15488    /// in the Monitoring configuration.
15489    pub producer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
15490
15491    /// Monitoring configurations for sending metrics to the consumer project.
15492    /// There can be multiple consumer destinations. A monitored resource type may
15493    /// appear in multiple monitoring destinations if different aggregations are
15494    /// needed for different sets of metrics associated with that monitored
15495    /// resource type. A monitored resource and metric pair may only be used once
15496    /// in the Monitoring configuration.
15497    pub consumer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
15498
15499    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15500}
15501
15502impl Monitoring {
15503    pub fn new() -> Self {
15504        std::default::Default::default()
15505    }
15506
15507    /// Sets the value of [producer_destinations][crate::model::Monitoring::producer_destinations].
15508    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
15509    where
15510        T: std::iter::IntoIterator<Item = V>,
15511        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
15512    {
15513        use std::iter::Iterator;
15514        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
15515        self
15516    }
15517
15518    /// Sets the value of [consumer_destinations][crate::model::Monitoring::consumer_destinations].
15519    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
15520    where
15521        T: std::iter::IntoIterator<Item = V>,
15522        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
15523    {
15524        use std::iter::Iterator;
15525        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
15526        self
15527    }
15528}
15529
15530impl wkt::message::Message for Monitoring {
15531    fn typename() -> &'static str {
15532        "type.googleapis.com/google.api.Monitoring"
15533    }
15534}
15535
15536#[doc(hidden)]
15537impl<'de> serde::de::Deserialize<'de> for Monitoring {
15538    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15539    where
15540        D: serde::Deserializer<'de>,
15541    {
15542        #[allow(non_camel_case_types)]
15543        #[doc(hidden)]
15544        #[derive(PartialEq, Eq, Hash)]
15545        enum __FieldTag {
15546            __producer_destinations,
15547            __consumer_destinations,
15548            Unknown(std::string::String),
15549        }
15550        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15551            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15552            where
15553                D: serde::Deserializer<'de>,
15554            {
15555                struct Visitor;
15556                impl<'de> serde::de::Visitor<'de> for Visitor {
15557                    type Value = __FieldTag;
15558                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15559                        formatter.write_str("a field name for Monitoring")
15560                    }
15561                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15562                    where
15563                        E: serde::de::Error,
15564                    {
15565                        use std::result::Result::Ok;
15566                        use std::string::ToString;
15567                        match value {
15568                            "producerDestinations" => Ok(__FieldTag::__producer_destinations),
15569                            "producer_destinations" => Ok(__FieldTag::__producer_destinations),
15570                            "consumerDestinations" => Ok(__FieldTag::__consumer_destinations),
15571                            "consumer_destinations" => Ok(__FieldTag::__consumer_destinations),
15572                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15573                        }
15574                    }
15575                }
15576                deserializer.deserialize_identifier(Visitor)
15577            }
15578        }
15579        struct Visitor;
15580        impl<'de> serde::de::Visitor<'de> for Visitor {
15581            type Value = Monitoring;
15582            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15583                formatter.write_str("struct Monitoring")
15584            }
15585            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15586            where
15587                A: serde::de::MapAccess<'de>,
15588            {
15589                #[allow(unused_imports)]
15590                use serde::de::Error;
15591                use std::option::Option::Some;
15592                let mut fields = std::collections::HashSet::new();
15593                let mut result = Self::Value::new();
15594                while let Some(tag) = map.next_key::<__FieldTag>()? {
15595                    #[allow(clippy::match_single_binding)]
15596                    match tag {
15597                        __FieldTag::__producer_destinations => {
15598                            if !fields.insert(__FieldTag::__producer_destinations) {
15599                                return std::result::Result::Err(A::Error::duplicate_field(
15600                                    "multiple values for producer_destinations",
15601                                ));
15602                            }
15603                            result.producer_destinations = map
15604                                .next_value::<std::option::Option<
15605                                    std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
15606                                >>()?
15607                                .unwrap_or_default();
15608                        }
15609                        __FieldTag::__consumer_destinations => {
15610                            if !fields.insert(__FieldTag::__consumer_destinations) {
15611                                return std::result::Result::Err(A::Error::duplicate_field(
15612                                    "multiple values for consumer_destinations",
15613                                ));
15614                            }
15615                            result.consumer_destinations = map
15616                                .next_value::<std::option::Option<
15617                                    std::vec::Vec<crate::model::monitoring::MonitoringDestination>,
15618                                >>()?
15619                                .unwrap_or_default();
15620                        }
15621                        __FieldTag::Unknown(key) => {
15622                            let value = map.next_value::<serde_json::Value>()?;
15623                            result._unknown_fields.insert(key, value);
15624                        }
15625                    }
15626                }
15627                std::result::Result::Ok(result)
15628            }
15629        }
15630        deserializer.deserialize_any(Visitor)
15631    }
15632}
15633
15634#[doc(hidden)]
15635impl serde::ser::Serialize for Monitoring {
15636    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15637    where
15638        S: serde::ser::Serializer,
15639    {
15640        use serde::ser::SerializeMap;
15641        #[allow(unused_imports)]
15642        use std::option::Option::Some;
15643        let mut state = serializer.serialize_map(std::option::Option::None)?;
15644        if !self.producer_destinations.is_empty() {
15645            state.serialize_entry("producerDestinations", &self.producer_destinations)?;
15646        }
15647        if !self.consumer_destinations.is_empty() {
15648            state.serialize_entry("consumerDestinations", &self.consumer_destinations)?;
15649        }
15650        if !self._unknown_fields.is_empty() {
15651            for (key, value) in self._unknown_fields.iter() {
15652                state.serialize_entry(key, &value)?;
15653            }
15654        }
15655        state.end()
15656    }
15657}
15658
15659/// Defines additional types related to [Monitoring].
15660pub mod monitoring {
15661    #[allow(unused_imports)]
15662    use super::*;
15663
15664    /// Configuration of a specific monitoring destination (the producer project
15665    /// or the consumer project).
15666    #[derive(Clone, Debug, Default, PartialEq)]
15667    #[non_exhaustive]
15668    pub struct MonitoringDestination {
15669        /// The monitored resource type. The type must be defined in
15670        /// [Service.monitored_resources][google.api.Service.monitored_resources]
15671        /// section.
15672        ///
15673        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
15674        pub monitored_resource: std::string::String,
15675
15676        /// Types of the metrics to report to this monitoring destination.
15677        /// Each type must be defined in
15678        /// [Service.metrics][google.api.Service.metrics] section.
15679        ///
15680        /// [google.api.Service.metrics]: crate::model::Service::metrics
15681        pub metrics: std::vec::Vec<std::string::String>,
15682
15683        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15684    }
15685
15686    impl MonitoringDestination {
15687        pub fn new() -> Self {
15688            std::default::Default::default()
15689        }
15690
15691        /// Sets the value of [monitored_resource][crate::model::monitoring::MonitoringDestination::monitored_resource].
15692        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
15693            mut self,
15694            v: T,
15695        ) -> Self {
15696            self.monitored_resource = v.into();
15697            self
15698        }
15699
15700        /// Sets the value of [metrics][crate::model::monitoring::MonitoringDestination::metrics].
15701        pub fn set_metrics<T, V>(mut self, v: T) -> Self
15702        where
15703            T: std::iter::IntoIterator<Item = V>,
15704            V: std::convert::Into<std::string::String>,
15705        {
15706            use std::iter::Iterator;
15707            self.metrics = v.into_iter().map(|i| i.into()).collect();
15708            self
15709        }
15710    }
15711
15712    impl wkt::message::Message for MonitoringDestination {
15713        fn typename() -> &'static str {
15714            "type.googleapis.com/google.api.Monitoring.MonitoringDestination"
15715        }
15716    }
15717
15718    #[doc(hidden)]
15719    impl<'de> serde::de::Deserialize<'de> for MonitoringDestination {
15720        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15721        where
15722            D: serde::Deserializer<'de>,
15723        {
15724            #[allow(non_camel_case_types)]
15725            #[doc(hidden)]
15726            #[derive(PartialEq, Eq, Hash)]
15727            enum __FieldTag {
15728                __monitored_resource,
15729                __metrics,
15730                Unknown(std::string::String),
15731            }
15732            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15733                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15734                where
15735                    D: serde::Deserializer<'de>,
15736                {
15737                    struct Visitor;
15738                    impl<'de> serde::de::Visitor<'de> for Visitor {
15739                        type Value = __FieldTag;
15740                        fn expecting(
15741                            &self,
15742                            formatter: &mut std::fmt::Formatter,
15743                        ) -> std::fmt::Result {
15744                            formatter.write_str("a field name for MonitoringDestination")
15745                        }
15746                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15747                        where
15748                            E: serde::de::Error,
15749                        {
15750                            use std::result::Result::Ok;
15751                            use std::string::ToString;
15752                            match value {
15753                                "monitoredResource" => Ok(__FieldTag::__monitored_resource),
15754                                "monitored_resource" => Ok(__FieldTag::__monitored_resource),
15755                                "metrics" => Ok(__FieldTag::__metrics),
15756                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15757                            }
15758                        }
15759                    }
15760                    deserializer.deserialize_identifier(Visitor)
15761                }
15762            }
15763            struct Visitor;
15764            impl<'de> serde::de::Visitor<'de> for Visitor {
15765                type Value = MonitoringDestination;
15766                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15767                    formatter.write_str("struct MonitoringDestination")
15768                }
15769                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15770                where
15771                    A: serde::de::MapAccess<'de>,
15772                {
15773                    #[allow(unused_imports)]
15774                    use serde::de::Error;
15775                    use std::option::Option::Some;
15776                    let mut fields = std::collections::HashSet::new();
15777                    let mut result = Self::Value::new();
15778                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15779                        #[allow(clippy::match_single_binding)]
15780                        match tag {
15781                            __FieldTag::__monitored_resource => {
15782                                if !fields.insert(__FieldTag::__monitored_resource) {
15783                                    return std::result::Result::Err(A::Error::duplicate_field(
15784                                        "multiple values for monitored_resource",
15785                                    ));
15786                                }
15787                                result.monitored_resource = map
15788                                    .next_value::<std::option::Option<std::string::String>>()?
15789                                    .unwrap_or_default();
15790                            }
15791                            __FieldTag::__metrics => {
15792                                if !fields.insert(__FieldTag::__metrics) {
15793                                    return std::result::Result::Err(A::Error::duplicate_field(
15794                                        "multiple values for metrics",
15795                                    ));
15796                                }
15797                                result.metrics = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
15798                            }
15799                            __FieldTag::Unknown(key) => {
15800                                let value = map.next_value::<serde_json::Value>()?;
15801                                result._unknown_fields.insert(key, value);
15802                            }
15803                        }
15804                    }
15805                    std::result::Result::Ok(result)
15806                }
15807            }
15808            deserializer.deserialize_any(Visitor)
15809        }
15810    }
15811
15812    #[doc(hidden)]
15813    impl serde::ser::Serialize for MonitoringDestination {
15814        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15815        where
15816            S: serde::ser::Serializer,
15817        {
15818            use serde::ser::SerializeMap;
15819            #[allow(unused_imports)]
15820            use std::option::Option::Some;
15821            let mut state = serializer.serialize_map(std::option::Option::None)?;
15822            if !self.monitored_resource.is_empty() {
15823                state.serialize_entry("monitoredResource", &self.monitored_resource)?;
15824            }
15825            if !self.metrics.is_empty() {
15826                state.serialize_entry("metrics", &self.metrics)?;
15827            }
15828            if !self._unknown_fields.is_empty() {
15829                for (key, value) in self._unknown_fields.iter() {
15830                    state.serialize_entry(key, &value)?;
15831                }
15832            }
15833            state.end()
15834        }
15835    }
15836}
15837
15838/// Google API Policy Annotation
15839///
15840/// This message defines a simple API policy annotation that can be used to
15841/// annotate API request and response message fields with applicable policies.
15842/// One field may have multiple applicable policies that must all be satisfied
15843/// before a request can be processed. This policy annotation is used to
15844/// generate the overall policy that will be used for automatic runtime
15845/// policy enforcement and documentation generation.
15846#[derive(Clone, Debug, Default, PartialEq)]
15847#[non_exhaustive]
15848pub struct FieldPolicy {
15849    /// Selects one or more request or response message fields to apply this
15850    /// `FieldPolicy`.
15851    ///
15852    /// When a `FieldPolicy` is used in proto annotation, the selector must
15853    /// be left as empty. The service config generator will automatically fill
15854    /// the correct value.
15855    ///
15856    /// When a `FieldPolicy` is used in service config, the selector must be a
15857    /// comma-separated string with valid request or response field paths,
15858    /// such as "foo.bar" or "foo.bar,foo.baz".
15859    pub selector: std::string::String,
15860
15861    /// Specifies the required permission(s) for the resource referred to by the
15862    /// field. It requires the field contains a valid resource reference, and
15863    /// the request must pass the permission checks to proceed. For example,
15864    /// "resourcemanager.projects.get".
15865    pub resource_permission: std::string::String,
15866
15867    /// Specifies the resource type for the resource referred to by the field.
15868    pub resource_type: std::string::String,
15869
15870    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15871}
15872
15873impl FieldPolicy {
15874    pub fn new() -> Self {
15875        std::default::Default::default()
15876    }
15877
15878    /// Sets the value of [selector][crate::model::FieldPolicy::selector].
15879    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15880        self.selector = v.into();
15881        self
15882    }
15883
15884    /// Sets the value of [resource_permission][crate::model::FieldPolicy::resource_permission].
15885    pub fn set_resource_permission<T: std::convert::Into<std::string::String>>(
15886        mut self,
15887        v: T,
15888    ) -> Self {
15889        self.resource_permission = v.into();
15890        self
15891    }
15892
15893    /// Sets the value of [resource_type][crate::model::FieldPolicy::resource_type].
15894    pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15895        self.resource_type = v.into();
15896        self
15897    }
15898}
15899
15900impl wkt::message::Message for FieldPolicy {
15901    fn typename() -> &'static str {
15902        "type.googleapis.com/google.api.FieldPolicy"
15903    }
15904}
15905
15906#[doc(hidden)]
15907impl<'de> serde::de::Deserialize<'de> for FieldPolicy {
15908    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15909    where
15910        D: serde::Deserializer<'de>,
15911    {
15912        #[allow(non_camel_case_types)]
15913        #[doc(hidden)]
15914        #[derive(PartialEq, Eq, Hash)]
15915        enum __FieldTag {
15916            __selector,
15917            __resource_permission,
15918            __resource_type,
15919            Unknown(std::string::String),
15920        }
15921        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15922            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15923            where
15924                D: serde::Deserializer<'de>,
15925            {
15926                struct Visitor;
15927                impl<'de> serde::de::Visitor<'de> for Visitor {
15928                    type Value = __FieldTag;
15929                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15930                        formatter.write_str("a field name for FieldPolicy")
15931                    }
15932                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15933                    where
15934                        E: serde::de::Error,
15935                    {
15936                        use std::result::Result::Ok;
15937                        use std::string::ToString;
15938                        match value {
15939                            "selector" => Ok(__FieldTag::__selector),
15940                            "resourcePermission" => Ok(__FieldTag::__resource_permission),
15941                            "resource_permission" => Ok(__FieldTag::__resource_permission),
15942                            "resourceType" => Ok(__FieldTag::__resource_type),
15943                            "resource_type" => Ok(__FieldTag::__resource_type),
15944                            _ => Ok(__FieldTag::Unknown(value.to_string())),
15945                        }
15946                    }
15947                }
15948                deserializer.deserialize_identifier(Visitor)
15949            }
15950        }
15951        struct Visitor;
15952        impl<'de> serde::de::Visitor<'de> for Visitor {
15953            type Value = FieldPolicy;
15954            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15955                formatter.write_str("struct FieldPolicy")
15956            }
15957            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15958            where
15959                A: serde::de::MapAccess<'de>,
15960            {
15961                #[allow(unused_imports)]
15962                use serde::de::Error;
15963                use std::option::Option::Some;
15964                let mut fields = std::collections::HashSet::new();
15965                let mut result = Self::Value::new();
15966                while let Some(tag) = map.next_key::<__FieldTag>()? {
15967                    #[allow(clippy::match_single_binding)]
15968                    match tag {
15969                        __FieldTag::__selector => {
15970                            if !fields.insert(__FieldTag::__selector) {
15971                                return std::result::Result::Err(A::Error::duplicate_field(
15972                                    "multiple values for selector",
15973                                ));
15974                            }
15975                            result.selector = map
15976                                .next_value::<std::option::Option<std::string::String>>()?
15977                                .unwrap_or_default();
15978                        }
15979                        __FieldTag::__resource_permission => {
15980                            if !fields.insert(__FieldTag::__resource_permission) {
15981                                return std::result::Result::Err(A::Error::duplicate_field(
15982                                    "multiple values for resource_permission",
15983                                ));
15984                            }
15985                            result.resource_permission = map
15986                                .next_value::<std::option::Option<std::string::String>>()?
15987                                .unwrap_or_default();
15988                        }
15989                        __FieldTag::__resource_type => {
15990                            if !fields.insert(__FieldTag::__resource_type) {
15991                                return std::result::Result::Err(A::Error::duplicate_field(
15992                                    "multiple values for resource_type",
15993                                ));
15994                            }
15995                            result.resource_type = map
15996                                .next_value::<std::option::Option<std::string::String>>()?
15997                                .unwrap_or_default();
15998                        }
15999                        __FieldTag::Unknown(key) => {
16000                            let value = map.next_value::<serde_json::Value>()?;
16001                            result._unknown_fields.insert(key, value);
16002                        }
16003                    }
16004                }
16005                std::result::Result::Ok(result)
16006            }
16007        }
16008        deserializer.deserialize_any(Visitor)
16009    }
16010}
16011
16012#[doc(hidden)]
16013impl serde::ser::Serialize for FieldPolicy {
16014    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16015    where
16016        S: serde::ser::Serializer,
16017    {
16018        use serde::ser::SerializeMap;
16019        #[allow(unused_imports)]
16020        use std::option::Option::Some;
16021        let mut state = serializer.serialize_map(std::option::Option::None)?;
16022        if !self.selector.is_empty() {
16023            state.serialize_entry("selector", &self.selector)?;
16024        }
16025        if !self.resource_permission.is_empty() {
16026            state.serialize_entry("resourcePermission", &self.resource_permission)?;
16027        }
16028        if !self.resource_type.is_empty() {
16029            state.serialize_entry("resourceType", &self.resource_type)?;
16030        }
16031        if !self._unknown_fields.is_empty() {
16032            for (key, value) in self._unknown_fields.iter() {
16033                state.serialize_entry(key, &value)?;
16034            }
16035        }
16036        state.end()
16037    }
16038}
16039
16040/// Defines policies applying to an RPC method.
16041#[derive(Clone, Debug, Default, PartialEq)]
16042#[non_exhaustive]
16043pub struct MethodPolicy {
16044    /// Selects a method to which these policies should be enforced, for example,
16045    /// "google.pubsub.v1.Subscriber.CreateSubscription".
16046    ///
16047    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
16048    /// details.
16049    ///
16050    /// NOTE: This field must not be set in the proto annotation. It will be
16051    /// automatically filled by the service config compiler .
16052    ///
16053    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
16054    pub selector: std::string::String,
16055
16056    /// Policies that are applicable to the request message.
16057    pub request_policies: std::vec::Vec<crate::model::FieldPolicy>,
16058
16059    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16060}
16061
16062impl MethodPolicy {
16063    pub fn new() -> Self {
16064        std::default::Default::default()
16065    }
16066
16067    /// Sets the value of [selector][crate::model::MethodPolicy::selector].
16068    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16069        self.selector = v.into();
16070        self
16071    }
16072
16073    /// Sets the value of [request_policies][crate::model::MethodPolicy::request_policies].
16074    pub fn set_request_policies<T, V>(mut self, v: T) -> Self
16075    where
16076        T: std::iter::IntoIterator<Item = V>,
16077        V: std::convert::Into<crate::model::FieldPolicy>,
16078    {
16079        use std::iter::Iterator;
16080        self.request_policies = v.into_iter().map(|i| i.into()).collect();
16081        self
16082    }
16083}
16084
16085impl wkt::message::Message for MethodPolicy {
16086    fn typename() -> &'static str {
16087        "type.googleapis.com/google.api.MethodPolicy"
16088    }
16089}
16090
16091#[doc(hidden)]
16092impl<'de> serde::de::Deserialize<'de> for MethodPolicy {
16093    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16094    where
16095        D: serde::Deserializer<'de>,
16096    {
16097        #[allow(non_camel_case_types)]
16098        #[doc(hidden)]
16099        #[derive(PartialEq, Eq, Hash)]
16100        enum __FieldTag {
16101            __selector,
16102            __request_policies,
16103            Unknown(std::string::String),
16104        }
16105        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16106            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16107            where
16108                D: serde::Deserializer<'de>,
16109            {
16110                struct Visitor;
16111                impl<'de> serde::de::Visitor<'de> for Visitor {
16112                    type Value = __FieldTag;
16113                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16114                        formatter.write_str("a field name for MethodPolicy")
16115                    }
16116                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16117                    where
16118                        E: serde::de::Error,
16119                    {
16120                        use std::result::Result::Ok;
16121                        use std::string::ToString;
16122                        match value {
16123                            "selector" => Ok(__FieldTag::__selector),
16124                            "requestPolicies" => Ok(__FieldTag::__request_policies),
16125                            "request_policies" => Ok(__FieldTag::__request_policies),
16126                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16127                        }
16128                    }
16129                }
16130                deserializer.deserialize_identifier(Visitor)
16131            }
16132        }
16133        struct Visitor;
16134        impl<'de> serde::de::Visitor<'de> for Visitor {
16135            type Value = MethodPolicy;
16136            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16137                formatter.write_str("struct MethodPolicy")
16138            }
16139            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16140            where
16141                A: serde::de::MapAccess<'de>,
16142            {
16143                #[allow(unused_imports)]
16144                use serde::de::Error;
16145                use std::option::Option::Some;
16146                let mut fields = std::collections::HashSet::new();
16147                let mut result = Self::Value::new();
16148                while let Some(tag) = map.next_key::<__FieldTag>()? {
16149                    #[allow(clippy::match_single_binding)]
16150                    match tag {
16151                        __FieldTag::__selector => {
16152                            if !fields.insert(__FieldTag::__selector) {
16153                                return std::result::Result::Err(A::Error::duplicate_field(
16154                                    "multiple values for selector",
16155                                ));
16156                            }
16157                            result.selector = map
16158                                .next_value::<std::option::Option<std::string::String>>()?
16159                                .unwrap_or_default();
16160                        }
16161                        __FieldTag::__request_policies => {
16162                            if !fields.insert(__FieldTag::__request_policies) {
16163                                return std::result::Result::Err(A::Error::duplicate_field(
16164                                    "multiple values for request_policies",
16165                                ));
16166                            }
16167                            result.request_policies = map.next_value::<std::option::Option<std::vec::Vec<crate::model::FieldPolicy>>>()?.unwrap_or_default();
16168                        }
16169                        __FieldTag::Unknown(key) => {
16170                            let value = map.next_value::<serde_json::Value>()?;
16171                            result._unknown_fields.insert(key, value);
16172                        }
16173                    }
16174                }
16175                std::result::Result::Ok(result)
16176            }
16177        }
16178        deserializer.deserialize_any(Visitor)
16179    }
16180}
16181
16182#[doc(hidden)]
16183impl serde::ser::Serialize for MethodPolicy {
16184    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16185    where
16186        S: serde::ser::Serializer,
16187    {
16188        use serde::ser::SerializeMap;
16189        #[allow(unused_imports)]
16190        use std::option::Option::Some;
16191        let mut state = serializer.serialize_map(std::option::Option::None)?;
16192        if !self.selector.is_empty() {
16193            state.serialize_entry("selector", &self.selector)?;
16194        }
16195        if !self.request_policies.is_empty() {
16196            state.serialize_entry("requestPolicies", &self.request_policies)?;
16197        }
16198        if !self._unknown_fields.is_empty() {
16199            for (key, value) in self._unknown_fields.iter() {
16200                state.serialize_entry(key, &value)?;
16201            }
16202        }
16203        state.end()
16204    }
16205}
16206
16207/// Quota configuration helps to achieve fairness and budgeting in service
16208/// usage.
16209///
16210/// The metric based quota configuration works this way:
16211///
16212/// - The service configuration defines a set of metrics.
16213/// - For API calls, the quota.metric_rules maps methods to metrics with
16214///   corresponding costs.
16215/// - The quota.limits defines limits on the metrics, which will be used for
16216///   quota checks at runtime.
16217///
16218/// An example quota configuration in yaml format:
16219///
16220/// quota:
16221/// limits:
16222///
16223/// ```norust
16224///  - name: apiWriteQpsPerProject
16225///    metric: library.googleapis.com/write_calls
16226///    unit: "1/min/{project}"  # rate limit for consumer projects
16227///    values:
16228///      STANDARD: 10000
16229///
16230///
16231///  (The metric rules bind all methods to the read_calls metric,
16232///   except for the UpdateBook and DeleteBook methods. These two methods
16233///   are mapped to the write_calls metric, with the UpdateBook method
16234///   consuming at twice rate as the DeleteBook method.)
16235///  metric_rules:
16236///  - selector: "*"
16237///    metric_costs:
16238///      library.googleapis.com/read_calls: 1
16239///  - selector: google.example.library.v1.LibraryService.UpdateBook
16240///    metric_costs:
16241///      library.googleapis.com/write_calls: 2
16242///  - selector: google.example.library.v1.LibraryService.DeleteBook
16243///    metric_costs:
16244///      library.googleapis.com/write_calls: 1
16245/// ```
16246///
16247/// Corresponding Metric definition:
16248///
16249/// ```norust
16250///  metrics:
16251///  - name: library.googleapis.com/read_calls
16252///    display_name: Read requests
16253///    metric_kind: DELTA
16254///    value_type: INT64
16255///
16256///  - name: library.googleapis.com/write_calls
16257///    display_name: Write requests
16258///    metric_kind: DELTA
16259///    value_type: INT64
16260/// ```
16261#[derive(Clone, Debug, Default, PartialEq)]
16262#[non_exhaustive]
16263pub struct Quota {
16264    /// List of QuotaLimit definitions for the service.
16265    pub limits: std::vec::Vec<crate::model::QuotaLimit>,
16266
16267    /// List of MetricRule definitions, each one mapping a selected method to one
16268    /// or more metrics.
16269    pub metric_rules: std::vec::Vec<crate::model::MetricRule>,
16270
16271    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16272}
16273
16274impl Quota {
16275    pub fn new() -> Self {
16276        std::default::Default::default()
16277    }
16278
16279    /// Sets the value of [limits][crate::model::Quota::limits].
16280    pub fn set_limits<T, V>(mut self, v: T) -> Self
16281    where
16282        T: std::iter::IntoIterator<Item = V>,
16283        V: std::convert::Into<crate::model::QuotaLimit>,
16284    {
16285        use std::iter::Iterator;
16286        self.limits = v.into_iter().map(|i| i.into()).collect();
16287        self
16288    }
16289
16290    /// Sets the value of [metric_rules][crate::model::Quota::metric_rules].
16291    pub fn set_metric_rules<T, V>(mut self, v: T) -> Self
16292    where
16293        T: std::iter::IntoIterator<Item = V>,
16294        V: std::convert::Into<crate::model::MetricRule>,
16295    {
16296        use std::iter::Iterator;
16297        self.metric_rules = v.into_iter().map(|i| i.into()).collect();
16298        self
16299    }
16300}
16301
16302impl wkt::message::Message for Quota {
16303    fn typename() -> &'static str {
16304        "type.googleapis.com/google.api.Quota"
16305    }
16306}
16307
16308#[doc(hidden)]
16309impl<'de> serde::de::Deserialize<'de> for Quota {
16310    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16311    where
16312        D: serde::Deserializer<'de>,
16313    {
16314        #[allow(non_camel_case_types)]
16315        #[doc(hidden)]
16316        #[derive(PartialEq, Eq, Hash)]
16317        enum __FieldTag {
16318            __limits,
16319            __metric_rules,
16320            Unknown(std::string::String),
16321        }
16322        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16323            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16324            where
16325                D: serde::Deserializer<'de>,
16326            {
16327                struct Visitor;
16328                impl<'de> serde::de::Visitor<'de> for Visitor {
16329                    type Value = __FieldTag;
16330                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16331                        formatter.write_str("a field name for Quota")
16332                    }
16333                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16334                    where
16335                        E: serde::de::Error,
16336                    {
16337                        use std::result::Result::Ok;
16338                        use std::string::ToString;
16339                        match value {
16340                            "limits" => Ok(__FieldTag::__limits),
16341                            "metricRules" => Ok(__FieldTag::__metric_rules),
16342                            "metric_rules" => Ok(__FieldTag::__metric_rules),
16343                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16344                        }
16345                    }
16346                }
16347                deserializer.deserialize_identifier(Visitor)
16348            }
16349        }
16350        struct Visitor;
16351        impl<'de> serde::de::Visitor<'de> for Visitor {
16352            type Value = Quota;
16353            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16354                formatter.write_str("struct Quota")
16355            }
16356            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16357            where
16358                A: serde::de::MapAccess<'de>,
16359            {
16360                #[allow(unused_imports)]
16361                use serde::de::Error;
16362                use std::option::Option::Some;
16363                let mut fields = std::collections::HashSet::new();
16364                let mut result = Self::Value::new();
16365                while let Some(tag) = map.next_key::<__FieldTag>()? {
16366                    #[allow(clippy::match_single_binding)]
16367                    match tag {
16368                        __FieldTag::__limits => {
16369                            if !fields.insert(__FieldTag::__limits) {
16370                                return std::result::Result::Err(A::Error::duplicate_field(
16371                                    "multiple values for limits",
16372                                ));
16373                            }
16374                            result.limits = map.next_value::<std::option::Option<std::vec::Vec<crate::model::QuotaLimit>>>()?.unwrap_or_default();
16375                        }
16376                        __FieldTag::__metric_rules => {
16377                            if !fields.insert(__FieldTag::__metric_rules) {
16378                                return std::result::Result::Err(A::Error::duplicate_field(
16379                                    "multiple values for metric_rules",
16380                                ));
16381                            }
16382                            result.metric_rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MetricRule>>>()?.unwrap_or_default();
16383                        }
16384                        __FieldTag::Unknown(key) => {
16385                            let value = map.next_value::<serde_json::Value>()?;
16386                            result._unknown_fields.insert(key, value);
16387                        }
16388                    }
16389                }
16390                std::result::Result::Ok(result)
16391            }
16392        }
16393        deserializer.deserialize_any(Visitor)
16394    }
16395}
16396
16397#[doc(hidden)]
16398impl serde::ser::Serialize for Quota {
16399    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16400    where
16401        S: serde::ser::Serializer,
16402    {
16403        use serde::ser::SerializeMap;
16404        #[allow(unused_imports)]
16405        use std::option::Option::Some;
16406        let mut state = serializer.serialize_map(std::option::Option::None)?;
16407        if !self.limits.is_empty() {
16408            state.serialize_entry("limits", &self.limits)?;
16409        }
16410        if !self.metric_rules.is_empty() {
16411            state.serialize_entry("metricRules", &self.metric_rules)?;
16412        }
16413        if !self._unknown_fields.is_empty() {
16414            for (key, value) in self._unknown_fields.iter() {
16415                state.serialize_entry(key, &value)?;
16416            }
16417        }
16418        state.end()
16419    }
16420}
16421
16422/// Bind API methods to metrics. Binding a method to a metric causes that
16423/// metric's configured quota behaviors to apply to the method call.
16424#[derive(Clone, Debug, Default, PartialEq)]
16425#[non_exhaustive]
16426pub struct MetricRule {
16427    /// Selects the methods to which this rule applies.
16428    ///
16429    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
16430    /// details.
16431    ///
16432    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
16433    pub selector: std::string::String,
16434
16435    /// Metrics to update when the selected methods are called, and the associated
16436    /// cost applied to each metric.
16437    ///
16438    /// The key of the map is the metric name, and the values are the amount
16439    /// increased for the metric against which the quota limits are defined.
16440    /// The value must not be negative.
16441    pub metric_costs: std::collections::HashMap<std::string::String, i64>,
16442
16443    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16444}
16445
16446impl MetricRule {
16447    pub fn new() -> Self {
16448        std::default::Default::default()
16449    }
16450
16451    /// Sets the value of [selector][crate::model::MetricRule::selector].
16452    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16453        self.selector = v.into();
16454        self
16455    }
16456
16457    /// Sets the value of [metric_costs][crate::model::MetricRule::metric_costs].
16458    pub fn set_metric_costs<T, K, V>(mut self, v: T) -> Self
16459    where
16460        T: std::iter::IntoIterator<Item = (K, V)>,
16461        K: std::convert::Into<std::string::String>,
16462        V: std::convert::Into<i64>,
16463    {
16464        use std::iter::Iterator;
16465        self.metric_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
16466        self
16467    }
16468}
16469
16470impl wkt::message::Message for MetricRule {
16471    fn typename() -> &'static str {
16472        "type.googleapis.com/google.api.MetricRule"
16473    }
16474}
16475
16476#[doc(hidden)]
16477impl<'de> serde::de::Deserialize<'de> for MetricRule {
16478    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16479    where
16480        D: serde::Deserializer<'de>,
16481    {
16482        #[allow(non_camel_case_types)]
16483        #[doc(hidden)]
16484        #[derive(PartialEq, Eq, Hash)]
16485        enum __FieldTag {
16486            __selector,
16487            __metric_costs,
16488            Unknown(std::string::String),
16489        }
16490        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16491            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16492            where
16493                D: serde::Deserializer<'de>,
16494            {
16495                struct Visitor;
16496                impl<'de> serde::de::Visitor<'de> for Visitor {
16497                    type Value = __FieldTag;
16498                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16499                        formatter.write_str("a field name for MetricRule")
16500                    }
16501                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16502                    where
16503                        E: serde::de::Error,
16504                    {
16505                        use std::result::Result::Ok;
16506                        use std::string::ToString;
16507                        match value {
16508                            "selector" => Ok(__FieldTag::__selector),
16509                            "metricCosts" => Ok(__FieldTag::__metric_costs),
16510                            "metric_costs" => Ok(__FieldTag::__metric_costs),
16511                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16512                        }
16513                    }
16514                }
16515                deserializer.deserialize_identifier(Visitor)
16516            }
16517        }
16518        struct Visitor;
16519        impl<'de> serde::de::Visitor<'de> for Visitor {
16520            type Value = MetricRule;
16521            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16522                formatter.write_str("struct MetricRule")
16523            }
16524            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16525            where
16526                A: serde::de::MapAccess<'de>,
16527            {
16528                #[allow(unused_imports)]
16529                use serde::de::Error;
16530                use std::option::Option::Some;
16531                let mut fields = std::collections::HashSet::new();
16532                let mut result = Self::Value::new();
16533                while let Some(tag) = map.next_key::<__FieldTag>()? {
16534                    #[allow(clippy::match_single_binding)]
16535                    match tag {
16536                        __FieldTag::__selector => {
16537                            if !fields.insert(__FieldTag::__selector) {
16538                                return std::result::Result::Err(A::Error::duplicate_field(
16539                                    "multiple values for selector",
16540                                ));
16541                            }
16542                            result.selector = map
16543                                .next_value::<std::option::Option<std::string::String>>()?
16544                                .unwrap_or_default();
16545                        }
16546                        __FieldTag::__metric_costs => {
16547                            if !fields.insert(__FieldTag::__metric_costs) {
16548                                return std::result::Result::Err(A::Error::duplicate_field(
16549                                    "multiple values for metric_costs",
16550                                ));
16551                            }
16552                            struct __With(
16553                                std::option::Option<
16554                                    std::collections::HashMap<std::string::String, i64>,
16555                                >,
16556                            );
16557                            impl<'de> serde::de::Deserialize<'de> for __With {
16558                                fn deserialize<D>(
16559                                    deserializer: D,
16560                                ) -> std::result::Result<Self, D::Error>
16561                                where
16562                                    D: serde::de::Deserializer<'de>,
16563                                {
16564                                    serde_with::As::<
16565                                        std::option::Option<
16566                                            std::collections::HashMap<
16567                                                serde_with::Same,
16568                                                wkt::internal::I64,
16569                                            >,
16570                                        >,
16571                                    >::deserialize(deserializer)
16572                                    .map(__With)
16573                                }
16574                            }
16575                            result.metric_costs = map.next_value::<__With>()?.0.unwrap_or_default();
16576                        }
16577                        __FieldTag::Unknown(key) => {
16578                            let value = map.next_value::<serde_json::Value>()?;
16579                            result._unknown_fields.insert(key, value);
16580                        }
16581                    }
16582                }
16583                std::result::Result::Ok(result)
16584            }
16585        }
16586        deserializer.deserialize_any(Visitor)
16587    }
16588}
16589
16590#[doc(hidden)]
16591impl serde::ser::Serialize for MetricRule {
16592    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16593    where
16594        S: serde::ser::Serializer,
16595    {
16596        use serde::ser::SerializeMap;
16597        #[allow(unused_imports)]
16598        use std::option::Option::Some;
16599        let mut state = serializer.serialize_map(std::option::Option::None)?;
16600        if !self.selector.is_empty() {
16601            state.serialize_entry("selector", &self.selector)?;
16602        }
16603        if !self.metric_costs.is_empty() {
16604            struct __With<'a>(&'a std::collections::HashMap<std::string::String, i64>);
16605            impl<'a> serde::ser::Serialize for __With<'a> {
16606                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16607                where
16608                    S: serde::ser::Serializer,
16609                {
16610                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::I64> >::serialize(self.0, serializer)
16611                }
16612            }
16613            state.serialize_entry("metricCosts", &__With(&self.metric_costs))?;
16614        }
16615        if !self._unknown_fields.is_empty() {
16616            for (key, value) in self._unknown_fields.iter() {
16617                state.serialize_entry(key, &value)?;
16618            }
16619        }
16620        state.end()
16621    }
16622}
16623
16624/// `QuotaLimit` defines a specific limit that applies over a specified duration
16625/// for a limit type. There can be at most one limit for a duration and limit
16626/// type combination defined within a `QuotaGroup`.
16627#[derive(Clone, Debug, Default, PartialEq)]
16628#[non_exhaustive]
16629pub struct QuotaLimit {
16630    /// Name of the quota limit.
16631    ///
16632    /// The name must be provided, and it must be unique within the service. The
16633    /// name can only include alphanumeric characters as well as '-'.
16634    ///
16635    /// The maximum length of the limit name is 64 characters.
16636    pub name: std::string::String,
16637
16638    /// Optional. User-visible, extended description for this quota limit.
16639    /// Should be used only when more context is needed to understand this limit
16640    /// than provided by the limit's display name (see: `display_name`).
16641    pub description: std::string::String,
16642
16643    /// Default number of tokens that can be consumed during the specified
16644    /// duration. This is the number of tokens assigned when a client
16645    /// application developer activates the service for his/her project.
16646    ///
16647    /// Specifying a value of 0 will block all requests. This can be used if you
16648    /// are provisioning quota to selected consumers and blocking others.
16649    /// Similarly, a value of -1 will indicate an unlimited quota. No other
16650    /// negative values are allowed.
16651    ///
16652    /// Used by group-based quotas only.
16653    pub default_limit: i64,
16654
16655    /// Maximum number of tokens that can be consumed during the specified
16656    /// duration. Client application developers can override the default limit up
16657    /// to this maximum. If specified, this value cannot be set to a value less
16658    /// than the default limit. If not specified, it is set to the default limit.
16659    ///
16660    /// To allow clients to apply overrides with no upper bound, set this to -1,
16661    /// indicating unlimited maximum quota.
16662    ///
16663    /// Used by group-based quotas only.
16664    pub max_limit: i64,
16665
16666    /// Free tier value displayed in the Developers Console for this limit.
16667    /// The free tier is the number of tokens that will be subtracted from the
16668    /// billed amount when billing is enabled.
16669    /// This field can only be set on a limit with duration "1d", in a billable
16670    /// group; it is invalid on any other limit. If this field is not set, it
16671    /// defaults to 0, indicating that there is no free tier for this service.
16672    ///
16673    /// Used by group-based quotas only.
16674    pub free_tier: i64,
16675
16676    /// Duration of this limit in textual notation. Must be "100s" or "1d".
16677    ///
16678    /// Used by group-based quotas only.
16679    pub duration: std::string::String,
16680
16681    /// The name of the metric this quota limit applies to. The quota limits with
16682    /// the same metric will be checked together during runtime. The metric must be
16683    /// defined within the service config.
16684    pub metric: std::string::String,
16685
16686    /// Specify the unit of the quota limit. It uses the same syntax as
16687    /// [MetricDescriptor.unit][google.api.MetricDescriptor.unit]. The supported
16688    /// unit kinds are determined by the quota backend system.
16689    ///
16690    /// Here are some examples:
16691    ///
16692    /// * "1/min/{project}" for quota per minute per project.
16693    ///
16694    /// Note: the order of unit components is insignificant.
16695    /// The "1" at the beginning is required to follow the metric unit syntax.
16696    ///
16697    /// [google.api.MetricDescriptor.unit]: crate::model::MetricDescriptor::unit
16698    pub unit: std::string::String,
16699
16700    /// Tiered limit values. You must specify this as a key:value pair, with an
16701    /// integer value that is the maximum number of requests allowed for the
16702    /// specified unit. Currently only STANDARD is supported.
16703    pub values: std::collections::HashMap<std::string::String, i64>,
16704
16705    /// User-visible display name for this limit.
16706    /// Optional. If not set, the UI will provide a default display name based on
16707    /// the quota configuration. This field can be used to override the default
16708    /// display name generated from the configuration.
16709    pub display_name: std::string::String,
16710
16711    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16712}
16713
16714impl QuotaLimit {
16715    pub fn new() -> Self {
16716        std::default::Default::default()
16717    }
16718
16719    /// Sets the value of [name][crate::model::QuotaLimit::name].
16720    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16721        self.name = v.into();
16722        self
16723    }
16724
16725    /// Sets the value of [description][crate::model::QuotaLimit::description].
16726    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16727        self.description = v.into();
16728        self
16729    }
16730
16731    /// Sets the value of [default_limit][crate::model::QuotaLimit::default_limit].
16732    pub fn set_default_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
16733        self.default_limit = v.into();
16734        self
16735    }
16736
16737    /// Sets the value of [max_limit][crate::model::QuotaLimit::max_limit].
16738    pub fn set_max_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
16739        self.max_limit = v.into();
16740        self
16741    }
16742
16743    /// Sets the value of [free_tier][crate::model::QuotaLimit::free_tier].
16744    pub fn set_free_tier<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
16745        self.free_tier = v.into();
16746        self
16747    }
16748
16749    /// Sets the value of [duration][crate::model::QuotaLimit::duration].
16750    pub fn set_duration<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16751        self.duration = v.into();
16752        self
16753    }
16754
16755    /// Sets the value of [metric][crate::model::QuotaLimit::metric].
16756    pub fn set_metric<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16757        self.metric = v.into();
16758        self
16759    }
16760
16761    /// Sets the value of [unit][crate::model::QuotaLimit::unit].
16762    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16763        self.unit = v.into();
16764        self
16765    }
16766
16767    /// Sets the value of [values][crate::model::QuotaLimit::values].
16768    pub fn set_values<T, K, V>(mut self, v: T) -> Self
16769    where
16770        T: std::iter::IntoIterator<Item = (K, V)>,
16771        K: std::convert::Into<std::string::String>,
16772        V: std::convert::Into<i64>,
16773    {
16774        use std::iter::Iterator;
16775        self.values = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
16776        self
16777    }
16778
16779    /// Sets the value of [display_name][crate::model::QuotaLimit::display_name].
16780    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16781        self.display_name = v.into();
16782        self
16783    }
16784}
16785
16786impl wkt::message::Message for QuotaLimit {
16787    fn typename() -> &'static str {
16788        "type.googleapis.com/google.api.QuotaLimit"
16789    }
16790}
16791
16792#[doc(hidden)]
16793impl<'de> serde::de::Deserialize<'de> for QuotaLimit {
16794    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16795    where
16796        D: serde::Deserializer<'de>,
16797    {
16798        #[allow(non_camel_case_types)]
16799        #[doc(hidden)]
16800        #[derive(PartialEq, Eq, Hash)]
16801        enum __FieldTag {
16802            __name,
16803            __description,
16804            __default_limit,
16805            __max_limit,
16806            __free_tier,
16807            __duration,
16808            __metric,
16809            __unit,
16810            __values,
16811            __display_name,
16812            Unknown(std::string::String),
16813        }
16814        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16815            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16816            where
16817                D: serde::Deserializer<'de>,
16818            {
16819                struct Visitor;
16820                impl<'de> serde::de::Visitor<'de> for Visitor {
16821                    type Value = __FieldTag;
16822                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16823                        formatter.write_str("a field name for QuotaLimit")
16824                    }
16825                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16826                    where
16827                        E: serde::de::Error,
16828                    {
16829                        use std::result::Result::Ok;
16830                        use std::string::ToString;
16831                        match value {
16832                            "name" => Ok(__FieldTag::__name),
16833                            "description" => Ok(__FieldTag::__description),
16834                            "defaultLimit" => Ok(__FieldTag::__default_limit),
16835                            "default_limit" => Ok(__FieldTag::__default_limit),
16836                            "maxLimit" => Ok(__FieldTag::__max_limit),
16837                            "max_limit" => Ok(__FieldTag::__max_limit),
16838                            "freeTier" => Ok(__FieldTag::__free_tier),
16839                            "free_tier" => Ok(__FieldTag::__free_tier),
16840                            "duration" => Ok(__FieldTag::__duration),
16841                            "metric" => Ok(__FieldTag::__metric),
16842                            "unit" => Ok(__FieldTag::__unit),
16843                            "values" => Ok(__FieldTag::__values),
16844                            "displayName" => Ok(__FieldTag::__display_name),
16845                            "display_name" => Ok(__FieldTag::__display_name),
16846                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16847                        }
16848                    }
16849                }
16850                deserializer.deserialize_identifier(Visitor)
16851            }
16852        }
16853        struct Visitor;
16854        impl<'de> serde::de::Visitor<'de> for Visitor {
16855            type Value = QuotaLimit;
16856            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16857                formatter.write_str("struct QuotaLimit")
16858            }
16859            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16860            where
16861                A: serde::de::MapAccess<'de>,
16862            {
16863                #[allow(unused_imports)]
16864                use serde::de::Error;
16865                use std::option::Option::Some;
16866                let mut fields = std::collections::HashSet::new();
16867                let mut result = Self::Value::new();
16868                while let Some(tag) = map.next_key::<__FieldTag>()? {
16869                    #[allow(clippy::match_single_binding)]
16870                    match tag {
16871                        __FieldTag::__name => {
16872                            if !fields.insert(__FieldTag::__name) {
16873                                return std::result::Result::Err(A::Error::duplicate_field(
16874                                    "multiple values for name",
16875                                ));
16876                            }
16877                            result.name = map
16878                                .next_value::<std::option::Option<std::string::String>>()?
16879                                .unwrap_or_default();
16880                        }
16881                        __FieldTag::__description => {
16882                            if !fields.insert(__FieldTag::__description) {
16883                                return std::result::Result::Err(A::Error::duplicate_field(
16884                                    "multiple values for description",
16885                                ));
16886                            }
16887                            result.description = map
16888                                .next_value::<std::option::Option<std::string::String>>()?
16889                                .unwrap_or_default();
16890                        }
16891                        __FieldTag::__default_limit => {
16892                            if !fields.insert(__FieldTag::__default_limit) {
16893                                return std::result::Result::Err(A::Error::duplicate_field(
16894                                    "multiple values for default_limit",
16895                                ));
16896                            }
16897                            struct __With(std::option::Option<i64>);
16898                            impl<'de> serde::de::Deserialize<'de> for __With {
16899                                fn deserialize<D>(
16900                                    deserializer: D,
16901                                ) -> std::result::Result<Self, D::Error>
16902                                where
16903                                    D: serde::de::Deserializer<'de>,
16904                                {
16905                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
16906                                }
16907                            }
16908                            result.default_limit =
16909                                map.next_value::<__With>()?.0.unwrap_or_default();
16910                        }
16911                        __FieldTag::__max_limit => {
16912                            if !fields.insert(__FieldTag::__max_limit) {
16913                                return std::result::Result::Err(A::Error::duplicate_field(
16914                                    "multiple values for max_limit",
16915                                ));
16916                            }
16917                            struct __With(std::option::Option<i64>);
16918                            impl<'de> serde::de::Deserialize<'de> for __With {
16919                                fn deserialize<D>(
16920                                    deserializer: D,
16921                                ) -> std::result::Result<Self, D::Error>
16922                                where
16923                                    D: serde::de::Deserializer<'de>,
16924                                {
16925                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
16926                                }
16927                            }
16928                            result.max_limit = map.next_value::<__With>()?.0.unwrap_or_default();
16929                        }
16930                        __FieldTag::__free_tier => {
16931                            if !fields.insert(__FieldTag::__free_tier) {
16932                                return std::result::Result::Err(A::Error::duplicate_field(
16933                                    "multiple values for free_tier",
16934                                ));
16935                            }
16936                            struct __With(std::option::Option<i64>);
16937                            impl<'de> serde::de::Deserialize<'de> for __With {
16938                                fn deserialize<D>(
16939                                    deserializer: D,
16940                                ) -> std::result::Result<Self, D::Error>
16941                                where
16942                                    D: serde::de::Deserializer<'de>,
16943                                {
16944                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
16945                                }
16946                            }
16947                            result.free_tier = map.next_value::<__With>()?.0.unwrap_or_default();
16948                        }
16949                        __FieldTag::__duration => {
16950                            if !fields.insert(__FieldTag::__duration) {
16951                                return std::result::Result::Err(A::Error::duplicate_field(
16952                                    "multiple values for duration",
16953                                ));
16954                            }
16955                            result.duration = map
16956                                .next_value::<std::option::Option<std::string::String>>()?
16957                                .unwrap_or_default();
16958                        }
16959                        __FieldTag::__metric => {
16960                            if !fields.insert(__FieldTag::__metric) {
16961                                return std::result::Result::Err(A::Error::duplicate_field(
16962                                    "multiple values for metric",
16963                                ));
16964                            }
16965                            result.metric = map
16966                                .next_value::<std::option::Option<std::string::String>>()?
16967                                .unwrap_or_default();
16968                        }
16969                        __FieldTag::__unit => {
16970                            if !fields.insert(__FieldTag::__unit) {
16971                                return std::result::Result::Err(A::Error::duplicate_field(
16972                                    "multiple values for unit",
16973                                ));
16974                            }
16975                            result.unit = map
16976                                .next_value::<std::option::Option<std::string::String>>()?
16977                                .unwrap_or_default();
16978                        }
16979                        __FieldTag::__values => {
16980                            if !fields.insert(__FieldTag::__values) {
16981                                return std::result::Result::Err(A::Error::duplicate_field(
16982                                    "multiple values for values",
16983                                ));
16984                            }
16985                            struct __With(
16986                                std::option::Option<
16987                                    std::collections::HashMap<std::string::String, i64>,
16988                                >,
16989                            );
16990                            impl<'de> serde::de::Deserialize<'de> for __With {
16991                                fn deserialize<D>(
16992                                    deserializer: D,
16993                                ) -> std::result::Result<Self, D::Error>
16994                                where
16995                                    D: serde::de::Deserializer<'de>,
16996                                {
16997                                    serde_with::As::<
16998                                        std::option::Option<
16999                                            std::collections::HashMap<
17000                                                serde_with::Same,
17001                                                wkt::internal::I64,
17002                                            >,
17003                                        >,
17004                                    >::deserialize(deserializer)
17005                                    .map(__With)
17006                                }
17007                            }
17008                            result.values = map.next_value::<__With>()?.0.unwrap_or_default();
17009                        }
17010                        __FieldTag::__display_name => {
17011                            if !fields.insert(__FieldTag::__display_name) {
17012                                return std::result::Result::Err(A::Error::duplicate_field(
17013                                    "multiple values for display_name",
17014                                ));
17015                            }
17016                            result.display_name = map
17017                                .next_value::<std::option::Option<std::string::String>>()?
17018                                .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 QuotaLimit {
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.name.is_empty() {
17044            state.serialize_entry("name", &self.name)?;
17045        }
17046        if !self.description.is_empty() {
17047            state.serialize_entry("description", &self.description)?;
17048        }
17049        if !wkt::internal::is_default(&self.default_limit) {
17050            struct __With<'a>(&'a i64);
17051            impl<'a> serde::ser::Serialize for __With<'a> {
17052                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17053                where
17054                    S: serde::ser::Serializer,
17055                {
17056                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17057                }
17058            }
17059            state.serialize_entry("defaultLimit", &__With(&self.default_limit))?;
17060        }
17061        if !wkt::internal::is_default(&self.max_limit) {
17062            struct __With<'a>(&'a i64);
17063            impl<'a> serde::ser::Serialize for __With<'a> {
17064                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17065                where
17066                    S: serde::ser::Serializer,
17067                {
17068                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17069                }
17070            }
17071            state.serialize_entry("maxLimit", &__With(&self.max_limit))?;
17072        }
17073        if !wkt::internal::is_default(&self.free_tier) {
17074            struct __With<'a>(&'a i64);
17075            impl<'a> serde::ser::Serialize for __With<'a> {
17076                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17077                where
17078                    S: serde::ser::Serializer,
17079                {
17080                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
17081                }
17082            }
17083            state.serialize_entry("freeTier", &__With(&self.free_tier))?;
17084        }
17085        if !self.duration.is_empty() {
17086            state.serialize_entry("duration", &self.duration)?;
17087        }
17088        if !self.metric.is_empty() {
17089            state.serialize_entry("metric", &self.metric)?;
17090        }
17091        if !self.unit.is_empty() {
17092            state.serialize_entry("unit", &self.unit)?;
17093        }
17094        if !self.values.is_empty() {
17095            struct __With<'a>(&'a std::collections::HashMap<std::string::String, i64>);
17096            impl<'a> serde::ser::Serialize for __With<'a> {
17097                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17098                where
17099                    S: serde::ser::Serializer,
17100                {
17101                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::I64> >::serialize(self.0, serializer)
17102                }
17103            }
17104            state.serialize_entry("values", &__With(&self.values))?;
17105        }
17106        if !self.display_name.is_empty() {
17107            state.serialize_entry("displayName", &self.display_name)?;
17108        }
17109        if !self._unknown_fields.is_empty() {
17110            for (key, value) in self._unknown_fields.iter() {
17111                state.serialize_entry(key, &value)?;
17112            }
17113        }
17114        state.end()
17115    }
17116}
17117
17118/// A simple descriptor of a resource type.
17119///
17120/// ResourceDescriptor annotates a resource message (either by means of a
17121/// protobuf annotation or use in the service config), and associates the
17122/// resource's schema, the resource type, and the pattern of the resource name.
17123///
17124/// Example:
17125///
17126/// ```norust
17127/// message Topic {
17128///   // Indicates this message defines a resource schema.
17129///   // Declares the resource type in the format of {service}/{kind}.
17130///   // For Kubernetes resources, the format is {api group}/{kind}.
17131///   option (google.api.resource) = {
17132///     type: "pubsub.googleapis.com/Topic"
17133///     pattern: "projects/{project}/topics/{topic}"
17134///   };
17135/// }
17136/// ```
17137///
17138/// The ResourceDescriptor Yaml config will look like:
17139///
17140/// ```norust
17141/// resources:
17142/// - type: "pubsub.googleapis.com/Topic"
17143///   pattern: "projects/{project}/topics/{topic}"
17144/// ```
17145///
17146/// Sometimes, resources have multiple patterns, typically because they can
17147/// live under multiple parents.
17148///
17149/// Example:
17150///
17151/// ```norust
17152/// message LogEntry {
17153///   option (google.api.resource) = {
17154///     type: "logging.googleapis.com/LogEntry"
17155///     pattern: "projects/{project}/logs/{log}"
17156///     pattern: "folders/{folder}/logs/{log}"
17157///     pattern: "organizations/{organization}/logs/{log}"
17158///     pattern: "billingAccounts/{billing_account}/logs/{log}"
17159///   };
17160/// }
17161/// ```
17162///
17163/// The ResourceDescriptor Yaml config will look like:
17164///
17165/// ```norust
17166/// resources:
17167/// - type: 'logging.googleapis.com/LogEntry'
17168///   pattern: "projects/{project}/logs/{log}"
17169///   pattern: "folders/{folder}/logs/{log}"
17170///   pattern: "organizations/{organization}/logs/{log}"
17171///   pattern: "billingAccounts/{billing_account}/logs/{log}"
17172/// ```
17173#[derive(Clone, Debug, Default, PartialEq)]
17174#[non_exhaustive]
17175pub struct ResourceDescriptor {
17176    /// The resource type. It must be in the format of
17177    /// {service_name}/{resource_type_kind}. The `resource_type_kind` must be
17178    /// singular and must not include version numbers.
17179    ///
17180    /// Example: `storage.googleapis.com/Bucket`
17181    ///
17182    /// The value of the resource_type_kind must follow the regular expression
17183    /// /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
17184    /// should use PascalCase (UpperCamelCase). The maximum number of
17185    /// characters allowed for the `resource_type_kind` is 100.
17186    pub r#type: std::string::String,
17187
17188    /// Optional. The relative resource name pattern associated with this resource
17189    /// type. The DNS prefix of the full resource name shouldn't be specified here.
17190    ///
17191    /// The path pattern must follow the syntax, which aligns with HTTP binding
17192    /// syntax:
17193    ///
17194    /// ```norust
17195    /// Template = Segment { "/" Segment } ;
17196    /// Segment = LITERAL | Variable ;
17197    /// Variable = "{" LITERAL "}" ;
17198    /// ```
17199    ///
17200    /// Examples:
17201    ///
17202    /// ```norust
17203    /// - "projects/{project}/topics/{topic}"
17204    /// - "projects/{project}/knowledgeBases/{knowledge_base}"
17205    /// ```
17206    ///
17207    /// The components in braces correspond to the IDs for each resource in the
17208    /// hierarchy. It is expected that, if multiple patterns are provided,
17209    /// the same component name (e.g. "project") refers to IDs of the same
17210    /// type of resource.
17211    pub pattern: std::vec::Vec<std::string::String>,
17212
17213    /// Optional. The field on the resource that designates the resource name
17214    /// field. If omitted, this is assumed to be "name".
17215    pub name_field: std::string::String,
17216
17217    /// Optional. The historical or future-looking state of the resource pattern.
17218    ///
17219    /// Example:
17220    ///
17221    /// ```norust
17222    /// // The InspectTemplate message originally only supported resource
17223    /// // names with organization, and project was added later.
17224    /// message InspectTemplate {
17225    ///   option (google.api.resource) = {
17226    ///     type: "dlp.googleapis.com/InspectTemplate"
17227    ///     pattern:
17228    ///     "organizations/{organization}/inspectTemplates/{inspect_template}"
17229    ///     pattern: "projects/{project}/inspectTemplates/{inspect_template}"
17230    ///     history: ORIGINALLY_SINGLE_PATTERN
17231    ///   };
17232    /// }
17233    /// ```
17234    pub history: crate::model::resource_descriptor::History,
17235
17236    /// The plural name used in the resource name and permission names, such as
17237    /// 'projects' for the resource name of 'projects/{project}' and the permission
17238    /// name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception
17239    /// to this is for Nested Collections that have stuttering names, as defined
17240    /// in [AIP-122](https://google.aip.dev/122#nested-collections), where the
17241    /// collection ID in the resource name pattern does not necessarily directly
17242    /// match the `plural` value.
17243    ///
17244    /// It is the same concept of the `plural` field in k8s CRD spec
17245    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
17246    ///
17247    /// Note: The plural form is required even for singleton resources. See
17248    /// <https://aip.dev/156>
17249    pub plural: std::string::String,
17250
17251    /// The same concept of the `singular` field in k8s CRD spec
17252    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
17253    /// Such as "project" for the `resourcemanager.googleapis.com/Project` type.
17254    pub singular: std::string::String,
17255
17256    /// Style flag(s) for this resource.
17257    /// These indicate that a resource is expected to conform to a given
17258    /// style. See the specific style flags for additional information.
17259    pub style: std::vec::Vec<crate::model::resource_descriptor::Style>,
17260
17261    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17262}
17263
17264impl ResourceDescriptor {
17265    pub fn new() -> Self {
17266        std::default::Default::default()
17267    }
17268
17269    /// Sets the value of [r#type][crate::model::ResourceDescriptor::type].
17270    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17271        self.r#type = v.into();
17272        self
17273    }
17274
17275    /// Sets the value of [pattern][crate::model::ResourceDescriptor::pattern].
17276    pub fn set_pattern<T, V>(mut self, v: T) -> Self
17277    where
17278        T: std::iter::IntoIterator<Item = V>,
17279        V: std::convert::Into<std::string::String>,
17280    {
17281        use std::iter::Iterator;
17282        self.pattern = v.into_iter().map(|i| i.into()).collect();
17283        self
17284    }
17285
17286    /// Sets the value of [name_field][crate::model::ResourceDescriptor::name_field].
17287    pub fn set_name_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17288        self.name_field = v.into();
17289        self
17290    }
17291
17292    /// Sets the value of [history][crate::model::ResourceDescriptor::history].
17293    pub fn set_history<T: std::convert::Into<crate::model::resource_descriptor::History>>(
17294        mut self,
17295        v: T,
17296    ) -> Self {
17297        self.history = v.into();
17298        self
17299    }
17300
17301    /// Sets the value of [plural][crate::model::ResourceDescriptor::plural].
17302    pub fn set_plural<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17303        self.plural = v.into();
17304        self
17305    }
17306
17307    /// Sets the value of [singular][crate::model::ResourceDescriptor::singular].
17308    pub fn set_singular<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17309        self.singular = v.into();
17310        self
17311    }
17312
17313    /// Sets the value of [style][crate::model::ResourceDescriptor::style].
17314    pub fn set_style<T, V>(mut self, v: T) -> Self
17315    where
17316        T: std::iter::IntoIterator<Item = V>,
17317        V: std::convert::Into<crate::model::resource_descriptor::Style>,
17318    {
17319        use std::iter::Iterator;
17320        self.style = v.into_iter().map(|i| i.into()).collect();
17321        self
17322    }
17323}
17324
17325impl wkt::message::Message for ResourceDescriptor {
17326    fn typename() -> &'static str {
17327        "type.googleapis.com/google.api.ResourceDescriptor"
17328    }
17329}
17330
17331#[doc(hidden)]
17332impl<'de> serde::de::Deserialize<'de> for ResourceDescriptor {
17333    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17334    where
17335        D: serde::Deserializer<'de>,
17336    {
17337        #[allow(non_camel_case_types)]
17338        #[doc(hidden)]
17339        #[derive(PartialEq, Eq, Hash)]
17340        enum __FieldTag {
17341            __type,
17342            __pattern,
17343            __name_field,
17344            __history,
17345            __plural,
17346            __singular,
17347            __style,
17348            Unknown(std::string::String),
17349        }
17350        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17351            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17352            where
17353                D: serde::Deserializer<'de>,
17354            {
17355                struct Visitor;
17356                impl<'de> serde::de::Visitor<'de> for Visitor {
17357                    type Value = __FieldTag;
17358                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17359                        formatter.write_str("a field name for ResourceDescriptor")
17360                    }
17361                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17362                    where
17363                        E: serde::de::Error,
17364                    {
17365                        use std::result::Result::Ok;
17366                        use std::string::ToString;
17367                        match value {
17368                            "type" => Ok(__FieldTag::__type),
17369                            "pattern" => Ok(__FieldTag::__pattern),
17370                            "nameField" => Ok(__FieldTag::__name_field),
17371                            "name_field" => Ok(__FieldTag::__name_field),
17372                            "history" => Ok(__FieldTag::__history),
17373                            "plural" => Ok(__FieldTag::__plural),
17374                            "singular" => Ok(__FieldTag::__singular),
17375                            "style" => Ok(__FieldTag::__style),
17376                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17377                        }
17378                    }
17379                }
17380                deserializer.deserialize_identifier(Visitor)
17381            }
17382        }
17383        struct Visitor;
17384        impl<'de> serde::de::Visitor<'de> for Visitor {
17385            type Value = ResourceDescriptor;
17386            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17387                formatter.write_str("struct ResourceDescriptor")
17388            }
17389            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17390            where
17391                A: serde::de::MapAccess<'de>,
17392            {
17393                #[allow(unused_imports)]
17394                use serde::de::Error;
17395                use std::option::Option::Some;
17396                let mut fields = std::collections::HashSet::new();
17397                let mut result = Self::Value::new();
17398                while let Some(tag) = map.next_key::<__FieldTag>()? {
17399                    #[allow(clippy::match_single_binding)]
17400                    match tag {
17401                        __FieldTag::__type => {
17402                            if !fields.insert(__FieldTag::__type) {
17403                                return std::result::Result::Err(A::Error::duplicate_field(
17404                                    "multiple values for type",
17405                                ));
17406                            }
17407                            result.r#type = map
17408                                .next_value::<std::option::Option<std::string::String>>()?
17409                                .unwrap_or_default();
17410                        }
17411                        __FieldTag::__pattern => {
17412                            if !fields.insert(__FieldTag::__pattern) {
17413                                return std::result::Result::Err(A::Error::duplicate_field(
17414                                    "multiple values for pattern",
17415                                ));
17416                            }
17417                            result.pattern = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
17418                        }
17419                        __FieldTag::__name_field => {
17420                            if !fields.insert(__FieldTag::__name_field) {
17421                                return std::result::Result::Err(A::Error::duplicate_field(
17422                                    "multiple values for name_field",
17423                                ));
17424                            }
17425                            result.name_field = map
17426                                .next_value::<std::option::Option<std::string::String>>()?
17427                                .unwrap_or_default();
17428                        }
17429                        __FieldTag::__history => {
17430                            if !fields.insert(__FieldTag::__history) {
17431                                return std::result::Result::Err(A::Error::duplicate_field(
17432                                    "multiple values for history",
17433                                ));
17434                            }
17435                            result.history = map.next_value::<std::option::Option<crate::model::resource_descriptor::History>>()?.unwrap_or_default();
17436                        }
17437                        __FieldTag::__plural => {
17438                            if !fields.insert(__FieldTag::__plural) {
17439                                return std::result::Result::Err(A::Error::duplicate_field(
17440                                    "multiple values for plural",
17441                                ));
17442                            }
17443                            result.plural = map
17444                                .next_value::<std::option::Option<std::string::String>>()?
17445                                .unwrap_or_default();
17446                        }
17447                        __FieldTag::__singular => {
17448                            if !fields.insert(__FieldTag::__singular) {
17449                                return std::result::Result::Err(A::Error::duplicate_field(
17450                                    "multiple values for singular",
17451                                ));
17452                            }
17453                            result.singular = map
17454                                .next_value::<std::option::Option<std::string::String>>()?
17455                                .unwrap_or_default();
17456                        }
17457                        __FieldTag::__style => {
17458                            if !fields.insert(__FieldTag::__style) {
17459                                return std::result::Result::Err(A::Error::duplicate_field(
17460                                    "multiple values for style",
17461                                ));
17462                            }
17463                            result.style = map
17464                                .next_value::<std::option::Option<
17465                                    std::vec::Vec<crate::model::resource_descriptor::Style>,
17466                                >>()?
17467                                .unwrap_or_default();
17468                        }
17469                        __FieldTag::Unknown(key) => {
17470                            let value = map.next_value::<serde_json::Value>()?;
17471                            result._unknown_fields.insert(key, value);
17472                        }
17473                    }
17474                }
17475                std::result::Result::Ok(result)
17476            }
17477        }
17478        deserializer.deserialize_any(Visitor)
17479    }
17480}
17481
17482#[doc(hidden)]
17483impl serde::ser::Serialize for ResourceDescriptor {
17484    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17485    where
17486        S: serde::ser::Serializer,
17487    {
17488        use serde::ser::SerializeMap;
17489        #[allow(unused_imports)]
17490        use std::option::Option::Some;
17491        let mut state = serializer.serialize_map(std::option::Option::None)?;
17492        if !self.r#type.is_empty() {
17493            state.serialize_entry("type", &self.r#type)?;
17494        }
17495        if !self.pattern.is_empty() {
17496            state.serialize_entry("pattern", &self.pattern)?;
17497        }
17498        if !self.name_field.is_empty() {
17499            state.serialize_entry("nameField", &self.name_field)?;
17500        }
17501        if !wkt::internal::is_default(&self.history) {
17502            state.serialize_entry("history", &self.history)?;
17503        }
17504        if !self.plural.is_empty() {
17505            state.serialize_entry("plural", &self.plural)?;
17506        }
17507        if !self.singular.is_empty() {
17508            state.serialize_entry("singular", &self.singular)?;
17509        }
17510        if !self.style.is_empty() {
17511            state.serialize_entry("style", &self.style)?;
17512        }
17513        if !self._unknown_fields.is_empty() {
17514            for (key, value) in self._unknown_fields.iter() {
17515                state.serialize_entry(key, &value)?;
17516            }
17517        }
17518        state.end()
17519    }
17520}
17521
17522/// Defines additional types related to [ResourceDescriptor].
17523pub mod resource_descriptor {
17524    #[allow(unused_imports)]
17525    use super::*;
17526
17527    /// A description of the historical or future-looking state of the
17528    /// resource pattern.
17529    ///
17530    /// # Working with unknown values
17531    ///
17532    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
17533    /// additional enum variants at any time. Adding new variants is not considered
17534    /// a breaking change. Applications should write their code in anticipation of:
17535    ///
17536    /// - New values appearing in future releases of the client library, **and**
17537    /// - New values received dynamically, without application changes.
17538    ///
17539    /// Please consult the [Working with enums] section in the user guide for some
17540    /// guidelines.
17541    ///
17542    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
17543    #[derive(Clone, Debug, PartialEq)]
17544    #[non_exhaustive]
17545    pub enum History {
17546        /// The "unset" value.
17547        Unspecified,
17548        /// The resource originally had one pattern and launched as such, and
17549        /// additional patterns were added later.
17550        OriginallySinglePattern,
17551        /// The resource has one pattern, but the API owner expects to add more
17552        /// later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents
17553        /// that from being necessary once there are multiple patterns.)
17554        FutureMultiPattern,
17555        /// If set, the enum was initialized with an unknown value.
17556        ///
17557        /// Applications can examine the value using [History::value] or
17558        /// [History::name].
17559        UnknownValue(history::UnknownValue),
17560    }
17561
17562    #[doc(hidden)]
17563    pub mod history {
17564        #[allow(unused_imports)]
17565        use super::*;
17566        #[derive(Clone, Debug, PartialEq)]
17567        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
17568    }
17569
17570    impl History {
17571        /// Gets the enum value.
17572        ///
17573        /// Returns `None` if the enum contains an unknown value deserialized from
17574        /// the string representation of enums.
17575        pub fn value(&self) -> std::option::Option<i32> {
17576            match self {
17577                Self::Unspecified => std::option::Option::Some(0),
17578                Self::OriginallySinglePattern => std::option::Option::Some(1),
17579                Self::FutureMultiPattern => std::option::Option::Some(2),
17580                Self::UnknownValue(u) => u.0.value(),
17581            }
17582        }
17583
17584        /// Gets the enum value as a string.
17585        ///
17586        /// Returns `None` if the enum contains an unknown value deserialized from
17587        /// the integer representation of enums.
17588        pub fn name(&self) -> std::option::Option<&str> {
17589            match self {
17590                Self::Unspecified => std::option::Option::Some("HISTORY_UNSPECIFIED"),
17591                Self::OriginallySinglePattern => {
17592                    std::option::Option::Some("ORIGINALLY_SINGLE_PATTERN")
17593                }
17594                Self::FutureMultiPattern => std::option::Option::Some("FUTURE_MULTI_PATTERN"),
17595                Self::UnknownValue(u) => u.0.name(),
17596            }
17597        }
17598    }
17599
17600    impl std::default::Default for History {
17601        fn default() -> Self {
17602            use std::convert::From;
17603            Self::from(0)
17604        }
17605    }
17606
17607    impl std::fmt::Display for History {
17608        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
17609            wkt::internal::display_enum(f, self.name(), self.value())
17610        }
17611    }
17612
17613    impl std::convert::From<i32> for History {
17614        fn from(value: i32) -> Self {
17615            match value {
17616                0 => Self::Unspecified,
17617                1 => Self::OriginallySinglePattern,
17618                2 => Self::FutureMultiPattern,
17619                _ => Self::UnknownValue(history::UnknownValue(
17620                    wkt::internal::UnknownEnumValue::Integer(value),
17621                )),
17622            }
17623        }
17624    }
17625
17626    impl std::convert::From<&str> for History {
17627        fn from(value: &str) -> Self {
17628            use std::string::ToString;
17629            match value {
17630                "HISTORY_UNSPECIFIED" => Self::Unspecified,
17631                "ORIGINALLY_SINGLE_PATTERN" => Self::OriginallySinglePattern,
17632                "FUTURE_MULTI_PATTERN" => Self::FutureMultiPattern,
17633                _ => Self::UnknownValue(history::UnknownValue(
17634                    wkt::internal::UnknownEnumValue::String(value.to_string()),
17635                )),
17636            }
17637        }
17638    }
17639
17640    impl serde::ser::Serialize for History {
17641        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17642        where
17643            S: serde::Serializer,
17644        {
17645            match self {
17646                Self::Unspecified => serializer.serialize_i32(0),
17647                Self::OriginallySinglePattern => serializer.serialize_i32(1),
17648                Self::FutureMultiPattern => serializer.serialize_i32(2),
17649                Self::UnknownValue(u) => u.0.serialize(serializer),
17650            }
17651        }
17652    }
17653
17654    impl<'de> serde::de::Deserialize<'de> for History {
17655        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17656        where
17657            D: serde::Deserializer<'de>,
17658        {
17659            deserializer.deserialize_any(wkt::internal::EnumVisitor::<History>::new(
17660                ".google.api.ResourceDescriptor.History",
17661            ))
17662        }
17663    }
17664
17665    /// A flag representing a specific style that a resource claims to conform to.
17666    ///
17667    /// # Working with unknown values
17668    ///
17669    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
17670    /// additional enum variants at any time. Adding new variants is not considered
17671    /// a breaking change. Applications should write their code in anticipation of:
17672    ///
17673    /// - New values appearing in future releases of the client library, **and**
17674    /// - New values received dynamically, without application changes.
17675    ///
17676    /// Please consult the [Working with enums] section in the user guide for some
17677    /// guidelines.
17678    ///
17679    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
17680    #[derive(Clone, Debug, PartialEq)]
17681    #[non_exhaustive]
17682    pub enum Style {
17683        /// The unspecified value. Do not use.
17684        Unspecified,
17685        /// This resource is intended to be "declarative-friendly".
17686        ///
17687        /// Declarative-friendly resources must be more strictly consistent, and
17688        /// setting this to true communicates to tools that this resource should
17689        /// adhere to declarative-friendly expectations.
17690        ///
17691        /// Note: This is used by the API linter (linter.aip.dev) to enable
17692        /// additional checks.
17693        DeclarativeFriendly,
17694        /// If set, the enum was initialized with an unknown value.
17695        ///
17696        /// Applications can examine the value using [Style::value] or
17697        /// [Style::name].
17698        UnknownValue(style::UnknownValue),
17699    }
17700
17701    #[doc(hidden)]
17702    pub mod style {
17703        #[allow(unused_imports)]
17704        use super::*;
17705        #[derive(Clone, Debug, PartialEq)]
17706        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
17707    }
17708
17709    impl Style {
17710        /// Gets the enum value.
17711        ///
17712        /// Returns `None` if the enum contains an unknown value deserialized from
17713        /// the string representation of enums.
17714        pub fn value(&self) -> std::option::Option<i32> {
17715            match self {
17716                Self::Unspecified => std::option::Option::Some(0),
17717                Self::DeclarativeFriendly => std::option::Option::Some(1),
17718                Self::UnknownValue(u) => u.0.value(),
17719            }
17720        }
17721
17722        /// Gets the enum value as a string.
17723        ///
17724        /// Returns `None` if the enum contains an unknown value deserialized from
17725        /// the integer representation of enums.
17726        pub fn name(&self) -> std::option::Option<&str> {
17727            match self {
17728                Self::Unspecified => std::option::Option::Some("STYLE_UNSPECIFIED"),
17729                Self::DeclarativeFriendly => std::option::Option::Some("DECLARATIVE_FRIENDLY"),
17730                Self::UnknownValue(u) => u.0.name(),
17731            }
17732        }
17733    }
17734
17735    impl std::default::Default for Style {
17736        fn default() -> Self {
17737            use std::convert::From;
17738            Self::from(0)
17739        }
17740    }
17741
17742    impl std::fmt::Display for Style {
17743        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
17744            wkt::internal::display_enum(f, self.name(), self.value())
17745        }
17746    }
17747
17748    impl std::convert::From<i32> for Style {
17749        fn from(value: i32) -> Self {
17750            match value {
17751                0 => Self::Unspecified,
17752                1 => Self::DeclarativeFriendly,
17753                _ => Self::UnknownValue(style::UnknownValue(
17754                    wkt::internal::UnknownEnumValue::Integer(value),
17755                )),
17756            }
17757        }
17758    }
17759
17760    impl std::convert::From<&str> for Style {
17761        fn from(value: &str) -> Self {
17762            use std::string::ToString;
17763            match value {
17764                "STYLE_UNSPECIFIED" => Self::Unspecified,
17765                "DECLARATIVE_FRIENDLY" => Self::DeclarativeFriendly,
17766                _ => Self::UnknownValue(style::UnknownValue(
17767                    wkt::internal::UnknownEnumValue::String(value.to_string()),
17768                )),
17769            }
17770        }
17771    }
17772
17773    impl serde::ser::Serialize for Style {
17774        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17775        where
17776            S: serde::Serializer,
17777        {
17778            match self {
17779                Self::Unspecified => serializer.serialize_i32(0),
17780                Self::DeclarativeFriendly => serializer.serialize_i32(1),
17781                Self::UnknownValue(u) => u.0.serialize(serializer),
17782            }
17783        }
17784    }
17785
17786    impl<'de> serde::de::Deserialize<'de> for Style {
17787        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17788        where
17789            D: serde::Deserializer<'de>,
17790        {
17791            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Style>::new(
17792                ".google.api.ResourceDescriptor.Style",
17793            ))
17794        }
17795    }
17796}
17797
17798/// Defines a proto annotation that describes a string field that refers to
17799/// an API resource.
17800#[derive(Clone, Debug, Default, PartialEq)]
17801#[non_exhaustive]
17802pub struct ResourceReference {
17803    /// The resource type that the annotated field references.
17804    ///
17805    /// Example:
17806    ///
17807    /// ```norust
17808    /// message Subscription {
17809    ///   string topic = 2 [(google.api.resource_reference) = {
17810    ///     type: "pubsub.googleapis.com/Topic"
17811    ///   }];
17812    /// }
17813    /// ```
17814    ///
17815    /// Occasionally, a field may reference an arbitrary resource. In this case,
17816    /// APIs use the special value * in their resource reference.
17817    ///
17818    /// Example:
17819    ///
17820    /// ```norust
17821    /// message GetIamPolicyRequest {
17822    ///   string resource = 2 [(google.api.resource_reference) = {
17823    ///     type: "*"
17824    ///   }];
17825    /// }
17826    /// ```
17827    pub r#type: std::string::String,
17828
17829    /// The resource type of a child collection that the annotated field
17830    /// references. This is useful for annotating the `parent` field that
17831    /// doesn't have a fixed resource type.
17832    ///
17833    /// Example:
17834    ///
17835    /// ```norust
17836    /// message ListLogEntriesRequest {
17837    ///   string parent = 1 [(google.api.resource_reference) = {
17838    ///     child_type: "logging.googleapis.com/LogEntry"
17839    ///   };
17840    /// }
17841    /// ```
17842    pub child_type: std::string::String,
17843
17844    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17845}
17846
17847impl ResourceReference {
17848    pub fn new() -> Self {
17849        std::default::Default::default()
17850    }
17851
17852    /// Sets the value of [r#type][crate::model::ResourceReference::type].
17853    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17854        self.r#type = v.into();
17855        self
17856    }
17857
17858    /// Sets the value of [child_type][crate::model::ResourceReference::child_type].
17859    pub fn set_child_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17860        self.child_type = v.into();
17861        self
17862    }
17863}
17864
17865impl wkt::message::Message for ResourceReference {
17866    fn typename() -> &'static str {
17867        "type.googleapis.com/google.api.ResourceReference"
17868    }
17869}
17870
17871#[doc(hidden)]
17872impl<'de> serde::de::Deserialize<'de> for ResourceReference {
17873    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17874    where
17875        D: serde::Deserializer<'de>,
17876    {
17877        #[allow(non_camel_case_types)]
17878        #[doc(hidden)]
17879        #[derive(PartialEq, Eq, Hash)]
17880        enum __FieldTag {
17881            __type,
17882            __child_type,
17883            Unknown(std::string::String),
17884        }
17885        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17886            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17887            where
17888                D: serde::Deserializer<'de>,
17889            {
17890                struct Visitor;
17891                impl<'de> serde::de::Visitor<'de> for Visitor {
17892                    type Value = __FieldTag;
17893                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17894                        formatter.write_str("a field name for ResourceReference")
17895                    }
17896                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17897                    where
17898                        E: serde::de::Error,
17899                    {
17900                        use std::result::Result::Ok;
17901                        use std::string::ToString;
17902                        match value {
17903                            "type" => Ok(__FieldTag::__type),
17904                            "childType" => Ok(__FieldTag::__child_type),
17905                            "child_type" => Ok(__FieldTag::__child_type),
17906                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17907                        }
17908                    }
17909                }
17910                deserializer.deserialize_identifier(Visitor)
17911            }
17912        }
17913        struct Visitor;
17914        impl<'de> serde::de::Visitor<'de> for Visitor {
17915            type Value = ResourceReference;
17916            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17917                formatter.write_str("struct ResourceReference")
17918            }
17919            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17920            where
17921                A: serde::de::MapAccess<'de>,
17922            {
17923                #[allow(unused_imports)]
17924                use serde::de::Error;
17925                use std::option::Option::Some;
17926                let mut fields = std::collections::HashSet::new();
17927                let mut result = Self::Value::new();
17928                while let Some(tag) = map.next_key::<__FieldTag>()? {
17929                    #[allow(clippy::match_single_binding)]
17930                    match tag {
17931                        __FieldTag::__type => {
17932                            if !fields.insert(__FieldTag::__type) {
17933                                return std::result::Result::Err(A::Error::duplicate_field(
17934                                    "multiple values for type",
17935                                ));
17936                            }
17937                            result.r#type = map
17938                                .next_value::<std::option::Option<std::string::String>>()?
17939                                .unwrap_or_default();
17940                        }
17941                        __FieldTag::__child_type => {
17942                            if !fields.insert(__FieldTag::__child_type) {
17943                                return std::result::Result::Err(A::Error::duplicate_field(
17944                                    "multiple values for child_type",
17945                                ));
17946                            }
17947                            result.child_type = map
17948                                .next_value::<std::option::Option<std::string::String>>()?
17949                                .unwrap_or_default();
17950                        }
17951                        __FieldTag::Unknown(key) => {
17952                            let value = map.next_value::<serde_json::Value>()?;
17953                            result._unknown_fields.insert(key, value);
17954                        }
17955                    }
17956                }
17957                std::result::Result::Ok(result)
17958            }
17959        }
17960        deserializer.deserialize_any(Visitor)
17961    }
17962}
17963
17964#[doc(hidden)]
17965impl serde::ser::Serialize for ResourceReference {
17966    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17967    where
17968        S: serde::ser::Serializer,
17969    {
17970        use serde::ser::SerializeMap;
17971        #[allow(unused_imports)]
17972        use std::option::Option::Some;
17973        let mut state = serializer.serialize_map(std::option::Option::None)?;
17974        if !self.r#type.is_empty() {
17975            state.serialize_entry("type", &self.r#type)?;
17976        }
17977        if !self.child_type.is_empty() {
17978            state.serialize_entry("childType", &self.child_type)?;
17979        }
17980        if !self._unknown_fields.is_empty() {
17981            for (key, value) in self._unknown_fields.iter() {
17982                state.serialize_entry(key, &value)?;
17983            }
17984        }
17985        state.end()
17986    }
17987}
17988
17989/// Specifies the routing information that should be sent along with the request
17990/// in the form of routing header.
17991/// **NOTE:** All service configuration rules follow the "last one wins" order.
17992///
17993/// The examples below will apply to an RPC which has the following request type:
17994///
17995/// Message Definition:
17996///
17997/// ```norust
17998/// message Request {
17999///   // The name of the Table
18000///   // Values can be of the following formats:
18001///   // - `projects/<project>/tables/<table>`
18002///   // - `projects/<project>/instances/<instance>/tables/<table>`
18003///   // - `region/<region>/zones/<zone>/tables/<table>`
18004///   string table_name = 1;
18005///
18006///   // This value specifies routing for replication.
18007///   // It can be in the following formats:
18008///   // - `profiles/<profile_id>`
18009///   // - a legacy `profile_id` that can be any string
18010///   string app_profile_id = 2;
18011/// }
18012/// ```
18013///
18014/// Example message:
18015///
18016/// ```norust
18017/// {
18018///   table_name: projects/proj_foo/instances/instance_bar/table/table_baz,
18019///   app_profile_id: profiles/prof_qux
18020/// }
18021/// ```
18022///
18023/// The routing header consists of one or multiple key-value pairs. Every key
18024/// and value must be percent-encoded, and joined together in the format of
18025/// `key1=value1&key2=value2`.
18026/// The examples below skip the percent-encoding for readability.
18027///
18028/// Example 1
18029///
18030/// Extracting a field from the request to put into the routing header
18031/// unchanged, with the key equal to the field name.
18032///
18033/// annotation:
18034///
18035/// ```norust
18036/// option (google.api.routing) = {
18037///   // Take the `app_profile_id`.
18038///   routing_parameters {
18039///     field: "app_profile_id"
18040///   }
18041/// };
18042/// ```
18043///
18044/// result:
18045///
18046/// ```norust
18047/// x-goog-request-params: app_profile_id=profiles/prof_qux
18048/// ```
18049///
18050/// Example 2
18051///
18052/// Extracting a field from the request to put into the routing header
18053/// unchanged, with the key different from the field name.
18054///
18055/// annotation:
18056///
18057/// ```norust
18058/// option (google.api.routing) = {
18059///   // Take the `app_profile_id`, but name it `routing_id` in the header.
18060///   routing_parameters {
18061///     field: "app_profile_id"
18062///     path_template: "{routing_id=**}"
18063///   }
18064/// };
18065/// ```
18066///
18067/// result:
18068///
18069/// ```norust
18070/// x-goog-request-params: routing_id=profiles/prof_qux
18071/// ```
18072///
18073/// Example 3
18074///
18075/// Extracting a field from the request to put into the routing
18076/// header, while matching a path template syntax on the field's value.
18077///
18078/// NB: it is more useful to send nothing than to send garbage for the purpose
18079/// of dynamic routing, since garbage pollutes cache. Thus the matching.
18080///
18081/// Sub-example 3a
18082///
18083/// The field matches the template.
18084///
18085/// annotation:
18086///
18087/// ```norust
18088/// option (google.api.routing) = {
18089///   // Take the `table_name`, if it's well-formed (with project-based
18090///   // syntax).
18091///   routing_parameters {
18092///     field: "table_name"
18093///     path_template: "{table_name=projects/*/instances/*/**}"
18094///   }
18095/// };
18096/// ```
18097///
18098/// result:
18099///
18100/// ```norust
18101/// x-goog-request-params:
18102/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
18103/// ```
18104///
18105/// Sub-example 3b
18106///
18107/// The field does not match the template.
18108///
18109/// annotation:
18110///
18111/// ```norust
18112/// option (google.api.routing) = {
18113///   // Take the `table_name`, if it's well-formed (with region-based
18114///   // syntax).
18115///   routing_parameters {
18116///     field: "table_name"
18117///     path_template: "{table_name=regions/*/zones/*/**}"
18118///   }
18119/// };
18120/// ```
18121///
18122/// result:
18123///
18124/// ```norust
18125/// <no routing header will be sent>
18126/// ```
18127///
18128/// Sub-example 3c
18129///
18130/// Multiple alternative conflictingly named path templates are
18131/// specified. The one that matches is used to construct the header.
18132///
18133/// annotation:
18134///
18135/// ```norust
18136/// option (google.api.routing) = {
18137///   // Take the `table_name`, if it's well-formed, whether
18138///   // using the region- or projects-based syntax.
18139///
18140///   routing_parameters {
18141///     field: "table_name"
18142///     path_template: "{table_name=regions/*/zones/*/**}"
18143///   }
18144///   routing_parameters {
18145///     field: "table_name"
18146///     path_template: "{table_name=projects/*/instances/*/**}"
18147///   }
18148/// };
18149/// ```
18150///
18151/// result:
18152///
18153/// ```norust
18154/// x-goog-request-params:
18155/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
18156/// ```
18157///
18158/// Example 4
18159///
18160/// Extracting a single routing header key-value pair by matching a
18161/// template syntax on (a part of) a single request field.
18162///
18163/// annotation:
18164///
18165/// ```norust
18166/// option (google.api.routing) = {
18167///   // Take just the project id from the `table_name` field.
18168///   routing_parameters {
18169///     field: "table_name"
18170///     path_template: "{routing_id=projects/*}/**"
18171///   }
18172/// };
18173/// ```
18174///
18175/// result:
18176///
18177/// ```norust
18178/// x-goog-request-params: routing_id=projects/proj_foo
18179/// ```
18180///
18181/// Example 5
18182///
18183/// Extracting a single routing header key-value pair by matching
18184/// several conflictingly named path templates on (parts of) a single request
18185/// field. The last template to match "wins" the conflict.
18186///
18187/// annotation:
18188///
18189/// ```norust
18190/// option (google.api.routing) = {
18191///   // If the `table_name` does not have instances information,
18192///   // take just the project id for routing.
18193///   // Otherwise take project + instance.
18194///
18195///   routing_parameters {
18196///     field: "table_name"
18197///     path_template: "{routing_id=projects/*}/**"
18198///   }
18199///   routing_parameters {
18200///     field: "table_name"
18201///     path_template: "{routing_id=projects/*/instances/*}/**"
18202///   }
18203/// };
18204/// ```
18205///
18206/// result:
18207///
18208/// ```norust
18209/// x-goog-request-params:
18210/// routing_id=projects/proj_foo/instances/instance_bar
18211/// ```
18212///
18213/// Example 6
18214///
18215/// Extracting multiple routing header key-value pairs by matching
18216/// several non-conflicting path templates on (parts of) a single request field.
18217///
18218/// Sub-example 6a
18219///
18220/// Make the templates strict, so that if the `table_name` does not
18221/// have an instance information, nothing is sent.
18222///
18223/// annotation:
18224///
18225/// ```norust
18226/// option (google.api.routing) = {
18227///   // The routing code needs two keys instead of one composite
18228///   // but works only for the tables with the "project-instance" name
18229///   // syntax.
18230///
18231///   routing_parameters {
18232///     field: "table_name"
18233///     path_template: "{project_id=projects/*}/instances/*/**"
18234///   }
18235///   routing_parameters {
18236///     field: "table_name"
18237///     path_template: "projects/*/{instance_id=instances/*}/**"
18238///   }
18239/// };
18240/// ```
18241///
18242/// result:
18243///
18244/// ```norust
18245/// x-goog-request-params:
18246/// project_id=projects/proj_foo&instance_id=instances/instance_bar
18247/// ```
18248///
18249/// Sub-example 6b
18250///
18251/// Make the templates loose, so that if the `table_name` does not
18252/// have an instance information, just the project id part is sent.
18253///
18254/// annotation:
18255///
18256/// ```norust
18257/// option (google.api.routing) = {
18258///   // The routing code wants two keys instead of one composite
18259///   // but will work with just the `project_id` for tables without
18260///   // an instance in the `table_name`.
18261///
18262///   routing_parameters {
18263///     field: "table_name"
18264///     path_template: "{project_id=projects/*}/**"
18265///   }
18266///   routing_parameters {
18267///     field: "table_name"
18268///     path_template: "projects/*/{instance_id=instances/*}/**"
18269///   }
18270/// };
18271/// ```
18272///
18273/// result (is the same as 6a for our example message because it has the instance
18274/// information):
18275///
18276/// ```norust
18277/// x-goog-request-params:
18278/// project_id=projects/proj_foo&instance_id=instances/instance_bar
18279/// ```
18280///
18281/// Example 7
18282///
18283/// Extracting multiple routing header key-value pairs by matching
18284/// several path templates on multiple request fields.
18285///
18286/// NB: note that here there is no way to specify sending nothing if one of the
18287/// fields does not match its template. E.g. if the `table_name` is in the wrong
18288/// format, the `project_id` will not be sent, but the `routing_id` will be.
18289/// The backend routing code has to be aware of that and be prepared to not
18290/// receive a full complement of keys if it expects multiple.
18291///
18292/// annotation:
18293///
18294/// ```norust
18295/// option (google.api.routing) = {
18296///   // The routing needs both `project_id` and `routing_id`
18297///   // (from the `app_profile_id` field) for routing.
18298///
18299///   routing_parameters {
18300///     field: "table_name"
18301///     path_template: "{project_id=projects/*}/**"
18302///   }
18303///   routing_parameters {
18304///     field: "app_profile_id"
18305///     path_template: "{routing_id=**}"
18306///   }
18307/// };
18308/// ```
18309///
18310/// result:
18311///
18312/// ```norust
18313/// x-goog-request-params:
18314/// project_id=projects/proj_foo&routing_id=profiles/prof_qux
18315/// ```
18316///
18317/// Example 8
18318///
18319/// Extracting a single routing header key-value pair by matching
18320/// several conflictingly named path templates on several request fields. The
18321/// last template to match "wins" the conflict.
18322///
18323/// annotation:
18324///
18325/// ```norust
18326/// option (google.api.routing) = {
18327///   // The `routing_id` can be a project id or a region id depending on
18328///   // the table name format, but only if the `app_profile_id` is not set.
18329///   // If `app_profile_id` is set it should be used instead.
18330///
18331///   routing_parameters {
18332///     field: "table_name"
18333///     path_template: "{routing_id=projects/*}/**"
18334///   }
18335///   routing_parameters {
18336///      field: "table_name"
18337///      path_template: "{routing_id=regions/*}/**"
18338///   }
18339///   routing_parameters {
18340///     field: "app_profile_id"
18341///     path_template: "{routing_id=**}"
18342///   }
18343/// };
18344/// ```
18345///
18346/// result:
18347///
18348/// ```norust
18349/// x-goog-request-params: routing_id=profiles/prof_qux
18350/// ```
18351///
18352/// Example 9
18353///
18354/// Bringing it all together.
18355///
18356/// annotation:
18357///
18358/// ```norust
18359/// option (google.api.routing) = {
18360///   // For routing both `table_location` and a `routing_id` are needed.
18361///   //
18362///   // table_location can be either an instance id or a region+zone id.
18363///   //
18364///   // For `routing_id`, take the value of `app_profile_id`
18365///   // - If it's in the format `profiles/<profile_id>`, send
18366///   // just the `<profile_id>` part.
18367///   // - If it's any other literal, send it as is.
18368///   // If the `app_profile_id` is empty, and the `table_name` starts with
18369///   // the project_id, send that instead.
18370///
18371///   routing_parameters {
18372///     field: "table_name"
18373///     path_template: "projects/*/{table_location=instances/*}/tables/*"
18374///   }
18375///   routing_parameters {
18376///     field: "table_name"
18377///     path_template: "{table_location=regions/*/zones/*}/tables/*"
18378///   }
18379///   routing_parameters {
18380///     field: "table_name"
18381///     path_template: "{routing_id=projects/*}/**"
18382///   }
18383///   routing_parameters {
18384///     field: "app_profile_id"
18385///     path_template: "{routing_id=**}"
18386///   }
18387///   routing_parameters {
18388///     field: "app_profile_id"
18389///     path_template: "profiles/{routing_id=*}"
18390///   }
18391/// };
18392/// ```
18393///
18394/// result:
18395///
18396/// ```norust
18397/// x-goog-request-params:
18398/// table_location=instances/instance_bar&routing_id=prof_qux
18399/// ```
18400#[derive(Clone, Debug, Default, PartialEq)]
18401#[non_exhaustive]
18402pub struct RoutingRule {
18403    /// A collection of Routing Parameter specifications.
18404    /// **NOTE:** If multiple Routing Parameters describe the same key
18405    /// (via the `path_template` field or via the `field` field when
18406    /// `path_template` is not provided), "last one wins" rule
18407    /// determines which Parameter gets used.
18408    /// See the examples for more details.
18409    pub routing_parameters: std::vec::Vec<crate::model::RoutingParameter>,
18410
18411    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18412}
18413
18414impl RoutingRule {
18415    pub fn new() -> Self {
18416        std::default::Default::default()
18417    }
18418
18419    /// Sets the value of [routing_parameters][crate::model::RoutingRule::routing_parameters].
18420    pub fn set_routing_parameters<T, V>(mut self, v: T) -> Self
18421    where
18422        T: std::iter::IntoIterator<Item = V>,
18423        V: std::convert::Into<crate::model::RoutingParameter>,
18424    {
18425        use std::iter::Iterator;
18426        self.routing_parameters = v.into_iter().map(|i| i.into()).collect();
18427        self
18428    }
18429}
18430
18431impl wkt::message::Message for RoutingRule {
18432    fn typename() -> &'static str {
18433        "type.googleapis.com/google.api.RoutingRule"
18434    }
18435}
18436
18437#[doc(hidden)]
18438impl<'de> serde::de::Deserialize<'de> for RoutingRule {
18439    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18440    where
18441        D: serde::Deserializer<'de>,
18442    {
18443        #[allow(non_camel_case_types)]
18444        #[doc(hidden)]
18445        #[derive(PartialEq, Eq, Hash)]
18446        enum __FieldTag {
18447            __routing_parameters,
18448            Unknown(std::string::String),
18449        }
18450        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18451            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18452            where
18453                D: serde::Deserializer<'de>,
18454            {
18455                struct Visitor;
18456                impl<'de> serde::de::Visitor<'de> for Visitor {
18457                    type Value = __FieldTag;
18458                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18459                        formatter.write_str("a field name for RoutingRule")
18460                    }
18461                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18462                    where
18463                        E: serde::de::Error,
18464                    {
18465                        use std::result::Result::Ok;
18466                        use std::string::ToString;
18467                        match value {
18468                            "routingParameters" => Ok(__FieldTag::__routing_parameters),
18469                            "routing_parameters" => Ok(__FieldTag::__routing_parameters),
18470                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18471                        }
18472                    }
18473                }
18474                deserializer.deserialize_identifier(Visitor)
18475            }
18476        }
18477        struct Visitor;
18478        impl<'de> serde::de::Visitor<'de> for Visitor {
18479            type Value = RoutingRule;
18480            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18481                formatter.write_str("struct RoutingRule")
18482            }
18483            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18484            where
18485                A: serde::de::MapAccess<'de>,
18486            {
18487                #[allow(unused_imports)]
18488                use serde::de::Error;
18489                use std::option::Option::Some;
18490                let mut fields = std::collections::HashSet::new();
18491                let mut result = Self::Value::new();
18492                while let Some(tag) = map.next_key::<__FieldTag>()? {
18493                    #[allow(clippy::match_single_binding)]
18494                    match tag {
18495                        __FieldTag::__routing_parameters => {
18496                            if !fields.insert(__FieldTag::__routing_parameters) {
18497                                return std::result::Result::Err(A::Error::duplicate_field(
18498                                    "multiple values for routing_parameters",
18499                                ));
18500                            }
18501                            result.routing_parameters =
18502                                map.next_value::<std::option::Option<
18503                                    std::vec::Vec<crate::model::RoutingParameter>,
18504                                >>()?
18505                                .unwrap_or_default();
18506                        }
18507                        __FieldTag::Unknown(key) => {
18508                            let value = map.next_value::<serde_json::Value>()?;
18509                            result._unknown_fields.insert(key, value);
18510                        }
18511                    }
18512                }
18513                std::result::Result::Ok(result)
18514            }
18515        }
18516        deserializer.deserialize_any(Visitor)
18517    }
18518}
18519
18520#[doc(hidden)]
18521impl serde::ser::Serialize for RoutingRule {
18522    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18523    where
18524        S: serde::ser::Serializer,
18525    {
18526        use serde::ser::SerializeMap;
18527        #[allow(unused_imports)]
18528        use std::option::Option::Some;
18529        let mut state = serializer.serialize_map(std::option::Option::None)?;
18530        if !self.routing_parameters.is_empty() {
18531            state.serialize_entry("routingParameters", &self.routing_parameters)?;
18532        }
18533        if !self._unknown_fields.is_empty() {
18534            for (key, value) in self._unknown_fields.iter() {
18535                state.serialize_entry(key, &value)?;
18536            }
18537        }
18538        state.end()
18539    }
18540}
18541
18542/// A projection from an input message to the GRPC or REST header.
18543#[derive(Clone, Debug, Default, PartialEq)]
18544#[non_exhaustive]
18545pub struct RoutingParameter {
18546    /// A request field to extract the header key-value pair from.
18547    pub field: std::string::String,
18548
18549    /// A pattern matching the key-value field. Optional.
18550    /// If not specified, the whole field specified in the `field` field will be
18551    /// taken as value, and its name used as key. If specified, it MUST contain
18552    /// exactly one named segment (along with any number of unnamed segments) The
18553    /// pattern will be matched over the field specified in the `field` field, then
18554    /// if the match is successful:
18555    ///
18556    /// - the name of the single named segment will be used as a header name,
18557    /// - the match value of the segment will be used as a header value;
18558    ///   if the match is NOT successful, nothing will be sent.
18559    ///
18560    /// Example:
18561    ///
18562    /// ```norust
18563    ///           -- This is a field in the request message
18564    ///          |   that the header value will be extracted from.
18565    ///          |
18566    ///          |                     -- This is the key name in the
18567    ///          |                    |   routing header.
18568    ///          V                    |
18569    /// field: "table_name"           v
18570    /// path_template: "projects/*/{table_location=instances/*}/tables/*"
18571    ///                                            ^            ^
18572    ///                                            |            |
18573    ///   In the {} brackets is the pattern that --             |
18574    ///   specifies what to extract from the                    |
18575    ///   field as a value to be sent.                          |
18576    ///                                                         |
18577    ///  The string in the field must match the whole pattern --
18578    ///  before brackets, inside brackets, after brackets.
18579    /// ```
18580    ///
18581    /// When looking at this specific example, we can see that:
18582    ///
18583    /// - A key-value pair with the key `table_location`
18584    ///   and the value matching `instances/*` should be added
18585    ///   to the x-goog-request-params routing header.
18586    /// - The value is extracted from the request message's `table_name` field
18587    ///   if it matches the full pattern specified:
18588    ///   `projects/*/instances/*/tables/*`.
18589    ///
18590    /// **NB:** If the `path_template` field is not provided, the key name is
18591    /// equal to the field name, and the whole field should be sent as a value.
18592    /// This makes the pattern for the field and the value functionally equivalent
18593    /// to `**`, and the configuration
18594    ///
18595    /// ```norust
18596    /// {
18597    ///   field: "table_name"
18598    /// }
18599    /// ```
18600    ///
18601    /// is a functionally equivalent shorthand to:
18602    ///
18603    /// ```norust
18604    /// {
18605    ///   field: "table_name"
18606    ///   path_template: "{table_name=**}"
18607    /// }
18608    /// ```
18609    ///
18610    /// See Example 1 for more details.
18611    pub path_template: std::string::String,
18612
18613    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18614}
18615
18616impl RoutingParameter {
18617    pub fn new() -> Self {
18618        std::default::Default::default()
18619    }
18620
18621    /// Sets the value of [field][crate::model::RoutingParameter::field].
18622    pub fn set_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18623        self.field = v.into();
18624        self
18625    }
18626
18627    /// Sets the value of [path_template][crate::model::RoutingParameter::path_template].
18628    pub fn set_path_template<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18629        self.path_template = v.into();
18630        self
18631    }
18632}
18633
18634impl wkt::message::Message for RoutingParameter {
18635    fn typename() -> &'static str {
18636        "type.googleapis.com/google.api.RoutingParameter"
18637    }
18638}
18639
18640#[doc(hidden)]
18641impl<'de> serde::de::Deserialize<'de> for RoutingParameter {
18642    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18643    where
18644        D: serde::Deserializer<'de>,
18645    {
18646        #[allow(non_camel_case_types)]
18647        #[doc(hidden)]
18648        #[derive(PartialEq, Eq, Hash)]
18649        enum __FieldTag {
18650            __field,
18651            __path_template,
18652            Unknown(std::string::String),
18653        }
18654        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18655            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18656            where
18657                D: serde::Deserializer<'de>,
18658            {
18659                struct Visitor;
18660                impl<'de> serde::de::Visitor<'de> for Visitor {
18661                    type Value = __FieldTag;
18662                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18663                        formatter.write_str("a field name for RoutingParameter")
18664                    }
18665                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18666                    where
18667                        E: serde::de::Error,
18668                    {
18669                        use std::result::Result::Ok;
18670                        use std::string::ToString;
18671                        match value {
18672                            "field" => Ok(__FieldTag::__field),
18673                            "pathTemplate" => Ok(__FieldTag::__path_template),
18674                            "path_template" => Ok(__FieldTag::__path_template),
18675                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18676                        }
18677                    }
18678                }
18679                deserializer.deserialize_identifier(Visitor)
18680            }
18681        }
18682        struct Visitor;
18683        impl<'de> serde::de::Visitor<'de> for Visitor {
18684            type Value = RoutingParameter;
18685            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18686                formatter.write_str("struct RoutingParameter")
18687            }
18688            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18689            where
18690                A: serde::de::MapAccess<'de>,
18691            {
18692                #[allow(unused_imports)]
18693                use serde::de::Error;
18694                use std::option::Option::Some;
18695                let mut fields = std::collections::HashSet::new();
18696                let mut result = Self::Value::new();
18697                while let Some(tag) = map.next_key::<__FieldTag>()? {
18698                    #[allow(clippy::match_single_binding)]
18699                    match tag {
18700                        __FieldTag::__field => {
18701                            if !fields.insert(__FieldTag::__field) {
18702                                return std::result::Result::Err(A::Error::duplicate_field(
18703                                    "multiple values for field",
18704                                ));
18705                            }
18706                            result.field = map
18707                                .next_value::<std::option::Option<std::string::String>>()?
18708                                .unwrap_or_default();
18709                        }
18710                        __FieldTag::__path_template => {
18711                            if !fields.insert(__FieldTag::__path_template) {
18712                                return std::result::Result::Err(A::Error::duplicate_field(
18713                                    "multiple values for path_template",
18714                                ));
18715                            }
18716                            result.path_template = map
18717                                .next_value::<std::option::Option<std::string::String>>()?
18718                                .unwrap_or_default();
18719                        }
18720                        __FieldTag::Unknown(key) => {
18721                            let value = map.next_value::<serde_json::Value>()?;
18722                            result._unknown_fields.insert(key, value);
18723                        }
18724                    }
18725                }
18726                std::result::Result::Ok(result)
18727            }
18728        }
18729        deserializer.deserialize_any(Visitor)
18730    }
18731}
18732
18733#[doc(hidden)]
18734impl serde::ser::Serialize for RoutingParameter {
18735    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18736    where
18737        S: serde::ser::Serializer,
18738    {
18739        use serde::ser::SerializeMap;
18740        #[allow(unused_imports)]
18741        use std::option::Option::Some;
18742        let mut state = serializer.serialize_map(std::option::Option::None)?;
18743        if !self.field.is_empty() {
18744            state.serialize_entry("field", &self.field)?;
18745        }
18746        if !self.path_template.is_empty() {
18747            state.serialize_entry("pathTemplate", &self.path_template)?;
18748        }
18749        if !self._unknown_fields.is_empty() {
18750            for (key, value) in self._unknown_fields.iter() {
18751                state.serialize_entry(key, &value)?;
18752            }
18753        }
18754        state.end()
18755    }
18756}
18757
18758/// `Service` is the root object of Google API service configuration (service
18759/// config). It describes the basic information about a logical service,
18760/// such as the service name and the user-facing title, and delegates other
18761/// aspects to sub-sections. Each sub-section is either a proto message or a
18762/// repeated proto message that configures a specific aspect, such as auth.
18763/// For more information, see each proto message definition.
18764///
18765/// Example:
18766///
18767/// ```norust
18768/// type: google.api.Service
18769/// name: calendar.googleapis.com
18770/// title: Google Calendar API
18771/// apis:
18772/// - name: google.calendar.v3.Calendar
18773///
18774/// visibility:
18775///   rules:
18776///   - selector: "google.calendar.v3.*"
18777///     restriction: PREVIEW
18778/// backend:
18779///   rules:
18780///   - selector: "google.calendar.v3.*"
18781///     address: calendar.example.com
18782///
18783/// authentication:
18784///   providers:
18785///   - id: google_calendar_auth
18786///     jwks_uri: https://www.googleapis.com/oauth2/v1/certs
18787///     issuer: https://securetoken.google.com
18788///   rules:
18789///   - selector: "*"
18790///     requirements:
18791///       provider_id: google_calendar_auth
18792/// ```
18793#[derive(Clone, Debug, Default, PartialEq)]
18794#[non_exhaustive]
18795pub struct Service {
18796    /// The service name, which is a DNS-like logical identifier for the
18797    /// service, such as `calendar.googleapis.com`. The service name
18798    /// typically goes through DNS verification to make sure the owner
18799    /// of the service also owns the DNS name.
18800    pub name: std::string::String,
18801
18802    /// The product title for this service, it is the name displayed in Google
18803    /// Cloud Console.
18804    pub title: std::string::String,
18805
18806    /// The Google project that owns this service.
18807    pub producer_project_id: std::string::String,
18808
18809    /// A unique ID for a specific instance of this message, typically assigned
18810    /// by the client for tracking purpose. Must be no longer than 63 characters
18811    /// and only lower case letters, digits, '.', '_' and '-' are allowed. If
18812    /// empty, the server may choose to generate one instead.
18813    pub id: std::string::String,
18814
18815    /// A list of API interfaces exported by this service. Only the `name` field
18816    /// of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by
18817    /// the configuration author, as the remaining fields will be derived from the
18818    /// IDL during the normalization process. It is an error to specify an API
18819    /// interface here which cannot be resolved against the associated IDL files.
18820    ///
18821    /// [google.protobuf.Api]: wkt::Api
18822    pub apis: std::vec::Vec<wkt::Api>,
18823
18824    /// A list of all proto message types included in this API service.
18825    /// Types referenced directly or indirectly by the `apis` are automatically
18826    /// included.  Messages which are not referenced but shall be included, such as
18827    /// types used by the `google.protobuf.Any` type, should be listed here by
18828    /// name by the configuration author. Example:
18829    ///
18830    /// ```norust
18831    /// types:
18832    /// - name: google.protobuf.Int32
18833    /// ```
18834    pub types: std::vec::Vec<wkt::Type>,
18835
18836    /// A list of all enum types included in this API service.  Enums referenced
18837    /// directly or indirectly by the `apis` are automatically included.  Enums
18838    /// which are not referenced but shall be included should be listed here by
18839    /// name by the configuration author. Example:
18840    ///
18841    /// ```norust
18842    /// enums:
18843    /// - name: google.someapi.v1.SomeEnum
18844    /// ```
18845    pub enums: std::vec::Vec<wkt::Enum>,
18846
18847    /// Additional API documentation.
18848    pub documentation: std::option::Option<crate::model::Documentation>,
18849
18850    /// API backend configuration.
18851    pub backend: std::option::Option<crate::model::Backend>,
18852
18853    /// HTTP configuration.
18854    pub http: std::option::Option<crate::model::Http>,
18855
18856    /// Quota configuration.
18857    pub quota: std::option::Option<crate::model::Quota>,
18858
18859    /// Auth configuration.
18860    pub authentication: std::option::Option<crate::model::Authentication>,
18861
18862    /// Context configuration.
18863    pub context: std::option::Option<crate::model::Context>,
18864
18865    /// Configuration controlling usage of this service.
18866    pub usage: std::option::Option<crate::model::Usage>,
18867
18868    /// Configuration for network endpoints.  If this is empty, then an endpoint
18869    /// with the same name as the service is automatically generated to service all
18870    /// defined APIs.
18871    pub endpoints: std::vec::Vec<crate::model::Endpoint>,
18872
18873    /// Configuration for the service control plane.
18874    pub control: std::option::Option<crate::model::Control>,
18875
18876    /// Defines the logs used by this service.
18877    pub logs: std::vec::Vec<crate::model::LogDescriptor>,
18878
18879    /// Defines the metrics used by this service.
18880    pub metrics: std::vec::Vec<crate::model::MetricDescriptor>,
18881
18882    /// Defines the monitored resources used by this service. This is required
18883    /// by the [Service.monitoring][google.api.Service.monitoring] and
18884    /// [Service.logging][google.api.Service.logging] configurations.
18885    ///
18886    /// [google.api.Service.logging]: crate::model::Service::logging
18887    /// [google.api.Service.monitoring]: crate::model::Service::monitoring
18888    pub monitored_resources: std::vec::Vec<crate::model::MonitoredResourceDescriptor>,
18889
18890    /// Billing configuration.
18891    pub billing: std::option::Option<crate::model::Billing>,
18892
18893    /// Logging configuration.
18894    pub logging: std::option::Option<crate::model::Logging>,
18895
18896    /// Monitoring configuration.
18897    pub monitoring: std::option::Option<crate::model::Monitoring>,
18898
18899    /// System parameter configuration.
18900    pub system_parameters: std::option::Option<crate::model::SystemParameters>,
18901
18902    /// Output only. The source information for this configuration if available.
18903    pub source_info: std::option::Option<crate::model::SourceInfo>,
18904
18905    /// Settings for [Google Cloud Client
18906    /// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
18907    /// generated from APIs defined as protocol buffers.
18908    pub publishing: std::option::Option<crate::model::Publishing>,
18909
18910    /// Obsolete. Do not use.
18911    ///
18912    /// This field has no semantic meaning. The service config compiler always
18913    /// sets this field to `3`.
18914    pub config_version: std::option::Option<wkt::UInt32Value>,
18915
18916    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18917}
18918
18919impl Service {
18920    pub fn new() -> Self {
18921        std::default::Default::default()
18922    }
18923
18924    /// Sets the value of [name][crate::model::Service::name].
18925    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18926        self.name = v.into();
18927        self
18928    }
18929
18930    /// Sets the value of [title][crate::model::Service::title].
18931    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18932        self.title = v.into();
18933        self
18934    }
18935
18936    /// Sets the value of [producer_project_id][crate::model::Service::producer_project_id].
18937    pub fn set_producer_project_id<T: std::convert::Into<std::string::String>>(
18938        mut self,
18939        v: T,
18940    ) -> Self {
18941        self.producer_project_id = v.into();
18942        self
18943    }
18944
18945    /// Sets the value of [id][crate::model::Service::id].
18946    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18947        self.id = v.into();
18948        self
18949    }
18950
18951    /// Sets the value of [apis][crate::model::Service::apis].
18952    pub fn set_apis<T, V>(mut self, v: T) -> Self
18953    where
18954        T: std::iter::IntoIterator<Item = V>,
18955        V: std::convert::Into<wkt::Api>,
18956    {
18957        use std::iter::Iterator;
18958        self.apis = v.into_iter().map(|i| i.into()).collect();
18959        self
18960    }
18961
18962    /// Sets the value of [types][crate::model::Service::types].
18963    pub fn set_types<T, V>(mut self, v: T) -> Self
18964    where
18965        T: std::iter::IntoIterator<Item = V>,
18966        V: std::convert::Into<wkt::Type>,
18967    {
18968        use std::iter::Iterator;
18969        self.types = v.into_iter().map(|i| i.into()).collect();
18970        self
18971    }
18972
18973    /// Sets the value of [enums][crate::model::Service::enums].
18974    pub fn set_enums<T, V>(mut self, v: T) -> Self
18975    where
18976        T: std::iter::IntoIterator<Item = V>,
18977        V: std::convert::Into<wkt::Enum>,
18978    {
18979        use std::iter::Iterator;
18980        self.enums = v.into_iter().map(|i| i.into()).collect();
18981        self
18982    }
18983
18984    /// Sets the value of [documentation][crate::model::Service::documentation].
18985    pub fn set_documentation<T>(mut self, v: T) -> Self
18986    where
18987        T: std::convert::Into<crate::model::Documentation>,
18988    {
18989        self.documentation = std::option::Option::Some(v.into());
18990        self
18991    }
18992
18993    /// Sets or clears the value of [documentation][crate::model::Service::documentation].
18994    pub fn set_or_clear_documentation<T>(mut self, v: std::option::Option<T>) -> Self
18995    where
18996        T: std::convert::Into<crate::model::Documentation>,
18997    {
18998        self.documentation = v.map(|x| x.into());
18999        self
19000    }
19001
19002    /// Sets the value of [backend][crate::model::Service::backend].
19003    pub fn set_backend<T>(mut self, v: T) -> Self
19004    where
19005        T: std::convert::Into<crate::model::Backend>,
19006    {
19007        self.backend = std::option::Option::Some(v.into());
19008        self
19009    }
19010
19011    /// Sets or clears the value of [backend][crate::model::Service::backend].
19012    pub fn set_or_clear_backend<T>(mut self, v: std::option::Option<T>) -> Self
19013    where
19014        T: std::convert::Into<crate::model::Backend>,
19015    {
19016        self.backend = v.map(|x| x.into());
19017        self
19018    }
19019
19020    /// Sets the value of [http][crate::model::Service::http].
19021    pub fn set_http<T>(mut self, v: T) -> Self
19022    where
19023        T: std::convert::Into<crate::model::Http>,
19024    {
19025        self.http = std::option::Option::Some(v.into());
19026        self
19027    }
19028
19029    /// Sets or clears the value of [http][crate::model::Service::http].
19030    pub fn set_or_clear_http<T>(mut self, v: std::option::Option<T>) -> Self
19031    where
19032        T: std::convert::Into<crate::model::Http>,
19033    {
19034        self.http = v.map(|x| x.into());
19035        self
19036    }
19037
19038    /// Sets the value of [quota][crate::model::Service::quota].
19039    pub fn set_quota<T>(mut self, v: T) -> Self
19040    where
19041        T: std::convert::Into<crate::model::Quota>,
19042    {
19043        self.quota = std::option::Option::Some(v.into());
19044        self
19045    }
19046
19047    /// Sets or clears the value of [quota][crate::model::Service::quota].
19048    pub fn set_or_clear_quota<T>(mut self, v: std::option::Option<T>) -> Self
19049    where
19050        T: std::convert::Into<crate::model::Quota>,
19051    {
19052        self.quota = v.map(|x| x.into());
19053        self
19054    }
19055
19056    /// Sets the value of [authentication][crate::model::Service::authentication].
19057    pub fn set_authentication<T>(mut self, v: T) -> Self
19058    where
19059        T: std::convert::Into<crate::model::Authentication>,
19060    {
19061        self.authentication = std::option::Option::Some(v.into());
19062        self
19063    }
19064
19065    /// Sets or clears the value of [authentication][crate::model::Service::authentication].
19066    pub fn set_or_clear_authentication<T>(mut self, v: std::option::Option<T>) -> Self
19067    where
19068        T: std::convert::Into<crate::model::Authentication>,
19069    {
19070        self.authentication = v.map(|x| x.into());
19071        self
19072    }
19073
19074    /// Sets the value of [context][crate::model::Service::context].
19075    pub fn set_context<T>(mut self, v: T) -> Self
19076    where
19077        T: std::convert::Into<crate::model::Context>,
19078    {
19079        self.context = std::option::Option::Some(v.into());
19080        self
19081    }
19082
19083    /// Sets or clears the value of [context][crate::model::Service::context].
19084    pub fn set_or_clear_context<T>(mut self, v: std::option::Option<T>) -> Self
19085    where
19086        T: std::convert::Into<crate::model::Context>,
19087    {
19088        self.context = v.map(|x| x.into());
19089        self
19090    }
19091
19092    /// Sets the value of [usage][crate::model::Service::usage].
19093    pub fn set_usage<T>(mut self, v: T) -> Self
19094    where
19095        T: std::convert::Into<crate::model::Usage>,
19096    {
19097        self.usage = std::option::Option::Some(v.into());
19098        self
19099    }
19100
19101    /// Sets or clears the value of [usage][crate::model::Service::usage].
19102    pub fn set_or_clear_usage<T>(mut self, v: std::option::Option<T>) -> Self
19103    where
19104        T: std::convert::Into<crate::model::Usage>,
19105    {
19106        self.usage = v.map(|x| x.into());
19107        self
19108    }
19109
19110    /// Sets the value of [endpoints][crate::model::Service::endpoints].
19111    pub fn set_endpoints<T, V>(mut self, v: T) -> Self
19112    where
19113        T: std::iter::IntoIterator<Item = V>,
19114        V: std::convert::Into<crate::model::Endpoint>,
19115    {
19116        use std::iter::Iterator;
19117        self.endpoints = v.into_iter().map(|i| i.into()).collect();
19118        self
19119    }
19120
19121    /// Sets the value of [control][crate::model::Service::control].
19122    pub fn set_control<T>(mut self, v: T) -> Self
19123    where
19124        T: std::convert::Into<crate::model::Control>,
19125    {
19126        self.control = std::option::Option::Some(v.into());
19127        self
19128    }
19129
19130    /// Sets or clears the value of [control][crate::model::Service::control].
19131    pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
19132    where
19133        T: std::convert::Into<crate::model::Control>,
19134    {
19135        self.control = v.map(|x| x.into());
19136        self
19137    }
19138
19139    /// Sets the value of [logs][crate::model::Service::logs].
19140    pub fn set_logs<T, V>(mut self, v: T) -> Self
19141    where
19142        T: std::iter::IntoIterator<Item = V>,
19143        V: std::convert::Into<crate::model::LogDescriptor>,
19144    {
19145        use std::iter::Iterator;
19146        self.logs = v.into_iter().map(|i| i.into()).collect();
19147        self
19148    }
19149
19150    /// Sets the value of [metrics][crate::model::Service::metrics].
19151    pub fn set_metrics<T, V>(mut self, v: T) -> Self
19152    where
19153        T: std::iter::IntoIterator<Item = V>,
19154        V: std::convert::Into<crate::model::MetricDescriptor>,
19155    {
19156        use std::iter::Iterator;
19157        self.metrics = v.into_iter().map(|i| i.into()).collect();
19158        self
19159    }
19160
19161    /// Sets the value of [monitored_resources][crate::model::Service::monitored_resources].
19162    pub fn set_monitored_resources<T, V>(mut self, v: T) -> Self
19163    where
19164        T: std::iter::IntoIterator<Item = V>,
19165        V: std::convert::Into<crate::model::MonitoredResourceDescriptor>,
19166    {
19167        use std::iter::Iterator;
19168        self.monitored_resources = v.into_iter().map(|i| i.into()).collect();
19169        self
19170    }
19171
19172    /// Sets the value of [billing][crate::model::Service::billing].
19173    pub fn set_billing<T>(mut self, v: T) -> Self
19174    where
19175        T: std::convert::Into<crate::model::Billing>,
19176    {
19177        self.billing = std::option::Option::Some(v.into());
19178        self
19179    }
19180
19181    /// Sets or clears the value of [billing][crate::model::Service::billing].
19182    pub fn set_or_clear_billing<T>(mut self, v: std::option::Option<T>) -> Self
19183    where
19184        T: std::convert::Into<crate::model::Billing>,
19185    {
19186        self.billing = v.map(|x| x.into());
19187        self
19188    }
19189
19190    /// Sets the value of [logging][crate::model::Service::logging].
19191    pub fn set_logging<T>(mut self, v: T) -> Self
19192    where
19193        T: std::convert::Into<crate::model::Logging>,
19194    {
19195        self.logging = std::option::Option::Some(v.into());
19196        self
19197    }
19198
19199    /// Sets or clears the value of [logging][crate::model::Service::logging].
19200    pub fn set_or_clear_logging<T>(mut self, v: std::option::Option<T>) -> Self
19201    where
19202        T: std::convert::Into<crate::model::Logging>,
19203    {
19204        self.logging = v.map(|x| x.into());
19205        self
19206    }
19207
19208    /// Sets the value of [monitoring][crate::model::Service::monitoring].
19209    pub fn set_monitoring<T>(mut self, v: T) -> Self
19210    where
19211        T: std::convert::Into<crate::model::Monitoring>,
19212    {
19213        self.monitoring = std::option::Option::Some(v.into());
19214        self
19215    }
19216
19217    /// Sets or clears the value of [monitoring][crate::model::Service::monitoring].
19218    pub fn set_or_clear_monitoring<T>(mut self, v: std::option::Option<T>) -> Self
19219    where
19220        T: std::convert::Into<crate::model::Monitoring>,
19221    {
19222        self.monitoring = v.map(|x| x.into());
19223        self
19224    }
19225
19226    /// Sets the value of [system_parameters][crate::model::Service::system_parameters].
19227    pub fn set_system_parameters<T>(mut self, v: T) -> Self
19228    where
19229        T: std::convert::Into<crate::model::SystemParameters>,
19230    {
19231        self.system_parameters = std::option::Option::Some(v.into());
19232        self
19233    }
19234
19235    /// Sets or clears the value of [system_parameters][crate::model::Service::system_parameters].
19236    pub fn set_or_clear_system_parameters<T>(mut self, v: std::option::Option<T>) -> Self
19237    where
19238        T: std::convert::Into<crate::model::SystemParameters>,
19239    {
19240        self.system_parameters = v.map(|x| x.into());
19241        self
19242    }
19243
19244    /// Sets the value of [source_info][crate::model::Service::source_info].
19245    pub fn set_source_info<T>(mut self, v: T) -> Self
19246    where
19247        T: std::convert::Into<crate::model::SourceInfo>,
19248    {
19249        self.source_info = std::option::Option::Some(v.into());
19250        self
19251    }
19252
19253    /// Sets or clears the value of [source_info][crate::model::Service::source_info].
19254    pub fn set_or_clear_source_info<T>(mut self, v: std::option::Option<T>) -> Self
19255    where
19256        T: std::convert::Into<crate::model::SourceInfo>,
19257    {
19258        self.source_info = v.map(|x| x.into());
19259        self
19260    }
19261
19262    /// Sets the value of [publishing][crate::model::Service::publishing].
19263    pub fn set_publishing<T>(mut self, v: T) -> Self
19264    where
19265        T: std::convert::Into<crate::model::Publishing>,
19266    {
19267        self.publishing = std::option::Option::Some(v.into());
19268        self
19269    }
19270
19271    /// Sets or clears the value of [publishing][crate::model::Service::publishing].
19272    pub fn set_or_clear_publishing<T>(mut self, v: std::option::Option<T>) -> Self
19273    where
19274        T: std::convert::Into<crate::model::Publishing>,
19275    {
19276        self.publishing = v.map(|x| x.into());
19277        self
19278    }
19279
19280    /// Sets the value of [config_version][crate::model::Service::config_version].
19281    pub fn set_config_version<T>(mut self, v: T) -> Self
19282    where
19283        T: std::convert::Into<wkt::UInt32Value>,
19284    {
19285        self.config_version = std::option::Option::Some(v.into());
19286        self
19287    }
19288
19289    /// Sets or clears the value of [config_version][crate::model::Service::config_version].
19290    pub fn set_or_clear_config_version<T>(mut self, v: std::option::Option<T>) -> Self
19291    where
19292        T: std::convert::Into<wkt::UInt32Value>,
19293    {
19294        self.config_version = v.map(|x| x.into());
19295        self
19296    }
19297}
19298
19299impl wkt::message::Message for Service {
19300    fn typename() -> &'static str {
19301        "type.googleapis.com/google.api.Service"
19302    }
19303}
19304
19305#[doc(hidden)]
19306impl<'de> serde::de::Deserialize<'de> for Service {
19307    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19308    where
19309        D: serde::Deserializer<'de>,
19310    {
19311        #[allow(non_camel_case_types)]
19312        #[doc(hidden)]
19313        #[derive(PartialEq, Eq, Hash)]
19314        enum __FieldTag {
19315            __name,
19316            __title,
19317            __producer_project_id,
19318            __id,
19319            __apis,
19320            __types,
19321            __enums,
19322            __documentation,
19323            __backend,
19324            __http,
19325            __quota,
19326            __authentication,
19327            __context,
19328            __usage,
19329            __endpoints,
19330            __control,
19331            __logs,
19332            __metrics,
19333            __monitored_resources,
19334            __billing,
19335            __logging,
19336            __monitoring,
19337            __system_parameters,
19338            __source_info,
19339            __publishing,
19340            __config_version,
19341            Unknown(std::string::String),
19342        }
19343        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19344            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19345            where
19346                D: serde::Deserializer<'de>,
19347            {
19348                struct Visitor;
19349                impl<'de> serde::de::Visitor<'de> for Visitor {
19350                    type Value = __FieldTag;
19351                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19352                        formatter.write_str("a field name for Service")
19353                    }
19354                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19355                    where
19356                        E: serde::de::Error,
19357                    {
19358                        use std::result::Result::Ok;
19359                        use std::string::ToString;
19360                        match value {
19361                            "name" => Ok(__FieldTag::__name),
19362                            "title" => Ok(__FieldTag::__title),
19363                            "producerProjectId" => Ok(__FieldTag::__producer_project_id),
19364                            "producer_project_id" => Ok(__FieldTag::__producer_project_id),
19365                            "id" => Ok(__FieldTag::__id),
19366                            "apis" => Ok(__FieldTag::__apis),
19367                            "types" => Ok(__FieldTag::__types),
19368                            "enums" => Ok(__FieldTag::__enums),
19369                            "documentation" => Ok(__FieldTag::__documentation),
19370                            "backend" => Ok(__FieldTag::__backend),
19371                            "http" => Ok(__FieldTag::__http),
19372                            "quota" => Ok(__FieldTag::__quota),
19373                            "authentication" => Ok(__FieldTag::__authentication),
19374                            "context" => Ok(__FieldTag::__context),
19375                            "usage" => Ok(__FieldTag::__usage),
19376                            "endpoints" => Ok(__FieldTag::__endpoints),
19377                            "control" => Ok(__FieldTag::__control),
19378                            "logs" => Ok(__FieldTag::__logs),
19379                            "metrics" => Ok(__FieldTag::__metrics),
19380                            "monitoredResources" => Ok(__FieldTag::__monitored_resources),
19381                            "monitored_resources" => Ok(__FieldTag::__monitored_resources),
19382                            "billing" => Ok(__FieldTag::__billing),
19383                            "logging" => Ok(__FieldTag::__logging),
19384                            "monitoring" => Ok(__FieldTag::__monitoring),
19385                            "systemParameters" => Ok(__FieldTag::__system_parameters),
19386                            "system_parameters" => Ok(__FieldTag::__system_parameters),
19387                            "sourceInfo" => Ok(__FieldTag::__source_info),
19388                            "source_info" => Ok(__FieldTag::__source_info),
19389                            "publishing" => Ok(__FieldTag::__publishing),
19390                            "configVersion" => Ok(__FieldTag::__config_version),
19391                            "config_version" => Ok(__FieldTag::__config_version),
19392                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19393                        }
19394                    }
19395                }
19396                deserializer.deserialize_identifier(Visitor)
19397            }
19398        }
19399        struct Visitor;
19400        impl<'de> serde::de::Visitor<'de> for Visitor {
19401            type Value = Service;
19402            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19403                formatter.write_str("struct Service")
19404            }
19405            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19406            where
19407                A: serde::de::MapAccess<'de>,
19408            {
19409                #[allow(unused_imports)]
19410                use serde::de::Error;
19411                use std::option::Option::Some;
19412                let mut fields = std::collections::HashSet::new();
19413                let mut result = Self::Value::new();
19414                while let Some(tag) = map.next_key::<__FieldTag>()? {
19415                    #[allow(clippy::match_single_binding)]
19416                    match tag {
19417                        __FieldTag::__name => {
19418                            if !fields.insert(__FieldTag::__name) {
19419                                return std::result::Result::Err(A::Error::duplicate_field(
19420                                    "multiple values for name",
19421                                ));
19422                            }
19423                            result.name = map
19424                                .next_value::<std::option::Option<std::string::String>>()?
19425                                .unwrap_or_default();
19426                        }
19427                        __FieldTag::__title => {
19428                            if !fields.insert(__FieldTag::__title) {
19429                                return std::result::Result::Err(A::Error::duplicate_field(
19430                                    "multiple values for title",
19431                                ));
19432                            }
19433                            result.title = map
19434                                .next_value::<std::option::Option<std::string::String>>()?
19435                                .unwrap_or_default();
19436                        }
19437                        __FieldTag::__producer_project_id => {
19438                            if !fields.insert(__FieldTag::__producer_project_id) {
19439                                return std::result::Result::Err(A::Error::duplicate_field(
19440                                    "multiple values for producer_project_id",
19441                                ));
19442                            }
19443                            result.producer_project_id = map
19444                                .next_value::<std::option::Option<std::string::String>>()?
19445                                .unwrap_or_default();
19446                        }
19447                        __FieldTag::__id => {
19448                            if !fields.insert(__FieldTag::__id) {
19449                                return std::result::Result::Err(A::Error::duplicate_field(
19450                                    "multiple values for id",
19451                                ));
19452                            }
19453                            result.id = map
19454                                .next_value::<std::option::Option<std::string::String>>()?
19455                                .unwrap_or_default();
19456                        }
19457                        __FieldTag::__apis => {
19458                            if !fields.insert(__FieldTag::__apis) {
19459                                return std::result::Result::Err(A::Error::duplicate_field(
19460                                    "multiple values for apis",
19461                                ));
19462                            }
19463                            result.apis = map
19464                                .next_value::<std::option::Option<std::vec::Vec<wkt::Api>>>()?
19465                                .unwrap_or_default();
19466                        }
19467                        __FieldTag::__types => {
19468                            if !fields.insert(__FieldTag::__types) {
19469                                return std::result::Result::Err(A::Error::duplicate_field(
19470                                    "multiple values for types",
19471                                ));
19472                            }
19473                            result.types = map
19474                                .next_value::<std::option::Option<std::vec::Vec<wkt::Type>>>()?
19475                                .unwrap_or_default();
19476                        }
19477                        __FieldTag::__enums => {
19478                            if !fields.insert(__FieldTag::__enums) {
19479                                return std::result::Result::Err(A::Error::duplicate_field(
19480                                    "multiple values for enums",
19481                                ));
19482                            }
19483                            result.enums = map
19484                                .next_value::<std::option::Option<std::vec::Vec<wkt::Enum>>>()?
19485                                .unwrap_or_default();
19486                        }
19487                        __FieldTag::__documentation => {
19488                            if !fields.insert(__FieldTag::__documentation) {
19489                                return std::result::Result::Err(A::Error::duplicate_field(
19490                                    "multiple values for documentation",
19491                                ));
19492                            }
19493                            result.documentation = map
19494                                .next_value::<std::option::Option<crate::model::Documentation>>()?;
19495                        }
19496                        __FieldTag::__backend => {
19497                            if !fields.insert(__FieldTag::__backend) {
19498                                return std::result::Result::Err(A::Error::duplicate_field(
19499                                    "multiple values for backend",
19500                                ));
19501                            }
19502                            result.backend =
19503                                map.next_value::<std::option::Option<crate::model::Backend>>()?;
19504                        }
19505                        __FieldTag::__http => {
19506                            if !fields.insert(__FieldTag::__http) {
19507                                return std::result::Result::Err(A::Error::duplicate_field(
19508                                    "multiple values for http",
19509                                ));
19510                            }
19511                            result.http =
19512                                map.next_value::<std::option::Option<crate::model::Http>>()?;
19513                        }
19514                        __FieldTag::__quota => {
19515                            if !fields.insert(__FieldTag::__quota) {
19516                                return std::result::Result::Err(A::Error::duplicate_field(
19517                                    "multiple values for quota",
19518                                ));
19519                            }
19520                            result.quota =
19521                                map.next_value::<std::option::Option<crate::model::Quota>>()?;
19522                        }
19523                        __FieldTag::__authentication => {
19524                            if !fields.insert(__FieldTag::__authentication) {
19525                                return std::result::Result::Err(A::Error::duplicate_field(
19526                                    "multiple values for authentication",
19527                                ));
19528                            }
19529                            result.authentication = map
19530                                .next_value::<std::option::Option<crate::model::Authentication>>(
19531                                )?;
19532                        }
19533                        __FieldTag::__context => {
19534                            if !fields.insert(__FieldTag::__context) {
19535                                return std::result::Result::Err(A::Error::duplicate_field(
19536                                    "multiple values for context",
19537                                ));
19538                            }
19539                            result.context =
19540                                map.next_value::<std::option::Option<crate::model::Context>>()?;
19541                        }
19542                        __FieldTag::__usage => {
19543                            if !fields.insert(__FieldTag::__usage) {
19544                                return std::result::Result::Err(A::Error::duplicate_field(
19545                                    "multiple values for usage",
19546                                ));
19547                            }
19548                            result.usage =
19549                                map.next_value::<std::option::Option<crate::model::Usage>>()?;
19550                        }
19551                        __FieldTag::__endpoints => {
19552                            if !fields.insert(__FieldTag::__endpoints) {
19553                                return std::result::Result::Err(A::Error::duplicate_field(
19554                                    "multiple values for endpoints",
19555                                ));
19556                            }
19557                            result.endpoints = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Endpoint>>>()?.unwrap_or_default();
19558                        }
19559                        __FieldTag::__control => {
19560                            if !fields.insert(__FieldTag::__control) {
19561                                return std::result::Result::Err(A::Error::duplicate_field(
19562                                    "multiple values for control",
19563                                ));
19564                            }
19565                            result.control =
19566                                map.next_value::<std::option::Option<crate::model::Control>>()?;
19567                        }
19568                        __FieldTag::__logs => {
19569                            if !fields.insert(__FieldTag::__logs) {
19570                                return std::result::Result::Err(A::Error::duplicate_field(
19571                                    "multiple values for logs",
19572                                ));
19573                            }
19574                            result.logs = map.next_value::<std::option::Option<std::vec::Vec<crate::model::LogDescriptor>>>()?.unwrap_or_default();
19575                        }
19576                        __FieldTag::__metrics => {
19577                            if !fields.insert(__FieldTag::__metrics) {
19578                                return std::result::Result::Err(A::Error::duplicate_field(
19579                                    "multiple values for metrics",
19580                                ));
19581                            }
19582                            result.metrics =
19583                                map.next_value::<std::option::Option<
19584                                    std::vec::Vec<crate::model::MetricDescriptor>,
19585                                >>()?
19586                                .unwrap_or_default();
19587                        }
19588                        __FieldTag::__monitored_resources => {
19589                            if !fields.insert(__FieldTag::__monitored_resources) {
19590                                return std::result::Result::Err(A::Error::duplicate_field(
19591                                    "multiple values for monitored_resources",
19592                                ));
19593                            }
19594                            result.monitored_resources = map
19595                                .next_value::<std::option::Option<
19596                                    std::vec::Vec<crate::model::MonitoredResourceDescriptor>,
19597                                >>()?
19598                                .unwrap_or_default();
19599                        }
19600                        __FieldTag::__billing => {
19601                            if !fields.insert(__FieldTag::__billing) {
19602                                return std::result::Result::Err(A::Error::duplicate_field(
19603                                    "multiple values for billing",
19604                                ));
19605                            }
19606                            result.billing =
19607                                map.next_value::<std::option::Option<crate::model::Billing>>()?;
19608                        }
19609                        __FieldTag::__logging => {
19610                            if !fields.insert(__FieldTag::__logging) {
19611                                return std::result::Result::Err(A::Error::duplicate_field(
19612                                    "multiple values for logging",
19613                                ));
19614                            }
19615                            result.logging =
19616                                map.next_value::<std::option::Option<crate::model::Logging>>()?;
19617                        }
19618                        __FieldTag::__monitoring => {
19619                            if !fields.insert(__FieldTag::__monitoring) {
19620                                return std::result::Result::Err(A::Error::duplicate_field(
19621                                    "multiple values for monitoring",
19622                                ));
19623                            }
19624                            result.monitoring =
19625                                map.next_value::<std::option::Option<crate::model::Monitoring>>()?;
19626                        }
19627                        __FieldTag::__system_parameters => {
19628                            if !fields.insert(__FieldTag::__system_parameters) {
19629                                return std::result::Result::Err(A::Error::duplicate_field(
19630                                    "multiple values for system_parameters",
19631                                ));
19632                            }
19633                            result.system_parameters = map
19634                                .next_value::<std::option::Option<crate::model::SystemParameters>>(
19635                                )?;
19636                        }
19637                        __FieldTag::__source_info => {
19638                            if !fields.insert(__FieldTag::__source_info) {
19639                                return std::result::Result::Err(A::Error::duplicate_field(
19640                                    "multiple values for source_info",
19641                                ));
19642                            }
19643                            result.source_info =
19644                                map.next_value::<std::option::Option<crate::model::SourceInfo>>()?;
19645                        }
19646                        __FieldTag::__publishing => {
19647                            if !fields.insert(__FieldTag::__publishing) {
19648                                return std::result::Result::Err(A::Error::duplicate_field(
19649                                    "multiple values for publishing",
19650                                ));
19651                            }
19652                            result.publishing =
19653                                map.next_value::<std::option::Option<crate::model::Publishing>>()?;
19654                        }
19655                        __FieldTag::__config_version => {
19656                            if !fields.insert(__FieldTag::__config_version) {
19657                                return std::result::Result::Err(A::Error::duplicate_field(
19658                                    "multiple values for config_version",
19659                                ));
19660                            }
19661                            struct __With(std::option::Option<wkt::UInt32Value>);
19662                            impl<'de> serde::de::Deserialize<'de> for __With {
19663                                fn deserialize<D>(
19664                                    deserializer: D,
19665                                ) -> std::result::Result<Self, D::Error>
19666                                where
19667                                    D: serde::de::Deserializer<'de>,
19668                                {
19669                                    serde_with::As::< std::option::Option<wkt::internal::U32> >::deserialize(deserializer).map(__With)
19670                                }
19671                            }
19672                            result.config_version = map.next_value::<__With>()?.0;
19673                        }
19674                        __FieldTag::Unknown(key) => {
19675                            let value = map.next_value::<serde_json::Value>()?;
19676                            result._unknown_fields.insert(key, value);
19677                        }
19678                    }
19679                }
19680                std::result::Result::Ok(result)
19681            }
19682        }
19683        deserializer.deserialize_any(Visitor)
19684    }
19685}
19686
19687#[doc(hidden)]
19688impl serde::ser::Serialize for Service {
19689    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19690    where
19691        S: serde::ser::Serializer,
19692    {
19693        use serde::ser::SerializeMap;
19694        #[allow(unused_imports)]
19695        use std::option::Option::Some;
19696        let mut state = serializer.serialize_map(std::option::Option::None)?;
19697        if !self.name.is_empty() {
19698            state.serialize_entry("name", &self.name)?;
19699        }
19700        if !self.title.is_empty() {
19701            state.serialize_entry("title", &self.title)?;
19702        }
19703        if !self.producer_project_id.is_empty() {
19704            state.serialize_entry("producerProjectId", &self.producer_project_id)?;
19705        }
19706        if !self.id.is_empty() {
19707            state.serialize_entry("id", &self.id)?;
19708        }
19709        if !self.apis.is_empty() {
19710            state.serialize_entry("apis", &self.apis)?;
19711        }
19712        if !self.types.is_empty() {
19713            state.serialize_entry("types", &self.types)?;
19714        }
19715        if !self.enums.is_empty() {
19716            state.serialize_entry("enums", &self.enums)?;
19717        }
19718        if self.documentation.is_some() {
19719            state.serialize_entry("documentation", &self.documentation)?;
19720        }
19721        if self.backend.is_some() {
19722            state.serialize_entry("backend", &self.backend)?;
19723        }
19724        if self.http.is_some() {
19725            state.serialize_entry("http", &self.http)?;
19726        }
19727        if self.quota.is_some() {
19728            state.serialize_entry("quota", &self.quota)?;
19729        }
19730        if self.authentication.is_some() {
19731            state.serialize_entry("authentication", &self.authentication)?;
19732        }
19733        if self.context.is_some() {
19734            state.serialize_entry("context", &self.context)?;
19735        }
19736        if self.usage.is_some() {
19737            state.serialize_entry("usage", &self.usage)?;
19738        }
19739        if !self.endpoints.is_empty() {
19740            state.serialize_entry("endpoints", &self.endpoints)?;
19741        }
19742        if self.control.is_some() {
19743            state.serialize_entry("control", &self.control)?;
19744        }
19745        if !self.logs.is_empty() {
19746            state.serialize_entry("logs", &self.logs)?;
19747        }
19748        if !self.metrics.is_empty() {
19749            state.serialize_entry("metrics", &self.metrics)?;
19750        }
19751        if !self.monitored_resources.is_empty() {
19752            state.serialize_entry("monitoredResources", &self.monitored_resources)?;
19753        }
19754        if self.billing.is_some() {
19755            state.serialize_entry("billing", &self.billing)?;
19756        }
19757        if self.logging.is_some() {
19758            state.serialize_entry("logging", &self.logging)?;
19759        }
19760        if self.monitoring.is_some() {
19761            state.serialize_entry("monitoring", &self.monitoring)?;
19762        }
19763        if self.system_parameters.is_some() {
19764            state.serialize_entry("systemParameters", &self.system_parameters)?;
19765        }
19766        if self.source_info.is_some() {
19767            state.serialize_entry("sourceInfo", &self.source_info)?;
19768        }
19769        if self.publishing.is_some() {
19770            state.serialize_entry("publishing", &self.publishing)?;
19771        }
19772        if self.config_version.is_some() {
19773            struct __With<'a>(&'a std::option::Option<wkt::UInt32Value>);
19774            impl<'a> serde::ser::Serialize for __With<'a> {
19775                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19776                where
19777                    S: serde::ser::Serializer,
19778                {
19779                    serde_with::As::<std::option::Option<wkt::internal::U32>>::serialize(
19780                        self.0, serializer,
19781                    )
19782                }
19783            }
19784            state.serialize_entry("configVersion", &__With(&self.config_version))?;
19785        }
19786        if !self._unknown_fields.is_empty() {
19787            for (key, value) in self._unknown_fields.iter() {
19788                state.serialize_entry(key, &value)?;
19789            }
19790        }
19791        state.end()
19792    }
19793}
19794
19795/// Source information used to create a Service Config
19796#[derive(Clone, Debug, Default, PartialEq)]
19797#[non_exhaustive]
19798pub struct SourceInfo {
19799    /// All files used during config generation.
19800    pub source_files: std::vec::Vec<wkt::Any>,
19801
19802    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19803}
19804
19805impl SourceInfo {
19806    pub fn new() -> Self {
19807        std::default::Default::default()
19808    }
19809
19810    /// Sets the value of [source_files][crate::model::SourceInfo::source_files].
19811    pub fn set_source_files<T, V>(mut self, v: T) -> Self
19812    where
19813        T: std::iter::IntoIterator<Item = V>,
19814        V: std::convert::Into<wkt::Any>,
19815    {
19816        use std::iter::Iterator;
19817        self.source_files = v.into_iter().map(|i| i.into()).collect();
19818        self
19819    }
19820}
19821
19822impl wkt::message::Message for SourceInfo {
19823    fn typename() -> &'static str {
19824        "type.googleapis.com/google.api.SourceInfo"
19825    }
19826}
19827
19828#[doc(hidden)]
19829impl<'de> serde::de::Deserialize<'de> for SourceInfo {
19830    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19831    where
19832        D: serde::Deserializer<'de>,
19833    {
19834        #[allow(non_camel_case_types)]
19835        #[doc(hidden)]
19836        #[derive(PartialEq, Eq, Hash)]
19837        enum __FieldTag {
19838            __source_files,
19839            Unknown(std::string::String),
19840        }
19841        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19842            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19843            where
19844                D: serde::Deserializer<'de>,
19845            {
19846                struct Visitor;
19847                impl<'de> serde::de::Visitor<'de> for Visitor {
19848                    type Value = __FieldTag;
19849                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19850                        formatter.write_str("a field name for SourceInfo")
19851                    }
19852                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19853                    where
19854                        E: serde::de::Error,
19855                    {
19856                        use std::result::Result::Ok;
19857                        use std::string::ToString;
19858                        match value {
19859                            "sourceFiles" => Ok(__FieldTag::__source_files),
19860                            "source_files" => Ok(__FieldTag::__source_files),
19861                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19862                        }
19863                    }
19864                }
19865                deserializer.deserialize_identifier(Visitor)
19866            }
19867        }
19868        struct Visitor;
19869        impl<'de> serde::de::Visitor<'de> for Visitor {
19870            type Value = SourceInfo;
19871            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19872                formatter.write_str("struct SourceInfo")
19873            }
19874            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19875            where
19876                A: serde::de::MapAccess<'de>,
19877            {
19878                #[allow(unused_imports)]
19879                use serde::de::Error;
19880                use std::option::Option::Some;
19881                let mut fields = std::collections::HashSet::new();
19882                let mut result = Self::Value::new();
19883                while let Some(tag) = map.next_key::<__FieldTag>()? {
19884                    #[allow(clippy::match_single_binding)]
19885                    match tag {
19886                        __FieldTag::__source_files => {
19887                            if !fields.insert(__FieldTag::__source_files) {
19888                                return std::result::Result::Err(A::Error::duplicate_field(
19889                                    "multiple values for source_files",
19890                                ));
19891                            }
19892                            result.source_files = map
19893                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
19894                                .unwrap_or_default();
19895                        }
19896                        __FieldTag::Unknown(key) => {
19897                            let value = map.next_value::<serde_json::Value>()?;
19898                            result._unknown_fields.insert(key, value);
19899                        }
19900                    }
19901                }
19902                std::result::Result::Ok(result)
19903            }
19904        }
19905        deserializer.deserialize_any(Visitor)
19906    }
19907}
19908
19909#[doc(hidden)]
19910impl serde::ser::Serialize for SourceInfo {
19911    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19912    where
19913        S: serde::ser::Serializer,
19914    {
19915        use serde::ser::SerializeMap;
19916        #[allow(unused_imports)]
19917        use std::option::Option::Some;
19918        let mut state = serializer.serialize_map(std::option::Option::None)?;
19919        if !self.source_files.is_empty() {
19920            state.serialize_entry("sourceFiles", &self.source_files)?;
19921        }
19922        if !self._unknown_fields.is_empty() {
19923            for (key, value) in self._unknown_fields.iter() {
19924                state.serialize_entry(key, &value)?;
19925            }
19926        }
19927        state.end()
19928    }
19929}
19930
19931/// ### System parameter configuration
19932///
19933/// A system parameter is a special kind of parameter defined by the API
19934/// system, not by an individual API. It is typically mapped to an HTTP header
19935/// and/or a URL query parameter. This configuration specifies which methods
19936/// change the names of the system parameters.
19937#[derive(Clone, Debug, Default, PartialEq)]
19938#[non_exhaustive]
19939pub struct SystemParameters {
19940    /// Define system parameters.
19941    ///
19942    /// The parameters defined here will override the default parameters
19943    /// implemented by the system. If this field is missing from the service
19944    /// config, default system parameters will be used. Default system parameters
19945    /// and names is implementation-dependent.
19946    ///
19947    /// Example: define api key for all methods
19948    ///
19949    /// ```norust
19950    /// system_parameters
19951    ///   rules:
19952    ///     - selector: "*"
19953    ///       parameters:
19954    ///         - name: api_key
19955    ///           url_query_parameter: api_key
19956    /// ```
19957    ///
19958    /// Example: define 2 api key names for a specific method.
19959    ///
19960    /// ```norust
19961    /// system_parameters
19962    ///   rules:
19963    ///     - selector: "/ListShelves"
19964    ///       parameters:
19965    ///         - name: api_key
19966    ///           http_header: Api-Key1
19967    ///         - name: api_key
19968    ///           http_header: Api-Key2
19969    /// ```
19970    ///
19971    /// **NOTE:** All service configuration rules follow "last one wins" order.
19972    pub rules: std::vec::Vec<crate::model::SystemParameterRule>,
19973
19974    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19975}
19976
19977impl SystemParameters {
19978    pub fn new() -> Self {
19979        std::default::Default::default()
19980    }
19981
19982    /// Sets the value of [rules][crate::model::SystemParameters::rules].
19983    pub fn set_rules<T, V>(mut self, v: T) -> Self
19984    where
19985        T: std::iter::IntoIterator<Item = V>,
19986        V: std::convert::Into<crate::model::SystemParameterRule>,
19987    {
19988        use std::iter::Iterator;
19989        self.rules = v.into_iter().map(|i| i.into()).collect();
19990        self
19991    }
19992}
19993
19994impl wkt::message::Message for SystemParameters {
19995    fn typename() -> &'static str {
19996        "type.googleapis.com/google.api.SystemParameters"
19997    }
19998}
19999
20000#[doc(hidden)]
20001impl<'de> serde::de::Deserialize<'de> for SystemParameters {
20002    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20003    where
20004        D: serde::Deserializer<'de>,
20005    {
20006        #[allow(non_camel_case_types)]
20007        #[doc(hidden)]
20008        #[derive(PartialEq, Eq, Hash)]
20009        enum __FieldTag {
20010            __rules,
20011            Unknown(std::string::String),
20012        }
20013        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20014            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20015            where
20016                D: serde::Deserializer<'de>,
20017            {
20018                struct Visitor;
20019                impl<'de> serde::de::Visitor<'de> for Visitor {
20020                    type Value = __FieldTag;
20021                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20022                        formatter.write_str("a field name for SystemParameters")
20023                    }
20024                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20025                    where
20026                        E: serde::de::Error,
20027                    {
20028                        use std::result::Result::Ok;
20029                        use std::string::ToString;
20030                        match value {
20031                            "rules" => Ok(__FieldTag::__rules),
20032                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20033                        }
20034                    }
20035                }
20036                deserializer.deserialize_identifier(Visitor)
20037            }
20038        }
20039        struct Visitor;
20040        impl<'de> serde::de::Visitor<'de> for Visitor {
20041            type Value = SystemParameters;
20042            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20043                formatter.write_str("struct SystemParameters")
20044            }
20045            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20046            where
20047                A: serde::de::MapAccess<'de>,
20048            {
20049                #[allow(unused_imports)]
20050                use serde::de::Error;
20051                use std::option::Option::Some;
20052                let mut fields = std::collections::HashSet::new();
20053                let mut result = Self::Value::new();
20054                while let Some(tag) = map.next_key::<__FieldTag>()? {
20055                    #[allow(clippy::match_single_binding)]
20056                    match tag {
20057                        __FieldTag::__rules => {
20058                            if !fields.insert(__FieldTag::__rules) {
20059                                return std::result::Result::Err(A::Error::duplicate_field(
20060                                    "multiple values for rules",
20061                                ));
20062                            }
20063                            result.rules = map
20064                                .next_value::<std::option::Option<
20065                                    std::vec::Vec<crate::model::SystemParameterRule>,
20066                                >>()?
20067                                .unwrap_or_default();
20068                        }
20069                        __FieldTag::Unknown(key) => {
20070                            let value = map.next_value::<serde_json::Value>()?;
20071                            result._unknown_fields.insert(key, value);
20072                        }
20073                    }
20074                }
20075                std::result::Result::Ok(result)
20076            }
20077        }
20078        deserializer.deserialize_any(Visitor)
20079    }
20080}
20081
20082#[doc(hidden)]
20083impl serde::ser::Serialize for SystemParameters {
20084    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20085    where
20086        S: serde::ser::Serializer,
20087    {
20088        use serde::ser::SerializeMap;
20089        #[allow(unused_imports)]
20090        use std::option::Option::Some;
20091        let mut state = serializer.serialize_map(std::option::Option::None)?;
20092        if !self.rules.is_empty() {
20093            state.serialize_entry("rules", &self.rules)?;
20094        }
20095        if !self._unknown_fields.is_empty() {
20096            for (key, value) in self._unknown_fields.iter() {
20097                state.serialize_entry(key, &value)?;
20098            }
20099        }
20100        state.end()
20101    }
20102}
20103
20104/// Define a system parameter rule mapping system parameter definitions to
20105/// methods.
20106#[derive(Clone, Debug, Default, PartialEq)]
20107#[non_exhaustive]
20108pub struct SystemParameterRule {
20109    /// Selects the methods to which this rule applies. Use '*' to indicate all
20110    /// methods in all APIs.
20111    ///
20112    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
20113    /// details.
20114    ///
20115    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
20116    pub selector: std::string::String,
20117
20118    /// Define parameters. Multiple names may be defined for a parameter.
20119    /// For a given method call, only one of them should be used. If multiple
20120    /// names are used the behavior is implementation-dependent.
20121    /// If none of the specified names are present the behavior is
20122    /// parameter-dependent.
20123    pub parameters: std::vec::Vec<crate::model::SystemParameter>,
20124
20125    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20126}
20127
20128impl SystemParameterRule {
20129    pub fn new() -> Self {
20130        std::default::Default::default()
20131    }
20132
20133    /// Sets the value of [selector][crate::model::SystemParameterRule::selector].
20134    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20135        self.selector = v.into();
20136        self
20137    }
20138
20139    /// Sets the value of [parameters][crate::model::SystemParameterRule::parameters].
20140    pub fn set_parameters<T, V>(mut self, v: T) -> Self
20141    where
20142        T: std::iter::IntoIterator<Item = V>,
20143        V: std::convert::Into<crate::model::SystemParameter>,
20144    {
20145        use std::iter::Iterator;
20146        self.parameters = v.into_iter().map(|i| i.into()).collect();
20147        self
20148    }
20149}
20150
20151impl wkt::message::Message for SystemParameterRule {
20152    fn typename() -> &'static str {
20153        "type.googleapis.com/google.api.SystemParameterRule"
20154    }
20155}
20156
20157#[doc(hidden)]
20158impl<'de> serde::de::Deserialize<'de> for SystemParameterRule {
20159    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20160    where
20161        D: serde::Deserializer<'de>,
20162    {
20163        #[allow(non_camel_case_types)]
20164        #[doc(hidden)]
20165        #[derive(PartialEq, Eq, Hash)]
20166        enum __FieldTag {
20167            __selector,
20168            __parameters,
20169            Unknown(std::string::String),
20170        }
20171        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20172            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20173            where
20174                D: serde::Deserializer<'de>,
20175            {
20176                struct Visitor;
20177                impl<'de> serde::de::Visitor<'de> for Visitor {
20178                    type Value = __FieldTag;
20179                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20180                        formatter.write_str("a field name for SystemParameterRule")
20181                    }
20182                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20183                    where
20184                        E: serde::de::Error,
20185                    {
20186                        use std::result::Result::Ok;
20187                        use std::string::ToString;
20188                        match value {
20189                            "selector" => Ok(__FieldTag::__selector),
20190                            "parameters" => Ok(__FieldTag::__parameters),
20191                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20192                        }
20193                    }
20194                }
20195                deserializer.deserialize_identifier(Visitor)
20196            }
20197        }
20198        struct Visitor;
20199        impl<'de> serde::de::Visitor<'de> for Visitor {
20200            type Value = SystemParameterRule;
20201            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20202                formatter.write_str("struct SystemParameterRule")
20203            }
20204            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20205            where
20206                A: serde::de::MapAccess<'de>,
20207            {
20208                #[allow(unused_imports)]
20209                use serde::de::Error;
20210                use std::option::Option::Some;
20211                let mut fields = std::collections::HashSet::new();
20212                let mut result = Self::Value::new();
20213                while let Some(tag) = map.next_key::<__FieldTag>()? {
20214                    #[allow(clippy::match_single_binding)]
20215                    match tag {
20216                        __FieldTag::__selector => {
20217                            if !fields.insert(__FieldTag::__selector) {
20218                                return std::result::Result::Err(A::Error::duplicate_field(
20219                                    "multiple values for selector",
20220                                ));
20221                            }
20222                            result.selector = map
20223                                .next_value::<std::option::Option<std::string::String>>()?
20224                                .unwrap_or_default();
20225                        }
20226                        __FieldTag::__parameters => {
20227                            if !fields.insert(__FieldTag::__parameters) {
20228                                return std::result::Result::Err(A::Error::duplicate_field(
20229                                    "multiple values for parameters",
20230                                ));
20231                            }
20232                            result.parameters =
20233                                map.next_value::<std::option::Option<
20234                                    std::vec::Vec<crate::model::SystemParameter>,
20235                                >>()?
20236                                .unwrap_or_default();
20237                        }
20238                        __FieldTag::Unknown(key) => {
20239                            let value = map.next_value::<serde_json::Value>()?;
20240                            result._unknown_fields.insert(key, value);
20241                        }
20242                    }
20243                }
20244                std::result::Result::Ok(result)
20245            }
20246        }
20247        deserializer.deserialize_any(Visitor)
20248    }
20249}
20250
20251#[doc(hidden)]
20252impl serde::ser::Serialize for SystemParameterRule {
20253    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20254    where
20255        S: serde::ser::Serializer,
20256    {
20257        use serde::ser::SerializeMap;
20258        #[allow(unused_imports)]
20259        use std::option::Option::Some;
20260        let mut state = serializer.serialize_map(std::option::Option::None)?;
20261        if !self.selector.is_empty() {
20262            state.serialize_entry("selector", &self.selector)?;
20263        }
20264        if !self.parameters.is_empty() {
20265            state.serialize_entry("parameters", &self.parameters)?;
20266        }
20267        if !self._unknown_fields.is_empty() {
20268            for (key, value) in self._unknown_fields.iter() {
20269                state.serialize_entry(key, &value)?;
20270            }
20271        }
20272        state.end()
20273    }
20274}
20275
20276/// Define a parameter's name and location. The parameter may be passed as either
20277/// an HTTP header or a URL query parameter, and if both are passed the behavior
20278/// is implementation-dependent.
20279#[derive(Clone, Debug, Default, PartialEq)]
20280#[non_exhaustive]
20281pub struct SystemParameter {
20282    /// Define the name of the parameter, such as "api_key" . It is case sensitive.
20283    pub name: std::string::String,
20284
20285    /// Define the HTTP header name to use for the parameter. It is case
20286    /// insensitive.
20287    pub http_header: std::string::String,
20288
20289    /// Define the URL query parameter name to use for the parameter. It is case
20290    /// sensitive.
20291    pub url_query_parameter: std::string::String,
20292
20293    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20294}
20295
20296impl SystemParameter {
20297    pub fn new() -> Self {
20298        std::default::Default::default()
20299    }
20300
20301    /// Sets the value of [name][crate::model::SystemParameter::name].
20302    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20303        self.name = v.into();
20304        self
20305    }
20306
20307    /// Sets the value of [http_header][crate::model::SystemParameter::http_header].
20308    pub fn set_http_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20309        self.http_header = v.into();
20310        self
20311    }
20312
20313    /// Sets the value of [url_query_parameter][crate::model::SystemParameter::url_query_parameter].
20314    pub fn set_url_query_parameter<T: std::convert::Into<std::string::String>>(
20315        mut self,
20316        v: T,
20317    ) -> Self {
20318        self.url_query_parameter = v.into();
20319        self
20320    }
20321}
20322
20323impl wkt::message::Message for SystemParameter {
20324    fn typename() -> &'static str {
20325        "type.googleapis.com/google.api.SystemParameter"
20326    }
20327}
20328
20329#[doc(hidden)]
20330impl<'de> serde::de::Deserialize<'de> for SystemParameter {
20331    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20332    where
20333        D: serde::Deserializer<'de>,
20334    {
20335        #[allow(non_camel_case_types)]
20336        #[doc(hidden)]
20337        #[derive(PartialEq, Eq, Hash)]
20338        enum __FieldTag {
20339            __name,
20340            __http_header,
20341            __url_query_parameter,
20342            Unknown(std::string::String),
20343        }
20344        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20345            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20346            where
20347                D: serde::Deserializer<'de>,
20348            {
20349                struct Visitor;
20350                impl<'de> serde::de::Visitor<'de> for Visitor {
20351                    type Value = __FieldTag;
20352                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20353                        formatter.write_str("a field name for SystemParameter")
20354                    }
20355                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20356                    where
20357                        E: serde::de::Error,
20358                    {
20359                        use std::result::Result::Ok;
20360                        use std::string::ToString;
20361                        match value {
20362                            "name" => Ok(__FieldTag::__name),
20363                            "httpHeader" => Ok(__FieldTag::__http_header),
20364                            "http_header" => Ok(__FieldTag::__http_header),
20365                            "urlQueryParameter" => Ok(__FieldTag::__url_query_parameter),
20366                            "url_query_parameter" => Ok(__FieldTag::__url_query_parameter),
20367                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20368                        }
20369                    }
20370                }
20371                deserializer.deserialize_identifier(Visitor)
20372            }
20373        }
20374        struct Visitor;
20375        impl<'de> serde::de::Visitor<'de> for Visitor {
20376            type Value = SystemParameter;
20377            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20378                formatter.write_str("struct SystemParameter")
20379            }
20380            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20381            where
20382                A: serde::de::MapAccess<'de>,
20383            {
20384                #[allow(unused_imports)]
20385                use serde::de::Error;
20386                use std::option::Option::Some;
20387                let mut fields = std::collections::HashSet::new();
20388                let mut result = Self::Value::new();
20389                while let Some(tag) = map.next_key::<__FieldTag>()? {
20390                    #[allow(clippy::match_single_binding)]
20391                    match tag {
20392                        __FieldTag::__name => {
20393                            if !fields.insert(__FieldTag::__name) {
20394                                return std::result::Result::Err(A::Error::duplicate_field(
20395                                    "multiple values for name",
20396                                ));
20397                            }
20398                            result.name = map
20399                                .next_value::<std::option::Option<std::string::String>>()?
20400                                .unwrap_or_default();
20401                        }
20402                        __FieldTag::__http_header => {
20403                            if !fields.insert(__FieldTag::__http_header) {
20404                                return std::result::Result::Err(A::Error::duplicate_field(
20405                                    "multiple values for http_header",
20406                                ));
20407                            }
20408                            result.http_header = map
20409                                .next_value::<std::option::Option<std::string::String>>()?
20410                                .unwrap_or_default();
20411                        }
20412                        __FieldTag::__url_query_parameter => {
20413                            if !fields.insert(__FieldTag::__url_query_parameter) {
20414                                return std::result::Result::Err(A::Error::duplicate_field(
20415                                    "multiple values for url_query_parameter",
20416                                ));
20417                            }
20418                            result.url_query_parameter = map
20419                                .next_value::<std::option::Option<std::string::String>>()?
20420                                .unwrap_or_default();
20421                        }
20422                        __FieldTag::Unknown(key) => {
20423                            let value = map.next_value::<serde_json::Value>()?;
20424                            result._unknown_fields.insert(key, value);
20425                        }
20426                    }
20427                }
20428                std::result::Result::Ok(result)
20429            }
20430        }
20431        deserializer.deserialize_any(Visitor)
20432    }
20433}
20434
20435#[doc(hidden)]
20436impl serde::ser::Serialize for SystemParameter {
20437    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20438    where
20439        S: serde::ser::Serializer,
20440    {
20441        use serde::ser::SerializeMap;
20442        #[allow(unused_imports)]
20443        use std::option::Option::Some;
20444        let mut state = serializer.serialize_map(std::option::Option::None)?;
20445        if !self.name.is_empty() {
20446            state.serialize_entry("name", &self.name)?;
20447        }
20448        if !self.http_header.is_empty() {
20449            state.serialize_entry("httpHeader", &self.http_header)?;
20450        }
20451        if !self.url_query_parameter.is_empty() {
20452            state.serialize_entry("urlQueryParameter", &self.url_query_parameter)?;
20453        }
20454        if !self._unknown_fields.is_empty() {
20455            for (key, value) in self._unknown_fields.iter() {
20456                state.serialize_entry(key, &value)?;
20457            }
20458        }
20459        state.end()
20460    }
20461}
20462
20463/// Configuration controlling usage of a service.
20464#[derive(Clone, Debug, Default, PartialEq)]
20465#[non_exhaustive]
20466pub struct Usage {
20467    /// Requirements that must be satisfied before a consumer project can use the
20468    /// service. Each requirement is of the form <service.name>/\<requirement-id\>;
20469    /// for example 'serviceusage.googleapis.com/billing-enabled'.
20470    ///
20471    /// For Google APIs, a Terms of Service requirement must be included here.
20472    /// Google Cloud APIs must include "serviceusage.googleapis.com/tos/cloud".
20473    /// Other Google APIs should include
20474    /// "serviceusage.googleapis.com/tos/universal". Additional ToS can be
20475    /// included based on the business needs.
20476    pub requirements: std::vec::Vec<std::string::String>,
20477
20478    /// A list of usage rules that apply to individual API methods.
20479    ///
20480    /// **NOTE:** All service configuration rules follow "last one wins" order.
20481    pub rules: std::vec::Vec<crate::model::UsageRule>,
20482
20483    /// The full resource name of a channel used for sending notifications to the
20484    /// service producer.
20485    ///
20486    /// Google Service Management currently only supports
20487    /// [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification
20488    /// channel. To use Google Cloud Pub/Sub as the channel, this must be the name
20489    /// of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format
20490    /// documented in <https://cloud.google.com/pubsub/docs/overview>.
20491    pub producer_notification_channel: std::string::String,
20492
20493    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20494}
20495
20496impl Usage {
20497    pub fn new() -> Self {
20498        std::default::Default::default()
20499    }
20500
20501    /// Sets the value of [requirements][crate::model::Usage::requirements].
20502    pub fn set_requirements<T, V>(mut self, v: T) -> Self
20503    where
20504        T: std::iter::IntoIterator<Item = V>,
20505        V: std::convert::Into<std::string::String>,
20506    {
20507        use std::iter::Iterator;
20508        self.requirements = v.into_iter().map(|i| i.into()).collect();
20509        self
20510    }
20511
20512    /// Sets the value of [rules][crate::model::Usage::rules].
20513    pub fn set_rules<T, V>(mut self, v: T) -> Self
20514    where
20515        T: std::iter::IntoIterator<Item = V>,
20516        V: std::convert::Into<crate::model::UsageRule>,
20517    {
20518        use std::iter::Iterator;
20519        self.rules = v.into_iter().map(|i| i.into()).collect();
20520        self
20521    }
20522
20523    /// Sets the value of [producer_notification_channel][crate::model::Usage::producer_notification_channel].
20524    pub fn set_producer_notification_channel<T: std::convert::Into<std::string::String>>(
20525        mut self,
20526        v: T,
20527    ) -> Self {
20528        self.producer_notification_channel = v.into();
20529        self
20530    }
20531}
20532
20533impl wkt::message::Message for Usage {
20534    fn typename() -> &'static str {
20535        "type.googleapis.com/google.api.Usage"
20536    }
20537}
20538
20539#[doc(hidden)]
20540impl<'de> serde::de::Deserialize<'de> for Usage {
20541    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20542    where
20543        D: serde::Deserializer<'de>,
20544    {
20545        #[allow(non_camel_case_types)]
20546        #[doc(hidden)]
20547        #[derive(PartialEq, Eq, Hash)]
20548        enum __FieldTag {
20549            __requirements,
20550            __rules,
20551            __producer_notification_channel,
20552            Unknown(std::string::String),
20553        }
20554        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20555            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20556            where
20557                D: serde::Deserializer<'de>,
20558            {
20559                struct Visitor;
20560                impl<'de> serde::de::Visitor<'de> for Visitor {
20561                    type Value = __FieldTag;
20562                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20563                        formatter.write_str("a field name for Usage")
20564                    }
20565                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20566                    where
20567                        E: serde::de::Error,
20568                    {
20569                        use std::result::Result::Ok;
20570                        use std::string::ToString;
20571                        match value {
20572                            "requirements" => Ok(__FieldTag::__requirements),
20573                            "rules" => Ok(__FieldTag::__rules),
20574                            "producerNotificationChannel" => {
20575                                Ok(__FieldTag::__producer_notification_channel)
20576                            }
20577                            "producer_notification_channel" => {
20578                                Ok(__FieldTag::__producer_notification_channel)
20579                            }
20580                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20581                        }
20582                    }
20583                }
20584                deserializer.deserialize_identifier(Visitor)
20585            }
20586        }
20587        struct Visitor;
20588        impl<'de> serde::de::Visitor<'de> for Visitor {
20589            type Value = Usage;
20590            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20591                formatter.write_str("struct Usage")
20592            }
20593            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20594            where
20595                A: serde::de::MapAccess<'de>,
20596            {
20597                #[allow(unused_imports)]
20598                use serde::de::Error;
20599                use std::option::Option::Some;
20600                let mut fields = std::collections::HashSet::new();
20601                let mut result = Self::Value::new();
20602                while let Some(tag) = map.next_key::<__FieldTag>()? {
20603                    #[allow(clippy::match_single_binding)]
20604                    match tag {
20605                        __FieldTag::__requirements => {
20606                            if !fields.insert(__FieldTag::__requirements) {
20607                                return std::result::Result::Err(A::Error::duplicate_field(
20608                                    "multiple values for requirements",
20609                                ));
20610                            }
20611                            result.requirements = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
20612                        }
20613                        __FieldTag::__rules => {
20614                            if !fields.insert(__FieldTag::__rules) {
20615                                return std::result::Result::Err(A::Error::duplicate_field(
20616                                    "multiple values for rules",
20617                                ));
20618                            }
20619                            result.rules = map.next_value::<std::option::Option<std::vec::Vec<crate::model::UsageRule>>>()?.unwrap_or_default();
20620                        }
20621                        __FieldTag::__producer_notification_channel => {
20622                            if !fields.insert(__FieldTag::__producer_notification_channel) {
20623                                return std::result::Result::Err(A::Error::duplicate_field(
20624                                    "multiple values for producer_notification_channel",
20625                                ));
20626                            }
20627                            result.producer_notification_channel = map
20628                                .next_value::<std::option::Option<std::string::String>>()?
20629                                .unwrap_or_default();
20630                        }
20631                        __FieldTag::Unknown(key) => {
20632                            let value = map.next_value::<serde_json::Value>()?;
20633                            result._unknown_fields.insert(key, value);
20634                        }
20635                    }
20636                }
20637                std::result::Result::Ok(result)
20638            }
20639        }
20640        deserializer.deserialize_any(Visitor)
20641    }
20642}
20643
20644#[doc(hidden)]
20645impl serde::ser::Serialize for Usage {
20646    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20647    where
20648        S: serde::ser::Serializer,
20649    {
20650        use serde::ser::SerializeMap;
20651        #[allow(unused_imports)]
20652        use std::option::Option::Some;
20653        let mut state = serializer.serialize_map(std::option::Option::None)?;
20654        if !self.requirements.is_empty() {
20655            state.serialize_entry("requirements", &self.requirements)?;
20656        }
20657        if !self.rules.is_empty() {
20658            state.serialize_entry("rules", &self.rules)?;
20659        }
20660        if !self.producer_notification_channel.is_empty() {
20661            state.serialize_entry(
20662                "producerNotificationChannel",
20663                &self.producer_notification_channel,
20664            )?;
20665        }
20666        if !self._unknown_fields.is_empty() {
20667            for (key, value) in self._unknown_fields.iter() {
20668                state.serialize_entry(key, &value)?;
20669            }
20670        }
20671        state.end()
20672    }
20673}
20674
20675/// Usage configuration rules for the service.
20676///
20677/// NOTE: Under development.
20678///
20679/// Use this rule to configure unregistered calls for the service. Unregistered
20680/// calls are calls that do not contain consumer project identity.
20681/// (Example: calls that do not contain an API key).
20682/// By default, API methods do not allow unregistered calls, and each method call
20683/// must be identified by a consumer project identity. Use this rule to
20684/// allow/disallow unregistered calls.
20685///
20686/// Example of an API that wants to allow unregistered calls for entire service.
20687///
20688/// ```norust
20689/// usage:
20690///   rules:
20691///   - selector: "*"
20692///     allow_unregistered_calls: true
20693/// ```
20694///
20695/// Example of a method that wants to allow unregistered calls.
20696///
20697/// ```norust
20698/// usage:
20699///   rules:
20700///   - selector: "google.example.library.v1.LibraryService.CreateBook"
20701///     allow_unregistered_calls: true
20702/// ```
20703#[derive(Clone, Debug, Default, PartialEq)]
20704#[non_exhaustive]
20705pub struct UsageRule {
20706    /// Selects the methods to which this rule applies. Use '*' to indicate all
20707    /// methods in all APIs.
20708    ///
20709    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
20710    /// details.
20711    ///
20712    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
20713    pub selector: std::string::String,
20714
20715    /// If true, the selected method allows unregistered calls, e.g. calls
20716    /// that don't identify any user or application.
20717    pub allow_unregistered_calls: bool,
20718
20719    /// If true, the selected method should skip service control and the control
20720    /// plane features, such as quota and billing, will not be available.
20721    /// This flag is used by Google Cloud Endpoints to bypass checks for internal
20722    /// methods, such as service health check methods.
20723    pub skip_service_control: bool,
20724
20725    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20726}
20727
20728impl UsageRule {
20729    pub fn new() -> Self {
20730        std::default::Default::default()
20731    }
20732
20733    /// Sets the value of [selector][crate::model::UsageRule::selector].
20734    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20735        self.selector = v.into();
20736        self
20737    }
20738
20739    /// Sets the value of [allow_unregistered_calls][crate::model::UsageRule::allow_unregistered_calls].
20740    pub fn set_allow_unregistered_calls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
20741        self.allow_unregistered_calls = v.into();
20742        self
20743    }
20744
20745    /// Sets the value of [skip_service_control][crate::model::UsageRule::skip_service_control].
20746    pub fn set_skip_service_control<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
20747        self.skip_service_control = v.into();
20748        self
20749    }
20750}
20751
20752impl wkt::message::Message for UsageRule {
20753    fn typename() -> &'static str {
20754        "type.googleapis.com/google.api.UsageRule"
20755    }
20756}
20757
20758#[doc(hidden)]
20759impl<'de> serde::de::Deserialize<'de> for UsageRule {
20760    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20761    where
20762        D: serde::Deserializer<'de>,
20763    {
20764        #[allow(non_camel_case_types)]
20765        #[doc(hidden)]
20766        #[derive(PartialEq, Eq, Hash)]
20767        enum __FieldTag {
20768            __selector,
20769            __allow_unregistered_calls,
20770            __skip_service_control,
20771            Unknown(std::string::String),
20772        }
20773        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20774            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20775            where
20776                D: serde::Deserializer<'de>,
20777            {
20778                struct Visitor;
20779                impl<'de> serde::de::Visitor<'de> for Visitor {
20780                    type Value = __FieldTag;
20781                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20782                        formatter.write_str("a field name for UsageRule")
20783                    }
20784                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20785                    where
20786                        E: serde::de::Error,
20787                    {
20788                        use std::result::Result::Ok;
20789                        use std::string::ToString;
20790                        match value {
20791                            "selector" => Ok(__FieldTag::__selector),
20792                            "allowUnregisteredCalls" => Ok(__FieldTag::__allow_unregistered_calls),
20793                            "allow_unregistered_calls" => {
20794                                Ok(__FieldTag::__allow_unregistered_calls)
20795                            }
20796                            "skipServiceControl" => Ok(__FieldTag::__skip_service_control),
20797                            "skip_service_control" => Ok(__FieldTag::__skip_service_control),
20798                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20799                        }
20800                    }
20801                }
20802                deserializer.deserialize_identifier(Visitor)
20803            }
20804        }
20805        struct Visitor;
20806        impl<'de> serde::de::Visitor<'de> for Visitor {
20807            type Value = UsageRule;
20808            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20809                formatter.write_str("struct UsageRule")
20810            }
20811            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20812            where
20813                A: serde::de::MapAccess<'de>,
20814            {
20815                #[allow(unused_imports)]
20816                use serde::de::Error;
20817                use std::option::Option::Some;
20818                let mut fields = std::collections::HashSet::new();
20819                let mut result = Self::Value::new();
20820                while let Some(tag) = map.next_key::<__FieldTag>()? {
20821                    #[allow(clippy::match_single_binding)]
20822                    match tag {
20823                        __FieldTag::__selector => {
20824                            if !fields.insert(__FieldTag::__selector) {
20825                                return std::result::Result::Err(A::Error::duplicate_field(
20826                                    "multiple values for selector",
20827                                ));
20828                            }
20829                            result.selector = map
20830                                .next_value::<std::option::Option<std::string::String>>()?
20831                                .unwrap_or_default();
20832                        }
20833                        __FieldTag::__allow_unregistered_calls => {
20834                            if !fields.insert(__FieldTag::__allow_unregistered_calls) {
20835                                return std::result::Result::Err(A::Error::duplicate_field(
20836                                    "multiple values for allow_unregistered_calls",
20837                                ));
20838                            }
20839                            result.allow_unregistered_calls = map
20840                                .next_value::<std::option::Option<bool>>()?
20841                                .unwrap_or_default();
20842                        }
20843                        __FieldTag::__skip_service_control => {
20844                            if !fields.insert(__FieldTag::__skip_service_control) {
20845                                return std::result::Result::Err(A::Error::duplicate_field(
20846                                    "multiple values for skip_service_control",
20847                                ));
20848                            }
20849                            result.skip_service_control = map
20850                                .next_value::<std::option::Option<bool>>()?
20851                                .unwrap_or_default();
20852                        }
20853                        __FieldTag::Unknown(key) => {
20854                            let value = map.next_value::<serde_json::Value>()?;
20855                            result._unknown_fields.insert(key, value);
20856                        }
20857                    }
20858                }
20859                std::result::Result::Ok(result)
20860            }
20861        }
20862        deserializer.deserialize_any(Visitor)
20863    }
20864}
20865
20866#[doc(hidden)]
20867impl serde::ser::Serialize for UsageRule {
20868    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20869    where
20870        S: serde::ser::Serializer,
20871    {
20872        use serde::ser::SerializeMap;
20873        #[allow(unused_imports)]
20874        use std::option::Option::Some;
20875        let mut state = serializer.serialize_map(std::option::Option::None)?;
20876        if !self.selector.is_empty() {
20877            state.serialize_entry("selector", &self.selector)?;
20878        }
20879        if !wkt::internal::is_default(&self.allow_unregistered_calls) {
20880            state.serialize_entry("allowUnregisteredCalls", &self.allow_unregistered_calls)?;
20881        }
20882        if !wkt::internal::is_default(&self.skip_service_control) {
20883            state.serialize_entry("skipServiceControl", &self.skip_service_control)?;
20884        }
20885        if !self._unknown_fields.is_empty() {
20886            for (key, value) in self._unknown_fields.iter() {
20887                state.serialize_entry(key, &value)?;
20888            }
20889        }
20890        state.end()
20891    }
20892}
20893
20894/// `Visibility` restricts service consumer's access to service elements,
20895/// such as whether an application can call a visibility-restricted method.
20896/// The restriction is expressed by applying visibility labels on service
20897/// elements. The visibility labels are elsewhere linked to service consumers.
20898///
20899/// A service can define multiple visibility labels, but a service consumer
20900/// should be granted at most one visibility label. Multiple visibility
20901/// labels for a single service consumer are not supported.
20902///
20903/// If an element and all its parents have no visibility label, its visibility
20904/// is unconditionally granted.
20905///
20906/// Example:
20907///
20908/// ```norust
20909/// visibility:
20910///   rules:
20911///   - selector: google.calendar.Calendar.EnhancedSearch
20912///     restriction: PREVIEW
20913///   - selector: google.calendar.Calendar.Delegate
20914///     restriction: INTERNAL
20915/// ```
20916///
20917/// Here, all methods are publicly visible except for the restricted methods
20918/// EnhancedSearch and Delegate.
20919#[derive(Clone, Debug, Default, PartialEq)]
20920#[non_exhaustive]
20921pub struct Visibility {
20922    /// A list of visibility rules that apply to individual API elements.
20923    ///
20924    /// **NOTE:** All service configuration rules follow "last one wins" order.
20925    pub rules: std::vec::Vec<crate::model::VisibilityRule>,
20926
20927    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20928}
20929
20930impl Visibility {
20931    pub fn new() -> Self {
20932        std::default::Default::default()
20933    }
20934
20935    /// Sets the value of [rules][crate::model::Visibility::rules].
20936    pub fn set_rules<T, V>(mut self, v: T) -> Self
20937    where
20938        T: std::iter::IntoIterator<Item = V>,
20939        V: std::convert::Into<crate::model::VisibilityRule>,
20940    {
20941        use std::iter::Iterator;
20942        self.rules = v.into_iter().map(|i| i.into()).collect();
20943        self
20944    }
20945}
20946
20947impl wkt::message::Message for Visibility {
20948    fn typename() -> &'static str {
20949        "type.googleapis.com/google.api.Visibility"
20950    }
20951}
20952
20953#[doc(hidden)]
20954impl<'de> serde::de::Deserialize<'de> for Visibility {
20955    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20956    where
20957        D: serde::Deserializer<'de>,
20958    {
20959        #[allow(non_camel_case_types)]
20960        #[doc(hidden)]
20961        #[derive(PartialEq, Eq, Hash)]
20962        enum __FieldTag {
20963            __rules,
20964            Unknown(std::string::String),
20965        }
20966        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20967            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20968            where
20969                D: serde::Deserializer<'de>,
20970            {
20971                struct Visitor;
20972                impl<'de> serde::de::Visitor<'de> for Visitor {
20973                    type Value = __FieldTag;
20974                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20975                        formatter.write_str("a field name for Visibility")
20976                    }
20977                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20978                    where
20979                        E: serde::de::Error,
20980                    {
20981                        use std::result::Result::Ok;
20982                        use std::string::ToString;
20983                        match value {
20984                            "rules" => Ok(__FieldTag::__rules),
20985                            _ => Ok(__FieldTag::Unknown(value.to_string())),
20986                        }
20987                    }
20988                }
20989                deserializer.deserialize_identifier(Visitor)
20990            }
20991        }
20992        struct Visitor;
20993        impl<'de> serde::de::Visitor<'de> for Visitor {
20994            type Value = Visibility;
20995            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20996                formatter.write_str("struct Visibility")
20997            }
20998            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20999            where
21000                A: serde::de::MapAccess<'de>,
21001            {
21002                #[allow(unused_imports)]
21003                use serde::de::Error;
21004                use std::option::Option::Some;
21005                let mut fields = std::collections::HashSet::new();
21006                let mut result = Self::Value::new();
21007                while let Some(tag) = map.next_key::<__FieldTag>()? {
21008                    #[allow(clippy::match_single_binding)]
21009                    match tag {
21010                        __FieldTag::__rules => {
21011                            if !fields.insert(__FieldTag::__rules) {
21012                                return std::result::Result::Err(A::Error::duplicate_field(
21013                                    "multiple values for rules",
21014                                ));
21015                            }
21016                            result.rules =
21017                                map.next_value::<std::option::Option<
21018                                    std::vec::Vec<crate::model::VisibilityRule>,
21019                                >>()?
21020                                .unwrap_or_default();
21021                        }
21022                        __FieldTag::Unknown(key) => {
21023                            let value = map.next_value::<serde_json::Value>()?;
21024                            result._unknown_fields.insert(key, value);
21025                        }
21026                    }
21027                }
21028                std::result::Result::Ok(result)
21029            }
21030        }
21031        deserializer.deserialize_any(Visitor)
21032    }
21033}
21034
21035#[doc(hidden)]
21036impl serde::ser::Serialize for Visibility {
21037    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21038    where
21039        S: serde::ser::Serializer,
21040    {
21041        use serde::ser::SerializeMap;
21042        #[allow(unused_imports)]
21043        use std::option::Option::Some;
21044        let mut state = serializer.serialize_map(std::option::Option::None)?;
21045        if !self.rules.is_empty() {
21046            state.serialize_entry("rules", &self.rules)?;
21047        }
21048        if !self._unknown_fields.is_empty() {
21049            for (key, value) in self._unknown_fields.iter() {
21050                state.serialize_entry(key, &value)?;
21051            }
21052        }
21053        state.end()
21054    }
21055}
21056
21057/// A visibility rule provides visibility configuration for an individual API
21058/// element.
21059#[derive(Clone, Debug, Default, PartialEq)]
21060#[non_exhaustive]
21061pub struct VisibilityRule {
21062    /// Selects methods, messages, fields, enums, etc. to which this rule applies.
21063    ///
21064    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
21065    /// details.
21066    ///
21067    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
21068    pub selector: std::string::String,
21069
21070    /// A comma-separated list of visibility labels that apply to the `selector`.
21071    /// Any of the listed labels can be used to grant the visibility.
21072    ///
21073    /// If a rule has multiple labels, removing one of the labels but not all of
21074    /// them can break clients.
21075    ///
21076    /// Example:
21077    ///
21078    /// ```norust
21079    /// visibility:
21080    ///   rules:
21081    ///   - selector: google.calendar.Calendar.EnhancedSearch
21082    ///     restriction: INTERNAL, PREVIEW
21083    /// ```
21084    ///
21085    /// Removing INTERNAL from this restriction will break clients that rely on
21086    /// this method and only had access to it through INTERNAL.
21087    pub restriction: std::string::String,
21088
21089    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
21090}
21091
21092impl VisibilityRule {
21093    pub fn new() -> Self {
21094        std::default::Default::default()
21095    }
21096
21097    /// Sets the value of [selector][crate::model::VisibilityRule::selector].
21098    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21099        self.selector = v.into();
21100        self
21101    }
21102
21103    /// Sets the value of [restriction][crate::model::VisibilityRule::restriction].
21104    pub fn set_restriction<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
21105        self.restriction = v.into();
21106        self
21107    }
21108}
21109
21110impl wkt::message::Message for VisibilityRule {
21111    fn typename() -> &'static str {
21112        "type.googleapis.com/google.api.VisibilityRule"
21113    }
21114}
21115
21116#[doc(hidden)]
21117impl<'de> serde::de::Deserialize<'de> for VisibilityRule {
21118    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21119    where
21120        D: serde::Deserializer<'de>,
21121    {
21122        #[allow(non_camel_case_types)]
21123        #[doc(hidden)]
21124        #[derive(PartialEq, Eq, Hash)]
21125        enum __FieldTag {
21126            __selector,
21127            __restriction,
21128            Unknown(std::string::String),
21129        }
21130        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
21131            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21132            where
21133                D: serde::Deserializer<'de>,
21134            {
21135                struct Visitor;
21136                impl<'de> serde::de::Visitor<'de> for Visitor {
21137                    type Value = __FieldTag;
21138                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21139                        formatter.write_str("a field name for VisibilityRule")
21140                    }
21141                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
21142                    where
21143                        E: serde::de::Error,
21144                    {
21145                        use std::result::Result::Ok;
21146                        use std::string::ToString;
21147                        match value {
21148                            "selector" => Ok(__FieldTag::__selector),
21149                            "restriction" => Ok(__FieldTag::__restriction),
21150                            _ => Ok(__FieldTag::Unknown(value.to_string())),
21151                        }
21152                    }
21153                }
21154                deserializer.deserialize_identifier(Visitor)
21155            }
21156        }
21157        struct Visitor;
21158        impl<'de> serde::de::Visitor<'de> for Visitor {
21159            type Value = VisibilityRule;
21160            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
21161                formatter.write_str("struct VisibilityRule")
21162            }
21163            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
21164            where
21165                A: serde::de::MapAccess<'de>,
21166            {
21167                #[allow(unused_imports)]
21168                use serde::de::Error;
21169                use std::option::Option::Some;
21170                let mut fields = std::collections::HashSet::new();
21171                let mut result = Self::Value::new();
21172                while let Some(tag) = map.next_key::<__FieldTag>()? {
21173                    #[allow(clippy::match_single_binding)]
21174                    match tag {
21175                        __FieldTag::__selector => {
21176                            if !fields.insert(__FieldTag::__selector) {
21177                                return std::result::Result::Err(A::Error::duplicate_field(
21178                                    "multiple values for selector",
21179                                ));
21180                            }
21181                            result.selector = map
21182                                .next_value::<std::option::Option<std::string::String>>()?
21183                                .unwrap_or_default();
21184                        }
21185                        __FieldTag::__restriction => {
21186                            if !fields.insert(__FieldTag::__restriction) {
21187                                return std::result::Result::Err(A::Error::duplicate_field(
21188                                    "multiple values for restriction",
21189                                ));
21190                            }
21191                            result.restriction = map
21192                                .next_value::<std::option::Option<std::string::String>>()?
21193                                .unwrap_or_default();
21194                        }
21195                        __FieldTag::Unknown(key) => {
21196                            let value = map.next_value::<serde_json::Value>()?;
21197                            result._unknown_fields.insert(key, value);
21198                        }
21199                    }
21200                }
21201                std::result::Result::Ok(result)
21202            }
21203        }
21204        deserializer.deserialize_any(Visitor)
21205    }
21206}
21207
21208#[doc(hidden)]
21209impl serde::ser::Serialize for VisibilityRule {
21210    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21211    where
21212        S: serde::ser::Serializer,
21213    {
21214        use serde::ser::SerializeMap;
21215        #[allow(unused_imports)]
21216        use std::option::Option::Some;
21217        let mut state = serializer.serialize_map(std::option::Option::None)?;
21218        if !self.selector.is_empty() {
21219            state.serialize_entry("selector", &self.selector)?;
21220        }
21221        if !self.restriction.is_empty() {
21222            state.serialize_entry("restriction", &self.restriction)?;
21223        }
21224        if !self._unknown_fields.is_empty() {
21225            for (key, value) in self._unknown_fields.iter() {
21226                state.serialize_entry(key, &value)?;
21227            }
21228        }
21229        state.end()
21230    }
21231}
21232
21233/// The organization for which the client libraries are being published.
21234/// Affects the url where generated docs are published, etc.
21235///
21236/// # Working with unknown values
21237///
21238/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
21239/// additional enum variants at any time. Adding new variants is not considered
21240/// a breaking change. Applications should write their code in anticipation of:
21241///
21242/// - New values appearing in future releases of the client library, **and**
21243/// - New values received dynamically, without application changes.
21244///
21245/// Please consult the [Working with enums] section in the user guide for some
21246/// guidelines.
21247///
21248/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
21249#[derive(Clone, Debug, PartialEq)]
21250#[non_exhaustive]
21251pub enum ClientLibraryOrganization {
21252    /// Not useful.
21253    Unspecified,
21254    /// Google Cloud Platform Org.
21255    Cloud,
21256    /// Ads (Advertising) Org.
21257    Ads,
21258    /// Photos Org.
21259    Photos,
21260    /// Street View Org.
21261    StreetView,
21262    /// Shopping Org.
21263    Shopping,
21264    /// Geo Org.
21265    Geo,
21266    /// Generative AI - <https://developers.generativeai.google>
21267    GenerativeAi,
21268    /// If set, the enum was initialized with an unknown value.
21269    ///
21270    /// Applications can examine the value using [ClientLibraryOrganization::value] or
21271    /// [ClientLibraryOrganization::name].
21272    UnknownValue(client_library_organization::UnknownValue),
21273}
21274
21275#[doc(hidden)]
21276pub mod client_library_organization {
21277    #[allow(unused_imports)]
21278    use super::*;
21279    #[derive(Clone, Debug, PartialEq)]
21280    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
21281}
21282
21283impl ClientLibraryOrganization {
21284    /// Gets the enum value.
21285    ///
21286    /// Returns `None` if the enum contains an unknown value deserialized from
21287    /// the string representation of enums.
21288    pub fn value(&self) -> std::option::Option<i32> {
21289        match self {
21290            Self::Unspecified => std::option::Option::Some(0),
21291            Self::Cloud => std::option::Option::Some(1),
21292            Self::Ads => std::option::Option::Some(2),
21293            Self::Photos => std::option::Option::Some(3),
21294            Self::StreetView => std::option::Option::Some(4),
21295            Self::Shopping => std::option::Option::Some(5),
21296            Self::Geo => std::option::Option::Some(6),
21297            Self::GenerativeAi => std::option::Option::Some(7),
21298            Self::UnknownValue(u) => u.0.value(),
21299        }
21300    }
21301
21302    /// Gets the enum value as a string.
21303    ///
21304    /// Returns `None` if the enum contains an unknown value deserialized from
21305    /// the integer representation of enums.
21306    pub fn name(&self) -> std::option::Option<&str> {
21307        match self {
21308            Self::Unspecified => {
21309                std::option::Option::Some("CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED")
21310            }
21311            Self::Cloud => std::option::Option::Some("CLOUD"),
21312            Self::Ads => std::option::Option::Some("ADS"),
21313            Self::Photos => std::option::Option::Some("PHOTOS"),
21314            Self::StreetView => std::option::Option::Some("STREET_VIEW"),
21315            Self::Shopping => std::option::Option::Some("SHOPPING"),
21316            Self::Geo => std::option::Option::Some("GEO"),
21317            Self::GenerativeAi => std::option::Option::Some("GENERATIVE_AI"),
21318            Self::UnknownValue(u) => u.0.name(),
21319        }
21320    }
21321}
21322
21323impl std::default::Default for ClientLibraryOrganization {
21324    fn default() -> Self {
21325        use std::convert::From;
21326        Self::from(0)
21327    }
21328}
21329
21330impl std::fmt::Display for ClientLibraryOrganization {
21331    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
21332        wkt::internal::display_enum(f, self.name(), self.value())
21333    }
21334}
21335
21336impl std::convert::From<i32> for ClientLibraryOrganization {
21337    fn from(value: i32) -> Self {
21338        match value {
21339            0 => Self::Unspecified,
21340            1 => Self::Cloud,
21341            2 => Self::Ads,
21342            3 => Self::Photos,
21343            4 => Self::StreetView,
21344            5 => Self::Shopping,
21345            6 => Self::Geo,
21346            7 => Self::GenerativeAi,
21347            _ => Self::UnknownValue(client_library_organization::UnknownValue(
21348                wkt::internal::UnknownEnumValue::Integer(value),
21349            )),
21350        }
21351    }
21352}
21353
21354impl std::convert::From<&str> for ClientLibraryOrganization {
21355    fn from(value: &str) -> Self {
21356        use std::string::ToString;
21357        match value {
21358            "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED" => Self::Unspecified,
21359            "CLOUD" => Self::Cloud,
21360            "ADS" => Self::Ads,
21361            "PHOTOS" => Self::Photos,
21362            "STREET_VIEW" => Self::StreetView,
21363            "SHOPPING" => Self::Shopping,
21364            "GEO" => Self::Geo,
21365            "GENERATIVE_AI" => Self::GenerativeAi,
21366            _ => Self::UnknownValue(client_library_organization::UnknownValue(
21367                wkt::internal::UnknownEnumValue::String(value.to_string()),
21368            )),
21369        }
21370    }
21371}
21372
21373impl serde::ser::Serialize for ClientLibraryOrganization {
21374    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21375    where
21376        S: serde::Serializer,
21377    {
21378        match self {
21379            Self::Unspecified => serializer.serialize_i32(0),
21380            Self::Cloud => serializer.serialize_i32(1),
21381            Self::Ads => serializer.serialize_i32(2),
21382            Self::Photos => serializer.serialize_i32(3),
21383            Self::StreetView => serializer.serialize_i32(4),
21384            Self::Shopping => serializer.serialize_i32(5),
21385            Self::Geo => serializer.serialize_i32(6),
21386            Self::GenerativeAi => serializer.serialize_i32(7),
21387            Self::UnknownValue(u) => u.0.serialize(serializer),
21388        }
21389    }
21390}
21391
21392impl<'de> serde::de::Deserialize<'de> for ClientLibraryOrganization {
21393    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21394    where
21395        D: serde::Deserializer<'de>,
21396    {
21397        deserializer.deserialize_any(
21398            wkt::internal::EnumVisitor::<ClientLibraryOrganization>::new(
21399                ".google.api.ClientLibraryOrganization",
21400            ),
21401        )
21402    }
21403}
21404
21405/// To where should client libraries be published?
21406///
21407/// # Working with unknown values
21408///
21409/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
21410/// additional enum variants at any time. Adding new variants is not considered
21411/// a breaking change. Applications should write their code in anticipation of:
21412///
21413/// - New values appearing in future releases of the client library, **and**
21414/// - New values received dynamically, without application changes.
21415///
21416/// Please consult the [Working with enums] section in the user guide for some
21417/// guidelines.
21418///
21419/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
21420#[derive(Clone, Debug, PartialEq)]
21421#[non_exhaustive]
21422pub enum ClientLibraryDestination {
21423    /// Client libraries will neither be generated nor published to package
21424    /// managers.
21425    Unspecified,
21426    /// Generate the client library in a repo under github.com/googleapis,
21427    /// but don't publish it to package managers.
21428    Github,
21429    /// Publish the library to package managers like nuget.org and npmjs.com.
21430    PackageManager,
21431    /// If set, the enum was initialized with an unknown value.
21432    ///
21433    /// Applications can examine the value using [ClientLibraryDestination::value] or
21434    /// [ClientLibraryDestination::name].
21435    UnknownValue(client_library_destination::UnknownValue),
21436}
21437
21438#[doc(hidden)]
21439pub mod client_library_destination {
21440    #[allow(unused_imports)]
21441    use super::*;
21442    #[derive(Clone, Debug, PartialEq)]
21443    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
21444}
21445
21446impl ClientLibraryDestination {
21447    /// Gets the enum value.
21448    ///
21449    /// Returns `None` if the enum contains an unknown value deserialized from
21450    /// the string representation of enums.
21451    pub fn value(&self) -> std::option::Option<i32> {
21452        match self {
21453            Self::Unspecified => std::option::Option::Some(0),
21454            Self::Github => std::option::Option::Some(10),
21455            Self::PackageManager => std::option::Option::Some(20),
21456            Self::UnknownValue(u) => u.0.value(),
21457        }
21458    }
21459
21460    /// Gets the enum value as a string.
21461    ///
21462    /// Returns `None` if the enum contains an unknown value deserialized from
21463    /// the integer representation of enums.
21464    pub fn name(&self) -> std::option::Option<&str> {
21465        match self {
21466            Self::Unspecified => {
21467                std::option::Option::Some("CLIENT_LIBRARY_DESTINATION_UNSPECIFIED")
21468            }
21469            Self::Github => std::option::Option::Some("GITHUB"),
21470            Self::PackageManager => std::option::Option::Some("PACKAGE_MANAGER"),
21471            Self::UnknownValue(u) => u.0.name(),
21472        }
21473    }
21474}
21475
21476impl std::default::Default for ClientLibraryDestination {
21477    fn default() -> Self {
21478        use std::convert::From;
21479        Self::from(0)
21480    }
21481}
21482
21483impl std::fmt::Display for ClientLibraryDestination {
21484    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
21485        wkt::internal::display_enum(f, self.name(), self.value())
21486    }
21487}
21488
21489impl std::convert::From<i32> for ClientLibraryDestination {
21490    fn from(value: i32) -> Self {
21491        match value {
21492            0 => Self::Unspecified,
21493            10 => Self::Github,
21494            20 => Self::PackageManager,
21495            _ => Self::UnknownValue(client_library_destination::UnknownValue(
21496                wkt::internal::UnknownEnumValue::Integer(value),
21497            )),
21498        }
21499    }
21500}
21501
21502impl std::convert::From<&str> for ClientLibraryDestination {
21503    fn from(value: &str) -> Self {
21504        use std::string::ToString;
21505        match value {
21506            "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED" => Self::Unspecified,
21507            "GITHUB" => Self::Github,
21508            "PACKAGE_MANAGER" => Self::PackageManager,
21509            _ => Self::UnknownValue(client_library_destination::UnknownValue(
21510                wkt::internal::UnknownEnumValue::String(value.to_string()),
21511            )),
21512        }
21513    }
21514}
21515
21516impl serde::ser::Serialize for ClientLibraryDestination {
21517    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21518    where
21519        S: serde::Serializer,
21520    {
21521        match self {
21522            Self::Unspecified => serializer.serialize_i32(0),
21523            Self::Github => serializer.serialize_i32(10),
21524            Self::PackageManager => serializer.serialize_i32(20),
21525            Self::UnknownValue(u) => u.0.serialize(serializer),
21526        }
21527    }
21528}
21529
21530impl<'de> serde::de::Deserialize<'de> for ClientLibraryDestination {
21531    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21532    where
21533        D: serde::Deserializer<'de>,
21534    {
21535        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ClientLibraryDestination>::new(
21536            ".google.api.ClientLibraryDestination",
21537        ))
21538    }
21539}
21540
21541/// Classifies set of possible modifications to an object in the service
21542/// configuration.
21543///
21544/// # Working with unknown values
21545///
21546/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
21547/// additional enum variants at any time. Adding new variants is not considered
21548/// a breaking change. Applications should write their code in anticipation of:
21549///
21550/// - New values appearing in future releases of the client library, **and**
21551/// - New values received dynamically, without application changes.
21552///
21553/// Please consult the [Working with enums] section in the user guide for some
21554/// guidelines.
21555///
21556/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
21557#[derive(Clone, Debug, PartialEq)]
21558#[non_exhaustive]
21559pub enum ChangeType {
21560    /// No value was provided.
21561    Unspecified,
21562    /// The changed object exists in the 'new' service configuration, but not
21563    /// in the 'old' service configuration.
21564    Added,
21565    /// The changed object exists in the 'old' service configuration, but not
21566    /// in the 'new' service configuration.
21567    Removed,
21568    /// The changed object exists in both service configurations, but its value
21569    /// is different.
21570    Modified,
21571    /// If set, the enum was initialized with an unknown value.
21572    ///
21573    /// Applications can examine the value using [ChangeType::value] or
21574    /// [ChangeType::name].
21575    UnknownValue(change_type::UnknownValue),
21576}
21577
21578#[doc(hidden)]
21579pub mod change_type {
21580    #[allow(unused_imports)]
21581    use super::*;
21582    #[derive(Clone, Debug, PartialEq)]
21583    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
21584}
21585
21586impl ChangeType {
21587    /// Gets the enum value.
21588    ///
21589    /// Returns `None` if the enum contains an unknown value deserialized from
21590    /// the string representation of enums.
21591    pub fn value(&self) -> std::option::Option<i32> {
21592        match self {
21593            Self::Unspecified => std::option::Option::Some(0),
21594            Self::Added => std::option::Option::Some(1),
21595            Self::Removed => std::option::Option::Some(2),
21596            Self::Modified => std::option::Option::Some(3),
21597            Self::UnknownValue(u) => u.0.value(),
21598        }
21599    }
21600
21601    /// Gets the enum value as a string.
21602    ///
21603    /// Returns `None` if the enum contains an unknown value deserialized from
21604    /// the integer representation of enums.
21605    pub fn name(&self) -> std::option::Option<&str> {
21606        match self {
21607            Self::Unspecified => std::option::Option::Some("CHANGE_TYPE_UNSPECIFIED"),
21608            Self::Added => std::option::Option::Some("ADDED"),
21609            Self::Removed => std::option::Option::Some("REMOVED"),
21610            Self::Modified => std::option::Option::Some("MODIFIED"),
21611            Self::UnknownValue(u) => u.0.name(),
21612        }
21613    }
21614}
21615
21616impl std::default::Default for ChangeType {
21617    fn default() -> Self {
21618        use std::convert::From;
21619        Self::from(0)
21620    }
21621}
21622
21623impl std::fmt::Display for ChangeType {
21624    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
21625        wkt::internal::display_enum(f, self.name(), self.value())
21626    }
21627}
21628
21629impl std::convert::From<i32> for ChangeType {
21630    fn from(value: i32) -> Self {
21631        match value {
21632            0 => Self::Unspecified,
21633            1 => Self::Added,
21634            2 => Self::Removed,
21635            3 => Self::Modified,
21636            _ => Self::UnknownValue(change_type::UnknownValue(
21637                wkt::internal::UnknownEnumValue::Integer(value),
21638            )),
21639        }
21640    }
21641}
21642
21643impl std::convert::From<&str> for ChangeType {
21644    fn from(value: &str) -> Self {
21645        use std::string::ToString;
21646        match value {
21647            "CHANGE_TYPE_UNSPECIFIED" => Self::Unspecified,
21648            "ADDED" => Self::Added,
21649            "REMOVED" => Self::Removed,
21650            "MODIFIED" => Self::Modified,
21651            _ => Self::UnknownValue(change_type::UnknownValue(
21652                wkt::internal::UnknownEnumValue::String(value.to_string()),
21653            )),
21654        }
21655    }
21656}
21657
21658impl serde::ser::Serialize for ChangeType {
21659    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
21660    where
21661        S: serde::Serializer,
21662    {
21663        match self {
21664            Self::Unspecified => serializer.serialize_i32(0),
21665            Self::Added => serializer.serialize_i32(1),
21666            Self::Removed => serializer.serialize_i32(2),
21667            Self::Modified => serializer.serialize_i32(3),
21668            Self::UnknownValue(u) => u.0.serialize(serializer),
21669        }
21670    }
21671}
21672
21673impl<'de> serde::de::Deserialize<'de> for ChangeType {
21674    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
21675    where
21676        D: serde::Deserializer<'de>,
21677    {
21678        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ChangeType>::new(
21679            ".google.api.ChangeType",
21680        ))
21681    }
21682}
21683
21684/// Defines the supported values for `google.rpc.ErrorInfo.reason` for the
21685/// `googleapis.com` error domain. This error domain is reserved for [Service
21686/// Infrastructure](https://cloud.google.com/service-infrastructure/docs/overview).
21687/// For each error info of this domain, the metadata key "service" refers to the
21688/// logical identifier of an API service, such as "pubsub.googleapis.com". The
21689/// "consumer" refers to the entity that consumes an API Service. It typically is
21690/// a Google project that owns the client application or the server resource,
21691/// such as "projects/123". Other metadata keys are specific to each error
21692/// reason. For more information, see the definition of the specific error
21693/// reason.
21694///
21695/// # Working with unknown values
21696///
21697/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
21698/// additional enum variants at any time. Adding new variants is not considered
21699/// a breaking change. Applications should write their code in anticipation of:
21700///
21701/// - New values appearing in future releases of the client library, **and**
21702/// - New values received dynamically, without application changes.
21703///
21704/// Please consult the [Working with enums] section in the user guide for some
21705/// guidelines.
21706///
21707/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
21708#[derive(Clone, Debug, PartialEq)]
21709#[non_exhaustive]
21710pub enum ErrorReason {
21711    /// Do not use this default value.
21712    Unspecified,
21713    /// The request is calling a disabled service for a consumer.
21714    ///
21715    /// Example of an ErrorInfo when the consumer "projects/123" contacting
21716    /// "pubsub.googleapis.com" service which is disabled:
21717    ///
21718    /// ```norust
21719    /// { "reason": "SERVICE_DISABLED",
21720    ///   "domain": "googleapis.com",
21721    ///   "metadata": {
21722    ///     "consumer": "projects/123",
21723    ///     "service": "pubsub.googleapis.com"
21724    ///   }
21725    /// }
21726    /// ```
21727    ///
21728    /// This response indicates the "pubsub.googleapis.com" has been disabled in
21729    /// "projects/123".
21730    ServiceDisabled,
21731    /// The request whose associated billing account is disabled.
21732    ///
21733    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
21734    /// "pubsub.googleapis.com" service because the associated billing account is
21735    /// disabled:
21736    ///
21737    /// ```norust
21738    /// { "reason": "BILLING_DISABLED",
21739    ///   "domain": "googleapis.com",
21740    ///   "metadata": {
21741    ///     "consumer": "projects/123",
21742    ///     "service": "pubsub.googleapis.com"
21743    ///   }
21744    /// }
21745    /// ```
21746    ///
21747    /// This response indicates the billing account associated has been disabled.
21748    BillingDisabled,
21749    /// The request is denied because the provided [API
21750    /// key](https://cloud.google.com/docs/authentication/api-keys) is invalid. It
21751    /// may be in a bad format, cannot be found, or has been expired).
21752    ///
21753    /// Example of an ErrorInfo when the request is contacting
21754    /// "storage.googleapis.com" service with an invalid API key:
21755    ///
21756    /// ```norust
21757    /// { "reason": "API_KEY_INVALID",
21758    ///   "domain": "googleapis.com",
21759    ///   "metadata": {
21760    ///     "service": "storage.googleapis.com",
21761    ///   }
21762    /// }
21763    /// ```
21764    ApiKeyInvalid,
21765    /// The request is denied because it violates [API key API
21766    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_api_restrictions).
21767    ///
21768    /// Example of an ErrorInfo when the consumer "projects/123" fails to call the
21769    /// "storage.googleapis.com" service because this service is restricted in the
21770    /// API key:
21771    ///
21772    /// ```norust
21773    /// { "reason": "API_KEY_SERVICE_BLOCKED",
21774    ///   "domain": "googleapis.com",
21775    ///   "metadata": {
21776    ///     "consumer": "projects/123",
21777    ///     "service": "storage.googleapis.com"
21778    ///   }
21779    /// }
21780    /// ```
21781    ApiKeyServiceBlocked,
21782    /// The request is denied because it violates [API key HTTP
21783    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions).
21784    ///
21785    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
21786    /// "storage.googleapis.com" service because the http referrer of the request
21787    /// violates API key HTTP restrictions:
21788    ///
21789    /// ```norust
21790    /// { "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
21791    ///   "domain": "googleapis.com",
21792    ///   "metadata": {
21793    ///     "consumer": "projects/123",
21794    ///     "service": "storage.googleapis.com",
21795    ///   }
21796    /// }
21797    /// ```
21798    ApiKeyHttpReferrerBlocked,
21799    /// The request is denied because it violates [API key IP address
21800    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
21801    ///
21802    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
21803    /// "storage.googleapis.com" service because the caller IP of the request
21804    /// violates API key IP address restrictions:
21805    ///
21806    /// ```norust
21807    /// { "reason": "API_KEY_IP_ADDRESS_BLOCKED",
21808    ///   "domain": "googleapis.com",
21809    ///   "metadata": {
21810    ///     "consumer": "projects/123",
21811    ///     "service": "storage.googleapis.com",
21812    ///   }
21813    /// }
21814    /// ```
21815    ApiKeyIpAddressBlocked,
21816    /// The request is denied because it violates [API key Android application
21817    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
21818    ///
21819    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
21820    /// "storage.googleapis.com" service because the request from the Android apps
21821    /// violates the API key Android application restrictions:
21822    ///
21823    /// ```norust
21824    /// { "reason": "API_KEY_ANDROID_APP_BLOCKED",
21825    ///   "domain": "googleapis.com",
21826    ///   "metadata": {
21827    ///     "consumer": "projects/123",
21828    ///     "service": "storage.googleapis.com"
21829    ///   }
21830    /// }
21831    /// ```
21832    ApiKeyAndroidAppBlocked,
21833    /// The request is denied because it violates [API key iOS application
21834    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
21835    ///
21836    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
21837    /// "storage.googleapis.com" service because the request from the iOS apps
21838    /// violates the API key iOS application restrictions:
21839    ///
21840    /// ```norust
21841    /// { "reason": "API_KEY_IOS_APP_BLOCKED",
21842    ///   "domain": "googleapis.com",
21843    ///   "metadata": {
21844    ///     "consumer": "projects/123",
21845    ///     "service": "storage.googleapis.com"
21846    ///   }
21847    /// }
21848    /// ```
21849    ApiKeyIosAppBlocked,
21850    /// The request is denied because there is not enough rate quota for the
21851    /// consumer.
21852    ///
21853    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
21854    /// "pubsub.googleapis.com" service because consumer's rate quota usage has
21855    /// reached the maximum value set for the quota limit
21856    /// "ReadsPerMinutePerProject" on the quota metric
21857    /// "pubsub.googleapis.com/read_requests":
21858    ///
21859    /// ```norust
21860    /// { "reason": "RATE_LIMIT_EXCEEDED",
21861    ///   "domain": "googleapis.com",
21862    ///   "metadata": {
21863    ///     "consumer": "projects/123",
21864    ///     "service": "pubsub.googleapis.com",
21865    ///     "quota_metric": "pubsub.googleapis.com/read_requests",
21866    ///     "quota_limit": "ReadsPerMinutePerProject"
21867    ///   }
21868    /// }
21869    /// ```
21870    ///
21871    /// Example of an ErrorInfo when the consumer "projects/123" checks quota on
21872    /// the service "dataflow.googleapis.com" and hits the organization quota
21873    /// limit "DefaultRequestsPerMinutePerOrganization" on the metric
21874    /// "dataflow.googleapis.com/default_requests".
21875    ///
21876    /// ```norust
21877    /// { "reason": "RATE_LIMIT_EXCEEDED",
21878    ///   "domain": "googleapis.com",
21879    ///   "metadata": {
21880    ///     "consumer": "projects/123",
21881    ///     "service": "dataflow.googleapis.com",
21882    ///     "quota_metric": "dataflow.googleapis.com/default_requests",
21883    ///     "quota_limit": "DefaultRequestsPerMinutePerOrganization"
21884    ///   }
21885    /// }
21886    /// ```
21887    RateLimitExceeded,
21888    /// The request is denied because there is not enough resource quota for the
21889    /// consumer.
21890    ///
21891    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
21892    /// "compute.googleapis.com" service because consumer's resource quota usage
21893    /// has reached the maximum value set for the quota limit "VMsPerProject"
21894    /// on the quota metric "compute.googleapis.com/vms":
21895    ///
21896    /// ```norust
21897    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
21898    ///   "domain": "googleapis.com",
21899    ///   "metadata": {
21900    ///     "consumer": "projects/123",
21901    ///     "service": "compute.googleapis.com",
21902    ///     "quota_metric": "compute.googleapis.com/vms",
21903    ///     "quota_limit": "VMsPerProject"
21904    ///   }
21905    /// }
21906    /// ```
21907    ///
21908    /// Example of an ErrorInfo when the consumer "projects/123" checks resource
21909    /// quota on the service "dataflow.googleapis.com" and hits the organization
21910    /// quota limit "jobs-per-organization" on the metric
21911    /// "dataflow.googleapis.com/job_count".
21912    ///
21913    /// ```norust
21914    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
21915    ///   "domain": "googleapis.com",
21916    ///   "metadata": {
21917    ///     "consumer": "projects/123",
21918    ///     "service": "dataflow.googleapis.com",
21919    ///     "quota_metric": "dataflow.googleapis.com/job_count",
21920    ///     "quota_limit": "jobs-per-organization"
21921    ///   }
21922    /// }
21923    /// ```
21924    ResourceQuotaExceeded,
21925    /// The request whose associated billing account address is in a tax restricted
21926    /// location, violates the local tax restrictions when creating resources in
21927    /// the restricted region.
21928    ///
21929    /// Example of an ErrorInfo when creating the Cloud Storage Bucket in the
21930    /// container "projects/123" under a tax restricted region
21931    /// "locations/asia-northeast3":
21932    ///
21933    /// ```norust
21934    /// { "reason": "LOCATION_TAX_POLICY_VIOLATED",
21935    ///   "domain": "googleapis.com",
21936    ///   "metadata": {
21937    ///     "consumer": "projects/123",
21938    ///     "service": "storage.googleapis.com",
21939    ///     "location": "locations/asia-northeast3"
21940    ///   }
21941    /// }
21942    /// ```
21943    ///
21944    /// This response indicates creating the Cloud Storage Bucket in
21945    /// "locations/asia-northeast3" violates the location tax restriction.
21946    LocationTaxPolicyViolated,
21947    /// The request is denied because the caller does not have required permission
21948    /// on the user project "projects/123" or the user project is invalid. For more
21949    /// information, check the [userProject System
21950    /// Parameters](https://cloud.google.com/apis/docs/system-parameters).
21951    ///
21952    /// Example of an ErrorInfo when the caller is calling Cloud Storage service
21953    /// with insufficient permissions on the user project:
21954    ///
21955    /// ```norust
21956    /// { "reason": "USER_PROJECT_DENIED",
21957    ///   "domain": "googleapis.com",
21958    ///   "metadata": {
21959    ///     "consumer": "projects/123",
21960    ///     "service": "storage.googleapis.com"
21961    ///   }
21962    /// }
21963    /// ```
21964    UserProjectDenied,
21965    /// The request is denied because the consumer "projects/123" is suspended due
21966    /// to Terms of Service(Tos) violations. Check [Project suspension
21967    /// guidelines](https://cloud.google.com/resource-manager/docs/project-suspension-guidelines)
21968    /// for more information.
21969    ///
21970    /// Example of an ErrorInfo when calling Cloud Storage service with the
21971    /// suspended consumer "projects/123":
21972    ///
21973    /// ```norust
21974    /// { "reason": "CONSUMER_SUSPENDED",
21975    ///   "domain": "googleapis.com",
21976    ///   "metadata": {
21977    ///     "consumer": "projects/123",
21978    ///     "service": "storage.googleapis.com"
21979    ///   }
21980    /// }
21981    /// ```
21982    ConsumerSuspended,
21983    /// The request is denied because the associated consumer is invalid. It may be
21984    /// in a bad format, cannot be found, or have been deleted.
21985    ///
21986    /// Example of an ErrorInfo when calling Cloud Storage service with the
21987    /// invalid consumer "projects/123":
21988    ///
21989    /// ```norust
21990    /// { "reason": "CONSUMER_INVALID",
21991    ///   "domain": "googleapis.com",
21992    ///   "metadata": {
21993    ///     "consumer": "projects/123",
21994    ///     "service": "storage.googleapis.com"
21995    ///   }
21996    /// }
21997    /// ```
21998    ConsumerInvalid,
21999    /// The request is denied because it violates [VPC Service
22000    /// Controls](https://cloud.google.com/vpc-service-controls/docs/overview).
22001    /// The 'uid' field is a random generated identifier that customer can use it
22002    /// to search the audit log for a request rejected by VPC Service Controls. For
22003    /// more information, please refer [VPC Service Controls
22004    /// Troubleshooting](https://cloud.google.com/vpc-service-controls/docs/troubleshooting#unique-id)
22005    ///
22006    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
22007    /// Cloud Storage service because the request is prohibited by the VPC Service
22008    /// Controls.
22009    ///
22010    /// ```norust
22011    /// { "reason": "SECURITY_POLICY_VIOLATED",
22012    ///   "domain": "googleapis.com",
22013    ///   "metadata": {
22014    ///     "uid": "123456789abcde",
22015    ///     "consumer": "projects/123",
22016    ///     "service": "storage.googleapis.com"
22017    ///   }
22018    /// }
22019    /// ```
22020    SecurityPolicyViolated,
22021    /// The request is denied because the provided access token has expired.
22022    ///
22023    /// Example of an ErrorInfo when the request is calling Cloud Storage service
22024    /// with an expired access token:
22025    ///
22026    /// ```norust
22027    /// { "reason": "ACCESS_TOKEN_EXPIRED",
22028    ///   "domain": "googleapis.com",
22029    ///   "metadata": {
22030    ///     "service": "storage.googleapis.com",
22031    ///     "method": "google.storage.v1.Storage.GetObject"
22032    ///   }
22033    /// }
22034    /// ```
22035    AccessTokenExpired,
22036    /// The request is denied because the provided access token doesn't have at
22037    /// least one of the acceptable scopes required for the API. Please check
22038    /// [OAuth 2.0 Scopes for Google
22039    /// APIs](https://developers.google.com/identity/protocols/oauth2/scopes) for
22040    /// the list of the OAuth 2.0 scopes that you might need to request to access
22041    /// the API.
22042    ///
22043    /// Example of an ErrorInfo when the request is calling Cloud Storage service
22044    /// with an access token that is missing required scopes:
22045    ///
22046    /// ```norust
22047    /// { "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
22048    ///   "domain": "googleapis.com",
22049    ///   "metadata": {
22050    ///     "service": "storage.googleapis.com",
22051    ///     "method": "google.storage.v1.Storage.GetObject"
22052    ///   }
22053    /// }
22054    /// ```
22055    AccessTokenScopeInsufficient,
22056    /// The request is denied because the account associated with the provided
22057    /// access token is in an invalid state, such as disabled or deleted.
22058    /// For more information, see <https://cloud.google.com/docs/authentication>.
22059    ///
22060    /// Warning: For privacy reasons, the server may not be able to disclose the
22061    /// email address for some accounts. The client MUST NOT depend on the
22062    /// availability of the `email` attribute.
22063    ///
22064    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
22065    /// an access token that is associated with a disabled or deleted [service
22066    /// account](http://cloud/iam/docs/service-accounts):
22067    ///
22068    /// ```norust
22069    /// { "reason": "ACCOUNT_STATE_INVALID",
22070    ///   "domain": "googleapis.com",
22071    ///   "metadata": {
22072    ///     "service": "storage.googleapis.com",
22073    ///     "method": "google.storage.v1.Storage.GetObject",
22074    ///     "email": "user@123.iam.gserviceaccount.com"
22075    ///   }
22076    /// }
22077    /// ```
22078    AccountStateInvalid,
22079    /// The request is denied because the type of the provided access token is not
22080    /// supported by the API being called.
22081    ///
22082    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
22083    /// an unsupported token type.
22084    ///
22085    /// ```norust
22086    /// { "reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
22087    ///   "domain": "googleapis.com",
22088    ///   "metadata": {
22089    ///     "service": "storage.googleapis.com",
22090    ///     "method": "google.storage.v1.Storage.GetObject"
22091    ///   }
22092    /// }
22093    /// ```
22094    AccessTokenTypeUnsupported,
22095    /// The request is denied because the request doesn't have any authentication
22096    /// credentials. For more information regarding the supported authentication
22097    /// strategies for Google Cloud APIs, see
22098    /// <https://cloud.google.com/docs/authentication>.
22099    ///
22100    /// Example of an ErrorInfo when the request is to the Cloud Storage API
22101    /// without any authentication credentials.
22102    ///
22103    /// ```norust
22104    /// { "reason": "CREDENTIALS_MISSING",
22105    ///   "domain": "googleapis.com",
22106    ///   "metadata": {
22107    ///     "service": "storage.googleapis.com",
22108    ///     "method": "google.storage.v1.Storage.GetObject"
22109    ///   }
22110    /// }
22111    /// ```
22112    CredentialsMissing,
22113    /// The request is denied because the provided project owning the resource
22114    /// which acts as the [API
22115    /// consumer](https://cloud.google.com/apis/design/glossary#api_consumer) is
22116    /// invalid. It may be in a bad format or empty.
22117    ///
22118    /// Example of an ErrorInfo when the request is to the Cloud Functions API,
22119    /// but the offered resource project in the request in a bad format which can't
22120    /// perform the ListFunctions method.
22121    ///
22122    /// ```norust
22123    /// { "reason": "RESOURCE_PROJECT_INVALID",
22124    ///   "domain": "googleapis.com",
22125    ///   "metadata": {
22126    ///     "service": "cloudfunctions.googleapis.com",
22127    ///     "method":
22128    ///     "google.cloud.functions.v1.CloudFunctionsService.ListFunctions"
22129    ///   }
22130    /// }
22131    /// ```
22132    ResourceProjectInvalid,
22133    /// The request is denied because the provided session cookie is missing,
22134    /// invalid or failed to decode.
22135    ///
22136    /// Example of an ErrorInfo when the request is calling Cloud Storage service
22137    /// with a SID cookie which can't be decoded.
22138    ///
22139    /// ```norust
22140    /// { "reason": "SESSION_COOKIE_INVALID",
22141    ///   "domain": "googleapis.com",
22142    ///   "metadata": {
22143    ///     "service": "storage.googleapis.com",
22144    ///     "method": "google.storage.v1.Storage.GetObject",
22145    ///     "cookie": "SID"
22146    ///   }
22147    /// }
22148    /// ```
22149    SessionCookieInvalid,
22150    /// The request is denied because the user is from a Google Workspace customer
22151    /// that blocks their users from accessing a particular service.
22152    ///
22153    /// Example scenario: <https://support.google.com/a/answer/9197205?hl=en>
22154    ///
22155    /// Example of an ErrorInfo when access to Google Cloud Storage service is
22156    /// blocked by the Google Workspace administrator:
22157    ///
22158    /// ```norust
22159    /// { "reason": "USER_BLOCKED_BY_ADMIN",
22160    ///   "domain": "googleapis.com",
22161    ///   "metadata": {
22162    ///     "service": "storage.googleapis.com",
22163    ///     "method": "google.storage.v1.Storage.GetObject",
22164    ///   }
22165    /// }
22166    /// ```
22167    UserBlockedByAdmin,
22168    /// The request is denied because the resource service usage is restricted
22169    /// by administrators according to the organization policy constraint.
22170    /// For more information see
22171    /// <https://cloud.google.com/resource-manager/docs/organization-policy/restricting-services>.
22172    ///
22173    /// Example of an ErrorInfo when access to Google Cloud Storage service is
22174    /// restricted by Resource Usage Restriction policy:
22175    ///
22176    /// ```norust
22177    /// { "reason": "RESOURCE_USAGE_RESTRICTION_VIOLATED",
22178    ///   "domain": "googleapis.com",
22179    ///   "metadata": {
22180    ///     "consumer": "projects/project-123",
22181    ///     "service": "storage.googleapis.com"
22182    ///   }
22183    /// }
22184    /// ```
22185    ResourceUsageRestrictionViolated,
22186    /// Unimplemented. Do not use.
22187    ///
22188    /// The request is denied because it contains unsupported system parameters in
22189    /// URL query parameters or HTTP headers. For more information,
22190    /// see <https://cloud.google.com/apis/docs/system-parameters>
22191    ///
22192    /// Example of an ErrorInfo when access "pubsub.googleapis.com" service with
22193    /// a request header of "x-goog-user-ip":
22194    ///
22195    /// ```norust
22196    /// { "reason": "SYSTEM_PARAMETER_UNSUPPORTED",
22197    ///   "domain": "googleapis.com",
22198    ///   "metadata": {
22199    ///     "service": "pubsub.googleapis.com"
22200    ///     "parameter": "x-goog-user-ip"
22201    ///   }
22202    /// }
22203    /// ```
22204    SystemParameterUnsupported,
22205    /// The request is denied because it violates Org Restriction: the requested
22206    /// resource does not belong to allowed organizations specified in
22207    /// "X-Goog-Allowed-Resources" header.
22208    ///
22209    /// Example of an ErrorInfo when accessing a GCP resource that is restricted by
22210    /// Org Restriction for "pubsub.googleapis.com" service.
22211    ///
22212    /// {
22213    /// reason: "ORG_RESTRICTION_VIOLATION"
22214    /// domain: "googleapis.com"
22215    /// metadata {
22216    /// "consumer":"projects/123456"
22217    /// "service": "pubsub.googleapis.com"
22218    /// }
22219    /// }
22220    OrgRestrictionViolation,
22221    /// The request is denied because "X-Goog-Allowed-Resources" header is in a bad
22222    /// format.
22223    ///
22224    /// Example of an ErrorInfo when
22225    /// accessing "pubsub.googleapis.com" service with an invalid
22226    /// "X-Goog-Allowed-Resources" request header.
22227    ///
22228    /// {
22229    /// reason: "ORG_RESTRICTION_HEADER_INVALID"
22230    /// domain: "googleapis.com"
22231    /// metadata {
22232    /// "consumer":"projects/123456"
22233    /// "service": "pubsub.googleapis.com"
22234    /// }
22235    /// }
22236    OrgRestrictionHeaderInvalid,
22237    /// Unimplemented. Do not use.
22238    ///
22239    /// The request is calling a service that is not visible to the consumer.
22240    ///
22241    /// Example of an ErrorInfo when the consumer "projects/123" contacting
22242    /// "pubsub.googleapis.com" service which is not visible to the consumer.
22243    ///
22244    /// ```norust
22245    /// { "reason": "SERVICE_NOT_VISIBLE",
22246    ///   "domain": "googleapis.com",
22247    ///   "metadata": {
22248    ///     "consumer": "projects/123",
22249    ///     "service": "pubsub.googleapis.com"
22250    ///   }
22251    /// }
22252    /// ```
22253    ///
22254    /// This response indicates the "pubsub.googleapis.com" is not visible to
22255    /// "projects/123" (or it may not exist).
22256    ServiceNotVisible,
22257    /// The request is related to a project for which GCP access is suspended.
22258    ///
22259    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
22260    /// "pubsub.googleapis.com" service because GCP access is suspended:
22261    ///
22262    /// ```norust
22263    /// { "reason": "GCP_SUSPENDED",
22264    ///   "domain": "googleapis.com",
22265    ///   "metadata": {
22266    ///     "consumer": "projects/123",
22267    ///     "service": "pubsub.googleapis.com"
22268    ///   }
22269    /// }
22270    /// ```
22271    ///
22272    /// This response indicates the associated GCP account has been suspended.
22273    GcpSuspended,
22274    /// The request violates the location policies when creating resources in
22275    /// the restricted region.
22276    ///
22277    /// Example of an ErrorInfo when creating the Cloud Storage Bucket by
22278    /// "projects/123" for service storage.googleapis.com:
22279    ///
22280    /// ```norust
22281    /// { "reason": "LOCATION_POLICY_VIOLATED",
22282    ///   "domain": "googleapis.com",
22283    ///   "metadata": {
22284    ///     "consumer": "projects/123",
22285    ///     "service": "storage.googleapis.com",
22286    ///   }
22287    /// }
22288    /// ```
22289    ///
22290    /// This response indicates creating the Cloud Storage Bucket in
22291    /// "locations/asia-northeast3" violates at least one location policy.
22292    /// The troubleshooting guidance is provided in the Help links.
22293    LocationPolicyViolated,
22294    /// The request is denied because origin request header is missing.
22295    ///
22296    /// Example of an ErrorInfo when
22297    /// accessing "pubsub.googleapis.com" service with an empty "Origin" request
22298    /// header.
22299    ///
22300    /// {
22301    /// reason: "MISSING_ORIGIN"
22302    /// domain: "googleapis.com"
22303    /// metadata {
22304    /// "consumer":"projects/123456"
22305    /// "service": "pubsub.googleapis.com"
22306    /// }
22307    /// }
22308    MissingOrigin,
22309    /// The request is denied because the request contains more than one credential
22310    /// type that are individually acceptable, but not together. The customer
22311    /// should retry their request with only one set of credentials.
22312    ///
22313    /// Example of an ErrorInfo when
22314    /// accessing "pubsub.googleapis.com" service with overloaded credentials.
22315    ///
22316    /// {
22317    /// reason: "OVERLOADED_CREDENTIALS"
22318    /// domain: "googleapis.com"
22319    /// metadata {
22320    /// "consumer":"projects/123456"
22321    /// "service": "pubsub.googleapis.com"
22322    /// }
22323    /// }
22324    OverloadedCredentials,
22325    /// If set, the enum was initialized with an unknown value.
22326    ///
22327    /// Applications can examine the value using [ErrorReason::value] or
22328    /// [ErrorReason::name].
22329    UnknownValue(error_reason::UnknownValue),
22330}
22331
22332#[doc(hidden)]
22333pub mod error_reason {
22334    #[allow(unused_imports)]
22335    use super::*;
22336    #[derive(Clone, Debug, PartialEq)]
22337    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22338}
22339
22340impl ErrorReason {
22341    /// Gets the enum value.
22342    ///
22343    /// Returns `None` if the enum contains an unknown value deserialized from
22344    /// the string representation of enums.
22345    pub fn value(&self) -> std::option::Option<i32> {
22346        match self {
22347            Self::Unspecified => std::option::Option::Some(0),
22348            Self::ServiceDisabled => std::option::Option::Some(1),
22349            Self::BillingDisabled => std::option::Option::Some(2),
22350            Self::ApiKeyInvalid => std::option::Option::Some(3),
22351            Self::ApiKeyServiceBlocked => std::option::Option::Some(4),
22352            Self::ApiKeyHttpReferrerBlocked => std::option::Option::Some(7),
22353            Self::ApiKeyIpAddressBlocked => std::option::Option::Some(8),
22354            Self::ApiKeyAndroidAppBlocked => std::option::Option::Some(9),
22355            Self::ApiKeyIosAppBlocked => std::option::Option::Some(13),
22356            Self::RateLimitExceeded => std::option::Option::Some(5),
22357            Self::ResourceQuotaExceeded => std::option::Option::Some(6),
22358            Self::LocationTaxPolicyViolated => std::option::Option::Some(10),
22359            Self::UserProjectDenied => std::option::Option::Some(11),
22360            Self::ConsumerSuspended => std::option::Option::Some(12),
22361            Self::ConsumerInvalid => std::option::Option::Some(14),
22362            Self::SecurityPolicyViolated => std::option::Option::Some(15),
22363            Self::AccessTokenExpired => std::option::Option::Some(16),
22364            Self::AccessTokenScopeInsufficient => std::option::Option::Some(17),
22365            Self::AccountStateInvalid => std::option::Option::Some(18),
22366            Self::AccessTokenTypeUnsupported => std::option::Option::Some(19),
22367            Self::CredentialsMissing => std::option::Option::Some(20),
22368            Self::ResourceProjectInvalid => std::option::Option::Some(21),
22369            Self::SessionCookieInvalid => std::option::Option::Some(23),
22370            Self::UserBlockedByAdmin => std::option::Option::Some(24),
22371            Self::ResourceUsageRestrictionViolated => std::option::Option::Some(25),
22372            Self::SystemParameterUnsupported => std::option::Option::Some(26),
22373            Self::OrgRestrictionViolation => std::option::Option::Some(27),
22374            Self::OrgRestrictionHeaderInvalid => std::option::Option::Some(28),
22375            Self::ServiceNotVisible => std::option::Option::Some(29),
22376            Self::GcpSuspended => std::option::Option::Some(30),
22377            Self::LocationPolicyViolated => std::option::Option::Some(31),
22378            Self::MissingOrigin => std::option::Option::Some(33),
22379            Self::OverloadedCredentials => std::option::Option::Some(34),
22380            Self::UnknownValue(u) => u.0.value(),
22381        }
22382    }
22383
22384    /// Gets the enum value as a string.
22385    ///
22386    /// Returns `None` if the enum contains an unknown value deserialized from
22387    /// the integer representation of enums.
22388    pub fn name(&self) -> std::option::Option<&str> {
22389        match self {
22390            Self::Unspecified => std::option::Option::Some("ERROR_REASON_UNSPECIFIED"),
22391            Self::ServiceDisabled => std::option::Option::Some("SERVICE_DISABLED"),
22392            Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
22393            Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
22394            Self::ApiKeyServiceBlocked => std::option::Option::Some("API_KEY_SERVICE_BLOCKED"),
22395            Self::ApiKeyHttpReferrerBlocked => {
22396                std::option::Option::Some("API_KEY_HTTP_REFERRER_BLOCKED")
22397            }
22398            Self::ApiKeyIpAddressBlocked => std::option::Option::Some("API_KEY_IP_ADDRESS_BLOCKED"),
22399            Self::ApiKeyAndroidAppBlocked => {
22400                std::option::Option::Some("API_KEY_ANDROID_APP_BLOCKED")
22401            }
22402            Self::ApiKeyIosAppBlocked => std::option::Option::Some("API_KEY_IOS_APP_BLOCKED"),
22403            Self::RateLimitExceeded => std::option::Option::Some("RATE_LIMIT_EXCEEDED"),
22404            Self::ResourceQuotaExceeded => std::option::Option::Some("RESOURCE_QUOTA_EXCEEDED"),
22405            Self::LocationTaxPolicyViolated => {
22406                std::option::Option::Some("LOCATION_TAX_POLICY_VIOLATED")
22407            }
22408            Self::UserProjectDenied => std::option::Option::Some("USER_PROJECT_DENIED"),
22409            Self::ConsumerSuspended => std::option::Option::Some("CONSUMER_SUSPENDED"),
22410            Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
22411            Self::SecurityPolicyViolated => std::option::Option::Some("SECURITY_POLICY_VIOLATED"),
22412            Self::AccessTokenExpired => std::option::Option::Some("ACCESS_TOKEN_EXPIRED"),
22413            Self::AccessTokenScopeInsufficient => {
22414                std::option::Option::Some("ACCESS_TOKEN_SCOPE_INSUFFICIENT")
22415            }
22416            Self::AccountStateInvalid => std::option::Option::Some("ACCOUNT_STATE_INVALID"),
22417            Self::AccessTokenTypeUnsupported => {
22418                std::option::Option::Some("ACCESS_TOKEN_TYPE_UNSUPPORTED")
22419            }
22420            Self::CredentialsMissing => std::option::Option::Some("CREDENTIALS_MISSING"),
22421            Self::ResourceProjectInvalid => std::option::Option::Some("RESOURCE_PROJECT_INVALID"),
22422            Self::SessionCookieInvalid => std::option::Option::Some("SESSION_COOKIE_INVALID"),
22423            Self::UserBlockedByAdmin => std::option::Option::Some("USER_BLOCKED_BY_ADMIN"),
22424            Self::ResourceUsageRestrictionViolated => {
22425                std::option::Option::Some("RESOURCE_USAGE_RESTRICTION_VIOLATED")
22426            }
22427            Self::SystemParameterUnsupported => {
22428                std::option::Option::Some("SYSTEM_PARAMETER_UNSUPPORTED")
22429            }
22430            Self::OrgRestrictionViolation => std::option::Option::Some("ORG_RESTRICTION_VIOLATION"),
22431            Self::OrgRestrictionHeaderInvalid => {
22432                std::option::Option::Some("ORG_RESTRICTION_HEADER_INVALID")
22433            }
22434            Self::ServiceNotVisible => std::option::Option::Some("SERVICE_NOT_VISIBLE"),
22435            Self::GcpSuspended => std::option::Option::Some("GCP_SUSPENDED"),
22436            Self::LocationPolicyViolated => std::option::Option::Some("LOCATION_POLICY_VIOLATED"),
22437            Self::MissingOrigin => std::option::Option::Some("MISSING_ORIGIN"),
22438            Self::OverloadedCredentials => std::option::Option::Some("OVERLOADED_CREDENTIALS"),
22439            Self::UnknownValue(u) => u.0.name(),
22440        }
22441    }
22442}
22443
22444impl std::default::Default for ErrorReason {
22445    fn default() -> Self {
22446        use std::convert::From;
22447        Self::from(0)
22448    }
22449}
22450
22451impl std::fmt::Display for ErrorReason {
22452    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22453        wkt::internal::display_enum(f, self.name(), self.value())
22454    }
22455}
22456
22457impl std::convert::From<i32> for ErrorReason {
22458    fn from(value: i32) -> Self {
22459        match value {
22460            0 => Self::Unspecified,
22461            1 => Self::ServiceDisabled,
22462            2 => Self::BillingDisabled,
22463            3 => Self::ApiKeyInvalid,
22464            4 => Self::ApiKeyServiceBlocked,
22465            5 => Self::RateLimitExceeded,
22466            6 => Self::ResourceQuotaExceeded,
22467            7 => Self::ApiKeyHttpReferrerBlocked,
22468            8 => Self::ApiKeyIpAddressBlocked,
22469            9 => Self::ApiKeyAndroidAppBlocked,
22470            10 => Self::LocationTaxPolicyViolated,
22471            11 => Self::UserProjectDenied,
22472            12 => Self::ConsumerSuspended,
22473            13 => Self::ApiKeyIosAppBlocked,
22474            14 => Self::ConsumerInvalid,
22475            15 => Self::SecurityPolicyViolated,
22476            16 => Self::AccessTokenExpired,
22477            17 => Self::AccessTokenScopeInsufficient,
22478            18 => Self::AccountStateInvalid,
22479            19 => Self::AccessTokenTypeUnsupported,
22480            20 => Self::CredentialsMissing,
22481            21 => Self::ResourceProjectInvalid,
22482            23 => Self::SessionCookieInvalid,
22483            24 => Self::UserBlockedByAdmin,
22484            25 => Self::ResourceUsageRestrictionViolated,
22485            26 => Self::SystemParameterUnsupported,
22486            27 => Self::OrgRestrictionViolation,
22487            28 => Self::OrgRestrictionHeaderInvalid,
22488            29 => Self::ServiceNotVisible,
22489            30 => Self::GcpSuspended,
22490            31 => Self::LocationPolicyViolated,
22491            33 => Self::MissingOrigin,
22492            34 => Self::OverloadedCredentials,
22493            _ => Self::UnknownValue(error_reason::UnknownValue(
22494                wkt::internal::UnknownEnumValue::Integer(value),
22495            )),
22496        }
22497    }
22498}
22499
22500impl std::convert::From<&str> for ErrorReason {
22501    fn from(value: &str) -> Self {
22502        use std::string::ToString;
22503        match value {
22504            "ERROR_REASON_UNSPECIFIED" => Self::Unspecified,
22505            "SERVICE_DISABLED" => Self::ServiceDisabled,
22506            "BILLING_DISABLED" => Self::BillingDisabled,
22507            "API_KEY_INVALID" => Self::ApiKeyInvalid,
22508            "API_KEY_SERVICE_BLOCKED" => Self::ApiKeyServiceBlocked,
22509            "API_KEY_HTTP_REFERRER_BLOCKED" => Self::ApiKeyHttpReferrerBlocked,
22510            "API_KEY_IP_ADDRESS_BLOCKED" => Self::ApiKeyIpAddressBlocked,
22511            "API_KEY_ANDROID_APP_BLOCKED" => Self::ApiKeyAndroidAppBlocked,
22512            "API_KEY_IOS_APP_BLOCKED" => Self::ApiKeyIosAppBlocked,
22513            "RATE_LIMIT_EXCEEDED" => Self::RateLimitExceeded,
22514            "RESOURCE_QUOTA_EXCEEDED" => Self::ResourceQuotaExceeded,
22515            "LOCATION_TAX_POLICY_VIOLATED" => Self::LocationTaxPolicyViolated,
22516            "USER_PROJECT_DENIED" => Self::UserProjectDenied,
22517            "CONSUMER_SUSPENDED" => Self::ConsumerSuspended,
22518            "CONSUMER_INVALID" => Self::ConsumerInvalid,
22519            "SECURITY_POLICY_VIOLATED" => Self::SecurityPolicyViolated,
22520            "ACCESS_TOKEN_EXPIRED" => Self::AccessTokenExpired,
22521            "ACCESS_TOKEN_SCOPE_INSUFFICIENT" => Self::AccessTokenScopeInsufficient,
22522            "ACCOUNT_STATE_INVALID" => Self::AccountStateInvalid,
22523            "ACCESS_TOKEN_TYPE_UNSUPPORTED" => Self::AccessTokenTypeUnsupported,
22524            "CREDENTIALS_MISSING" => Self::CredentialsMissing,
22525            "RESOURCE_PROJECT_INVALID" => Self::ResourceProjectInvalid,
22526            "SESSION_COOKIE_INVALID" => Self::SessionCookieInvalid,
22527            "USER_BLOCKED_BY_ADMIN" => Self::UserBlockedByAdmin,
22528            "RESOURCE_USAGE_RESTRICTION_VIOLATED" => Self::ResourceUsageRestrictionViolated,
22529            "SYSTEM_PARAMETER_UNSUPPORTED" => Self::SystemParameterUnsupported,
22530            "ORG_RESTRICTION_VIOLATION" => Self::OrgRestrictionViolation,
22531            "ORG_RESTRICTION_HEADER_INVALID" => Self::OrgRestrictionHeaderInvalid,
22532            "SERVICE_NOT_VISIBLE" => Self::ServiceNotVisible,
22533            "GCP_SUSPENDED" => Self::GcpSuspended,
22534            "LOCATION_POLICY_VIOLATED" => Self::LocationPolicyViolated,
22535            "MISSING_ORIGIN" => Self::MissingOrigin,
22536            "OVERLOADED_CREDENTIALS" => Self::OverloadedCredentials,
22537            _ => Self::UnknownValue(error_reason::UnknownValue(
22538                wkt::internal::UnknownEnumValue::String(value.to_string()),
22539            )),
22540        }
22541    }
22542}
22543
22544impl serde::ser::Serialize for ErrorReason {
22545    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22546    where
22547        S: serde::Serializer,
22548    {
22549        match self {
22550            Self::Unspecified => serializer.serialize_i32(0),
22551            Self::ServiceDisabled => serializer.serialize_i32(1),
22552            Self::BillingDisabled => serializer.serialize_i32(2),
22553            Self::ApiKeyInvalid => serializer.serialize_i32(3),
22554            Self::ApiKeyServiceBlocked => serializer.serialize_i32(4),
22555            Self::ApiKeyHttpReferrerBlocked => serializer.serialize_i32(7),
22556            Self::ApiKeyIpAddressBlocked => serializer.serialize_i32(8),
22557            Self::ApiKeyAndroidAppBlocked => serializer.serialize_i32(9),
22558            Self::ApiKeyIosAppBlocked => serializer.serialize_i32(13),
22559            Self::RateLimitExceeded => serializer.serialize_i32(5),
22560            Self::ResourceQuotaExceeded => serializer.serialize_i32(6),
22561            Self::LocationTaxPolicyViolated => serializer.serialize_i32(10),
22562            Self::UserProjectDenied => serializer.serialize_i32(11),
22563            Self::ConsumerSuspended => serializer.serialize_i32(12),
22564            Self::ConsumerInvalid => serializer.serialize_i32(14),
22565            Self::SecurityPolicyViolated => serializer.serialize_i32(15),
22566            Self::AccessTokenExpired => serializer.serialize_i32(16),
22567            Self::AccessTokenScopeInsufficient => serializer.serialize_i32(17),
22568            Self::AccountStateInvalid => serializer.serialize_i32(18),
22569            Self::AccessTokenTypeUnsupported => serializer.serialize_i32(19),
22570            Self::CredentialsMissing => serializer.serialize_i32(20),
22571            Self::ResourceProjectInvalid => serializer.serialize_i32(21),
22572            Self::SessionCookieInvalid => serializer.serialize_i32(23),
22573            Self::UserBlockedByAdmin => serializer.serialize_i32(24),
22574            Self::ResourceUsageRestrictionViolated => serializer.serialize_i32(25),
22575            Self::SystemParameterUnsupported => serializer.serialize_i32(26),
22576            Self::OrgRestrictionViolation => serializer.serialize_i32(27),
22577            Self::OrgRestrictionHeaderInvalid => serializer.serialize_i32(28),
22578            Self::ServiceNotVisible => serializer.serialize_i32(29),
22579            Self::GcpSuspended => serializer.serialize_i32(30),
22580            Self::LocationPolicyViolated => serializer.serialize_i32(31),
22581            Self::MissingOrigin => serializer.serialize_i32(33),
22582            Self::OverloadedCredentials => serializer.serialize_i32(34),
22583            Self::UnknownValue(u) => u.0.serialize(serializer),
22584        }
22585    }
22586}
22587
22588impl<'de> serde::de::Deserialize<'de> for ErrorReason {
22589    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22590    where
22591        D: serde::Deserializer<'de>,
22592    {
22593        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ErrorReason>::new(
22594            ".google.api.ErrorReason",
22595        ))
22596    }
22597}
22598
22599/// An indicator of the behavior of a given field (for example, that a field
22600/// is required in requests, or given as output but ignored as input).
22601/// This **does not** change the behavior in protocol buffers itself; it only
22602/// denotes the behavior and may affect how API tooling handles the field.
22603///
22604/// Note: This enum **may** receive new values in the future.
22605///
22606/// # Working with unknown values
22607///
22608/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22609/// additional enum variants at any time. Adding new variants is not considered
22610/// a breaking change. Applications should write their code in anticipation of:
22611///
22612/// - New values appearing in future releases of the client library, **and**
22613/// - New values received dynamically, without application changes.
22614///
22615/// Please consult the [Working with enums] section in the user guide for some
22616/// guidelines.
22617///
22618/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22619#[derive(Clone, Debug, PartialEq)]
22620#[non_exhaustive]
22621pub enum FieldBehavior {
22622    /// Conventional default for enums. Do not use this.
22623    Unspecified,
22624    /// Specifically denotes a field as optional.
22625    /// While all fields in protocol buffers are optional, this may be specified
22626    /// for emphasis if appropriate.
22627    Optional,
22628    /// Denotes a field as required.
22629    /// This indicates that the field **must** be provided as part of the request,
22630    /// and failure to do so will cause an error (usually `INVALID_ARGUMENT`).
22631    Required,
22632    /// Denotes a field as output only.
22633    /// This indicates that the field is provided in responses, but including the
22634    /// field in a request does nothing (the server *must* ignore it and
22635    /// *must not* throw an error as a result of the field's presence).
22636    OutputOnly,
22637    /// Denotes a field as input only.
22638    /// This indicates that the field is provided in requests, and the
22639    /// corresponding field is not included in output.
22640    InputOnly,
22641    /// Denotes a field as immutable.
22642    /// This indicates that the field may be set once in a request to create a
22643    /// resource, but may not be changed thereafter.
22644    Immutable,
22645    /// Denotes that a (repeated) field is an unordered list.
22646    /// This indicates that the service may provide the elements of the list
22647    /// in any arbitrary  order, rather than the order the user originally
22648    /// provided. Additionally, the list's order may or may not be stable.
22649    UnorderedList,
22650    /// Denotes that this field returns a non-empty default value if not set.
22651    /// This indicates that if the user provides the empty value in a request,
22652    /// a non-empty value will be returned. The user will not be aware of what
22653    /// non-empty value to expect.
22654    NonEmptyDefault,
22655    /// Denotes that the field in a resource (a message annotated with
22656    /// google.api.resource) is used in the resource name to uniquely identify the
22657    /// resource. For AIP-compliant APIs, this should only be applied to the
22658    /// `name` field on the resource.
22659    ///
22660    /// This behavior should not be applied to references to other resources within
22661    /// the message.
22662    ///
22663    /// The identifier field of resources often have different field behavior
22664    /// depending on the request it is embedded in (e.g. for Create methods name
22665    /// is optional and unused, while for Update methods it is required). Instead
22666    /// of method-specific annotations, only `IDENTIFIER` is required.
22667    Identifier,
22668    /// If set, the enum was initialized with an unknown value.
22669    ///
22670    /// Applications can examine the value using [FieldBehavior::value] or
22671    /// [FieldBehavior::name].
22672    UnknownValue(field_behavior::UnknownValue),
22673}
22674
22675#[doc(hidden)]
22676pub mod field_behavior {
22677    #[allow(unused_imports)]
22678    use super::*;
22679    #[derive(Clone, Debug, PartialEq)]
22680    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22681}
22682
22683impl FieldBehavior {
22684    /// Gets the enum value.
22685    ///
22686    /// Returns `None` if the enum contains an unknown value deserialized from
22687    /// the string representation of enums.
22688    pub fn value(&self) -> std::option::Option<i32> {
22689        match self {
22690            Self::Unspecified => std::option::Option::Some(0),
22691            Self::Optional => std::option::Option::Some(1),
22692            Self::Required => std::option::Option::Some(2),
22693            Self::OutputOnly => std::option::Option::Some(3),
22694            Self::InputOnly => std::option::Option::Some(4),
22695            Self::Immutable => std::option::Option::Some(5),
22696            Self::UnorderedList => std::option::Option::Some(6),
22697            Self::NonEmptyDefault => std::option::Option::Some(7),
22698            Self::Identifier => std::option::Option::Some(8),
22699            Self::UnknownValue(u) => u.0.value(),
22700        }
22701    }
22702
22703    /// Gets the enum value as a string.
22704    ///
22705    /// Returns `None` if the enum contains an unknown value deserialized from
22706    /// the integer representation of enums.
22707    pub fn name(&self) -> std::option::Option<&str> {
22708        match self {
22709            Self::Unspecified => std::option::Option::Some("FIELD_BEHAVIOR_UNSPECIFIED"),
22710            Self::Optional => std::option::Option::Some("OPTIONAL"),
22711            Self::Required => std::option::Option::Some("REQUIRED"),
22712            Self::OutputOnly => std::option::Option::Some("OUTPUT_ONLY"),
22713            Self::InputOnly => std::option::Option::Some("INPUT_ONLY"),
22714            Self::Immutable => std::option::Option::Some("IMMUTABLE"),
22715            Self::UnorderedList => std::option::Option::Some("UNORDERED_LIST"),
22716            Self::NonEmptyDefault => std::option::Option::Some("NON_EMPTY_DEFAULT"),
22717            Self::Identifier => std::option::Option::Some("IDENTIFIER"),
22718            Self::UnknownValue(u) => u.0.name(),
22719        }
22720    }
22721}
22722
22723impl std::default::Default for FieldBehavior {
22724    fn default() -> Self {
22725        use std::convert::From;
22726        Self::from(0)
22727    }
22728}
22729
22730impl std::fmt::Display for FieldBehavior {
22731    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22732        wkt::internal::display_enum(f, self.name(), self.value())
22733    }
22734}
22735
22736impl std::convert::From<i32> for FieldBehavior {
22737    fn from(value: i32) -> Self {
22738        match value {
22739            0 => Self::Unspecified,
22740            1 => Self::Optional,
22741            2 => Self::Required,
22742            3 => Self::OutputOnly,
22743            4 => Self::InputOnly,
22744            5 => Self::Immutable,
22745            6 => Self::UnorderedList,
22746            7 => Self::NonEmptyDefault,
22747            8 => Self::Identifier,
22748            _ => Self::UnknownValue(field_behavior::UnknownValue(
22749                wkt::internal::UnknownEnumValue::Integer(value),
22750            )),
22751        }
22752    }
22753}
22754
22755impl std::convert::From<&str> for FieldBehavior {
22756    fn from(value: &str) -> Self {
22757        use std::string::ToString;
22758        match value {
22759            "FIELD_BEHAVIOR_UNSPECIFIED" => Self::Unspecified,
22760            "OPTIONAL" => Self::Optional,
22761            "REQUIRED" => Self::Required,
22762            "OUTPUT_ONLY" => Self::OutputOnly,
22763            "INPUT_ONLY" => Self::InputOnly,
22764            "IMMUTABLE" => Self::Immutable,
22765            "UNORDERED_LIST" => Self::UnorderedList,
22766            "NON_EMPTY_DEFAULT" => Self::NonEmptyDefault,
22767            "IDENTIFIER" => Self::Identifier,
22768            _ => Self::UnknownValue(field_behavior::UnknownValue(
22769                wkt::internal::UnknownEnumValue::String(value.to_string()),
22770            )),
22771        }
22772    }
22773}
22774
22775impl serde::ser::Serialize for FieldBehavior {
22776    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22777    where
22778        S: serde::Serializer,
22779    {
22780        match self {
22781            Self::Unspecified => serializer.serialize_i32(0),
22782            Self::Optional => serializer.serialize_i32(1),
22783            Self::Required => serializer.serialize_i32(2),
22784            Self::OutputOnly => serializer.serialize_i32(3),
22785            Self::InputOnly => serializer.serialize_i32(4),
22786            Self::Immutable => serializer.serialize_i32(5),
22787            Self::UnorderedList => serializer.serialize_i32(6),
22788            Self::NonEmptyDefault => serializer.serialize_i32(7),
22789            Self::Identifier => serializer.serialize_i32(8),
22790            Self::UnknownValue(u) => u.0.serialize(serializer),
22791        }
22792    }
22793}
22794
22795impl<'de> serde::de::Deserialize<'de> for FieldBehavior {
22796    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22797    where
22798        D: serde::Deserializer<'de>,
22799    {
22800        deserializer.deserialize_any(wkt::internal::EnumVisitor::<FieldBehavior>::new(
22801            ".google.api.FieldBehavior",
22802        ))
22803    }
22804}
22805
22806/// The launch stage as defined by [Google Cloud Platform
22807/// Launch Stages](https://cloud.google.com/terms/launch-stages).
22808///
22809/// # Working with unknown values
22810///
22811/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
22812/// additional enum variants at any time. Adding new variants is not considered
22813/// a breaking change. Applications should write their code in anticipation of:
22814///
22815/// - New values appearing in future releases of the client library, **and**
22816/// - New values received dynamically, without application changes.
22817///
22818/// Please consult the [Working with enums] section in the user guide for some
22819/// guidelines.
22820///
22821/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
22822#[derive(Clone, Debug, PartialEq)]
22823#[non_exhaustive]
22824pub enum LaunchStage {
22825    /// Do not use this default value.
22826    Unspecified,
22827    /// The feature is not yet implemented. Users can not use it.
22828    Unimplemented,
22829    /// Prelaunch features are hidden from users and are only visible internally.
22830    Prelaunch,
22831    /// Early Access features are limited to a closed group of testers. To use
22832    /// these features, you must sign up in advance and sign a Trusted Tester
22833    /// agreement (which includes confidentiality provisions). These features may
22834    /// be unstable, changed in backward-incompatible ways, and are not
22835    /// guaranteed to be released.
22836    EarlyAccess,
22837    /// Alpha is a limited availability test for releases before they are cleared
22838    /// for widespread use. By Alpha, all significant design issues are resolved
22839    /// and we are in the process of verifying functionality. Alpha customers
22840    /// need to apply for access, agree to applicable terms, and have their
22841    /// projects allowlisted. Alpha releases don't have to be feature complete,
22842    /// no SLAs are provided, and there are no technical support obligations, but
22843    /// they will be far enough along that customers can actually use them in
22844    /// test environments or for limited-use tests -- just like they would in
22845    /// normal production cases.
22846    Alpha,
22847    /// Beta is the point at which we are ready to open a release for any
22848    /// customer to use. There are no SLA or technical support obligations in a
22849    /// Beta release. Products will be complete from a feature perspective, but
22850    /// may have some open outstanding issues. Beta releases are suitable for
22851    /// limited production use cases.
22852    Beta,
22853    /// GA features are open to all developers and are considered stable and
22854    /// fully qualified for production use.
22855    Ga,
22856    /// Deprecated features are scheduled to be shut down and removed. For more
22857    /// information, see the "Deprecation Policy" section of our [Terms of
22858    /// Service](https://cloud.google.com/terms/)
22859    /// and the [Google Cloud Platform Subject to the Deprecation
22860    /// Policy](https://cloud.google.com/terms/deprecation) documentation.
22861    Deprecated,
22862    /// If set, the enum was initialized with an unknown value.
22863    ///
22864    /// Applications can examine the value using [LaunchStage::value] or
22865    /// [LaunchStage::name].
22866    UnknownValue(launch_stage::UnknownValue),
22867}
22868
22869#[doc(hidden)]
22870pub mod launch_stage {
22871    #[allow(unused_imports)]
22872    use super::*;
22873    #[derive(Clone, Debug, PartialEq)]
22874    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
22875}
22876
22877impl LaunchStage {
22878    /// Gets the enum value.
22879    ///
22880    /// Returns `None` if the enum contains an unknown value deserialized from
22881    /// the string representation of enums.
22882    pub fn value(&self) -> std::option::Option<i32> {
22883        match self {
22884            Self::Unspecified => std::option::Option::Some(0),
22885            Self::Unimplemented => std::option::Option::Some(6),
22886            Self::Prelaunch => std::option::Option::Some(7),
22887            Self::EarlyAccess => std::option::Option::Some(1),
22888            Self::Alpha => std::option::Option::Some(2),
22889            Self::Beta => std::option::Option::Some(3),
22890            Self::Ga => std::option::Option::Some(4),
22891            Self::Deprecated => std::option::Option::Some(5),
22892            Self::UnknownValue(u) => u.0.value(),
22893        }
22894    }
22895
22896    /// Gets the enum value as a string.
22897    ///
22898    /// Returns `None` if the enum contains an unknown value deserialized from
22899    /// the integer representation of enums.
22900    pub fn name(&self) -> std::option::Option<&str> {
22901        match self {
22902            Self::Unspecified => std::option::Option::Some("LAUNCH_STAGE_UNSPECIFIED"),
22903            Self::Unimplemented => std::option::Option::Some("UNIMPLEMENTED"),
22904            Self::Prelaunch => std::option::Option::Some("PRELAUNCH"),
22905            Self::EarlyAccess => std::option::Option::Some("EARLY_ACCESS"),
22906            Self::Alpha => std::option::Option::Some("ALPHA"),
22907            Self::Beta => std::option::Option::Some("BETA"),
22908            Self::Ga => std::option::Option::Some("GA"),
22909            Self::Deprecated => std::option::Option::Some("DEPRECATED"),
22910            Self::UnknownValue(u) => u.0.name(),
22911        }
22912    }
22913}
22914
22915impl std::default::Default for LaunchStage {
22916    fn default() -> Self {
22917        use std::convert::From;
22918        Self::from(0)
22919    }
22920}
22921
22922impl std::fmt::Display for LaunchStage {
22923    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
22924        wkt::internal::display_enum(f, self.name(), self.value())
22925    }
22926}
22927
22928impl std::convert::From<i32> for LaunchStage {
22929    fn from(value: i32) -> Self {
22930        match value {
22931            0 => Self::Unspecified,
22932            1 => Self::EarlyAccess,
22933            2 => Self::Alpha,
22934            3 => Self::Beta,
22935            4 => Self::Ga,
22936            5 => Self::Deprecated,
22937            6 => Self::Unimplemented,
22938            7 => Self::Prelaunch,
22939            _ => Self::UnknownValue(launch_stage::UnknownValue(
22940                wkt::internal::UnknownEnumValue::Integer(value),
22941            )),
22942        }
22943    }
22944}
22945
22946impl std::convert::From<&str> for LaunchStage {
22947    fn from(value: &str) -> Self {
22948        use std::string::ToString;
22949        match value {
22950            "LAUNCH_STAGE_UNSPECIFIED" => Self::Unspecified,
22951            "UNIMPLEMENTED" => Self::Unimplemented,
22952            "PRELAUNCH" => Self::Prelaunch,
22953            "EARLY_ACCESS" => Self::EarlyAccess,
22954            "ALPHA" => Self::Alpha,
22955            "BETA" => Self::Beta,
22956            "GA" => Self::Ga,
22957            "DEPRECATED" => Self::Deprecated,
22958            _ => Self::UnknownValue(launch_stage::UnknownValue(
22959                wkt::internal::UnknownEnumValue::String(value.to_string()),
22960            )),
22961        }
22962    }
22963}
22964
22965impl serde::ser::Serialize for LaunchStage {
22966    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
22967    where
22968        S: serde::Serializer,
22969    {
22970        match self {
22971            Self::Unspecified => serializer.serialize_i32(0),
22972            Self::Unimplemented => serializer.serialize_i32(6),
22973            Self::Prelaunch => serializer.serialize_i32(7),
22974            Self::EarlyAccess => serializer.serialize_i32(1),
22975            Self::Alpha => serializer.serialize_i32(2),
22976            Self::Beta => serializer.serialize_i32(3),
22977            Self::Ga => serializer.serialize_i32(4),
22978            Self::Deprecated => serializer.serialize_i32(5),
22979            Self::UnknownValue(u) => u.0.serialize(serializer),
22980        }
22981    }
22982}
22983
22984impl<'de> serde::de::Deserialize<'de> for LaunchStage {
22985    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
22986    where
22987        D: serde::Deserializer<'de>,
22988    {
22989        deserializer.deserialize_any(wkt::internal::EnumVisitor::<LaunchStage>::new(
22990            ".google.api.LaunchStage",
22991        ))
22992    }
22993}