google_cloud_rpc_context/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27/// This message defines the standard attribute vocabulary for Google APIs.
28///
29/// An attribute is a piece of metadata that describes an activity on a network
30/// service. For example, the size of an HTTP request, or the status code of
31/// an HTTP response.
32///
33/// Each attribute has a type and a name, which is logically defined as
34/// a proto message field in `AttributeContext`. The field type becomes the
35/// attribute type, and the field path becomes the attribute name. For example,
36/// the attribute `source.ip` maps to field `AttributeContext.source.ip`.
37///
38/// This message definition is guaranteed not to have any wire breaking change.
39/// So you can use it directly for passing attributes across different systems.
40///
41/// NOTE: Different system may generate different subset of attributes. Please
42/// verify the system specification before relying on an attribute generated
43/// a system.
44#[derive(Clone, Debug, Default, PartialEq)]
45#[non_exhaustive]
46pub struct AttributeContext {
47    /// The origin of a network activity. In a multi hop network activity,
48    /// the origin represents the sender of the first hop. For the first hop,
49    /// the `source` and the `origin` must have the same content.
50    pub origin: std::option::Option<crate::model::attribute_context::Peer>,
51
52    /// The source of a network activity, such as starting a TCP connection.
53    /// In a multi hop network activity, the source represents the sender of the
54    /// last hop.
55    pub source: std::option::Option<crate::model::attribute_context::Peer>,
56
57    /// The destination of a network activity, such as accepting a TCP connection.
58    /// In a multi hop network activity, the destination represents the receiver of
59    /// the last hop.
60    pub destination: std::option::Option<crate::model::attribute_context::Peer>,
61
62    /// Represents a network request, such as an HTTP request.
63    pub request: std::option::Option<crate::model::attribute_context::Request>,
64
65    /// Represents a network response, such as an HTTP response.
66    pub response: std::option::Option<crate::model::attribute_context::Response>,
67
68    /// Represents a target resource that is involved with a network activity.
69    /// If multiple resources are involved with an activity, this must be the
70    /// primary one.
71    pub resource: std::option::Option<crate::model::attribute_context::Resource>,
72
73    /// Represents an API operation that is involved to a network activity.
74    pub api: std::option::Option<crate::model::attribute_context::Api>,
75
76    /// Supports extensions for advanced use cases, such as logs and metrics.
77    pub extensions: std::vec::Vec<wkt::Any>,
78
79    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
80}
81
82impl AttributeContext {
83    pub fn new() -> Self {
84        std::default::Default::default()
85    }
86
87    /// Sets the value of [origin][crate::model::AttributeContext::origin].
88    pub fn set_origin<T>(mut self, v: T) -> Self
89    where
90        T: std::convert::Into<crate::model::attribute_context::Peer>,
91    {
92        self.origin = std::option::Option::Some(v.into());
93        self
94    }
95
96    /// Sets or clears the value of [origin][crate::model::AttributeContext::origin].
97    pub fn set_or_clear_origin<T>(mut self, v: std::option::Option<T>) -> Self
98    where
99        T: std::convert::Into<crate::model::attribute_context::Peer>,
100    {
101        self.origin = v.map(|x| x.into());
102        self
103    }
104
105    /// Sets the value of [source][crate::model::AttributeContext::source].
106    pub fn set_source<T>(mut self, v: T) -> Self
107    where
108        T: std::convert::Into<crate::model::attribute_context::Peer>,
109    {
110        self.source = std::option::Option::Some(v.into());
111        self
112    }
113
114    /// Sets or clears the value of [source][crate::model::AttributeContext::source].
115    pub fn set_or_clear_source<T>(mut self, v: std::option::Option<T>) -> Self
116    where
117        T: std::convert::Into<crate::model::attribute_context::Peer>,
118    {
119        self.source = v.map(|x| x.into());
120        self
121    }
122
123    /// Sets the value of [destination][crate::model::AttributeContext::destination].
124    pub fn set_destination<T>(mut self, v: T) -> Self
125    where
126        T: std::convert::Into<crate::model::attribute_context::Peer>,
127    {
128        self.destination = std::option::Option::Some(v.into());
129        self
130    }
131
132    /// Sets or clears the value of [destination][crate::model::AttributeContext::destination].
133    pub fn set_or_clear_destination<T>(mut self, v: std::option::Option<T>) -> Self
134    where
135        T: std::convert::Into<crate::model::attribute_context::Peer>,
136    {
137        self.destination = v.map(|x| x.into());
138        self
139    }
140
141    /// Sets the value of [request][crate::model::AttributeContext::request].
142    pub fn set_request<T>(mut self, v: T) -> Self
143    where
144        T: std::convert::Into<crate::model::attribute_context::Request>,
145    {
146        self.request = std::option::Option::Some(v.into());
147        self
148    }
149
150    /// Sets or clears the value of [request][crate::model::AttributeContext::request].
151    pub fn set_or_clear_request<T>(mut self, v: std::option::Option<T>) -> Self
152    where
153        T: std::convert::Into<crate::model::attribute_context::Request>,
154    {
155        self.request = v.map(|x| x.into());
156        self
157    }
158
159    /// Sets the value of [response][crate::model::AttributeContext::response].
160    pub fn set_response<T>(mut self, v: T) -> Self
161    where
162        T: std::convert::Into<crate::model::attribute_context::Response>,
163    {
164        self.response = std::option::Option::Some(v.into());
165        self
166    }
167
168    /// Sets or clears the value of [response][crate::model::AttributeContext::response].
169    pub fn set_or_clear_response<T>(mut self, v: std::option::Option<T>) -> Self
170    where
171        T: std::convert::Into<crate::model::attribute_context::Response>,
172    {
173        self.response = v.map(|x| x.into());
174        self
175    }
176
177    /// Sets the value of [resource][crate::model::AttributeContext::resource].
178    pub fn set_resource<T>(mut self, v: T) -> Self
179    where
180        T: std::convert::Into<crate::model::attribute_context::Resource>,
181    {
182        self.resource = std::option::Option::Some(v.into());
183        self
184    }
185
186    /// Sets or clears the value of [resource][crate::model::AttributeContext::resource].
187    pub fn set_or_clear_resource<T>(mut self, v: std::option::Option<T>) -> Self
188    where
189        T: std::convert::Into<crate::model::attribute_context::Resource>,
190    {
191        self.resource = v.map(|x| x.into());
192        self
193    }
194
195    /// Sets the value of [api][crate::model::AttributeContext::api].
196    pub fn set_api<T>(mut self, v: T) -> Self
197    where
198        T: std::convert::Into<crate::model::attribute_context::Api>,
199    {
200        self.api = std::option::Option::Some(v.into());
201        self
202    }
203
204    /// Sets or clears the value of [api][crate::model::AttributeContext::api].
205    pub fn set_or_clear_api<T>(mut self, v: std::option::Option<T>) -> Self
206    where
207        T: std::convert::Into<crate::model::attribute_context::Api>,
208    {
209        self.api = v.map(|x| x.into());
210        self
211    }
212
213    /// Sets the value of [extensions][crate::model::AttributeContext::extensions].
214    pub fn set_extensions<T, V>(mut self, v: T) -> Self
215    where
216        T: std::iter::IntoIterator<Item = V>,
217        V: std::convert::Into<wkt::Any>,
218    {
219        use std::iter::Iterator;
220        self.extensions = v.into_iter().map(|i| i.into()).collect();
221        self
222    }
223}
224
225impl wkt::message::Message for AttributeContext {
226    fn typename() -> &'static str {
227        "type.googleapis.com/google.rpc.context.AttributeContext"
228    }
229}
230
231#[doc(hidden)]
232impl<'de> serde::de::Deserialize<'de> for AttributeContext {
233    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
234    where
235        D: serde::Deserializer<'de>,
236    {
237        #[allow(non_camel_case_types)]
238        #[doc(hidden)]
239        #[derive(PartialEq, Eq, Hash)]
240        enum __FieldTag {
241            __origin,
242            __source,
243            __destination,
244            __request,
245            __response,
246            __resource,
247            __api,
248            __extensions,
249            Unknown(std::string::String),
250        }
251        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
252            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
253            where
254                D: serde::Deserializer<'de>,
255            {
256                struct Visitor;
257                impl<'de> serde::de::Visitor<'de> for Visitor {
258                    type Value = __FieldTag;
259                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
260                        formatter.write_str("a field name for AttributeContext")
261                    }
262                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
263                    where
264                        E: serde::de::Error,
265                    {
266                        use std::result::Result::Ok;
267                        use std::string::ToString;
268                        match value {
269                            "origin" => Ok(__FieldTag::__origin),
270                            "source" => Ok(__FieldTag::__source),
271                            "destination" => Ok(__FieldTag::__destination),
272                            "request" => Ok(__FieldTag::__request),
273                            "response" => Ok(__FieldTag::__response),
274                            "resource" => Ok(__FieldTag::__resource),
275                            "api" => Ok(__FieldTag::__api),
276                            "extensions" => Ok(__FieldTag::__extensions),
277                            _ => Ok(__FieldTag::Unknown(value.to_string())),
278                        }
279                    }
280                }
281                deserializer.deserialize_identifier(Visitor)
282            }
283        }
284        struct Visitor;
285        impl<'de> serde::de::Visitor<'de> for Visitor {
286            type Value = AttributeContext;
287            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
288                formatter.write_str("struct AttributeContext")
289            }
290            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
291            where
292                A: serde::de::MapAccess<'de>,
293            {
294                #[allow(unused_imports)]
295                use serde::de::Error;
296                use std::option::Option::Some;
297                let mut fields = std::collections::HashSet::new();
298                let mut result = Self::Value::new();
299                while let Some(tag) = map.next_key::<__FieldTag>()? {
300                    #[allow(clippy::match_single_binding)]
301                    match tag {
302                        __FieldTag::__origin => {
303                            if !fields.insert(__FieldTag::__origin) {
304                                return std::result::Result::Err(A::Error::duplicate_field(
305                                    "multiple values for origin",
306                                ));
307                            }
308                            result.origin = map.next_value::<std::option::Option<crate::model::attribute_context::Peer>>()?
309                                ;
310                        }
311                        __FieldTag::__source => {
312                            if !fields.insert(__FieldTag::__source) {
313                                return std::result::Result::Err(A::Error::duplicate_field(
314                                    "multiple values for source",
315                                ));
316                            }
317                            result.source = map.next_value::<std::option::Option<crate::model::attribute_context::Peer>>()?
318                                ;
319                        }
320                        __FieldTag::__destination => {
321                            if !fields.insert(__FieldTag::__destination) {
322                                return std::result::Result::Err(A::Error::duplicate_field(
323                                    "multiple values for destination",
324                                ));
325                            }
326                            result.destination = map.next_value::<std::option::Option<crate::model::attribute_context::Peer>>()?
327                                ;
328                        }
329                        __FieldTag::__request => {
330                            if !fields.insert(__FieldTag::__request) {
331                                return std::result::Result::Err(A::Error::duplicate_field(
332                                    "multiple values for request",
333                                ));
334                            }
335                            result.request = map.next_value::<std::option::Option<crate::model::attribute_context::Request>>()?
336                                ;
337                        }
338                        __FieldTag::__response => {
339                            if !fields.insert(__FieldTag::__response) {
340                                return std::result::Result::Err(A::Error::duplicate_field(
341                                    "multiple values for response",
342                                ));
343                            }
344                            result.response = map.next_value::<std::option::Option<crate::model::attribute_context::Response>>()?
345                                ;
346                        }
347                        __FieldTag::__resource => {
348                            if !fields.insert(__FieldTag::__resource) {
349                                return std::result::Result::Err(A::Error::duplicate_field(
350                                    "multiple values for resource",
351                                ));
352                            }
353                            result.resource = map.next_value::<std::option::Option<crate::model::attribute_context::Resource>>()?
354                                ;
355                        }
356                        __FieldTag::__api => {
357                            if !fields.insert(__FieldTag::__api) {
358                                return std::result::Result::Err(A::Error::duplicate_field(
359                                    "multiple values for api",
360                                ));
361                            }
362                            result.api = map.next_value::<std::option::Option<crate::model::attribute_context::Api>>()?
363                                ;
364                        }
365                        __FieldTag::__extensions => {
366                            if !fields.insert(__FieldTag::__extensions) {
367                                return std::result::Result::Err(A::Error::duplicate_field(
368                                    "multiple values for extensions",
369                                ));
370                            }
371                            result.extensions = map
372                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
373                                .unwrap_or_default();
374                        }
375                        __FieldTag::Unknown(key) => {
376                            let value = map.next_value::<serde_json::Value>()?;
377                            result._unknown_fields.insert(key, value);
378                        }
379                    }
380                }
381                std::result::Result::Ok(result)
382            }
383        }
384        deserializer.deserialize_any(Visitor)
385    }
386}
387
388#[doc(hidden)]
389impl serde::ser::Serialize for AttributeContext {
390    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
391    where
392        S: serde::ser::Serializer,
393    {
394        use serde::ser::SerializeMap;
395        #[allow(unused_imports)]
396        use std::option::Option::Some;
397        let mut state = serializer.serialize_map(std::option::Option::None)?;
398        if self.origin.is_some() {
399            state.serialize_entry("origin", &self.origin)?;
400        }
401        if self.source.is_some() {
402            state.serialize_entry("source", &self.source)?;
403        }
404        if self.destination.is_some() {
405            state.serialize_entry("destination", &self.destination)?;
406        }
407        if self.request.is_some() {
408            state.serialize_entry("request", &self.request)?;
409        }
410        if self.response.is_some() {
411            state.serialize_entry("response", &self.response)?;
412        }
413        if self.resource.is_some() {
414            state.serialize_entry("resource", &self.resource)?;
415        }
416        if self.api.is_some() {
417            state.serialize_entry("api", &self.api)?;
418        }
419        if !self.extensions.is_empty() {
420            state.serialize_entry("extensions", &self.extensions)?;
421        }
422        if !self._unknown_fields.is_empty() {
423            for (key, value) in self._unknown_fields.iter() {
424                state.serialize_entry(key, &value)?;
425            }
426        }
427        state.end()
428    }
429}
430
431/// Defines additional types related to [AttributeContext].
432pub mod attribute_context {
433    #[allow(unused_imports)]
434    use super::*;
435
436    /// This message defines attributes for a node that handles a network request.
437    /// The node can be either a service or an application that sends, forwards,
438    /// or receives the request. Service peers should fill in
439    /// `principal` and `labels` as appropriate.
440    #[derive(Clone, Debug, Default, PartialEq)]
441    #[non_exhaustive]
442    pub struct Peer {
443        /// The IP address of the peer.
444        pub ip: std::string::String,
445
446        /// The network port of the peer.
447        pub port: i64,
448
449        /// The labels associated with the peer.
450        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
451
452        /// The identity of this peer. Similar to `Request.auth.principal`, but
453        /// relative to the peer instead of the request. For example, the
454        /// identity associated with a load balancer that forwarded the request.
455        pub principal: std::string::String,
456
457        /// The CLDR country/region code associated with the above IP address.
458        /// If the IP address is private, the `region_code` should reflect the
459        /// physical location where this peer is running.
460        pub region_code: std::string::String,
461
462        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
463    }
464
465    impl Peer {
466        pub fn new() -> Self {
467            std::default::Default::default()
468        }
469
470        /// Sets the value of [ip][crate::model::attribute_context::Peer::ip].
471        pub fn set_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
472            self.ip = v.into();
473            self
474        }
475
476        /// Sets the value of [port][crate::model::attribute_context::Peer::port].
477        pub fn set_port<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
478            self.port = v.into();
479            self
480        }
481
482        /// Sets the value of [labels][crate::model::attribute_context::Peer::labels].
483        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
484        where
485            T: std::iter::IntoIterator<Item = (K, V)>,
486            K: std::convert::Into<std::string::String>,
487            V: std::convert::Into<std::string::String>,
488        {
489            use std::iter::Iterator;
490            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
491            self
492        }
493
494        /// Sets the value of [principal][crate::model::attribute_context::Peer::principal].
495        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
496            self.principal = v.into();
497            self
498        }
499
500        /// Sets the value of [region_code][crate::model::attribute_context::Peer::region_code].
501        pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
502            self.region_code = v.into();
503            self
504        }
505    }
506
507    impl wkt::message::Message for Peer {
508        fn typename() -> &'static str {
509            "type.googleapis.com/google.rpc.context.AttributeContext.Peer"
510        }
511    }
512
513    #[doc(hidden)]
514    impl<'de> serde::de::Deserialize<'de> for Peer {
515        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
516        where
517            D: serde::Deserializer<'de>,
518        {
519            #[allow(non_camel_case_types)]
520            #[doc(hidden)]
521            #[derive(PartialEq, Eq, Hash)]
522            enum __FieldTag {
523                __ip,
524                __port,
525                __labels,
526                __principal,
527                __region_code,
528                Unknown(std::string::String),
529            }
530            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
531                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
532                where
533                    D: serde::Deserializer<'de>,
534                {
535                    struct Visitor;
536                    impl<'de> serde::de::Visitor<'de> for Visitor {
537                        type Value = __FieldTag;
538                        fn expecting(
539                            &self,
540                            formatter: &mut std::fmt::Formatter,
541                        ) -> std::fmt::Result {
542                            formatter.write_str("a field name for Peer")
543                        }
544                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
545                        where
546                            E: serde::de::Error,
547                        {
548                            use std::result::Result::Ok;
549                            use std::string::ToString;
550                            match value {
551                                "ip" => Ok(__FieldTag::__ip),
552                                "port" => Ok(__FieldTag::__port),
553                                "labels" => Ok(__FieldTag::__labels),
554                                "principal" => Ok(__FieldTag::__principal),
555                                "regionCode" => Ok(__FieldTag::__region_code),
556                                "region_code" => Ok(__FieldTag::__region_code),
557                                _ => Ok(__FieldTag::Unknown(value.to_string())),
558                            }
559                        }
560                    }
561                    deserializer.deserialize_identifier(Visitor)
562                }
563            }
564            struct Visitor;
565            impl<'de> serde::de::Visitor<'de> for Visitor {
566                type Value = Peer;
567                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
568                    formatter.write_str("struct Peer")
569                }
570                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
571                where
572                    A: serde::de::MapAccess<'de>,
573                {
574                    #[allow(unused_imports)]
575                    use serde::de::Error;
576                    use std::option::Option::Some;
577                    let mut fields = std::collections::HashSet::new();
578                    let mut result = Self::Value::new();
579                    while let Some(tag) = map.next_key::<__FieldTag>()? {
580                        #[allow(clippy::match_single_binding)]
581                        match tag {
582                            __FieldTag::__ip => {
583                                if !fields.insert(__FieldTag::__ip) {
584                                    return std::result::Result::Err(A::Error::duplicate_field(
585                                        "multiple values for ip",
586                                    ));
587                                }
588                                result.ip = map
589                                    .next_value::<std::option::Option<std::string::String>>()?
590                                    .unwrap_or_default();
591                            }
592                            __FieldTag::__port => {
593                                if !fields.insert(__FieldTag::__port) {
594                                    return std::result::Result::Err(A::Error::duplicate_field(
595                                        "multiple values for port",
596                                    ));
597                                }
598                                struct __With(std::option::Option<i64>);
599                                impl<'de> serde::de::Deserialize<'de> for __With {
600                                    fn deserialize<D>(
601                                        deserializer: D,
602                                    ) -> std::result::Result<Self, D::Error>
603                                    where
604                                        D: serde::de::Deserializer<'de>,
605                                    {
606                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
607                                    }
608                                }
609                                result.port = map.next_value::<__With>()?.0.unwrap_or_default();
610                            }
611                            __FieldTag::__labels => {
612                                if !fields.insert(__FieldTag::__labels) {
613                                    return std::result::Result::Err(A::Error::duplicate_field(
614                                        "multiple values for labels",
615                                    ));
616                                }
617                                result.labels = map
618                                    .next_value::<std::option::Option<
619                                        std::collections::HashMap<
620                                            std::string::String,
621                                            std::string::String,
622                                        >,
623                                    >>()?
624                                    .unwrap_or_default();
625                            }
626                            __FieldTag::__principal => {
627                                if !fields.insert(__FieldTag::__principal) {
628                                    return std::result::Result::Err(A::Error::duplicate_field(
629                                        "multiple values for principal",
630                                    ));
631                                }
632                                result.principal = map
633                                    .next_value::<std::option::Option<std::string::String>>()?
634                                    .unwrap_or_default();
635                            }
636                            __FieldTag::__region_code => {
637                                if !fields.insert(__FieldTag::__region_code) {
638                                    return std::result::Result::Err(A::Error::duplicate_field(
639                                        "multiple values for region_code",
640                                    ));
641                                }
642                                result.region_code = map
643                                    .next_value::<std::option::Option<std::string::String>>()?
644                                    .unwrap_or_default();
645                            }
646                            __FieldTag::Unknown(key) => {
647                                let value = map.next_value::<serde_json::Value>()?;
648                                result._unknown_fields.insert(key, value);
649                            }
650                        }
651                    }
652                    std::result::Result::Ok(result)
653                }
654            }
655            deserializer.deserialize_any(Visitor)
656        }
657    }
658
659    #[doc(hidden)]
660    impl serde::ser::Serialize for Peer {
661        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
662        where
663            S: serde::ser::Serializer,
664        {
665            use serde::ser::SerializeMap;
666            #[allow(unused_imports)]
667            use std::option::Option::Some;
668            let mut state = serializer.serialize_map(std::option::Option::None)?;
669            if !self.ip.is_empty() {
670                state.serialize_entry("ip", &self.ip)?;
671            }
672            if !wkt::internal::is_default(&self.port) {
673                struct __With<'a>(&'a i64);
674                impl<'a> serde::ser::Serialize for __With<'a> {
675                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
676                    where
677                        S: serde::ser::Serializer,
678                    {
679                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
680                    }
681                }
682                state.serialize_entry("port", &__With(&self.port))?;
683            }
684            if !self.labels.is_empty() {
685                state.serialize_entry("labels", &self.labels)?;
686            }
687            if !self.principal.is_empty() {
688                state.serialize_entry("principal", &self.principal)?;
689            }
690            if !self.region_code.is_empty() {
691                state.serialize_entry("regionCode", &self.region_code)?;
692            }
693            if !self._unknown_fields.is_empty() {
694                for (key, value) in self._unknown_fields.iter() {
695                    state.serialize_entry(key, &value)?;
696                }
697            }
698            state.end()
699        }
700    }
701
702    /// This message defines attributes associated with API operations, such as
703    /// a network API request. The terminology is based on the conventions used
704    /// by Google APIs, Istio, and OpenAPI.
705    #[derive(Clone, Debug, Default, PartialEq)]
706    #[non_exhaustive]
707    pub struct Api {
708        /// The API service name. It is a logical identifier for a networked API,
709        /// such as "pubsub.googleapis.com". The naming syntax depends on the
710        /// API management system being used for handling the request.
711        pub service: std::string::String,
712
713        /// The API operation name. For gRPC requests, it is the fully qualified API
714        /// method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI
715        /// requests, it is the `operationId`, such as "getPet".
716        pub operation: std::string::String,
717
718        /// The API protocol used for sending the request, such as "http", "https",
719        /// "grpc", or "internal".
720        pub protocol: std::string::String,
721
722        /// The API version associated with the API operation above, such as "v1" or
723        /// "v1alpha1".
724        pub version: std::string::String,
725
726        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
727    }
728
729    impl Api {
730        pub fn new() -> Self {
731            std::default::Default::default()
732        }
733
734        /// Sets the value of [service][crate::model::attribute_context::Api::service].
735        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
736            self.service = v.into();
737            self
738        }
739
740        /// Sets the value of [operation][crate::model::attribute_context::Api::operation].
741        pub fn set_operation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
742            self.operation = v.into();
743            self
744        }
745
746        /// Sets the value of [protocol][crate::model::attribute_context::Api::protocol].
747        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
748            self.protocol = v.into();
749            self
750        }
751
752        /// Sets the value of [version][crate::model::attribute_context::Api::version].
753        pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
754            self.version = v.into();
755            self
756        }
757    }
758
759    impl wkt::message::Message for Api {
760        fn typename() -> &'static str {
761            "type.googleapis.com/google.rpc.context.AttributeContext.Api"
762        }
763    }
764
765    #[doc(hidden)]
766    impl<'de> serde::de::Deserialize<'de> for Api {
767        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
768        where
769            D: serde::Deserializer<'de>,
770        {
771            #[allow(non_camel_case_types)]
772            #[doc(hidden)]
773            #[derive(PartialEq, Eq, Hash)]
774            enum __FieldTag {
775                __service,
776                __operation,
777                __protocol,
778                __version,
779                Unknown(std::string::String),
780            }
781            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
782                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
783                where
784                    D: serde::Deserializer<'de>,
785                {
786                    struct Visitor;
787                    impl<'de> serde::de::Visitor<'de> for Visitor {
788                        type Value = __FieldTag;
789                        fn expecting(
790                            &self,
791                            formatter: &mut std::fmt::Formatter,
792                        ) -> std::fmt::Result {
793                            formatter.write_str("a field name for Api")
794                        }
795                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
796                        where
797                            E: serde::de::Error,
798                        {
799                            use std::result::Result::Ok;
800                            use std::string::ToString;
801                            match value {
802                                "service" => Ok(__FieldTag::__service),
803                                "operation" => Ok(__FieldTag::__operation),
804                                "protocol" => Ok(__FieldTag::__protocol),
805                                "version" => Ok(__FieldTag::__version),
806                                _ => Ok(__FieldTag::Unknown(value.to_string())),
807                            }
808                        }
809                    }
810                    deserializer.deserialize_identifier(Visitor)
811                }
812            }
813            struct Visitor;
814            impl<'de> serde::de::Visitor<'de> for Visitor {
815                type Value = Api;
816                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
817                    formatter.write_str("struct Api")
818                }
819                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
820                where
821                    A: serde::de::MapAccess<'de>,
822                {
823                    #[allow(unused_imports)]
824                    use serde::de::Error;
825                    use std::option::Option::Some;
826                    let mut fields = std::collections::HashSet::new();
827                    let mut result = Self::Value::new();
828                    while let Some(tag) = map.next_key::<__FieldTag>()? {
829                        #[allow(clippy::match_single_binding)]
830                        match tag {
831                            __FieldTag::__service => {
832                                if !fields.insert(__FieldTag::__service) {
833                                    return std::result::Result::Err(A::Error::duplicate_field(
834                                        "multiple values for service",
835                                    ));
836                                }
837                                result.service = map
838                                    .next_value::<std::option::Option<std::string::String>>()?
839                                    .unwrap_or_default();
840                            }
841                            __FieldTag::__operation => {
842                                if !fields.insert(__FieldTag::__operation) {
843                                    return std::result::Result::Err(A::Error::duplicate_field(
844                                        "multiple values for operation",
845                                    ));
846                                }
847                                result.operation = map
848                                    .next_value::<std::option::Option<std::string::String>>()?
849                                    .unwrap_or_default();
850                            }
851                            __FieldTag::__protocol => {
852                                if !fields.insert(__FieldTag::__protocol) {
853                                    return std::result::Result::Err(A::Error::duplicate_field(
854                                        "multiple values for protocol",
855                                    ));
856                                }
857                                result.protocol = map
858                                    .next_value::<std::option::Option<std::string::String>>()?
859                                    .unwrap_or_default();
860                            }
861                            __FieldTag::__version => {
862                                if !fields.insert(__FieldTag::__version) {
863                                    return std::result::Result::Err(A::Error::duplicate_field(
864                                        "multiple values for version",
865                                    ));
866                                }
867                                result.version = map
868                                    .next_value::<std::option::Option<std::string::String>>()?
869                                    .unwrap_or_default();
870                            }
871                            __FieldTag::Unknown(key) => {
872                                let value = map.next_value::<serde_json::Value>()?;
873                                result._unknown_fields.insert(key, value);
874                            }
875                        }
876                    }
877                    std::result::Result::Ok(result)
878                }
879            }
880            deserializer.deserialize_any(Visitor)
881        }
882    }
883
884    #[doc(hidden)]
885    impl serde::ser::Serialize for Api {
886        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
887        where
888            S: serde::ser::Serializer,
889        {
890            use serde::ser::SerializeMap;
891            #[allow(unused_imports)]
892            use std::option::Option::Some;
893            let mut state = serializer.serialize_map(std::option::Option::None)?;
894            if !self.service.is_empty() {
895                state.serialize_entry("service", &self.service)?;
896            }
897            if !self.operation.is_empty() {
898                state.serialize_entry("operation", &self.operation)?;
899            }
900            if !self.protocol.is_empty() {
901                state.serialize_entry("protocol", &self.protocol)?;
902            }
903            if !self.version.is_empty() {
904                state.serialize_entry("version", &self.version)?;
905            }
906            if !self._unknown_fields.is_empty() {
907                for (key, value) in self._unknown_fields.iter() {
908                    state.serialize_entry(key, &value)?;
909                }
910            }
911            state.end()
912        }
913    }
914
915    /// This message defines request authentication attributes. Terminology is
916    /// based on the JSON Web Token (JWT) standard, but the terms also
917    /// correlate to concepts in other standards.
918    #[derive(Clone, Debug, Default, PartialEq)]
919    #[non_exhaustive]
920    pub struct Auth {
921        /// The authenticated principal. Reflects the issuer (`iss`) and subject
922        /// (`sub`) claims within a JWT. The issuer and subject should be `/`
923        /// delimited, with `/` percent-encoded within the subject fragment. For
924        /// Google accounts, the principal format is:
925        /// `https://accounts.google.com/{id}`
926        pub principal: std::string::String,
927
928        /// The intended audience(s) for this authentication information. Reflects
929        /// the audience (`aud`) claim within a JWT. The audience
930        /// value(s) depends on the `issuer`, but typically include one or more of
931        /// the following pieces of information:
932        ///
933        /// * The services intended to receive the credential. For example,
934        ///   [`https://pubsub.googleapis.com/`, `https://storage.googleapis.com/`].
935        /// * A set of service-based scopes. For example,
936        ///   [`https://www.googleapis.com/auth/cloud-platform`].
937        /// * The client id of an app, such as the Firebase project id for JWTs
938        ///   from Firebase Auth.
939        ///
940        /// Consult the documentation for the credential issuer to determine the
941        /// information provided.
942        pub audiences: std::vec::Vec<std::string::String>,
943
944        /// The authorized presenter of the credential. Reflects the optional
945        /// Authorized Presenter (`azp`) claim within a JWT or the
946        /// OAuth client id. For example, a Google Cloud Platform client id looks
947        /// as follows: "123456789012.apps.googleusercontent.com".
948        pub presenter: std::string::String,
949
950        /// Structured claims presented with the credential. JWTs include
951        /// `{key: value}` pairs for standard and private claims. The following
952        /// is a subset of the standard required and optional claims that would
953        /// typically be presented for a Google-based JWT:
954        ///
955        /// {'iss': 'accounts.google.com',
956        /// 'sub': '113289723416554971153',
957        /// 'aud': ['123456789012', 'pubsub.googleapis.com'],
958        /// 'azp': '123456789012.apps.googleusercontent.com',
959        /// 'email': 'jsmith@example.com',
960        /// 'iat': 1353601026,
961        /// 'exp': 1353604926}
962        ///
963        /// SAML assertions are similarly specified, but with an identity provider
964        /// dependent structure.
965        pub claims: std::option::Option<wkt::Struct>,
966
967        /// A list of access level resource names that allow resources to be
968        /// accessed by authenticated requester. It is part of Secure GCP processing
969        /// for the incoming request. An access level string has the format:
970        /// "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}"
971        ///
972        /// Example:
973        /// "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL"
974        pub access_levels: std::vec::Vec<std::string::String>,
975
976        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
977    }
978
979    impl Auth {
980        pub fn new() -> Self {
981            std::default::Default::default()
982        }
983
984        /// Sets the value of [principal][crate::model::attribute_context::Auth::principal].
985        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
986            self.principal = v.into();
987            self
988        }
989
990        /// Sets the value of [audiences][crate::model::attribute_context::Auth::audiences].
991        pub fn set_audiences<T, V>(mut self, v: T) -> Self
992        where
993            T: std::iter::IntoIterator<Item = V>,
994            V: std::convert::Into<std::string::String>,
995        {
996            use std::iter::Iterator;
997            self.audiences = v.into_iter().map(|i| i.into()).collect();
998            self
999        }
1000
1001        /// Sets the value of [presenter][crate::model::attribute_context::Auth::presenter].
1002        pub fn set_presenter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1003            self.presenter = v.into();
1004            self
1005        }
1006
1007        /// Sets the value of [claims][crate::model::attribute_context::Auth::claims].
1008        pub fn set_claims<T>(mut self, v: T) -> Self
1009        where
1010            T: std::convert::Into<wkt::Struct>,
1011        {
1012            self.claims = std::option::Option::Some(v.into());
1013            self
1014        }
1015
1016        /// Sets or clears the value of [claims][crate::model::attribute_context::Auth::claims].
1017        pub fn set_or_clear_claims<T>(mut self, v: std::option::Option<T>) -> Self
1018        where
1019            T: std::convert::Into<wkt::Struct>,
1020        {
1021            self.claims = v.map(|x| x.into());
1022            self
1023        }
1024
1025        /// Sets the value of [access_levels][crate::model::attribute_context::Auth::access_levels].
1026        pub fn set_access_levels<T, V>(mut self, v: T) -> Self
1027        where
1028            T: std::iter::IntoIterator<Item = V>,
1029            V: std::convert::Into<std::string::String>,
1030        {
1031            use std::iter::Iterator;
1032            self.access_levels = v.into_iter().map(|i| i.into()).collect();
1033            self
1034        }
1035    }
1036
1037    impl wkt::message::Message for Auth {
1038        fn typename() -> &'static str {
1039            "type.googleapis.com/google.rpc.context.AttributeContext.Auth"
1040        }
1041    }
1042
1043    #[doc(hidden)]
1044    impl<'de> serde::de::Deserialize<'de> for Auth {
1045        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1046        where
1047            D: serde::Deserializer<'de>,
1048        {
1049            #[allow(non_camel_case_types)]
1050            #[doc(hidden)]
1051            #[derive(PartialEq, Eq, Hash)]
1052            enum __FieldTag {
1053                __principal,
1054                __audiences,
1055                __presenter,
1056                __claims,
1057                __access_levels,
1058                Unknown(std::string::String),
1059            }
1060            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1061                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1062                where
1063                    D: serde::Deserializer<'de>,
1064                {
1065                    struct Visitor;
1066                    impl<'de> serde::de::Visitor<'de> for Visitor {
1067                        type Value = __FieldTag;
1068                        fn expecting(
1069                            &self,
1070                            formatter: &mut std::fmt::Formatter,
1071                        ) -> std::fmt::Result {
1072                            formatter.write_str("a field name for Auth")
1073                        }
1074                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1075                        where
1076                            E: serde::de::Error,
1077                        {
1078                            use std::result::Result::Ok;
1079                            use std::string::ToString;
1080                            match value {
1081                                "principal" => Ok(__FieldTag::__principal),
1082                                "audiences" => Ok(__FieldTag::__audiences),
1083                                "presenter" => Ok(__FieldTag::__presenter),
1084                                "claims" => Ok(__FieldTag::__claims),
1085                                "accessLevels" => Ok(__FieldTag::__access_levels),
1086                                "access_levels" => Ok(__FieldTag::__access_levels),
1087                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1088                            }
1089                        }
1090                    }
1091                    deserializer.deserialize_identifier(Visitor)
1092                }
1093            }
1094            struct Visitor;
1095            impl<'de> serde::de::Visitor<'de> for Visitor {
1096                type Value = Auth;
1097                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1098                    formatter.write_str("struct Auth")
1099                }
1100                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1101                where
1102                    A: serde::de::MapAccess<'de>,
1103                {
1104                    #[allow(unused_imports)]
1105                    use serde::de::Error;
1106                    use std::option::Option::Some;
1107                    let mut fields = std::collections::HashSet::new();
1108                    let mut result = Self::Value::new();
1109                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1110                        #[allow(clippy::match_single_binding)]
1111                        match tag {
1112                            __FieldTag::__principal => {
1113                                if !fields.insert(__FieldTag::__principal) {
1114                                    return std::result::Result::Err(A::Error::duplicate_field(
1115                                        "multiple values for principal",
1116                                    ));
1117                                }
1118                                result.principal = map
1119                                    .next_value::<std::option::Option<std::string::String>>()?
1120                                    .unwrap_or_default();
1121                            }
1122                            __FieldTag::__audiences => {
1123                                if !fields.insert(__FieldTag::__audiences) {
1124                                    return std::result::Result::Err(A::Error::duplicate_field(
1125                                        "multiple values for audiences",
1126                                    ));
1127                                }
1128                                result.audiences = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
1129                            }
1130                            __FieldTag::__presenter => {
1131                                if !fields.insert(__FieldTag::__presenter) {
1132                                    return std::result::Result::Err(A::Error::duplicate_field(
1133                                        "multiple values for presenter",
1134                                    ));
1135                                }
1136                                result.presenter = map
1137                                    .next_value::<std::option::Option<std::string::String>>()?
1138                                    .unwrap_or_default();
1139                            }
1140                            __FieldTag::__claims => {
1141                                if !fields.insert(__FieldTag::__claims) {
1142                                    return std::result::Result::Err(A::Error::duplicate_field(
1143                                        "multiple values for claims",
1144                                    ));
1145                                }
1146                                result.claims =
1147                                    map.next_value::<std::option::Option<wkt::Struct>>()?;
1148                            }
1149                            __FieldTag::__access_levels => {
1150                                if !fields.insert(__FieldTag::__access_levels) {
1151                                    return std::result::Result::Err(A::Error::duplicate_field(
1152                                        "multiple values for access_levels",
1153                                    ));
1154                                }
1155                                result.access_levels = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
1156                            }
1157                            __FieldTag::Unknown(key) => {
1158                                let value = map.next_value::<serde_json::Value>()?;
1159                                result._unknown_fields.insert(key, value);
1160                            }
1161                        }
1162                    }
1163                    std::result::Result::Ok(result)
1164                }
1165            }
1166            deserializer.deserialize_any(Visitor)
1167        }
1168    }
1169
1170    #[doc(hidden)]
1171    impl serde::ser::Serialize for Auth {
1172        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1173        where
1174            S: serde::ser::Serializer,
1175        {
1176            use serde::ser::SerializeMap;
1177            #[allow(unused_imports)]
1178            use std::option::Option::Some;
1179            let mut state = serializer.serialize_map(std::option::Option::None)?;
1180            if !self.principal.is_empty() {
1181                state.serialize_entry("principal", &self.principal)?;
1182            }
1183            if !self.audiences.is_empty() {
1184                state.serialize_entry("audiences", &self.audiences)?;
1185            }
1186            if !self.presenter.is_empty() {
1187                state.serialize_entry("presenter", &self.presenter)?;
1188            }
1189            if self.claims.is_some() {
1190                state.serialize_entry("claims", &self.claims)?;
1191            }
1192            if !self.access_levels.is_empty() {
1193                state.serialize_entry("accessLevels", &self.access_levels)?;
1194            }
1195            if !self._unknown_fields.is_empty() {
1196                for (key, value) in self._unknown_fields.iter() {
1197                    state.serialize_entry(key, &value)?;
1198                }
1199            }
1200            state.end()
1201        }
1202    }
1203
1204    /// This message defines attributes for an HTTP request. If the actual
1205    /// request is not an HTTP request, the runtime system should try to map
1206    /// the actual request to an equivalent HTTP request.
1207    #[derive(Clone, Debug, Default, PartialEq)]
1208    #[non_exhaustive]
1209    pub struct Request {
1210        /// The unique ID for a request, which can be propagated to downstream
1211        /// systems. The ID should have low probability of collision
1212        /// within a single day for a specific service.
1213        pub id: std::string::String,
1214
1215        /// The HTTP request method, such as `GET`, `POST`.
1216        pub method: std::string::String,
1217
1218        /// The HTTP request headers. If multiple headers share the same key, they
1219        /// must be merged according to the HTTP spec. All header keys must be
1220        /// lowercased, because HTTP header keys are case-insensitive.
1221        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
1222
1223        /// The HTTP URL path, excluding the query parameters.
1224        pub path: std::string::String,
1225
1226        /// The HTTP request `Host` header value.
1227        pub host: std::string::String,
1228
1229        /// The HTTP URL scheme, such as `http` and `https`.
1230        pub scheme: std::string::String,
1231
1232        /// The HTTP URL query in the format of `name1=value1&name2=value2`, as it
1233        /// appears in the first line of the HTTP request. No decoding is performed.
1234        pub query: std::string::String,
1235
1236        /// The timestamp when the `destination` service receives the last byte of
1237        /// the request.
1238        pub time: std::option::Option<wkt::Timestamp>,
1239
1240        /// The HTTP request size in bytes. If unknown, it must be -1.
1241        pub size: i64,
1242
1243        /// The network protocol used with the request, such as "http/1.1",
1244        /// "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See
1245        /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
1246        /// for details.
1247        pub protocol: std::string::String,
1248
1249        /// A special parameter for request reason. It is used by security systems
1250        /// to associate auditing information with a request.
1251        pub reason: std::string::String,
1252
1253        /// The request authentication. May be absent for unauthenticated requests.
1254        /// Derived from the HTTP request `Authorization` header or equivalent.
1255        pub auth: std::option::Option<crate::model::attribute_context::Auth>,
1256
1257        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1258    }
1259
1260    impl Request {
1261        pub fn new() -> Self {
1262            std::default::Default::default()
1263        }
1264
1265        /// Sets the value of [id][crate::model::attribute_context::Request::id].
1266        pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1267            self.id = v.into();
1268            self
1269        }
1270
1271        /// Sets the value of [method][crate::model::attribute_context::Request::method].
1272        pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1273            self.method = v.into();
1274            self
1275        }
1276
1277        /// Sets the value of [headers][crate::model::attribute_context::Request::headers].
1278        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
1279        where
1280            T: std::iter::IntoIterator<Item = (K, V)>,
1281            K: std::convert::Into<std::string::String>,
1282            V: std::convert::Into<std::string::String>,
1283        {
1284            use std::iter::Iterator;
1285            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1286            self
1287        }
1288
1289        /// Sets the value of [path][crate::model::attribute_context::Request::path].
1290        pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1291            self.path = v.into();
1292            self
1293        }
1294
1295        /// Sets the value of [host][crate::model::attribute_context::Request::host].
1296        pub fn set_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1297            self.host = v.into();
1298            self
1299        }
1300
1301        /// Sets the value of [scheme][crate::model::attribute_context::Request::scheme].
1302        pub fn set_scheme<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1303            self.scheme = v.into();
1304            self
1305        }
1306
1307        /// Sets the value of [query][crate::model::attribute_context::Request::query].
1308        pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1309            self.query = v.into();
1310            self
1311        }
1312
1313        /// Sets the value of [time][crate::model::attribute_context::Request::time].
1314        pub fn set_time<T>(mut self, v: T) -> Self
1315        where
1316            T: std::convert::Into<wkt::Timestamp>,
1317        {
1318            self.time = std::option::Option::Some(v.into());
1319            self
1320        }
1321
1322        /// Sets or clears the value of [time][crate::model::attribute_context::Request::time].
1323        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
1324        where
1325            T: std::convert::Into<wkt::Timestamp>,
1326        {
1327            self.time = v.map(|x| x.into());
1328            self
1329        }
1330
1331        /// Sets the value of [size][crate::model::attribute_context::Request::size].
1332        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1333            self.size = v.into();
1334            self
1335        }
1336
1337        /// Sets the value of [protocol][crate::model::attribute_context::Request::protocol].
1338        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1339            self.protocol = v.into();
1340            self
1341        }
1342
1343        /// Sets the value of [reason][crate::model::attribute_context::Request::reason].
1344        pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1345            self.reason = v.into();
1346            self
1347        }
1348
1349        /// Sets the value of [auth][crate::model::attribute_context::Request::auth].
1350        pub fn set_auth<T>(mut self, v: T) -> Self
1351        where
1352            T: std::convert::Into<crate::model::attribute_context::Auth>,
1353        {
1354            self.auth = std::option::Option::Some(v.into());
1355            self
1356        }
1357
1358        /// Sets or clears the value of [auth][crate::model::attribute_context::Request::auth].
1359        pub fn set_or_clear_auth<T>(mut self, v: std::option::Option<T>) -> Self
1360        where
1361            T: std::convert::Into<crate::model::attribute_context::Auth>,
1362        {
1363            self.auth = v.map(|x| x.into());
1364            self
1365        }
1366    }
1367
1368    impl wkt::message::Message for Request {
1369        fn typename() -> &'static str {
1370            "type.googleapis.com/google.rpc.context.AttributeContext.Request"
1371        }
1372    }
1373
1374    #[doc(hidden)]
1375    impl<'de> serde::de::Deserialize<'de> for Request {
1376        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1377        where
1378            D: serde::Deserializer<'de>,
1379        {
1380            #[allow(non_camel_case_types)]
1381            #[doc(hidden)]
1382            #[derive(PartialEq, Eq, Hash)]
1383            enum __FieldTag {
1384                __id,
1385                __method,
1386                __headers,
1387                __path,
1388                __host,
1389                __scheme,
1390                __query,
1391                __time,
1392                __size,
1393                __protocol,
1394                __reason,
1395                __auth,
1396                Unknown(std::string::String),
1397            }
1398            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1399                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1400                where
1401                    D: serde::Deserializer<'de>,
1402                {
1403                    struct Visitor;
1404                    impl<'de> serde::de::Visitor<'de> for Visitor {
1405                        type Value = __FieldTag;
1406                        fn expecting(
1407                            &self,
1408                            formatter: &mut std::fmt::Formatter,
1409                        ) -> std::fmt::Result {
1410                            formatter.write_str("a field name for Request")
1411                        }
1412                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1413                        where
1414                            E: serde::de::Error,
1415                        {
1416                            use std::result::Result::Ok;
1417                            use std::string::ToString;
1418                            match value {
1419                                "id" => Ok(__FieldTag::__id),
1420                                "method" => Ok(__FieldTag::__method),
1421                                "headers" => Ok(__FieldTag::__headers),
1422                                "path" => Ok(__FieldTag::__path),
1423                                "host" => Ok(__FieldTag::__host),
1424                                "scheme" => Ok(__FieldTag::__scheme),
1425                                "query" => Ok(__FieldTag::__query),
1426                                "time" => Ok(__FieldTag::__time),
1427                                "size" => Ok(__FieldTag::__size),
1428                                "protocol" => Ok(__FieldTag::__protocol),
1429                                "reason" => Ok(__FieldTag::__reason),
1430                                "auth" => Ok(__FieldTag::__auth),
1431                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1432                            }
1433                        }
1434                    }
1435                    deserializer.deserialize_identifier(Visitor)
1436                }
1437            }
1438            struct Visitor;
1439            impl<'de> serde::de::Visitor<'de> for Visitor {
1440                type Value = Request;
1441                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1442                    formatter.write_str("struct Request")
1443                }
1444                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1445                where
1446                    A: serde::de::MapAccess<'de>,
1447                {
1448                    #[allow(unused_imports)]
1449                    use serde::de::Error;
1450                    use std::option::Option::Some;
1451                    let mut fields = std::collections::HashSet::new();
1452                    let mut result = Self::Value::new();
1453                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1454                        #[allow(clippy::match_single_binding)]
1455                        match tag {
1456                            __FieldTag::__id => {
1457                                if !fields.insert(__FieldTag::__id) {
1458                                    return std::result::Result::Err(A::Error::duplicate_field(
1459                                        "multiple values for id",
1460                                    ));
1461                                }
1462                                result.id = map
1463                                    .next_value::<std::option::Option<std::string::String>>()?
1464                                    .unwrap_or_default();
1465                            }
1466                            __FieldTag::__method => {
1467                                if !fields.insert(__FieldTag::__method) {
1468                                    return std::result::Result::Err(A::Error::duplicate_field(
1469                                        "multiple values for method",
1470                                    ));
1471                                }
1472                                result.method = map
1473                                    .next_value::<std::option::Option<std::string::String>>()?
1474                                    .unwrap_or_default();
1475                            }
1476                            __FieldTag::__headers => {
1477                                if !fields.insert(__FieldTag::__headers) {
1478                                    return std::result::Result::Err(A::Error::duplicate_field(
1479                                        "multiple values for headers",
1480                                    ));
1481                                }
1482                                result.headers = map
1483                                    .next_value::<std::option::Option<
1484                                        std::collections::HashMap<
1485                                            std::string::String,
1486                                            std::string::String,
1487                                        >,
1488                                    >>()?
1489                                    .unwrap_or_default();
1490                            }
1491                            __FieldTag::__path => {
1492                                if !fields.insert(__FieldTag::__path) {
1493                                    return std::result::Result::Err(A::Error::duplicate_field(
1494                                        "multiple values for path",
1495                                    ));
1496                                }
1497                                result.path = map
1498                                    .next_value::<std::option::Option<std::string::String>>()?
1499                                    .unwrap_or_default();
1500                            }
1501                            __FieldTag::__host => {
1502                                if !fields.insert(__FieldTag::__host) {
1503                                    return std::result::Result::Err(A::Error::duplicate_field(
1504                                        "multiple values for host",
1505                                    ));
1506                                }
1507                                result.host = map
1508                                    .next_value::<std::option::Option<std::string::String>>()?
1509                                    .unwrap_or_default();
1510                            }
1511                            __FieldTag::__scheme => {
1512                                if !fields.insert(__FieldTag::__scheme) {
1513                                    return std::result::Result::Err(A::Error::duplicate_field(
1514                                        "multiple values for scheme",
1515                                    ));
1516                                }
1517                                result.scheme = map
1518                                    .next_value::<std::option::Option<std::string::String>>()?
1519                                    .unwrap_or_default();
1520                            }
1521                            __FieldTag::__query => {
1522                                if !fields.insert(__FieldTag::__query) {
1523                                    return std::result::Result::Err(A::Error::duplicate_field(
1524                                        "multiple values for query",
1525                                    ));
1526                                }
1527                                result.query = map
1528                                    .next_value::<std::option::Option<std::string::String>>()?
1529                                    .unwrap_or_default();
1530                            }
1531                            __FieldTag::__time => {
1532                                if !fields.insert(__FieldTag::__time) {
1533                                    return std::result::Result::Err(A::Error::duplicate_field(
1534                                        "multiple values for time",
1535                                    ));
1536                                }
1537                                result.time =
1538                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
1539                            }
1540                            __FieldTag::__size => {
1541                                if !fields.insert(__FieldTag::__size) {
1542                                    return std::result::Result::Err(A::Error::duplicate_field(
1543                                        "multiple values for size",
1544                                    ));
1545                                }
1546                                struct __With(std::option::Option<i64>);
1547                                impl<'de> serde::de::Deserialize<'de> for __With {
1548                                    fn deserialize<D>(
1549                                        deserializer: D,
1550                                    ) -> std::result::Result<Self, D::Error>
1551                                    where
1552                                        D: serde::de::Deserializer<'de>,
1553                                    {
1554                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1555                                    }
1556                                }
1557                                result.size = map.next_value::<__With>()?.0.unwrap_or_default();
1558                            }
1559                            __FieldTag::__protocol => {
1560                                if !fields.insert(__FieldTag::__protocol) {
1561                                    return std::result::Result::Err(A::Error::duplicate_field(
1562                                        "multiple values for protocol",
1563                                    ));
1564                                }
1565                                result.protocol = map
1566                                    .next_value::<std::option::Option<std::string::String>>()?
1567                                    .unwrap_or_default();
1568                            }
1569                            __FieldTag::__reason => {
1570                                if !fields.insert(__FieldTag::__reason) {
1571                                    return std::result::Result::Err(A::Error::duplicate_field(
1572                                        "multiple values for reason",
1573                                    ));
1574                                }
1575                                result.reason = map
1576                                    .next_value::<std::option::Option<std::string::String>>()?
1577                                    .unwrap_or_default();
1578                            }
1579                            __FieldTag::__auth => {
1580                                if !fields.insert(__FieldTag::__auth) {
1581                                    return std::result::Result::Err(A::Error::duplicate_field(
1582                                        "multiple values for auth",
1583                                    ));
1584                                }
1585                                result.auth = map.next_value::<std::option::Option<crate::model::attribute_context::Auth>>()?
1586                                    ;
1587                            }
1588                            __FieldTag::Unknown(key) => {
1589                                let value = map.next_value::<serde_json::Value>()?;
1590                                result._unknown_fields.insert(key, value);
1591                            }
1592                        }
1593                    }
1594                    std::result::Result::Ok(result)
1595                }
1596            }
1597            deserializer.deserialize_any(Visitor)
1598        }
1599    }
1600
1601    #[doc(hidden)]
1602    impl serde::ser::Serialize for Request {
1603        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1604        where
1605            S: serde::ser::Serializer,
1606        {
1607            use serde::ser::SerializeMap;
1608            #[allow(unused_imports)]
1609            use std::option::Option::Some;
1610            let mut state = serializer.serialize_map(std::option::Option::None)?;
1611            if !self.id.is_empty() {
1612                state.serialize_entry("id", &self.id)?;
1613            }
1614            if !self.method.is_empty() {
1615                state.serialize_entry("method", &self.method)?;
1616            }
1617            if !self.headers.is_empty() {
1618                state.serialize_entry("headers", &self.headers)?;
1619            }
1620            if !self.path.is_empty() {
1621                state.serialize_entry("path", &self.path)?;
1622            }
1623            if !self.host.is_empty() {
1624                state.serialize_entry("host", &self.host)?;
1625            }
1626            if !self.scheme.is_empty() {
1627                state.serialize_entry("scheme", &self.scheme)?;
1628            }
1629            if !self.query.is_empty() {
1630                state.serialize_entry("query", &self.query)?;
1631            }
1632            if self.time.is_some() {
1633                state.serialize_entry("time", &self.time)?;
1634            }
1635            if !wkt::internal::is_default(&self.size) {
1636                struct __With<'a>(&'a i64);
1637                impl<'a> serde::ser::Serialize for __With<'a> {
1638                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1639                    where
1640                        S: serde::ser::Serializer,
1641                    {
1642                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1643                    }
1644                }
1645                state.serialize_entry("size", &__With(&self.size))?;
1646            }
1647            if !self.protocol.is_empty() {
1648                state.serialize_entry("protocol", &self.protocol)?;
1649            }
1650            if !self.reason.is_empty() {
1651                state.serialize_entry("reason", &self.reason)?;
1652            }
1653            if self.auth.is_some() {
1654                state.serialize_entry("auth", &self.auth)?;
1655            }
1656            if !self._unknown_fields.is_empty() {
1657                for (key, value) in self._unknown_fields.iter() {
1658                    state.serialize_entry(key, &value)?;
1659                }
1660            }
1661            state.end()
1662        }
1663    }
1664
1665    /// This message defines attributes for a typical network response. It
1666    /// generally models semantics of an HTTP response.
1667    #[derive(Clone, Debug, Default, PartialEq)]
1668    #[non_exhaustive]
1669    pub struct Response {
1670        /// The HTTP response status code, such as `200` and `404`.
1671        pub code: i64,
1672
1673        /// The HTTP response size in bytes. If unknown, it must be -1.
1674        pub size: i64,
1675
1676        /// The HTTP response headers. If multiple headers share the same key, they
1677        /// must be merged according to HTTP spec. All header keys must be
1678        /// lowercased, because HTTP header keys are case-insensitive.
1679        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
1680
1681        /// The timestamp when the `destination` service sends the last byte of
1682        /// the response.
1683        pub time: std::option::Option<wkt::Timestamp>,
1684
1685        /// The amount of time it takes the backend service to fully respond to a
1686        /// request. Measured from when the destination service starts to send the
1687        /// request to the backend until when the destination service receives the
1688        /// complete response from the backend.
1689        pub backend_latency: std::option::Option<wkt::Duration>,
1690
1691        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1692    }
1693
1694    impl Response {
1695        pub fn new() -> Self {
1696            std::default::Default::default()
1697        }
1698
1699        /// Sets the value of [code][crate::model::attribute_context::Response::code].
1700        pub fn set_code<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1701            self.code = v.into();
1702            self
1703        }
1704
1705        /// Sets the value of [size][crate::model::attribute_context::Response::size].
1706        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1707            self.size = v.into();
1708            self
1709        }
1710
1711        /// Sets the value of [headers][crate::model::attribute_context::Response::headers].
1712        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
1713        where
1714            T: std::iter::IntoIterator<Item = (K, V)>,
1715            K: std::convert::Into<std::string::String>,
1716            V: std::convert::Into<std::string::String>,
1717        {
1718            use std::iter::Iterator;
1719            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1720            self
1721        }
1722
1723        /// Sets the value of [time][crate::model::attribute_context::Response::time].
1724        pub fn set_time<T>(mut self, v: T) -> Self
1725        where
1726            T: std::convert::Into<wkt::Timestamp>,
1727        {
1728            self.time = std::option::Option::Some(v.into());
1729            self
1730        }
1731
1732        /// Sets or clears the value of [time][crate::model::attribute_context::Response::time].
1733        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
1734        where
1735            T: std::convert::Into<wkt::Timestamp>,
1736        {
1737            self.time = v.map(|x| x.into());
1738            self
1739        }
1740
1741        /// Sets the value of [backend_latency][crate::model::attribute_context::Response::backend_latency].
1742        pub fn set_backend_latency<T>(mut self, v: T) -> Self
1743        where
1744            T: std::convert::Into<wkt::Duration>,
1745        {
1746            self.backend_latency = std::option::Option::Some(v.into());
1747            self
1748        }
1749
1750        /// Sets or clears the value of [backend_latency][crate::model::attribute_context::Response::backend_latency].
1751        pub fn set_or_clear_backend_latency<T>(mut self, v: std::option::Option<T>) -> Self
1752        where
1753            T: std::convert::Into<wkt::Duration>,
1754        {
1755            self.backend_latency = v.map(|x| x.into());
1756            self
1757        }
1758    }
1759
1760    impl wkt::message::Message for Response {
1761        fn typename() -> &'static str {
1762            "type.googleapis.com/google.rpc.context.AttributeContext.Response"
1763        }
1764    }
1765
1766    #[doc(hidden)]
1767    impl<'de> serde::de::Deserialize<'de> for Response {
1768        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1769        where
1770            D: serde::Deserializer<'de>,
1771        {
1772            #[allow(non_camel_case_types)]
1773            #[doc(hidden)]
1774            #[derive(PartialEq, Eq, Hash)]
1775            enum __FieldTag {
1776                __code,
1777                __size,
1778                __headers,
1779                __time,
1780                __backend_latency,
1781                Unknown(std::string::String),
1782            }
1783            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1784                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1785                where
1786                    D: serde::Deserializer<'de>,
1787                {
1788                    struct Visitor;
1789                    impl<'de> serde::de::Visitor<'de> for Visitor {
1790                        type Value = __FieldTag;
1791                        fn expecting(
1792                            &self,
1793                            formatter: &mut std::fmt::Formatter,
1794                        ) -> std::fmt::Result {
1795                            formatter.write_str("a field name for Response")
1796                        }
1797                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1798                        where
1799                            E: serde::de::Error,
1800                        {
1801                            use std::result::Result::Ok;
1802                            use std::string::ToString;
1803                            match value {
1804                                "code" => Ok(__FieldTag::__code),
1805                                "size" => Ok(__FieldTag::__size),
1806                                "headers" => Ok(__FieldTag::__headers),
1807                                "time" => Ok(__FieldTag::__time),
1808                                "backendLatency" => Ok(__FieldTag::__backend_latency),
1809                                "backend_latency" => Ok(__FieldTag::__backend_latency),
1810                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1811                            }
1812                        }
1813                    }
1814                    deserializer.deserialize_identifier(Visitor)
1815                }
1816            }
1817            struct Visitor;
1818            impl<'de> serde::de::Visitor<'de> for Visitor {
1819                type Value = Response;
1820                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1821                    formatter.write_str("struct Response")
1822                }
1823                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1824                where
1825                    A: serde::de::MapAccess<'de>,
1826                {
1827                    #[allow(unused_imports)]
1828                    use serde::de::Error;
1829                    use std::option::Option::Some;
1830                    let mut fields = std::collections::HashSet::new();
1831                    let mut result = Self::Value::new();
1832                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1833                        #[allow(clippy::match_single_binding)]
1834                        match tag {
1835                            __FieldTag::__code => {
1836                                if !fields.insert(__FieldTag::__code) {
1837                                    return std::result::Result::Err(A::Error::duplicate_field(
1838                                        "multiple values for code",
1839                                    ));
1840                                }
1841                                struct __With(std::option::Option<i64>);
1842                                impl<'de> serde::de::Deserialize<'de> for __With {
1843                                    fn deserialize<D>(
1844                                        deserializer: D,
1845                                    ) -> std::result::Result<Self, D::Error>
1846                                    where
1847                                        D: serde::de::Deserializer<'de>,
1848                                    {
1849                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1850                                    }
1851                                }
1852                                result.code = map.next_value::<__With>()?.0.unwrap_or_default();
1853                            }
1854                            __FieldTag::__size => {
1855                                if !fields.insert(__FieldTag::__size) {
1856                                    return std::result::Result::Err(A::Error::duplicate_field(
1857                                        "multiple values for size",
1858                                    ));
1859                                }
1860                                struct __With(std::option::Option<i64>);
1861                                impl<'de> serde::de::Deserialize<'de> for __With {
1862                                    fn deserialize<D>(
1863                                        deserializer: D,
1864                                    ) -> std::result::Result<Self, D::Error>
1865                                    where
1866                                        D: serde::de::Deserializer<'de>,
1867                                    {
1868                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1869                                    }
1870                                }
1871                                result.size = map.next_value::<__With>()?.0.unwrap_or_default();
1872                            }
1873                            __FieldTag::__headers => {
1874                                if !fields.insert(__FieldTag::__headers) {
1875                                    return std::result::Result::Err(A::Error::duplicate_field(
1876                                        "multiple values for headers",
1877                                    ));
1878                                }
1879                                result.headers = map
1880                                    .next_value::<std::option::Option<
1881                                        std::collections::HashMap<
1882                                            std::string::String,
1883                                            std::string::String,
1884                                        >,
1885                                    >>()?
1886                                    .unwrap_or_default();
1887                            }
1888                            __FieldTag::__time => {
1889                                if !fields.insert(__FieldTag::__time) {
1890                                    return std::result::Result::Err(A::Error::duplicate_field(
1891                                        "multiple values for time",
1892                                    ));
1893                                }
1894                                result.time =
1895                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
1896                            }
1897                            __FieldTag::__backend_latency => {
1898                                if !fields.insert(__FieldTag::__backend_latency) {
1899                                    return std::result::Result::Err(A::Error::duplicate_field(
1900                                        "multiple values for backend_latency",
1901                                    ));
1902                                }
1903                                result.backend_latency =
1904                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
1905                            }
1906                            __FieldTag::Unknown(key) => {
1907                                let value = map.next_value::<serde_json::Value>()?;
1908                                result._unknown_fields.insert(key, value);
1909                            }
1910                        }
1911                    }
1912                    std::result::Result::Ok(result)
1913                }
1914            }
1915            deserializer.deserialize_any(Visitor)
1916        }
1917    }
1918
1919    #[doc(hidden)]
1920    impl serde::ser::Serialize for Response {
1921        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1922        where
1923            S: serde::ser::Serializer,
1924        {
1925            use serde::ser::SerializeMap;
1926            #[allow(unused_imports)]
1927            use std::option::Option::Some;
1928            let mut state = serializer.serialize_map(std::option::Option::None)?;
1929            if !wkt::internal::is_default(&self.code) {
1930                struct __With<'a>(&'a i64);
1931                impl<'a> serde::ser::Serialize for __With<'a> {
1932                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1933                    where
1934                        S: serde::ser::Serializer,
1935                    {
1936                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1937                    }
1938                }
1939                state.serialize_entry("code", &__With(&self.code))?;
1940            }
1941            if !wkt::internal::is_default(&self.size) {
1942                struct __With<'a>(&'a i64);
1943                impl<'a> serde::ser::Serialize for __With<'a> {
1944                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1945                    where
1946                        S: serde::ser::Serializer,
1947                    {
1948                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1949                    }
1950                }
1951                state.serialize_entry("size", &__With(&self.size))?;
1952            }
1953            if !self.headers.is_empty() {
1954                state.serialize_entry("headers", &self.headers)?;
1955            }
1956            if self.time.is_some() {
1957                state.serialize_entry("time", &self.time)?;
1958            }
1959            if self.backend_latency.is_some() {
1960                state.serialize_entry("backendLatency", &self.backend_latency)?;
1961            }
1962            if !self._unknown_fields.is_empty() {
1963                for (key, value) in self._unknown_fields.iter() {
1964                    state.serialize_entry(key, &value)?;
1965                }
1966            }
1967            state.end()
1968        }
1969    }
1970
1971    /// This message defines core attributes for a resource. A resource is an
1972    /// addressable (named) entity provided by the destination service. For
1973    /// example, a file stored on a network storage service.
1974    #[derive(Clone, Debug, Default, PartialEq)]
1975    #[non_exhaustive]
1976    pub struct Resource {
1977        /// The name of the service that this resource belongs to, such as
1978        /// `pubsub.googleapis.com`. The service may be different from the DNS
1979        /// hostname that actually serves the request.
1980        pub service: std::string::String,
1981
1982        /// The stable identifier (name) of a resource on the `service`. A resource
1983        /// can be logically identified as "//{resource.service}/{resource.name}".
1984        /// The differences between a resource name and a URI are:
1985        ///
1986        /// * Resource name is a logical identifier, independent of network
1987        ///   protocol and API version. For example,
1988        ///   `//pubsub.googleapis.com/projects/123/topics/news-feed`.
1989        /// * URI often includes protocol and version information, so it can
1990        ///   be used directly by applications. For example,
1991        ///   `<https://pubsub.googleapis.com/v1/projects/123/topics/news-feed>`.
1992        ///
1993        /// See <https://cloud.google.com/apis/design/resource_names> for details.
1994        pub name: std::string::String,
1995
1996        /// The type of the resource. The syntax is platform-specific because
1997        /// different platforms define their resources differently.
1998        ///
1999        /// For Google APIs, the type format must be "{service}/{kind}", such as
2000        /// "pubsub.googleapis.com/Topic".
2001        pub r#type: std::string::String,
2002
2003        /// The labels or tags on the resource, such as AWS resource tags and
2004        /// Kubernetes resource labels.
2005        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
2006
2007        /// The unique identifier of the resource. UID is unique in the time
2008        /// and space for this resource within the scope of the service. It is
2009        /// typically generated by the server on successful creation of a resource
2010        /// and must not be changed. UID is used to uniquely identify resources
2011        /// with resource name reuses. This should be a UUID4.
2012        pub uid: std::string::String,
2013
2014        /// Annotations is an unstructured key-value map stored with a resource that
2015        /// may be set by external tools to store and retrieve arbitrary metadata.
2016        /// They are not queryable and should be preserved when modifying objects.
2017        ///
2018        /// More info:
2019        /// <https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/>
2020        pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
2021
2022        /// Mutable. The display name set by clients. Must be <= 63 characters.
2023        pub display_name: std::string::String,
2024
2025        /// Output only. The timestamp when the resource was created. This may
2026        /// be either the time creation was initiated or when it was completed.
2027        pub create_time: std::option::Option<wkt::Timestamp>,
2028
2029        /// Output only. The timestamp when the resource was last updated. Any
2030        /// change to the resource made by users must refresh this value.
2031        /// Changes to a resource made by the service should refresh this value.
2032        pub update_time: std::option::Option<wkt::Timestamp>,
2033
2034        /// Output only. The timestamp when the resource was deleted.
2035        /// If the resource is not deleted, this must be empty.
2036        pub delete_time: std::option::Option<wkt::Timestamp>,
2037
2038        /// Output only. An opaque value that uniquely identifies a version or
2039        /// generation of a resource. It can be used to confirm that the client
2040        /// and server agree on the ordering of a resource being written.
2041        pub etag: std::string::String,
2042
2043        /// Immutable. The location of the resource. The location encoding is
2044        /// specific to the service provider, and new encoding may be introduced
2045        /// as the service evolves.
2046        ///
2047        /// For Google Cloud products, the encoding is what is used by Google Cloud
2048        /// APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The
2049        /// semantics of `location` is identical to the
2050        /// `cloud.googleapis.com/location` label used by some Google Cloud APIs.
2051        pub location: std::string::String,
2052
2053        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2054    }
2055
2056    impl Resource {
2057        pub fn new() -> Self {
2058            std::default::Default::default()
2059        }
2060
2061        /// Sets the value of [service][crate::model::attribute_context::Resource::service].
2062        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2063            self.service = v.into();
2064            self
2065        }
2066
2067        /// Sets the value of [name][crate::model::attribute_context::Resource::name].
2068        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2069            self.name = v.into();
2070            self
2071        }
2072
2073        /// Sets the value of [r#type][crate::model::attribute_context::Resource::type].
2074        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2075            self.r#type = v.into();
2076            self
2077        }
2078
2079        /// Sets the value of [labels][crate::model::attribute_context::Resource::labels].
2080        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
2081        where
2082            T: std::iter::IntoIterator<Item = (K, V)>,
2083            K: std::convert::Into<std::string::String>,
2084            V: std::convert::Into<std::string::String>,
2085        {
2086            use std::iter::Iterator;
2087            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2088            self
2089        }
2090
2091        /// Sets the value of [uid][crate::model::attribute_context::Resource::uid].
2092        pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2093            self.uid = v.into();
2094            self
2095        }
2096
2097        /// Sets the value of [annotations][crate::model::attribute_context::Resource::annotations].
2098        pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
2099        where
2100            T: std::iter::IntoIterator<Item = (K, V)>,
2101            K: std::convert::Into<std::string::String>,
2102            V: std::convert::Into<std::string::String>,
2103        {
2104            use std::iter::Iterator;
2105            self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2106            self
2107        }
2108
2109        /// Sets the value of [display_name][crate::model::attribute_context::Resource::display_name].
2110        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2111            mut self,
2112            v: T,
2113        ) -> Self {
2114            self.display_name = v.into();
2115            self
2116        }
2117
2118        /// Sets the value of [create_time][crate::model::attribute_context::Resource::create_time].
2119        pub fn set_create_time<T>(mut self, v: T) -> Self
2120        where
2121            T: std::convert::Into<wkt::Timestamp>,
2122        {
2123            self.create_time = std::option::Option::Some(v.into());
2124            self
2125        }
2126
2127        /// Sets or clears the value of [create_time][crate::model::attribute_context::Resource::create_time].
2128        pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
2129        where
2130            T: std::convert::Into<wkt::Timestamp>,
2131        {
2132            self.create_time = v.map(|x| x.into());
2133            self
2134        }
2135
2136        /// Sets the value of [update_time][crate::model::attribute_context::Resource::update_time].
2137        pub fn set_update_time<T>(mut self, v: T) -> Self
2138        where
2139            T: std::convert::Into<wkt::Timestamp>,
2140        {
2141            self.update_time = std::option::Option::Some(v.into());
2142            self
2143        }
2144
2145        /// Sets or clears the value of [update_time][crate::model::attribute_context::Resource::update_time].
2146        pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
2147        where
2148            T: std::convert::Into<wkt::Timestamp>,
2149        {
2150            self.update_time = v.map(|x| x.into());
2151            self
2152        }
2153
2154        /// Sets the value of [delete_time][crate::model::attribute_context::Resource::delete_time].
2155        pub fn set_delete_time<T>(mut self, v: T) -> Self
2156        where
2157            T: std::convert::Into<wkt::Timestamp>,
2158        {
2159            self.delete_time = std::option::Option::Some(v.into());
2160            self
2161        }
2162
2163        /// Sets or clears the value of [delete_time][crate::model::attribute_context::Resource::delete_time].
2164        pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
2165        where
2166            T: std::convert::Into<wkt::Timestamp>,
2167        {
2168            self.delete_time = v.map(|x| x.into());
2169            self
2170        }
2171
2172        /// Sets the value of [etag][crate::model::attribute_context::Resource::etag].
2173        pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2174            self.etag = v.into();
2175            self
2176        }
2177
2178        /// Sets the value of [location][crate::model::attribute_context::Resource::location].
2179        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2180            self.location = v.into();
2181            self
2182        }
2183    }
2184
2185    impl wkt::message::Message for Resource {
2186        fn typename() -> &'static str {
2187            "type.googleapis.com/google.rpc.context.AttributeContext.Resource"
2188        }
2189    }
2190
2191    #[doc(hidden)]
2192    impl<'de> serde::de::Deserialize<'de> for Resource {
2193        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2194        where
2195            D: serde::Deserializer<'de>,
2196        {
2197            #[allow(non_camel_case_types)]
2198            #[doc(hidden)]
2199            #[derive(PartialEq, Eq, Hash)]
2200            enum __FieldTag {
2201                __service,
2202                __name,
2203                __type,
2204                __labels,
2205                __uid,
2206                __annotations,
2207                __display_name,
2208                __create_time,
2209                __update_time,
2210                __delete_time,
2211                __etag,
2212                __location,
2213                Unknown(std::string::String),
2214            }
2215            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2216                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2217                where
2218                    D: serde::Deserializer<'de>,
2219                {
2220                    struct Visitor;
2221                    impl<'de> serde::de::Visitor<'de> for Visitor {
2222                        type Value = __FieldTag;
2223                        fn expecting(
2224                            &self,
2225                            formatter: &mut std::fmt::Formatter,
2226                        ) -> std::fmt::Result {
2227                            formatter.write_str("a field name for Resource")
2228                        }
2229                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2230                        where
2231                            E: serde::de::Error,
2232                        {
2233                            use std::result::Result::Ok;
2234                            use std::string::ToString;
2235                            match value {
2236                                "service" => Ok(__FieldTag::__service),
2237                                "name" => Ok(__FieldTag::__name),
2238                                "type" => Ok(__FieldTag::__type),
2239                                "labels" => Ok(__FieldTag::__labels),
2240                                "uid" => Ok(__FieldTag::__uid),
2241                                "annotations" => Ok(__FieldTag::__annotations),
2242                                "displayName" => Ok(__FieldTag::__display_name),
2243                                "display_name" => Ok(__FieldTag::__display_name),
2244                                "createTime" => Ok(__FieldTag::__create_time),
2245                                "create_time" => Ok(__FieldTag::__create_time),
2246                                "updateTime" => Ok(__FieldTag::__update_time),
2247                                "update_time" => Ok(__FieldTag::__update_time),
2248                                "deleteTime" => Ok(__FieldTag::__delete_time),
2249                                "delete_time" => Ok(__FieldTag::__delete_time),
2250                                "etag" => Ok(__FieldTag::__etag),
2251                                "location" => Ok(__FieldTag::__location),
2252                                _ => Ok(__FieldTag::Unknown(value.to_string())),
2253                            }
2254                        }
2255                    }
2256                    deserializer.deserialize_identifier(Visitor)
2257                }
2258            }
2259            struct Visitor;
2260            impl<'de> serde::de::Visitor<'de> for Visitor {
2261                type Value = Resource;
2262                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2263                    formatter.write_str("struct Resource")
2264                }
2265                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2266                where
2267                    A: serde::de::MapAccess<'de>,
2268                {
2269                    #[allow(unused_imports)]
2270                    use serde::de::Error;
2271                    use std::option::Option::Some;
2272                    let mut fields = std::collections::HashSet::new();
2273                    let mut result = Self::Value::new();
2274                    while let Some(tag) = map.next_key::<__FieldTag>()? {
2275                        #[allow(clippy::match_single_binding)]
2276                        match tag {
2277                            __FieldTag::__service => {
2278                                if !fields.insert(__FieldTag::__service) {
2279                                    return std::result::Result::Err(A::Error::duplicate_field(
2280                                        "multiple values for service",
2281                                    ));
2282                                }
2283                                result.service = map
2284                                    .next_value::<std::option::Option<std::string::String>>()?
2285                                    .unwrap_or_default();
2286                            }
2287                            __FieldTag::__name => {
2288                                if !fields.insert(__FieldTag::__name) {
2289                                    return std::result::Result::Err(A::Error::duplicate_field(
2290                                        "multiple values for name",
2291                                    ));
2292                                }
2293                                result.name = map
2294                                    .next_value::<std::option::Option<std::string::String>>()?
2295                                    .unwrap_or_default();
2296                            }
2297                            __FieldTag::__type => {
2298                                if !fields.insert(__FieldTag::__type) {
2299                                    return std::result::Result::Err(A::Error::duplicate_field(
2300                                        "multiple values for type",
2301                                    ));
2302                                }
2303                                result.r#type = map
2304                                    .next_value::<std::option::Option<std::string::String>>()?
2305                                    .unwrap_or_default();
2306                            }
2307                            __FieldTag::__labels => {
2308                                if !fields.insert(__FieldTag::__labels) {
2309                                    return std::result::Result::Err(A::Error::duplicate_field(
2310                                        "multiple values for labels",
2311                                    ));
2312                                }
2313                                result.labels = map
2314                                    .next_value::<std::option::Option<
2315                                        std::collections::HashMap<
2316                                            std::string::String,
2317                                            std::string::String,
2318                                        >,
2319                                    >>()?
2320                                    .unwrap_or_default();
2321                            }
2322                            __FieldTag::__uid => {
2323                                if !fields.insert(__FieldTag::__uid) {
2324                                    return std::result::Result::Err(A::Error::duplicate_field(
2325                                        "multiple values for uid",
2326                                    ));
2327                                }
2328                                result.uid = map
2329                                    .next_value::<std::option::Option<std::string::String>>()?
2330                                    .unwrap_or_default();
2331                            }
2332                            __FieldTag::__annotations => {
2333                                if !fields.insert(__FieldTag::__annotations) {
2334                                    return std::result::Result::Err(A::Error::duplicate_field(
2335                                        "multiple values for annotations",
2336                                    ));
2337                                }
2338                                result.annotations = map
2339                                    .next_value::<std::option::Option<
2340                                        std::collections::HashMap<
2341                                            std::string::String,
2342                                            std::string::String,
2343                                        >,
2344                                    >>()?
2345                                    .unwrap_or_default();
2346                            }
2347                            __FieldTag::__display_name => {
2348                                if !fields.insert(__FieldTag::__display_name) {
2349                                    return std::result::Result::Err(A::Error::duplicate_field(
2350                                        "multiple values for display_name",
2351                                    ));
2352                                }
2353                                result.display_name = map
2354                                    .next_value::<std::option::Option<std::string::String>>()?
2355                                    .unwrap_or_default();
2356                            }
2357                            __FieldTag::__create_time => {
2358                                if !fields.insert(__FieldTag::__create_time) {
2359                                    return std::result::Result::Err(A::Error::duplicate_field(
2360                                        "multiple values for create_time",
2361                                    ));
2362                                }
2363                                result.create_time =
2364                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2365                            }
2366                            __FieldTag::__update_time => {
2367                                if !fields.insert(__FieldTag::__update_time) {
2368                                    return std::result::Result::Err(A::Error::duplicate_field(
2369                                        "multiple values for update_time",
2370                                    ));
2371                                }
2372                                result.update_time =
2373                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2374                            }
2375                            __FieldTag::__delete_time => {
2376                                if !fields.insert(__FieldTag::__delete_time) {
2377                                    return std::result::Result::Err(A::Error::duplicate_field(
2378                                        "multiple values for delete_time",
2379                                    ));
2380                                }
2381                                result.delete_time =
2382                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2383                            }
2384                            __FieldTag::__etag => {
2385                                if !fields.insert(__FieldTag::__etag) {
2386                                    return std::result::Result::Err(A::Error::duplicate_field(
2387                                        "multiple values for etag",
2388                                    ));
2389                                }
2390                                result.etag = map
2391                                    .next_value::<std::option::Option<std::string::String>>()?
2392                                    .unwrap_or_default();
2393                            }
2394                            __FieldTag::__location => {
2395                                if !fields.insert(__FieldTag::__location) {
2396                                    return std::result::Result::Err(A::Error::duplicate_field(
2397                                        "multiple values for location",
2398                                    ));
2399                                }
2400                                result.location = map
2401                                    .next_value::<std::option::Option<std::string::String>>()?
2402                                    .unwrap_or_default();
2403                            }
2404                            __FieldTag::Unknown(key) => {
2405                                let value = map.next_value::<serde_json::Value>()?;
2406                                result._unknown_fields.insert(key, value);
2407                            }
2408                        }
2409                    }
2410                    std::result::Result::Ok(result)
2411                }
2412            }
2413            deserializer.deserialize_any(Visitor)
2414        }
2415    }
2416
2417    #[doc(hidden)]
2418    impl serde::ser::Serialize for Resource {
2419        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2420        where
2421            S: serde::ser::Serializer,
2422        {
2423            use serde::ser::SerializeMap;
2424            #[allow(unused_imports)]
2425            use std::option::Option::Some;
2426            let mut state = serializer.serialize_map(std::option::Option::None)?;
2427            if !self.service.is_empty() {
2428                state.serialize_entry("service", &self.service)?;
2429            }
2430            if !self.name.is_empty() {
2431                state.serialize_entry("name", &self.name)?;
2432            }
2433            if !self.r#type.is_empty() {
2434                state.serialize_entry("type", &self.r#type)?;
2435            }
2436            if !self.labels.is_empty() {
2437                state.serialize_entry("labels", &self.labels)?;
2438            }
2439            if !self.uid.is_empty() {
2440                state.serialize_entry("uid", &self.uid)?;
2441            }
2442            if !self.annotations.is_empty() {
2443                state.serialize_entry("annotations", &self.annotations)?;
2444            }
2445            if !self.display_name.is_empty() {
2446                state.serialize_entry("displayName", &self.display_name)?;
2447            }
2448            if self.create_time.is_some() {
2449                state.serialize_entry("createTime", &self.create_time)?;
2450            }
2451            if self.update_time.is_some() {
2452                state.serialize_entry("updateTime", &self.update_time)?;
2453            }
2454            if self.delete_time.is_some() {
2455                state.serialize_entry("deleteTime", &self.delete_time)?;
2456            }
2457            if !self.etag.is_empty() {
2458                state.serialize_entry("etag", &self.etag)?;
2459            }
2460            if !self.location.is_empty() {
2461                state.serialize_entry("location", &self.location)?;
2462            }
2463            if !self._unknown_fields.is_empty() {
2464                for (key, value) in self._unknown_fields.iter() {
2465                    state.serialize_entry(key, &value)?;
2466                }
2467            }
2468            state.end()
2469        }
2470    }
2471}
2472
2473/// `AuditContext` provides information that is needed for audit logging.
2474#[derive(Clone, Debug, Default, PartialEq)]
2475#[non_exhaustive]
2476pub struct AuditContext {
2477    /// Serialized audit log.
2478    pub audit_log: ::bytes::Bytes,
2479
2480    /// An API request message that is scrubbed based on the method annotation.
2481    /// This field should only be filled if audit_log field is present.
2482    /// Service Control will use this to assemble a complete log for Cloud Audit
2483    /// Logs and Google internal audit logs.
2484    pub scrubbed_request: std::option::Option<wkt::Struct>,
2485
2486    /// An API response message that is scrubbed based on the method annotation.
2487    /// This field should only be filled if audit_log field is present.
2488    /// Service Control will use this to assemble a complete log for Cloud Audit
2489    /// Logs and Google internal audit logs.
2490    pub scrubbed_response: std::option::Option<wkt::Struct>,
2491
2492    /// Number of scrubbed response items.
2493    pub scrubbed_response_item_count: i32,
2494
2495    /// Audit resource name which is scrubbed.
2496    pub target_resource: std::string::String,
2497
2498    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2499}
2500
2501impl AuditContext {
2502    pub fn new() -> Self {
2503        std::default::Default::default()
2504    }
2505
2506    /// Sets the value of [audit_log][crate::model::AuditContext::audit_log].
2507    pub fn set_audit_log<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2508        self.audit_log = v.into();
2509        self
2510    }
2511
2512    /// Sets the value of [scrubbed_request][crate::model::AuditContext::scrubbed_request].
2513    pub fn set_scrubbed_request<T>(mut self, v: T) -> Self
2514    where
2515        T: std::convert::Into<wkt::Struct>,
2516    {
2517        self.scrubbed_request = std::option::Option::Some(v.into());
2518        self
2519    }
2520
2521    /// Sets or clears the value of [scrubbed_request][crate::model::AuditContext::scrubbed_request].
2522    pub fn set_or_clear_scrubbed_request<T>(mut self, v: std::option::Option<T>) -> Self
2523    where
2524        T: std::convert::Into<wkt::Struct>,
2525    {
2526        self.scrubbed_request = v.map(|x| x.into());
2527        self
2528    }
2529
2530    /// Sets the value of [scrubbed_response][crate::model::AuditContext::scrubbed_response].
2531    pub fn set_scrubbed_response<T>(mut self, v: T) -> Self
2532    where
2533        T: std::convert::Into<wkt::Struct>,
2534    {
2535        self.scrubbed_response = std::option::Option::Some(v.into());
2536        self
2537    }
2538
2539    /// Sets or clears the value of [scrubbed_response][crate::model::AuditContext::scrubbed_response].
2540    pub fn set_or_clear_scrubbed_response<T>(mut self, v: std::option::Option<T>) -> Self
2541    where
2542        T: std::convert::Into<wkt::Struct>,
2543    {
2544        self.scrubbed_response = v.map(|x| x.into());
2545        self
2546    }
2547
2548    /// Sets the value of [scrubbed_response_item_count][crate::model::AuditContext::scrubbed_response_item_count].
2549    pub fn set_scrubbed_response_item_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2550        self.scrubbed_response_item_count = v.into();
2551        self
2552    }
2553
2554    /// Sets the value of [target_resource][crate::model::AuditContext::target_resource].
2555    pub fn set_target_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2556        self.target_resource = v.into();
2557        self
2558    }
2559}
2560
2561impl wkt::message::Message for AuditContext {
2562    fn typename() -> &'static str {
2563        "type.googleapis.com/google.rpc.context.AuditContext"
2564    }
2565}
2566
2567#[doc(hidden)]
2568impl<'de> serde::de::Deserialize<'de> for AuditContext {
2569    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2570    where
2571        D: serde::Deserializer<'de>,
2572    {
2573        #[allow(non_camel_case_types)]
2574        #[doc(hidden)]
2575        #[derive(PartialEq, Eq, Hash)]
2576        enum __FieldTag {
2577            __audit_log,
2578            __scrubbed_request,
2579            __scrubbed_response,
2580            __scrubbed_response_item_count,
2581            __target_resource,
2582            Unknown(std::string::String),
2583        }
2584        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2585            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2586            where
2587                D: serde::Deserializer<'de>,
2588            {
2589                struct Visitor;
2590                impl<'de> serde::de::Visitor<'de> for Visitor {
2591                    type Value = __FieldTag;
2592                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2593                        formatter.write_str("a field name for AuditContext")
2594                    }
2595                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2596                    where
2597                        E: serde::de::Error,
2598                    {
2599                        use std::result::Result::Ok;
2600                        use std::string::ToString;
2601                        match value {
2602                            "auditLog" => Ok(__FieldTag::__audit_log),
2603                            "audit_log" => Ok(__FieldTag::__audit_log),
2604                            "scrubbedRequest" => Ok(__FieldTag::__scrubbed_request),
2605                            "scrubbed_request" => Ok(__FieldTag::__scrubbed_request),
2606                            "scrubbedResponse" => Ok(__FieldTag::__scrubbed_response),
2607                            "scrubbed_response" => Ok(__FieldTag::__scrubbed_response),
2608                            "scrubbedResponseItemCount" => {
2609                                Ok(__FieldTag::__scrubbed_response_item_count)
2610                            }
2611                            "scrubbed_response_item_count" => {
2612                                Ok(__FieldTag::__scrubbed_response_item_count)
2613                            }
2614                            "targetResource" => Ok(__FieldTag::__target_resource),
2615                            "target_resource" => Ok(__FieldTag::__target_resource),
2616                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2617                        }
2618                    }
2619                }
2620                deserializer.deserialize_identifier(Visitor)
2621            }
2622        }
2623        struct Visitor;
2624        impl<'de> serde::de::Visitor<'de> for Visitor {
2625            type Value = AuditContext;
2626            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2627                formatter.write_str("struct AuditContext")
2628            }
2629            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2630            where
2631                A: serde::de::MapAccess<'de>,
2632            {
2633                #[allow(unused_imports)]
2634                use serde::de::Error;
2635                use std::option::Option::Some;
2636                let mut fields = std::collections::HashSet::new();
2637                let mut result = Self::Value::new();
2638                while let Some(tag) = map.next_key::<__FieldTag>()? {
2639                    #[allow(clippy::match_single_binding)]
2640                    match tag {
2641                        __FieldTag::__audit_log => {
2642                            if !fields.insert(__FieldTag::__audit_log) {
2643                                return std::result::Result::Err(A::Error::duplicate_field(
2644                                    "multiple values for audit_log",
2645                                ));
2646                            }
2647                            struct __With(std::option::Option<::bytes::Bytes>);
2648                            impl<'de> serde::de::Deserialize<'de> for __With {
2649                                fn deserialize<D>(
2650                                    deserializer: D,
2651                                ) -> std::result::Result<Self, D::Error>
2652                                where
2653                                    D: serde::de::Deserializer<'de>,
2654                                {
2655                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
2656                                }
2657                            }
2658                            result.audit_log = map.next_value::<__With>()?.0.unwrap_or_default();
2659                        }
2660                        __FieldTag::__scrubbed_request => {
2661                            if !fields.insert(__FieldTag::__scrubbed_request) {
2662                                return std::result::Result::Err(A::Error::duplicate_field(
2663                                    "multiple values for scrubbed_request",
2664                                ));
2665                            }
2666                            result.scrubbed_request =
2667                                map.next_value::<std::option::Option<wkt::Struct>>()?;
2668                        }
2669                        __FieldTag::__scrubbed_response => {
2670                            if !fields.insert(__FieldTag::__scrubbed_response) {
2671                                return std::result::Result::Err(A::Error::duplicate_field(
2672                                    "multiple values for scrubbed_response",
2673                                ));
2674                            }
2675                            result.scrubbed_response =
2676                                map.next_value::<std::option::Option<wkt::Struct>>()?;
2677                        }
2678                        __FieldTag::__scrubbed_response_item_count => {
2679                            if !fields.insert(__FieldTag::__scrubbed_response_item_count) {
2680                                return std::result::Result::Err(A::Error::duplicate_field(
2681                                    "multiple values for scrubbed_response_item_count",
2682                                ));
2683                            }
2684                            struct __With(std::option::Option<i32>);
2685                            impl<'de> serde::de::Deserialize<'de> for __With {
2686                                fn deserialize<D>(
2687                                    deserializer: D,
2688                                ) -> std::result::Result<Self, D::Error>
2689                                where
2690                                    D: serde::de::Deserializer<'de>,
2691                                {
2692                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2693                                }
2694                            }
2695                            result.scrubbed_response_item_count =
2696                                map.next_value::<__With>()?.0.unwrap_or_default();
2697                        }
2698                        __FieldTag::__target_resource => {
2699                            if !fields.insert(__FieldTag::__target_resource) {
2700                                return std::result::Result::Err(A::Error::duplicate_field(
2701                                    "multiple values for target_resource",
2702                                ));
2703                            }
2704                            result.target_resource = map
2705                                .next_value::<std::option::Option<std::string::String>>()?
2706                                .unwrap_or_default();
2707                        }
2708                        __FieldTag::Unknown(key) => {
2709                            let value = map.next_value::<serde_json::Value>()?;
2710                            result._unknown_fields.insert(key, value);
2711                        }
2712                    }
2713                }
2714                std::result::Result::Ok(result)
2715            }
2716        }
2717        deserializer.deserialize_any(Visitor)
2718    }
2719}
2720
2721#[doc(hidden)]
2722impl serde::ser::Serialize for AuditContext {
2723    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2724    where
2725        S: serde::ser::Serializer,
2726    {
2727        use serde::ser::SerializeMap;
2728        #[allow(unused_imports)]
2729        use std::option::Option::Some;
2730        let mut state = serializer.serialize_map(std::option::Option::None)?;
2731        if !self.audit_log.is_empty() {
2732            struct __With<'a>(&'a ::bytes::Bytes);
2733            impl<'a> serde::ser::Serialize for __With<'a> {
2734                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2735                where
2736                    S: serde::ser::Serializer,
2737                {
2738                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
2739                }
2740            }
2741            state.serialize_entry("auditLog", &__With(&self.audit_log))?;
2742        }
2743        if self.scrubbed_request.is_some() {
2744            state.serialize_entry("scrubbedRequest", &self.scrubbed_request)?;
2745        }
2746        if self.scrubbed_response.is_some() {
2747            state.serialize_entry("scrubbedResponse", &self.scrubbed_response)?;
2748        }
2749        if !wkt::internal::is_default(&self.scrubbed_response_item_count) {
2750            struct __With<'a>(&'a i32);
2751            impl<'a> serde::ser::Serialize for __With<'a> {
2752                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2753                where
2754                    S: serde::ser::Serializer,
2755                {
2756                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
2757                }
2758            }
2759            state.serialize_entry(
2760                "scrubbedResponseItemCount",
2761                &__With(&self.scrubbed_response_item_count),
2762            )?;
2763        }
2764        if !self.target_resource.is_empty() {
2765            state.serialize_entry("targetResource", &self.target_resource)?;
2766        }
2767        if !self._unknown_fields.is_empty() {
2768            for (key, value) in self._unknown_fields.iter() {
2769                state.serialize_entry(key, &value)?;
2770            }
2771        }
2772        state.end()
2773    }
2774}