aws_sdk_iam/operation/
enable_organizations_root_credentials_management.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `EnableOrganizationsRootCredentialsManagement`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct EnableOrganizationsRootCredentialsManagement;
6impl EnableOrganizationsRootCredentialsManagement {
7    /// Creates a new `EnableOrganizationsRootCredentialsManagement`
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::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementInput,
14    ) -> ::std::result::Result<
15        crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError,
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::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError>(
27                )
28                .expect("correct error type")
29            })
30        };
31        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
32            .await
33            .map_err(map_err)?;
34        let output = context.finalize().map_err(map_err)?;
35        ::std::result::Result::Ok(
36            output
37                .downcast::<crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementOutput>()
38                .expect("correct output type"),
39        )
40    }
41
42    pub(crate) async fn orchestrate_with_stop_point(
43        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
44        input: crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementInput,
45        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
46    ) -> ::std::result::Result<
47        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
48        ::aws_smithy_runtime_api::client::result::SdkError<
49            ::aws_smithy_runtime_api::client::interceptors::context::Error,
50            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
51        >,
52    > {
53        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
55            "iam",
56            "EnableOrganizationsRootCredentialsManagement",
57            input,
58            runtime_plugins,
59            stop_point,
60        )
61        .await
62    }
63
64    pub(crate) fn operation_runtime_plugins(
65        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
66        client_config: &crate::config::Config,
67        config_override: ::std::option::Option<crate::config::Builder>,
68    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
69        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
70        runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
71            ::aws_runtime::auth::sigv4::SCHEME_ID,
72        ]));
73        if let ::std::option::Option::Some(config_override) = config_override {
74            for plugin in config_override.runtime_plugins.iter().cloned() {
75                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
76            }
77            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
78                config_override,
79                client_config.config.clone(),
80                &client_config.runtime_components,
81            ));
82        }
83        runtime_plugins
84    }
85}
86impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for EnableOrganizationsRootCredentialsManagement {
87    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
88        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("EnableOrganizationsRootCredentialsManagement");
89
90        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
91            EnableOrganizationsRootCredentialsManagementRequestSerializer,
92        ));
93        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
94            EnableOrganizationsRootCredentialsManagementResponseDeserializer,
95        ));
96
97        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
98            ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
99        ));
100
101        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
102            "EnableOrganizationsRootCredentialsManagement",
103            "iam",
104        ));
105        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
106        signing_options.double_uri_encode = true;
107        signing_options.content_sha256_header = false;
108        signing_options.normalize_uri_path = true;
109        signing_options.payload_override = None;
110
111        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
112            signing_options,
113            ..::std::default::Default::default()
114        });
115
116        ::std::option::Option::Some(cfg.freeze())
117    }
118
119    fn runtime_components(
120        &self,
121        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
122    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
123        #[allow(unused_mut)]
124        let mut rcb =
125            ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("EnableOrganizationsRootCredentialsManagement")
126                .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
127                .with_interceptor(EnableOrganizationsRootCredentialsManagementEndpointParamsInterceptor)
128                .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
129                    crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError,
130                >::new())
131                .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
132                    crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError,
133                >::new())
134                .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
135                    crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError,
136                >::new());
137
138        ::std::borrow::Cow::Owned(rcb)
139    }
140}
141
142#[derive(Debug)]
143struct EnableOrganizationsRootCredentialsManagementResponseDeserializer;
144impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EnableOrganizationsRootCredentialsManagementResponseDeserializer {
145    fn deserialize_nonstreaming(
146        &self,
147        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
148    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
149        let (success, status) = (response.status().is_success(), response.status().as_u16());
150        let headers = response.headers();
151        let body = response.body().bytes().expect("body loaded");
152        #[allow(unused_mut)]
153        let mut force_error = false;
154        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
155        let parse_result = if !success && status != 200 || force_error {
156            crate::protocol_serde::shape_enable_organizations_root_credentials_management::de_enable_organizations_root_credentials_management_http_error(status, headers, body)
157        } else {
158            crate::protocol_serde::shape_enable_organizations_root_credentials_management::de_enable_organizations_root_credentials_management_http_response(status, headers, body)
159        };
160        crate::protocol_serde::type_erase_result(parse_result)
161    }
162}
163#[derive(Debug)]
164struct EnableOrganizationsRootCredentialsManagementRequestSerializer;
165impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EnableOrganizationsRootCredentialsManagementRequestSerializer {
166    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
167    fn serialize_input(
168        &self,
169        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
170        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
171    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
172        let input = input
173            .downcast::<crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementInput>()
174            .expect("correct type");
175        let _header_serialization_settings = _cfg
176            .load::<crate::serialization_settings::HeaderSerializationSettings>()
177            .cloned()
178            .unwrap_or_default();
179        let mut request_builder = {
180            fn uri_base(
181                _input: &crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementInput,
182                output: &mut ::std::string::String,
183            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
184                use ::std::fmt::Write as _;
185                ::std::write!(output, "/").expect("formatting should succeed");
186                ::std::result::Result::Ok(())
187            }
188            #[allow(clippy::unnecessary_wraps)]
189            fn update_http_builder(
190                input: &crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementInput,
191                builder: ::http::request::Builder,
192            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
193                let mut uri = ::std::string::String::new();
194                uri_base(input, &mut uri)?;
195                ::std::result::Result::Ok(builder.method("POST").uri(uri))
196            }
197            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
198            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/x-www-form-urlencoded");
199            builder
200        };
201        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_enable_organizations_root_credentials_management_input::ser_enable_organizations_root_credentials_management_input_input_input(&input)?);
202
203        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
204    }
205}
206#[derive(Debug)]
207struct EnableOrganizationsRootCredentialsManagementEndpointParamsInterceptor;
208
209impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EnableOrganizationsRootCredentialsManagementEndpointParamsInterceptor {
210    fn name(&self) -> &'static str {
211        "EnableOrganizationsRootCredentialsManagementEndpointParamsInterceptor"
212    }
213
214    fn read_before_execution(
215        &self,
216        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
217            '_,
218            ::aws_smithy_runtime_api::client::interceptors::context::Input,
219            ::aws_smithy_runtime_api::client::interceptors::context::Output,
220            ::aws_smithy_runtime_api::client::interceptors::context::Error,
221        >,
222        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
223    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
224        let _input = context
225            .input()
226            .downcast_ref::<EnableOrganizationsRootCredentialsManagementInput>()
227            .ok_or("failed to downcast to EnableOrganizationsRootCredentialsManagementInput")?;
228
229        let params = crate::config::endpoint::Params::builder()
230            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
231            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
232            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
233            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
234            .build()
235            .map_err(|err| {
236                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
237            })?;
238        cfg.interceptor_state()
239            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
240        ::std::result::Result::Ok(())
241    }
242}
243
244// The get_* functions below are generated from JMESPath expressions in the
245// operationContextParams trait. They target the operation's input shape.
246
247/// Error type for the `EnableOrganizationsRootCredentialsManagementError` operation.
248#[non_exhaustive]
249#[derive(::std::fmt::Debug)]
250pub enum EnableOrganizationsRootCredentialsManagementError {
251    /// <p>The request was rejected because the account making the request is not the management account or delegated administrator account for <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#id_root-user-access-management">centralized root access</a>.</p>
252    AccountNotManagementOrDelegatedAdministratorException(crate::types::error::AccountNotManagementOrDelegatedAdministratorException),
253    /// <p>The request was rejected because the account making the request is not the management account for the organization.</p>
254    CallerIsNotManagementAccountException(crate::types::error::CallerIsNotManagementAccountException),
255    /// <p>The request was rejected because no organization is associated with your account.</p>
256    OrganizationNotFoundException(crate::types::error::OrganizationNotFoundException),
257    /// <p>The request was rejected because your organization does not have All features enabled. For more information, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#feature-set">Available feature sets</a> in the <i>Organizations User Guide</i>.</p>
258    OrganizationNotInAllFeaturesModeException(crate::types::error::OrganizationNotInAllFeaturesModeException),
259    /// <p>The request was rejected because trusted access is not enabled for IAM in Organizations. For details, see IAM and Organizations in the <i>Organizations User Guide</i>.</p>
260    ServiceAccessNotEnabledException(crate::types::error::ServiceAccessNotEnabledException),
261    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
262    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
263    variable wildcard pattern and check `.code()`:
264     \
265    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
266     \
267    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-EnableOrganizationsRootCredentialsManagementError) for what information is available for the error.")]
268    Unhandled(crate::error::sealed_unhandled::Unhandled),
269}
270impl EnableOrganizationsRootCredentialsManagementError {
271    /// Creates the `EnableOrganizationsRootCredentialsManagementError::Unhandled` variant from any error type.
272    pub fn unhandled(
273        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
274    ) -> Self {
275        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
276            source: err.into(),
277            meta: ::std::default::Default::default(),
278        })
279    }
280
281    /// Creates the `EnableOrganizationsRootCredentialsManagementError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
282    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
283        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
284            source: err.clone().into(),
285            meta: err,
286        })
287    }
288    ///
289    /// Returns error metadata, which includes the error code, message,
290    /// request ID, and potentially additional information.
291    ///
292    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
293        match self {
294            Self::AccountNotManagementOrDelegatedAdministratorException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
295            Self::CallerIsNotManagementAccountException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
296            Self::OrganizationNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
297            Self::OrganizationNotInAllFeaturesModeException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
298            Self::ServiceAccessNotEnabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
299            Self::Unhandled(e) => &e.meta,
300        }
301    }
302    /// Returns `true` if the error kind is `EnableOrganizationsRootCredentialsManagementError::AccountNotManagementOrDelegatedAdministratorException`.
303    pub fn is_account_not_management_or_delegated_administrator_exception(&self) -> bool {
304        matches!(self, Self::AccountNotManagementOrDelegatedAdministratorException(_))
305    }
306    /// Returns `true` if the error kind is `EnableOrganizationsRootCredentialsManagementError::CallerIsNotManagementAccountException`.
307    pub fn is_caller_is_not_management_account_exception(&self) -> bool {
308        matches!(self, Self::CallerIsNotManagementAccountException(_))
309    }
310    /// Returns `true` if the error kind is `EnableOrganizationsRootCredentialsManagementError::OrganizationNotFoundException`.
311    pub fn is_organization_not_found_exception(&self) -> bool {
312        matches!(self, Self::OrganizationNotFoundException(_))
313    }
314    /// Returns `true` if the error kind is `EnableOrganizationsRootCredentialsManagementError::OrganizationNotInAllFeaturesModeException`.
315    pub fn is_organization_not_in_all_features_mode_exception(&self) -> bool {
316        matches!(self, Self::OrganizationNotInAllFeaturesModeException(_))
317    }
318    /// Returns `true` if the error kind is `EnableOrganizationsRootCredentialsManagementError::ServiceAccessNotEnabledException`.
319    pub fn is_service_access_not_enabled_exception(&self) -> bool {
320        matches!(self, Self::ServiceAccessNotEnabledException(_))
321    }
322}
323impl ::std::error::Error for EnableOrganizationsRootCredentialsManagementError {
324    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
325        match self {
326            Self::AccountNotManagementOrDelegatedAdministratorException(_inner) => ::std::option::Option::Some(_inner),
327            Self::CallerIsNotManagementAccountException(_inner) => ::std::option::Option::Some(_inner),
328            Self::OrganizationNotFoundException(_inner) => ::std::option::Option::Some(_inner),
329            Self::OrganizationNotInAllFeaturesModeException(_inner) => ::std::option::Option::Some(_inner),
330            Self::ServiceAccessNotEnabledException(_inner) => ::std::option::Option::Some(_inner),
331            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
332        }
333    }
334}
335impl ::std::fmt::Display for EnableOrganizationsRootCredentialsManagementError {
336    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
337        match self {
338            Self::AccountNotManagementOrDelegatedAdministratorException(_inner) => _inner.fmt(f),
339            Self::CallerIsNotManagementAccountException(_inner) => _inner.fmt(f),
340            Self::OrganizationNotFoundException(_inner) => _inner.fmt(f),
341            Self::OrganizationNotInAllFeaturesModeException(_inner) => _inner.fmt(f),
342            Self::ServiceAccessNotEnabledException(_inner) => _inner.fmt(f),
343            Self::Unhandled(_inner) => {
344                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
345                    write!(f, "unhandled error ({code})")
346                } else {
347                    f.write_str("unhandled error")
348                }
349            }
350        }
351    }
352}
353impl ::aws_smithy_types::retry::ProvideErrorKind for EnableOrganizationsRootCredentialsManagementError {
354    fn code(&self) -> ::std::option::Option<&str> {
355        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
356    }
357    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
358        ::std::option::Option::None
359    }
360}
361impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for EnableOrganizationsRootCredentialsManagementError {
362    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
363        match self {
364            Self::AccountNotManagementOrDelegatedAdministratorException(_inner) => {
365                ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
366            }
367            Self::CallerIsNotManagementAccountException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
368            Self::OrganizationNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
369            Self::OrganizationNotInAllFeaturesModeException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
370            Self::ServiceAccessNotEnabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
371            Self::Unhandled(_inner) => &_inner.meta,
372        }
373    }
374}
375impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for EnableOrganizationsRootCredentialsManagementError {
376    fn create_unhandled_error(
377        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
378        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
379    ) -> Self {
380        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
381            source,
382            meta: meta.unwrap_or_default(),
383        })
384    }
385}
386impl ::aws_types::request_id::RequestId
387    for crate::operation::enable_organizations_root_credentials_management::EnableOrganizationsRootCredentialsManagementError
388{
389    fn request_id(&self) -> Option<&str> {
390        self.meta().request_id()
391    }
392}
393
394pub use crate::operation::enable_organizations_root_credentials_management::_enable_organizations_root_credentials_management_output::EnableOrganizationsRootCredentialsManagementOutput;
395
396pub use crate::operation::enable_organizations_root_credentials_management::_enable_organizations_root_credentials_management_input::EnableOrganizationsRootCredentialsManagementInput;
397
398mod _enable_organizations_root_credentials_management_input;
399
400mod _enable_organizations_root_credentials_management_output;
401
402/// Builders
403pub mod builders;