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