Skip to main content

aws_sdk_lambda/operation/
add_permission.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `AddPermission`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct AddPermission;
6impl AddPermission {
7    /// Creates a new `AddPermission`
8    pub fn new() -> Self {
9        Self
10    }
11    pub(crate) async fn orchestrate(
12        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13        input: crate::operation::add_permission::AddPermissionInput,
14    ) -> ::std::result::Result<
15        crate::operation::add_permission::AddPermissionOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::add_permission::AddPermissionError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::add_permission::AddPermissionError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::add_permission::AddPermissionOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::add_permission::AddPermissionInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        use ::tracing::Instrument;
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Lambda", "AddPermission", input, runtime_plugins, stop_point)
55            // Create a parent span for the entire operation. Includes a random, internal-only,
56            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
57            .instrument(::tracing::debug_span!(
58                "Lambda.AddPermission",
59                "rpc.service" = "Lambda",
60                "rpc.method" = "AddPermission",
61                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62                "rpc.system" = "aws-api",
63            ))
64            .await
65    }
66
67    pub(crate) fn operation_runtime_plugins(
68        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69        client_config: &crate::config::Config,
70        config_override: ::std::option::Option<crate::config::Builder>,
71    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74        if let ::std::option::Option::Some(config_override) = config_override {
75            for plugin in config_override.runtime_plugins.iter().cloned() {
76                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77            }
78            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79                config_override,
80                client_config.config.clone(),
81                &client_config.runtime_components,
82            ));
83        }
84        runtime_plugins
85    }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for AddPermission {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AddPermission");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            AddPermissionRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            AddPermissionResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("AddPermission")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("AddPermission", "Lambda"));
106        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
107        signing_options.double_uri_encode = true;
108        signing_options.content_sha256_header = false;
109        signing_options.normalize_uri_path = true;
110        signing_options.payload_override = None;
111
112        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
113            signing_options,
114            ..::std::default::Default::default()
115        });
116
117        ::std::option::Option::Some(cfg.freeze())
118    }
119
120    fn runtime_components(
121        &self,
122        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
123    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
124        #[allow(unused_mut)]
125        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("AddPermission")
126            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
127                AddPermissionTelemetryInputCaptureInterceptor,
128            ))
129            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
130                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
131            ))
132            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
133                AddPermissionEndpointParamsInterceptor,
134            ))
135            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
136                crate::operation::add_permission::AddPermissionError,
137            >::new())
138            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
139                crate::operation::add_permission::AddPermissionError,
140            >::new())
141            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
142                crate::operation::add_permission::AddPermissionError,
143            >::new())
144            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
145                crate::operation::add_permission::AddPermissionError,
146            >::new());
147
148        ::std::borrow::Cow::Owned(rcb)
149    }
150}
151
152#[derive(Debug)]
153struct AddPermissionTelemetryInputCaptureInterceptor;
154
155#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
156impl ::aws_smithy_runtime_api::client::interceptors::Intercept for AddPermissionTelemetryInputCaptureInterceptor {
157    fn name(&self) -> &'static str {
158        "AddPermissionTelemetryInputCaptureInterceptor"
159    }
160
161    fn read_before_execution(
162        &self,
163        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
164            '_,
165            ::aws_smithy_runtime_api::client::interceptors::context::Input,
166            ::aws_smithy_runtime_api::client::interceptors::context::Output,
167            ::aws_smithy_runtime_api::client::interceptors::context::Error,
168        >,
169        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
170    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
171        // Nothing to do unless the customer opted in by naming members to record.
172        let ::std::option::Option::Some(requested) = cfg
173            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
174            .filter(|r| !r.is_empty())
175        else {
176            return ::std::result::Result::Ok(());
177        };
178
179        let ::std::option::Option::Some(input) = context.input().downcast_ref::<AddPermissionInput>() else {
180            // A mismatched input is not this interceptor's concern; skip quietly.
181            return ::std::result::Result::Ok(());
182        };
183
184        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
185        if requested.should_capture("FunctionName") {
186            if let ::std::option::Option::Some(value) = input.function_name.as_deref() {
187                captured.insert("FunctionName", value);
188            }
189        }
190        if requested.should_capture("StatementId") {
191            if let ::std::option::Option::Some(value) = input.statement_id.as_deref() {
192                captured.insert("StatementId", value);
193            }
194        }
195        if requested.should_capture("Action") {
196            if let ::std::option::Option::Some(value) = input.action.as_deref() {
197                captured.insert("Action", value);
198            }
199        }
200        if requested.should_capture("Principal") {
201            if let ::std::option::Option::Some(value) = input.principal.as_deref() {
202                captured.insert("Principal", value);
203            }
204        }
205        if requested.should_capture("SourceArn") {
206            if let ::std::option::Option::Some(value) = input.source_arn.as_deref() {
207                captured.insert("SourceArn", value);
208            }
209        }
210        if requested.should_capture("SourceAccount") {
211            if let ::std::option::Option::Some(value) = input.source_account.as_deref() {
212                captured.insert("SourceAccount", value);
213            }
214        }
215        if requested.should_capture("EventSourceToken") {
216            if let ::std::option::Option::Some(value) = input.event_source_token.as_deref() {
217                captured.insert("EventSourceToken", value);
218            }
219        }
220        if requested.should_capture("Qualifier") {
221            if let ::std::option::Option::Some(value) = input.qualifier.as_deref() {
222                captured.insert("Qualifier", value);
223            }
224        }
225        if requested.should_capture("RevisionId") {
226            if let ::std::option::Option::Some(value) = input.revision_id.as_deref() {
227                captured.insert("RevisionId", value);
228            }
229        }
230        if requested.should_capture("PrincipalOrgID") {
231            if let ::std::option::Option::Some(value) = input.principal_org_id.as_deref() {
232                captured.insert("PrincipalOrgID", value);
233            }
234        }
235
236        cfg.interceptor_state().store_put(captured);
237        ::std::result::Result::Ok(())
238    }
239}
240#[derive(Debug)]
241struct AddPermissionResponseDeserializer;
242impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for AddPermissionResponseDeserializer {
243    fn deserialize_nonstreaming_with_config(
244        &self,
245        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
246        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
247    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
248        let (success, status) = (response.status().is_success(), response.status().as_u16());
249        let headers = response.headers();
250        let body = response.body().bytes().expect("body loaded");
251        #[allow(unused_mut)]
252        let mut force_error = false;
253        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
254        let parse_result = if !success && status != 201 || force_error {
255            crate::protocol_serde::shape_add_permission::de_add_permission_http_error(status, headers, body)
256        } else {
257            crate::protocol_serde::shape_add_permission::de_add_permission_http_response(status, headers, body)
258        };
259        crate::protocol_serde::type_erase_result(parse_result)
260    }
261}
262#[derive(Debug)]
263struct AddPermissionRequestSerializer;
264impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for AddPermissionRequestSerializer {
265    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
266    fn serialize_input(
267        &self,
268        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
269        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
270    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
271        let input = input
272            .downcast::<crate::operation::add_permission::AddPermissionInput>()
273            .expect("correct type");
274        let _header_serialization_settings = _cfg
275            .load::<crate::serialization_settings::HeaderSerializationSettings>()
276            .cloned()
277            .unwrap_or_default();
278        let mut request_builder = {
279            #[allow(clippy::uninlined_format_args)]
280            fn uri_base(
281                _input: &crate::operation::add_permission::AddPermissionInput,
282                output: &mut ::std::string::String,
283            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
284                use ::std::fmt::Write as _;
285                let input_1 = &_input.function_name;
286                let input_1 = input_1
287                    .as_ref()
288                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("function_name", "cannot be empty or unset"))?;
289                let function_name = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
290                if function_name.is_empty() {
291                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
292                        "function_name",
293                        "cannot be empty or unset",
294                    ));
295                }
296                ::std::write!(output, "/2015-03-31/functions/{FunctionName}/policy", FunctionName = function_name)
297                    .expect("formatting should succeed");
298                ::std::result::Result::Ok(())
299            }
300            fn uri_query(
301                _input: &crate::operation::add_permission::AddPermissionInput,
302                mut output: &mut ::std::string::String,
303            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
304                let mut query = ::aws_smithy_http::query::Writer::new(output);
305                if let ::std::option::Option::Some(inner_2) = &_input.qualifier {
306                    {
307                        query.push_kv("Qualifier", &::aws_smithy_http::query::fmt_string(inner_2));
308                    }
309                }
310                ::std::result::Result::Ok(())
311            }
312            #[allow(clippy::unnecessary_wraps)]
313            fn update_http_builder(
314                input: &crate::operation::add_permission::AddPermissionInput,
315                builder: ::http_1x::request::Builder,
316            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
317                let mut uri = ::std::string::String::new();
318                uri_base(input, &mut uri)?;
319                uri_query(input, &mut uri)?;
320                ::std::result::Result::Ok(builder.method("POST").uri(uri))
321            }
322            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
323            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/json");
324            builder
325        };
326        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_add_permission::ser_add_permission_input(&input)?);
327        if let Some(content_length) = body.content_length() {
328            let content_length = content_length.to_string();
329            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
330        }
331        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
332    }
333}
334#[derive(Debug)]
335struct AddPermissionEndpointParamsInterceptor;
336
337#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
338impl ::aws_smithy_runtime_api::client::interceptors::Intercept for AddPermissionEndpointParamsInterceptor {
339    fn name(&self) -> &'static str {
340        "AddPermissionEndpointParamsInterceptor"
341    }
342
343    fn read_before_execution(
344        &self,
345        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
346            '_,
347            ::aws_smithy_runtime_api::client::interceptors::context::Input,
348            ::aws_smithy_runtime_api::client::interceptors::context::Output,
349            ::aws_smithy_runtime_api::client::interceptors::context::Error,
350        >,
351        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
352    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
353        let _input = context
354            .input()
355            .downcast_ref::<AddPermissionInput>()
356            .ok_or("failed to downcast to AddPermissionInput")?;
357
358        let params = crate::config::endpoint::Params::builder()
359            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
360            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
361            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
362            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
363            .build()
364            .map_err(|err| {
365                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
366            })?;
367        cfg.interceptor_state()
368            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
369        ::std::result::Result::Ok(())
370    }
371}
372
373// The get_* functions below are generated from JMESPath expressions in the
374// operationContextParams trait. They target the operation's input shape.
375
376/// Error type for the `AddPermissionError` operation.
377#[non_exhaustive]
378#[derive(::std::fmt::Debug)]
379pub enum AddPermissionError {
380    /// <p>One of the parameters in the request is not valid.</p>
381    InvalidParameterValueException(crate::types::error::InvalidParameterValueException),
382    /// <p>The permissions policy for the resource is too large. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">Lambda quotas</a>.</p>
383    PolicyLengthExceededException(crate::types::error::PolicyLengthExceededException),
384    /// <p>The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.</p>
385    /// <ul>
386    /// <li>
387    /// <p><b>For AddPermission and RemovePermission API operations:</b> Call <code>GetPolicy</code> to retrieve the latest RevisionId for your resource.</p></li>
388    /// <li>
389    /// <p><b>For all other API operations:</b> Call <code>GetFunction</code> or <code>GetAlias</code> to retrieve the latest RevisionId for your resource.</p></li>
390    /// </ul>
391    PreconditionFailedException(crate::types::error::PreconditionFailedException),
392    /// <p>The resource-based policy you tried to add to the Lambda resource would grant public access to it, which isn't allowed.</p>
393    PublicPolicyException(crate::types::error::PublicPolicyException),
394    /// <p>The resource already exists, or another operation is in progress.</p>
395    ResourceConflictException(crate::types::error::ResourceConflictException),
396    /// <p>The resource specified in the request does not exist.</p>
397    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
398    /// <p>The Lambda service encountered an internal error.</p>
399    ServiceException(crate::types::error::ServiceException),
400    /// <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
401    TooManyRequestsException(crate::types::error::TooManyRequestsException),
402    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
403    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
404    variable wildcard pattern and check `.code()`:
405     \
406    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
407     \
408    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-AddPermissionError) for what information is available for the error.")]
409    Unhandled(crate::error::sealed_unhandled::Unhandled),
410}
411impl AddPermissionError {
412    /// Creates the `AddPermissionError::Unhandled` variant from any error type.
413    pub fn unhandled(
414        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
415    ) -> Self {
416        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
417            source: err.into(),
418            meta: ::std::default::Default::default(),
419        })
420    }
421
422    /// Creates the `AddPermissionError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
423    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
424        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
425            source: err.clone().into(),
426            meta: err,
427        })
428    }
429    ///
430    /// Returns error metadata, which includes the error code, message,
431    /// request ID, and potentially additional information.
432    ///
433    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
434        match self {
435            Self::InvalidParameterValueException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
436            Self::PolicyLengthExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
437            Self::PreconditionFailedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
438            Self::PublicPolicyException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
439            Self::ResourceConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
440            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
441            Self::ServiceException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
442            Self::TooManyRequestsException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
443            Self::Unhandled(e) => &e.meta,
444        }
445    }
446    /// Returns `true` if the error kind is `AddPermissionError::InvalidParameterValueException`.
447    pub fn is_invalid_parameter_value_exception(&self) -> bool {
448        matches!(self, Self::InvalidParameterValueException(_))
449    }
450    /// Returns `true` if the error kind is `AddPermissionError::PolicyLengthExceededException`.
451    pub fn is_policy_length_exceeded_exception(&self) -> bool {
452        matches!(self, Self::PolicyLengthExceededException(_))
453    }
454    /// Returns `true` if the error kind is `AddPermissionError::PreconditionFailedException`.
455    pub fn is_precondition_failed_exception(&self) -> bool {
456        matches!(self, Self::PreconditionFailedException(_))
457    }
458    /// Returns `true` if the error kind is `AddPermissionError::PublicPolicyException`.
459    pub fn is_public_policy_exception(&self) -> bool {
460        matches!(self, Self::PublicPolicyException(_))
461    }
462    /// Returns `true` if the error kind is `AddPermissionError::ResourceConflictException`.
463    pub fn is_resource_conflict_exception(&self) -> bool {
464        matches!(self, Self::ResourceConflictException(_))
465    }
466    /// Returns `true` if the error kind is `AddPermissionError::ResourceNotFoundException`.
467    pub fn is_resource_not_found_exception(&self) -> bool {
468        matches!(self, Self::ResourceNotFoundException(_))
469    }
470    /// Returns `true` if the error kind is `AddPermissionError::ServiceException`.
471    pub fn is_service_exception(&self) -> bool {
472        matches!(self, Self::ServiceException(_))
473    }
474    /// Returns `true` if the error kind is `AddPermissionError::TooManyRequestsException`.
475    pub fn is_too_many_requests_exception(&self) -> bool {
476        matches!(self, Self::TooManyRequestsException(_))
477    }
478}
479impl ::std::error::Error for AddPermissionError {
480    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
481        match self {
482            Self::InvalidParameterValueException(_inner) => ::std::option::Option::Some(_inner),
483            Self::PolicyLengthExceededException(_inner) => ::std::option::Option::Some(_inner),
484            Self::PreconditionFailedException(_inner) => ::std::option::Option::Some(_inner),
485            Self::PublicPolicyException(_inner) => ::std::option::Option::Some(_inner),
486            Self::ResourceConflictException(_inner) => ::std::option::Option::Some(_inner),
487            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
488            Self::ServiceException(_inner) => ::std::option::Option::Some(_inner),
489            Self::TooManyRequestsException(_inner) => ::std::option::Option::Some(_inner),
490            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
491        }
492    }
493}
494impl ::std::fmt::Display for AddPermissionError {
495    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
496        match self {
497            Self::InvalidParameterValueException(_inner) => _inner.fmt(f),
498            Self::PolicyLengthExceededException(_inner) => _inner.fmt(f),
499            Self::PreconditionFailedException(_inner) => _inner.fmt(f),
500            Self::PublicPolicyException(_inner) => _inner.fmt(f),
501            Self::ResourceConflictException(_inner) => _inner.fmt(f),
502            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
503            Self::ServiceException(_inner) => _inner.fmt(f),
504            Self::TooManyRequestsException(_inner) => _inner.fmt(f),
505            Self::Unhandled(_inner) => {
506                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
507                    write!(f, "unhandled error ({code})")
508                } else {
509                    f.write_str("unhandled error")
510                }
511            }
512        }
513    }
514}
515impl ::aws_smithy_types::retry::ProvideErrorKind for AddPermissionError {
516    fn code(&self) -> ::std::option::Option<&str> {
517        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
518    }
519    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
520        ::std::option::Option::None
521    }
522}
523impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for AddPermissionError {
524    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
525        match self {
526            Self::InvalidParameterValueException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
527            Self::PolicyLengthExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
528            Self::PreconditionFailedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
529            Self::PublicPolicyException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
530            Self::ResourceConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
531            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
532            Self::ServiceException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
533            Self::TooManyRequestsException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
534            Self::Unhandled(_inner) => &_inner.meta,
535        }
536    }
537}
538impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for AddPermissionError {
539    fn create_unhandled_error(
540        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
541        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
542    ) -> Self {
543        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
544            source,
545            meta: meta.unwrap_or_default(),
546        })
547    }
548}
549impl ::aws_types::request_id::RequestId for crate::operation::add_permission::AddPermissionError {
550    fn request_id(&self) -> Option<&str> {
551        self.meta().request_id()
552    }
553}
554
555pub use crate::operation::add_permission::_add_permission_input::AddPermissionInput;
556
557pub use crate::operation::add_permission::_add_permission_output::AddPermissionOutput;
558
559mod _add_permission_input;
560
561mod _add_permission_output;
562
563/// Builders
564pub mod builders;