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