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