google_cloud_rpc/model.rs
1// Copyright 2024 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/// Describes the cause of the error with structured details.
32///
33/// Example of an error when contacting the "pubsub.googleapis.com" API when it
34/// is not enabled:
35///
36/// ```norust
37/// { "reason": "API_DISABLED"
38/// "domain": "googleapis.com"
39/// "metadata": {
40/// "resource": "projects/123",
41/// "service": "pubsub.googleapis.com"
42/// }
43/// }
44/// ```
45///
46/// This response indicates that the pubsub.googleapis.com API is not enabled.
47///
48/// Example of an error that is returned when attempting to create a Spanner
49/// instance in a region that is out of stock:
50///
51/// ```norust
52/// { "reason": "STOCKOUT"
53/// "domain": "spanner.googleapis.com",
54/// "metadata": {
55/// "availableRegions": "us-central1,us-east2"
56/// }
57/// }
58/// ```
59#[derive(Clone, Default, PartialEq)]
60#[non_exhaustive]
61pub struct ErrorInfo {
62 /// The reason of the error. This is a constant value that identifies the
63 /// proximate cause of the error. Error reasons are unique within a particular
64 /// domain of errors. This should be at most 63 characters and match a
65 /// regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
66 /// UPPER_SNAKE_CASE.
67 pub reason: std::string::String,
68
69 /// The logical grouping to which the "reason" belongs. The error domain
70 /// is typically the registered service name of the tool or product that
71 /// generates the error. Example: "pubsub.googleapis.com". If the error is
72 /// generated by some common infrastructure, the error domain must be a
73 /// globally unique value that identifies the infrastructure. For Google API
74 /// infrastructure, the error domain is "googleapis.com".
75 pub domain: std::string::String,
76
77 /// Additional structured details about this error.
78 ///
79 /// Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should
80 /// ideally be lowerCamelCase. Also, they must be limited to 64 characters in
81 /// length. When identifying the current value of an exceeded limit, the units
82 /// should be contained in the key, not the value. For example, rather than
83 /// `{"instanceLimit": "100/request"}`, should be returned as,
84 /// `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of
85 /// instances that can be created in a single (batch) request.
86 pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
87
88 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
89}
90
91impl ErrorInfo {
92 pub fn new() -> Self {
93 std::default::Default::default()
94 }
95
96 /// Sets the value of [reason][crate::model::ErrorInfo::reason].
97 pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
98 self.reason = v.into();
99 self
100 }
101
102 /// Sets the value of [domain][crate::model::ErrorInfo::domain].
103 pub fn set_domain<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
104 self.domain = v.into();
105 self
106 }
107
108 /// Sets the value of [metadata][crate::model::ErrorInfo::metadata].
109 pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
110 where
111 T: std::iter::IntoIterator<Item = (K, V)>,
112 K: std::convert::Into<std::string::String>,
113 V: std::convert::Into<std::string::String>,
114 {
115 use std::iter::Iterator;
116 self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
117 self
118 }
119}
120
121impl wkt::message::Message for ErrorInfo {
122 fn typename() -> &'static str {
123 "type.googleapis.com/google.rpc.ErrorInfo"
124 }
125}
126
127/// Describes when the clients can retry a failed request. Clients could ignore
128/// the recommendation here or retry when this information is missing from error
129/// responses.
130///
131/// It's always recommended that clients should use exponential backoff when
132/// retrying.
133///
134/// Clients should wait until `retry_delay` amount of time has passed since
135/// receiving the error response before retrying. If retrying requests also
136/// fail, clients should use an exponential backoff scheme to gradually increase
137/// the delay between retries based on `retry_delay`, until either a maximum
138/// number of retries have been reached or a maximum retry delay cap has been
139/// reached.
140#[derive(Clone, Default, PartialEq)]
141#[non_exhaustive]
142pub struct RetryInfo {
143 /// Clients should wait at least this long between retrying the same request.
144 pub retry_delay: std::option::Option<wkt::Duration>,
145
146 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
147}
148
149impl RetryInfo {
150 pub fn new() -> Self {
151 std::default::Default::default()
152 }
153
154 /// Sets the value of [retry_delay][crate::model::RetryInfo::retry_delay].
155 pub fn set_retry_delay<T>(mut self, v: T) -> Self
156 where
157 T: std::convert::Into<wkt::Duration>,
158 {
159 self.retry_delay = std::option::Option::Some(v.into());
160 self
161 }
162
163 /// Sets or clears the value of [retry_delay][crate::model::RetryInfo::retry_delay].
164 pub fn set_or_clear_retry_delay<T>(mut self, v: std::option::Option<T>) -> Self
165 where
166 T: std::convert::Into<wkt::Duration>,
167 {
168 self.retry_delay = v.map(|x| x.into());
169 self
170 }
171}
172
173impl wkt::message::Message for RetryInfo {
174 fn typename() -> &'static str {
175 "type.googleapis.com/google.rpc.RetryInfo"
176 }
177}
178
179/// Describes additional debugging info.
180#[derive(Clone, Default, PartialEq)]
181#[non_exhaustive]
182pub struct DebugInfo {
183 /// The stack trace entries indicating where the error occurred.
184 pub stack_entries: std::vec::Vec<std::string::String>,
185
186 /// Additional debugging information provided by the server.
187 pub detail: std::string::String,
188
189 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
190}
191
192impl DebugInfo {
193 pub fn new() -> Self {
194 std::default::Default::default()
195 }
196
197 /// Sets the value of [stack_entries][crate::model::DebugInfo::stack_entries].
198 pub fn set_stack_entries<T, V>(mut self, v: T) -> Self
199 where
200 T: std::iter::IntoIterator<Item = V>,
201 V: std::convert::Into<std::string::String>,
202 {
203 use std::iter::Iterator;
204 self.stack_entries = v.into_iter().map(|i| i.into()).collect();
205 self
206 }
207
208 /// Sets the value of [detail][crate::model::DebugInfo::detail].
209 pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
210 self.detail = v.into();
211 self
212 }
213}
214
215impl wkt::message::Message for DebugInfo {
216 fn typename() -> &'static str {
217 "type.googleapis.com/google.rpc.DebugInfo"
218 }
219}
220
221/// Describes how a quota check failed.
222///
223/// For example if a daily limit was exceeded for the calling project,
224/// a service could respond with a QuotaFailure detail containing the project
225/// id and the description of the quota limit that was exceeded. If the
226/// calling project hasn't enabled the service in the developer console, then
227/// a service could respond with the project id and set `service_disabled`
228/// to true.
229///
230/// Also see RetryInfo and Help types for other details about handling a
231/// quota failure.
232#[derive(Clone, Default, PartialEq)]
233#[non_exhaustive]
234pub struct QuotaFailure {
235 /// Describes all quota violations.
236 pub violations: std::vec::Vec<crate::model::quota_failure::Violation>,
237
238 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
239}
240
241impl QuotaFailure {
242 pub fn new() -> Self {
243 std::default::Default::default()
244 }
245
246 /// Sets the value of [violations][crate::model::QuotaFailure::violations].
247 pub fn set_violations<T, V>(mut self, v: T) -> Self
248 where
249 T: std::iter::IntoIterator<Item = V>,
250 V: std::convert::Into<crate::model::quota_failure::Violation>,
251 {
252 use std::iter::Iterator;
253 self.violations = v.into_iter().map(|i| i.into()).collect();
254 self
255 }
256}
257
258impl wkt::message::Message for QuotaFailure {
259 fn typename() -> &'static str {
260 "type.googleapis.com/google.rpc.QuotaFailure"
261 }
262}
263
264/// Defines additional types related to [QuotaFailure].
265pub mod quota_failure {
266 #[allow(unused_imports)]
267 use super::*;
268
269 /// A message type used to describe a single quota violation. For example, a
270 /// daily quota or a custom quota that was exceeded.
271 #[derive(Clone, Default, PartialEq)]
272 #[non_exhaustive]
273 pub struct Violation {
274 /// The subject on which the quota check failed.
275 /// For example, "clientip:\<ip address of client\>" or "project:\<Google
276 /// developer project id\>".
277 pub subject: std::string::String,
278
279 /// A description of how the quota check failed. Clients can use this
280 /// description to find more about the quota configuration in the service's
281 /// public documentation, or find the relevant quota limit to adjust through
282 /// developer console.
283 ///
284 /// For example: "Service disabled" or "Daily Limit for read operations
285 /// exceeded".
286 pub description: std::string::String,
287
288 /// The API Service from which the `QuotaFailure.Violation` orginates. In
289 /// some cases, Quota issues originate from an API Service other than the one
290 /// that was called. In other words, a dependency of the called API Service
291 /// could be the cause of the `QuotaFailure`, and this field would have the
292 /// dependency API service name.
293 ///
294 /// For example, if the called API is Kubernetes Engine API
295 /// (container.googleapis.com), and a quota violation occurs in the
296 /// Kubernetes Engine API itself, this field would be
297 /// "container.googleapis.com". On the other hand, if the quota violation
298 /// occurs when the Kubernetes Engine API creates VMs in the Compute Engine
299 /// API (compute.googleapis.com), this field would be
300 /// "compute.googleapis.com".
301 pub api_service: std::string::String,
302
303 /// The metric of the violated quota. A quota metric is a named counter to
304 /// measure usage, such as API requests or CPUs. When an activity occurs in a
305 /// service, such as Virtual Machine allocation, one or more quota metrics
306 /// may be affected.
307 ///
308 /// For example, "compute.googleapis.com/cpus_per_vm_family",
309 /// "storage.googleapis.com/internet_egress_bandwidth".
310 pub quota_metric: std::string::String,
311
312 /// The id of the violated quota. Also know as "limit name", this is the
313 /// unique identifier of a quota in the context of an API service.
314 ///
315 /// For example, "CPUS-PER-VM-FAMILY-per-project-region".
316 pub quota_id: std::string::String,
317
318 /// The dimensions of the violated quota. Every non-global quota is enforced
319 /// on a set of dimensions. While quota metric defines what to count, the
320 /// dimensions specify for what aspects the counter should be increased.
321 ///
322 /// For example, the quota "CPUs per region per VM family" enforces a limit
323 /// on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions
324 /// "region" and "vm_family". And if the violation occurred in region
325 /// "us-central1" and for VM family "n1", the quota_dimensions would be,
326 ///
327 /// {
328 /// "region": "us-central1",
329 /// "vm_family": "n1",
330 /// }
331 ///
332 /// When a quota is enforced globally, the quota_dimensions would always be
333 /// empty.
334 pub quota_dimensions: std::collections::HashMap<std::string::String, std::string::String>,
335
336 /// The enforced quota value at the time of the `QuotaFailure`.
337 ///
338 /// For example, if the enforced quota value at the time of the
339 /// `QuotaFailure` on the number of CPUs is "10", then the value of this
340 /// field would reflect this quantity.
341 pub quota_value: i64,
342
343 /// The new quota value being rolled out at the time of the violation. At the
344 /// completion of the rollout, this value will be enforced in place of
345 /// quota_value. If no rollout is in progress at the time of the violation,
346 /// this field is not set.
347 ///
348 /// For example, if at the time of the violation a rollout is in progress
349 /// changing the number of CPUs quota from 10 to 20, 20 would be the value of
350 /// this field.
351 pub future_quota_value: std::option::Option<i64>,
352
353 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
354 }
355
356 impl Violation {
357 pub fn new() -> Self {
358 std::default::Default::default()
359 }
360
361 /// Sets the value of [subject][crate::model::quota_failure::Violation::subject].
362 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
363 self.subject = v.into();
364 self
365 }
366
367 /// Sets the value of [description][crate::model::quota_failure::Violation::description].
368 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
369 self.description = v.into();
370 self
371 }
372
373 /// Sets the value of [api_service][crate::model::quota_failure::Violation::api_service].
374 pub fn set_api_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
375 self.api_service = v.into();
376 self
377 }
378
379 /// Sets the value of [quota_metric][crate::model::quota_failure::Violation::quota_metric].
380 pub fn set_quota_metric<T: std::convert::Into<std::string::String>>(
381 mut self,
382 v: T,
383 ) -> Self {
384 self.quota_metric = v.into();
385 self
386 }
387
388 /// Sets the value of [quota_id][crate::model::quota_failure::Violation::quota_id].
389 pub fn set_quota_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
390 self.quota_id = v.into();
391 self
392 }
393
394 /// Sets the value of [quota_dimensions][crate::model::quota_failure::Violation::quota_dimensions].
395 pub fn set_quota_dimensions<T, K, V>(mut self, v: T) -> Self
396 where
397 T: std::iter::IntoIterator<Item = (K, V)>,
398 K: std::convert::Into<std::string::String>,
399 V: std::convert::Into<std::string::String>,
400 {
401 use std::iter::Iterator;
402 self.quota_dimensions = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
403 self
404 }
405
406 /// Sets the value of [quota_value][crate::model::quota_failure::Violation::quota_value].
407 pub fn set_quota_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
408 self.quota_value = v.into();
409 self
410 }
411
412 /// Sets the value of [future_quota_value][crate::model::quota_failure::Violation::future_quota_value].
413 pub fn set_future_quota_value<T>(mut self, v: T) -> Self
414 where
415 T: std::convert::Into<i64>,
416 {
417 self.future_quota_value = std::option::Option::Some(v.into());
418 self
419 }
420
421 /// Sets or clears the value of [future_quota_value][crate::model::quota_failure::Violation::future_quota_value].
422 pub fn set_or_clear_future_quota_value<T>(mut self, v: std::option::Option<T>) -> Self
423 where
424 T: std::convert::Into<i64>,
425 {
426 self.future_quota_value = v.map(|x| x.into());
427 self
428 }
429 }
430
431 impl wkt::message::Message for Violation {
432 fn typename() -> &'static str {
433 "type.googleapis.com/google.rpc.QuotaFailure.Violation"
434 }
435 }
436}
437
438/// Describes what preconditions have failed.
439///
440/// For example, if an RPC failed because it required the Terms of Service to be
441/// acknowledged, it could list the terms of service violation in the
442/// PreconditionFailure message.
443#[derive(Clone, Default, PartialEq)]
444#[non_exhaustive]
445pub struct PreconditionFailure {
446 /// Describes all precondition violations.
447 pub violations: std::vec::Vec<crate::model::precondition_failure::Violation>,
448
449 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
450}
451
452impl PreconditionFailure {
453 pub fn new() -> Self {
454 std::default::Default::default()
455 }
456
457 /// Sets the value of [violations][crate::model::PreconditionFailure::violations].
458 pub fn set_violations<T, V>(mut self, v: T) -> Self
459 where
460 T: std::iter::IntoIterator<Item = V>,
461 V: std::convert::Into<crate::model::precondition_failure::Violation>,
462 {
463 use std::iter::Iterator;
464 self.violations = v.into_iter().map(|i| i.into()).collect();
465 self
466 }
467}
468
469impl wkt::message::Message for PreconditionFailure {
470 fn typename() -> &'static str {
471 "type.googleapis.com/google.rpc.PreconditionFailure"
472 }
473}
474
475/// Defines additional types related to [PreconditionFailure].
476pub mod precondition_failure {
477 #[allow(unused_imports)]
478 use super::*;
479
480 /// A message type used to describe a single precondition failure.
481 #[derive(Clone, Default, PartialEq)]
482 #[non_exhaustive]
483 pub struct Violation {
484 /// The type of PreconditionFailure. We recommend using a service-specific
485 /// enum type to define the supported precondition violation subjects. For
486 /// example, "TOS" for "Terms of Service violation".
487 pub r#type: std::string::String,
488
489 /// The subject, relative to the type, that failed.
490 /// For example, "google.com/cloud" relative to the "TOS" type would indicate
491 /// which terms of service is being referenced.
492 pub subject: std::string::String,
493
494 /// A description of how the precondition failed. Developers can use this
495 /// description to understand how to fix the failure.
496 ///
497 /// For example: "Terms of service not accepted".
498 pub description: std::string::String,
499
500 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
501 }
502
503 impl Violation {
504 pub fn new() -> Self {
505 std::default::Default::default()
506 }
507
508 /// Sets the value of [r#type][crate::model::precondition_failure::Violation::type].
509 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
510 self.r#type = v.into();
511 self
512 }
513
514 /// Sets the value of [subject][crate::model::precondition_failure::Violation::subject].
515 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
516 self.subject = v.into();
517 self
518 }
519
520 /// Sets the value of [description][crate::model::precondition_failure::Violation::description].
521 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
522 self.description = v.into();
523 self
524 }
525 }
526
527 impl wkt::message::Message for Violation {
528 fn typename() -> &'static str {
529 "type.googleapis.com/google.rpc.PreconditionFailure.Violation"
530 }
531 }
532}
533
534/// Describes violations in a client request. This error type focuses on the
535/// syntactic aspects of the request.
536#[derive(Clone, Default, PartialEq)]
537#[non_exhaustive]
538pub struct BadRequest {
539 /// Describes all violations in a client request.
540 pub field_violations: std::vec::Vec<crate::model::bad_request::FieldViolation>,
541
542 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
543}
544
545impl BadRequest {
546 pub fn new() -> Self {
547 std::default::Default::default()
548 }
549
550 /// Sets the value of [field_violations][crate::model::BadRequest::field_violations].
551 pub fn set_field_violations<T, V>(mut self, v: T) -> Self
552 where
553 T: std::iter::IntoIterator<Item = V>,
554 V: std::convert::Into<crate::model::bad_request::FieldViolation>,
555 {
556 use std::iter::Iterator;
557 self.field_violations = v.into_iter().map(|i| i.into()).collect();
558 self
559 }
560}
561
562impl wkt::message::Message for BadRequest {
563 fn typename() -> &'static str {
564 "type.googleapis.com/google.rpc.BadRequest"
565 }
566}
567
568/// Defines additional types related to [BadRequest].
569pub mod bad_request {
570 #[allow(unused_imports)]
571 use super::*;
572
573 /// A message type used to describe a single bad request field.
574 #[derive(Clone, Default, PartialEq)]
575 #[non_exhaustive]
576 pub struct FieldViolation {
577 /// A path that leads to a field in the request body. The value will be a
578 /// sequence of dot-separated identifiers that identify a protocol buffer
579 /// field.
580 ///
581 /// Consider the following:
582 ///
583 /// ```norust
584 /// message CreateContactRequest {
585 /// message EmailAddress {
586 /// enum Type {
587 /// TYPE_UNSPECIFIED = 0;
588 /// HOME = 1;
589 /// WORK = 2;
590 /// }
591 ///
592 /// optional string email = 1;
593 /// repeated EmailType type = 2;
594 /// }
595 ///
596 /// string full_name = 1;
597 /// repeated EmailAddress email_addresses = 2;
598 /// }
599 /// ```
600 ///
601 /// In this example, in proto `field` could take one of the following values:
602 ///
603 /// * `full_name` for a violation in the `full_name` value
604 /// * `email_addresses[1].email` for a violation in the `email` field of the
605 /// first `email_addresses` message
606 /// * `email_addresses[3].type[2]` for a violation in the second `type`
607 /// value in the third `email_addresses` message.
608 ///
609 /// In JSON, the same values are represented as:
610 ///
611 /// * `fullName` for a violation in the `fullName` value
612 /// * `emailAddresses[1].email` for a violation in the `email` field of the
613 /// first `emailAddresses` message
614 /// * `emailAddresses[3].type[2]` for a violation in the second `type`
615 /// value in the third `emailAddresses` message.
616 pub field: std::string::String,
617
618 /// A description of why the request element is bad.
619 pub description: std::string::String,
620
621 /// The reason of the field-level error. This is a constant value that
622 /// identifies the proximate cause of the field-level error. It should
623 /// uniquely identify the type of the FieldViolation within the scope of the
624 /// google.rpc.ErrorInfo.domain. This should be at most 63
625 /// characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`,
626 /// which represents UPPER_SNAKE_CASE.
627 pub reason: std::string::String,
628
629 /// Provides a localized error message for field-level errors that is safe to
630 /// return to the API consumer.
631 pub localized_message: std::option::Option<crate::model::LocalizedMessage>,
632
633 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
634 }
635
636 impl FieldViolation {
637 pub fn new() -> Self {
638 std::default::Default::default()
639 }
640
641 /// Sets the value of [field][crate::model::bad_request::FieldViolation::field].
642 pub fn set_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
643 self.field = v.into();
644 self
645 }
646
647 /// Sets the value of [description][crate::model::bad_request::FieldViolation::description].
648 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
649 self.description = v.into();
650 self
651 }
652
653 /// Sets the value of [reason][crate::model::bad_request::FieldViolation::reason].
654 pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
655 self.reason = v.into();
656 self
657 }
658
659 /// Sets the value of [localized_message][crate::model::bad_request::FieldViolation::localized_message].
660 pub fn set_localized_message<T>(mut self, v: T) -> Self
661 where
662 T: std::convert::Into<crate::model::LocalizedMessage>,
663 {
664 self.localized_message = std::option::Option::Some(v.into());
665 self
666 }
667
668 /// Sets or clears the value of [localized_message][crate::model::bad_request::FieldViolation::localized_message].
669 pub fn set_or_clear_localized_message<T>(mut self, v: std::option::Option<T>) -> Self
670 where
671 T: std::convert::Into<crate::model::LocalizedMessage>,
672 {
673 self.localized_message = v.map(|x| x.into());
674 self
675 }
676 }
677
678 impl wkt::message::Message for FieldViolation {
679 fn typename() -> &'static str {
680 "type.googleapis.com/google.rpc.BadRequest.FieldViolation"
681 }
682 }
683}
684
685/// Contains metadata about the request that clients can attach when filing a bug
686/// or providing other forms of feedback.
687#[derive(Clone, Default, PartialEq)]
688#[non_exhaustive]
689pub struct RequestInfo {
690 /// An opaque string that should only be interpreted by the service generating
691 /// it. For example, it can be used to identify requests in the service's logs.
692 pub request_id: std::string::String,
693
694 /// Any data that was used to serve this request. For example, an encrypted
695 /// stack trace that can be sent back to the service provider for debugging.
696 pub serving_data: std::string::String,
697
698 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
699}
700
701impl RequestInfo {
702 pub fn new() -> Self {
703 std::default::Default::default()
704 }
705
706 /// Sets the value of [request_id][crate::model::RequestInfo::request_id].
707 pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
708 self.request_id = v.into();
709 self
710 }
711
712 /// Sets the value of [serving_data][crate::model::RequestInfo::serving_data].
713 pub fn set_serving_data<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
714 self.serving_data = v.into();
715 self
716 }
717}
718
719impl wkt::message::Message for RequestInfo {
720 fn typename() -> &'static str {
721 "type.googleapis.com/google.rpc.RequestInfo"
722 }
723}
724
725/// Describes the resource that is being accessed.
726#[derive(Clone, Default, PartialEq)]
727#[non_exhaustive]
728pub struct ResourceInfo {
729 /// A name for the type of resource being accessed, e.g. "sql table",
730 /// "cloud storage bucket", "file", "Google calendar"; or the type URL
731 /// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
732 pub resource_type: std::string::String,
733
734 /// The name of the resource being accessed. For example, a shared calendar
735 /// name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
736 /// error is
737 /// [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
738 ///
739 /// [google.rpc.Code.PERMISSION_DENIED]: crate::model::Code::PermissionDenied
740 pub resource_name: std::string::String,
741
742 /// The owner of the resource (optional).
743 /// For example, "user:\<owner email\>" or "project:\<Google developer project
744 /// id\>".
745 pub owner: std::string::String,
746
747 /// Describes what error is encountered when accessing this resource.
748 /// For example, updating a cloud project may require the `writer` permission
749 /// on the developer console project.
750 pub description: std::string::String,
751
752 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
753}
754
755impl ResourceInfo {
756 pub fn new() -> Self {
757 std::default::Default::default()
758 }
759
760 /// Sets the value of [resource_type][crate::model::ResourceInfo::resource_type].
761 pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
762 self.resource_type = v.into();
763 self
764 }
765
766 /// Sets the value of [resource_name][crate::model::ResourceInfo::resource_name].
767 pub fn set_resource_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
768 self.resource_name = v.into();
769 self
770 }
771
772 /// Sets the value of [owner][crate::model::ResourceInfo::owner].
773 pub fn set_owner<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
774 self.owner = v.into();
775 self
776 }
777
778 /// Sets the value of [description][crate::model::ResourceInfo::description].
779 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
780 self.description = v.into();
781 self
782 }
783}
784
785impl wkt::message::Message for ResourceInfo {
786 fn typename() -> &'static str {
787 "type.googleapis.com/google.rpc.ResourceInfo"
788 }
789}
790
791/// Provides links to documentation or for performing an out of band action.
792///
793/// For example, if a quota check failed with an error indicating the calling
794/// project hasn't enabled the accessed service, this can contain a URL pointing
795/// directly to the right place in the developer console to flip the bit.
796#[derive(Clone, Default, PartialEq)]
797#[non_exhaustive]
798pub struct Help {
799 /// URL(s) pointing to additional information on handling the current error.
800 pub links: std::vec::Vec<crate::model::help::Link>,
801
802 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
803}
804
805impl Help {
806 pub fn new() -> Self {
807 std::default::Default::default()
808 }
809
810 /// Sets the value of [links][crate::model::Help::links].
811 pub fn set_links<T, V>(mut self, v: T) -> Self
812 where
813 T: std::iter::IntoIterator<Item = V>,
814 V: std::convert::Into<crate::model::help::Link>,
815 {
816 use std::iter::Iterator;
817 self.links = v.into_iter().map(|i| i.into()).collect();
818 self
819 }
820}
821
822impl wkt::message::Message for Help {
823 fn typename() -> &'static str {
824 "type.googleapis.com/google.rpc.Help"
825 }
826}
827
828/// Defines additional types related to [Help].
829pub mod help {
830 #[allow(unused_imports)]
831 use super::*;
832
833 /// Describes a URL link.
834 #[derive(Clone, Default, PartialEq)]
835 #[non_exhaustive]
836 pub struct Link {
837 /// Describes what the link offers.
838 pub description: std::string::String,
839
840 /// The URL of the link.
841 pub url: std::string::String,
842
843 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
844 }
845
846 impl Link {
847 pub fn new() -> Self {
848 std::default::Default::default()
849 }
850
851 /// Sets the value of [description][crate::model::help::Link::description].
852 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
853 self.description = v.into();
854 self
855 }
856
857 /// Sets the value of [url][crate::model::help::Link::url].
858 pub fn set_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
859 self.url = v.into();
860 self
861 }
862 }
863
864 impl wkt::message::Message for Link {
865 fn typename() -> &'static str {
866 "type.googleapis.com/google.rpc.Help.Link"
867 }
868 }
869}
870
871/// Provides a localized error message that is safe to return to the user
872/// which can be attached to an RPC error.
873#[derive(Clone, Default, PartialEq)]
874#[non_exhaustive]
875pub struct LocalizedMessage {
876 /// The locale used following the specification defined at
877 /// <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>.
878 /// Examples are: "en-US", "fr-CH", "es-MX"
879 pub locale: std::string::String,
880
881 /// The localized error message in the above locale.
882 pub message: std::string::String,
883
884 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
885}
886
887impl LocalizedMessage {
888 pub fn new() -> Self {
889 std::default::Default::default()
890 }
891
892 /// Sets the value of [locale][crate::model::LocalizedMessage::locale].
893 pub fn set_locale<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
894 self.locale = v.into();
895 self
896 }
897
898 /// Sets the value of [message][crate::model::LocalizedMessage::message].
899 pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
900 self.message = v.into();
901 self
902 }
903}
904
905impl wkt::message::Message for LocalizedMessage {
906 fn typename() -> &'static str {
907 "type.googleapis.com/google.rpc.LocalizedMessage"
908 }
909}
910
911/// Represents an HTTP request.
912#[derive(Clone, Default, PartialEq)]
913#[non_exhaustive]
914pub struct HttpRequest {
915 /// The HTTP request method.
916 pub method: std::string::String,
917
918 /// The HTTP request URI.
919 pub uri: std::string::String,
920
921 /// The HTTP request headers. The ordering of the headers is significant.
922 /// Multiple headers with the same key may present for the request.
923 pub headers: std::vec::Vec<crate::model::HttpHeader>,
924
925 /// The HTTP request body. If the body is not expected, it should be empty.
926 pub body: ::bytes::Bytes,
927
928 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
929}
930
931impl HttpRequest {
932 pub fn new() -> Self {
933 std::default::Default::default()
934 }
935
936 /// Sets the value of [method][crate::model::HttpRequest::method].
937 pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
938 self.method = v.into();
939 self
940 }
941
942 /// Sets the value of [uri][crate::model::HttpRequest::uri].
943 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
944 self.uri = v.into();
945 self
946 }
947
948 /// Sets the value of [headers][crate::model::HttpRequest::headers].
949 pub fn set_headers<T, V>(mut self, v: T) -> Self
950 where
951 T: std::iter::IntoIterator<Item = V>,
952 V: std::convert::Into<crate::model::HttpHeader>,
953 {
954 use std::iter::Iterator;
955 self.headers = v.into_iter().map(|i| i.into()).collect();
956 self
957 }
958
959 /// Sets the value of [body][crate::model::HttpRequest::body].
960 pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
961 self.body = v.into();
962 self
963 }
964}
965
966impl wkt::message::Message for HttpRequest {
967 fn typename() -> &'static str {
968 "type.googleapis.com/google.rpc.HttpRequest"
969 }
970}
971
972/// Represents an HTTP response.
973#[derive(Clone, Default, PartialEq)]
974#[non_exhaustive]
975pub struct HttpResponse {
976 /// The HTTP status code, such as 200 or 404.
977 pub status: i32,
978
979 /// The HTTP reason phrase, such as "OK" or "Not Found".
980 pub reason: std::string::String,
981
982 /// The HTTP response headers. The ordering of the headers is significant.
983 /// Multiple headers with the same key may present for the response.
984 pub headers: std::vec::Vec<crate::model::HttpHeader>,
985
986 /// The HTTP response body. If the body is not expected, it should be empty.
987 pub body: ::bytes::Bytes,
988
989 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
990}
991
992impl HttpResponse {
993 pub fn new() -> Self {
994 std::default::Default::default()
995 }
996
997 /// Sets the value of [status][crate::model::HttpResponse::status].
998 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
999 self.status = v.into();
1000 self
1001 }
1002
1003 /// Sets the value of [reason][crate::model::HttpResponse::reason].
1004 pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1005 self.reason = v.into();
1006 self
1007 }
1008
1009 /// Sets the value of [headers][crate::model::HttpResponse::headers].
1010 pub fn set_headers<T, V>(mut self, v: T) -> Self
1011 where
1012 T: std::iter::IntoIterator<Item = V>,
1013 V: std::convert::Into<crate::model::HttpHeader>,
1014 {
1015 use std::iter::Iterator;
1016 self.headers = v.into_iter().map(|i| i.into()).collect();
1017 self
1018 }
1019
1020 /// Sets the value of [body][crate::model::HttpResponse::body].
1021 pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
1022 self.body = v.into();
1023 self
1024 }
1025}
1026
1027impl wkt::message::Message for HttpResponse {
1028 fn typename() -> &'static str {
1029 "type.googleapis.com/google.rpc.HttpResponse"
1030 }
1031}
1032
1033/// Represents an HTTP header.
1034#[derive(Clone, Default, PartialEq)]
1035#[non_exhaustive]
1036pub struct HttpHeader {
1037 /// The HTTP header key. It is case insensitive.
1038 pub key: std::string::String,
1039
1040 /// The HTTP header value.
1041 pub value: std::string::String,
1042
1043 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1044}
1045
1046impl HttpHeader {
1047 pub fn new() -> Self {
1048 std::default::Default::default()
1049 }
1050
1051 /// Sets the value of [key][crate::model::HttpHeader::key].
1052 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1053 self.key = v.into();
1054 self
1055 }
1056
1057 /// Sets the value of [value][crate::model::HttpHeader::value].
1058 pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1059 self.value = v.into();
1060 self
1061 }
1062}
1063
1064impl wkt::message::Message for HttpHeader {
1065 fn typename() -> &'static str {
1066 "type.googleapis.com/google.rpc.HttpHeader"
1067 }
1068}
1069
1070/// The `Status` type defines a logical error model that is suitable for
1071/// different programming environments, including REST APIs and RPC APIs. It is
1072/// used by [gRPC](https://github.com/grpc). Each `Status` message contains
1073/// three pieces of data: error code, error message, and error details.
1074///
1075/// You can find out more about this error model and how to work with it in the
1076/// [API Design Guide](https://cloud.google.com/apis/design/errors).
1077#[derive(Clone, Default, PartialEq)]
1078#[non_exhaustive]
1079pub struct Status {
1080 /// The status code, which should be an enum value of
1081 /// [google.rpc.Code][google.rpc.Code].
1082 ///
1083 /// [google.rpc.Code]: crate::model::Code
1084 pub code: i32,
1085
1086 /// A developer-facing error message, which should be in English. Any
1087 /// user-facing error message should be localized and sent in the
1088 /// [google.rpc.Status.details][google.rpc.Status.details] field, or localized
1089 /// by the client.
1090 ///
1091 /// [google.rpc.Status.details]: crate::model::Status::details
1092 pub message: std::string::String,
1093
1094 /// A list of messages that carry the error details. There is a common set of
1095 /// message types for APIs to use.
1096 pub details: std::vec::Vec<wkt::Any>,
1097
1098 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1099}
1100
1101impl Status {
1102 pub fn new() -> Self {
1103 std::default::Default::default()
1104 }
1105
1106 /// Sets the value of [code][crate::model::Status::code].
1107 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1108 self.code = v.into();
1109 self
1110 }
1111
1112 /// Sets the value of [message][crate::model::Status::message].
1113 pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1114 self.message = v.into();
1115 self
1116 }
1117
1118 /// Sets the value of [details][crate::model::Status::details].
1119 pub fn set_details<T, V>(mut self, v: T) -> Self
1120 where
1121 T: std::iter::IntoIterator<Item = V>,
1122 V: std::convert::Into<wkt::Any>,
1123 {
1124 use std::iter::Iterator;
1125 self.details = v.into_iter().map(|i| i.into()).collect();
1126 self
1127 }
1128}
1129
1130impl wkt::message::Message for Status {
1131 fn typename() -> &'static str {
1132 "type.googleapis.com/google.rpc.Status"
1133 }
1134}
1135
1136/// The canonical error codes for gRPC APIs.
1137///
1138/// Sometimes multiple error codes may apply. Services should return
1139/// the most specific error code that applies. For example, prefer
1140/// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
1141/// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
1142///
1143/// # Working with unknown values
1144///
1145/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1146/// additional enum variants at any time. Adding new variants is not considered
1147/// a breaking change. Applications should write their code in anticipation of:
1148///
1149/// - New values appearing in future releases of the client library, **and**
1150/// - New values received dynamically, without application changes.
1151///
1152/// Please consult the [Working with enums] section in the user guide for some
1153/// guidelines.
1154///
1155/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1156#[derive(Clone, Debug, PartialEq)]
1157#[non_exhaustive]
1158pub enum Code {
1159 /// Not an error; returned on success.
1160 ///
1161 /// HTTP Mapping: 200 OK
1162 Ok,
1163 /// The operation was cancelled, typically by the caller.
1164 ///
1165 /// HTTP Mapping: 499 Client Closed Request
1166 Cancelled,
1167 /// Unknown error. For example, this error may be returned when
1168 /// a `Status` value received from another address space belongs to
1169 /// an error space that is not known in this address space. Also
1170 /// errors raised by APIs that do not return enough error information
1171 /// may be converted to this error.
1172 ///
1173 /// HTTP Mapping: 500 Internal Server Error
1174 Unknown,
1175 /// The client specified an invalid argument. Note that this differs
1176 /// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
1177 /// that are problematic regardless of the state of the system
1178 /// (e.g., a malformed file name).
1179 ///
1180 /// HTTP Mapping: 400 Bad Request
1181 InvalidArgument,
1182 /// The deadline expired before the operation could complete. For operations
1183 /// that change the state of the system, this error may be returned
1184 /// even if the operation has completed successfully. For example, a
1185 /// successful response from a server could have been delayed long
1186 /// enough for the deadline to expire.
1187 ///
1188 /// HTTP Mapping: 504 Gateway Timeout
1189 DeadlineExceeded,
1190 /// Some requested entity (e.g., file or directory) was not found.
1191 ///
1192 /// Note to server developers: if a request is denied for an entire class
1193 /// of users, such as gradual feature rollout or undocumented allowlist,
1194 /// `NOT_FOUND` may be used. If a request is denied for some users within
1195 /// a class of users, such as user-based access control, `PERMISSION_DENIED`
1196 /// must be used.
1197 ///
1198 /// HTTP Mapping: 404 Not Found
1199 NotFound,
1200 /// The entity that a client attempted to create (e.g., file or directory)
1201 /// already exists.
1202 ///
1203 /// HTTP Mapping: 409 Conflict
1204 AlreadyExists,
1205 /// The caller does not have permission to execute the specified
1206 /// operation. `PERMISSION_DENIED` must not be used for rejections
1207 /// caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
1208 /// instead for those errors). `PERMISSION_DENIED` must not be
1209 /// used if the caller can not be identified (use `UNAUTHENTICATED`
1210 /// instead for those errors). This error code does not imply the
1211 /// request is valid or the requested entity exists or satisfies
1212 /// other pre-conditions.
1213 ///
1214 /// HTTP Mapping: 403 Forbidden
1215 PermissionDenied,
1216 /// The request does not have valid authentication credentials for the
1217 /// operation.
1218 ///
1219 /// HTTP Mapping: 401 Unauthorized
1220 Unauthenticated,
1221 /// Some resource has been exhausted, perhaps a per-user quota, or
1222 /// perhaps the entire file system is out of space.
1223 ///
1224 /// HTTP Mapping: 429 Too Many Requests
1225 ResourceExhausted,
1226 /// The operation was rejected because the system is not in a state
1227 /// required for the operation's execution. For example, the directory
1228 /// to be deleted is non-empty, an rmdir operation is applied to
1229 /// a non-directory, etc.
1230 ///
1231 /// Service implementors can use the following guidelines to decide
1232 /// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
1233 /// (a) Use `UNAVAILABLE` if the client can retry just the failing call.
1234 /// (b) Use `ABORTED` if the client should retry at a higher level. For
1235 /// example, when a client-specified test-and-set fails, indicating the
1236 /// client should restart a read-modify-write sequence.
1237 /// (c) Use `FAILED_PRECONDITION` if the client should not retry until
1238 /// the system state has been explicitly fixed. For example, if an "rmdir"
1239 /// fails because the directory is non-empty, `FAILED_PRECONDITION`
1240 /// should be returned since the client should not retry unless
1241 /// the files are deleted from the directory.
1242 ///
1243 /// HTTP Mapping: 400 Bad Request
1244 FailedPrecondition,
1245 /// The operation was aborted, typically due to a concurrency issue such as
1246 /// a sequencer check failure or transaction abort.
1247 ///
1248 /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
1249 /// `ABORTED`, and `UNAVAILABLE`.
1250 ///
1251 /// HTTP Mapping: 409 Conflict
1252 Aborted,
1253 /// The operation was attempted past the valid range. E.g., seeking or
1254 /// reading past end-of-file.
1255 ///
1256 /// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
1257 /// be fixed if the system state changes. For example, a 32-bit file
1258 /// system will generate `INVALID_ARGUMENT` if asked to read at an
1259 /// offset that is not in the range [0,2^32-1], but it will generate
1260 /// `OUT_OF_RANGE` if asked to read from an offset past the current
1261 /// file size.
1262 ///
1263 /// There is a fair bit of overlap between `FAILED_PRECONDITION` and
1264 /// `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
1265 /// error) when it applies so that callers who are iterating through
1266 /// a space can easily look for an `OUT_OF_RANGE` error to detect when
1267 /// they are done.
1268 ///
1269 /// HTTP Mapping: 400 Bad Request
1270 OutOfRange,
1271 /// The operation is not implemented or is not supported/enabled in this
1272 /// service.
1273 ///
1274 /// HTTP Mapping: 501 Not Implemented
1275 Unimplemented,
1276 /// Internal errors. This means that some invariants expected by the
1277 /// underlying system have been broken. This error code is reserved
1278 /// for serious errors.
1279 ///
1280 /// HTTP Mapping: 500 Internal Server Error
1281 Internal,
1282 /// The service is currently unavailable. This is most likely a
1283 /// transient condition, which can be corrected by retrying with
1284 /// a backoff. Note that it is not always safe to retry
1285 /// non-idempotent operations.
1286 ///
1287 /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
1288 /// `ABORTED`, and `UNAVAILABLE`.
1289 ///
1290 /// HTTP Mapping: 503 Service Unavailable
1291 Unavailable,
1292 /// Unrecoverable data loss or corruption.
1293 ///
1294 /// HTTP Mapping: 500 Internal Server Error
1295 DataLoss,
1296 /// If set, the enum was initialized with an unknown value.
1297 ///
1298 /// Applications can examine the value using [Code::value] or
1299 /// [Code::name].
1300 UnknownValue(code::UnknownValue),
1301}
1302
1303#[doc(hidden)]
1304pub mod code {
1305 #[allow(unused_imports)]
1306 use super::*;
1307 #[derive(Clone, Debug, PartialEq)]
1308 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1309}
1310
1311impl Code {
1312 /// Gets the enum value.
1313 ///
1314 /// Returns `None` if the enum contains an unknown value deserialized from
1315 /// the string representation of enums.
1316 pub fn value(&self) -> std::option::Option<i32> {
1317 match self {
1318 Self::Ok => std::option::Option::Some(0),
1319 Self::Cancelled => std::option::Option::Some(1),
1320 Self::Unknown => std::option::Option::Some(2),
1321 Self::InvalidArgument => std::option::Option::Some(3),
1322 Self::DeadlineExceeded => std::option::Option::Some(4),
1323 Self::NotFound => std::option::Option::Some(5),
1324 Self::AlreadyExists => std::option::Option::Some(6),
1325 Self::PermissionDenied => std::option::Option::Some(7),
1326 Self::Unauthenticated => std::option::Option::Some(16),
1327 Self::ResourceExhausted => std::option::Option::Some(8),
1328 Self::FailedPrecondition => std::option::Option::Some(9),
1329 Self::Aborted => std::option::Option::Some(10),
1330 Self::OutOfRange => std::option::Option::Some(11),
1331 Self::Unimplemented => std::option::Option::Some(12),
1332 Self::Internal => std::option::Option::Some(13),
1333 Self::Unavailable => std::option::Option::Some(14),
1334 Self::DataLoss => std::option::Option::Some(15),
1335 Self::UnknownValue(u) => u.0.value(),
1336 }
1337 }
1338
1339 /// Gets the enum value as a string.
1340 ///
1341 /// Returns `None` if the enum contains an unknown value deserialized from
1342 /// the integer representation of enums.
1343 pub fn name(&self) -> std::option::Option<&str> {
1344 match self {
1345 Self::Ok => std::option::Option::Some("OK"),
1346 Self::Cancelled => std::option::Option::Some("CANCELLED"),
1347 Self::Unknown => std::option::Option::Some("UNKNOWN"),
1348 Self::InvalidArgument => std::option::Option::Some("INVALID_ARGUMENT"),
1349 Self::DeadlineExceeded => std::option::Option::Some("DEADLINE_EXCEEDED"),
1350 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
1351 Self::AlreadyExists => std::option::Option::Some("ALREADY_EXISTS"),
1352 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
1353 Self::Unauthenticated => std::option::Option::Some("UNAUTHENTICATED"),
1354 Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
1355 Self::FailedPrecondition => std::option::Option::Some("FAILED_PRECONDITION"),
1356 Self::Aborted => std::option::Option::Some("ABORTED"),
1357 Self::OutOfRange => std::option::Option::Some("OUT_OF_RANGE"),
1358 Self::Unimplemented => std::option::Option::Some("UNIMPLEMENTED"),
1359 Self::Internal => std::option::Option::Some("INTERNAL"),
1360 Self::Unavailable => std::option::Option::Some("UNAVAILABLE"),
1361 Self::DataLoss => std::option::Option::Some("DATA_LOSS"),
1362 Self::UnknownValue(u) => u.0.name(),
1363 }
1364 }
1365}
1366
1367impl std::default::Default for Code {
1368 fn default() -> Self {
1369 use std::convert::From;
1370 Self::from(0)
1371 }
1372}
1373
1374impl std::fmt::Display for Code {
1375 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1376 wkt::internal::display_enum(f, self.name(), self.value())
1377 }
1378}
1379
1380impl std::convert::From<i32> for Code {
1381 fn from(value: i32) -> Self {
1382 match value {
1383 0 => Self::Ok,
1384 1 => Self::Cancelled,
1385 2 => Self::Unknown,
1386 3 => Self::InvalidArgument,
1387 4 => Self::DeadlineExceeded,
1388 5 => Self::NotFound,
1389 6 => Self::AlreadyExists,
1390 7 => Self::PermissionDenied,
1391 8 => Self::ResourceExhausted,
1392 9 => Self::FailedPrecondition,
1393 10 => Self::Aborted,
1394 11 => Self::OutOfRange,
1395 12 => Self::Unimplemented,
1396 13 => Self::Internal,
1397 14 => Self::Unavailable,
1398 15 => Self::DataLoss,
1399 16 => Self::Unauthenticated,
1400 _ => Self::UnknownValue(code::UnknownValue(
1401 wkt::internal::UnknownEnumValue::Integer(value),
1402 )),
1403 }
1404 }
1405}
1406
1407impl std::convert::From<&str> for Code {
1408 fn from(value: &str) -> Self {
1409 use std::string::ToString;
1410 match value {
1411 "OK" => Self::Ok,
1412 "CANCELLED" => Self::Cancelled,
1413 "UNKNOWN" => Self::Unknown,
1414 "INVALID_ARGUMENT" => Self::InvalidArgument,
1415 "DEADLINE_EXCEEDED" => Self::DeadlineExceeded,
1416 "NOT_FOUND" => Self::NotFound,
1417 "ALREADY_EXISTS" => Self::AlreadyExists,
1418 "PERMISSION_DENIED" => Self::PermissionDenied,
1419 "UNAUTHENTICATED" => Self::Unauthenticated,
1420 "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
1421 "FAILED_PRECONDITION" => Self::FailedPrecondition,
1422 "ABORTED" => Self::Aborted,
1423 "OUT_OF_RANGE" => Self::OutOfRange,
1424 "UNIMPLEMENTED" => Self::Unimplemented,
1425 "INTERNAL" => Self::Internal,
1426 "UNAVAILABLE" => Self::Unavailable,
1427 "DATA_LOSS" => Self::DataLoss,
1428 _ => Self::UnknownValue(code::UnknownValue(wkt::internal::UnknownEnumValue::String(
1429 value.to_string(),
1430 ))),
1431 }
1432 }
1433}
1434
1435impl serde::ser::Serialize for Code {
1436 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1437 where
1438 S: serde::Serializer,
1439 {
1440 match self {
1441 Self::Ok => serializer.serialize_i32(0),
1442 Self::Cancelled => serializer.serialize_i32(1),
1443 Self::Unknown => serializer.serialize_i32(2),
1444 Self::InvalidArgument => serializer.serialize_i32(3),
1445 Self::DeadlineExceeded => serializer.serialize_i32(4),
1446 Self::NotFound => serializer.serialize_i32(5),
1447 Self::AlreadyExists => serializer.serialize_i32(6),
1448 Self::PermissionDenied => serializer.serialize_i32(7),
1449 Self::Unauthenticated => serializer.serialize_i32(16),
1450 Self::ResourceExhausted => serializer.serialize_i32(8),
1451 Self::FailedPrecondition => serializer.serialize_i32(9),
1452 Self::Aborted => serializer.serialize_i32(10),
1453 Self::OutOfRange => serializer.serialize_i32(11),
1454 Self::Unimplemented => serializer.serialize_i32(12),
1455 Self::Internal => serializer.serialize_i32(13),
1456 Self::Unavailable => serializer.serialize_i32(14),
1457 Self::DataLoss => serializer.serialize_i32(15),
1458 Self::UnknownValue(u) => u.0.serialize(serializer),
1459 }
1460 }
1461}
1462
1463impl<'de> serde::de::Deserialize<'de> for Code {
1464 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1465 where
1466 D: serde::Deserializer<'de>,
1467 {
1468 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(".google.rpc.Code"))
1469 }
1470}