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