Skip to main content

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