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