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_with;
23extern crate std;
24extern crate wkt;
25
26/// This message defines the standard attribute vocabulary for Google APIs.
27///
28/// An attribute is a piece of metadata that describes an activity on a network
29/// service. For example, the size of an HTTP request, or the status code of
30/// an HTTP response.
31///
32/// Each attribute has a type and a name, which is logically defined as
33/// a proto message field in `AttributeContext`. The field type becomes the
34/// attribute type, and the field path becomes the attribute name. For example,
35/// the attribute `source.ip` maps to field `AttributeContext.source.ip`.
36///
37/// This message definition is guaranteed not to have any wire breaking change.
38/// So you can use it directly for passing attributes across different systems.
39///
40/// NOTE: Different system may generate different subset of attributes. Please
41/// verify the system specification before relying on an attribute generated
42/// a system.
43#[serde_with::serde_as]
44#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
45#[serde(default, rename_all = "camelCase")]
46#[non_exhaustive]
47pub struct AttributeContext {
48    /// The origin of a network activity. In a multi hop network activity,
49    /// the origin represents the sender of the first hop. For the first hop,
50    /// the `source` and the `origin` must have the same content.
51    #[serde(skip_serializing_if = "std::option::Option::is_none")]
52    pub origin: std::option::Option<crate::model::attribute_context::Peer>,
53
54    /// The source of a network activity, such as starting a TCP connection.
55    /// In a multi hop network activity, the source represents the sender of the
56    /// last hop.
57    #[serde(skip_serializing_if = "std::option::Option::is_none")]
58    pub source: std::option::Option<crate::model::attribute_context::Peer>,
59
60    /// The destination of a network activity, such as accepting a TCP connection.
61    /// In a multi hop network activity, the destination represents the receiver of
62    /// the last hop.
63    #[serde(skip_serializing_if = "std::option::Option::is_none")]
64    pub destination: std::option::Option<crate::model::attribute_context::Peer>,
65
66    /// Represents a network request, such as an HTTP request.
67    #[serde(skip_serializing_if = "std::option::Option::is_none")]
68    pub request: std::option::Option<crate::model::attribute_context::Request>,
69
70    /// Represents a network response, such as an HTTP response.
71    #[serde(skip_serializing_if = "std::option::Option::is_none")]
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    #[serde(skip_serializing_if = "std::option::Option::is_none")]
78    pub resource: std::option::Option<crate::model::attribute_context::Resource>,
79
80    /// Represents an API operation that is involved to a network activity.
81    #[serde(skip_serializing_if = "std::option::Option::is_none")]
82    pub api: std::option::Option<crate::model::attribute_context::Api>,
83
84    /// Supports extensions for advanced use cases, such as logs and metrics.
85    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
86    pub extensions: std::vec::Vec<wkt::Any>,
87}
88
89impl AttributeContext {
90    pub fn new() -> Self {
91        std::default::Default::default()
92    }
93
94    /// Sets the value of [origin][crate::model::AttributeContext::origin].
95    pub fn set_origin<
96        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Peer>>,
97    >(
98        mut self,
99        v: T,
100    ) -> Self {
101        self.origin = v.into();
102        self
103    }
104
105    /// Sets the value of [source][crate::model::AttributeContext::source].
106    pub fn set_source<
107        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Peer>>,
108    >(
109        mut self,
110        v: T,
111    ) -> Self {
112        self.source = v.into();
113        self
114    }
115
116    /// Sets the value of [destination][crate::model::AttributeContext::destination].
117    pub fn set_destination<
118        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Peer>>,
119    >(
120        mut self,
121        v: T,
122    ) -> Self {
123        self.destination = v.into();
124        self
125    }
126
127    /// Sets the value of [request][crate::model::AttributeContext::request].
128    pub fn set_request<
129        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Request>>,
130    >(
131        mut self,
132        v: T,
133    ) -> Self {
134        self.request = v.into();
135        self
136    }
137
138    /// Sets the value of [response][crate::model::AttributeContext::response].
139    pub fn set_response<
140        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Response>>,
141    >(
142        mut self,
143        v: T,
144    ) -> Self {
145        self.response = v.into();
146        self
147    }
148
149    /// Sets the value of [resource][crate::model::AttributeContext::resource].
150    pub fn set_resource<
151        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Resource>>,
152    >(
153        mut self,
154        v: T,
155    ) -> Self {
156        self.resource = v.into();
157        self
158    }
159
160    /// Sets the value of [api][crate::model::AttributeContext::api].
161    pub fn set_api<
162        T: std::convert::Into<std::option::Option<crate::model::attribute_context::Api>>,
163    >(
164        mut self,
165        v: T,
166    ) -> Self {
167        self.api = v.into();
168        self
169    }
170
171    /// Sets the value of [extensions][crate::model::AttributeContext::extensions].
172    pub fn set_extensions<T, V>(mut self, v: T) -> Self
173    where
174        T: std::iter::IntoIterator<Item = V>,
175        V: std::convert::Into<wkt::Any>,
176    {
177        use std::iter::Iterator;
178        self.extensions = v.into_iter().map(|i| i.into()).collect();
179        self
180    }
181}
182
183impl wkt::message::Message for AttributeContext {
184    fn typename() -> &'static str {
185        "type.googleapis.com/google.rpc.context.AttributeContext"
186    }
187}
188
189/// Defines additional types related to AttributeContext
190pub mod attribute_context {
191    #[allow(unused_imports)]
192    use super::*;
193
194    /// This message defines attributes for a node that handles a network request.
195    /// The node can be either a service or an application that sends, forwards,
196    /// or receives the request. Service peers should fill in
197    /// `principal` and `labels` as appropriate.
198    #[serde_with::serde_as]
199    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
200    #[serde(default, rename_all = "camelCase")]
201    #[non_exhaustive]
202    pub struct Peer {
203        /// The IP address of the peer.
204        #[serde(skip_serializing_if = "std::string::String::is_empty")]
205        pub ip: std::string::String,
206
207        /// The network port of the peer.
208        #[serde_as(as = "serde_with::DisplayFromStr")]
209        pub port: i64,
210
211        /// The labels associated with the peer.
212        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
213        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
214
215        /// The identity of this peer. Similar to `Request.auth.principal`, but
216        /// relative to the peer instead of the request. For example, the
217        /// identity associated with a load balancer that forwarded the request.
218        #[serde(skip_serializing_if = "std::string::String::is_empty")]
219        pub principal: std::string::String,
220
221        /// The CLDR country/region code associated with the above IP address.
222        /// If the IP address is private, the `region_code` should reflect the
223        /// physical location where this peer is running.
224        #[serde(skip_serializing_if = "std::string::String::is_empty")]
225        pub region_code: std::string::String,
226    }
227
228    impl Peer {
229        pub fn new() -> Self {
230            std::default::Default::default()
231        }
232
233        /// Sets the value of [ip][crate::model::attribute_context::Peer::ip].
234        pub fn set_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
235            self.ip = v.into();
236            self
237        }
238
239        /// Sets the value of [port][crate::model::attribute_context::Peer::port].
240        pub fn set_port<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
241            self.port = v.into();
242            self
243        }
244
245        /// Sets the value of [principal][crate::model::attribute_context::Peer::principal].
246        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
247            self.principal = v.into();
248            self
249        }
250
251        /// Sets the value of [region_code][crate::model::attribute_context::Peer::region_code].
252        pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
253            self.region_code = v.into();
254            self
255        }
256
257        /// Sets the value of [labels][crate::model::attribute_context::Peer::labels].
258        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
259        where
260            T: std::iter::IntoIterator<Item = (K, V)>,
261            K: std::convert::Into<std::string::String>,
262            V: std::convert::Into<std::string::String>,
263        {
264            use std::iter::Iterator;
265            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
266            self
267        }
268    }
269
270    impl wkt::message::Message for Peer {
271        fn typename() -> &'static str {
272            "type.googleapis.com/google.rpc.context.AttributeContext.Peer"
273        }
274    }
275
276    /// This message defines attributes associated with API operations, such as
277    /// a network API request. The terminology is based on the conventions used
278    /// by Google APIs, Istio, and OpenAPI.
279    #[serde_with::serde_as]
280    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
281    #[serde(default, rename_all = "camelCase")]
282    #[non_exhaustive]
283    pub struct Api {
284        /// The API service name. It is a logical identifier for a networked API,
285        /// such as "pubsub.googleapis.com". The naming syntax depends on the
286        /// API management system being used for handling the request.
287        #[serde(skip_serializing_if = "std::string::String::is_empty")]
288        pub service: std::string::String,
289
290        /// The API operation name. For gRPC requests, it is the fully qualified API
291        /// method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI
292        /// requests, it is the `operationId`, such as "getPet".
293        #[serde(skip_serializing_if = "std::string::String::is_empty")]
294        pub operation: std::string::String,
295
296        /// The API protocol used for sending the request, such as "http", "https",
297        /// "grpc", or "internal".
298        #[serde(skip_serializing_if = "std::string::String::is_empty")]
299        pub protocol: std::string::String,
300
301        /// The API version associated with the API operation above, such as "v1" or
302        /// "v1alpha1".
303        #[serde(skip_serializing_if = "std::string::String::is_empty")]
304        pub version: std::string::String,
305    }
306
307    impl Api {
308        pub fn new() -> Self {
309            std::default::Default::default()
310        }
311
312        /// Sets the value of [service][crate::model::attribute_context::Api::service].
313        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
314            self.service = v.into();
315            self
316        }
317
318        /// Sets the value of [operation][crate::model::attribute_context::Api::operation].
319        pub fn set_operation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
320            self.operation = v.into();
321            self
322        }
323
324        /// Sets the value of [protocol][crate::model::attribute_context::Api::protocol].
325        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
326            self.protocol = v.into();
327            self
328        }
329
330        /// Sets the value of [version][crate::model::attribute_context::Api::version].
331        pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
332            self.version = v.into();
333            self
334        }
335    }
336
337    impl wkt::message::Message for Api {
338        fn typename() -> &'static str {
339            "type.googleapis.com/google.rpc.context.AttributeContext.Api"
340        }
341    }
342
343    /// This message defines request authentication attributes. Terminology is
344    /// based on the JSON Web Token (JWT) standard, but the terms also
345    /// correlate to concepts in other standards.
346    #[serde_with::serde_as]
347    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
348    #[serde(default, rename_all = "camelCase")]
349    #[non_exhaustive]
350    pub struct Auth {
351        /// The authenticated principal. Reflects the issuer (`iss`) and subject
352        /// (`sub`) claims within a JWT. The issuer and subject should be `/`
353        /// delimited, with `/` percent-encoded within the subject fragment. For
354        /// Google accounts, the principal format is:
355        /// `https://accounts.google.com/{id}`
356        #[serde(skip_serializing_if = "std::string::String::is_empty")]
357        pub principal: std::string::String,
358
359        /// The intended audience(s) for this authentication information. Reflects
360        /// the audience (`aud`) claim within a JWT. The audience
361        /// value(s) depends on the `issuer`, but typically include one or more of
362        /// the following pieces of information:
363        ///
364        /// * The services intended to receive the credential. For example,
365        ///   [`https://pubsub.googleapis.com/`, `https://storage.googleapis.com/`].
366        /// * A set of service-based scopes. For example,
367        ///   [`https://www.googleapis.com/auth/cloud-platform`].
368        /// * The client id of an app, such as the Firebase project id for JWTs
369        ///   from Firebase Auth.
370        ///
371        /// Consult the documentation for the credential issuer to determine the
372        /// information provided.
373        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
374        pub audiences: std::vec::Vec<std::string::String>,
375
376        /// The authorized presenter of the credential. Reflects the optional
377        /// Authorized Presenter (`azp`) claim within a JWT or the
378        /// OAuth client id. For example, a Google Cloud Platform client id looks
379        /// as follows: "123456789012.apps.googleusercontent.com".
380        #[serde(skip_serializing_if = "std::string::String::is_empty")]
381        pub presenter: std::string::String,
382
383        /// Structured claims presented with the credential. JWTs include
384        /// `{key: value}` pairs for standard and private claims. The following
385        /// is a subset of the standard required and optional claims that would
386        /// typically be presented for a Google-based JWT:
387        ///
388        /// {'iss': 'accounts.google.com',
389        /// 'sub': '113289723416554971153',
390        /// 'aud': ['123456789012', 'pubsub.googleapis.com'],
391        /// 'azp': '123456789012.apps.googleusercontent.com',
392        /// 'email': 'jsmith@example.com',
393        /// 'iat': 1353601026,
394        /// 'exp': 1353604926}
395        ///
396        /// SAML assertions are similarly specified, but with an identity provider
397        /// dependent structure.
398        #[serde(skip_serializing_if = "std::option::Option::is_none")]
399        pub claims: std::option::Option<wkt::Struct>,
400
401        /// A list of access level resource names that allow resources to be
402        /// accessed by authenticated requester. It is part of Secure GCP processing
403        /// for the incoming request. An access level string has the format:
404        /// "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}"
405        ///
406        /// Example:
407        /// "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL"
408        #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
409        pub access_levels: std::vec::Vec<std::string::String>,
410    }
411
412    impl Auth {
413        pub fn new() -> Self {
414            std::default::Default::default()
415        }
416
417        /// Sets the value of [principal][crate::model::attribute_context::Auth::principal].
418        pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
419            self.principal = v.into();
420            self
421        }
422
423        /// Sets the value of [presenter][crate::model::attribute_context::Auth::presenter].
424        pub fn set_presenter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
425            self.presenter = v.into();
426            self
427        }
428
429        /// Sets the value of [claims][crate::model::attribute_context::Auth::claims].
430        pub fn set_claims<T: std::convert::Into<std::option::Option<wkt::Struct>>>(
431            mut self,
432            v: T,
433        ) -> Self {
434            self.claims = v.into();
435            self
436        }
437
438        /// Sets the value of [audiences][crate::model::attribute_context::Auth::audiences].
439        pub fn set_audiences<T, V>(mut self, v: T) -> Self
440        where
441            T: std::iter::IntoIterator<Item = V>,
442            V: std::convert::Into<std::string::String>,
443        {
444            use std::iter::Iterator;
445            self.audiences = v.into_iter().map(|i| i.into()).collect();
446            self
447        }
448
449        /// Sets the value of [access_levels][crate::model::attribute_context::Auth::access_levels].
450        pub fn set_access_levels<T, V>(mut self, v: T) -> Self
451        where
452            T: std::iter::IntoIterator<Item = V>,
453            V: std::convert::Into<std::string::String>,
454        {
455            use std::iter::Iterator;
456            self.access_levels = v.into_iter().map(|i| i.into()).collect();
457            self
458        }
459    }
460
461    impl wkt::message::Message for Auth {
462        fn typename() -> &'static str {
463            "type.googleapis.com/google.rpc.context.AttributeContext.Auth"
464        }
465    }
466
467    /// This message defines attributes for an HTTP request. If the actual
468    /// request is not an HTTP request, the runtime system should try to map
469    /// the actual request to an equivalent HTTP request.
470    #[serde_with::serde_as]
471    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
472    #[serde(default, rename_all = "camelCase")]
473    #[non_exhaustive]
474    pub struct Request {
475        /// The unique ID for a request, which can be propagated to downstream
476        /// systems. The ID should have low probability of collision
477        /// within a single day for a specific service.
478        #[serde(skip_serializing_if = "std::string::String::is_empty")]
479        pub id: std::string::String,
480
481        /// The HTTP request method, such as `GET`, `POST`.
482        #[serde(skip_serializing_if = "std::string::String::is_empty")]
483        pub method: std::string::String,
484
485        /// The HTTP request headers. If multiple headers share the same key, they
486        /// must be merged according to the HTTP spec. All header keys must be
487        /// lowercased, because HTTP header keys are case-insensitive.
488        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
489        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
490
491        /// The HTTP URL path, excluding the query parameters.
492        #[serde(skip_serializing_if = "std::string::String::is_empty")]
493        pub path: std::string::String,
494
495        /// The HTTP request `Host` header value.
496        #[serde(skip_serializing_if = "std::string::String::is_empty")]
497        pub host: std::string::String,
498
499        /// The HTTP URL scheme, such as `http` and `https`.
500        #[serde(skip_serializing_if = "std::string::String::is_empty")]
501        pub scheme: std::string::String,
502
503        /// The HTTP URL query in the format of `name1=value1&name2=value2`, as it
504        /// appears in the first line of the HTTP request. No decoding is performed.
505        #[serde(skip_serializing_if = "std::string::String::is_empty")]
506        pub query: std::string::String,
507
508        /// The timestamp when the `destination` service receives the last byte of
509        /// the request.
510        #[serde(skip_serializing_if = "std::option::Option::is_none")]
511        pub time: std::option::Option<wkt::Timestamp>,
512
513        /// The HTTP request size in bytes. If unknown, it must be -1.
514        #[serde_as(as = "serde_with::DisplayFromStr")]
515        pub size: i64,
516
517        /// The network protocol used with the request, such as "http/1.1",
518        /// "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See
519        /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
520        /// for details.
521        #[serde(skip_serializing_if = "std::string::String::is_empty")]
522        pub protocol: std::string::String,
523
524        /// A special parameter for request reason. It is used by security systems
525        /// to associate auditing information with a request.
526        #[serde(skip_serializing_if = "std::string::String::is_empty")]
527        pub reason: std::string::String,
528
529        /// The request authentication. May be absent for unauthenticated requests.
530        /// Derived from the HTTP request `Authorization` header or equivalent.
531        #[serde(skip_serializing_if = "std::option::Option::is_none")]
532        pub auth: std::option::Option<crate::model::attribute_context::Auth>,
533    }
534
535    impl Request {
536        pub fn new() -> Self {
537            std::default::Default::default()
538        }
539
540        /// Sets the value of [id][crate::model::attribute_context::Request::id].
541        pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
542            self.id = v.into();
543            self
544        }
545
546        /// Sets the value of [method][crate::model::attribute_context::Request::method].
547        pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
548            self.method = v.into();
549            self
550        }
551
552        /// Sets the value of [path][crate::model::attribute_context::Request::path].
553        pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
554            self.path = v.into();
555            self
556        }
557
558        /// Sets the value of [host][crate::model::attribute_context::Request::host].
559        pub fn set_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
560            self.host = v.into();
561            self
562        }
563
564        /// Sets the value of [scheme][crate::model::attribute_context::Request::scheme].
565        pub fn set_scheme<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
566            self.scheme = v.into();
567            self
568        }
569
570        /// Sets the value of [query][crate::model::attribute_context::Request::query].
571        pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
572            self.query = v.into();
573            self
574        }
575
576        /// Sets the value of [time][crate::model::attribute_context::Request::time].
577        pub fn set_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
578            mut self,
579            v: T,
580        ) -> Self {
581            self.time = v.into();
582            self
583        }
584
585        /// Sets the value of [size][crate::model::attribute_context::Request::size].
586        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
587            self.size = v.into();
588            self
589        }
590
591        /// Sets the value of [protocol][crate::model::attribute_context::Request::protocol].
592        pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
593            self.protocol = v.into();
594            self
595        }
596
597        /// Sets the value of [reason][crate::model::attribute_context::Request::reason].
598        pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
599            self.reason = v.into();
600            self
601        }
602
603        /// Sets the value of [auth][crate::model::attribute_context::Request::auth].
604        pub fn set_auth<
605            T: std::convert::Into<std::option::Option<crate::model::attribute_context::Auth>>,
606        >(
607            mut self,
608            v: T,
609        ) -> Self {
610            self.auth = v.into();
611            self
612        }
613
614        /// Sets the value of [headers][crate::model::attribute_context::Request::headers].
615        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
616        where
617            T: std::iter::IntoIterator<Item = (K, V)>,
618            K: std::convert::Into<std::string::String>,
619            V: std::convert::Into<std::string::String>,
620        {
621            use std::iter::Iterator;
622            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
623            self
624        }
625    }
626
627    impl wkt::message::Message for Request {
628        fn typename() -> &'static str {
629            "type.googleapis.com/google.rpc.context.AttributeContext.Request"
630        }
631    }
632
633    /// This message defines attributes for a typical network response. It
634    /// generally models semantics of an HTTP response.
635    #[serde_with::serde_as]
636    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
637    #[serde(default, rename_all = "camelCase")]
638    #[non_exhaustive]
639    pub struct Response {
640        /// The HTTP response status code, such as `200` and `404`.
641        #[serde_as(as = "serde_with::DisplayFromStr")]
642        pub code: i64,
643
644        /// The HTTP response size in bytes. If unknown, it must be -1.
645        #[serde_as(as = "serde_with::DisplayFromStr")]
646        pub size: i64,
647
648        /// The HTTP response headers. If multiple headers share the same key, they
649        /// must be merged according to HTTP spec. All header keys must be
650        /// lowercased, because HTTP header keys are case-insensitive.
651        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
652        pub headers: std::collections::HashMap<std::string::String, std::string::String>,
653
654        /// The timestamp when the `destination` service sends the last byte of
655        /// the response.
656        #[serde(skip_serializing_if = "std::option::Option::is_none")]
657        pub time: std::option::Option<wkt::Timestamp>,
658
659        /// The amount of time it takes the backend service to fully respond to a
660        /// request. Measured from when the destination service starts to send the
661        /// request to the backend until when the destination service receives the
662        /// complete response from the backend.
663        #[serde(skip_serializing_if = "std::option::Option::is_none")]
664        pub backend_latency: std::option::Option<wkt::Duration>,
665    }
666
667    impl Response {
668        pub fn new() -> Self {
669            std::default::Default::default()
670        }
671
672        /// Sets the value of [code][crate::model::attribute_context::Response::code].
673        pub fn set_code<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
674            self.code = v.into();
675            self
676        }
677
678        /// Sets the value of [size][crate::model::attribute_context::Response::size].
679        pub fn set_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
680            self.size = v.into();
681            self
682        }
683
684        /// Sets the value of [time][crate::model::attribute_context::Response::time].
685        pub fn set_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
686            mut self,
687            v: T,
688        ) -> Self {
689            self.time = v.into();
690            self
691        }
692
693        /// Sets the value of [backend_latency][crate::model::attribute_context::Response::backend_latency].
694        pub fn set_backend_latency<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
695            mut self,
696            v: T,
697        ) -> Self {
698            self.backend_latency = v.into();
699            self
700        }
701
702        /// Sets the value of [headers][crate::model::attribute_context::Response::headers].
703        pub fn set_headers<T, K, V>(mut self, v: T) -> Self
704        where
705            T: std::iter::IntoIterator<Item = (K, V)>,
706            K: std::convert::Into<std::string::String>,
707            V: std::convert::Into<std::string::String>,
708        {
709            use std::iter::Iterator;
710            self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
711            self
712        }
713    }
714
715    impl wkt::message::Message for Response {
716        fn typename() -> &'static str {
717            "type.googleapis.com/google.rpc.context.AttributeContext.Response"
718        }
719    }
720
721    /// This message defines core attributes for a resource. A resource is an
722    /// addressable (named) entity provided by the destination service. For
723    /// example, a file stored on a network storage service.
724    #[serde_with::serde_as]
725    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
726    #[serde(default, rename_all = "camelCase")]
727    #[non_exhaustive]
728    pub struct Resource {
729        /// The name of the service that this resource belongs to, such as
730        /// `pubsub.googleapis.com`. The service may be different from the DNS
731        /// hostname that actually serves the request.
732        #[serde(skip_serializing_if = "std::string::String::is_empty")]
733        pub service: std::string::String,
734
735        /// The stable identifier (name) of a resource on the `service`. A resource
736        /// can be logically identified as "//{resource.service}/{resource.name}".
737        /// The differences between a resource name and a URI are:
738        ///
739        /// * Resource name is a logical identifier, independent of network
740        ///   protocol and API version. For example,
741        ///   `//pubsub.googleapis.com/projects/123/topics/news-feed`.
742        /// * URI often includes protocol and version information, so it can
743        ///   be used directly by applications. For example,
744        ///   `<https://pubsub.googleapis.com/v1/projects/123/topics/news-feed>`.
745        ///
746        /// See <https://cloud.google.com/apis/design/resource_names> for details.
747        #[serde(skip_serializing_if = "std::string::String::is_empty")]
748        pub name: std::string::String,
749
750        /// The type of the resource. The syntax is platform-specific because
751        /// different platforms define their resources differently.
752        ///
753        /// For Google APIs, the type format must be "{service}/{kind}", such as
754        /// "pubsub.googleapis.com/Topic".
755        #[serde(rename = "type")]
756        #[serde(skip_serializing_if = "std::string::String::is_empty")]
757        pub r#type: std::string::String,
758
759        /// The labels or tags on the resource, such as AWS resource tags and
760        /// Kubernetes resource labels.
761        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
762        pub labels: std::collections::HashMap<std::string::String, std::string::String>,
763
764        /// The unique identifier of the resource. UID is unique in the time
765        /// and space for this resource within the scope of the service. It is
766        /// typically generated by the server on successful creation of a resource
767        /// and must not be changed. UID is used to uniquely identify resources
768        /// with resource name reuses. This should be a UUID4.
769        #[serde(skip_serializing_if = "std::string::String::is_empty")]
770        pub uid: std::string::String,
771
772        /// Annotations is an unstructured key-value map stored with a resource that
773        /// may be set by external tools to store and retrieve arbitrary metadata.
774        /// They are not queryable and should be preserved when modifying objects.
775        ///
776        /// More info:
777        /// <https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/>
778        #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
779        pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
780
781        /// Mutable. The display name set by clients. Must be <= 63 characters.
782        #[serde(skip_serializing_if = "std::string::String::is_empty")]
783        pub display_name: std::string::String,
784
785        /// Output only. The timestamp when the resource was created. This may
786        /// be either the time creation was initiated or when it was completed.
787        #[serde(skip_serializing_if = "std::option::Option::is_none")]
788        pub create_time: std::option::Option<wkt::Timestamp>,
789
790        /// Output only. The timestamp when the resource was last updated. Any
791        /// change to the resource made by users must refresh this value.
792        /// Changes to a resource made by the service should refresh this value.
793        #[serde(skip_serializing_if = "std::option::Option::is_none")]
794        pub update_time: std::option::Option<wkt::Timestamp>,
795
796        /// Output only. The timestamp when the resource was deleted.
797        /// If the resource is not deleted, this must be empty.
798        #[serde(skip_serializing_if = "std::option::Option::is_none")]
799        pub delete_time: std::option::Option<wkt::Timestamp>,
800
801        /// Output only. An opaque value that uniquely identifies a version or
802        /// generation of a resource. It can be used to confirm that the client
803        /// and server agree on the ordering of a resource being written.
804        #[serde(skip_serializing_if = "std::string::String::is_empty")]
805        pub etag: std::string::String,
806
807        /// Immutable. The location of the resource. The location encoding is
808        /// specific to the service provider, and new encoding may be introduced
809        /// as the service evolves.
810        ///
811        /// For Google Cloud products, the encoding is what is used by Google Cloud
812        /// APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The
813        /// semantics of `location` is identical to the
814        /// `cloud.googleapis.com/location` label used by some Google Cloud APIs.
815        #[serde(skip_serializing_if = "std::string::String::is_empty")]
816        pub location: std::string::String,
817    }
818
819    impl Resource {
820        pub fn new() -> Self {
821            std::default::Default::default()
822        }
823
824        /// Sets the value of [service][crate::model::attribute_context::Resource::service].
825        pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
826            self.service = v.into();
827            self
828        }
829
830        /// Sets the value of [name][crate::model::attribute_context::Resource::name].
831        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
832            self.name = v.into();
833            self
834        }
835
836        /// Sets the value of [r#type][crate::model::attribute_context::Resource::type].
837        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
838            self.r#type = v.into();
839            self
840        }
841
842        /// Sets the value of [uid][crate::model::attribute_context::Resource::uid].
843        pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
844            self.uid = v.into();
845            self
846        }
847
848        /// Sets the value of [display_name][crate::model::attribute_context::Resource::display_name].
849        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
850            mut self,
851            v: T,
852        ) -> Self {
853            self.display_name = v.into();
854            self
855        }
856
857        /// Sets the value of [create_time][crate::model::attribute_context::Resource::create_time].
858        pub fn set_create_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
859            mut self,
860            v: T,
861        ) -> Self {
862            self.create_time = v.into();
863            self
864        }
865
866        /// Sets the value of [update_time][crate::model::attribute_context::Resource::update_time].
867        pub fn set_update_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
868            mut self,
869            v: T,
870        ) -> Self {
871            self.update_time = v.into();
872            self
873        }
874
875        /// Sets the value of [delete_time][crate::model::attribute_context::Resource::delete_time].
876        pub fn set_delete_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
877            mut self,
878            v: T,
879        ) -> Self {
880            self.delete_time = v.into();
881            self
882        }
883
884        /// Sets the value of [etag][crate::model::attribute_context::Resource::etag].
885        pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
886            self.etag = v.into();
887            self
888        }
889
890        /// Sets the value of [location][crate::model::attribute_context::Resource::location].
891        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
892            self.location = v.into();
893            self
894        }
895
896        /// Sets the value of [labels][crate::model::attribute_context::Resource::labels].
897        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
898        where
899            T: std::iter::IntoIterator<Item = (K, V)>,
900            K: std::convert::Into<std::string::String>,
901            V: std::convert::Into<std::string::String>,
902        {
903            use std::iter::Iterator;
904            self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
905            self
906        }
907
908        /// Sets the value of [annotations][crate::model::attribute_context::Resource::annotations].
909        pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
910        where
911            T: std::iter::IntoIterator<Item = (K, V)>,
912            K: std::convert::Into<std::string::String>,
913            V: std::convert::Into<std::string::String>,
914        {
915            use std::iter::Iterator;
916            self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
917            self
918        }
919    }
920
921    impl wkt::message::Message for Resource {
922        fn typename() -> &'static str {
923            "type.googleapis.com/google.rpc.context.AttributeContext.Resource"
924        }
925    }
926}
927
928/// `AuditContext` provides information that is needed for audit logging.
929#[serde_with::serde_as]
930#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
931#[serde(default, rename_all = "camelCase")]
932#[non_exhaustive]
933pub struct AuditContext {
934    /// Serialized audit log.
935    #[serde(skip_serializing_if = "bytes::Bytes::is_empty")]
936    #[serde_as(as = "serde_with::base64::Base64")]
937    pub audit_log: bytes::Bytes,
938
939    /// An API request message that is scrubbed based on the method annotation.
940    /// This field should only be filled if audit_log field is present.
941    /// Service Control will use this to assemble a complete log for Cloud Audit
942    /// Logs and Google internal audit logs.
943    #[serde(skip_serializing_if = "std::option::Option::is_none")]
944    pub scrubbed_request: std::option::Option<wkt::Struct>,
945
946    /// An API response message that is scrubbed based on the method annotation.
947    /// This field should only be filled if audit_log field is present.
948    /// Service Control will use this to assemble a complete log for Cloud Audit
949    /// Logs and Google internal audit logs.
950    #[serde(skip_serializing_if = "std::option::Option::is_none")]
951    pub scrubbed_response: std::option::Option<wkt::Struct>,
952
953    /// Number of scrubbed response items.
954    pub scrubbed_response_item_count: i32,
955
956    /// Audit resource name which is scrubbed.
957    #[serde(skip_serializing_if = "std::string::String::is_empty")]
958    pub target_resource: std::string::String,
959}
960
961impl AuditContext {
962    pub fn new() -> Self {
963        std::default::Default::default()
964    }
965
966    /// Sets the value of [audit_log][crate::model::AuditContext::audit_log].
967    pub fn set_audit_log<T: std::convert::Into<bytes::Bytes>>(mut self, v: T) -> Self {
968        self.audit_log = v.into();
969        self
970    }
971
972    /// Sets the value of [scrubbed_request][crate::model::AuditContext::scrubbed_request].
973    pub fn set_scrubbed_request<T: std::convert::Into<std::option::Option<wkt::Struct>>>(
974        mut self,
975        v: T,
976    ) -> Self {
977        self.scrubbed_request = v.into();
978        self
979    }
980
981    /// Sets the value of [scrubbed_response][crate::model::AuditContext::scrubbed_response].
982    pub fn set_scrubbed_response<T: std::convert::Into<std::option::Option<wkt::Struct>>>(
983        mut self,
984        v: T,
985    ) -> Self {
986        self.scrubbed_response = v.into();
987        self
988    }
989
990    /// Sets the value of [scrubbed_response_item_count][crate::model::AuditContext::scrubbed_response_item_count].
991    pub fn set_scrubbed_response_item_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
992        self.scrubbed_response_item_count = v.into();
993        self
994    }
995
996    /// Sets the value of [target_resource][crate::model::AuditContext::target_resource].
997    pub fn set_target_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
998        self.target_resource = v.into();
999        self
1000    }
1001}
1002
1003impl wkt::message::Message for AuditContext {
1004    fn typename() -> &'static str {
1005        "type.googleapis.com/google.rpc.context.AuditContext"
1006    }
1007}