Skip to main content

aws_sdk_kms/operation/
create_key.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `CreateKey`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CreateKey;
6impl CreateKey {
7    /// Creates a new `CreateKey`
8    pub fn new() -> Self {
9        Self
10    }
11    /// The schema for this operation's input shape.
12    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::create_key::CreateKeyInput::SCHEMA;
13    /// The schema for this operation's output shape.
14    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::create_key::CreateKeyOutput::SCHEMA;
15    pub(crate) async fn orchestrate(
16        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17        input: crate::operation::create_key::CreateKeyInput,
18    ) -> ::std::result::Result<
19        crate::operation::create_key::CreateKeyOutput,
20        ::aws_smithy_runtime_api::client::result::SdkError<
21            crate::operation::create_key::CreateKeyError,
22            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
23        >,
24    > {
25        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
26            ::aws_smithy_runtime_api::client::interceptors::context::Error,
27            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
28        >| {
29            err.map_service_error(|err| {
30                err.downcast::<crate::operation::create_key::CreateKeyError>()
31                    .expect("correct error type")
32            })
33        };
34        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
35            .await
36            .map_err(map_err)?;
37        let output = context.finalize().map_err(map_err)?;
38        ::std::result::Result::Ok(
39            output
40                .downcast::<crate::operation::create_key::CreateKeyOutput>()
41                .expect("correct output type"),
42        )
43    }
44
45    pub(crate) async fn orchestrate_with_stop_point(
46        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
47        input: crate::operation::create_key::CreateKeyInput,
48        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
49    ) -> ::std::result::Result<
50        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
51        ::aws_smithy_runtime_api::client::result::SdkError<
52            ::aws_smithy_runtime_api::client::interceptors::context::Error,
53            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
54        >,
55    > {
56        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
57        use ::tracing::Instrument;
58        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("KMS", "CreateKey", input, runtime_plugins, stop_point)
59            // Create a parent span for the entire operation. Includes a random, internal-only,
60            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
61            .instrument(::tracing::debug_span!(
62                "KMS.CreateKey",
63                "rpc.service" = "KMS",
64                "rpc.method" = "CreateKey",
65                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
66                "rpc.system" = "aws-api",
67            ))
68            .await
69    }
70
71    pub(crate) fn operation_runtime_plugins(
72        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
73        client_config: &crate::config::Config,
74        config_override: ::std::option::Option<crate::config::Builder>,
75    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
76        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
77
78        if let ::std::option::Option::Some(config_override) = config_override {
79            for plugin in config_override.runtime_plugins.iter().cloned() {
80                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
81            }
82            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
83                config_override,
84                client_config.config.clone(),
85                &client_config.runtime_components,
86            ));
87        }
88        runtime_plugins
89    }
90}
91/// Per-operation error registry. Contains an entry for every modeled
92/// error this operation can throw.
93///
94/// Used by the schema-serde error path as the operation-scoped lookup
95/// for registry-backed error reification: an error code that does not
96/// match one of the operation's modeled errors directly is resolved
97/// against this registry first, then widened to the service-wide error
98/// registry.
99pub(crate) mod error_registry {
100    pub(crate) static REGISTRY: ::std::sync::LazyLock<::aws_smithy_schema::registry::TypeRegistry> = ::std::sync::LazyLock::new(|| {
101        ::aws_smithy_schema::registry::TypeRegistry::builder()
102                            .insert_error_shape(
103                        crate::types::error::CloudHsmClusterInvalidConfigurationException::SCHEMA,
104                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
105                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CloudHsmClusterInvalidConfigurationException::deserialize(d)?))
106                        },
107                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
108                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CloudHsmClusterInvalidConfigurationException::deserialize(d)?))
109                        },
110                    )
111.insert_error_shape(
112                        crate::types::error::CustomKeyStoreInvalidStateException::SCHEMA,
113                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
114                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CustomKeyStoreInvalidStateException::deserialize(d)?))
115                        },
116                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
117                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CustomKeyStoreInvalidStateException::deserialize(d)?))
118                        },
119                    )
120.insert_error_shape(
121                        crate::types::error::CustomKeyStoreNotFoundException::SCHEMA,
122                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
123                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CustomKeyStoreNotFoundException::deserialize(d)?))
124                        },
125                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
126                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CustomKeyStoreNotFoundException::deserialize(d)?))
127                        },
128                    )
129.insert_error_shape(
130                        crate::types::error::DependencyTimeoutException::SCHEMA,
131                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
132                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::DependencyTimeoutException::deserialize(d)?))
133                        },
134                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
135                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::DependencyTimeoutException::deserialize(d)?))
136                        },
137                    )
138.insert_error_shape(
139                        crate::types::error::InvalidArnException::SCHEMA,
140                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
141                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::InvalidArnException::deserialize(d)?))
142                        },
143                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
144                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::InvalidArnException::deserialize(d)?))
145                        },
146                    )
147.insert_error_shape(
148                        crate::types::error::KmsInternalException::SCHEMA,
149                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
150                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::KmsInternalException::deserialize(d)?))
151                        },
152                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
153                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::KmsInternalException::deserialize(d)?))
154                        },
155                    )
156.insert_error_shape(
157                        crate::types::error::LimitExceededException::SCHEMA,
158                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
159                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::LimitExceededException::deserialize(d)?))
160                        },
161                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
162                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::LimitExceededException::deserialize(d)?))
163                        },
164                    )
165.insert_error_shape(
166                        crate::types::error::MalformedPolicyDocumentException::SCHEMA,
167                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
168                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::MalformedPolicyDocumentException::deserialize(d)?))
169                        },
170                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
171                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::MalformedPolicyDocumentException::deserialize(d)?))
172                        },
173                    )
174.insert_error_shape(
175                        crate::types::error::TagException::SCHEMA,
176                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
177                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::TagException::deserialize(d)?))
178                        },
179                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
180                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::TagException::deserialize(d)?))
181                        },
182                    )
183.insert_error_shape(
184                        crate::types::error::UnsupportedOperationException::SCHEMA,
185                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
186                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::UnsupportedOperationException::deserialize(d)?))
187                        },
188                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
189                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::UnsupportedOperationException::deserialize(d)?))
190                        },
191                    )
192.insert_error_shape(
193                        crate::types::error::XksKeyAlreadyInUseException::SCHEMA,
194                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
195                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::XksKeyAlreadyInUseException::deserialize(d)?))
196                        },
197                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
198                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::XksKeyAlreadyInUseException::deserialize(d)?))
199                        },
200                    )
201.insert_error_shape(
202                        crate::types::error::XksKeyInvalidConfigurationException::SCHEMA,
203                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
204                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::XksKeyInvalidConfigurationException::deserialize(d)?))
205                        },
206                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
207                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::XksKeyInvalidConfigurationException::deserialize(d)?))
208                        },
209                    )
210.insert_error_shape(
211                        crate::types::error::XksKeyNotFoundException::SCHEMA,
212                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
213                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::XksKeyNotFoundException::deserialize(d)?))
214                        },
215                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
216                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::XksKeyNotFoundException::deserialize(d)?))
217                        },
218                    )
219                            .build()
220    });
221}
222impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for CreateKey {
223    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
224        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CreateKey");
225
226        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
227            CreateKeyRequestSerializer,
228        ));
229        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
230            CreateKeyResponseDeserializer,
231        ));
232
233        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
234            crate::config::auth::Params::builder()
235                .operation_name("CreateKey")
236                .build()
237                .expect("required fields set"),
238        ));
239
240        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("CreateKey", "KMS"));
241        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
242        signing_options.double_uri_encode = true;
243        signing_options.content_sha256_header = false;
244        signing_options.normalize_uri_path = true;
245        signing_options.payload_override = None;
246
247        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
248            signing_options,
249            ..::std::default::Default::default()
250        });
251
252        ::std::option::Option::Some(cfg.freeze())
253    }
254
255    fn runtime_components(
256        &self,
257        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
258    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
259        #[allow(unused_mut)]
260        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CreateKey")
261            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
262                CreateKeyTelemetryInputCaptureInterceptor,
263            ))
264            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
265                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
266            ))
267            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
268                CreateKeyEndpointParamsInterceptor,
269            ))
270            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
271                crate::operation::create_key::CreateKeyError,
272            >::new())
273            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
274                crate::operation::create_key::CreateKeyError,
275            >::new())
276            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
277                crate::operation::create_key::CreateKeyError,
278            >::new())
279            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
280                crate::operation::create_key::CreateKeyError,
281            >::new());
282
283        ::std::borrow::Cow::Owned(rcb)
284    }
285}
286
287#[derive(Debug)]
288struct CreateKeyTelemetryInputCaptureInterceptor;
289
290#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
291impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateKeyTelemetryInputCaptureInterceptor {
292    fn name(&self) -> &'static str {
293        "CreateKeyTelemetryInputCaptureInterceptor"
294    }
295
296    fn read_before_execution(
297        &self,
298        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
299            '_,
300            ::aws_smithy_runtime_api::client::interceptors::context::Input,
301            ::aws_smithy_runtime_api::client::interceptors::context::Output,
302            ::aws_smithy_runtime_api::client::interceptors::context::Error,
303        >,
304        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
305    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
306        // Nothing to do unless the customer opted in by naming members to record.
307        let ::std::option::Option::Some(requested) = cfg
308            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
309            .filter(|r| !r.is_empty())
310        else {
311            return ::std::result::Result::Ok(());
312        };
313
314        let ::std::option::Option::Some(input) = context.input().downcast_ref::<CreateKeyInput>() else {
315            // A mismatched input is not this interceptor's concern; skip quietly.
316            return ::std::result::Result::Ok(());
317        };
318
319        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
320        if requested.should_capture("Policy") {
321            if let ::std::option::Option::Some(value) = input.policy.as_deref() {
322                captured.insert("Policy", value);
323            }
324        }
325        if requested.should_capture("Description") {
326            if let ::std::option::Option::Some(value) = input.description.as_deref() {
327                captured.insert("Description", value);
328            }
329        }
330        if requested.should_capture("CustomKeyStoreId") {
331            if let ::std::option::Option::Some(value) = input.custom_key_store_id.as_deref() {
332                captured.insert("CustomKeyStoreId", value);
333            }
334        }
335        if requested.should_capture("XksKeyId") {
336            if let ::std::option::Option::Some(value) = input.xks_key_id.as_deref() {
337                captured.insert("XksKeyId", value);
338            }
339        }
340
341        cfg.interceptor_state().store_put(captured);
342        ::std::result::Result::Ok(())
343    }
344}
345#[derive(Debug)]
346struct CreateKeyResponseDeserializer;
347impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CreateKeyResponseDeserializer {
348    fn deserialize_nonstreaming_with_config(
349        &self,
350        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
351        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
352    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
353        let (success, status) = (response.status().is_success(), response.status().as_u16());
354        // Load body and headers BEFORE BeforeParseResponse so customizations
355        // (e.g., S3's `body_is_error` check that detects errors returned with
356        // HTTP 200) can inspect them. The legacy non-streaming path also
357        // loads `body` before firing this hook.
358        #[allow(unused_variables)]
359        let body = response.body().bytes().expect("body loaded");
360        let headers = response.headers();
361        #[allow(unused_mut)]
362        let mut force_error = false;
363        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
364        if !success && status != 200 || force_error {
365            let protocol = _cfg
366                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
367                .expect("a SharedClientProtocol is required");
368            #[allow(unused_mut)]
369            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
370                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
371            })?;
372            generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
373            let generic = generic_builder.build();
374            let error_code = match generic.code() {
375                ::std::option::Option::Some(code) => code,
376                ::std::option::Option::None => {
377                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
378                        ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::create_key::CreateKeyError::unhandled(generic)),
379                    ))
380                }
381            };
382            let _error_message = generic.message().map(|msg| msg.to_owned());
383            let err = match error_code {
384                "CloudHsmClusterInvalidConfigurationException" => {
385                    crate::operation::create_key::CreateKeyError::CloudHsmClusterInvalidConfigurationException({
386                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
387                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
388                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
389                            )
390                        })?;
391                        let mut tmp = <crate::types::error::builders::CloudHsmClusterInvalidConfigurationExceptionBuilder>::default();
392                        tmp.deserialize_members(&mut *deser).map_err(|e| {
393                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
394                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
395                            )
396                        })?;
397                        if tmp.message.is_none() {
398                            tmp.message = _error_message;
399                        }
400                        let tmp = tmp.meta(generic);
401                        tmp.build()
402                    })
403                }
404                "CustomKeyStoreInvalidStateException" => crate::operation::create_key::CreateKeyError::CustomKeyStoreInvalidStateException({
405                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
406                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
407                            e,
408                        ))
409                    })?;
410                    let mut tmp = <crate::types::error::builders::CustomKeyStoreInvalidStateExceptionBuilder>::default();
411                    tmp.deserialize_members(&mut *deser).map_err(|e| {
412                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
413                            e,
414                        ))
415                    })?;
416                    if tmp.message.is_none() {
417                        tmp.message = _error_message;
418                    }
419                    let tmp = tmp.meta(generic);
420                    tmp.build()
421                }),
422                "CustomKeyStoreNotFoundException" => crate::operation::create_key::CreateKeyError::CustomKeyStoreNotFoundException({
423                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
424                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
425                            e,
426                        ))
427                    })?;
428                    let mut tmp = <crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder>::default();
429                    tmp.deserialize_members(&mut *deser).map_err(|e| {
430                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
431                            e,
432                        ))
433                    })?;
434                    if tmp.message.is_none() {
435                        tmp.message = _error_message;
436                    }
437                    let tmp = tmp.meta(generic);
438                    tmp.build()
439                }),
440                "DependencyTimeoutException" => crate::operation::create_key::CreateKeyError::DependencyTimeoutException({
441                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
442                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
443                            e,
444                        ))
445                    })?;
446                    let mut tmp = <crate::types::error::builders::DependencyTimeoutExceptionBuilder>::default();
447                    tmp.deserialize_members(&mut *deser).map_err(|e| {
448                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
449                            e,
450                        ))
451                    })?;
452                    if tmp.message.is_none() {
453                        tmp.message = _error_message;
454                    }
455                    let tmp = tmp.meta(generic);
456                    tmp.build()
457                }),
458                "InvalidArnException" => crate::operation::create_key::CreateKeyError::InvalidArnException({
459                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
460                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
461                            e,
462                        ))
463                    })?;
464                    let mut tmp = <crate::types::error::builders::InvalidArnExceptionBuilder>::default();
465                    tmp.deserialize_members(&mut *deser).map_err(|e| {
466                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
467                            e,
468                        ))
469                    })?;
470                    if tmp.message.is_none() {
471                        tmp.message = _error_message;
472                    }
473                    let tmp = tmp.meta(generic);
474                    tmp.build()
475                }),
476                "KMSInternalException" => crate::operation::create_key::CreateKeyError::KmsInternalException({
477                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
478                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
479                            e,
480                        ))
481                    })?;
482                    let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
483                    tmp.deserialize_members(&mut *deser).map_err(|e| {
484                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
485                            e,
486                        ))
487                    })?;
488                    if tmp.message.is_none() {
489                        tmp.message = _error_message;
490                    }
491                    let tmp = tmp.meta(generic);
492                    tmp.build()
493                }),
494                "LimitExceededException" => crate::operation::create_key::CreateKeyError::LimitExceededException({
495                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
496                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
497                            e,
498                        ))
499                    })?;
500                    let mut tmp = <crate::types::error::builders::LimitExceededExceptionBuilder>::default();
501                    tmp.deserialize_members(&mut *deser).map_err(|e| {
502                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
503                            e,
504                        ))
505                    })?;
506                    if tmp.message.is_none() {
507                        tmp.message = _error_message;
508                    }
509                    let tmp = tmp.meta(generic);
510                    tmp.build()
511                }),
512                "MalformedPolicyDocumentException" => crate::operation::create_key::CreateKeyError::MalformedPolicyDocumentException({
513                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
514                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
515                            e,
516                        ))
517                    })?;
518                    let mut tmp = <crate::types::error::builders::MalformedPolicyDocumentExceptionBuilder>::default();
519                    tmp.deserialize_members(&mut *deser).map_err(|e| {
520                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
521                            e,
522                        ))
523                    })?;
524                    if tmp.message.is_none() {
525                        tmp.message = _error_message;
526                    }
527                    let tmp = tmp.meta(generic);
528                    tmp.build()
529                }),
530                "TagException" => crate::operation::create_key::CreateKeyError::TagException({
531                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
532                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
533                            e,
534                        ))
535                    })?;
536                    let mut tmp = <crate::types::error::builders::TagExceptionBuilder>::default();
537                    tmp.deserialize_members(&mut *deser).map_err(|e| {
538                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
539                            e,
540                        ))
541                    })?;
542                    if tmp.message.is_none() {
543                        tmp.message = _error_message;
544                    }
545                    let tmp = tmp.meta(generic);
546                    tmp.build()
547                }),
548                "UnsupportedOperationException" => crate::operation::create_key::CreateKeyError::UnsupportedOperationException({
549                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
550                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
551                            e,
552                        ))
553                    })?;
554                    let mut tmp = <crate::types::error::builders::UnsupportedOperationExceptionBuilder>::default();
555                    tmp.deserialize_members(&mut *deser).map_err(|e| {
556                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
557                            e,
558                        ))
559                    })?;
560                    if tmp.message.is_none() {
561                        tmp.message = _error_message;
562                    }
563                    let tmp = tmp.meta(generic);
564                    tmp.build()
565                }),
566                "XksKeyAlreadyInUseException" => crate::operation::create_key::CreateKeyError::XksKeyAlreadyInUseException({
567                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
568                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
569                            e,
570                        ))
571                    })?;
572                    let mut tmp = <crate::types::error::builders::XksKeyAlreadyInUseExceptionBuilder>::default();
573                    tmp.deserialize_members(&mut *deser).map_err(|e| {
574                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
575                            e,
576                        ))
577                    })?;
578                    if tmp.message.is_none() {
579                        tmp.message = _error_message;
580                    }
581                    let tmp = tmp.meta(generic);
582                    tmp.build()
583                }),
584                "XksKeyInvalidConfigurationException" => crate::operation::create_key::CreateKeyError::XksKeyInvalidConfigurationException({
585                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
586                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
587                            e,
588                        ))
589                    })?;
590                    let mut tmp = <crate::types::error::builders::XksKeyInvalidConfigurationExceptionBuilder>::default();
591                    tmp.deserialize_members(&mut *deser).map_err(|e| {
592                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
593                            e,
594                        ))
595                    })?;
596                    if tmp.message.is_none() {
597                        tmp.message = _error_message;
598                    }
599                    let tmp = tmp.meta(generic);
600                    tmp.build()
601                }),
602                "XksKeyNotFoundException" => crate::operation::create_key::CreateKeyError::XksKeyNotFoundException({
603                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
604                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
605                            e,
606                        ))
607                    })?;
608                    let mut tmp = <crate::types::error::builders::XksKeyNotFoundExceptionBuilder>::default();
609                    tmp.deserialize_members(&mut *deser).map_err(|e| {
610                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
611                            e,
612                        ))
613                    })?;
614                    if tmp.message.is_none() {
615                        tmp.message = _error_message;
616                    }
617                    let tmp = tmp.meta(generic);
618                    tmp.build()
619                }),
620                _ => {
621                    // Registry-backed, operation-scoped reification of an error whose
622                    // code this operation does not model directly: the operation's own
623                    // error registry is consulted first, then the lookup widens to the
624                    // service-wide error registry. On a hit, the reified error is attached
625                    // as the source of the returned unhandled error while its metadata
626                    // (code, message, request id) is preserved; on a miss the generic
627                    // error is returned unchanged.
628                    match protocol
629                        .deserialize_error_response(response, _cfg)
630                        .ok()
631                        .and_then(|mut deser| {
632                            ::aws_smithy_schema::registry::reify_error(
633                                crate::operation::create_key::error_registry::REGISTRY
634                                    .or(&crate::error_type_registry::REGISTRY),
635                                error_code,
636                                &mut *deser,
637                            )
638                        }) {
639                        ::std::option::Option::Some(source) => <crate::operation::create_key::CreateKeyError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
640                        ::std::option::Option::None => crate::operation::create_key::CreateKeyError::generic(generic),
641                    }
642                }
643            };
644            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
645                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
646            ))
647        } else {
648            let protocol = _cfg
649                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
650                .expect("a SharedClientProtocol is required");
651            let mut deser = protocol.deserialize_response(response, CreateKey::OUTPUT_SCHEMA, _cfg).map_err(|e| {
652                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
653            })?;
654            // `headers` is already in scope from the top of the function; alias it as
655            // `_response_headers` so MutateOutput customizations have a stable name to
656            // read from.
657            let _response_headers = headers;
658            // `mut` is required because `deserialize_members` and the `MutateOutput`
659            // builder setters take `&mut self`. Marked `allow(unused_mut)` because an
660            // empty output has no members and no customizations to run.
661            #[allow(unused_mut)]
662            let mut output = <crate::operation::create_key::builders::CreateKeyOutputBuilder>::default();
663            output.deserialize_members(&mut *deser).map_err(|e| {
664                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
665            })?;
666            output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
667            let output = output.build();
668            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
669        }
670    }
671}
672#[derive(Debug)]
673struct CreateKeyRequestSerializer;
674impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CreateKeyRequestSerializer {
675    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
676    fn serialize_input(
677        &self,
678        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
679        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
680    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
681        let input = input.downcast::<crate::operation::create_key::CreateKeyInput>().expect("correct type");
682
683        let protocol = _cfg
684            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
685            .expect("a SharedClientProtocol is required");
686        let mut request = protocol
687            .serialize_request(&input, CreateKey::INPUT_SCHEMA, "/", _cfg)
688            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
689
690        return ::std::result::Result::Ok(request);
691    }
692}
693#[derive(Debug)]
694struct CreateKeyEndpointParamsInterceptor;
695
696#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
697impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateKeyEndpointParamsInterceptor {
698    fn name(&self) -> &'static str {
699        "CreateKeyEndpointParamsInterceptor"
700    }
701
702    fn read_before_execution(
703        &self,
704        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
705            '_,
706            ::aws_smithy_runtime_api::client::interceptors::context::Input,
707            ::aws_smithy_runtime_api::client::interceptors::context::Output,
708            ::aws_smithy_runtime_api::client::interceptors::context::Error,
709        >,
710        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
711    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
712        let _input = context
713            .input()
714            .downcast_ref::<CreateKeyInput>()
715            .ok_or("failed to downcast to CreateKeyInput")?;
716
717        let params = crate::config::endpoint::Params::builder()
718            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
719            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
720            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
721            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
722            .build()
723            .map_err(|err| {
724                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
725            })?;
726        cfg.interceptor_state()
727            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
728        ::std::result::Result::Ok(())
729    }
730}
731
732// The get_* functions below are generated from JMESPath expressions in the
733// operationContextParams trait. They target the operation's input shape.
734
735/// Error type for the `CreateKeyError` operation.
736#[non_exhaustive]
737#[derive(::std::fmt::Debug)]
738pub enum CreateKeyError {
739    /// <p>The request was rejected because the associated CloudHSM cluster did not meet the configuration requirements for an CloudHSM key store.</p>
740    /// <ul>
741    /// <li>
742    /// <p>The CloudHSM cluster must be configured with private subnets in at least two different Availability Zones in the Region.</p></li>
743    /// <li>
744    /// <p>The <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/configure-sg.html">security group for the cluster</a> (cloudhsm-cluster-<i><cluster-id></cluster-id></i>-sg) must include inbound rules and outbound rules that allow TCP traffic on ports 2223-2225. The <b>Source</b> in the inbound rules and the <b>Destination</b> in the outbound rules must match the security group ID. These rules are set by default when you create the CloudHSM cluster. Do not delete or change them. To get information about a particular security group, use the <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSecurityGroups.html">DescribeSecurityGroups</a> operation.</p></li>
745    /// <li>
746    /// <p>The CloudHSM cluster must contain at least as many HSMs as the operation requires. To add HSMs, use the CloudHSM <a href="https://docs.aws.amazon.com/cloudhsm/latest/APIReference/API_CreateHsm.html">CreateHsm</a> operation.</p>
747    /// <p>For the <code>CreateCustomKeyStore</code>, <code>UpdateCustomKeyStore</code>, and <code>CreateKey</code> operations, the CloudHSM cluster must have at least two active HSMs, each in a different Availability Zone. For the <code>ConnectCustomKeyStore</code> operation, the CloudHSM must contain at least one active HSM.</p></li>
748    /// </ul>
749    /// <p>For information about the requirements for an CloudHSM cluster that is associated with an CloudHSM key store, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/create-keystore.html#before-keystore">Assemble the Prerequisites</a> in the <i>Key Management Service Developer Guide</i>. For information about creating a private subnet for an CloudHSM cluster, see <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/create-subnets.html">Create a Private Subnet</a> in the <i>CloudHSM User Guide</i>. For information about cluster security groups, see <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/configure-sg.html">Configure a Default Security Group</a> in the <i> <i>CloudHSM User Guide</i> </i>.</p>
750    CloudHsmClusterInvalidConfigurationException(crate::types::error::CloudHsmClusterInvalidConfigurationException),
751    /// <p>The request was rejected because of the <code>ConnectionState</code> of the custom key store. To get the <code>ConnectionState</code> of a custom key store, use the <code>DescribeCustomKeyStores</code> operation.</p>
752    /// <p>This exception is thrown under the following conditions:</p>
753    /// <ul>
754    /// <li>
755    /// <p>You requested the <code>ConnectCustomKeyStore</code> operation on a custom key store with a <code>ConnectionState</code> of <code>DISCONNECTING</code> or <code>FAILED</code>. This operation is valid for all other <code>ConnectionState</code> values. To reconnect a custom key store in a <code>FAILED</code> state, disconnect it (<code>DisconnectCustomKeyStore</code>), then connect it (<code>ConnectCustomKeyStore</code>).</p></li>
756    /// <li>
757    /// <p>You requested the <code>CreateKey</code> operation in a custom key store that is not connected. This operations is valid only when the custom key store <code>ConnectionState</code> is <code>CONNECTED</code>.</p></li>
758    /// <li>
759    /// <p>You requested the <code>DisconnectCustomKeyStore</code> operation on a custom key store with a <code>ConnectionState</code> of <code>DISCONNECTING</code> or <code>DISCONNECTED</code>. This operation is valid for all other <code>ConnectionState</code> values.</p></li>
760    /// <li>
761    /// <p>You requested the <code>UpdateCustomKeyStore</code> or <code>DeleteCustomKeyStore</code> operation on a custom key store that is not disconnected. <code>UpdateCustomKeyStore</code> can be called on a custom key store in the <code>CONNECTED</code> state only to update <code>NewCustomKeyStoreName</code>. For all other properties, the custom key store <code>ConnectionState</code> must be <code>DISCONNECTED</code>.</p></li>
762    /// <li>
763    /// <p>You requested the <code>GenerateRandom</code> operation in an CloudHSM key store that is not connected. This operation is valid only when the CloudHSM key store <code>ConnectionState</code> is <code>CONNECTED</code>.</p></li>
764    /// </ul>
765    CustomKeyStoreInvalidStateException(crate::types::error::CustomKeyStoreInvalidStateException),
766    /// <p>The request was rejected because KMS cannot find a custom key store with the specified key store name or ID.</p>
767    CustomKeyStoreNotFoundException(crate::types::error::CustomKeyStoreNotFoundException),
768    /// <p>The system timed out while trying to fulfill the request. You can retry the request.</p>
769    DependencyTimeoutException(crate::types::error::DependencyTimeoutException),
770    /// <p>The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.</p>
771    InvalidArnException(crate::types::error::InvalidArnException),
772    /// <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
773    KmsInternalException(crate::types::error::KmsInternalException),
774    /// <p>The request was rejected because a length constraint or quota was exceeded. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/limits.html">Quotas</a> in the <i>Key Management Service Developer Guide</i>.</p>
775    LimitExceededException(crate::types::error::LimitExceededException),
776    /// <p>The request was rejected because the specified policy is not syntactically or semantically correct.</p>
777    MalformedPolicyDocumentException(crate::types::error::MalformedPolicyDocumentException),
778    /// <p>The request was rejected because one or more tags are not valid.</p>
779    TagException(crate::types::error::TagException),
780    /// <p>The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.</p>
781    UnsupportedOperationException(crate::types::error::UnsupportedOperationException),
782    /// <p>The request was rejected because the (<code>XksKeyId</code>) is already associated with another KMS key in this external key store. Each KMS key in an external key store must be associated with a different external key.</p>
783    XksKeyAlreadyInUseException(crate::types::error::XksKeyAlreadyInUseException),
784    /// <p>The request was rejected because the external key specified by the <code>XksKeyId</code> parameter did not meet the configuration requirements for an external key store.</p>
785    /// <p>The external key must be an AES-256 symmetric key that is enabled and performs encryption and decryption.</p>
786    XksKeyInvalidConfigurationException(crate::types::error::XksKeyInvalidConfigurationException),
787    /// <p>The request was rejected because the external key store proxy could not find the external key. This exception is thrown when the value of the <code>XksKeyId</code> parameter doesn't identify a key in the external key manager associated with the external key proxy.</p>
788    /// <p>Verify that the <code>XksKeyId</code> represents an existing key in the external key manager. Use the key identifier that the external key store proxy uses to identify the key. For details, see the documentation provided with your external key store proxy or key manager.</p>
789    XksKeyNotFoundException(crate::types::error::XksKeyNotFoundException),
790    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
791    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
792    variable wildcard pattern and check `.code()`:
793     \
794    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
795     \
796    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CreateKeyError) for what information is available for the error.")]
797    Unhandled(crate::error::sealed_unhandled::Unhandled),
798}
799impl CreateKeyError {
800    /// Creates the `CreateKeyError::Unhandled` variant from any error type.
801    pub fn unhandled(
802        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
803    ) -> Self {
804        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
805            source: err.into(),
806            meta: ::std::default::Default::default(),
807        })
808    }
809
810    /// Creates the `CreateKeyError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
811    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
812        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
813            source: err.clone().into(),
814            meta: err,
815        })
816    }
817    ///
818    /// Returns error metadata, which includes the error code, message,
819    /// request ID, and potentially additional information.
820    ///
821    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
822        match self {
823            Self::CloudHsmClusterInvalidConfigurationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
824            Self::CustomKeyStoreInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
825            Self::CustomKeyStoreNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
826            Self::DependencyTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
827            Self::InvalidArnException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
828            Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
829            Self::LimitExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
830            Self::MalformedPolicyDocumentException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
831            Self::TagException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
832            Self::UnsupportedOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
833            Self::XksKeyAlreadyInUseException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
834            Self::XksKeyInvalidConfigurationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
835            Self::XksKeyNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
836            Self::Unhandled(e) => &e.meta,
837        }
838    }
839    /// Returns `true` if the error kind is `CreateKeyError::CloudHsmClusterInvalidConfigurationException`.
840    pub fn is_cloud_hsm_cluster_invalid_configuration_exception(&self) -> bool {
841        matches!(self, Self::CloudHsmClusterInvalidConfigurationException(_))
842    }
843    /// Returns `true` if the error kind is `CreateKeyError::CustomKeyStoreInvalidStateException`.
844    pub fn is_custom_key_store_invalid_state_exception(&self) -> bool {
845        matches!(self, Self::CustomKeyStoreInvalidStateException(_))
846    }
847    /// Returns `true` if the error kind is `CreateKeyError::CustomKeyStoreNotFoundException`.
848    pub fn is_custom_key_store_not_found_exception(&self) -> bool {
849        matches!(self, Self::CustomKeyStoreNotFoundException(_))
850    }
851    /// Returns `true` if the error kind is `CreateKeyError::DependencyTimeoutException`.
852    pub fn is_dependency_timeout_exception(&self) -> bool {
853        matches!(self, Self::DependencyTimeoutException(_))
854    }
855    /// Returns `true` if the error kind is `CreateKeyError::InvalidArnException`.
856    pub fn is_invalid_arn_exception(&self) -> bool {
857        matches!(self, Self::InvalidArnException(_))
858    }
859    /// Returns `true` if the error kind is `CreateKeyError::KmsInternalException`.
860    pub fn is_kms_internal_exception(&self) -> bool {
861        matches!(self, Self::KmsInternalException(_))
862    }
863    /// Returns `true` if the error kind is `CreateKeyError::LimitExceededException`.
864    pub fn is_limit_exceeded_exception(&self) -> bool {
865        matches!(self, Self::LimitExceededException(_))
866    }
867    /// Returns `true` if the error kind is `CreateKeyError::MalformedPolicyDocumentException`.
868    pub fn is_malformed_policy_document_exception(&self) -> bool {
869        matches!(self, Self::MalformedPolicyDocumentException(_))
870    }
871    /// Returns `true` if the error kind is `CreateKeyError::TagException`.
872    pub fn is_tag_exception(&self) -> bool {
873        matches!(self, Self::TagException(_))
874    }
875    /// Returns `true` if the error kind is `CreateKeyError::UnsupportedOperationException`.
876    pub fn is_unsupported_operation_exception(&self) -> bool {
877        matches!(self, Self::UnsupportedOperationException(_))
878    }
879    /// Returns `true` if the error kind is `CreateKeyError::XksKeyAlreadyInUseException`.
880    pub fn is_xks_key_already_in_use_exception(&self) -> bool {
881        matches!(self, Self::XksKeyAlreadyInUseException(_))
882    }
883    /// Returns `true` if the error kind is `CreateKeyError::XksKeyInvalidConfigurationException`.
884    pub fn is_xks_key_invalid_configuration_exception(&self) -> bool {
885        matches!(self, Self::XksKeyInvalidConfigurationException(_))
886    }
887    /// Returns `true` if the error kind is `CreateKeyError::XksKeyNotFoundException`.
888    pub fn is_xks_key_not_found_exception(&self) -> bool {
889        matches!(self, Self::XksKeyNotFoundException(_))
890    }
891}
892impl ::std::error::Error for CreateKeyError {
893    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
894        match self {
895            Self::CloudHsmClusterInvalidConfigurationException(_inner) => ::std::option::Option::Some(_inner),
896            Self::CustomKeyStoreInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
897            Self::CustomKeyStoreNotFoundException(_inner) => ::std::option::Option::Some(_inner),
898            Self::DependencyTimeoutException(_inner) => ::std::option::Option::Some(_inner),
899            Self::InvalidArnException(_inner) => ::std::option::Option::Some(_inner),
900            Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
901            Self::LimitExceededException(_inner) => ::std::option::Option::Some(_inner),
902            Self::MalformedPolicyDocumentException(_inner) => ::std::option::Option::Some(_inner),
903            Self::TagException(_inner) => ::std::option::Option::Some(_inner),
904            Self::UnsupportedOperationException(_inner) => ::std::option::Option::Some(_inner),
905            Self::XksKeyAlreadyInUseException(_inner) => ::std::option::Option::Some(_inner),
906            Self::XksKeyInvalidConfigurationException(_inner) => ::std::option::Option::Some(_inner),
907            Self::XksKeyNotFoundException(_inner) => ::std::option::Option::Some(_inner),
908            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
909        }
910    }
911}
912impl ::std::fmt::Display for CreateKeyError {
913    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
914        match self {
915            Self::CloudHsmClusterInvalidConfigurationException(_inner) => _inner.fmt(f),
916            Self::CustomKeyStoreInvalidStateException(_inner) => _inner.fmt(f),
917            Self::CustomKeyStoreNotFoundException(_inner) => _inner.fmt(f),
918            Self::DependencyTimeoutException(_inner) => _inner.fmt(f),
919            Self::InvalidArnException(_inner) => _inner.fmt(f),
920            Self::KmsInternalException(_inner) => _inner.fmt(f),
921            Self::LimitExceededException(_inner) => _inner.fmt(f),
922            Self::MalformedPolicyDocumentException(_inner) => _inner.fmt(f),
923            Self::TagException(_inner) => _inner.fmt(f),
924            Self::UnsupportedOperationException(_inner) => _inner.fmt(f),
925            Self::XksKeyAlreadyInUseException(_inner) => _inner.fmt(f),
926            Self::XksKeyInvalidConfigurationException(_inner) => _inner.fmt(f),
927            Self::XksKeyNotFoundException(_inner) => _inner.fmt(f),
928            Self::Unhandled(_inner) => {
929                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
930                    write!(f, "unhandled error ({code})")
931                } else {
932                    f.write_str("unhandled error")
933                }
934            }
935        }
936    }
937}
938impl ::aws_smithy_types::retry::ProvideErrorKind for CreateKeyError {
939    fn code(&self) -> ::std::option::Option<&str> {
940        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
941    }
942    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
943        ::std::option::Option::None
944    }
945}
946impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CreateKeyError {
947    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
948        match self {
949            Self::CloudHsmClusterInvalidConfigurationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
950            Self::CustomKeyStoreInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
951            Self::CustomKeyStoreNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
952            Self::DependencyTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
953            Self::InvalidArnException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
954            Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
955            Self::LimitExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
956            Self::MalformedPolicyDocumentException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
957            Self::TagException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
958            Self::UnsupportedOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
959            Self::XksKeyAlreadyInUseException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
960            Self::XksKeyInvalidConfigurationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
961            Self::XksKeyNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
962            Self::Unhandled(_inner) => &_inner.meta,
963        }
964    }
965}
966impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CreateKeyError {
967    fn create_unhandled_error(
968        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
969        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
970    ) -> Self {
971        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
972            source,
973            meta: meta.unwrap_or_default(),
974        })
975    }
976}
977impl ::aws_types::request_id::RequestId for crate::operation::create_key::CreateKeyError {
978    fn request_id(&self) -> Option<&str> {
979        self.meta().request_id()
980    }
981}
982
983pub use crate::operation::create_key::_create_key_input::CreateKeyInput;
984
985pub use crate::operation::create_key::_create_key_output::CreateKeyOutput;
986
987mod _create_key_input;
988
989mod _create_key_output;
990
991/// Builders
992pub mod builders;