Skip to main content

aws_sdk_m2/types/error/
_throttling_exception.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The number of requests made exceeds the limit.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ThrottlingException {
7    #[allow(missing_docs)] // documentation missing in model
8    pub message: ::std::string::String,
9    /// <p>The identifier of the service that the throttled request was made to.</p>
10    pub service_code: ::std::option::Option<::std::string::String>,
11    /// <p>The identifier of the throttled request.</p>
12    pub quota_code: ::std::option::Option<::std::string::String>,
13    /// <p>The number of seconds to wait before retrying the request.</p>
14    pub retry_after_seconds: i32,
15    pub(crate) meta: ::aws_smithy_types::error::ErrorMetadata,
16}
17impl ThrottlingException {
18    /// <p>The identifier of the service that the throttled request was made to.</p>
19    pub fn service_code(&self) -> ::std::option::Option<&str> {
20        self.service_code.as_deref()
21    }
22    /// <p>The identifier of the throttled request.</p>
23    pub fn quota_code(&self) -> ::std::option::Option<&str> {
24        self.quota_code.as_deref()
25    }
26    /// <p>The number of seconds to wait before retrying the request.</p>
27    pub fn retry_after_seconds(&self) -> i32 {
28        self.retry_after_seconds
29    }
30}
31impl ThrottlingException {
32    /// Returns `Some(ErrorKind)` if the error is retryable. Otherwise, returns `None`.
33    pub fn retryable_error_kind(&self) -> ::aws_smithy_types::retry::ErrorKind {
34        ::aws_smithy_types::retry::ErrorKind::ThrottlingError
35    }
36    /// Returns the error message.
37    pub fn message(&self) -> &str {
38        &self.message
39    }
40}
41impl ::std::fmt::Display for ThrottlingException {
42    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43        ::std::write!(f, "ThrottlingException")?;
44        {
45            ::std::write!(f, ": {}", &self.message)?;
46        }
47        Ok(())
48    }
49}
50impl ::std::error::Error for ThrottlingException {}
51impl ::aws_types::request_id::RequestId for crate::types::error::ThrottlingException {
52    fn request_id(&self) -> Option<&str> {
53        use ::aws_smithy_types::error::metadata::ProvideErrorMetadata;
54        self.meta().request_id()
55    }
56}
57impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ThrottlingException {
58    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
59        &self.meta
60    }
61}
62impl ThrottlingException {
63    /// Creates a new builder-style object to manufacture [`ThrottlingException`](crate::types::error::ThrottlingException).
64    pub fn builder() -> crate::types::error::builders::ThrottlingExceptionBuilder {
65        crate::types::error::builders::ThrottlingExceptionBuilder::default()
66    }
67}
68
69/// A builder for [`ThrottlingException`](crate::types::error::ThrottlingException).
70#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
71#[non_exhaustive]
72pub struct ThrottlingExceptionBuilder {
73    pub(crate) message: ::std::option::Option<::std::string::String>,
74    pub(crate) service_code: ::std::option::Option<::std::string::String>,
75    pub(crate) quota_code: ::std::option::Option<::std::string::String>,
76    pub(crate) retry_after_seconds: ::std::option::Option<i32>,
77    meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
78}
79impl ThrottlingExceptionBuilder {
80    #[allow(missing_docs)] // documentation missing in model
81    /// This field is required.
82    pub fn message(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
83        self.message = ::std::option::Option::Some(input.into());
84        self
85    }
86    #[allow(missing_docs)] // documentation missing in model
87    pub fn set_message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
88        self.message = input;
89        self
90    }
91    #[allow(missing_docs)] // documentation missing in model
92    pub fn get_message(&self) -> &::std::option::Option<::std::string::String> {
93        &self.message
94    }
95    /// <p>The identifier of the service that the throttled request was made to.</p>
96    pub fn service_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
97        self.service_code = ::std::option::Option::Some(input.into());
98        self
99    }
100    /// <p>The identifier of the service that the throttled request was made to.</p>
101    pub fn set_service_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102        self.service_code = input;
103        self
104    }
105    /// <p>The identifier of the service that the throttled request was made to.</p>
106    pub fn get_service_code(&self) -> &::std::option::Option<::std::string::String> {
107        &self.service_code
108    }
109    /// <p>The identifier of the throttled request.</p>
110    pub fn quota_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
111        self.quota_code = ::std::option::Option::Some(input.into());
112        self
113    }
114    /// <p>The identifier of the throttled request.</p>
115    pub fn set_quota_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
116        self.quota_code = input;
117        self
118    }
119    /// <p>The identifier of the throttled request.</p>
120    pub fn get_quota_code(&self) -> &::std::option::Option<::std::string::String> {
121        &self.quota_code
122    }
123    /// <p>The number of seconds to wait before retrying the request.</p>
124    pub fn retry_after_seconds(mut self, input: i32) -> Self {
125        self.retry_after_seconds = ::std::option::Option::Some(input);
126        self
127    }
128    /// <p>The number of seconds to wait before retrying the request.</p>
129    pub fn set_retry_after_seconds(mut self, input: ::std::option::Option<i32>) -> Self {
130        self.retry_after_seconds = input;
131        self
132    }
133    /// <p>The number of seconds to wait before retrying the request.</p>
134    pub fn get_retry_after_seconds(&self) -> &::std::option::Option<i32> {
135        &self.retry_after_seconds
136    }
137    /// Sets error metadata
138    pub fn meta(mut self, meta: ::aws_smithy_types::error::ErrorMetadata) -> Self {
139        self.meta = Some(meta);
140        self
141    }
142
143    /// Sets error metadata
144    pub fn set_meta(&mut self, meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>) -> &mut Self {
145        self.meta = meta;
146        self
147    }
148    /// Consumes the builder and constructs a [`ThrottlingException`](crate::types::error::ThrottlingException).
149    /// This method will fail if any of the following fields are not set:
150    /// - [`message`](crate::types::error::builders::ThrottlingExceptionBuilder::message)
151    pub fn build(self) -> ::std::result::Result<crate::types::error::ThrottlingException, ::aws_smithy_types::error::operation::BuildError> {
152        ::std::result::Result::Ok(crate::types::error::ThrottlingException {
153            message: self.message.ok_or_else(|| {
154                ::aws_smithy_types::error::operation::BuildError::missing_field(
155                    "message",
156                    "message was not specified but it is required when building ThrottlingException",
157                )
158            })?,
159            service_code: self.service_code,
160            quota_code: self.quota_code,
161            retry_after_seconds: self.retry_after_seconds.unwrap_or_default(),
162            meta: self.meta.unwrap_or_default(),
163        })
164    }
165}