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