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