aws_sdk_organizations/operation/
attach_policy.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `AttachPolicy`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct AttachPolicy;
6impl AttachPolicy {
7    /// Creates a new `AttachPolicy`
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::attach_policy::AttachPolicyInput,
14    ) -> ::std::result::Result<
15        crate::operation::attach_policy::AttachPolicyOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::attach_policy::AttachPolicyError,
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::attach_policy::AttachPolicyError>()
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::attach_policy::AttachPolicyOutput>()
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::attach_policy::AttachPolicyInput,
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("Organizations", "AttachPolicy", 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                "Organizations.AttachPolicy",
59                "rpc.service" = "Organizations",
60                "rpc.method" = "AttachPolicy",
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 AttachPolicy {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AttachPolicy");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            AttachPolicyRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            AttachPolicyResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("AttachPolicy")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
106            "AttachPolicy",
107            "Organizations",
108        ));
109        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
110        signing_options.double_uri_encode = true;
111        signing_options.content_sha256_header = false;
112        signing_options.normalize_uri_path = true;
113        signing_options.payload_override = None;
114
115        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
116            signing_options,
117            ..::std::default::Default::default()
118        });
119
120        ::std::option::Option::Some(cfg.freeze())
121    }
122
123    fn runtime_components(
124        &self,
125        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
126    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
127        #[allow(unused_mut)]
128        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("AttachPolicy")
129            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
130            .with_interceptor(AttachPolicyEndpointParamsInterceptor)
131            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
132                crate::operation::attach_policy::AttachPolicyError,
133            >::new())
134            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
135                crate::operation::attach_policy::AttachPolicyError,
136            >::new())
137            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
138                crate::operation::attach_policy::AttachPolicyError,
139            >::new());
140
141        ::std::borrow::Cow::Owned(rcb)
142    }
143}
144
145#[derive(Debug)]
146struct AttachPolicyResponseDeserializer;
147impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for AttachPolicyResponseDeserializer {
148    fn deserialize_nonstreaming(
149        &self,
150        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
151    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
152        let (success, status) = (response.status().is_success(), response.status().as_u16());
153        let headers = response.headers();
154        let body = response.body().bytes().expect("body loaded");
155        #[allow(unused_mut)]
156        let mut force_error = false;
157        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
158        let parse_result = if !success && status != 200 || force_error {
159            crate::protocol_serde::shape_attach_policy::de_attach_policy_http_error(status, headers, body)
160        } else {
161            crate::protocol_serde::shape_attach_policy::de_attach_policy_http_response(status, headers, body)
162        };
163        crate::protocol_serde::type_erase_result(parse_result)
164    }
165}
166#[derive(Debug)]
167struct AttachPolicyRequestSerializer;
168impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for AttachPolicyRequestSerializer {
169    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
170    fn serialize_input(
171        &self,
172        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
173        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
174    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
175        let input = input
176            .downcast::<crate::operation::attach_policy::AttachPolicyInput>()
177            .expect("correct type");
178        let _header_serialization_settings = _cfg
179            .load::<crate::serialization_settings::HeaderSerializationSettings>()
180            .cloned()
181            .unwrap_or_default();
182        let mut request_builder = {
183            #[allow(clippy::uninlined_format_args)]
184            fn uri_base(
185                _input: &crate::operation::attach_policy::AttachPolicyInput,
186                output: &mut ::std::string::String,
187            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
188                use ::std::fmt::Write as _;
189                ::std::write!(output, "/").expect("formatting should succeed");
190                ::std::result::Result::Ok(())
191            }
192            #[allow(clippy::unnecessary_wraps)]
193            fn update_http_builder(
194                input: &crate::operation::attach_policy::AttachPolicyInput,
195                builder: ::http::request::Builder,
196            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
197                let mut uri = ::std::string::String::new();
198                uri_base(input, &mut uri)?;
199                ::std::result::Result::Ok(builder.method("POST").uri(uri))
200            }
201            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
202            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/x-amz-json-1.1");
203            builder = _header_serialization_settings.set_default_header(
204                builder,
205                ::http::header::HeaderName::from_static("x-amz-target"),
206                "AWSOrganizationsV20161128.AttachPolicy",
207            );
208            builder
209        };
210        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_attach_policy::ser_attach_policy_input(&input)?);
211        if let Some(content_length) = body.content_length() {
212            let content_length = content_length.to_string();
213            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
214        }
215        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
216    }
217}
218#[derive(Debug)]
219struct AttachPolicyEndpointParamsInterceptor;
220
221impl ::aws_smithy_runtime_api::client::interceptors::Intercept for AttachPolicyEndpointParamsInterceptor {
222    fn name(&self) -> &'static str {
223        "AttachPolicyEndpointParamsInterceptor"
224    }
225
226    fn read_before_execution(
227        &self,
228        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
229            '_,
230            ::aws_smithy_runtime_api::client::interceptors::context::Input,
231            ::aws_smithy_runtime_api::client::interceptors::context::Output,
232            ::aws_smithy_runtime_api::client::interceptors::context::Error,
233        >,
234        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
235    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
236        let _input = context
237            .input()
238            .downcast_ref::<AttachPolicyInput>()
239            .ok_or("failed to downcast to AttachPolicyInput")?;
240
241        let params = crate::config::endpoint::Params::builder()
242            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
243            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
244            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
245            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
246            .build()
247            .map_err(|err| {
248                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
249            })?;
250        cfg.interceptor_state()
251            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
252        ::std::result::Result::Ok(())
253    }
254}
255
256// The get_* functions below are generated from JMESPath expressions in the
257// operationContextParams trait. They target the operation's input shape.
258
259/// Error type for the `AttachPolicyError` operation.
260#[non_exhaustive]
261#[derive(::std::fmt::Debug)]
262pub enum AttachPolicyError {
263    /// <p>You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access.html">Access Management</a> in the <i>IAM User Guide</i>.</p>
264    AccessDeniedException(crate::types::error::AccessDeniedException),
265    /// <p>Your account isn't a member of an organization. To make this request, you must use the credentials of an account that belongs to an organization.</p>
266    AwsOrganizationsNotInUseException(crate::types::error::AwsOrganizationsNotInUseException),
267    /// <p>The target of the operation is currently being modified by a different request. Try again later.</p>
268    ConcurrentModificationException(crate::types::error::ConcurrentModificationException),
269    /// <p>Performing this operation violates a minimum or maximum value limit. For example, attempting to remove the last service control policy (SCP) from an OU or root, inviting or creating too many accounts to the organization, or attaching too many policies to an account, OU, or root. This exception includes a reason that contains additional information about the violated limit:</p><note>
270    /// <p>Some of the reasons in the following list might not be applicable to this specific API or operation.</p>
271    /// </note>
272    /// <ul>
273    /// <li>
274    /// <p>ACCOUNT_CANNOT_LEAVE_ORGANIZATION: You attempted to remove the management account from the organization. You can't remove the management account. Instead, after you remove all member accounts, delete the organization itself.</p></li>
275    /// <li>
276    /// <p>ACCOUNT_CANNOT_LEAVE_WITHOUT_PHONE_VERIFICATION: You attempted to remove an account from the organization that doesn't yet have enough information to exist as a standalone account. This account requires you to first complete phone verification. Follow the steps at <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_remove.html#orgs_manage_accounts_remove-from-master">Removing a member account from your organization</a> in the <i>Organizations User Guide</i>.</p></li>
277    /// <li>
278    /// <p>ACCOUNT_CREATION_RATE_LIMIT_EXCEEDED: You attempted to exceed the number of accounts that you can create in one day.</p></li>
279    /// <li>
280    /// <p>ACCOUNT_CREATION_NOT_COMPLETE: Your account setup isn't complete or your account isn't fully active. You must complete the account setup before you create an organization.</p></li>
281    /// <li>
282    /// <p>ACCOUNT_NUMBER_LIMIT_EXCEEDED: You attempted to exceed the limit on the number of accounts in an organization. If you need more accounts, contact <a href="https://console.aws.amazon.com/support/home#/">Amazon Web Services Support</a> to request an increase in your limit.</p>
283    /// <p>Or the number of invitations that you tried to send would cause you to exceed the limit of accounts in your organization. Send fewer invitations or contact Amazon Web Services Support to request an increase in the number of accounts.</p><note>
284    /// <p>Deleted and closed accounts still count toward your limit.</p>
285    /// </note> <important>
286    /// <p>If you get this exception when running a command immediately after creating the organization, wait one hour and try again. After an hour, if the command continues to fail with this error, contact <a href="https://console.aws.amazon.com/support/home#/">Amazon Web Services Support</a>.</p>
287    /// </important></li>
288    /// <li>
289    /// <p>ALL_FEATURES_MIGRATION_ORGANIZATION_SIZE_LIMIT_EXCEEDED: Your organization has more than 5000 accounts, and you can only use the standard migration process for organizations with less than 5000 accounts. Use the assisted migration process to enable all features mode, or create a support case for assistance if you are unable to use assisted migration.</p></li>
290    /// <li>
291    /// <p>CANNOT_REGISTER_SUSPENDED_ACCOUNT_AS_DELEGATED_ADMINISTRATOR: You cannot register a suspended account as a delegated administrator.</p></li>
292    /// <li>
293    /// <p>CANNOT_REGISTER_MASTER_AS_DELEGATED_ADMINISTRATOR: You attempted to register the management account of the organization as a delegated administrator for an Amazon Web Services service integrated with Organizations. You can designate only a member account as a delegated administrator.</p></li>
294    /// <li>
295    /// <p>CANNOT_CLOSE_MANAGEMENT_ACCOUNT: You attempted to close the management account. To close the management account for the organization, you must first either remove or close all member accounts in the organization. Follow standard account closure process using root credentials.​</p></li>
296    /// <li>
297    /// <p>CANNOT_REMOVE_DELEGATED_ADMINISTRATOR_FROM_ORG: You attempted to remove an account that is registered as a delegated administrator for a service integrated with your organization. To complete this operation, you must first deregister this account as a delegated administrator.</p></li>
298    /// <li>
299    /// <p>CLOSE_ACCOUNT_QUOTA_EXCEEDED: You have exceeded close account quota for the past 30 days.</p></li>
300    /// <li>
301    /// <p>CLOSE_ACCOUNT_REQUESTS_LIMIT_EXCEEDED: You attempted to exceed the number of accounts that you can close at a time. ​</p></li>
302    /// <li>
303    /// <p>CREATE_ORGANIZATION_IN_BILLING_MODE_UNSUPPORTED_REGION: To create an organization in the specified region, you must enable all features mode.</p></li>
304    /// <li>
305    /// <p>DELEGATED_ADMINISTRATOR_EXISTS_FOR_THIS_SERVICE: You attempted to register an Amazon Web Services account as a delegated administrator for an Amazon Web Services service that already has a delegated administrator. To complete this operation, you must first deregister any existing delegated administrators for this service.</p></li>
306    /// <li>
307    /// <p>EMAIL_VERIFICATION_CODE_EXPIRED: The email verification code is only valid for a limited period of time. You must resubmit the request and generate a new verfication code.</p></li>
308    /// <li>
309    /// <p>HANDSHAKE_RATE_LIMIT_EXCEEDED: You attempted to exceed the number of handshakes that you can send in one day.</p></li>
310    /// <li>
311    /// <p>INVALID_PAYMENT_INSTRUMENT: You cannot remove an account because no supported payment method is associated with the account. Amazon Web Services does not support cards issued by financial institutions in Russia or Belarus. For more information, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/manage-general.html">Managing your Amazon Web Services payments</a>.</p></li>
312    /// <li>
313    /// <p>MASTER_ACCOUNT_ADDRESS_DOES_NOT_MATCH_MARKETPLACE: To create an account in this organization, you first must migrate the organization's management account to the marketplace that corresponds to the management account's address. All accounts in an organization must be associated with the same marketplace.</p></li>
314    /// <li>
315    /// <p>MASTER_ACCOUNT_MISSING_BUSINESS_LICENSE: Applies only to the Amazon Web Services Regions in China. To create an organization, the master must have a valid business license. For more information, contact customer support.</p></li>
316    /// <li>
317    /// <p>MASTER_ACCOUNT_MISSING_CONTACT_INFO: To complete this operation, you must first provide a valid contact address and phone number for the management account. Then try the operation again.</p></li>
318    /// <li>
319    /// <p>MASTER_ACCOUNT_NOT_GOVCLOUD_ENABLED: To complete this operation, the management account must have an associated account in the Amazon Web Services GovCloud (US-West) Region. For more information, see <a href="https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-organizations.html">Organizations</a> in the <i>Amazon Web Services GovCloud User Guide</i>.</p></li>
320    /// <li>
321    /// <p>MASTER_ACCOUNT_PAYMENT_INSTRUMENT_REQUIRED: To create an organization with this management account, you first must associate a valid payment instrument, such as a credit card, with the account. For more information, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_account-before-remove.html">Considerations before removing an account from an organization</a> in the <i>Organizations User Guide</i>.</p></li>
322    /// <li>
323    /// <p>MAX_DELEGATED_ADMINISTRATORS_FOR_SERVICE_LIMIT_EXCEEDED: You attempted to register more delegated administrators than allowed for the service principal.</p></li>
324    /// <li>
325    /// <p>MAX_POLICY_TYPE_ATTACHMENT_LIMIT_EXCEEDED: You attempted to exceed the number of policies of a certain type that can be attached to an entity at one time.</p></li>
326    /// <li>
327    /// <p>MAX_TAG_LIMIT_EXCEEDED: You have exceeded the number of tags allowed on this resource.</p></li>
328    /// <li>
329    /// <p>MEMBER_ACCOUNT_PAYMENT_INSTRUMENT_REQUIRED: To complete this operation with this member account, you first must associate a valid payment instrument, such as a credit card, with the account. For more information, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_account-before-remove.html">Considerations before removing an account from an organization</a> in the <i>Organizations User Guide</i>.</p></li>
330    /// <li>
331    /// <p>MIN_POLICY_TYPE_ATTACHMENT_LIMIT_EXCEEDED: You attempted to detach a policy from an entity that would cause the entity to have fewer than the minimum number of policies of a certain type required.</p></li>
332    /// <li>
333    /// <p>ORGANIZATION_NOT_IN_ALL_FEATURES_MODE: You attempted to perform an operation that requires the organization to be configured to support all features. An organization that supports only consolidated billing features can't perform this operation.</p></li>
334    /// <li>
335    /// <p>OU_DEPTH_LIMIT_EXCEEDED: You attempted to create an OU tree that is too many levels deep.</p></li>
336    /// <li>
337    /// <p>OU_NUMBER_LIMIT_EXCEEDED: You attempted to exceed the number of OUs that you can have in an organization.</p></li>
338    /// <li>
339    /// <p>POLICY_CONTENT_LIMIT_EXCEEDED: You attempted to create a policy that is larger than the maximum size.</p></li>
340    /// <li>
341    /// <p>POLICY_NUMBER_LIMIT_EXCEEDED: You attempted to exceed the number of policies that you can have in an organization.</p></li>
342    /// <li>
343    /// <p>POLICY_TYPE_ENABLED_FOR_THIS_SERVICE: You attempted to disable service access before you disabled the policy type (for example, SECURITYHUB_POLICY). To complete this operation, you must first disable the policy type.</p></li>
344    /// <li>
345    /// <p>SERVICE_ACCESS_NOT_ENABLED:</p>
346    /// <ul>
347    /// <li>
348    /// <p>You attempted to register a delegated administrator before you enabled service access. Call the <code>EnableAWSServiceAccess</code> API first.</p></li>
349    /// <li>
350    /// <p>You attempted to enable a policy type before you enabled service access. Call the <code>EnableAWSServiceAccess</code> API first.</p></li>
351    /// </ul></li>
352    /// <li>
353    /// <p>TAG_POLICY_VIOLATION: You attempted to create or update a resource with tags that are not compliant with the tag policy requirements for this account.</p></li>
354    /// <li>
355    /// <p>WAIT_PERIOD_ACTIVE: After you create an Amazon Web Services account, you must wait until at least four days after the account was created. Invited accounts aren't subject to this waiting period.</p></li>
356    /// </ul>
357    ConstraintViolationException(crate::types::error::ConstraintViolationException),
358    /// <p>The selected policy is already attached to the specified target.</p>
359    DuplicatePolicyAttachmentException(crate::types::error::DuplicatePolicyAttachmentException),
360    /// <p>The requested operation failed because you provided invalid values for one or more of the request parameters. This exception includes a reason that contains additional information about the violated limit:</p><note>
361    /// <p>Some of the reasons in the following list might not be applicable to this specific API or operation.</p>
362    /// </note>
363    /// <ul>
364    /// <li>
365    /// <p>DUPLICATE_TAG_KEY: Tag keys must be unique among the tags attached to the same entity.</p></li>
366    /// <li>
367    /// <p>IMMUTABLE_POLICY: You specified a policy that is managed by Amazon Web Services and can't be modified.</p></li>
368    /// <li>
369    /// <p>INPUT_REQUIRED: You must include a value for all required parameters.</p></li>
370    /// <li>
371    /// <p>INVALID_EMAIL_ADDRESS_TARGET: You specified an invalid email address for the invited account owner.</p></li>
372    /// <li>
373    /// <p>INVALID_ENUM: You specified an invalid value.</p></li>
374    /// <li>
375    /// <p>INVALID_ENUM_POLICY_TYPE: You specified an invalid policy type string.</p></li>
376    /// <li>
377    /// <p>INVALID_FULL_NAME_TARGET: You specified a full name that contains invalid characters.</p></li>
378    /// <li>
379    /// <p>INVALID_LIST_MEMBER: You provided a list to a parameter that contains at least one invalid value.</p></li>
380    /// <li>
381    /// <p>INVALID_PAGINATION_TOKEN: Get the value for the <code>NextToken</code> parameter from the response to a previous call of the operation.</p></li>
382    /// <li>
383    /// <p>INVALID_PARTY_TYPE_TARGET: You specified the wrong type of entity (account, organization, or email) as a party.</p></li>
384    /// <li>
385    /// <p>INVALID_PATTERN: You provided a value that doesn't match the required pattern.</p></li>
386    /// <li>
387    /// <p>INVALID_PATTERN_TARGET_ID: You specified a policy target ID that doesn't match the required pattern.</p></li>
388    /// <li>
389    /// <p>INVALID_PRINCIPAL: You specified an invalid principal element in the policy.</p></li>
390    /// <li>
391    /// <p>INVALID_ROLE_NAME: You provided a role name that isn't valid. A role name can't begin with the reserved prefix <code>AWSServiceRoleFor</code>.</p></li>
392    /// <li>
393    /// <p>INVALID_SYNTAX_ORGANIZATION_ARN: You specified an invalid Amazon Resource Name (ARN) for the organization.</p></li>
394    /// <li>
395    /// <p>INVALID_SYNTAX_POLICY_ID: You specified an invalid policy ID.</p></li>
396    /// <li>
397    /// <p>INVALID_SYSTEM_TAGS_PARAMETER: You specified a tag key that is a system tag. You can’t add, edit, or delete system tag keys because they're reserved for Amazon Web Services use. System tags don’t count against your tags per resource limit.</p></li>
398    /// <li>
399    /// <p>MAX_FILTER_LIMIT_EXCEEDED: You can specify only one filter parameter for the operation.</p></li>
400    /// <li>
401    /// <p>MAX_LENGTH_EXCEEDED: You provided a string parameter that is longer than allowed.</p></li>
402    /// <li>
403    /// <p>MAX_VALUE_EXCEEDED: You provided a numeric parameter that has a larger value than allowed.</p></li>
404    /// <li>
405    /// <p>MIN_LENGTH_EXCEEDED: You provided a string parameter that is shorter than allowed.</p></li>
406    /// <li>
407    /// <p>MIN_VALUE_EXCEEDED: You provided a numeric parameter that has a smaller value than allowed.</p></li>
408    /// <li>
409    /// <p>MOVING_ACCOUNT_BETWEEN_DIFFERENT_ROOTS: You can move an account only between entities in the same root.</p></li>
410    /// <li>
411    /// <p>NON_DETACHABLE_POLICY: You can't detach this Amazon Web Services Managed Policy.</p></li>
412    /// <li>
413    /// <p>TARGET_NOT_SUPPORTED: You can't perform the specified operation on that target entity.</p></li>
414    /// <li>
415    /// <p>UNRECOGNIZED_SERVICE_PRINCIPAL: You specified a service principal that isn't recognized.</p></li>
416    /// </ul>
417    InvalidInputException(crate::types::error::InvalidInputException),
418    /// <p>Changes to the effective policy are in progress, and its contents can't be returned. Try the operation again later.</p>
419    PolicyChangesInProgressException(crate::types::error::PolicyChangesInProgressException),
420    /// <p>We can't find a policy with the <code>PolicyId</code> that you specified.</p>
421    PolicyNotFoundException(crate::types::error::PolicyNotFoundException),
422    /// <p>The specified policy type isn't currently enabled in this root. You can't attach policies of the specified type to entities in a root until you enable that type in the root. For more information, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html">Enabling all features in your organization</a> in the <i>Organizations User Guide</i>.</p>
423    PolicyTypeNotEnabledException(crate::types::error::PolicyTypeNotEnabledException),
424    /// <p>Organizations can't complete your request because of an internal service error. Try again later.</p>
425    ServiceException(crate::types::error::ServiceException),
426    /// <p>We can't find a root, OU, account, or policy with the <code>TargetId</code> that you specified.</p>
427    TargetNotFoundException(crate::types::error::TargetNotFoundException),
428    /// <p>You have sent too many requests in too short a period of time. The quota helps protect against denial-of-service attacks. Try again later.</p>
429    /// <p>For information about quotas that affect Organizations, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_limits.html">Quotas for Organizations</a> in the <i>Organizations User Guide</i>.</p>
430    TooManyRequestsException(crate::types::error::TooManyRequestsException),
431    /// <p>This action isn't available in the current Amazon Web Services Region.</p>
432    UnsupportedApiEndpointException(crate::types::error::UnsupportedApiEndpointException),
433    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
434    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
435    variable wildcard pattern and check `.code()`:
436     \
437    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
438     \
439    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-AttachPolicyError) for what information is available for the error.")]
440    Unhandled(crate::error::sealed_unhandled::Unhandled),
441}
442impl AttachPolicyError {
443    /// Creates the `AttachPolicyError::Unhandled` variant from any error type.
444    pub fn unhandled(
445        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
446    ) -> Self {
447        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
448            source: err.into(),
449            meta: ::std::default::Default::default(),
450        })
451    }
452
453    /// Creates the `AttachPolicyError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
454    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
455        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
456            source: err.clone().into(),
457            meta: err,
458        })
459    }
460    ///
461    /// Returns error metadata, which includes the error code, message,
462    /// request ID, and potentially additional information.
463    ///
464    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
465        match self {
466            Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
467            Self::AwsOrganizationsNotInUseException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
468            Self::ConcurrentModificationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
469            Self::ConstraintViolationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
470            Self::DuplicatePolicyAttachmentException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
471            Self::InvalidInputException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
472            Self::PolicyChangesInProgressException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
473            Self::PolicyNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
474            Self::PolicyTypeNotEnabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
475            Self::ServiceException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
476            Self::TargetNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
477            Self::TooManyRequestsException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
478            Self::UnsupportedApiEndpointException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
479            Self::Unhandled(e) => &e.meta,
480        }
481    }
482    /// Returns `true` if the error kind is `AttachPolicyError::AccessDeniedException`.
483    pub fn is_access_denied_exception(&self) -> bool {
484        matches!(self, Self::AccessDeniedException(_))
485    }
486    /// Returns `true` if the error kind is `AttachPolicyError::AwsOrganizationsNotInUseException`.
487    pub fn is_aws_organizations_not_in_use_exception(&self) -> bool {
488        matches!(self, Self::AwsOrganizationsNotInUseException(_))
489    }
490    /// Returns `true` if the error kind is `AttachPolicyError::ConcurrentModificationException`.
491    pub fn is_concurrent_modification_exception(&self) -> bool {
492        matches!(self, Self::ConcurrentModificationException(_))
493    }
494    /// Returns `true` if the error kind is `AttachPolicyError::ConstraintViolationException`.
495    pub fn is_constraint_violation_exception(&self) -> bool {
496        matches!(self, Self::ConstraintViolationException(_))
497    }
498    /// Returns `true` if the error kind is `AttachPolicyError::DuplicatePolicyAttachmentException`.
499    pub fn is_duplicate_policy_attachment_exception(&self) -> bool {
500        matches!(self, Self::DuplicatePolicyAttachmentException(_))
501    }
502    /// Returns `true` if the error kind is `AttachPolicyError::InvalidInputException`.
503    pub fn is_invalid_input_exception(&self) -> bool {
504        matches!(self, Self::InvalidInputException(_))
505    }
506    /// Returns `true` if the error kind is `AttachPolicyError::PolicyChangesInProgressException`.
507    pub fn is_policy_changes_in_progress_exception(&self) -> bool {
508        matches!(self, Self::PolicyChangesInProgressException(_))
509    }
510    /// Returns `true` if the error kind is `AttachPolicyError::PolicyNotFoundException`.
511    pub fn is_policy_not_found_exception(&self) -> bool {
512        matches!(self, Self::PolicyNotFoundException(_))
513    }
514    /// Returns `true` if the error kind is `AttachPolicyError::PolicyTypeNotEnabledException`.
515    pub fn is_policy_type_not_enabled_exception(&self) -> bool {
516        matches!(self, Self::PolicyTypeNotEnabledException(_))
517    }
518    /// Returns `true` if the error kind is `AttachPolicyError::ServiceException`.
519    pub fn is_service_exception(&self) -> bool {
520        matches!(self, Self::ServiceException(_))
521    }
522    /// Returns `true` if the error kind is `AttachPolicyError::TargetNotFoundException`.
523    pub fn is_target_not_found_exception(&self) -> bool {
524        matches!(self, Self::TargetNotFoundException(_))
525    }
526    /// Returns `true` if the error kind is `AttachPolicyError::TooManyRequestsException`.
527    pub fn is_too_many_requests_exception(&self) -> bool {
528        matches!(self, Self::TooManyRequestsException(_))
529    }
530    /// Returns `true` if the error kind is `AttachPolicyError::UnsupportedApiEndpointException`.
531    pub fn is_unsupported_api_endpoint_exception(&self) -> bool {
532        matches!(self, Self::UnsupportedApiEndpointException(_))
533    }
534}
535impl ::std::error::Error for AttachPolicyError {
536    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
537        match self {
538            Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
539            Self::AwsOrganizationsNotInUseException(_inner) => ::std::option::Option::Some(_inner),
540            Self::ConcurrentModificationException(_inner) => ::std::option::Option::Some(_inner),
541            Self::ConstraintViolationException(_inner) => ::std::option::Option::Some(_inner),
542            Self::DuplicatePolicyAttachmentException(_inner) => ::std::option::Option::Some(_inner),
543            Self::InvalidInputException(_inner) => ::std::option::Option::Some(_inner),
544            Self::PolicyChangesInProgressException(_inner) => ::std::option::Option::Some(_inner),
545            Self::PolicyNotFoundException(_inner) => ::std::option::Option::Some(_inner),
546            Self::PolicyTypeNotEnabledException(_inner) => ::std::option::Option::Some(_inner),
547            Self::ServiceException(_inner) => ::std::option::Option::Some(_inner),
548            Self::TargetNotFoundException(_inner) => ::std::option::Option::Some(_inner),
549            Self::TooManyRequestsException(_inner) => ::std::option::Option::Some(_inner),
550            Self::UnsupportedApiEndpointException(_inner) => ::std::option::Option::Some(_inner),
551            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
552        }
553    }
554}
555impl ::std::fmt::Display for AttachPolicyError {
556    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
557        match self {
558            Self::AccessDeniedException(_inner) => _inner.fmt(f),
559            Self::AwsOrganizationsNotInUseException(_inner) => _inner.fmt(f),
560            Self::ConcurrentModificationException(_inner) => _inner.fmt(f),
561            Self::ConstraintViolationException(_inner) => _inner.fmt(f),
562            Self::DuplicatePolicyAttachmentException(_inner) => _inner.fmt(f),
563            Self::InvalidInputException(_inner) => _inner.fmt(f),
564            Self::PolicyChangesInProgressException(_inner) => _inner.fmt(f),
565            Self::PolicyNotFoundException(_inner) => _inner.fmt(f),
566            Self::PolicyTypeNotEnabledException(_inner) => _inner.fmt(f),
567            Self::ServiceException(_inner) => _inner.fmt(f),
568            Self::TargetNotFoundException(_inner) => _inner.fmt(f),
569            Self::TooManyRequestsException(_inner) => _inner.fmt(f),
570            Self::UnsupportedApiEndpointException(_inner) => _inner.fmt(f),
571            Self::Unhandled(_inner) => {
572                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
573                    write!(f, "unhandled error ({code})")
574                } else {
575                    f.write_str("unhandled error")
576                }
577            }
578        }
579    }
580}
581impl ::aws_smithy_types::retry::ProvideErrorKind for AttachPolicyError {
582    fn code(&self) -> ::std::option::Option<&str> {
583        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
584    }
585    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
586        ::std::option::Option::None
587    }
588}
589impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for AttachPolicyError {
590    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
591        match self {
592            Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
593            Self::AwsOrganizationsNotInUseException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
594            Self::ConcurrentModificationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
595            Self::ConstraintViolationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
596            Self::DuplicatePolicyAttachmentException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
597            Self::InvalidInputException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
598            Self::PolicyChangesInProgressException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
599            Self::PolicyNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
600            Self::PolicyTypeNotEnabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
601            Self::ServiceException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
602            Self::TargetNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
603            Self::TooManyRequestsException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
604            Self::UnsupportedApiEndpointException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
605            Self::Unhandled(_inner) => &_inner.meta,
606        }
607    }
608}
609impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for AttachPolicyError {
610    fn create_unhandled_error(
611        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
612        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
613    ) -> Self {
614        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
615            source,
616            meta: meta.unwrap_or_default(),
617        })
618    }
619}
620impl ::aws_types::request_id::RequestId for crate::operation::attach_policy::AttachPolicyError {
621    fn request_id(&self) -> Option<&str> {
622        self.meta().request_id()
623    }
624}
625
626pub use crate::operation::attach_policy::_attach_policy_output::AttachPolicyOutput;
627
628pub use crate::operation::attach_policy::_attach_policy_input::AttachPolicyInput;
629
630mod _attach_policy_input;
631
632mod _attach_policy_output;
633
634/// Builders
635pub mod builders;