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