Skip to main content

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
27mod debug;
28mod deserialize;
29mod serialize;
30
31/// This message defines the standard attribute vocabulary for Google APIs.
32///
33/// An attribute is a piece of metadata that describes an activity on a network
34/// service. For example, the size of an HTTP request, or the status code of
35/// an HTTP response.
36///
37/// Each attribute has a type and a name, which is logically defined as
38/// a proto message field in `AttributeContext`. The field type becomes the
39/// attribute type, and the field path becomes the attribute name. For example,
40/// the attribute `source.ip` maps to field `AttributeContext.source.ip`.
41///
42/// This message definition is guaranteed not to have any wire breaking change.
43/// So you can use it directly for passing attributes across different systems.
44///
45/// NOTE: Different system may generate different subset of attributes. Please
46/// verify the system specification before relying on an attribute generated
47/// a system.
48#[derive(Clone, Default, PartialEq)]
49#[non_exhaustive]
50pub struct AttributeContext {
51    /// The origin of a network activity. In a multi hop network activity,
52    /// the origin represents the sender of the first hop. For the first hop,
53    /// the `source` and the `origin` must have the same content.
54    pub origin: std::option::Option<crate::model::attribute_context::Peer>,
55
56    /// The source of a network activity, such as starting a TCP connection.
57    /// In a multi hop network activity, the source represents the sender of the
58    /// last hop.
59    pub source: std::option::Option<crate::model::attribute_context::Peer>,
60
61    /// The destination of a network activity, such as accepting a TCP connection.
62    /// In a multi hop network activity, the destination represents the receiver of
63    /// the last hop.
64    pub destination: std::option::Option<crate::model::attribute_context::Peer>,
65
66    /// Represents a network request, such as an HTTP request.
67    pub request: std::option::Option<crate::model::attribute_context::Request>,
68
69    /// Represents a network response, such as an HTTP response.
70    pub response: std::option::Option<crate::model::attribute_context::Response>,
71
72    /// Represents a target resource that is involved with a network activity.
73    /// If multiple resources are involved with an activity, this must be the
74    /// primary one.
75    pub resource: std::option::Option<crate::model::attribute_context::Resource>,
76
77    /// Represents an API operation that is involved to a network activity.
78    pub api: std::option::Option<crate::model::attribute_context::Api>,
79
80    /// Supports extensions for advanced use cases, such as logs and metrics.
81    pub extensions: std::vec::Vec<wkt::Any>,
82
83    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
84}
85
86impl AttributeContext {
87    /// Creates a new default instance.
88    pub fn new() -> Self {
89        std::default::Default::default()
90    }
91
92    /// Sets the value of [origin][crate::model::AttributeContext::origin].
93    ///
94    /// # Example
95    /// ```ignore,no_run
96    /// # use google_cloud_rpc_context::model::AttributeContext;
97    /// use google_cloud_rpc_context::model::attribute_context::Peer;
98    /// let x = AttributeContext::new().set_origin(Peer::default()/* use setters */);
99    /// ```
100    pub fn set_origin<T>(mut self, v: T) -> Self
101    where
102        T: std::convert::Into<crate::model::attribute_context::Peer>,
103    {
104        self.origin = std::option::Option::Some(v.into());
105        self
106    }
107
108    /// Sets or clears the value of [origin][crate::model::AttributeContext::origin].
109    ///
110    /// # Example
111    /// ```ignore,no_run
112    /// # use google_cloud_rpc_context::model::AttributeContext;
113    /// use google_cloud_rpc_context::model::attribute_context::Peer;
114    /// let x = AttributeContext::new().set_or_clear_origin(Some(Peer::default()/* use setters */));
115    /// let x = AttributeContext::new().set_or_clear_origin(None::<Peer>);
116    /// ```
117    pub fn set_or_clear_origin<T>(mut self, v: std::option::Option<T>) -> Self
118    where
119        T: std::convert::Into<crate::model::attribute_context::Peer>,
120    {
121        self.origin = v.map(|x| x.into());
122        self
123    }
124
125    /// Sets the value of [source][crate::model::AttributeContext::source].
126    ///
127    /// # Example
128    /// ```ignore,no_run
129    /// # use google_cloud_rpc_context::model::AttributeContext;
130    /// use google_cloud_rpc_context::model::attribute_context::Peer;
131    /// let x = AttributeContext::new().set_source(Peer::default()/* use setters */);
132    /// ```
133    pub fn set_source<T>(mut self, v: T) -> Self
134    where
135        T: std::convert::Into<crate::model::attribute_context::Peer>,
136    {
137        self.source = std::option::Option::Some(v.into());
138        self
139    }
140
141    /// Sets or clears the value of [source][crate::model::AttributeContext::source].
142    ///
143    /// # Example
144    /// ```ignore,no_run
145    /// # use google_cloud_rpc_context::model::AttributeContext;
146    /// use google_cloud_rpc_context::model::attribute_context::Peer;
147    /// let x = AttributeContext::new().set_or_clear_source(Some(Peer::default()/* use setters */));
148    /// let x = AttributeContext::new().set_or_clear_source(None::<Peer>);
149    /// ```
150    pub fn set_or_clear_source<T>(mut self, v: std::option::Option<T>) -> Self
151    where
152        T: std::convert::Into<crate::model::attribute_context::Peer>,
153    {
154        self.source = v.map(|x| x.into());
155        self
156    }
157
158    /// Sets the value of [destination][crate::model::AttributeContext::destination].
159    ///
160    /// # Example
161    /// ```ignore,no_run
162    /// # use google_cloud_rpc_context::model::AttributeContext;
163    /// use google_cloud_rpc_context::model::attribute_context::Peer;
164    /// let x = AttributeContext::new().set_destination(Peer::default()/* use setters */);
165    /// ```
166    pub fn set_destination<T>(mut self, v: T) -> Self
167    where
168        T: std::convert::Into<crate::model::attribute_context::Peer>,
169    {
170        self.destination = std::option::Option::Some(v.into());
171        self
172    }
173
174    /// Sets or clears the value of [destination][crate::model::AttributeContext::destination].
175    ///
176    /// # Example
177    /// ```ignore,no_run
178    /// # use google_cloud_rpc_context::model::AttributeContext;
179    /// use google_cloud_rpc_context::model::attribute_context::Peer;
180    /// let x = AttributeContext::new().set_or_clear_destination(Some(Peer::default()/* use setters */));
181    /// let x = AttributeContext::new().set_or_clear_destination(None::<Peer>);
182    /// ```
183    pub fn set_or_clear_destination<T>(mut self, v: std::option::Option<T>) -> Self
184    where
185        T: std::convert::Into<crate::model::attribute_context::Peer>,
186    {
187        self.destination = v.map(|x| x.into());
188        self
189    }
190
191    /// Sets the value of [request][crate::model::AttributeContext::request].
192    ///
193    /// # Example
194    /// ```ignore,no_run
195    /// # use google_cloud_rpc_context::model::AttributeContext;
196    /// use google_cloud_rpc_context::model::attribute_context::Request;
197    /// let x = AttributeContext::new().set_request(Request::default()/* use setters */);
198    /// ```
199    pub fn set_request<T>(mut self, v: T) -> Self
200    where
201        T: std::convert::Into<crate::model::attribute_context::Request>,
202    {
203        self.request = std::option::Option::Some(v.into());
204        self
205    }
206
207    /// Sets or clears the value of [request][crate::model::AttributeContext::request].
208    ///
209    /// # Example
210    /// ```ignore,no_run
211    /// # use google_cloud_rpc_context::model::AttributeContext;
212    /// use google_cloud_rpc_context::model::attribute_context::Request;
213    /// let x = AttributeContext::new().set_or_clear_request(Some(Request::default()/* use setters */));
214    /// let x = AttributeContext::new().set_or_clear_request(None::<Request>);
215    /// ```
216    pub fn set_or_clear_request<T>(mut self, v: std::option::Option<T>) -> Self
217    where
218        T: std::convert::Into<crate::model::attribute_context::Request>,
219    {
220        self.request = v.map(|x| x.into());
221        self
222    }
223
224    /// Sets the value of [response][crate::model::AttributeContext::response].
225    ///
226    /// # Example
227    /// ```ignore,no_run
228    /// # use google_cloud_rpc_context::model::AttributeContext;
229    /// use google_cloud_rpc_context::model::attribute_context::Response;
230    /// let x = AttributeContext::new().set_response(Response::default()/* use setters */);
231    /// ```
232    pub fn set_response<T>(mut self, v: T) -> Self
233    where
234        T: std::convert::Into<crate::model::attribute_context::Response>,
235    {
236        self.response = std::option::Option::Some(v.into());
237        self
238    }
239
240    /// Sets or clears the value of [response][crate::model::AttributeContext::response].
241    ///
242    /// # Example
243    /// ```ignore,no_run
244    /// # use google_cloud_rpc_context::model::AttributeContext;
245    /// use google_cloud_rpc_context::model::attribute_context::Response;
246    /// let x = AttributeContext::new().set_or_clear_response(Some(Response::default()/* use setters */));
247    /// let x = AttributeContext::new().set_or_clear_response(None::<Response>);
248    /// ```
249    pub fn set_or_clear_response<T>(mut self, v: std::option::Option<T>) -> Self
250    where
251        T: std::convert::Into<crate::model::attribute_context::Response>,
252    {
253        self.response = v.map(|x| x.into());
254        self
255    }
256
257    /// Sets the value of [resource][crate::model::AttributeContext::resource].
258    ///
259    /// # Example
260    /// ```ignore,no_run
261    /// # use google_cloud_rpc_context::model::AttributeContext;
262    /// use google_cloud_rpc_context::model::attribute_context::Resource;
263    /// let x = AttributeContext::new().set_resource(Resource::default()/* use setters */);
264    /// ```
265    pub fn set_resource<T>(mut self, v: T) -> Self
266    where
267        T: std::convert::Into<crate::model::attribute_context::Resource>,
268    {
269        self.resource = std::option::Option::Some(v.into());
270        self
271    }
272
273    /// Sets or clears the value of [resource][crate::model::AttributeContext::resource].
274    ///
275    /// # Example
276    /// ```ignore,no_run
277    /// # use google_cloud_rpc_context::model::AttributeContext;
278    /// use google_cloud_rpc_context::model::attribute_context::Resource;
279    /// let x = AttributeContext::new().set_or_clear_resource(Some(Resource::default()/* use setters */));
280    /// let x = AttributeContext::new().set_or_clear_resource(None::<Resource>);
281    /// ```
282    pub fn set_or_clear_resource<T>(mut self, v: std::option::Option<T>) -> Self
283    where
284        T: std::convert::Into<crate::model::attribute_context::Resource>,
285    {
286        self.resource = v.map(|x| x.into());
287        self
288    }
289
290    /// Sets the value of [api][crate::model::AttributeContext::api].
291    ///
292    /// # Example
293    /// ```ignore,no_run
294    /// # use google_cloud_rpc_context::model::AttributeContext;
295    /// use google_cloud_rpc_context::model::attribute_context::Api;
296    /// let x = AttributeContext::new().set_api(Api::default()/* use setters */);
297    /// ```
298    pub fn set_api<T>(mut self, v: T) -> Self
299    where
300        T: std::convert::Into<crate::model::attribute_context::Api>,
301    {
302        self.api = std::option::Option::Some(v.into());
303        self
304    }
305
306    /// Sets or clears the value of [api][crate::model::AttributeContext::api].
307    ///
308    /// # Example
309    /// ```ignore,no_run
310    /// # use google_cloud_rpc_context::model::AttributeContext;
311    /// use google_cloud_rpc_context::model::attribute_context::Api;
312    /// let x = AttributeContext::new().set_or_clear_api(Some(Api::default()/* use setters */));
313    /// let x = AttributeContext::new().set_or_clear_api(None::<Api>);
314    /// ```
315    pub fn set_or_clear_api<T>(mut self, v: std::option::Option<T>) -> Self
316    where
317        T: std::convert::Into<crate::model::attribute_context::Api>,
318    {
319        self.api = v.map(|x| x.into());
320        self
321    }
322
323    /// Sets the value of [extensions][crate::model::AttributeContext::extensions].
324    ///
325    /// # Example
326    /// ```ignore,no_run
327    /// # use google_cloud_rpc_context::model::AttributeContext;
328    /// use wkt::Any;
329    /// let x = AttributeContext::new()
330    ///     .set_extensions([
331    ///         Any::default()/* use setters */,
332    ///         Any::default()/* use (different) setters */,
333    ///     ]);
334    /// ```
335    pub fn set_extensions<T, V>(mut self, v: T) -> Self
336    where
337        T: std::iter::IntoIterator<Item = V>,
338        V: std::convert::Into<wkt::Any>,
339    {
340        use std::iter::Iterator;
341        self.extensions = v.into_iter().map(|i| i.into()).collect();
342        self
343    }
344}
345
346impl wkt::message::Message for AttributeContext {
347    fn typename() -> &'static str {
348        "type.googleapis.com/google.rpc.context.AttributeContext"
349    }
350}
351
352/// Defines additional types related to [AttributeContext].
353pub mod attribute_context {
354    #[allow(unused_imports)]
355    use super::*;
356
357    /// This message defines attributes for a node that handles a network request.
358    /// The node can be either a service or an application that sends, forwards,
359    /// or receives the request. Service peers should fill in
360    /// `principal` and `labels` as appropriate.
361    #[derive(Clone, Default, PartialEq)]
362    #[non_exhaustive]
363    pub struct Peer {
364        /// The IP address of the peer.
365        pub ip: std::string::String,
366
367        /// The network port of the peer.
368        pub port: i64,
369
370        /// The labels associated with the peer.
371        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
372
373        /// The identity of this peer. Similar to `Request.auth.principal`, but
374        /// relative to the peer instead of the request. For example, the
375        /// identity associated with a load balancer that forwarded the request.
376        pub principal: std::string::String,
377
378        /// The CLDR country/region code associated with the above IP address.
379        /// If the IP address is private, the `region_code` should reflect the
380        /// physical location where this peer is running.
381        pub region_code: std::string::String,
382
383        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
384    }
385
386    impl Peer {
387        /// Creates a new default instance.
388        pub fn new() -> Self {
389            std::default::Default::default()
390        }
391
392        /// Sets the value of [ip][crate::model::attribute_context::Peer::ip].
393        ///
394        /// # Example
395        /// ```ignore,no_run
396        /// # use google_cloud_rpc_context::model::attribute_context::Peer;
397        /// let x = Peer::new().set_ip("example");
398        /// ```
399        pub fn set_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
400            self.ip = v.into();
401            self
402        }
403
404        /// Sets the value of [port][crate::model::attribute_context::Peer::port].
405        ///
406        /// # Example
407        /// ```ignore,no_run
408        /// # use google_cloud_rpc_context::model::attribute_context::Peer;
409        /// let x = Peer::new().set_port(42);
410        /// ```
411        pub fn set_port<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
412            self.port = v.into();
413            self
414        }
415
416        /// Sets the value of [labels][crate::model::attribute_context::Peer::labels].
417        ///
418        /// # Example
419        /// ```ignore,no_run
420        /// # use google_cloud_rpc_context::model::attribute_context::Peer;
421        /// let x = Peer::new().set_labels([
422        ///     ("key0", "abc"),
423        ///     ("key1", "xyz"),
424        /// ]);
425        /// ```
426        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
427        where
428            T: std::iter::IntoIterator<Item = (K, V)>,
429            K: std::convert::Into<std::string::String>,
430            V: std::convert::Into<std::string::String>,
431        {
432            use std::iter::Iterator;
433            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
434            self
435        }
436
437        /// Sets the value of [principal][crate::model::attribute_context::Peer::principal].
438        ///
439        /// # Example
440        /// ```ignore,no_run
441        /// # use google_cloud_rpc_context::model::attribute_context::Peer;
442        /// let x = Peer::new().set_principal("example");
443        /// ```
444        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
445            self.principal = v.into();
446            self
447        }
448
449        /// Sets the value of [region_code][crate::model::attribute_context::Peer::region_code].
450        ///
451        /// # Example
452        /// ```ignore,no_run
453        /// # use google_cloud_rpc_context::model::attribute_context::Peer;
454        /// let x = Peer::new().set_region_code("example");
455        /// ```
456        pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
457            self.region_code = v.into();
458            self
459        }
460    }
461
462    impl wkt::message::Message for Peer {
463        fn typename() -> &'static str {
464            "type.googleapis.com/google.rpc.context.AttributeContext.Peer"
465        }
466    }
467
468    /// This message defines attributes associated with API operations, such as
469    /// a network API request. The terminology is based on the conventions used
470    /// by Google APIs, Istio, and OpenAPI.
471    #[derive(Clone, Default, PartialEq)]
472    #[non_exhaustive]
473    pub struct Api {
474        /// The API service name. It is a logical identifier for a networked API,
475        /// such as "pubsub.googleapis.com". The naming syntax depends on the
476        /// API management system being used for handling the request.
477        pub service: std::string::String,
478
479        /// The API operation name. For gRPC requests, it is the fully qualified API
480        /// method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI
481        /// requests, it is the `operationId`, such as "getPet".
482        pub operation: std::string::String,
483
484        /// The API protocol used for sending the request, such as "http", "https",
485        /// "grpc", or "internal".
486        pub protocol: std::string::String,
487
488        /// The API version associated with the API operation above, such as "v1" or
489        /// "v1alpha1".
490        pub version: std::string::String,
491
492        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
493    }
494
495    impl Api {
496        /// Creates a new default instance.
497        pub fn new() -> Self {
498            std::default::Default::default()
499        }
500
501        /// Sets the value of [service][crate::model::attribute_context::Api::service].
502        ///
503        /// # Example
504        /// ```ignore,no_run
505        /// # use google_cloud_rpc_context::model::attribute_context::Api;
506        /// let x = Api::new().set_service("example");
507        /// ```
508        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
509            self.service = v.into();
510            self
511        }
512
513        /// Sets the value of [operation][crate::model::attribute_context::Api::operation].
514        ///
515        /// # Example
516        /// ```ignore,no_run
517        /// # use google_cloud_rpc_context::model::attribute_context::Api;
518        /// let x = Api::new().set_operation("example");
519        /// ```
520        pub fn set_operation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
521            self.operation = v.into();
522            self
523        }
524
525        /// Sets the value of [protocol][crate::model::attribute_context::Api::protocol].
526        ///
527        /// # Example
528        /// ```ignore,no_run
529        /// # use google_cloud_rpc_context::model::attribute_context::Api;
530        /// let x = Api::new().set_protocol("example");
531        /// ```
532        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
533            self.protocol = v.into();
534            self
535        }
536
537        /// Sets the value of [version][crate::model::attribute_context::Api::version].
538        ///
539        /// # Example
540        /// ```ignore,no_run
541        /// # use google_cloud_rpc_context::model::attribute_context::Api;
542        /// let x = Api::new().set_version("example");
543        /// ```
544        pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
545            self.version = v.into();
546            self
547        }
548    }
549
550    impl wkt::message::Message for Api {
551        fn typename() -> &'static str {
552            "type.googleapis.com/google.rpc.context.AttributeContext.Api"
553        }
554    }
555
556    /// This message defines request authentication attributes. Terminology is
557    /// based on the JSON Web Token (JWT) standard, but the terms also
558    /// correlate to concepts in other standards.
559    #[derive(Clone, Default, PartialEq)]
560    #[non_exhaustive]
561    pub struct Auth {
562        /// The authenticated principal. Reflects the issuer (`iss`) and subject
563        /// (`sub`) claims within a JWT. The issuer and subject should be `/`
564        /// delimited, with `/` percent-encoded within the subject fragment. For
565        /// Google accounts, the principal format is:
566        /// `https://accounts.google.com/{id}`
567        pub principal: std::string::String,
568
569        /// The intended audience(s) for this authentication information. Reflects
570        /// the audience (`aud`) claim within a JWT. The audience
571        /// value(s) depends on the `issuer`, but typically include one or more of
572        /// the following pieces of information:
573        ///
574        /// * The services intended to receive the credential. For example,
575        ///   [`https://pubsub.googleapis.com/`, `https://storage.googleapis.com/`].
576        /// * A set of service-based scopes. For example,
577        ///   [`https://www.googleapis.com/auth/cloud-platform`].
578        /// * The client id of an app, such as the Firebase project id for JWTs
579        ///   from Firebase Auth.
580        ///
581        /// Consult the documentation for the credential issuer to determine the
582        /// information provided.
583        pub audiences: std::vec::Vec<std::string::String>,
584
585        /// The authorized presenter of the credential. Reflects the optional
586        /// Authorized Presenter (`azp`) claim within a JWT or the
587        /// OAuth client id. For example, a Google Cloud Platform client id looks
588        /// as follows: "123456789012.apps.googleusercontent.com".
589        pub presenter: std::string::String,
590
591        /// Structured claims presented with the credential. JWTs include
592        /// `{key: value}` pairs for standard and private claims. The following
593        /// is a subset of the standard required and optional claims that would
594        /// typically be presented for a Google-based JWT:
595        ///
596        /// {'iss': 'accounts.google.com',
597        /// 'sub': '113289723416554971153',
598        /// 'aud': ['123456789012', 'pubsub.googleapis.com'],
599        /// 'azp': '123456789012.apps.googleusercontent.com',
600        /// 'email': 'jsmith@example.com',
601        /// 'iat': 1353601026,
602        /// 'exp': 1353604926}
603        ///
604        /// SAML assertions are similarly specified, but with an identity provider
605        /// dependent structure.
606        pub claims: std::option::Option<wkt::Struct>,
607
608        /// A list of access level resource names that allow resources to be
609        /// accessed by authenticated requester. It is part of Secure GCP processing
610        /// for the incoming request. An access level string has the format:
611        /// "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}"
612        ///
613        /// Example:
614        /// "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL"
615        pub access_levels: std::vec::Vec<std::string::String>,
616
617        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
618    }
619
620    impl Auth {
621        /// Creates a new default instance.
622        pub fn new() -> Self {
623            std::default::Default::default()
624        }
625
626        /// Sets the value of [principal][crate::model::attribute_context::Auth::principal].
627        ///
628        /// # Example
629        /// ```ignore,no_run
630        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
631        /// let x = Auth::new().set_principal("example");
632        /// ```
633        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
634            self.principal = v.into();
635            self
636        }
637
638        /// Sets the value of [audiences][crate::model::attribute_context::Auth::audiences].
639        ///
640        /// # Example
641        /// ```ignore,no_run
642        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
643        /// let x = Auth::new().set_audiences(["a", "b", "c"]);
644        /// ```
645        pub fn set_audiences<T, V>(mut self, v: T) -> Self
646        where
647            T: std::iter::IntoIterator<Item = V>,
648            V: std::convert::Into<std::string::String>,
649        {
650            use std::iter::Iterator;
651            self.audiences = v.into_iter().map(|i| i.into()).collect();
652            self
653        }
654
655        /// Sets the value of [presenter][crate::model::attribute_context::Auth::presenter].
656        ///
657        /// # Example
658        /// ```ignore,no_run
659        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
660        /// let x = Auth::new().set_presenter("example");
661        /// ```
662        pub fn set_presenter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
663            self.presenter = v.into();
664            self
665        }
666
667        /// Sets the value of [claims][crate::model::attribute_context::Auth::claims].
668        ///
669        /// # Example
670        /// ```ignore,no_run
671        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
672        /// use wkt::Struct;
673        /// let x = Auth::new().set_claims(Struct::default()/* use setters */);
674        /// ```
675        pub fn set_claims<T>(mut self, v: T) -> Self
676        where
677            T: std::convert::Into<wkt::Struct>,
678        {
679            self.claims = std::option::Option::Some(v.into());
680            self
681        }
682
683        /// Sets or clears the value of [claims][crate::model::attribute_context::Auth::claims].
684        ///
685        /// # Example
686        /// ```ignore,no_run
687        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
688        /// use wkt::Struct;
689        /// let x = Auth::new().set_or_clear_claims(Some(Struct::default()/* use setters */));
690        /// let x = Auth::new().set_or_clear_claims(None::<Struct>);
691        /// ```
692        pub fn set_or_clear_claims<T>(mut self, v: std::option::Option<T>) -> Self
693        where
694            T: std::convert::Into<wkt::Struct>,
695        {
696            self.claims = v.map(|x| x.into());
697            self
698        }
699
700        /// Sets the value of [access_levels][crate::model::attribute_context::Auth::access_levels].
701        ///
702        /// # Example
703        /// ```ignore,no_run
704        /// # use google_cloud_rpc_context::model::attribute_context::Auth;
705        /// let x = Auth::new().set_access_levels(["a", "b", "c"]);
706        /// ```
707        pub fn set_access_levels<T, V>(mut self, v: T) -> Self
708        where
709            T: std::iter::IntoIterator<Item = V>,
710            V: std::convert::Into<std::string::String>,
711        {
712            use std::iter::Iterator;
713            self.access_levels = v.into_iter().map(|i| i.into()).collect();
714            self
715        }
716    }
717
718    impl wkt::message::Message for Auth {
719        fn typename() -> &'static str {
720            "type.googleapis.com/google.rpc.context.AttributeContext.Auth"
721        }
722    }
723
724    /// This message defines attributes for an HTTP request. If the actual
725    /// request is not an HTTP request, the runtime system should try to map
726    /// the actual request to an equivalent HTTP request.
727    #[derive(Clone, Default, PartialEq)]
728    #[non_exhaustive]
729    pub struct Request {
730        /// The unique ID for a request, which can be propagated to downstream
731        /// systems. The ID should have low probability of collision
732        /// within a single day for a specific service.
733        pub id: std::string::String,
734
735        /// The HTTP request method, such as `GET`, `POST`.
736        pub method: std::string::String,
737
738        /// The HTTP request headers. If multiple headers share the same key, they
739        /// must be merged according to the HTTP spec. All header keys must be
740        /// lowercased, because HTTP header keys are case-insensitive.
741        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
742
743        /// The HTTP URL path, excluding the query parameters.
744        pub path: std::string::String,
745
746        /// The HTTP request `Host` header value.
747        pub host: std::string::String,
748
749        /// The HTTP URL scheme, such as `http` and `https`.
750        pub scheme: std::string::String,
751
752        /// The HTTP URL query in the format of `name1=value1&name2=value2`, as it
753        /// appears in the first line of the HTTP request. No decoding is performed.
754        pub query: std::string::String,
755
756        /// The timestamp when the `destination` service receives the last byte of
757        /// the request.
758        pub time: std::option::Option<wkt::Timestamp>,
759
760        /// The HTTP request size in bytes. If unknown, it must be -1.
761        pub size: i64,
762
763        /// The network protocol used with the request, such as "http/1.1",
764        /// "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See
765        /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
766        /// for details.
767        pub protocol: std::string::String,
768
769        /// A special parameter for request reason. It is used by security systems
770        /// to associate auditing information with a request.
771        pub reason: std::string::String,
772
773        /// The request authentication. May be absent for unauthenticated requests.
774        /// Derived from the HTTP request `Authorization` header or equivalent.
775        pub auth: std::option::Option<crate::model::attribute_context::Auth>,
776
777        /// The values from Origin header from the HTTP request, such as
778        /// `https://console.cloud.google.com`. Modern browsers can only have one
779        /// origin. Special browsers and/or HTTP clients may require multiple
780        /// origins.
781        pub origin: std::string::String,
782
783        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
784    }
785
786    impl Request {
787        /// Creates a new default instance.
788        pub fn new() -> Self {
789            std::default::Default::default()
790        }
791
792        /// Sets the value of [id][crate::model::attribute_context::Request::id].
793        ///
794        /// # Example
795        /// ```ignore,no_run
796        /// # use google_cloud_rpc_context::model::attribute_context::Request;
797        /// let x = Request::new().set_id("example");
798        /// ```
799        pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
800            self.id = v.into();
801            self
802        }
803
804        /// Sets the value of [method][crate::model::attribute_context::Request::method].
805        ///
806        /// # Example
807        /// ```ignore,no_run
808        /// # use google_cloud_rpc_context::model::attribute_context::Request;
809        /// let x = Request::new().set_method("example");
810        /// ```
811        pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
812            self.method = v.into();
813            self
814        }
815
816        /// Sets the value of [headers][crate::model::attribute_context::Request::headers].
817        ///
818        /// # Example
819        /// ```ignore,no_run
820        /// # use google_cloud_rpc_context::model::attribute_context::Request;
821        /// let x = Request::new().set_headers([
822        ///     ("key0", "abc"),
823        ///     ("key1", "xyz"),
824        /// ]);
825        /// ```
826        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
827        where
828            T: std::iter::IntoIterator<Item = (K, V)>,
829            K: std::convert::Into<std::string::String>,
830            V: std::convert::Into<std::string::String>,
831        {
832            use std::iter::Iterator;
833            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
834            self
835        }
836
837        /// Sets the value of [path][crate::model::attribute_context::Request::path].
838        ///
839        /// # Example
840        /// ```ignore,no_run
841        /// # use google_cloud_rpc_context::model::attribute_context::Request;
842        /// let x = Request::new().set_path("example");
843        /// ```
844        pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
845            self.path = v.into();
846            self
847        }
848
849        /// Sets the value of [host][crate::model::attribute_context::Request::host].
850        ///
851        /// # Example
852        /// ```ignore,no_run
853        /// # use google_cloud_rpc_context::model::attribute_context::Request;
854        /// let x = Request::new().set_host("example");
855        /// ```
856        pub fn set_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
857            self.host = v.into();
858            self
859        }
860
861        /// Sets the value of [scheme][crate::model::attribute_context::Request::scheme].
862        ///
863        /// # Example
864        /// ```ignore,no_run
865        /// # use google_cloud_rpc_context::model::attribute_context::Request;
866        /// let x = Request::new().set_scheme("example");
867        /// ```
868        pub fn set_scheme<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
869            self.scheme = v.into();
870            self
871        }
872
873        /// Sets the value of [query][crate::model::attribute_context::Request::query].
874        ///
875        /// # Example
876        /// ```ignore,no_run
877        /// # use google_cloud_rpc_context::model::attribute_context::Request;
878        /// let x = Request::new().set_query("example");
879        /// ```
880        pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
881            self.query = v.into();
882            self
883        }
884
885        /// Sets the value of [time][crate::model::attribute_context::Request::time].
886        ///
887        /// # Example
888        /// ```ignore,no_run
889        /// # use google_cloud_rpc_context::model::attribute_context::Request;
890        /// use wkt::Timestamp;
891        /// let x = Request::new().set_time(Timestamp::default()/* use setters */);
892        /// ```
893        pub fn set_time<T>(mut self, v: T) -> Self
894        where
895            T: std::convert::Into<wkt::Timestamp>,
896        {
897            self.time = std::option::Option::Some(v.into());
898            self
899        }
900
901        /// Sets or clears the value of [time][crate::model::attribute_context::Request::time].
902        ///
903        /// # Example
904        /// ```ignore,no_run
905        /// # use google_cloud_rpc_context::model::attribute_context::Request;
906        /// use wkt::Timestamp;
907        /// let x = Request::new().set_or_clear_time(Some(Timestamp::default()/* use setters */));
908        /// let x = Request::new().set_or_clear_time(None::<Timestamp>);
909        /// ```
910        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
911        where
912            T: std::convert::Into<wkt::Timestamp>,
913        {
914            self.time = v.map(|x| x.into());
915            self
916        }
917
918        /// Sets the value of [size][crate::model::attribute_context::Request::size].
919        ///
920        /// # Example
921        /// ```ignore,no_run
922        /// # use google_cloud_rpc_context::model::attribute_context::Request;
923        /// let x = Request::new().set_size(42);
924        /// ```
925        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
926            self.size = v.into();
927            self
928        }
929
930        /// Sets the value of [protocol][crate::model::attribute_context::Request::protocol].
931        ///
932        /// # Example
933        /// ```ignore,no_run
934        /// # use google_cloud_rpc_context::model::attribute_context::Request;
935        /// let x = Request::new().set_protocol("example");
936        /// ```
937        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
938            self.protocol = v.into();
939            self
940        }
941
942        /// Sets the value of [reason][crate::model::attribute_context::Request::reason].
943        ///
944        /// # Example
945        /// ```ignore,no_run
946        /// # use google_cloud_rpc_context::model::attribute_context::Request;
947        /// let x = Request::new().set_reason("example");
948        /// ```
949        pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
950            self.reason = v.into();
951            self
952        }
953
954        /// Sets the value of [auth][crate::model::attribute_context::Request::auth].
955        ///
956        /// # Example
957        /// ```ignore,no_run
958        /// # use google_cloud_rpc_context::model::attribute_context::Request;
959        /// use google_cloud_rpc_context::model::attribute_context::Auth;
960        /// let x = Request::new().set_auth(Auth::default()/* use setters */);
961        /// ```
962        pub fn set_auth<T>(mut self, v: T) -> Self
963        where
964            T: std::convert::Into<crate::model::attribute_context::Auth>,
965        {
966            self.auth = std::option::Option::Some(v.into());
967            self
968        }
969
970        /// Sets or clears the value of [auth][crate::model::attribute_context::Request::auth].
971        ///
972        /// # Example
973        /// ```ignore,no_run
974        /// # use google_cloud_rpc_context::model::attribute_context::Request;
975        /// use google_cloud_rpc_context::model::attribute_context::Auth;
976        /// let x = Request::new().set_or_clear_auth(Some(Auth::default()/* use setters */));
977        /// let x = Request::new().set_or_clear_auth(None::<Auth>);
978        /// ```
979        pub fn set_or_clear_auth<T>(mut self, v: std::option::Option<T>) -> Self
980        where
981            T: std::convert::Into<crate::model::attribute_context::Auth>,
982        {
983            self.auth = v.map(|x| x.into());
984            self
985        }
986
987        /// Sets the value of [origin][crate::model::attribute_context::Request::origin].
988        ///
989        /// # Example
990        /// ```ignore,no_run
991        /// # use google_cloud_rpc_context::model::attribute_context::Request;
992        /// let x = Request::new().set_origin("example");
993        /// ```
994        pub fn set_origin<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
995            self.origin = v.into();
996            self
997        }
998    }
999
1000    impl wkt::message::Message for Request {
1001        fn typename() -> &'static str {
1002            "type.googleapis.com/google.rpc.context.AttributeContext.Request"
1003        }
1004    }
1005
1006    /// This message defines attributes for a typical network response. It
1007    /// generally models semantics of an HTTP response.
1008    #[derive(Clone, Default, PartialEq)]
1009    #[non_exhaustive]
1010    pub struct Response {
1011        /// The HTTP response status code, such as `200` and `404`.
1012        pub code: i64,
1013
1014        /// The HTTP response size in bytes. If unknown, it must be -1.
1015        pub size: i64,
1016
1017        /// The HTTP response headers. If multiple headers share the same key, they
1018        /// must be merged according to HTTP spec. All header keys must be
1019        /// lowercased, because HTTP header keys are case-insensitive.
1020        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
1021
1022        /// The timestamp when the `destination` service sends the last byte of
1023        /// the response.
1024        pub time: std::option::Option<wkt::Timestamp>,
1025
1026        /// The amount of time it takes the backend service to fully respond to a
1027        /// request. Measured from when the destination service starts to send the
1028        /// request to the backend until when the destination service receives the
1029        /// complete response from the backend.
1030        pub backend_latency: std::option::Option<wkt::Duration>,
1031
1032        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1033    }
1034
1035    impl Response {
1036        /// Creates a new default instance.
1037        pub fn new() -> Self {
1038            std::default::Default::default()
1039        }
1040
1041        /// Sets the value of [code][crate::model::attribute_context::Response::code].
1042        ///
1043        /// # Example
1044        /// ```ignore,no_run
1045        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1046        /// let x = Response::new().set_code(42);
1047        /// ```
1048        pub fn set_code<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1049            self.code = v.into();
1050            self
1051        }
1052
1053        /// Sets the value of [size][crate::model::attribute_context::Response::size].
1054        ///
1055        /// # Example
1056        /// ```ignore,no_run
1057        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1058        /// let x = Response::new().set_size(42);
1059        /// ```
1060        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1061            self.size = v.into();
1062            self
1063        }
1064
1065        /// Sets the value of [headers][crate::model::attribute_context::Response::headers].
1066        ///
1067        /// # Example
1068        /// ```ignore,no_run
1069        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1070        /// let x = Response::new().set_headers([
1071        ///     ("key0", "abc"),
1072        ///     ("key1", "xyz"),
1073        /// ]);
1074        /// ```
1075        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
1076        where
1077            T: std::iter::IntoIterator<Item = (K, V)>,
1078            K: std::convert::Into<std::string::String>,
1079            V: std::convert::Into<std::string::String>,
1080        {
1081            use std::iter::Iterator;
1082            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1083            self
1084        }
1085
1086        /// Sets the value of [time][crate::model::attribute_context::Response::time].
1087        ///
1088        /// # Example
1089        /// ```ignore,no_run
1090        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1091        /// use wkt::Timestamp;
1092        /// let x = Response::new().set_time(Timestamp::default()/* use setters */);
1093        /// ```
1094        pub fn set_time<T>(mut self, v: T) -> Self
1095        where
1096            T: std::convert::Into<wkt::Timestamp>,
1097        {
1098            self.time = std::option::Option::Some(v.into());
1099            self
1100        }
1101
1102        /// Sets or clears the value of [time][crate::model::attribute_context::Response::time].
1103        ///
1104        /// # Example
1105        /// ```ignore,no_run
1106        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1107        /// use wkt::Timestamp;
1108        /// let x = Response::new().set_or_clear_time(Some(Timestamp::default()/* use setters */));
1109        /// let x = Response::new().set_or_clear_time(None::<Timestamp>);
1110        /// ```
1111        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
1112        where
1113            T: std::convert::Into<wkt::Timestamp>,
1114        {
1115            self.time = v.map(|x| x.into());
1116            self
1117        }
1118
1119        /// Sets the value of [backend_latency][crate::model::attribute_context::Response::backend_latency].
1120        ///
1121        /// # Example
1122        /// ```ignore,no_run
1123        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1124        /// use wkt::Duration;
1125        /// let x = Response::new().set_backend_latency(Duration::default()/* use setters */);
1126        /// ```
1127        pub fn set_backend_latency<T>(mut self, v: T) -> Self
1128        where
1129            T: std::convert::Into<wkt::Duration>,
1130        {
1131            self.backend_latency = std::option::Option::Some(v.into());
1132            self
1133        }
1134
1135        /// Sets or clears the value of [backend_latency][crate::model::attribute_context::Response::backend_latency].
1136        ///
1137        /// # Example
1138        /// ```ignore,no_run
1139        /// # use google_cloud_rpc_context::model::attribute_context::Response;
1140        /// use wkt::Duration;
1141        /// let x = Response::new().set_or_clear_backend_latency(Some(Duration::default()/* use setters */));
1142        /// let x = Response::new().set_or_clear_backend_latency(None::<Duration>);
1143        /// ```
1144        pub fn set_or_clear_backend_latency<T>(mut self, v: std::option::Option<T>) -> Self
1145        where
1146            T: std::convert::Into<wkt::Duration>,
1147        {
1148            self.backend_latency = v.map(|x| x.into());
1149            self
1150        }
1151    }
1152
1153    impl wkt::message::Message for Response {
1154        fn typename() -> &'static str {
1155            "type.googleapis.com/google.rpc.context.AttributeContext.Response"
1156        }
1157    }
1158
1159    /// This message defines core attributes for a resource. A resource is an
1160    /// addressable (named) entity provided by the destination service. For
1161    /// example, a file stored on a network storage service.
1162    #[derive(Clone, Default, PartialEq)]
1163    #[non_exhaustive]
1164    pub struct Resource {
1165        /// The name of the service that this resource belongs to, such as
1166        /// `pubsub.googleapis.com`. The service may be different from the DNS
1167        /// hostname that actually serves the request.
1168        pub service: std::string::String,
1169
1170        /// The stable identifier (name) of a resource on the `service`. A resource
1171        /// can be logically identified as "//{resource.service}/{resource.name}".
1172        /// The differences between a resource name and a URI are:
1173        ///
1174        /// * Resource name is a logical identifier, independent of network
1175        ///   protocol and API version. For example,
1176        ///   `//pubsub.googleapis.com/projects/123/topics/news-feed`.
1177        /// * URI often includes protocol and version information, so it can
1178        ///   be used directly by applications. For example,
1179        ///   `<https://pubsub.googleapis.com/v1/projects/123/topics/news-feed>`.
1180        ///
1181        /// See <https://cloud.google.com/apis/design/resource_names> for details.
1182        pub name: std::string::String,
1183
1184        /// The type of the resource. The syntax is platform-specific because
1185        /// different platforms define their resources differently.
1186        ///
1187        /// For Google APIs, the type format must be "{service}/{kind}", such as
1188        /// "pubsub.googleapis.com/Topic".
1189        pub r#type: std::string::String,
1190
1191        /// The labels or tags on the resource, such as AWS resource tags and
1192        /// Kubernetes resource labels.
1193        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1194
1195        /// The unique identifier of the resource. UID is unique in the time
1196        /// and space for this resource within the scope of the service. It is
1197        /// typically generated by the server on successful creation of a resource
1198        /// and must not be changed. UID is used to uniquely identify resources
1199        /// with resource name reuses. This should be a UUID4.
1200        pub uid: std::string::String,
1201
1202        /// Annotations is an unstructured key-value map stored with a resource that
1203        /// may be set by external tools to store and retrieve arbitrary metadata.
1204        /// They are not queryable and should be preserved when modifying objects.
1205        ///
1206        /// More info:
1207        /// <https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/>
1208        pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
1209
1210        /// Mutable. The display name set by clients. Must be <= 63 characters.
1211        pub display_name: std::string::String,
1212
1213        /// Output only. The timestamp when the resource was created. This may
1214        /// be either the time creation was initiated or when it was completed.
1215        pub create_time: std::option::Option<wkt::Timestamp>,
1216
1217        /// Output only. The timestamp when the resource was last updated. Any
1218        /// change to the resource made by users must refresh this value.
1219        /// Changes to a resource made by the service should refresh this value.
1220        pub update_time: std::option::Option<wkt::Timestamp>,
1221
1222        /// Output only. The timestamp when the resource was deleted.
1223        /// If the resource is not deleted, this must be empty.
1224        pub delete_time: std::option::Option<wkt::Timestamp>,
1225
1226        /// Output only. An opaque value that uniquely identifies a version or
1227        /// generation of a resource. It can be used to confirm that the client
1228        /// and server agree on the ordering of a resource being written.
1229        pub etag: std::string::String,
1230
1231        /// Immutable. The location of the resource. The location encoding is
1232        /// specific to the service provider, and new encoding may be introduced
1233        /// as the service evolves.
1234        ///
1235        /// For Google Cloud products, the encoding is what is used by Google Cloud
1236        /// APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The
1237        /// semantics of `location` is identical to the
1238        /// `cloud.googleapis.com/location` label used by some Google Cloud APIs.
1239        pub location: std::string::String,
1240
1241        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1242    }
1243
1244    impl Resource {
1245        /// Creates a new default instance.
1246        pub fn new() -> Self {
1247            std::default::Default::default()
1248        }
1249
1250        /// Sets the value of [service][crate::model::attribute_context::Resource::service].
1251        ///
1252        /// # Example
1253        /// ```ignore,no_run
1254        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1255        /// let x = Resource::new().set_service("example");
1256        /// ```
1257        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1258            self.service = v.into();
1259            self
1260        }
1261
1262        /// Sets the value of [name][crate::model::attribute_context::Resource::name].
1263        ///
1264        /// # Example
1265        /// ```ignore,no_run
1266        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1267        /// let x = Resource::new().set_name("example");
1268        /// ```
1269        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1270            self.name = v.into();
1271            self
1272        }
1273
1274        /// Sets the value of [r#type][crate::model::attribute_context::Resource::type].
1275        ///
1276        /// # Example
1277        /// ```ignore,no_run
1278        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1279        /// let x = Resource::new().set_type("example");
1280        /// ```
1281        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1282            self.r#type = v.into();
1283            self
1284        }
1285
1286        /// Sets the value of [labels][crate::model::attribute_context::Resource::labels].
1287        ///
1288        /// # Example
1289        /// ```ignore,no_run
1290        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1291        /// let x = Resource::new().set_labels([
1292        ///     ("key0", "abc"),
1293        ///     ("key1", "xyz"),
1294        /// ]);
1295        /// ```
1296        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1297        where
1298            T: std::iter::IntoIterator<Item = (K, V)>,
1299            K: std::convert::Into<std::string::String>,
1300            V: std::convert::Into<std::string::String>,
1301        {
1302            use std::iter::Iterator;
1303            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1304            self
1305        }
1306
1307        /// Sets the value of [uid][crate::model::attribute_context::Resource::uid].
1308        ///
1309        /// # Example
1310        /// ```ignore,no_run
1311        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1312        /// let x = Resource::new().set_uid("example");
1313        /// ```
1314        pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1315            self.uid = v.into();
1316            self
1317        }
1318
1319        /// Sets the value of [annotations][crate::model::attribute_context::Resource::annotations].
1320        ///
1321        /// # Example
1322        /// ```ignore,no_run
1323        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1324        /// let x = Resource::new().set_annotations([
1325        ///     ("key0", "abc"),
1326        ///     ("key1", "xyz"),
1327        /// ]);
1328        /// ```
1329        pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
1330        where
1331            T: std::iter::IntoIterator<Item = (K, V)>,
1332            K: std::convert::Into<std::string::String>,
1333            V: std::convert::Into<std::string::String>,
1334        {
1335            use std::iter::Iterator;
1336            self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1337            self
1338        }
1339
1340        /// Sets the value of [display_name][crate::model::attribute_context::Resource::display_name].
1341        ///
1342        /// # Example
1343        /// ```ignore,no_run
1344        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1345        /// let x = Resource::new().set_display_name("example");
1346        /// ```
1347        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
1348            mut self,
1349            v: T,
1350        ) -> Self {
1351            self.display_name = v.into();
1352            self
1353        }
1354
1355        /// Sets the value of [create_time][crate::model::attribute_context::Resource::create_time].
1356        ///
1357        /// # Example
1358        /// ```ignore,no_run
1359        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1360        /// use wkt::Timestamp;
1361        /// let x = Resource::new().set_create_time(Timestamp::default()/* use setters */);
1362        /// ```
1363        pub fn set_create_time<T>(mut self, v: T) -> Self
1364        where
1365            T: std::convert::Into<wkt::Timestamp>,
1366        {
1367            self.create_time = std::option::Option::Some(v.into());
1368            self
1369        }
1370
1371        /// Sets or clears the value of [create_time][crate::model::attribute_context::Resource::create_time].
1372        ///
1373        /// # Example
1374        /// ```ignore,no_run
1375        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1376        /// use wkt::Timestamp;
1377        /// let x = Resource::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
1378        /// let x = Resource::new().set_or_clear_create_time(None::<Timestamp>);
1379        /// ```
1380        pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
1381        where
1382            T: std::convert::Into<wkt::Timestamp>,
1383        {
1384            self.create_time = v.map(|x| x.into());
1385            self
1386        }
1387
1388        /// Sets the value of [update_time][crate::model::attribute_context::Resource::update_time].
1389        ///
1390        /// # Example
1391        /// ```ignore,no_run
1392        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1393        /// use wkt::Timestamp;
1394        /// let x = Resource::new().set_update_time(Timestamp::default()/* use setters */);
1395        /// ```
1396        pub fn set_update_time<T>(mut self, v: T) -> Self
1397        where
1398            T: std::convert::Into<wkt::Timestamp>,
1399        {
1400            self.update_time = std::option::Option::Some(v.into());
1401            self
1402        }
1403
1404        /// Sets or clears the value of [update_time][crate::model::attribute_context::Resource::update_time].
1405        ///
1406        /// # Example
1407        /// ```ignore,no_run
1408        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1409        /// use wkt::Timestamp;
1410        /// let x = Resource::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
1411        /// let x = Resource::new().set_or_clear_update_time(None::<Timestamp>);
1412        /// ```
1413        pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
1414        where
1415            T: std::convert::Into<wkt::Timestamp>,
1416        {
1417            self.update_time = v.map(|x| x.into());
1418            self
1419        }
1420
1421        /// Sets the value of [delete_time][crate::model::attribute_context::Resource::delete_time].
1422        ///
1423        /// # Example
1424        /// ```ignore,no_run
1425        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1426        /// use wkt::Timestamp;
1427        /// let x = Resource::new().set_delete_time(Timestamp::default()/* use setters */);
1428        /// ```
1429        pub fn set_delete_time<T>(mut self, v: T) -> Self
1430        where
1431            T: std::convert::Into<wkt::Timestamp>,
1432        {
1433            self.delete_time = std::option::Option::Some(v.into());
1434            self
1435        }
1436
1437        /// Sets or clears the value of [delete_time][crate::model::attribute_context::Resource::delete_time].
1438        ///
1439        /// # Example
1440        /// ```ignore,no_run
1441        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1442        /// use wkt::Timestamp;
1443        /// let x = Resource::new().set_or_clear_delete_time(Some(Timestamp::default()/* use setters */));
1444        /// let x = Resource::new().set_or_clear_delete_time(None::<Timestamp>);
1445        /// ```
1446        pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
1447        where
1448            T: std::convert::Into<wkt::Timestamp>,
1449        {
1450            self.delete_time = v.map(|x| x.into());
1451            self
1452        }
1453
1454        /// Sets the value of [etag][crate::model::attribute_context::Resource::etag].
1455        ///
1456        /// # Example
1457        /// ```ignore,no_run
1458        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1459        /// let x = Resource::new().set_etag("example");
1460        /// ```
1461        pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1462            self.etag = v.into();
1463            self
1464        }
1465
1466        /// Sets the value of [location][crate::model::attribute_context::Resource::location].
1467        ///
1468        /// # Example
1469        /// ```ignore,no_run
1470        /// # use google_cloud_rpc_context::model::attribute_context::Resource;
1471        /// let x = Resource::new().set_location("example");
1472        /// ```
1473        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1474            self.location = v.into();
1475            self
1476        }
1477    }
1478
1479    impl wkt::message::Message for Resource {
1480        fn typename() -> &'static str {
1481            "type.googleapis.com/google.rpc.context.AttributeContext.Resource"
1482        }
1483    }
1484}
1485
1486/// `AuditContext` provides information that is needed for audit logging.
1487#[derive(Clone, Default, PartialEq)]
1488#[non_exhaustive]
1489pub struct AuditContext {
1490    /// Serialized audit log.
1491    pub audit_log: ::bytes::Bytes,
1492
1493    /// An API request message that is scrubbed based on the method annotation.
1494    /// This field should only be filled if audit_log field is present.
1495    /// Service Control will use this to assemble a complete log for Cloud Audit
1496    /// Logs and Google internal audit logs.
1497    pub scrubbed_request: std::option::Option<wkt::Struct>,
1498
1499    /// An API response message that is scrubbed based on the method annotation.
1500    /// This field should only be filled if audit_log field is present.
1501    /// Service Control will use this to assemble a complete log for Cloud Audit
1502    /// Logs and Google internal audit logs.
1503    pub scrubbed_response: std::option::Option<wkt::Struct>,
1504
1505    /// Number of scrubbed response items.
1506    pub scrubbed_response_item_count: i32,
1507
1508    /// Audit resource name which is scrubbed.
1509    pub target_resource: std::string::String,
1510
1511    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1512}
1513
1514impl AuditContext {
1515    /// Creates a new default instance.
1516    pub fn new() -> Self {
1517        std::default::Default::default()
1518    }
1519
1520    /// Sets the value of [audit_log][crate::model::AuditContext::audit_log].
1521    ///
1522    /// # Example
1523    /// ```ignore,no_run
1524    /// # use google_cloud_rpc_context::model::AuditContext;
1525    /// let x = AuditContext::new().set_audit_log(bytes::Bytes::from_static(b"example"));
1526    /// ```
1527    pub fn set_audit_log<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
1528        self.audit_log = v.into();
1529        self
1530    }
1531
1532    /// Sets the value of [scrubbed_request][crate::model::AuditContext::scrubbed_request].
1533    ///
1534    /// # Example
1535    /// ```ignore,no_run
1536    /// # use google_cloud_rpc_context::model::AuditContext;
1537    /// use wkt::Struct;
1538    /// let x = AuditContext::new().set_scrubbed_request(Struct::default()/* use setters */);
1539    /// ```
1540    pub fn set_scrubbed_request<T>(mut self, v: T) -> Self
1541    where
1542        T: std::convert::Into<wkt::Struct>,
1543    {
1544        self.scrubbed_request = std::option::Option::Some(v.into());
1545        self
1546    }
1547
1548    /// Sets or clears the value of [scrubbed_request][crate::model::AuditContext::scrubbed_request].
1549    ///
1550    /// # Example
1551    /// ```ignore,no_run
1552    /// # use google_cloud_rpc_context::model::AuditContext;
1553    /// use wkt::Struct;
1554    /// let x = AuditContext::new().set_or_clear_scrubbed_request(Some(Struct::default()/* use setters */));
1555    /// let x = AuditContext::new().set_or_clear_scrubbed_request(None::<Struct>);
1556    /// ```
1557    pub fn set_or_clear_scrubbed_request<T>(mut self, v: std::option::Option<T>) -> Self
1558    where
1559        T: std::convert::Into<wkt::Struct>,
1560    {
1561        self.scrubbed_request = v.map(|x| x.into());
1562        self
1563    }
1564
1565    /// Sets the value of [scrubbed_response][crate::model::AuditContext::scrubbed_response].
1566    ///
1567    /// # Example
1568    /// ```ignore,no_run
1569    /// # use google_cloud_rpc_context::model::AuditContext;
1570    /// use wkt::Struct;
1571    /// let x = AuditContext::new().set_scrubbed_response(Struct::default()/* use setters */);
1572    /// ```
1573    pub fn set_scrubbed_response<T>(mut self, v: T) -> Self
1574    where
1575        T: std::convert::Into<wkt::Struct>,
1576    {
1577        self.scrubbed_response = std::option::Option::Some(v.into());
1578        self
1579    }
1580
1581    /// Sets or clears the value of [scrubbed_response][crate::model::AuditContext::scrubbed_response].
1582    ///
1583    /// # Example
1584    /// ```ignore,no_run
1585    /// # use google_cloud_rpc_context::model::AuditContext;
1586    /// use wkt::Struct;
1587    /// let x = AuditContext::new().set_or_clear_scrubbed_response(Some(Struct::default()/* use setters */));
1588    /// let x = AuditContext::new().set_or_clear_scrubbed_response(None::<Struct>);
1589    /// ```
1590    pub fn set_or_clear_scrubbed_response<T>(mut self, v: std::option::Option<T>) -> Self
1591    where
1592        T: std::convert::Into<wkt::Struct>,
1593    {
1594        self.scrubbed_response = v.map(|x| x.into());
1595        self
1596    }
1597
1598    /// Sets the value of [scrubbed_response_item_count][crate::model::AuditContext::scrubbed_response_item_count].
1599    ///
1600    /// # Example
1601    /// ```ignore,no_run
1602    /// # use google_cloud_rpc_context::model::AuditContext;
1603    /// let x = AuditContext::new().set_scrubbed_response_item_count(42);
1604    /// ```
1605    pub fn set_scrubbed_response_item_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1606        self.scrubbed_response_item_count = v.into();
1607        self
1608    }
1609
1610    /// Sets the value of [target_resource][crate::model::AuditContext::target_resource].
1611    ///
1612    /// # Example
1613    /// ```ignore,no_run
1614    /// # use google_cloud_rpc_context::model::AuditContext;
1615    /// let x = AuditContext::new().set_target_resource("example");
1616    /// ```
1617    pub fn set_target_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1618        self.target_resource = v.into();
1619        self
1620    }
1621}
1622
1623impl wkt::message::Message for AuditContext {
1624    fn typename() -> &'static str {
1625        "type.googleapis.com/google.rpc.context.AuditContext"
1626    }
1627}