Skip to main content

aws_sdk_devopsguru/types/error/
_throttling_exception.rs

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