google_cloud_rpc/
model.rs

1// Copyright 2024 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27/// Describes the cause of the error with structured details.
28///
29/// Example of an error when contacting the "pubsub.googleapis.com" API when it
30/// is not enabled:
31///
32/// ```norust
33/// { "reason": "API_DISABLED"
34///   "domain": "googleapis.com"
35///   "metadata": {
36///     "resource": "projects/123",
37///     "service": "pubsub.googleapis.com"
38///   }
39/// }
40/// ```
41///
42/// This response indicates that the pubsub.googleapis.com API is not enabled.
43///
44/// Example of an error that is returned when attempting to create a Spanner
45/// instance in a region that is out of stock:
46///
47/// ```norust
48/// { "reason": "STOCKOUT"
49///   "domain": "spanner.googleapis.com",
50///   "metadata": {
51///     "availableRegions": "us-central1,us-east2"
52///   }
53/// }
54/// ```
55#[derive(Clone, Default, PartialEq)]
56#[non_exhaustive]
57pub struct ErrorInfo {
58    /// The reason of the error. This is a constant value that identifies the
59    /// proximate cause of the error. Error reasons are unique within a particular
60    /// domain of errors. This should be at most 63 characters and match a
61    /// regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
62    /// UPPER_SNAKE_CASE.
63    pub reason: std::string::String,
64
65    /// The logical grouping to which the "reason" belongs. The error domain
66    /// is typically the registered service name of the tool or product that
67    /// generates the error. Example: "pubsub.googleapis.com". If the error is
68    /// generated by some common infrastructure, the error domain must be a
69    /// globally unique value that identifies the infrastructure. For Google API
70    /// infrastructure, the error domain is "googleapis.com".
71    pub domain: std::string::String,
72
73    /// Additional structured details about this error.
74    ///
75    /// Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should
76    /// ideally be lowerCamelCase. Also, they must be limited to 64 characters in
77    /// length. When identifying the current value of an exceeded limit, the units
78    /// should be contained in the key, not the value.  For example, rather than
79    /// `{"instanceLimit": "100/request"}`, should be returned as,
80    /// `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of
81    /// instances that can be created in a single (batch) request.
82    pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
83
84    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
85}
86
87impl ErrorInfo {
88    pub fn new() -> Self {
89        std::default::Default::default()
90    }
91
92    /// Sets the value of [reason][crate::model::ErrorInfo::reason].
93    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
94        self.reason = v.into();
95        self
96    }
97
98    /// Sets the value of [domain][crate::model::ErrorInfo::domain].
99    pub fn set_domain<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
100        self.domain = v.into();
101        self
102    }
103
104    /// Sets the value of [metadata][crate::model::ErrorInfo::metadata].
105    pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
106    where
107        T: std::iter::IntoIterator<Item = (K, V)>,
108        K: std::convert::Into<std::string::String>,
109        V: std::convert::Into<std::string::String>,
110    {
111        use std::iter::Iterator;
112        self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
113        self
114    }
115}
116
117impl wkt::message::Message for ErrorInfo {
118    fn typename() -> &'static str {
119        "type.googleapis.com/google.rpc.ErrorInfo"
120    }
121}
122
123#[doc(hidden)]
124impl<'de> serde::de::Deserialize<'de> for ErrorInfo {
125    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
126    where
127        D: serde::Deserializer<'de>,
128    {
129        #[allow(non_camel_case_types)]
130        #[doc(hidden)]
131        #[derive(PartialEq, Eq, Hash)]
132        enum __FieldTag {
133            __reason,
134            __domain,
135            __metadata,
136            Unknown(std::string::String),
137        }
138        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
139            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
140            where
141                D: serde::Deserializer<'de>,
142            {
143                struct Visitor;
144                impl<'de> serde::de::Visitor<'de> for Visitor {
145                    type Value = __FieldTag;
146                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
147                        formatter.write_str("a field name for ErrorInfo")
148                    }
149                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
150                    where
151                        E: serde::de::Error,
152                    {
153                        use std::result::Result::Ok;
154                        use std::string::ToString;
155                        match value {
156                            "reason" => Ok(__FieldTag::__reason),
157                            "domain" => Ok(__FieldTag::__domain),
158                            "metadata" => Ok(__FieldTag::__metadata),
159                            _ => Ok(__FieldTag::Unknown(value.to_string())),
160                        }
161                    }
162                }
163                deserializer.deserialize_identifier(Visitor)
164            }
165        }
166        struct Visitor;
167        impl<'de> serde::de::Visitor<'de> for Visitor {
168            type Value = ErrorInfo;
169            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
170                formatter.write_str("struct ErrorInfo")
171            }
172            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
173            where
174                A: serde::de::MapAccess<'de>,
175            {
176                #[allow(unused_imports)]
177                use serde::de::Error;
178                use std::option::Option::Some;
179                let mut fields = std::collections::HashSet::new();
180                let mut result = Self::Value::new();
181                while let Some(tag) = map.next_key::<__FieldTag>()? {
182                    #[allow(clippy::match_single_binding)]
183                    match tag {
184                        __FieldTag::__reason => {
185                            if !fields.insert(__FieldTag::__reason) {
186                                return std::result::Result::Err(A::Error::duplicate_field(
187                                    "multiple values for reason",
188                                ));
189                            }
190                            result.reason = map
191                                .next_value::<std::option::Option<std::string::String>>()?
192                                .unwrap_or_default();
193                        }
194                        __FieldTag::__domain => {
195                            if !fields.insert(__FieldTag::__domain) {
196                                return std::result::Result::Err(A::Error::duplicate_field(
197                                    "multiple values for domain",
198                                ));
199                            }
200                            result.domain = map
201                                .next_value::<std::option::Option<std::string::String>>()?
202                                .unwrap_or_default();
203                        }
204                        __FieldTag::__metadata => {
205                            if !fields.insert(__FieldTag::__metadata) {
206                                return std::result::Result::Err(A::Error::duplicate_field(
207                                    "multiple values for metadata",
208                                ));
209                            }
210                            result.metadata = map
211                                .next_value::<std::option::Option<
212                                    std::collections::HashMap<
213                                        std::string::String,
214                                        std::string::String,
215                                    >,
216                                >>()?
217                                .unwrap_or_default();
218                        }
219                        __FieldTag::Unknown(key) => {
220                            let value = map.next_value::<serde_json::Value>()?;
221                            result._unknown_fields.insert(key, value);
222                        }
223                    }
224                }
225                std::result::Result::Ok(result)
226            }
227        }
228        deserializer.deserialize_any(Visitor)
229    }
230}
231
232#[doc(hidden)]
233impl serde::ser::Serialize for ErrorInfo {
234    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
235    where
236        S: serde::ser::Serializer,
237    {
238        use serde::ser::SerializeMap;
239        #[allow(unused_imports)]
240        use std::option::Option::Some;
241        let mut state = serializer.serialize_map(std::option::Option::None)?;
242        if !self.reason.is_empty() {
243            state.serialize_entry("reason", &self.reason)?;
244        }
245        if !self.domain.is_empty() {
246            state.serialize_entry("domain", &self.domain)?;
247        }
248        if !self.metadata.is_empty() {
249            state.serialize_entry("metadata", &self.metadata)?;
250        }
251        if !self._unknown_fields.is_empty() {
252            for (key, value) in self._unknown_fields.iter() {
253                state.serialize_entry(key, &value)?;
254            }
255        }
256        state.end()
257    }
258}
259
260impl std::fmt::Debug for ErrorInfo {
261    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
262        let mut debug_struct = f.debug_struct("ErrorInfo");
263        debug_struct.field("reason", &self.reason);
264        debug_struct.field("domain", &self.domain);
265        debug_struct.field("metadata", &self.metadata);
266        if !self._unknown_fields.is_empty() {
267            debug_struct.field("_unknown_fields", &self._unknown_fields);
268        }
269        debug_struct.finish()
270    }
271}
272
273/// Describes when the clients can retry a failed request. Clients could ignore
274/// the recommendation here or retry when this information is missing from error
275/// responses.
276///
277/// It's always recommended that clients should use exponential backoff when
278/// retrying.
279///
280/// Clients should wait until `retry_delay` amount of time has passed since
281/// receiving the error response before retrying.  If retrying requests also
282/// fail, clients should use an exponential backoff scheme to gradually increase
283/// the delay between retries based on `retry_delay`, until either a maximum
284/// number of retries have been reached or a maximum retry delay cap has been
285/// reached.
286#[derive(Clone, Default, PartialEq)]
287#[non_exhaustive]
288pub struct RetryInfo {
289    /// Clients should wait at least this long between retrying the same request.
290    pub retry_delay: std::option::Option<wkt::Duration>,
291
292    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
293}
294
295impl RetryInfo {
296    pub fn new() -> Self {
297        std::default::Default::default()
298    }
299
300    /// Sets the value of [retry_delay][crate::model::RetryInfo::retry_delay].
301    pub fn set_retry_delay<T>(mut self, v: T) -> Self
302    where
303        T: std::convert::Into<wkt::Duration>,
304    {
305        self.retry_delay = std::option::Option::Some(v.into());
306        self
307    }
308
309    /// Sets or clears the value of [retry_delay][crate::model::RetryInfo::retry_delay].
310    pub fn set_or_clear_retry_delay<T>(mut self, v: std::option::Option<T>) -> Self
311    where
312        T: std::convert::Into<wkt::Duration>,
313    {
314        self.retry_delay = v.map(|x| x.into());
315        self
316    }
317}
318
319impl wkt::message::Message for RetryInfo {
320    fn typename() -> &'static str {
321        "type.googleapis.com/google.rpc.RetryInfo"
322    }
323}
324
325#[doc(hidden)]
326impl<'de> serde::de::Deserialize<'de> for RetryInfo {
327    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
328    where
329        D: serde::Deserializer<'de>,
330    {
331        #[allow(non_camel_case_types)]
332        #[doc(hidden)]
333        #[derive(PartialEq, Eq, Hash)]
334        enum __FieldTag {
335            __retry_delay,
336            Unknown(std::string::String),
337        }
338        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
339            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
340            where
341                D: serde::Deserializer<'de>,
342            {
343                struct Visitor;
344                impl<'de> serde::de::Visitor<'de> for Visitor {
345                    type Value = __FieldTag;
346                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
347                        formatter.write_str("a field name for RetryInfo")
348                    }
349                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
350                    where
351                        E: serde::de::Error,
352                    {
353                        use std::result::Result::Ok;
354                        use std::string::ToString;
355                        match value {
356                            "retryDelay" => Ok(__FieldTag::__retry_delay),
357                            "retry_delay" => Ok(__FieldTag::__retry_delay),
358                            _ => Ok(__FieldTag::Unknown(value.to_string())),
359                        }
360                    }
361                }
362                deserializer.deserialize_identifier(Visitor)
363            }
364        }
365        struct Visitor;
366        impl<'de> serde::de::Visitor<'de> for Visitor {
367            type Value = RetryInfo;
368            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
369                formatter.write_str("struct RetryInfo")
370            }
371            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
372            where
373                A: serde::de::MapAccess<'de>,
374            {
375                #[allow(unused_imports)]
376                use serde::de::Error;
377                use std::option::Option::Some;
378                let mut fields = std::collections::HashSet::new();
379                let mut result = Self::Value::new();
380                while let Some(tag) = map.next_key::<__FieldTag>()? {
381                    #[allow(clippy::match_single_binding)]
382                    match tag {
383                        __FieldTag::__retry_delay => {
384                            if !fields.insert(__FieldTag::__retry_delay) {
385                                return std::result::Result::Err(A::Error::duplicate_field(
386                                    "multiple values for retry_delay",
387                                ));
388                            }
389                            result.retry_delay =
390                                map.next_value::<std::option::Option<wkt::Duration>>()?;
391                        }
392                        __FieldTag::Unknown(key) => {
393                            let value = map.next_value::<serde_json::Value>()?;
394                            result._unknown_fields.insert(key, value);
395                        }
396                    }
397                }
398                std::result::Result::Ok(result)
399            }
400        }
401        deserializer.deserialize_any(Visitor)
402    }
403}
404
405#[doc(hidden)]
406impl serde::ser::Serialize for RetryInfo {
407    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
408    where
409        S: serde::ser::Serializer,
410    {
411        use serde::ser::SerializeMap;
412        #[allow(unused_imports)]
413        use std::option::Option::Some;
414        let mut state = serializer.serialize_map(std::option::Option::None)?;
415        if self.retry_delay.is_some() {
416            state.serialize_entry("retryDelay", &self.retry_delay)?;
417        }
418        if !self._unknown_fields.is_empty() {
419            for (key, value) in self._unknown_fields.iter() {
420                state.serialize_entry(key, &value)?;
421            }
422        }
423        state.end()
424    }
425}
426
427impl std::fmt::Debug for RetryInfo {
428    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
429        let mut debug_struct = f.debug_struct("RetryInfo");
430        debug_struct.field("retry_delay", &self.retry_delay);
431        if !self._unknown_fields.is_empty() {
432            debug_struct.field("_unknown_fields", &self._unknown_fields);
433        }
434        debug_struct.finish()
435    }
436}
437
438/// Describes additional debugging info.
439#[derive(Clone, Default, PartialEq)]
440#[non_exhaustive]
441pub struct DebugInfo {
442    /// The stack trace entries indicating where the error occurred.
443    pub stack_entries: std::vec::Vec<std::string::String>,
444
445    /// Additional debugging information provided by the server.
446    pub detail: std::string::String,
447
448    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
449}
450
451impl DebugInfo {
452    pub fn new() -> Self {
453        std::default::Default::default()
454    }
455
456    /// Sets the value of [stack_entries][crate::model::DebugInfo::stack_entries].
457    pub fn set_stack_entries<T, V>(mut self, v: T) -> Self
458    where
459        T: std::iter::IntoIterator<Item = V>,
460        V: std::convert::Into<std::string::String>,
461    {
462        use std::iter::Iterator;
463        self.stack_entries = v.into_iter().map(|i| i.into()).collect();
464        self
465    }
466
467    /// Sets the value of [detail][crate::model::DebugInfo::detail].
468    pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
469        self.detail = v.into();
470        self
471    }
472}
473
474impl wkt::message::Message for DebugInfo {
475    fn typename() -> &'static str {
476        "type.googleapis.com/google.rpc.DebugInfo"
477    }
478}
479
480#[doc(hidden)]
481impl<'de> serde::de::Deserialize<'de> for DebugInfo {
482    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
483    where
484        D: serde::Deserializer<'de>,
485    {
486        #[allow(non_camel_case_types)]
487        #[doc(hidden)]
488        #[derive(PartialEq, Eq, Hash)]
489        enum __FieldTag {
490            __stack_entries,
491            __detail,
492            Unknown(std::string::String),
493        }
494        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
495            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
496            where
497                D: serde::Deserializer<'de>,
498            {
499                struct Visitor;
500                impl<'de> serde::de::Visitor<'de> for Visitor {
501                    type Value = __FieldTag;
502                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
503                        formatter.write_str("a field name for DebugInfo")
504                    }
505                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
506                    where
507                        E: serde::de::Error,
508                    {
509                        use std::result::Result::Ok;
510                        use std::string::ToString;
511                        match value {
512                            "stackEntries" => Ok(__FieldTag::__stack_entries),
513                            "stack_entries" => Ok(__FieldTag::__stack_entries),
514                            "detail" => Ok(__FieldTag::__detail),
515                            _ => Ok(__FieldTag::Unknown(value.to_string())),
516                        }
517                    }
518                }
519                deserializer.deserialize_identifier(Visitor)
520            }
521        }
522        struct Visitor;
523        impl<'de> serde::de::Visitor<'de> for Visitor {
524            type Value = DebugInfo;
525            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
526                formatter.write_str("struct DebugInfo")
527            }
528            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
529            where
530                A: serde::de::MapAccess<'de>,
531            {
532                #[allow(unused_imports)]
533                use serde::de::Error;
534                use std::option::Option::Some;
535                let mut fields = std::collections::HashSet::new();
536                let mut result = Self::Value::new();
537                while let Some(tag) = map.next_key::<__FieldTag>()? {
538                    #[allow(clippy::match_single_binding)]
539                    match tag {
540                        __FieldTag::__stack_entries => {
541                            if !fields.insert(__FieldTag::__stack_entries) {
542                                return std::result::Result::Err(A::Error::duplicate_field(
543                                    "multiple values for stack_entries",
544                                ));
545                            }
546                            result.stack_entries = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
547                        }
548                        __FieldTag::__detail => {
549                            if !fields.insert(__FieldTag::__detail) {
550                                return std::result::Result::Err(A::Error::duplicate_field(
551                                    "multiple values for detail",
552                                ));
553                            }
554                            result.detail = map
555                                .next_value::<std::option::Option<std::string::String>>()?
556                                .unwrap_or_default();
557                        }
558                        __FieldTag::Unknown(key) => {
559                            let value = map.next_value::<serde_json::Value>()?;
560                            result._unknown_fields.insert(key, value);
561                        }
562                    }
563                }
564                std::result::Result::Ok(result)
565            }
566        }
567        deserializer.deserialize_any(Visitor)
568    }
569}
570
571#[doc(hidden)]
572impl serde::ser::Serialize for DebugInfo {
573    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
574    where
575        S: serde::ser::Serializer,
576    {
577        use serde::ser::SerializeMap;
578        #[allow(unused_imports)]
579        use std::option::Option::Some;
580        let mut state = serializer.serialize_map(std::option::Option::None)?;
581        if !self.stack_entries.is_empty() {
582            state.serialize_entry("stackEntries", &self.stack_entries)?;
583        }
584        if !self.detail.is_empty() {
585            state.serialize_entry("detail", &self.detail)?;
586        }
587        if !self._unknown_fields.is_empty() {
588            for (key, value) in self._unknown_fields.iter() {
589                state.serialize_entry(key, &value)?;
590            }
591        }
592        state.end()
593    }
594}
595
596impl std::fmt::Debug for DebugInfo {
597    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
598        let mut debug_struct = f.debug_struct("DebugInfo");
599        debug_struct.field("stack_entries", &self.stack_entries);
600        debug_struct.field("detail", &self.detail);
601        if !self._unknown_fields.is_empty() {
602            debug_struct.field("_unknown_fields", &self._unknown_fields);
603        }
604        debug_struct.finish()
605    }
606}
607
608/// Describes how a quota check failed.
609///
610/// For example if a daily limit was exceeded for the calling project,
611/// a service could respond with a QuotaFailure detail containing the project
612/// id and the description of the quota limit that was exceeded.  If the
613/// calling project hasn't enabled the service in the developer console, then
614/// a service could respond with the project id and set `service_disabled`
615/// to true.
616///
617/// Also see RetryInfo and Help types for other details about handling a
618/// quota failure.
619#[derive(Clone, Default, PartialEq)]
620#[non_exhaustive]
621pub struct QuotaFailure {
622    /// Describes all quota violations.
623    pub violations: std::vec::Vec<crate::model::quota_failure::Violation>,
624
625    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
626}
627
628impl QuotaFailure {
629    pub fn new() -> Self {
630        std::default::Default::default()
631    }
632
633    /// Sets the value of [violations][crate::model::QuotaFailure::violations].
634    pub fn set_violations<T, V>(mut self, v: T) -> Self
635    where
636        T: std::iter::IntoIterator<Item = V>,
637        V: std::convert::Into<crate::model::quota_failure::Violation>,
638    {
639        use std::iter::Iterator;
640        self.violations = v.into_iter().map(|i| i.into()).collect();
641        self
642    }
643}
644
645impl wkt::message::Message for QuotaFailure {
646    fn typename() -> &'static str {
647        "type.googleapis.com/google.rpc.QuotaFailure"
648    }
649}
650
651#[doc(hidden)]
652impl<'de> serde::de::Deserialize<'de> for QuotaFailure {
653    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
654    where
655        D: serde::Deserializer<'de>,
656    {
657        #[allow(non_camel_case_types)]
658        #[doc(hidden)]
659        #[derive(PartialEq, Eq, Hash)]
660        enum __FieldTag {
661            __violations,
662            Unknown(std::string::String),
663        }
664        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
665            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
666            where
667                D: serde::Deserializer<'de>,
668            {
669                struct Visitor;
670                impl<'de> serde::de::Visitor<'de> for Visitor {
671                    type Value = __FieldTag;
672                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
673                        formatter.write_str("a field name for QuotaFailure")
674                    }
675                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
676                    where
677                        E: serde::de::Error,
678                    {
679                        use std::result::Result::Ok;
680                        use std::string::ToString;
681                        match value {
682                            "violations" => Ok(__FieldTag::__violations),
683                            _ => Ok(__FieldTag::Unknown(value.to_string())),
684                        }
685                    }
686                }
687                deserializer.deserialize_identifier(Visitor)
688            }
689        }
690        struct Visitor;
691        impl<'de> serde::de::Visitor<'de> for Visitor {
692            type Value = QuotaFailure;
693            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
694                formatter.write_str("struct QuotaFailure")
695            }
696            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
697            where
698                A: serde::de::MapAccess<'de>,
699            {
700                #[allow(unused_imports)]
701                use serde::de::Error;
702                use std::option::Option::Some;
703                let mut fields = std::collections::HashSet::new();
704                let mut result = Self::Value::new();
705                while let Some(tag) = map.next_key::<__FieldTag>()? {
706                    #[allow(clippy::match_single_binding)]
707                    match tag {
708                        __FieldTag::__violations => {
709                            if !fields.insert(__FieldTag::__violations) {
710                                return std::result::Result::Err(A::Error::duplicate_field(
711                                    "multiple values for violations",
712                                ));
713                            }
714                            result.violations = map
715                                .next_value::<std::option::Option<
716                                    std::vec::Vec<crate::model::quota_failure::Violation>,
717                                >>()?
718                                .unwrap_or_default();
719                        }
720                        __FieldTag::Unknown(key) => {
721                            let value = map.next_value::<serde_json::Value>()?;
722                            result._unknown_fields.insert(key, value);
723                        }
724                    }
725                }
726                std::result::Result::Ok(result)
727            }
728        }
729        deserializer.deserialize_any(Visitor)
730    }
731}
732
733#[doc(hidden)]
734impl serde::ser::Serialize for QuotaFailure {
735    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
736    where
737        S: serde::ser::Serializer,
738    {
739        use serde::ser::SerializeMap;
740        #[allow(unused_imports)]
741        use std::option::Option::Some;
742        let mut state = serializer.serialize_map(std::option::Option::None)?;
743        if !self.violations.is_empty() {
744            state.serialize_entry("violations", &self.violations)?;
745        }
746        if !self._unknown_fields.is_empty() {
747            for (key, value) in self._unknown_fields.iter() {
748                state.serialize_entry(key, &value)?;
749            }
750        }
751        state.end()
752    }
753}
754
755impl std::fmt::Debug for QuotaFailure {
756    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
757        let mut debug_struct = f.debug_struct("QuotaFailure");
758        debug_struct.field("violations", &self.violations);
759        if !self._unknown_fields.is_empty() {
760            debug_struct.field("_unknown_fields", &self._unknown_fields);
761        }
762        debug_struct.finish()
763    }
764}
765
766/// Defines additional types related to [QuotaFailure].
767pub mod quota_failure {
768    #[allow(unused_imports)]
769    use super::*;
770
771    /// A message type used to describe a single quota violation.  For example, a
772    /// daily quota or a custom quota that was exceeded.
773    #[derive(Clone, Default, PartialEq)]
774    #[non_exhaustive]
775    pub struct Violation {
776        /// The subject on which the quota check failed.
777        /// For example, "clientip:\<ip address of client\>" or "project:\<Google
778        /// developer project id\>".
779        pub subject: std::string::String,
780
781        /// A description of how the quota check failed. Clients can use this
782        /// description to find more about the quota configuration in the service's
783        /// public documentation, or find the relevant quota limit to adjust through
784        /// developer console.
785        ///
786        /// For example: "Service disabled" or "Daily Limit for read operations
787        /// exceeded".
788        pub description: std::string::String,
789
790        /// The API Service from which the `QuotaFailure.Violation` orginates. In
791        /// some cases, Quota issues originate from an API Service other than the one
792        /// that was called. In other words, a dependency of the called API Service
793        /// could be the cause of the `QuotaFailure`, and this field would have the
794        /// dependency API service name.
795        ///
796        /// For example, if the called API is Kubernetes Engine API
797        /// (container.googleapis.com), and a quota violation occurs in the
798        /// Kubernetes Engine API itself, this field would be
799        /// "container.googleapis.com". On the other hand, if the quota violation
800        /// occurs when the Kubernetes Engine API creates VMs in the Compute Engine
801        /// API (compute.googleapis.com), this field would be
802        /// "compute.googleapis.com".
803        pub api_service: std::string::String,
804
805        /// The metric of the violated quota. A quota metric is a named counter to
806        /// measure usage, such as API requests or CPUs. When an activity occurs in a
807        /// service, such as Virtual Machine allocation, one or more quota metrics
808        /// may be affected.
809        ///
810        /// For example, "compute.googleapis.com/cpus_per_vm_family",
811        /// "storage.googleapis.com/internet_egress_bandwidth".
812        pub quota_metric: std::string::String,
813
814        /// The id of the violated quota. Also know as "limit name", this is the
815        /// unique identifier of a quota in the context of an API service.
816        ///
817        /// For example, "CPUS-PER-VM-FAMILY-per-project-region".
818        pub quota_id: std::string::String,
819
820        /// The dimensions of the violated quota. Every non-global quota is enforced
821        /// on a set of dimensions. While quota metric defines what to count, the
822        /// dimensions specify for what aspects the counter should be increased.
823        ///
824        /// For example, the quota "CPUs per region per VM family" enforces a limit
825        /// on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions
826        /// "region" and "vm_family". And if the violation occurred in region
827        /// "us-central1" and for VM family "n1", the quota_dimensions would be,
828        ///
829        /// {
830        /// "region": "us-central1",
831        /// "vm_family": "n1",
832        /// }
833        ///
834        /// When a quota is enforced globally, the quota_dimensions would always be
835        /// empty.
836        pub quota_dimensions: std::collections::HashMap<std::string::String, std::string::String>,
837
838        /// The enforced quota value at the time of the `QuotaFailure`.
839        ///
840        /// For example, if the enforced quota value at the time of the
841        /// `QuotaFailure` on the number of CPUs is "10", then the value of this
842        /// field would reflect this quantity.
843        pub quota_value: i64,
844
845        /// The new quota value being rolled out at the time of the violation. At the
846        /// completion of the rollout, this value will be enforced in place of
847        /// quota_value. If no rollout is in progress at the time of the violation,
848        /// this field is not set.
849        ///
850        /// For example, if at the time of the violation a rollout is in progress
851        /// changing the number of CPUs quota from 10 to 20, 20 would be the value of
852        /// this field.
853        pub future_quota_value: std::option::Option<i64>,
854
855        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
856    }
857
858    impl Violation {
859        pub fn new() -> Self {
860            std::default::Default::default()
861        }
862
863        /// Sets the value of [subject][crate::model::quota_failure::Violation::subject].
864        pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
865            self.subject = v.into();
866            self
867        }
868
869        /// Sets the value of [description][crate::model::quota_failure::Violation::description].
870        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
871            self.description = v.into();
872            self
873        }
874
875        /// Sets the value of [api_service][crate::model::quota_failure::Violation::api_service].
876        pub fn set_api_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
877            self.api_service = v.into();
878            self
879        }
880
881        /// Sets the value of [quota_metric][crate::model::quota_failure::Violation::quota_metric].
882        pub fn set_quota_metric<T: std::convert::Into<std::string::String>>(
883            mut self,
884            v: T,
885        ) -> Self {
886            self.quota_metric = v.into();
887            self
888        }
889
890        /// Sets the value of [quota_id][crate::model::quota_failure::Violation::quota_id].
891        pub fn set_quota_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
892            self.quota_id = v.into();
893            self
894        }
895
896        /// Sets the value of [quota_dimensions][crate::model::quota_failure::Violation::quota_dimensions].
897        pub fn set_quota_dimensions<T, K, V>(mut self, v: T) -> Self
898        where
899            T: std::iter::IntoIterator<Item = (K, V)>,
900            K: std::convert::Into<std::string::String>,
901            V: std::convert::Into<std::string::String>,
902        {
903            use std::iter::Iterator;
904            self.quota_dimensions = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
905            self
906        }
907
908        /// Sets the value of [quota_value][crate::model::quota_failure::Violation::quota_value].
909        pub fn set_quota_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
910            self.quota_value = v.into();
911            self
912        }
913
914        /// Sets the value of [future_quota_value][crate::model::quota_failure::Violation::future_quota_value].
915        pub fn set_future_quota_value<T>(mut self, v: T) -> Self
916        where
917            T: std::convert::Into<i64>,
918        {
919            self.future_quota_value = std::option::Option::Some(v.into());
920            self
921        }
922
923        /// Sets or clears the value of [future_quota_value][crate::model::quota_failure::Violation::future_quota_value].
924        pub fn set_or_clear_future_quota_value<T>(mut self, v: std::option::Option<T>) -> Self
925        where
926            T: std::convert::Into<i64>,
927        {
928            self.future_quota_value = v.map(|x| x.into());
929            self
930        }
931    }
932
933    impl wkt::message::Message for Violation {
934        fn typename() -> &'static str {
935            "type.googleapis.com/google.rpc.QuotaFailure.Violation"
936        }
937    }
938
939    #[doc(hidden)]
940    impl<'de> serde::de::Deserialize<'de> for Violation {
941        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
942        where
943            D: serde::Deserializer<'de>,
944        {
945            #[allow(non_camel_case_types)]
946            #[doc(hidden)]
947            #[derive(PartialEq, Eq, Hash)]
948            enum __FieldTag {
949                __subject,
950                __description,
951                __api_service,
952                __quota_metric,
953                __quota_id,
954                __quota_dimensions,
955                __quota_value,
956                __future_quota_value,
957                Unknown(std::string::String),
958            }
959            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
960                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
961                where
962                    D: serde::Deserializer<'de>,
963                {
964                    struct Visitor;
965                    impl<'de> serde::de::Visitor<'de> for Visitor {
966                        type Value = __FieldTag;
967                        fn expecting(
968                            &self,
969                            formatter: &mut std::fmt::Formatter,
970                        ) -> std::fmt::Result {
971                            formatter.write_str("a field name for Violation")
972                        }
973                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
974                        where
975                            E: serde::de::Error,
976                        {
977                            use std::result::Result::Ok;
978                            use std::string::ToString;
979                            match value {
980                                "subject" => Ok(__FieldTag::__subject),
981                                "description" => Ok(__FieldTag::__description),
982                                "apiService" => Ok(__FieldTag::__api_service),
983                                "api_service" => Ok(__FieldTag::__api_service),
984                                "quotaMetric" => Ok(__FieldTag::__quota_metric),
985                                "quota_metric" => Ok(__FieldTag::__quota_metric),
986                                "quotaId" => Ok(__FieldTag::__quota_id),
987                                "quota_id" => Ok(__FieldTag::__quota_id),
988                                "quotaDimensions" => Ok(__FieldTag::__quota_dimensions),
989                                "quota_dimensions" => Ok(__FieldTag::__quota_dimensions),
990                                "quotaValue" => Ok(__FieldTag::__quota_value),
991                                "quota_value" => Ok(__FieldTag::__quota_value),
992                                "futureQuotaValue" => Ok(__FieldTag::__future_quota_value),
993                                "future_quota_value" => Ok(__FieldTag::__future_quota_value),
994                                _ => Ok(__FieldTag::Unknown(value.to_string())),
995                            }
996                        }
997                    }
998                    deserializer.deserialize_identifier(Visitor)
999                }
1000            }
1001            struct Visitor;
1002            impl<'de> serde::de::Visitor<'de> for Visitor {
1003                type Value = Violation;
1004                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1005                    formatter.write_str("struct Violation")
1006                }
1007                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1008                where
1009                    A: serde::de::MapAccess<'de>,
1010                {
1011                    #[allow(unused_imports)]
1012                    use serde::de::Error;
1013                    use std::option::Option::Some;
1014                    let mut fields = std::collections::HashSet::new();
1015                    let mut result = Self::Value::new();
1016                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1017                        #[allow(clippy::match_single_binding)]
1018                        match tag {
1019                            __FieldTag::__subject => {
1020                                if !fields.insert(__FieldTag::__subject) {
1021                                    return std::result::Result::Err(A::Error::duplicate_field(
1022                                        "multiple values for subject",
1023                                    ));
1024                                }
1025                                result.subject = map
1026                                    .next_value::<std::option::Option<std::string::String>>()?
1027                                    .unwrap_or_default();
1028                            }
1029                            __FieldTag::__description => {
1030                                if !fields.insert(__FieldTag::__description) {
1031                                    return std::result::Result::Err(A::Error::duplicate_field(
1032                                        "multiple values for description",
1033                                    ));
1034                                }
1035                                result.description = map
1036                                    .next_value::<std::option::Option<std::string::String>>()?
1037                                    .unwrap_or_default();
1038                            }
1039                            __FieldTag::__api_service => {
1040                                if !fields.insert(__FieldTag::__api_service) {
1041                                    return std::result::Result::Err(A::Error::duplicate_field(
1042                                        "multiple values for api_service",
1043                                    ));
1044                                }
1045                                result.api_service = map
1046                                    .next_value::<std::option::Option<std::string::String>>()?
1047                                    .unwrap_or_default();
1048                            }
1049                            __FieldTag::__quota_metric => {
1050                                if !fields.insert(__FieldTag::__quota_metric) {
1051                                    return std::result::Result::Err(A::Error::duplicate_field(
1052                                        "multiple values for quota_metric",
1053                                    ));
1054                                }
1055                                result.quota_metric = map
1056                                    .next_value::<std::option::Option<std::string::String>>()?
1057                                    .unwrap_or_default();
1058                            }
1059                            __FieldTag::__quota_id => {
1060                                if !fields.insert(__FieldTag::__quota_id) {
1061                                    return std::result::Result::Err(A::Error::duplicate_field(
1062                                        "multiple values for quota_id",
1063                                    ));
1064                                }
1065                                result.quota_id = map
1066                                    .next_value::<std::option::Option<std::string::String>>()?
1067                                    .unwrap_or_default();
1068                            }
1069                            __FieldTag::__quota_dimensions => {
1070                                if !fields.insert(__FieldTag::__quota_dimensions) {
1071                                    return std::result::Result::Err(A::Error::duplicate_field(
1072                                        "multiple values for quota_dimensions",
1073                                    ));
1074                                }
1075                                result.quota_dimensions = map
1076                                    .next_value::<std::option::Option<
1077                                        std::collections::HashMap<
1078                                            std::string::String,
1079                                            std::string::String,
1080                                        >,
1081                                    >>()?
1082                                    .unwrap_or_default();
1083                            }
1084                            __FieldTag::__quota_value => {
1085                                if !fields.insert(__FieldTag::__quota_value) {
1086                                    return std::result::Result::Err(A::Error::duplicate_field(
1087                                        "multiple values for quota_value",
1088                                    ));
1089                                }
1090                                struct __With(std::option::Option<i64>);
1091                                impl<'de> serde::de::Deserialize<'de> for __With {
1092                                    fn deserialize<D>(
1093                                        deserializer: D,
1094                                    ) -> std::result::Result<Self, D::Error>
1095                                    where
1096                                        D: serde::de::Deserializer<'de>,
1097                                    {
1098                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1099                                    }
1100                                }
1101                                result.quota_value =
1102                                    map.next_value::<__With>()?.0.unwrap_or_default();
1103                            }
1104                            __FieldTag::__future_quota_value => {
1105                                if !fields.insert(__FieldTag::__future_quota_value) {
1106                                    return std::result::Result::Err(A::Error::duplicate_field(
1107                                        "multiple values for future_quota_value",
1108                                    ));
1109                                }
1110                                struct __With(std::option::Option<i64>);
1111                                impl<'de> serde::de::Deserialize<'de> for __With {
1112                                    fn deserialize<D>(
1113                                        deserializer: D,
1114                                    ) -> std::result::Result<Self, D::Error>
1115                                    where
1116                                        D: serde::de::Deserializer<'de>,
1117                                    {
1118                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1119                                    }
1120                                }
1121                                result.future_quota_value = map.next_value::<__With>()?.0;
1122                            }
1123                            __FieldTag::Unknown(key) => {
1124                                let value = map.next_value::<serde_json::Value>()?;
1125                                result._unknown_fields.insert(key, value);
1126                            }
1127                        }
1128                    }
1129                    std::result::Result::Ok(result)
1130                }
1131            }
1132            deserializer.deserialize_any(Visitor)
1133        }
1134    }
1135
1136    #[doc(hidden)]
1137    impl serde::ser::Serialize for Violation {
1138        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1139        where
1140            S: serde::ser::Serializer,
1141        {
1142            use serde::ser::SerializeMap;
1143            #[allow(unused_imports)]
1144            use std::option::Option::Some;
1145            let mut state = serializer.serialize_map(std::option::Option::None)?;
1146            if !self.subject.is_empty() {
1147                state.serialize_entry("subject", &self.subject)?;
1148            }
1149            if !self.description.is_empty() {
1150                state.serialize_entry("description", &self.description)?;
1151            }
1152            if !self.api_service.is_empty() {
1153                state.serialize_entry("apiService", &self.api_service)?;
1154            }
1155            if !self.quota_metric.is_empty() {
1156                state.serialize_entry("quotaMetric", &self.quota_metric)?;
1157            }
1158            if !self.quota_id.is_empty() {
1159                state.serialize_entry("quotaId", &self.quota_id)?;
1160            }
1161            if !self.quota_dimensions.is_empty() {
1162                state.serialize_entry("quotaDimensions", &self.quota_dimensions)?;
1163            }
1164            if !wkt::internal::is_default(&self.quota_value) {
1165                struct __With<'a>(&'a i64);
1166                impl<'a> serde::ser::Serialize for __With<'a> {
1167                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1168                    where
1169                        S: serde::ser::Serializer,
1170                    {
1171                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1172                    }
1173                }
1174                state.serialize_entry("quotaValue", &__With(&self.quota_value))?;
1175            }
1176            if self.future_quota_value.is_some() {
1177                struct __With<'a>(&'a std::option::Option<i64>);
1178                impl<'a> serde::ser::Serialize for __With<'a> {
1179                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1180                    where
1181                        S: serde::ser::Serializer,
1182                    {
1183                        serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
1184                            self.0, serializer,
1185                        )
1186                    }
1187                }
1188                state.serialize_entry("futureQuotaValue", &__With(&self.future_quota_value))?;
1189            }
1190            if !self._unknown_fields.is_empty() {
1191                for (key, value) in self._unknown_fields.iter() {
1192                    state.serialize_entry(key, &value)?;
1193                }
1194            }
1195            state.end()
1196        }
1197    }
1198
1199    impl std::fmt::Debug for Violation {
1200        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1201            let mut debug_struct = f.debug_struct("Violation");
1202            debug_struct.field("subject", &self.subject);
1203            debug_struct.field("description", &self.description);
1204            debug_struct.field("api_service", &self.api_service);
1205            debug_struct.field("quota_metric", &self.quota_metric);
1206            debug_struct.field("quota_id", &self.quota_id);
1207            debug_struct.field("quota_dimensions", &self.quota_dimensions);
1208            debug_struct.field("quota_value", &self.quota_value);
1209            debug_struct.field("future_quota_value", &self.future_quota_value);
1210            if !self._unknown_fields.is_empty() {
1211                debug_struct.field("_unknown_fields", &self._unknown_fields);
1212            }
1213            debug_struct.finish()
1214        }
1215    }
1216}
1217
1218/// Describes what preconditions have failed.
1219///
1220/// For example, if an RPC failed because it required the Terms of Service to be
1221/// acknowledged, it could list the terms of service violation in the
1222/// PreconditionFailure message.
1223#[derive(Clone, Default, PartialEq)]
1224#[non_exhaustive]
1225pub struct PreconditionFailure {
1226    /// Describes all precondition violations.
1227    pub violations: std::vec::Vec<crate::model::precondition_failure::Violation>,
1228
1229    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1230}
1231
1232impl PreconditionFailure {
1233    pub fn new() -> Self {
1234        std::default::Default::default()
1235    }
1236
1237    /// Sets the value of [violations][crate::model::PreconditionFailure::violations].
1238    pub fn set_violations<T, V>(mut self, v: T) -> Self
1239    where
1240        T: std::iter::IntoIterator<Item = V>,
1241        V: std::convert::Into<crate::model::precondition_failure::Violation>,
1242    {
1243        use std::iter::Iterator;
1244        self.violations = v.into_iter().map(|i| i.into()).collect();
1245        self
1246    }
1247}
1248
1249impl wkt::message::Message for PreconditionFailure {
1250    fn typename() -> &'static str {
1251        "type.googleapis.com/google.rpc.PreconditionFailure"
1252    }
1253}
1254
1255#[doc(hidden)]
1256impl<'de> serde::de::Deserialize<'de> for PreconditionFailure {
1257    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1258    where
1259        D: serde::Deserializer<'de>,
1260    {
1261        #[allow(non_camel_case_types)]
1262        #[doc(hidden)]
1263        #[derive(PartialEq, Eq, Hash)]
1264        enum __FieldTag {
1265            __violations,
1266            Unknown(std::string::String),
1267        }
1268        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1269            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1270            where
1271                D: serde::Deserializer<'de>,
1272            {
1273                struct Visitor;
1274                impl<'de> serde::de::Visitor<'de> for Visitor {
1275                    type Value = __FieldTag;
1276                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1277                        formatter.write_str("a field name for PreconditionFailure")
1278                    }
1279                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1280                    where
1281                        E: serde::de::Error,
1282                    {
1283                        use std::result::Result::Ok;
1284                        use std::string::ToString;
1285                        match value {
1286                            "violations" => Ok(__FieldTag::__violations),
1287                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1288                        }
1289                    }
1290                }
1291                deserializer.deserialize_identifier(Visitor)
1292            }
1293        }
1294        struct Visitor;
1295        impl<'de> serde::de::Visitor<'de> for Visitor {
1296            type Value = PreconditionFailure;
1297            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1298                formatter.write_str("struct PreconditionFailure")
1299            }
1300            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1301            where
1302                A: serde::de::MapAccess<'de>,
1303            {
1304                #[allow(unused_imports)]
1305                use serde::de::Error;
1306                use std::option::Option::Some;
1307                let mut fields = std::collections::HashSet::new();
1308                let mut result = Self::Value::new();
1309                while let Some(tag) = map.next_key::<__FieldTag>()? {
1310                    #[allow(clippy::match_single_binding)]
1311                    match tag {
1312                        __FieldTag::__violations => {
1313                            if !fields.insert(__FieldTag::__violations) {
1314                                return std::result::Result::Err(A::Error::duplicate_field(
1315                                    "multiple values for violations",
1316                                ));
1317                            }
1318                            result.violations = map
1319                                .next_value::<std::option::Option<
1320                                    std::vec::Vec<crate::model::precondition_failure::Violation>,
1321                                >>()?
1322                                .unwrap_or_default();
1323                        }
1324                        __FieldTag::Unknown(key) => {
1325                            let value = map.next_value::<serde_json::Value>()?;
1326                            result._unknown_fields.insert(key, value);
1327                        }
1328                    }
1329                }
1330                std::result::Result::Ok(result)
1331            }
1332        }
1333        deserializer.deserialize_any(Visitor)
1334    }
1335}
1336
1337#[doc(hidden)]
1338impl serde::ser::Serialize for PreconditionFailure {
1339    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1340    where
1341        S: serde::ser::Serializer,
1342    {
1343        use serde::ser::SerializeMap;
1344        #[allow(unused_imports)]
1345        use std::option::Option::Some;
1346        let mut state = serializer.serialize_map(std::option::Option::None)?;
1347        if !self.violations.is_empty() {
1348            state.serialize_entry("violations", &self.violations)?;
1349        }
1350        if !self._unknown_fields.is_empty() {
1351            for (key, value) in self._unknown_fields.iter() {
1352                state.serialize_entry(key, &value)?;
1353            }
1354        }
1355        state.end()
1356    }
1357}
1358
1359impl std::fmt::Debug for PreconditionFailure {
1360    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1361        let mut debug_struct = f.debug_struct("PreconditionFailure");
1362        debug_struct.field("violations", &self.violations);
1363        if !self._unknown_fields.is_empty() {
1364            debug_struct.field("_unknown_fields", &self._unknown_fields);
1365        }
1366        debug_struct.finish()
1367    }
1368}
1369
1370/// Defines additional types related to [PreconditionFailure].
1371pub mod precondition_failure {
1372    #[allow(unused_imports)]
1373    use super::*;
1374
1375    /// A message type used to describe a single precondition failure.
1376    #[derive(Clone, Default, PartialEq)]
1377    #[non_exhaustive]
1378    pub struct Violation {
1379        /// The type of PreconditionFailure. We recommend using a service-specific
1380        /// enum type to define the supported precondition violation subjects. For
1381        /// example, "TOS" for "Terms of Service violation".
1382        pub r#type: std::string::String,
1383
1384        /// The subject, relative to the type, that failed.
1385        /// For example, "google.com/cloud" relative to the "TOS" type would indicate
1386        /// which terms of service is being referenced.
1387        pub subject: std::string::String,
1388
1389        /// A description of how the precondition failed. Developers can use this
1390        /// description to understand how to fix the failure.
1391        ///
1392        /// For example: "Terms of service not accepted".
1393        pub description: std::string::String,
1394
1395        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1396    }
1397
1398    impl Violation {
1399        pub fn new() -> Self {
1400            std::default::Default::default()
1401        }
1402
1403        /// Sets the value of [r#type][crate::model::precondition_failure::Violation::type].
1404        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1405            self.r#type = v.into();
1406            self
1407        }
1408
1409        /// Sets the value of [subject][crate::model::precondition_failure::Violation::subject].
1410        pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1411            self.subject = v.into();
1412            self
1413        }
1414
1415        /// Sets the value of [description][crate::model::precondition_failure::Violation::description].
1416        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1417            self.description = v.into();
1418            self
1419        }
1420    }
1421
1422    impl wkt::message::Message for Violation {
1423        fn typename() -> &'static str {
1424            "type.googleapis.com/google.rpc.PreconditionFailure.Violation"
1425        }
1426    }
1427
1428    #[doc(hidden)]
1429    impl<'de> serde::de::Deserialize<'de> for Violation {
1430        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1431        where
1432            D: serde::Deserializer<'de>,
1433        {
1434            #[allow(non_camel_case_types)]
1435            #[doc(hidden)]
1436            #[derive(PartialEq, Eq, Hash)]
1437            enum __FieldTag {
1438                __type,
1439                __subject,
1440                __description,
1441                Unknown(std::string::String),
1442            }
1443            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1444                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1445                where
1446                    D: serde::Deserializer<'de>,
1447                {
1448                    struct Visitor;
1449                    impl<'de> serde::de::Visitor<'de> for Visitor {
1450                        type Value = __FieldTag;
1451                        fn expecting(
1452                            &self,
1453                            formatter: &mut std::fmt::Formatter,
1454                        ) -> std::fmt::Result {
1455                            formatter.write_str("a field name for Violation")
1456                        }
1457                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1458                        where
1459                            E: serde::de::Error,
1460                        {
1461                            use std::result::Result::Ok;
1462                            use std::string::ToString;
1463                            match value {
1464                                "type" => Ok(__FieldTag::__type),
1465                                "subject" => Ok(__FieldTag::__subject),
1466                                "description" => Ok(__FieldTag::__description),
1467                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1468                            }
1469                        }
1470                    }
1471                    deserializer.deserialize_identifier(Visitor)
1472                }
1473            }
1474            struct Visitor;
1475            impl<'de> serde::de::Visitor<'de> for Visitor {
1476                type Value = Violation;
1477                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1478                    formatter.write_str("struct Violation")
1479                }
1480                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1481                where
1482                    A: serde::de::MapAccess<'de>,
1483                {
1484                    #[allow(unused_imports)]
1485                    use serde::de::Error;
1486                    use std::option::Option::Some;
1487                    let mut fields = std::collections::HashSet::new();
1488                    let mut result = Self::Value::new();
1489                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1490                        #[allow(clippy::match_single_binding)]
1491                        match tag {
1492                            __FieldTag::__type => {
1493                                if !fields.insert(__FieldTag::__type) {
1494                                    return std::result::Result::Err(A::Error::duplicate_field(
1495                                        "multiple values for type",
1496                                    ));
1497                                }
1498                                result.r#type = map
1499                                    .next_value::<std::option::Option<std::string::String>>()?
1500                                    .unwrap_or_default();
1501                            }
1502                            __FieldTag::__subject => {
1503                                if !fields.insert(__FieldTag::__subject) {
1504                                    return std::result::Result::Err(A::Error::duplicate_field(
1505                                        "multiple values for subject",
1506                                    ));
1507                                }
1508                                result.subject = map
1509                                    .next_value::<std::option::Option<std::string::String>>()?
1510                                    .unwrap_or_default();
1511                            }
1512                            __FieldTag::__description => {
1513                                if !fields.insert(__FieldTag::__description) {
1514                                    return std::result::Result::Err(A::Error::duplicate_field(
1515                                        "multiple values for description",
1516                                    ));
1517                                }
1518                                result.description = map
1519                                    .next_value::<std::option::Option<std::string::String>>()?
1520                                    .unwrap_or_default();
1521                            }
1522                            __FieldTag::Unknown(key) => {
1523                                let value = map.next_value::<serde_json::Value>()?;
1524                                result._unknown_fields.insert(key, value);
1525                            }
1526                        }
1527                    }
1528                    std::result::Result::Ok(result)
1529                }
1530            }
1531            deserializer.deserialize_any(Visitor)
1532        }
1533    }
1534
1535    #[doc(hidden)]
1536    impl serde::ser::Serialize for Violation {
1537        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1538        where
1539            S: serde::ser::Serializer,
1540        {
1541            use serde::ser::SerializeMap;
1542            #[allow(unused_imports)]
1543            use std::option::Option::Some;
1544            let mut state = serializer.serialize_map(std::option::Option::None)?;
1545            if !self.r#type.is_empty() {
1546                state.serialize_entry("type", &self.r#type)?;
1547            }
1548            if !self.subject.is_empty() {
1549                state.serialize_entry("subject", &self.subject)?;
1550            }
1551            if !self.description.is_empty() {
1552                state.serialize_entry("description", &self.description)?;
1553            }
1554            if !self._unknown_fields.is_empty() {
1555                for (key, value) in self._unknown_fields.iter() {
1556                    state.serialize_entry(key, &value)?;
1557                }
1558            }
1559            state.end()
1560        }
1561    }
1562
1563    impl std::fmt::Debug for Violation {
1564        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1565            let mut debug_struct = f.debug_struct("Violation");
1566            debug_struct.field("r#type", &self.r#type);
1567            debug_struct.field("subject", &self.subject);
1568            debug_struct.field("description", &self.description);
1569            if !self._unknown_fields.is_empty() {
1570                debug_struct.field("_unknown_fields", &self._unknown_fields);
1571            }
1572            debug_struct.finish()
1573        }
1574    }
1575}
1576
1577/// Describes violations in a client request. This error type focuses on the
1578/// syntactic aspects of the request.
1579#[derive(Clone, Default, PartialEq)]
1580#[non_exhaustive]
1581pub struct BadRequest {
1582    /// Describes all violations in a client request.
1583    pub field_violations: std::vec::Vec<crate::model::bad_request::FieldViolation>,
1584
1585    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1586}
1587
1588impl BadRequest {
1589    pub fn new() -> Self {
1590        std::default::Default::default()
1591    }
1592
1593    /// Sets the value of [field_violations][crate::model::BadRequest::field_violations].
1594    pub fn set_field_violations<T, V>(mut self, v: T) -> Self
1595    where
1596        T: std::iter::IntoIterator<Item = V>,
1597        V: std::convert::Into<crate::model::bad_request::FieldViolation>,
1598    {
1599        use std::iter::Iterator;
1600        self.field_violations = v.into_iter().map(|i| i.into()).collect();
1601        self
1602    }
1603}
1604
1605impl wkt::message::Message for BadRequest {
1606    fn typename() -> &'static str {
1607        "type.googleapis.com/google.rpc.BadRequest"
1608    }
1609}
1610
1611#[doc(hidden)]
1612impl<'de> serde::de::Deserialize<'de> for BadRequest {
1613    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1614    where
1615        D: serde::Deserializer<'de>,
1616    {
1617        #[allow(non_camel_case_types)]
1618        #[doc(hidden)]
1619        #[derive(PartialEq, Eq, Hash)]
1620        enum __FieldTag {
1621            __field_violations,
1622            Unknown(std::string::String),
1623        }
1624        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1625            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1626            where
1627                D: serde::Deserializer<'de>,
1628            {
1629                struct Visitor;
1630                impl<'de> serde::de::Visitor<'de> for Visitor {
1631                    type Value = __FieldTag;
1632                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1633                        formatter.write_str("a field name for BadRequest")
1634                    }
1635                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1636                    where
1637                        E: serde::de::Error,
1638                    {
1639                        use std::result::Result::Ok;
1640                        use std::string::ToString;
1641                        match value {
1642                            "fieldViolations" => Ok(__FieldTag::__field_violations),
1643                            "field_violations" => Ok(__FieldTag::__field_violations),
1644                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1645                        }
1646                    }
1647                }
1648                deserializer.deserialize_identifier(Visitor)
1649            }
1650        }
1651        struct Visitor;
1652        impl<'de> serde::de::Visitor<'de> for Visitor {
1653            type Value = BadRequest;
1654            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1655                formatter.write_str("struct BadRequest")
1656            }
1657            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1658            where
1659                A: serde::de::MapAccess<'de>,
1660            {
1661                #[allow(unused_imports)]
1662                use serde::de::Error;
1663                use std::option::Option::Some;
1664                let mut fields = std::collections::HashSet::new();
1665                let mut result = Self::Value::new();
1666                while let Some(tag) = map.next_key::<__FieldTag>()? {
1667                    #[allow(clippy::match_single_binding)]
1668                    match tag {
1669                        __FieldTag::__field_violations => {
1670                            if !fields.insert(__FieldTag::__field_violations) {
1671                                return std::result::Result::Err(A::Error::duplicate_field(
1672                                    "multiple values for field_violations",
1673                                ));
1674                            }
1675                            result.field_violations = map
1676                                .next_value::<std::option::Option<
1677                                    std::vec::Vec<crate::model::bad_request::FieldViolation>,
1678                                >>()?
1679                                .unwrap_or_default();
1680                        }
1681                        __FieldTag::Unknown(key) => {
1682                            let value = map.next_value::<serde_json::Value>()?;
1683                            result._unknown_fields.insert(key, value);
1684                        }
1685                    }
1686                }
1687                std::result::Result::Ok(result)
1688            }
1689        }
1690        deserializer.deserialize_any(Visitor)
1691    }
1692}
1693
1694#[doc(hidden)]
1695impl serde::ser::Serialize for BadRequest {
1696    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1697    where
1698        S: serde::ser::Serializer,
1699    {
1700        use serde::ser::SerializeMap;
1701        #[allow(unused_imports)]
1702        use std::option::Option::Some;
1703        let mut state = serializer.serialize_map(std::option::Option::None)?;
1704        if !self.field_violations.is_empty() {
1705            state.serialize_entry("fieldViolations", &self.field_violations)?;
1706        }
1707        if !self._unknown_fields.is_empty() {
1708            for (key, value) in self._unknown_fields.iter() {
1709                state.serialize_entry(key, &value)?;
1710            }
1711        }
1712        state.end()
1713    }
1714}
1715
1716impl std::fmt::Debug for BadRequest {
1717    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1718        let mut debug_struct = f.debug_struct("BadRequest");
1719        debug_struct.field("field_violations", &self.field_violations);
1720        if !self._unknown_fields.is_empty() {
1721            debug_struct.field("_unknown_fields", &self._unknown_fields);
1722        }
1723        debug_struct.finish()
1724    }
1725}
1726
1727/// Defines additional types related to [BadRequest].
1728pub mod bad_request {
1729    #[allow(unused_imports)]
1730    use super::*;
1731
1732    /// A message type used to describe a single bad request field.
1733    #[derive(Clone, Default, PartialEq)]
1734    #[non_exhaustive]
1735    pub struct FieldViolation {
1736        /// A path that leads to a field in the request body. The value will be a
1737        /// sequence of dot-separated identifiers that identify a protocol buffer
1738        /// field.
1739        ///
1740        /// Consider the following:
1741        ///
1742        /// ```norust
1743        /// message CreateContactRequest {
1744        ///   message EmailAddress {
1745        ///     enum Type {
1746        ///       TYPE_UNSPECIFIED = 0;
1747        ///       HOME = 1;
1748        ///       WORK = 2;
1749        ///     }
1750        ///
1751        ///     optional string email = 1;
1752        ///     repeated EmailType type = 2;
1753        ///   }
1754        ///
1755        ///   string full_name = 1;
1756        ///   repeated EmailAddress email_addresses = 2;
1757        /// }
1758        /// ```
1759        ///
1760        /// In this example, in proto `field` could take one of the following values:
1761        ///
1762        /// * `full_name` for a violation in the `full_name` value
1763        /// * `email_addresses[1].email` for a violation in the `email` field of the
1764        ///   first `email_addresses` message
1765        /// * `email_addresses[3].type[2]` for a violation in the second `type`
1766        ///   value in the third `email_addresses` message.
1767        ///
1768        /// In JSON, the same values are represented as:
1769        ///
1770        /// * `fullName` for a violation in the `fullName` value
1771        /// * `emailAddresses[1].email` for a violation in the `email` field of the
1772        ///   first `emailAddresses` message
1773        /// * `emailAddresses[3].type[2]` for a violation in the second `type`
1774        ///   value in the third `emailAddresses` message.
1775        pub field: std::string::String,
1776
1777        /// A description of why the request element is bad.
1778        pub description: std::string::String,
1779
1780        /// The reason of the field-level error. This is a constant value that
1781        /// identifies the proximate cause of the field-level error. It should
1782        /// uniquely identify the type of the FieldViolation within the scope of the
1783        /// google.rpc.ErrorInfo.domain. This should be at most 63
1784        /// characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`,
1785        /// which represents UPPER_SNAKE_CASE.
1786        pub reason: std::string::String,
1787
1788        /// Provides a localized error message for field-level errors that is safe to
1789        /// return to the API consumer.
1790        pub localized_message: std::option::Option<crate::model::LocalizedMessage>,
1791
1792        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1793    }
1794
1795    impl FieldViolation {
1796        pub fn new() -> Self {
1797            std::default::Default::default()
1798        }
1799
1800        /// Sets the value of [field][crate::model::bad_request::FieldViolation::field].
1801        pub fn set_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1802            self.field = v.into();
1803            self
1804        }
1805
1806        /// Sets the value of [description][crate::model::bad_request::FieldViolation::description].
1807        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1808            self.description = v.into();
1809            self
1810        }
1811
1812        /// Sets the value of [reason][crate::model::bad_request::FieldViolation::reason].
1813        pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1814            self.reason = v.into();
1815            self
1816        }
1817
1818        /// Sets the value of [localized_message][crate::model::bad_request::FieldViolation::localized_message].
1819        pub fn set_localized_message<T>(mut self, v: T) -> Self
1820        where
1821            T: std::convert::Into<crate::model::LocalizedMessage>,
1822        {
1823            self.localized_message = std::option::Option::Some(v.into());
1824            self
1825        }
1826
1827        /// Sets or clears the value of [localized_message][crate::model::bad_request::FieldViolation::localized_message].
1828        pub fn set_or_clear_localized_message<T>(mut self, v: std::option::Option<T>) -> Self
1829        where
1830            T: std::convert::Into<crate::model::LocalizedMessage>,
1831        {
1832            self.localized_message = v.map(|x| x.into());
1833            self
1834        }
1835    }
1836
1837    impl wkt::message::Message for FieldViolation {
1838        fn typename() -> &'static str {
1839            "type.googleapis.com/google.rpc.BadRequest.FieldViolation"
1840        }
1841    }
1842
1843    #[doc(hidden)]
1844    impl<'de> serde::de::Deserialize<'de> for FieldViolation {
1845        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1846        where
1847            D: serde::Deserializer<'de>,
1848        {
1849            #[allow(non_camel_case_types)]
1850            #[doc(hidden)]
1851            #[derive(PartialEq, Eq, Hash)]
1852            enum __FieldTag {
1853                __field,
1854                __description,
1855                __reason,
1856                __localized_message,
1857                Unknown(std::string::String),
1858            }
1859            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1860                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1861                where
1862                    D: serde::Deserializer<'de>,
1863                {
1864                    struct Visitor;
1865                    impl<'de> serde::de::Visitor<'de> for Visitor {
1866                        type Value = __FieldTag;
1867                        fn expecting(
1868                            &self,
1869                            formatter: &mut std::fmt::Formatter,
1870                        ) -> std::fmt::Result {
1871                            formatter.write_str("a field name for FieldViolation")
1872                        }
1873                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1874                        where
1875                            E: serde::de::Error,
1876                        {
1877                            use std::result::Result::Ok;
1878                            use std::string::ToString;
1879                            match value {
1880                                "field" => Ok(__FieldTag::__field),
1881                                "description" => Ok(__FieldTag::__description),
1882                                "reason" => Ok(__FieldTag::__reason),
1883                                "localizedMessage" => Ok(__FieldTag::__localized_message),
1884                                "localized_message" => Ok(__FieldTag::__localized_message),
1885                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1886                            }
1887                        }
1888                    }
1889                    deserializer.deserialize_identifier(Visitor)
1890                }
1891            }
1892            struct Visitor;
1893            impl<'de> serde::de::Visitor<'de> for Visitor {
1894                type Value = FieldViolation;
1895                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1896                    formatter.write_str("struct FieldViolation")
1897                }
1898                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1899                where
1900                    A: serde::de::MapAccess<'de>,
1901                {
1902                    #[allow(unused_imports)]
1903                    use serde::de::Error;
1904                    use std::option::Option::Some;
1905                    let mut fields = std::collections::HashSet::new();
1906                    let mut result = Self::Value::new();
1907                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1908                        #[allow(clippy::match_single_binding)]
1909                        match tag {
1910                            __FieldTag::__field => {
1911                                if !fields.insert(__FieldTag::__field) {
1912                                    return std::result::Result::Err(A::Error::duplicate_field(
1913                                        "multiple values for field",
1914                                    ));
1915                                }
1916                                result.field = map
1917                                    .next_value::<std::option::Option<std::string::String>>()?
1918                                    .unwrap_or_default();
1919                            }
1920                            __FieldTag::__description => {
1921                                if !fields.insert(__FieldTag::__description) {
1922                                    return std::result::Result::Err(A::Error::duplicate_field(
1923                                        "multiple values for description",
1924                                    ));
1925                                }
1926                                result.description = map
1927                                    .next_value::<std::option::Option<std::string::String>>()?
1928                                    .unwrap_or_default();
1929                            }
1930                            __FieldTag::__reason => {
1931                                if !fields.insert(__FieldTag::__reason) {
1932                                    return std::result::Result::Err(A::Error::duplicate_field(
1933                                        "multiple values for reason",
1934                                    ));
1935                                }
1936                                result.reason = map
1937                                    .next_value::<std::option::Option<std::string::String>>()?
1938                                    .unwrap_or_default();
1939                            }
1940                            __FieldTag::__localized_message => {
1941                                if !fields.insert(__FieldTag::__localized_message) {
1942                                    return std::result::Result::Err(A::Error::duplicate_field(
1943                                        "multiple values for localized_message",
1944                                    ));
1945                                }
1946                                result.localized_message = map.next_value::<std::option::Option<crate::model::LocalizedMessage>>()?
1947                                    ;
1948                            }
1949                            __FieldTag::Unknown(key) => {
1950                                let value = map.next_value::<serde_json::Value>()?;
1951                                result._unknown_fields.insert(key, value);
1952                            }
1953                        }
1954                    }
1955                    std::result::Result::Ok(result)
1956                }
1957            }
1958            deserializer.deserialize_any(Visitor)
1959        }
1960    }
1961
1962    #[doc(hidden)]
1963    impl serde::ser::Serialize for FieldViolation {
1964        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1965        where
1966            S: serde::ser::Serializer,
1967        {
1968            use serde::ser::SerializeMap;
1969            #[allow(unused_imports)]
1970            use std::option::Option::Some;
1971            let mut state = serializer.serialize_map(std::option::Option::None)?;
1972            if !self.field.is_empty() {
1973                state.serialize_entry("field", &self.field)?;
1974            }
1975            if !self.description.is_empty() {
1976                state.serialize_entry("description", &self.description)?;
1977            }
1978            if !self.reason.is_empty() {
1979                state.serialize_entry("reason", &self.reason)?;
1980            }
1981            if self.localized_message.is_some() {
1982                state.serialize_entry("localizedMessage", &self.localized_message)?;
1983            }
1984            if !self._unknown_fields.is_empty() {
1985                for (key, value) in self._unknown_fields.iter() {
1986                    state.serialize_entry(key, &value)?;
1987                }
1988            }
1989            state.end()
1990        }
1991    }
1992
1993    impl std::fmt::Debug for FieldViolation {
1994        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1995            let mut debug_struct = f.debug_struct("FieldViolation");
1996            debug_struct.field("field", &self.field);
1997            debug_struct.field("description", &self.description);
1998            debug_struct.field("reason", &self.reason);
1999            debug_struct.field("localized_message", &self.localized_message);
2000            if !self._unknown_fields.is_empty() {
2001                debug_struct.field("_unknown_fields", &self._unknown_fields);
2002            }
2003            debug_struct.finish()
2004        }
2005    }
2006}
2007
2008/// Contains metadata about the request that clients can attach when filing a bug
2009/// or providing other forms of feedback.
2010#[derive(Clone, Default, PartialEq)]
2011#[non_exhaustive]
2012pub struct RequestInfo {
2013    /// An opaque string that should only be interpreted by the service generating
2014    /// it. For example, it can be used to identify requests in the service's logs.
2015    pub request_id: std::string::String,
2016
2017    /// Any data that was used to serve this request. For example, an encrypted
2018    /// stack trace that can be sent back to the service provider for debugging.
2019    pub serving_data: std::string::String,
2020
2021    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2022}
2023
2024impl RequestInfo {
2025    pub fn new() -> Self {
2026        std::default::Default::default()
2027    }
2028
2029    /// Sets the value of [request_id][crate::model::RequestInfo::request_id].
2030    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2031        self.request_id = v.into();
2032        self
2033    }
2034
2035    /// Sets the value of [serving_data][crate::model::RequestInfo::serving_data].
2036    pub fn set_serving_data<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2037        self.serving_data = v.into();
2038        self
2039    }
2040}
2041
2042impl wkt::message::Message for RequestInfo {
2043    fn typename() -> &'static str {
2044        "type.googleapis.com/google.rpc.RequestInfo"
2045    }
2046}
2047
2048#[doc(hidden)]
2049impl<'de> serde::de::Deserialize<'de> for RequestInfo {
2050    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2051    where
2052        D: serde::Deserializer<'de>,
2053    {
2054        #[allow(non_camel_case_types)]
2055        #[doc(hidden)]
2056        #[derive(PartialEq, Eq, Hash)]
2057        enum __FieldTag {
2058            __request_id,
2059            __serving_data,
2060            Unknown(std::string::String),
2061        }
2062        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2063            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2064            where
2065                D: serde::Deserializer<'de>,
2066            {
2067                struct Visitor;
2068                impl<'de> serde::de::Visitor<'de> for Visitor {
2069                    type Value = __FieldTag;
2070                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2071                        formatter.write_str("a field name for RequestInfo")
2072                    }
2073                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2074                    where
2075                        E: serde::de::Error,
2076                    {
2077                        use std::result::Result::Ok;
2078                        use std::string::ToString;
2079                        match value {
2080                            "requestId" => Ok(__FieldTag::__request_id),
2081                            "request_id" => Ok(__FieldTag::__request_id),
2082                            "servingData" => Ok(__FieldTag::__serving_data),
2083                            "serving_data" => Ok(__FieldTag::__serving_data),
2084                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2085                        }
2086                    }
2087                }
2088                deserializer.deserialize_identifier(Visitor)
2089            }
2090        }
2091        struct Visitor;
2092        impl<'de> serde::de::Visitor<'de> for Visitor {
2093            type Value = RequestInfo;
2094            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2095                formatter.write_str("struct RequestInfo")
2096            }
2097            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2098            where
2099                A: serde::de::MapAccess<'de>,
2100            {
2101                #[allow(unused_imports)]
2102                use serde::de::Error;
2103                use std::option::Option::Some;
2104                let mut fields = std::collections::HashSet::new();
2105                let mut result = Self::Value::new();
2106                while let Some(tag) = map.next_key::<__FieldTag>()? {
2107                    #[allow(clippy::match_single_binding)]
2108                    match tag {
2109                        __FieldTag::__request_id => {
2110                            if !fields.insert(__FieldTag::__request_id) {
2111                                return std::result::Result::Err(A::Error::duplicate_field(
2112                                    "multiple values for request_id",
2113                                ));
2114                            }
2115                            result.request_id = map
2116                                .next_value::<std::option::Option<std::string::String>>()?
2117                                .unwrap_or_default();
2118                        }
2119                        __FieldTag::__serving_data => {
2120                            if !fields.insert(__FieldTag::__serving_data) {
2121                                return std::result::Result::Err(A::Error::duplicate_field(
2122                                    "multiple values for serving_data",
2123                                ));
2124                            }
2125                            result.serving_data = map
2126                                .next_value::<std::option::Option<std::string::String>>()?
2127                                .unwrap_or_default();
2128                        }
2129                        __FieldTag::Unknown(key) => {
2130                            let value = map.next_value::<serde_json::Value>()?;
2131                            result._unknown_fields.insert(key, value);
2132                        }
2133                    }
2134                }
2135                std::result::Result::Ok(result)
2136            }
2137        }
2138        deserializer.deserialize_any(Visitor)
2139    }
2140}
2141
2142#[doc(hidden)]
2143impl serde::ser::Serialize for RequestInfo {
2144    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2145    where
2146        S: serde::ser::Serializer,
2147    {
2148        use serde::ser::SerializeMap;
2149        #[allow(unused_imports)]
2150        use std::option::Option::Some;
2151        let mut state = serializer.serialize_map(std::option::Option::None)?;
2152        if !self.request_id.is_empty() {
2153            state.serialize_entry("requestId", &self.request_id)?;
2154        }
2155        if !self.serving_data.is_empty() {
2156            state.serialize_entry("servingData", &self.serving_data)?;
2157        }
2158        if !self._unknown_fields.is_empty() {
2159            for (key, value) in self._unknown_fields.iter() {
2160                state.serialize_entry(key, &value)?;
2161            }
2162        }
2163        state.end()
2164    }
2165}
2166
2167impl std::fmt::Debug for RequestInfo {
2168    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2169        let mut debug_struct = f.debug_struct("RequestInfo");
2170        debug_struct.field("request_id", &self.request_id);
2171        debug_struct.field("serving_data", &self.serving_data);
2172        if !self._unknown_fields.is_empty() {
2173            debug_struct.field("_unknown_fields", &self._unknown_fields);
2174        }
2175        debug_struct.finish()
2176    }
2177}
2178
2179/// Describes the resource that is being accessed.
2180#[derive(Clone, Default, PartialEq)]
2181#[non_exhaustive]
2182pub struct ResourceInfo {
2183    /// A name for the type of resource being accessed, e.g. "sql table",
2184    /// "cloud storage bucket", "file", "Google calendar"; or the type URL
2185    /// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
2186    pub resource_type: std::string::String,
2187
2188    /// The name of the resource being accessed.  For example, a shared calendar
2189    /// name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
2190    /// error is
2191    /// [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
2192    ///
2193    /// [google.rpc.Code.PERMISSION_DENIED]: crate::model::Code::PermissionDenied
2194    pub resource_name: std::string::String,
2195
2196    /// The owner of the resource (optional).
2197    /// For example, "user:\<owner email\>" or "project:\<Google developer project
2198    /// id\>".
2199    pub owner: std::string::String,
2200
2201    /// Describes what error is encountered when accessing this resource.
2202    /// For example, updating a cloud project may require the `writer` permission
2203    /// on the developer console project.
2204    pub description: std::string::String,
2205
2206    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2207}
2208
2209impl ResourceInfo {
2210    pub fn new() -> Self {
2211        std::default::Default::default()
2212    }
2213
2214    /// Sets the value of [resource_type][crate::model::ResourceInfo::resource_type].
2215    pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2216        self.resource_type = v.into();
2217        self
2218    }
2219
2220    /// Sets the value of [resource_name][crate::model::ResourceInfo::resource_name].
2221    pub fn set_resource_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2222        self.resource_name = v.into();
2223        self
2224    }
2225
2226    /// Sets the value of [owner][crate::model::ResourceInfo::owner].
2227    pub fn set_owner<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2228        self.owner = v.into();
2229        self
2230    }
2231
2232    /// Sets the value of [description][crate::model::ResourceInfo::description].
2233    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2234        self.description = v.into();
2235        self
2236    }
2237}
2238
2239impl wkt::message::Message for ResourceInfo {
2240    fn typename() -> &'static str {
2241        "type.googleapis.com/google.rpc.ResourceInfo"
2242    }
2243}
2244
2245#[doc(hidden)]
2246impl<'de> serde::de::Deserialize<'de> for ResourceInfo {
2247    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2248    where
2249        D: serde::Deserializer<'de>,
2250    {
2251        #[allow(non_camel_case_types)]
2252        #[doc(hidden)]
2253        #[derive(PartialEq, Eq, Hash)]
2254        enum __FieldTag {
2255            __resource_type,
2256            __resource_name,
2257            __owner,
2258            __description,
2259            Unknown(std::string::String),
2260        }
2261        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2262            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2263            where
2264                D: serde::Deserializer<'de>,
2265            {
2266                struct Visitor;
2267                impl<'de> serde::de::Visitor<'de> for Visitor {
2268                    type Value = __FieldTag;
2269                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2270                        formatter.write_str("a field name for ResourceInfo")
2271                    }
2272                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2273                    where
2274                        E: serde::de::Error,
2275                    {
2276                        use std::result::Result::Ok;
2277                        use std::string::ToString;
2278                        match value {
2279                            "resourceType" => Ok(__FieldTag::__resource_type),
2280                            "resource_type" => Ok(__FieldTag::__resource_type),
2281                            "resourceName" => Ok(__FieldTag::__resource_name),
2282                            "resource_name" => Ok(__FieldTag::__resource_name),
2283                            "owner" => Ok(__FieldTag::__owner),
2284                            "description" => Ok(__FieldTag::__description),
2285                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2286                        }
2287                    }
2288                }
2289                deserializer.deserialize_identifier(Visitor)
2290            }
2291        }
2292        struct Visitor;
2293        impl<'de> serde::de::Visitor<'de> for Visitor {
2294            type Value = ResourceInfo;
2295            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2296                formatter.write_str("struct ResourceInfo")
2297            }
2298            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2299            where
2300                A: serde::de::MapAccess<'de>,
2301            {
2302                #[allow(unused_imports)]
2303                use serde::de::Error;
2304                use std::option::Option::Some;
2305                let mut fields = std::collections::HashSet::new();
2306                let mut result = Self::Value::new();
2307                while let Some(tag) = map.next_key::<__FieldTag>()? {
2308                    #[allow(clippy::match_single_binding)]
2309                    match tag {
2310                        __FieldTag::__resource_type => {
2311                            if !fields.insert(__FieldTag::__resource_type) {
2312                                return std::result::Result::Err(A::Error::duplicate_field(
2313                                    "multiple values for resource_type",
2314                                ));
2315                            }
2316                            result.resource_type = map
2317                                .next_value::<std::option::Option<std::string::String>>()?
2318                                .unwrap_or_default();
2319                        }
2320                        __FieldTag::__resource_name => {
2321                            if !fields.insert(__FieldTag::__resource_name) {
2322                                return std::result::Result::Err(A::Error::duplicate_field(
2323                                    "multiple values for resource_name",
2324                                ));
2325                            }
2326                            result.resource_name = map
2327                                .next_value::<std::option::Option<std::string::String>>()?
2328                                .unwrap_or_default();
2329                        }
2330                        __FieldTag::__owner => {
2331                            if !fields.insert(__FieldTag::__owner) {
2332                                return std::result::Result::Err(A::Error::duplicate_field(
2333                                    "multiple values for owner",
2334                                ));
2335                            }
2336                            result.owner = map
2337                                .next_value::<std::option::Option<std::string::String>>()?
2338                                .unwrap_or_default();
2339                        }
2340                        __FieldTag::__description => {
2341                            if !fields.insert(__FieldTag::__description) {
2342                                return std::result::Result::Err(A::Error::duplicate_field(
2343                                    "multiple values for description",
2344                                ));
2345                            }
2346                            result.description = map
2347                                .next_value::<std::option::Option<std::string::String>>()?
2348                                .unwrap_or_default();
2349                        }
2350                        __FieldTag::Unknown(key) => {
2351                            let value = map.next_value::<serde_json::Value>()?;
2352                            result._unknown_fields.insert(key, value);
2353                        }
2354                    }
2355                }
2356                std::result::Result::Ok(result)
2357            }
2358        }
2359        deserializer.deserialize_any(Visitor)
2360    }
2361}
2362
2363#[doc(hidden)]
2364impl serde::ser::Serialize for ResourceInfo {
2365    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2366    where
2367        S: serde::ser::Serializer,
2368    {
2369        use serde::ser::SerializeMap;
2370        #[allow(unused_imports)]
2371        use std::option::Option::Some;
2372        let mut state = serializer.serialize_map(std::option::Option::None)?;
2373        if !self.resource_type.is_empty() {
2374            state.serialize_entry("resourceType", &self.resource_type)?;
2375        }
2376        if !self.resource_name.is_empty() {
2377            state.serialize_entry("resourceName", &self.resource_name)?;
2378        }
2379        if !self.owner.is_empty() {
2380            state.serialize_entry("owner", &self.owner)?;
2381        }
2382        if !self.description.is_empty() {
2383            state.serialize_entry("description", &self.description)?;
2384        }
2385        if !self._unknown_fields.is_empty() {
2386            for (key, value) in self._unknown_fields.iter() {
2387                state.serialize_entry(key, &value)?;
2388            }
2389        }
2390        state.end()
2391    }
2392}
2393
2394impl std::fmt::Debug for ResourceInfo {
2395    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2396        let mut debug_struct = f.debug_struct("ResourceInfo");
2397        debug_struct.field("resource_type", &self.resource_type);
2398        debug_struct.field("resource_name", &self.resource_name);
2399        debug_struct.field("owner", &self.owner);
2400        debug_struct.field("description", &self.description);
2401        if !self._unknown_fields.is_empty() {
2402            debug_struct.field("_unknown_fields", &self._unknown_fields);
2403        }
2404        debug_struct.finish()
2405    }
2406}
2407
2408/// Provides links to documentation or for performing an out of band action.
2409///
2410/// For example, if a quota check failed with an error indicating the calling
2411/// project hasn't enabled the accessed service, this can contain a URL pointing
2412/// directly to the right place in the developer console to flip the bit.
2413#[derive(Clone, Default, PartialEq)]
2414#[non_exhaustive]
2415pub struct Help {
2416    /// URL(s) pointing to additional information on handling the current error.
2417    pub links: std::vec::Vec<crate::model::help::Link>,
2418
2419    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2420}
2421
2422impl Help {
2423    pub fn new() -> Self {
2424        std::default::Default::default()
2425    }
2426
2427    /// Sets the value of [links][crate::model::Help::links].
2428    pub fn set_links<T, V>(mut self, v: T) -> Self
2429    where
2430        T: std::iter::IntoIterator<Item = V>,
2431        V: std::convert::Into<crate::model::help::Link>,
2432    {
2433        use std::iter::Iterator;
2434        self.links = v.into_iter().map(|i| i.into()).collect();
2435        self
2436    }
2437}
2438
2439impl wkt::message::Message for Help {
2440    fn typename() -> &'static str {
2441        "type.googleapis.com/google.rpc.Help"
2442    }
2443}
2444
2445#[doc(hidden)]
2446impl<'de> serde::de::Deserialize<'de> for Help {
2447    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2448    where
2449        D: serde::Deserializer<'de>,
2450    {
2451        #[allow(non_camel_case_types)]
2452        #[doc(hidden)]
2453        #[derive(PartialEq, Eq, Hash)]
2454        enum __FieldTag {
2455            __links,
2456            Unknown(std::string::String),
2457        }
2458        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2459            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2460            where
2461                D: serde::Deserializer<'de>,
2462            {
2463                struct Visitor;
2464                impl<'de> serde::de::Visitor<'de> for Visitor {
2465                    type Value = __FieldTag;
2466                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2467                        formatter.write_str("a field name for Help")
2468                    }
2469                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2470                    where
2471                        E: serde::de::Error,
2472                    {
2473                        use std::result::Result::Ok;
2474                        use std::string::ToString;
2475                        match value {
2476                            "links" => Ok(__FieldTag::__links),
2477                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2478                        }
2479                    }
2480                }
2481                deserializer.deserialize_identifier(Visitor)
2482            }
2483        }
2484        struct Visitor;
2485        impl<'de> serde::de::Visitor<'de> for Visitor {
2486            type Value = Help;
2487            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2488                formatter.write_str("struct Help")
2489            }
2490            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2491            where
2492                A: serde::de::MapAccess<'de>,
2493            {
2494                #[allow(unused_imports)]
2495                use serde::de::Error;
2496                use std::option::Option::Some;
2497                let mut fields = std::collections::HashSet::new();
2498                let mut result = Self::Value::new();
2499                while let Some(tag) = map.next_key::<__FieldTag>()? {
2500                    #[allow(clippy::match_single_binding)]
2501                    match tag {
2502                        __FieldTag::__links => {
2503                            if !fields.insert(__FieldTag::__links) {
2504                                return std::result::Result::Err(A::Error::duplicate_field(
2505                                    "multiple values for links",
2506                                ));
2507                            }
2508                            result.links = map.next_value::<std::option::Option<std::vec::Vec<crate::model::help::Link>>>()?.unwrap_or_default();
2509                        }
2510                        __FieldTag::Unknown(key) => {
2511                            let value = map.next_value::<serde_json::Value>()?;
2512                            result._unknown_fields.insert(key, value);
2513                        }
2514                    }
2515                }
2516                std::result::Result::Ok(result)
2517            }
2518        }
2519        deserializer.deserialize_any(Visitor)
2520    }
2521}
2522
2523#[doc(hidden)]
2524impl serde::ser::Serialize for Help {
2525    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2526    where
2527        S: serde::ser::Serializer,
2528    {
2529        use serde::ser::SerializeMap;
2530        #[allow(unused_imports)]
2531        use std::option::Option::Some;
2532        let mut state = serializer.serialize_map(std::option::Option::None)?;
2533        if !self.links.is_empty() {
2534            state.serialize_entry("links", &self.links)?;
2535        }
2536        if !self._unknown_fields.is_empty() {
2537            for (key, value) in self._unknown_fields.iter() {
2538                state.serialize_entry(key, &value)?;
2539            }
2540        }
2541        state.end()
2542    }
2543}
2544
2545impl std::fmt::Debug for Help {
2546    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2547        let mut debug_struct = f.debug_struct("Help");
2548        debug_struct.field("links", &self.links);
2549        if !self._unknown_fields.is_empty() {
2550            debug_struct.field("_unknown_fields", &self._unknown_fields);
2551        }
2552        debug_struct.finish()
2553    }
2554}
2555
2556/// Defines additional types related to [Help].
2557pub mod help {
2558    #[allow(unused_imports)]
2559    use super::*;
2560
2561    /// Describes a URL link.
2562    #[derive(Clone, Default, PartialEq)]
2563    #[non_exhaustive]
2564    pub struct Link {
2565        /// Describes what the link offers.
2566        pub description: std::string::String,
2567
2568        /// The URL of the link.
2569        pub url: std::string::String,
2570
2571        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2572    }
2573
2574    impl Link {
2575        pub fn new() -> Self {
2576            std::default::Default::default()
2577        }
2578
2579        /// Sets the value of [description][crate::model::help::Link::description].
2580        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2581            self.description = v.into();
2582            self
2583        }
2584
2585        /// Sets the value of [url][crate::model::help::Link::url].
2586        pub fn set_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2587            self.url = v.into();
2588            self
2589        }
2590    }
2591
2592    impl wkt::message::Message for Link {
2593        fn typename() -> &'static str {
2594            "type.googleapis.com/google.rpc.Help.Link"
2595        }
2596    }
2597
2598    #[doc(hidden)]
2599    impl<'de> serde::de::Deserialize<'de> for Link {
2600        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2601        where
2602            D: serde::Deserializer<'de>,
2603        {
2604            #[allow(non_camel_case_types)]
2605            #[doc(hidden)]
2606            #[derive(PartialEq, Eq, Hash)]
2607            enum __FieldTag {
2608                __description,
2609                __url,
2610                Unknown(std::string::String),
2611            }
2612            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2613                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2614                where
2615                    D: serde::Deserializer<'de>,
2616                {
2617                    struct Visitor;
2618                    impl<'de> serde::de::Visitor<'de> for Visitor {
2619                        type Value = __FieldTag;
2620                        fn expecting(
2621                            &self,
2622                            formatter: &mut std::fmt::Formatter,
2623                        ) -> std::fmt::Result {
2624                            formatter.write_str("a field name for Link")
2625                        }
2626                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2627                        where
2628                            E: serde::de::Error,
2629                        {
2630                            use std::result::Result::Ok;
2631                            use std::string::ToString;
2632                            match value {
2633                                "description" => Ok(__FieldTag::__description),
2634                                "url" => Ok(__FieldTag::__url),
2635                                _ => Ok(__FieldTag::Unknown(value.to_string())),
2636                            }
2637                        }
2638                    }
2639                    deserializer.deserialize_identifier(Visitor)
2640                }
2641            }
2642            struct Visitor;
2643            impl<'de> serde::de::Visitor<'de> for Visitor {
2644                type Value = Link;
2645                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2646                    formatter.write_str("struct Link")
2647                }
2648                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2649                where
2650                    A: serde::de::MapAccess<'de>,
2651                {
2652                    #[allow(unused_imports)]
2653                    use serde::de::Error;
2654                    use std::option::Option::Some;
2655                    let mut fields = std::collections::HashSet::new();
2656                    let mut result = Self::Value::new();
2657                    while let Some(tag) = map.next_key::<__FieldTag>()? {
2658                        #[allow(clippy::match_single_binding)]
2659                        match tag {
2660                            __FieldTag::__description => {
2661                                if !fields.insert(__FieldTag::__description) {
2662                                    return std::result::Result::Err(A::Error::duplicate_field(
2663                                        "multiple values for description",
2664                                    ));
2665                                }
2666                                result.description = map
2667                                    .next_value::<std::option::Option<std::string::String>>()?
2668                                    .unwrap_or_default();
2669                            }
2670                            __FieldTag::__url => {
2671                                if !fields.insert(__FieldTag::__url) {
2672                                    return std::result::Result::Err(A::Error::duplicate_field(
2673                                        "multiple values for url",
2674                                    ));
2675                                }
2676                                result.url = map
2677                                    .next_value::<std::option::Option<std::string::String>>()?
2678                                    .unwrap_or_default();
2679                            }
2680                            __FieldTag::Unknown(key) => {
2681                                let value = map.next_value::<serde_json::Value>()?;
2682                                result._unknown_fields.insert(key, value);
2683                            }
2684                        }
2685                    }
2686                    std::result::Result::Ok(result)
2687                }
2688            }
2689            deserializer.deserialize_any(Visitor)
2690        }
2691    }
2692
2693    #[doc(hidden)]
2694    impl serde::ser::Serialize for Link {
2695        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2696        where
2697            S: serde::ser::Serializer,
2698        {
2699            use serde::ser::SerializeMap;
2700            #[allow(unused_imports)]
2701            use std::option::Option::Some;
2702            let mut state = serializer.serialize_map(std::option::Option::None)?;
2703            if !self.description.is_empty() {
2704                state.serialize_entry("description", &self.description)?;
2705            }
2706            if !self.url.is_empty() {
2707                state.serialize_entry("url", &self.url)?;
2708            }
2709            if !self._unknown_fields.is_empty() {
2710                for (key, value) in self._unknown_fields.iter() {
2711                    state.serialize_entry(key, &value)?;
2712                }
2713            }
2714            state.end()
2715        }
2716    }
2717
2718    impl std::fmt::Debug for Link {
2719        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2720            let mut debug_struct = f.debug_struct("Link");
2721            debug_struct.field("description", &self.description);
2722            debug_struct.field("url", &self.url);
2723            if !self._unknown_fields.is_empty() {
2724                debug_struct.field("_unknown_fields", &self._unknown_fields);
2725            }
2726            debug_struct.finish()
2727        }
2728    }
2729}
2730
2731/// Provides a localized error message that is safe to return to the user
2732/// which can be attached to an RPC error.
2733#[derive(Clone, Default, PartialEq)]
2734#[non_exhaustive]
2735pub struct LocalizedMessage {
2736    /// The locale used following the specification defined at
2737    /// <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>.
2738    /// Examples are: "en-US", "fr-CH", "es-MX"
2739    pub locale: std::string::String,
2740
2741    /// The localized error message in the above locale.
2742    pub message: std::string::String,
2743
2744    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2745}
2746
2747impl LocalizedMessage {
2748    pub fn new() -> Self {
2749        std::default::Default::default()
2750    }
2751
2752    /// Sets the value of [locale][crate::model::LocalizedMessage::locale].
2753    pub fn set_locale<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2754        self.locale = v.into();
2755        self
2756    }
2757
2758    /// Sets the value of [message][crate::model::LocalizedMessage::message].
2759    pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2760        self.message = v.into();
2761        self
2762    }
2763}
2764
2765impl wkt::message::Message for LocalizedMessage {
2766    fn typename() -> &'static str {
2767        "type.googleapis.com/google.rpc.LocalizedMessage"
2768    }
2769}
2770
2771#[doc(hidden)]
2772impl<'de> serde::de::Deserialize<'de> for LocalizedMessage {
2773    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2774    where
2775        D: serde::Deserializer<'de>,
2776    {
2777        #[allow(non_camel_case_types)]
2778        #[doc(hidden)]
2779        #[derive(PartialEq, Eq, Hash)]
2780        enum __FieldTag {
2781            __locale,
2782            __message,
2783            Unknown(std::string::String),
2784        }
2785        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2786            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2787            where
2788                D: serde::Deserializer<'de>,
2789            {
2790                struct Visitor;
2791                impl<'de> serde::de::Visitor<'de> for Visitor {
2792                    type Value = __FieldTag;
2793                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2794                        formatter.write_str("a field name for LocalizedMessage")
2795                    }
2796                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2797                    where
2798                        E: serde::de::Error,
2799                    {
2800                        use std::result::Result::Ok;
2801                        use std::string::ToString;
2802                        match value {
2803                            "locale" => Ok(__FieldTag::__locale),
2804                            "message" => Ok(__FieldTag::__message),
2805                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2806                        }
2807                    }
2808                }
2809                deserializer.deserialize_identifier(Visitor)
2810            }
2811        }
2812        struct Visitor;
2813        impl<'de> serde::de::Visitor<'de> for Visitor {
2814            type Value = LocalizedMessage;
2815            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2816                formatter.write_str("struct LocalizedMessage")
2817            }
2818            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2819            where
2820                A: serde::de::MapAccess<'de>,
2821            {
2822                #[allow(unused_imports)]
2823                use serde::de::Error;
2824                use std::option::Option::Some;
2825                let mut fields = std::collections::HashSet::new();
2826                let mut result = Self::Value::new();
2827                while let Some(tag) = map.next_key::<__FieldTag>()? {
2828                    #[allow(clippy::match_single_binding)]
2829                    match tag {
2830                        __FieldTag::__locale => {
2831                            if !fields.insert(__FieldTag::__locale) {
2832                                return std::result::Result::Err(A::Error::duplicate_field(
2833                                    "multiple values for locale",
2834                                ));
2835                            }
2836                            result.locale = map
2837                                .next_value::<std::option::Option<std::string::String>>()?
2838                                .unwrap_or_default();
2839                        }
2840                        __FieldTag::__message => {
2841                            if !fields.insert(__FieldTag::__message) {
2842                                return std::result::Result::Err(A::Error::duplicate_field(
2843                                    "multiple values for message",
2844                                ));
2845                            }
2846                            result.message = map
2847                                .next_value::<std::option::Option<std::string::String>>()?
2848                                .unwrap_or_default();
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 LocalizedMessage {
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.locale.is_empty() {
2874            state.serialize_entry("locale", &self.locale)?;
2875        }
2876        if !self.message.is_empty() {
2877            state.serialize_entry("message", &self.message)?;
2878        }
2879        if !self._unknown_fields.is_empty() {
2880            for (key, value) in self._unknown_fields.iter() {
2881                state.serialize_entry(key, &value)?;
2882            }
2883        }
2884        state.end()
2885    }
2886}
2887
2888impl std::fmt::Debug for LocalizedMessage {
2889    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2890        let mut debug_struct = f.debug_struct("LocalizedMessage");
2891        debug_struct.field("locale", &self.locale);
2892        debug_struct.field("message", &self.message);
2893        if !self._unknown_fields.is_empty() {
2894            debug_struct.field("_unknown_fields", &self._unknown_fields);
2895        }
2896        debug_struct.finish()
2897    }
2898}
2899
2900/// Represents an HTTP request.
2901#[derive(Clone, Default, PartialEq)]
2902#[non_exhaustive]
2903pub struct HttpRequest {
2904    /// The HTTP request method.
2905    pub method: std::string::String,
2906
2907    /// The HTTP request URI.
2908    pub uri: std::string::String,
2909
2910    /// The HTTP request headers. The ordering of the headers is significant.
2911    /// Multiple headers with the same key may present for the request.
2912    pub headers: std::vec::Vec<crate::model::HttpHeader>,
2913
2914    /// The HTTP request body. If the body is not expected, it should be empty.
2915    pub body: ::bytes::Bytes,
2916
2917    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2918}
2919
2920impl HttpRequest {
2921    pub fn new() -> Self {
2922        std::default::Default::default()
2923    }
2924
2925    /// Sets the value of [method][crate::model::HttpRequest::method].
2926    pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2927        self.method = v.into();
2928        self
2929    }
2930
2931    /// Sets the value of [uri][crate::model::HttpRequest::uri].
2932    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2933        self.uri = v.into();
2934        self
2935    }
2936
2937    /// Sets the value of [headers][crate::model::HttpRequest::headers].
2938    pub fn set_headers<T, V>(mut self, v: T) -> Self
2939    where
2940        T: std::iter::IntoIterator<Item = V>,
2941        V: std::convert::Into<crate::model::HttpHeader>,
2942    {
2943        use std::iter::Iterator;
2944        self.headers = v.into_iter().map(|i| i.into()).collect();
2945        self
2946    }
2947
2948    /// Sets the value of [body][crate::model::HttpRequest::body].
2949    pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2950        self.body = v.into();
2951        self
2952    }
2953}
2954
2955impl wkt::message::Message for HttpRequest {
2956    fn typename() -> &'static str {
2957        "type.googleapis.com/google.rpc.HttpRequest"
2958    }
2959}
2960
2961#[doc(hidden)]
2962impl<'de> serde::de::Deserialize<'de> for HttpRequest {
2963    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2964    where
2965        D: serde::Deserializer<'de>,
2966    {
2967        #[allow(non_camel_case_types)]
2968        #[doc(hidden)]
2969        #[derive(PartialEq, Eq, Hash)]
2970        enum __FieldTag {
2971            __method,
2972            __uri,
2973            __headers,
2974            __body,
2975            Unknown(std::string::String),
2976        }
2977        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2978            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2979            where
2980                D: serde::Deserializer<'de>,
2981            {
2982                struct Visitor;
2983                impl<'de> serde::de::Visitor<'de> for Visitor {
2984                    type Value = __FieldTag;
2985                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2986                        formatter.write_str("a field name for HttpRequest")
2987                    }
2988                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2989                    where
2990                        E: serde::de::Error,
2991                    {
2992                        use std::result::Result::Ok;
2993                        use std::string::ToString;
2994                        match value {
2995                            "method" => Ok(__FieldTag::__method),
2996                            "uri" => Ok(__FieldTag::__uri),
2997                            "headers" => Ok(__FieldTag::__headers),
2998                            "body" => Ok(__FieldTag::__body),
2999                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3000                        }
3001                    }
3002                }
3003                deserializer.deserialize_identifier(Visitor)
3004            }
3005        }
3006        struct Visitor;
3007        impl<'de> serde::de::Visitor<'de> for Visitor {
3008            type Value = HttpRequest;
3009            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3010                formatter.write_str("struct HttpRequest")
3011            }
3012            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3013            where
3014                A: serde::de::MapAccess<'de>,
3015            {
3016                #[allow(unused_imports)]
3017                use serde::de::Error;
3018                use std::option::Option::Some;
3019                let mut fields = std::collections::HashSet::new();
3020                let mut result = Self::Value::new();
3021                while let Some(tag) = map.next_key::<__FieldTag>()? {
3022                    #[allow(clippy::match_single_binding)]
3023                    match tag {
3024                        __FieldTag::__method => {
3025                            if !fields.insert(__FieldTag::__method) {
3026                                return std::result::Result::Err(A::Error::duplicate_field(
3027                                    "multiple values for method",
3028                                ));
3029                            }
3030                            result.method = map
3031                                .next_value::<std::option::Option<std::string::String>>()?
3032                                .unwrap_or_default();
3033                        }
3034                        __FieldTag::__uri => {
3035                            if !fields.insert(__FieldTag::__uri) {
3036                                return std::result::Result::Err(A::Error::duplicate_field(
3037                                    "multiple values for uri",
3038                                ));
3039                            }
3040                            result.uri = map
3041                                .next_value::<std::option::Option<std::string::String>>()?
3042                                .unwrap_or_default();
3043                        }
3044                        __FieldTag::__headers => {
3045                            if !fields.insert(__FieldTag::__headers) {
3046                                return std::result::Result::Err(A::Error::duplicate_field(
3047                                    "multiple values for headers",
3048                                ));
3049                            }
3050                            result.headers = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpHeader>>>()?.unwrap_or_default();
3051                        }
3052                        __FieldTag::__body => {
3053                            if !fields.insert(__FieldTag::__body) {
3054                                return std::result::Result::Err(A::Error::duplicate_field(
3055                                    "multiple values for body",
3056                                ));
3057                            }
3058                            struct __With(std::option::Option<::bytes::Bytes>);
3059                            impl<'de> serde::de::Deserialize<'de> for __With {
3060                                fn deserialize<D>(
3061                                    deserializer: D,
3062                                ) -> std::result::Result<Self, D::Error>
3063                                where
3064                                    D: serde::de::Deserializer<'de>,
3065                                {
3066                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
3067                                }
3068                            }
3069                            result.body = map.next_value::<__With>()?.0.unwrap_or_default();
3070                        }
3071                        __FieldTag::Unknown(key) => {
3072                            let value = map.next_value::<serde_json::Value>()?;
3073                            result._unknown_fields.insert(key, value);
3074                        }
3075                    }
3076                }
3077                std::result::Result::Ok(result)
3078            }
3079        }
3080        deserializer.deserialize_any(Visitor)
3081    }
3082}
3083
3084#[doc(hidden)]
3085impl serde::ser::Serialize for HttpRequest {
3086    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3087    where
3088        S: serde::ser::Serializer,
3089    {
3090        use serde::ser::SerializeMap;
3091        #[allow(unused_imports)]
3092        use std::option::Option::Some;
3093        let mut state = serializer.serialize_map(std::option::Option::None)?;
3094        if !self.method.is_empty() {
3095            state.serialize_entry("method", &self.method)?;
3096        }
3097        if !self.uri.is_empty() {
3098            state.serialize_entry("uri", &self.uri)?;
3099        }
3100        if !self.headers.is_empty() {
3101            state.serialize_entry("headers", &self.headers)?;
3102        }
3103        if !self.body.is_empty() {
3104            struct __With<'a>(&'a ::bytes::Bytes);
3105            impl<'a> serde::ser::Serialize for __With<'a> {
3106                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3107                where
3108                    S: serde::ser::Serializer,
3109                {
3110                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
3111                }
3112            }
3113            state.serialize_entry("body", &__With(&self.body))?;
3114        }
3115        if !self._unknown_fields.is_empty() {
3116            for (key, value) in self._unknown_fields.iter() {
3117                state.serialize_entry(key, &value)?;
3118            }
3119        }
3120        state.end()
3121    }
3122}
3123
3124impl std::fmt::Debug for HttpRequest {
3125    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3126        let mut debug_struct = f.debug_struct("HttpRequest");
3127        debug_struct.field("method", &self.method);
3128        debug_struct.field("uri", &self.uri);
3129        debug_struct.field("headers", &self.headers);
3130        debug_struct.field("body", &self.body);
3131        if !self._unknown_fields.is_empty() {
3132            debug_struct.field("_unknown_fields", &self._unknown_fields);
3133        }
3134        debug_struct.finish()
3135    }
3136}
3137
3138/// Represents an HTTP response.
3139#[derive(Clone, Default, PartialEq)]
3140#[non_exhaustive]
3141pub struct HttpResponse {
3142    /// The HTTP status code, such as 200 or 404.
3143    pub status: i32,
3144
3145    /// The HTTP reason phrase, such as "OK" or "Not Found".
3146    pub reason: std::string::String,
3147
3148    /// The HTTP response headers. The ordering of the headers is significant.
3149    /// Multiple headers with the same key may present for the response.
3150    pub headers: std::vec::Vec<crate::model::HttpHeader>,
3151
3152    /// The HTTP response body. If the body is not expected, it should be empty.
3153    pub body: ::bytes::Bytes,
3154
3155    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3156}
3157
3158impl HttpResponse {
3159    pub fn new() -> Self {
3160        std::default::Default::default()
3161    }
3162
3163    /// Sets the value of [status][crate::model::HttpResponse::status].
3164    pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3165        self.status = v.into();
3166        self
3167    }
3168
3169    /// Sets the value of [reason][crate::model::HttpResponse::reason].
3170    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3171        self.reason = v.into();
3172        self
3173    }
3174
3175    /// Sets the value of [headers][crate::model::HttpResponse::headers].
3176    pub fn set_headers<T, V>(mut self, v: T) -> Self
3177    where
3178        T: std::iter::IntoIterator<Item = V>,
3179        V: std::convert::Into<crate::model::HttpHeader>,
3180    {
3181        use std::iter::Iterator;
3182        self.headers = v.into_iter().map(|i| i.into()).collect();
3183        self
3184    }
3185
3186    /// Sets the value of [body][crate::model::HttpResponse::body].
3187    pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3188        self.body = v.into();
3189        self
3190    }
3191}
3192
3193impl wkt::message::Message for HttpResponse {
3194    fn typename() -> &'static str {
3195        "type.googleapis.com/google.rpc.HttpResponse"
3196    }
3197}
3198
3199#[doc(hidden)]
3200impl<'de> serde::de::Deserialize<'de> for HttpResponse {
3201    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3202    where
3203        D: serde::Deserializer<'de>,
3204    {
3205        #[allow(non_camel_case_types)]
3206        #[doc(hidden)]
3207        #[derive(PartialEq, Eq, Hash)]
3208        enum __FieldTag {
3209            __status,
3210            __reason,
3211            __headers,
3212            __body,
3213            Unknown(std::string::String),
3214        }
3215        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3216            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3217            where
3218                D: serde::Deserializer<'de>,
3219            {
3220                struct Visitor;
3221                impl<'de> serde::de::Visitor<'de> for Visitor {
3222                    type Value = __FieldTag;
3223                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3224                        formatter.write_str("a field name for HttpResponse")
3225                    }
3226                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3227                    where
3228                        E: serde::de::Error,
3229                    {
3230                        use std::result::Result::Ok;
3231                        use std::string::ToString;
3232                        match value {
3233                            "status" => Ok(__FieldTag::__status),
3234                            "reason" => Ok(__FieldTag::__reason),
3235                            "headers" => Ok(__FieldTag::__headers),
3236                            "body" => Ok(__FieldTag::__body),
3237                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3238                        }
3239                    }
3240                }
3241                deserializer.deserialize_identifier(Visitor)
3242            }
3243        }
3244        struct Visitor;
3245        impl<'de> serde::de::Visitor<'de> for Visitor {
3246            type Value = HttpResponse;
3247            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3248                formatter.write_str("struct HttpResponse")
3249            }
3250            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3251            where
3252                A: serde::de::MapAccess<'de>,
3253            {
3254                #[allow(unused_imports)]
3255                use serde::de::Error;
3256                use std::option::Option::Some;
3257                let mut fields = std::collections::HashSet::new();
3258                let mut result = Self::Value::new();
3259                while let Some(tag) = map.next_key::<__FieldTag>()? {
3260                    #[allow(clippy::match_single_binding)]
3261                    match tag {
3262                        __FieldTag::__status => {
3263                            if !fields.insert(__FieldTag::__status) {
3264                                return std::result::Result::Err(A::Error::duplicate_field(
3265                                    "multiple values for status",
3266                                ));
3267                            }
3268                            struct __With(std::option::Option<i32>);
3269                            impl<'de> serde::de::Deserialize<'de> for __With {
3270                                fn deserialize<D>(
3271                                    deserializer: D,
3272                                ) -> std::result::Result<Self, D::Error>
3273                                where
3274                                    D: serde::de::Deserializer<'de>,
3275                                {
3276                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3277                                }
3278                            }
3279                            result.status = map.next_value::<__With>()?.0.unwrap_or_default();
3280                        }
3281                        __FieldTag::__reason => {
3282                            if !fields.insert(__FieldTag::__reason) {
3283                                return std::result::Result::Err(A::Error::duplicate_field(
3284                                    "multiple values for reason",
3285                                ));
3286                            }
3287                            result.reason = map
3288                                .next_value::<std::option::Option<std::string::String>>()?
3289                                .unwrap_or_default();
3290                        }
3291                        __FieldTag::__headers => {
3292                            if !fields.insert(__FieldTag::__headers) {
3293                                return std::result::Result::Err(A::Error::duplicate_field(
3294                                    "multiple values for headers",
3295                                ));
3296                            }
3297                            result.headers = map.next_value::<std::option::Option<std::vec::Vec<crate::model::HttpHeader>>>()?.unwrap_or_default();
3298                        }
3299                        __FieldTag::__body => {
3300                            if !fields.insert(__FieldTag::__body) {
3301                                return std::result::Result::Err(A::Error::duplicate_field(
3302                                    "multiple values for body",
3303                                ));
3304                            }
3305                            struct __With(std::option::Option<::bytes::Bytes>);
3306                            impl<'de> serde::de::Deserialize<'de> for __With {
3307                                fn deserialize<D>(
3308                                    deserializer: D,
3309                                ) -> std::result::Result<Self, D::Error>
3310                                where
3311                                    D: serde::de::Deserializer<'de>,
3312                                {
3313                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
3314                                }
3315                            }
3316                            result.body = map.next_value::<__With>()?.0.unwrap_or_default();
3317                        }
3318                        __FieldTag::Unknown(key) => {
3319                            let value = map.next_value::<serde_json::Value>()?;
3320                            result._unknown_fields.insert(key, value);
3321                        }
3322                    }
3323                }
3324                std::result::Result::Ok(result)
3325            }
3326        }
3327        deserializer.deserialize_any(Visitor)
3328    }
3329}
3330
3331#[doc(hidden)]
3332impl serde::ser::Serialize for HttpResponse {
3333    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3334    where
3335        S: serde::ser::Serializer,
3336    {
3337        use serde::ser::SerializeMap;
3338        #[allow(unused_imports)]
3339        use std::option::Option::Some;
3340        let mut state = serializer.serialize_map(std::option::Option::None)?;
3341        if !wkt::internal::is_default(&self.status) {
3342            struct __With<'a>(&'a i32);
3343            impl<'a> serde::ser::Serialize for __With<'a> {
3344                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3345                where
3346                    S: serde::ser::Serializer,
3347                {
3348                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3349                }
3350            }
3351            state.serialize_entry("status", &__With(&self.status))?;
3352        }
3353        if !self.reason.is_empty() {
3354            state.serialize_entry("reason", &self.reason)?;
3355        }
3356        if !self.headers.is_empty() {
3357            state.serialize_entry("headers", &self.headers)?;
3358        }
3359        if !self.body.is_empty() {
3360            struct __With<'a>(&'a ::bytes::Bytes);
3361            impl<'a> serde::ser::Serialize for __With<'a> {
3362                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3363                where
3364                    S: serde::ser::Serializer,
3365                {
3366                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
3367                }
3368            }
3369            state.serialize_entry("body", &__With(&self.body))?;
3370        }
3371        if !self._unknown_fields.is_empty() {
3372            for (key, value) in self._unknown_fields.iter() {
3373                state.serialize_entry(key, &value)?;
3374            }
3375        }
3376        state.end()
3377    }
3378}
3379
3380impl std::fmt::Debug for HttpResponse {
3381    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3382        let mut debug_struct = f.debug_struct("HttpResponse");
3383        debug_struct.field("status", &self.status);
3384        debug_struct.field("reason", &self.reason);
3385        debug_struct.field("headers", &self.headers);
3386        debug_struct.field("body", &self.body);
3387        if !self._unknown_fields.is_empty() {
3388            debug_struct.field("_unknown_fields", &self._unknown_fields);
3389        }
3390        debug_struct.finish()
3391    }
3392}
3393
3394/// Represents an HTTP header.
3395#[derive(Clone, Default, PartialEq)]
3396#[non_exhaustive]
3397pub struct HttpHeader {
3398    /// The HTTP header key. It is case insensitive.
3399    pub key: std::string::String,
3400
3401    /// The HTTP header value.
3402    pub value: std::string::String,
3403
3404    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3405}
3406
3407impl HttpHeader {
3408    pub fn new() -> Self {
3409        std::default::Default::default()
3410    }
3411
3412    /// Sets the value of [key][crate::model::HttpHeader::key].
3413    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3414        self.key = v.into();
3415        self
3416    }
3417
3418    /// Sets the value of [value][crate::model::HttpHeader::value].
3419    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3420        self.value = v.into();
3421        self
3422    }
3423}
3424
3425impl wkt::message::Message for HttpHeader {
3426    fn typename() -> &'static str {
3427        "type.googleapis.com/google.rpc.HttpHeader"
3428    }
3429}
3430
3431#[doc(hidden)]
3432impl<'de> serde::de::Deserialize<'de> for HttpHeader {
3433    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3434    where
3435        D: serde::Deserializer<'de>,
3436    {
3437        #[allow(non_camel_case_types)]
3438        #[doc(hidden)]
3439        #[derive(PartialEq, Eq, Hash)]
3440        enum __FieldTag {
3441            __key,
3442            __value,
3443            Unknown(std::string::String),
3444        }
3445        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3446            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3447            where
3448                D: serde::Deserializer<'de>,
3449            {
3450                struct Visitor;
3451                impl<'de> serde::de::Visitor<'de> for Visitor {
3452                    type Value = __FieldTag;
3453                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3454                        formatter.write_str("a field name for HttpHeader")
3455                    }
3456                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3457                    where
3458                        E: serde::de::Error,
3459                    {
3460                        use std::result::Result::Ok;
3461                        use std::string::ToString;
3462                        match value {
3463                            "key" => Ok(__FieldTag::__key),
3464                            "value" => Ok(__FieldTag::__value),
3465                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3466                        }
3467                    }
3468                }
3469                deserializer.deserialize_identifier(Visitor)
3470            }
3471        }
3472        struct Visitor;
3473        impl<'de> serde::de::Visitor<'de> for Visitor {
3474            type Value = HttpHeader;
3475            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3476                formatter.write_str("struct HttpHeader")
3477            }
3478            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3479            where
3480                A: serde::de::MapAccess<'de>,
3481            {
3482                #[allow(unused_imports)]
3483                use serde::de::Error;
3484                use std::option::Option::Some;
3485                let mut fields = std::collections::HashSet::new();
3486                let mut result = Self::Value::new();
3487                while let Some(tag) = map.next_key::<__FieldTag>()? {
3488                    #[allow(clippy::match_single_binding)]
3489                    match tag {
3490                        __FieldTag::__key => {
3491                            if !fields.insert(__FieldTag::__key) {
3492                                return std::result::Result::Err(A::Error::duplicate_field(
3493                                    "multiple values for key",
3494                                ));
3495                            }
3496                            result.key = map
3497                                .next_value::<std::option::Option<std::string::String>>()?
3498                                .unwrap_or_default();
3499                        }
3500                        __FieldTag::__value => {
3501                            if !fields.insert(__FieldTag::__value) {
3502                                return std::result::Result::Err(A::Error::duplicate_field(
3503                                    "multiple values for value",
3504                                ));
3505                            }
3506                            result.value = map
3507                                .next_value::<std::option::Option<std::string::String>>()?
3508                                .unwrap_or_default();
3509                        }
3510                        __FieldTag::Unknown(key) => {
3511                            let value = map.next_value::<serde_json::Value>()?;
3512                            result._unknown_fields.insert(key, value);
3513                        }
3514                    }
3515                }
3516                std::result::Result::Ok(result)
3517            }
3518        }
3519        deserializer.deserialize_any(Visitor)
3520    }
3521}
3522
3523#[doc(hidden)]
3524impl serde::ser::Serialize for HttpHeader {
3525    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3526    where
3527        S: serde::ser::Serializer,
3528    {
3529        use serde::ser::SerializeMap;
3530        #[allow(unused_imports)]
3531        use std::option::Option::Some;
3532        let mut state = serializer.serialize_map(std::option::Option::None)?;
3533        if !self.key.is_empty() {
3534            state.serialize_entry("key", &self.key)?;
3535        }
3536        if !self.value.is_empty() {
3537            state.serialize_entry("value", &self.value)?;
3538        }
3539        if !self._unknown_fields.is_empty() {
3540            for (key, value) in self._unknown_fields.iter() {
3541                state.serialize_entry(key, &value)?;
3542            }
3543        }
3544        state.end()
3545    }
3546}
3547
3548impl std::fmt::Debug for HttpHeader {
3549    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3550        let mut debug_struct = f.debug_struct("HttpHeader");
3551        debug_struct.field("key", &self.key);
3552        debug_struct.field("value", &self.value);
3553        if !self._unknown_fields.is_empty() {
3554            debug_struct.field("_unknown_fields", &self._unknown_fields);
3555        }
3556        debug_struct.finish()
3557    }
3558}
3559
3560/// The `Status` type defines a logical error model that is suitable for
3561/// different programming environments, including REST APIs and RPC APIs. It is
3562/// used by [gRPC](https://github.com/grpc). Each `Status` message contains
3563/// three pieces of data: error code, error message, and error details.
3564///
3565/// You can find out more about this error model and how to work with it in the
3566/// [API Design Guide](https://cloud.google.com/apis/design/errors).
3567#[derive(Clone, Default, PartialEq)]
3568#[non_exhaustive]
3569pub struct Status {
3570    /// The status code, which should be an enum value of
3571    /// [google.rpc.Code][google.rpc.Code].
3572    ///
3573    /// [google.rpc.Code]: crate::model::Code
3574    pub code: i32,
3575
3576    /// A developer-facing error message, which should be in English. Any
3577    /// user-facing error message should be localized and sent in the
3578    /// [google.rpc.Status.details][google.rpc.Status.details] field, or localized
3579    /// by the client.
3580    ///
3581    /// [google.rpc.Status.details]: crate::model::Status::details
3582    pub message: std::string::String,
3583
3584    /// A list of messages that carry the error details.  There is a common set of
3585    /// message types for APIs to use.
3586    pub details: std::vec::Vec<wkt::Any>,
3587
3588    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3589}
3590
3591impl Status {
3592    pub fn new() -> Self {
3593        std::default::Default::default()
3594    }
3595
3596    /// Sets the value of [code][crate::model::Status::code].
3597    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3598        self.code = v.into();
3599        self
3600    }
3601
3602    /// Sets the value of [message][crate::model::Status::message].
3603    pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3604        self.message = v.into();
3605        self
3606    }
3607
3608    /// Sets the value of [details][crate::model::Status::details].
3609    pub fn set_details<T, V>(mut self, v: T) -> Self
3610    where
3611        T: std::iter::IntoIterator<Item = V>,
3612        V: std::convert::Into<wkt::Any>,
3613    {
3614        use std::iter::Iterator;
3615        self.details = v.into_iter().map(|i| i.into()).collect();
3616        self
3617    }
3618}
3619
3620impl wkt::message::Message for Status {
3621    fn typename() -> &'static str {
3622        "type.googleapis.com/google.rpc.Status"
3623    }
3624}
3625
3626#[doc(hidden)]
3627impl<'de> serde::de::Deserialize<'de> for Status {
3628    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3629    where
3630        D: serde::Deserializer<'de>,
3631    {
3632        #[allow(non_camel_case_types)]
3633        #[doc(hidden)]
3634        #[derive(PartialEq, Eq, Hash)]
3635        enum __FieldTag {
3636            __code,
3637            __message,
3638            __details,
3639            Unknown(std::string::String),
3640        }
3641        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3642            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3643            where
3644                D: serde::Deserializer<'de>,
3645            {
3646                struct Visitor;
3647                impl<'de> serde::de::Visitor<'de> for Visitor {
3648                    type Value = __FieldTag;
3649                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3650                        formatter.write_str("a field name for Status")
3651                    }
3652                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3653                    where
3654                        E: serde::de::Error,
3655                    {
3656                        use std::result::Result::Ok;
3657                        use std::string::ToString;
3658                        match value {
3659                            "code" => Ok(__FieldTag::__code),
3660                            "message" => Ok(__FieldTag::__message),
3661                            "details" => Ok(__FieldTag::__details),
3662                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3663                        }
3664                    }
3665                }
3666                deserializer.deserialize_identifier(Visitor)
3667            }
3668        }
3669        struct Visitor;
3670        impl<'de> serde::de::Visitor<'de> for Visitor {
3671            type Value = Status;
3672            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3673                formatter.write_str("struct Status")
3674            }
3675            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3676            where
3677                A: serde::de::MapAccess<'de>,
3678            {
3679                #[allow(unused_imports)]
3680                use serde::de::Error;
3681                use std::option::Option::Some;
3682                let mut fields = std::collections::HashSet::new();
3683                let mut result = Self::Value::new();
3684                while let Some(tag) = map.next_key::<__FieldTag>()? {
3685                    #[allow(clippy::match_single_binding)]
3686                    match tag {
3687                        __FieldTag::__code => {
3688                            if !fields.insert(__FieldTag::__code) {
3689                                return std::result::Result::Err(A::Error::duplicate_field(
3690                                    "multiple values for code",
3691                                ));
3692                            }
3693                            struct __With(std::option::Option<i32>);
3694                            impl<'de> serde::de::Deserialize<'de> for __With {
3695                                fn deserialize<D>(
3696                                    deserializer: D,
3697                                ) -> std::result::Result<Self, D::Error>
3698                                where
3699                                    D: serde::de::Deserializer<'de>,
3700                                {
3701                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3702                                }
3703                            }
3704                            result.code = map.next_value::<__With>()?.0.unwrap_or_default();
3705                        }
3706                        __FieldTag::__message => {
3707                            if !fields.insert(__FieldTag::__message) {
3708                                return std::result::Result::Err(A::Error::duplicate_field(
3709                                    "multiple values for message",
3710                                ));
3711                            }
3712                            result.message = map
3713                                .next_value::<std::option::Option<std::string::String>>()?
3714                                .unwrap_or_default();
3715                        }
3716                        __FieldTag::__details => {
3717                            if !fields.insert(__FieldTag::__details) {
3718                                return std::result::Result::Err(A::Error::duplicate_field(
3719                                    "multiple values for details",
3720                                ));
3721                            }
3722                            result.details = map
3723                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
3724                                .unwrap_or_default();
3725                        }
3726                        __FieldTag::Unknown(key) => {
3727                            let value = map.next_value::<serde_json::Value>()?;
3728                            result._unknown_fields.insert(key, value);
3729                        }
3730                    }
3731                }
3732                std::result::Result::Ok(result)
3733            }
3734        }
3735        deserializer.deserialize_any(Visitor)
3736    }
3737}
3738
3739#[doc(hidden)]
3740impl serde::ser::Serialize for Status {
3741    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3742    where
3743        S: serde::ser::Serializer,
3744    {
3745        use serde::ser::SerializeMap;
3746        #[allow(unused_imports)]
3747        use std::option::Option::Some;
3748        let mut state = serializer.serialize_map(std::option::Option::None)?;
3749        if !wkt::internal::is_default(&self.code) {
3750            struct __With<'a>(&'a i32);
3751            impl<'a> serde::ser::Serialize for __With<'a> {
3752                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3753                where
3754                    S: serde::ser::Serializer,
3755                {
3756                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3757                }
3758            }
3759            state.serialize_entry("code", &__With(&self.code))?;
3760        }
3761        if !self.message.is_empty() {
3762            state.serialize_entry("message", &self.message)?;
3763        }
3764        if !self.details.is_empty() {
3765            state.serialize_entry("details", &self.details)?;
3766        }
3767        if !self._unknown_fields.is_empty() {
3768            for (key, value) in self._unknown_fields.iter() {
3769                state.serialize_entry(key, &value)?;
3770            }
3771        }
3772        state.end()
3773    }
3774}
3775
3776impl std::fmt::Debug for Status {
3777    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3778        let mut debug_struct = f.debug_struct("Status");
3779        debug_struct.field("code", &self.code);
3780        debug_struct.field("message", &self.message);
3781        debug_struct.field("details", &self.details);
3782        if !self._unknown_fields.is_empty() {
3783            debug_struct.field("_unknown_fields", &self._unknown_fields);
3784        }
3785        debug_struct.finish()
3786    }
3787}
3788
3789/// The canonical error codes for gRPC APIs.
3790///
3791/// Sometimes multiple error codes may apply.  Services should return
3792/// the most specific error code that applies.  For example, prefer
3793/// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
3794/// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
3795///
3796/// # Working with unknown values
3797///
3798/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3799/// additional enum variants at any time. Adding new variants is not considered
3800/// a breaking change. Applications should write their code in anticipation of:
3801///
3802/// - New values appearing in future releases of the client library, **and**
3803/// - New values received dynamically, without application changes.
3804///
3805/// Please consult the [Working with enums] section in the user guide for some
3806/// guidelines.
3807///
3808/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3809#[derive(Clone, Debug, PartialEq)]
3810#[non_exhaustive]
3811pub enum Code {
3812    /// Not an error; returned on success.
3813    ///
3814    /// HTTP Mapping: 200 OK
3815    Ok,
3816    /// The operation was cancelled, typically by the caller.
3817    ///
3818    /// HTTP Mapping: 499 Client Closed Request
3819    Cancelled,
3820    /// Unknown error.  For example, this error may be returned when
3821    /// a `Status` value received from another address space belongs to
3822    /// an error space that is not known in this address space.  Also
3823    /// errors raised by APIs that do not return enough error information
3824    /// may be converted to this error.
3825    ///
3826    /// HTTP Mapping: 500 Internal Server Error
3827    Unknown,
3828    /// The client specified an invalid argument.  Note that this differs
3829    /// from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
3830    /// that are problematic regardless of the state of the system
3831    /// (e.g., a malformed file name).
3832    ///
3833    /// HTTP Mapping: 400 Bad Request
3834    InvalidArgument,
3835    /// The deadline expired before the operation could complete. For operations
3836    /// that change the state of the system, this error may be returned
3837    /// even if the operation has completed successfully.  For example, a
3838    /// successful response from a server could have been delayed long
3839    /// enough for the deadline to expire.
3840    ///
3841    /// HTTP Mapping: 504 Gateway Timeout
3842    DeadlineExceeded,
3843    /// Some requested entity (e.g., file or directory) was not found.
3844    ///
3845    /// Note to server developers: if a request is denied for an entire class
3846    /// of users, such as gradual feature rollout or undocumented allowlist,
3847    /// `NOT_FOUND` may be used. If a request is denied for some users within
3848    /// a class of users, such as user-based access control, `PERMISSION_DENIED`
3849    /// must be used.
3850    ///
3851    /// HTTP Mapping: 404 Not Found
3852    NotFound,
3853    /// The entity that a client attempted to create (e.g., file or directory)
3854    /// already exists.
3855    ///
3856    /// HTTP Mapping: 409 Conflict
3857    AlreadyExists,
3858    /// The caller does not have permission to execute the specified
3859    /// operation. `PERMISSION_DENIED` must not be used for rejections
3860    /// caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
3861    /// instead for those errors). `PERMISSION_DENIED` must not be
3862    /// used if the caller can not be identified (use `UNAUTHENTICATED`
3863    /// instead for those errors). This error code does not imply the
3864    /// request is valid or the requested entity exists or satisfies
3865    /// other pre-conditions.
3866    ///
3867    /// HTTP Mapping: 403 Forbidden
3868    PermissionDenied,
3869    /// The request does not have valid authentication credentials for the
3870    /// operation.
3871    ///
3872    /// HTTP Mapping: 401 Unauthorized
3873    Unauthenticated,
3874    /// Some resource has been exhausted, perhaps a per-user quota, or
3875    /// perhaps the entire file system is out of space.
3876    ///
3877    /// HTTP Mapping: 429 Too Many Requests
3878    ResourceExhausted,
3879    /// The operation was rejected because the system is not in a state
3880    /// required for the operation's execution.  For example, the directory
3881    /// to be deleted is non-empty, an rmdir operation is applied to
3882    /// a non-directory, etc.
3883    ///
3884    /// Service implementors can use the following guidelines to decide
3885    /// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
3886    /// (a) Use `UNAVAILABLE` if the client can retry just the failing call.
3887    /// (b) Use `ABORTED` if the client should retry at a higher level. For
3888    /// example, when a client-specified test-and-set fails, indicating the
3889    /// client should restart a read-modify-write sequence.
3890    /// (c) Use `FAILED_PRECONDITION` if the client should not retry until
3891    /// the system state has been explicitly fixed. For example, if an "rmdir"
3892    /// fails because the directory is non-empty, `FAILED_PRECONDITION`
3893    /// should be returned since the client should not retry unless
3894    /// the files are deleted from the directory.
3895    ///
3896    /// HTTP Mapping: 400 Bad Request
3897    FailedPrecondition,
3898    /// The operation was aborted, typically due to a concurrency issue such as
3899    /// a sequencer check failure or transaction abort.
3900    ///
3901    /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
3902    /// `ABORTED`, and `UNAVAILABLE`.
3903    ///
3904    /// HTTP Mapping: 409 Conflict
3905    Aborted,
3906    /// The operation was attempted past the valid range.  E.g., seeking or
3907    /// reading past end-of-file.
3908    ///
3909    /// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
3910    /// be fixed if the system state changes. For example, a 32-bit file
3911    /// system will generate `INVALID_ARGUMENT` if asked to read at an
3912    /// offset that is not in the range [0,2^32-1], but it will generate
3913    /// `OUT_OF_RANGE` if asked to read from an offset past the current
3914    /// file size.
3915    ///
3916    /// There is a fair bit of overlap between `FAILED_PRECONDITION` and
3917    /// `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
3918    /// error) when it applies so that callers who are iterating through
3919    /// a space can easily look for an `OUT_OF_RANGE` error to detect when
3920    /// they are done.
3921    ///
3922    /// HTTP Mapping: 400 Bad Request
3923    OutOfRange,
3924    /// The operation is not implemented or is not supported/enabled in this
3925    /// service.
3926    ///
3927    /// HTTP Mapping: 501 Not Implemented
3928    Unimplemented,
3929    /// Internal errors.  This means that some invariants expected by the
3930    /// underlying system have been broken.  This error code is reserved
3931    /// for serious errors.
3932    ///
3933    /// HTTP Mapping: 500 Internal Server Error
3934    Internal,
3935    /// The service is currently unavailable.  This is most likely a
3936    /// transient condition, which can be corrected by retrying with
3937    /// a backoff. Note that it is not always safe to retry
3938    /// non-idempotent operations.
3939    ///
3940    /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
3941    /// `ABORTED`, and `UNAVAILABLE`.
3942    ///
3943    /// HTTP Mapping: 503 Service Unavailable
3944    Unavailable,
3945    /// Unrecoverable data loss or corruption.
3946    ///
3947    /// HTTP Mapping: 500 Internal Server Error
3948    DataLoss,
3949    /// If set, the enum was initialized with an unknown value.
3950    ///
3951    /// Applications can examine the value using [Code::value] or
3952    /// [Code::name].
3953    UnknownValue(code::UnknownValue),
3954}
3955
3956#[doc(hidden)]
3957pub mod code {
3958    #[allow(unused_imports)]
3959    use super::*;
3960    #[derive(Clone, Debug, PartialEq)]
3961    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3962}
3963
3964impl Code {
3965    /// Gets the enum value.
3966    ///
3967    /// Returns `None` if the enum contains an unknown value deserialized from
3968    /// the string representation of enums.
3969    pub fn value(&self) -> std::option::Option<i32> {
3970        match self {
3971            Self::Ok => std::option::Option::Some(0),
3972            Self::Cancelled => std::option::Option::Some(1),
3973            Self::Unknown => std::option::Option::Some(2),
3974            Self::InvalidArgument => std::option::Option::Some(3),
3975            Self::DeadlineExceeded => std::option::Option::Some(4),
3976            Self::NotFound => std::option::Option::Some(5),
3977            Self::AlreadyExists => std::option::Option::Some(6),
3978            Self::PermissionDenied => std::option::Option::Some(7),
3979            Self::Unauthenticated => std::option::Option::Some(16),
3980            Self::ResourceExhausted => std::option::Option::Some(8),
3981            Self::FailedPrecondition => std::option::Option::Some(9),
3982            Self::Aborted => std::option::Option::Some(10),
3983            Self::OutOfRange => std::option::Option::Some(11),
3984            Self::Unimplemented => std::option::Option::Some(12),
3985            Self::Internal => std::option::Option::Some(13),
3986            Self::Unavailable => std::option::Option::Some(14),
3987            Self::DataLoss => std::option::Option::Some(15),
3988            Self::UnknownValue(u) => u.0.value(),
3989        }
3990    }
3991
3992    /// Gets the enum value as a string.
3993    ///
3994    /// Returns `None` if the enum contains an unknown value deserialized from
3995    /// the integer representation of enums.
3996    pub fn name(&self) -> std::option::Option<&str> {
3997        match self {
3998            Self::Ok => std::option::Option::Some("OK"),
3999            Self::Cancelled => std::option::Option::Some("CANCELLED"),
4000            Self::Unknown => std::option::Option::Some("UNKNOWN"),
4001            Self::InvalidArgument => std::option::Option::Some("INVALID_ARGUMENT"),
4002            Self::DeadlineExceeded => std::option::Option::Some("DEADLINE_EXCEEDED"),
4003            Self::NotFound => std::option::Option::Some("NOT_FOUND"),
4004            Self::AlreadyExists => std::option::Option::Some("ALREADY_EXISTS"),
4005            Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
4006            Self::Unauthenticated => std::option::Option::Some("UNAUTHENTICATED"),
4007            Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
4008            Self::FailedPrecondition => std::option::Option::Some("FAILED_PRECONDITION"),
4009            Self::Aborted => std::option::Option::Some("ABORTED"),
4010            Self::OutOfRange => std::option::Option::Some("OUT_OF_RANGE"),
4011            Self::Unimplemented => std::option::Option::Some("UNIMPLEMENTED"),
4012            Self::Internal => std::option::Option::Some("INTERNAL"),
4013            Self::Unavailable => std::option::Option::Some("UNAVAILABLE"),
4014            Self::DataLoss => std::option::Option::Some("DATA_LOSS"),
4015            Self::UnknownValue(u) => u.0.name(),
4016        }
4017    }
4018}
4019
4020impl std::default::Default for Code {
4021    fn default() -> Self {
4022        use std::convert::From;
4023        Self::from(0)
4024    }
4025}
4026
4027impl std::fmt::Display for Code {
4028    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4029        wkt::internal::display_enum(f, self.name(), self.value())
4030    }
4031}
4032
4033impl std::convert::From<i32> for Code {
4034    fn from(value: i32) -> Self {
4035        match value {
4036            0 => Self::Ok,
4037            1 => Self::Cancelled,
4038            2 => Self::Unknown,
4039            3 => Self::InvalidArgument,
4040            4 => Self::DeadlineExceeded,
4041            5 => Self::NotFound,
4042            6 => Self::AlreadyExists,
4043            7 => Self::PermissionDenied,
4044            8 => Self::ResourceExhausted,
4045            9 => Self::FailedPrecondition,
4046            10 => Self::Aborted,
4047            11 => Self::OutOfRange,
4048            12 => Self::Unimplemented,
4049            13 => Self::Internal,
4050            14 => Self::Unavailable,
4051            15 => Self::DataLoss,
4052            16 => Self::Unauthenticated,
4053            _ => Self::UnknownValue(code::UnknownValue(
4054                wkt::internal::UnknownEnumValue::Integer(value),
4055            )),
4056        }
4057    }
4058}
4059
4060impl std::convert::From<&str> for Code {
4061    fn from(value: &str) -> Self {
4062        use std::string::ToString;
4063        match value {
4064            "OK" => Self::Ok,
4065            "CANCELLED" => Self::Cancelled,
4066            "UNKNOWN" => Self::Unknown,
4067            "INVALID_ARGUMENT" => Self::InvalidArgument,
4068            "DEADLINE_EXCEEDED" => Self::DeadlineExceeded,
4069            "NOT_FOUND" => Self::NotFound,
4070            "ALREADY_EXISTS" => Self::AlreadyExists,
4071            "PERMISSION_DENIED" => Self::PermissionDenied,
4072            "UNAUTHENTICATED" => Self::Unauthenticated,
4073            "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
4074            "FAILED_PRECONDITION" => Self::FailedPrecondition,
4075            "ABORTED" => Self::Aborted,
4076            "OUT_OF_RANGE" => Self::OutOfRange,
4077            "UNIMPLEMENTED" => Self::Unimplemented,
4078            "INTERNAL" => Self::Internal,
4079            "UNAVAILABLE" => Self::Unavailable,
4080            "DATA_LOSS" => Self::DataLoss,
4081            _ => Self::UnknownValue(code::UnknownValue(wkt::internal::UnknownEnumValue::String(
4082                value.to_string(),
4083            ))),
4084        }
4085    }
4086}
4087
4088impl serde::ser::Serialize for Code {
4089    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4090    where
4091        S: serde::Serializer,
4092    {
4093        match self {
4094            Self::Ok => serializer.serialize_i32(0),
4095            Self::Cancelled => serializer.serialize_i32(1),
4096            Self::Unknown => serializer.serialize_i32(2),
4097            Self::InvalidArgument => serializer.serialize_i32(3),
4098            Self::DeadlineExceeded => serializer.serialize_i32(4),
4099            Self::NotFound => serializer.serialize_i32(5),
4100            Self::AlreadyExists => serializer.serialize_i32(6),
4101            Self::PermissionDenied => serializer.serialize_i32(7),
4102            Self::Unauthenticated => serializer.serialize_i32(16),
4103            Self::ResourceExhausted => serializer.serialize_i32(8),
4104            Self::FailedPrecondition => serializer.serialize_i32(9),
4105            Self::Aborted => serializer.serialize_i32(10),
4106            Self::OutOfRange => serializer.serialize_i32(11),
4107            Self::Unimplemented => serializer.serialize_i32(12),
4108            Self::Internal => serializer.serialize_i32(13),
4109            Self::Unavailable => serializer.serialize_i32(14),
4110            Self::DataLoss => serializer.serialize_i32(15),
4111            Self::UnknownValue(u) => u.0.serialize(serializer),
4112        }
4113    }
4114}
4115
4116impl<'de> serde::de::Deserialize<'de> for Code {
4117    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4118    where
4119        D: serde::Deserializer<'de>,
4120    {
4121        deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(".google.rpc.Code"))
4122    }
4123}