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