Skip to main content

aws_sdk_kms/operation/
connect_custom_key_store.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `ConnectCustomKeyStore`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ConnectCustomKeyStore;
6impl ConnectCustomKeyStore {
7    /// Creates a new `ConnectCustomKeyStore`
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> =
13        crate::operation::connect_custom_key_store::ConnectCustomKeyStoreInput::SCHEMA;
14    /// The schema for this operation's output shape.
15    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> =
16        crate::operation::connect_custom_key_store::ConnectCustomKeyStoreOutput::SCHEMA;
17    pub(crate) async fn orchestrate(
18        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
19        input: crate::operation::connect_custom_key_store::ConnectCustomKeyStoreInput,
20    ) -> ::std::result::Result<
21        crate::operation::connect_custom_key_store::ConnectCustomKeyStoreOutput,
22        ::aws_smithy_runtime_api::client::result::SdkError<
23            crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError,
24            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
25        >,
26    > {
27        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
28            ::aws_smithy_runtime_api::client::interceptors::context::Error,
29            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
30        >| {
31            err.map_service_error(|err| {
32                err.downcast::<crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError>()
33                    .expect("correct error type")
34            })
35        };
36        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
37            .await
38            .map_err(map_err)?;
39        let output = context.finalize().map_err(map_err)?;
40        ::std::result::Result::Ok(
41            output
42                .downcast::<crate::operation::connect_custom_key_store::ConnectCustomKeyStoreOutput>()
43                .expect("correct output type"),
44        )
45    }
46
47    pub(crate) async fn orchestrate_with_stop_point(
48        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
49        input: crate::operation::connect_custom_key_store::ConnectCustomKeyStoreInput,
50        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
51    ) -> ::std::result::Result<
52        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
53        ::aws_smithy_runtime_api::client::result::SdkError<
54            ::aws_smithy_runtime_api::client::interceptors::context::Error,
55            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
56        >,
57    > {
58        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
59        use ::tracing::Instrument;
60        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("KMS", "ConnectCustomKeyStore", input, runtime_plugins, stop_point)
61            // Create a parent span for the entire operation. Includes a random, internal-only,
62            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
63            .instrument(::tracing::debug_span!(
64                "KMS.ConnectCustomKeyStore",
65                "rpc.service" = "KMS",
66                "rpc.method" = "ConnectCustomKeyStore",
67                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
68                "rpc.system" = "aws-api",
69            ))
70            .await
71    }
72
73    pub(crate) fn operation_runtime_plugins(
74        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
75        client_config: &crate::config::Config,
76        config_override: ::std::option::Option<crate::config::Builder>,
77    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
78        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
79
80        if let ::std::option::Option::Some(config_override) = config_override {
81            for plugin in config_override.runtime_plugins.iter().cloned() {
82                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
83            }
84            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
85                config_override,
86                client_config.config.clone(),
87                &client_config.runtime_components,
88            ));
89        }
90        runtime_plugins
91    }
92}
93/// Per-operation error registry. Contains an entry for every modeled
94/// error this operation can throw.
95///
96/// Used by the schema-serde error path as the operation-scoped lookup
97/// for registry-backed error reification: an error code that does not
98/// match one of the operation's modeled errors directly is resolved
99/// against this registry first, then widened to the service-wide error
100/// registry.
101pub(crate) mod error_registry {
102    pub(crate) static REGISTRY: ::std::sync::LazyLock<::aws_smithy_schema::registry::TypeRegistry> = ::std::sync::LazyLock::new(|| {
103        ::aws_smithy_schema::registry::TypeRegistry::builder()
104                            .insert_error_shape(
105                        crate::types::error::CloudHsmClusterInvalidConfigurationException::SCHEMA,
106                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
107                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CloudHsmClusterInvalidConfigurationException::deserialize(d)?))
108                        },
109                        |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> {
110                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CloudHsmClusterInvalidConfigurationException::deserialize(d)?))
111                        },
112                    )
113.insert_error_shape(
114                        crate::types::error::CloudHsmClusterNotActiveException::SCHEMA,
115                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
116                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CloudHsmClusterNotActiveException::deserialize(d)?))
117                        },
118                        |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> {
119                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CloudHsmClusterNotActiveException::deserialize(d)?))
120                        },
121                    )
122.insert_error_shape(
123                        crate::types::error::CustomKeyStoreInvalidStateException::SCHEMA,
124                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
125                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CustomKeyStoreInvalidStateException::deserialize(d)?))
126                        },
127                        |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> {
128                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CustomKeyStoreInvalidStateException::deserialize(d)?))
129                        },
130                    )
131.insert_error_shape(
132                        crate::types::error::CustomKeyStoreNotFoundException::SCHEMA,
133                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
134                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::CustomKeyStoreNotFoundException::deserialize(d)?))
135                        },
136                        |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> {
137                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::CustomKeyStoreNotFoundException::deserialize(d)?))
138                        },
139                    )
140.insert_error_shape(
141                        crate::types::error::KmsInternalException::SCHEMA,
142                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
143                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::KmsInternalException::deserialize(d)?))
144                        },
145                        |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> {
146                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::KmsInternalException::deserialize(d)?))
147                        },
148                    )
149                            .build()
150    });
151}
152impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConnectCustomKeyStore {
153    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
154        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ConnectCustomKeyStore");
155
156        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
157            ConnectCustomKeyStoreRequestSerializer,
158        ));
159        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
160            ConnectCustomKeyStoreResponseDeserializer,
161        ));
162
163        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
164            crate::config::auth::Params::builder()
165                .operation_name("ConnectCustomKeyStore")
166                .build()
167                .expect("required fields set"),
168        ));
169
170        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
171            "ConnectCustomKeyStore",
172            "KMS",
173        ));
174        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
175        signing_options.double_uri_encode = true;
176        signing_options.content_sha256_header = false;
177        signing_options.normalize_uri_path = true;
178        signing_options.payload_override = None;
179
180        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
181            signing_options,
182            ..::std::default::Default::default()
183        });
184
185        ::std::option::Option::Some(cfg.freeze())
186    }
187
188    fn runtime_components(
189        &self,
190        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
191    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
192        #[allow(unused_mut)]
193        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ConnectCustomKeyStore")
194            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
195                ConnectCustomKeyStoreTelemetryInputCaptureInterceptor,
196            ))
197            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
198                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
199            ))
200            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
201                ConnectCustomKeyStoreEndpointParamsInterceptor,
202            ))
203            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
204                crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError,
205            >::new())
206            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
207                crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError,
208            >::new())
209            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
210                crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError,
211            >::new())
212            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
213                crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError,
214            >::new());
215
216        ::std::borrow::Cow::Owned(rcb)
217    }
218}
219
220#[derive(Debug)]
221struct ConnectCustomKeyStoreTelemetryInputCaptureInterceptor;
222
223#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
224impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ConnectCustomKeyStoreTelemetryInputCaptureInterceptor {
225    fn name(&self) -> &'static str {
226        "ConnectCustomKeyStoreTelemetryInputCaptureInterceptor"
227    }
228
229    fn read_before_execution(
230        &self,
231        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
232            '_,
233            ::aws_smithy_runtime_api::client::interceptors::context::Input,
234            ::aws_smithy_runtime_api::client::interceptors::context::Output,
235            ::aws_smithy_runtime_api::client::interceptors::context::Error,
236        >,
237        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
238    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
239        // Nothing to do unless the customer opted in by naming members to record.
240        let ::std::option::Option::Some(requested) = cfg
241            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
242            .filter(|r| !r.is_empty())
243        else {
244            return ::std::result::Result::Ok(());
245        };
246
247        let ::std::option::Option::Some(input) = context.input().downcast_ref::<ConnectCustomKeyStoreInput>() else {
248            // A mismatched input is not this interceptor's concern; skip quietly.
249            return ::std::result::Result::Ok(());
250        };
251
252        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
253        if requested.should_capture("CustomKeyStoreId") {
254            if let ::std::option::Option::Some(value) = input.custom_key_store_id.as_deref() {
255                captured.insert("CustomKeyStoreId", value);
256            }
257        }
258
259        cfg.interceptor_state().store_put(captured);
260        ::std::result::Result::Ok(())
261    }
262}
263#[derive(Debug)]
264struct ConnectCustomKeyStoreResponseDeserializer;
265impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ConnectCustomKeyStoreResponseDeserializer {
266    fn deserialize_nonstreaming_with_config(
267        &self,
268        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
269        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
270    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
271        let (success, status) = (response.status().is_success(), response.status().as_u16());
272        // Load body and headers BEFORE BeforeParseResponse so customizations
273        // (e.g., S3's `body_is_error` check that detects errors returned with
274        // HTTP 200) can inspect them. The legacy non-streaming path also
275        // loads `body` before firing this hook.
276        #[allow(unused_variables)]
277        let body = response.body().bytes().expect("body loaded");
278        let headers = response.headers();
279        #[allow(unused_mut)]
280        let mut force_error = false;
281        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
282        if !success && status != 200 || force_error {
283            let protocol = _cfg
284                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
285                .expect("a SharedClientProtocol is required");
286            #[allow(unused_mut)]
287            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
288                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
289            })?;
290            generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
291            let generic = generic_builder.build();
292            let error_code = match generic.code() {
293                ::std::option::Option::Some(code) => code,
294                ::std::option::Option::None => {
295                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
296                        ::aws_smithy_runtime_api::box_error::BoxError::from(
297                            crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::unhandled(generic),
298                        ),
299                    ))
300                }
301            };
302            let _error_message = generic.message().map(|msg| msg.to_owned());
303            let err = match error_code {
304                "CloudHsmClusterInvalidConfigurationException" => {
305                    crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::CloudHsmClusterInvalidConfigurationException({
306                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
307                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
308                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
309                            )
310                        })?;
311                        let mut tmp = <crate::types::error::builders::CloudHsmClusterInvalidConfigurationExceptionBuilder>::default();
312                        tmp.deserialize_members(&mut *deser).map_err(|e| {
313                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
314                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
315                            )
316                        })?;
317                        if tmp.message.is_none() {
318                            tmp.message = _error_message;
319                        }
320                        let tmp = tmp.meta(generic);
321                        tmp.build()
322                    })
323                }
324                "CloudHsmClusterNotActiveException" => {
325                    crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::CloudHsmClusterNotActiveException({
326                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
327                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
328                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
329                            )
330                        })?;
331                        let mut tmp = <crate::types::error::builders::CloudHsmClusterNotActiveExceptionBuilder>::default();
332                        tmp.deserialize_members(&mut *deser).map_err(|e| {
333                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
334                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
335                            )
336                        })?;
337                        if tmp.message.is_none() {
338                            tmp.message = _error_message;
339                        }
340                        let tmp = tmp.meta(generic);
341                        tmp.build()
342                    })
343                }
344                "CustomKeyStoreInvalidStateException" => {
345                    crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::CustomKeyStoreInvalidStateException({
346                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
347                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
348                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
349                            )
350                        })?;
351                        let mut tmp = <crate::types::error::builders::CustomKeyStoreInvalidStateExceptionBuilder>::default();
352                        tmp.deserialize_members(&mut *deser).map_err(|e| {
353                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
354                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
355                            )
356                        })?;
357                        if tmp.message.is_none() {
358                            tmp.message = _error_message;
359                        }
360                        let tmp = tmp.meta(generic);
361                        tmp.build()
362                    })
363                }
364                "CustomKeyStoreNotFoundException" => {
365                    crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::CustomKeyStoreNotFoundException({
366                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
367                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
368                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
369                            )
370                        })?;
371                        let mut tmp = <crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder>::default();
372                        tmp.deserialize_members(&mut *deser).map_err(|e| {
373                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
374                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
375                            )
376                        })?;
377                        if tmp.message.is_none() {
378                            tmp.message = _error_message;
379                        }
380                        let tmp = tmp.meta(generic);
381                        tmp.build()
382                    })
383                }
384                "KMSInternalException" => crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::KmsInternalException({
385                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
386                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
387                            e,
388                        ))
389                    })?;
390                    let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
391                    tmp.deserialize_members(&mut *deser).map_err(|e| {
392                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
393                            e,
394                        ))
395                    })?;
396                    if tmp.message.is_none() {
397                        tmp.message = _error_message;
398                    }
399                    let tmp = tmp.meta(generic);
400                    tmp.build()
401                }),
402                _ => {
403                    // Registry-backed, operation-scoped reification of an error whose
404                    // code this operation does not model directly: the operation's own
405                    // error registry is consulted first, then the lookup widens to the
406                    // service-wide error registry. On a hit, the reified error is attached
407                    // as the source of the returned unhandled error while its metadata
408                    // (code, message, request id) is preserved; on a miss the generic
409                    // error is returned unchanged.
410                    match protocol
411                        .deserialize_error_response(response, _cfg)
412                        .ok()
413                        .and_then(|mut deser| {
414                            ::aws_smithy_schema::registry::reify_error(
415                                crate::operation::connect_custom_key_store::error_registry::REGISTRY
416                                    .or(&crate::error_type_registry::REGISTRY),
417                                error_code,
418                                &mut *deser,
419                            )
420                        }) {
421                        ::std::option::Option::Some(source) => <crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
422                        ::std::option::Option::None => crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError::generic(generic),
423                    }
424                }
425            };
426            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
427                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
428            ))
429        } else {
430            let protocol = _cfg
431                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
432                .expect("a SharedClientProtocol is required");
433            let mut deser = protocol
434                .deserialize_response(response, ConnectCustomKeyStore::OUTPUT_SCHEMA, _cfg)
435                .map_err(|e| {
436                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
437                })?;
438            // `headers` is already in scope from the top of the function; alias it as
439            // `_response_headers` so MutateOutput customizations have a stable name to
440            // read from.
441            let _response_headers = headers;
442            // `mut` is required because `deserialize_members` and the `MutateOutput`
443            // builder setters take `&mut self`. Marked `allow(unused_mut)` because an
444            // empty output has no members and no customizations to run.
445            #[allow(unused_mut)]
446            let mut output = <crate::operation::connect_custom_key_store::builders::ConnectCustomKeyStoreOutputBuilder>::default();
447            output.deserialize_members(&mut *deser).map_err(|e| {
448                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
449            })?;
450            output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
451            let output = output.build();
452            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
453        }
454    }
455}
456#[derive(Debug)]
457struct ConnectCustomKeyStoreRequestSerializer;
458impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ConnectCustomKeyStoreRequestSerializer {
459    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
460    fn serialize_input(
461        &self,
462        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
463        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
464    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
465        let input = input
466            .downcast::<crate::operation::connect_custom_key_store::ConnectCustomKeyStoreInput>()
467            .expect("correct type");
468
469        let protocol = _cfg
470            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
471            .expect("a SharedClientProtocol is required");
472        let mut request = protocol
473            .serialize_request(&input, ConnectCustomKeyStore::INPUT_SCHEMA, "/", _cfg)
474            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
475
476        return ::std::result::Result::Ok(request);
477    }
478}
479#[derive(Debug)]
480struct ConnectCustomKeyStoreEndpointParamsInterceptor;
481
482#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
483impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ConnectCustomKeyStoreEndpointParamsInterceptor {
484    fn name(&self) -> &'static str {
485        "ConnectCustomKeyStoreEndpointParamsInterceptor"
486    }
487
488    fn read_before_execution(
489        &self,
490        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
491            '_,
492            ::aws_smithy_runtime_api::client::interceptors::context::Input,
493            ::aws_smithy_runtime_api::client::interceptors::context::Output,
494            ::aws_smithy_runtime_api::client::interceptors::context::Error,
495        >,
496        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
497    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
498        let _input = context
499            .input()
500            .downcast_ref::<ConnectCustomKeyStoreInput>()
501            .ok_or("failed to downcast to ConnectCustomKeyStoreInput")?;
502
503        let params = crate::config::endpoint::Params::builder()
504            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
505            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
506            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
507            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
508            .build()
509            .map_err(|err| {
510                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
511            })?;
512        cfg.interceptor_state()
513            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
514        ::std::result::Result::Ok(())
515    }
516}
517
518// The get_* functions below are generated from JMESPath expressions in the
519// operationContextParams trait. They target the operation's input shape.
520
521/// Error type for the `ConnectCustomKeyStoreError` operation.
522#[non_exhaustive]
523#[derive(::std::fmt::Debug)]
524pub enum ConnectCustomKeyStoreError {
525    /// <p>The request was rejected because the associated CloudHSM cluster did not meet the configuration requirements for an CloudHSM key store.</p>
526    /// <ul>
527    /// <li>
528    /// <p>The CloudHSM cluster must be configured with private subnets in at least two different Availability Zones in the Region.</p></li>
529    /// <li>
530    /// <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>
531    /// <li>
532    /// <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>
533    /// <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>
534    /// </ul>
535    /// <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>
536    CloudHsmClusterInvalidConfigurationException(crate::types::error::CloudHsmClusterInvalidConfigurationException),
537    /// <p>The request was rejected because the CloudHSM cluster associated with the CloudHSM key store is not active. Initialize and activate the cluster and try the command again. For detailed instructions, see <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/getting-started.html">Getting Started</a> in the <i>CloudHSM User Guide</i>.</p>
538    CloudHsmClusterNotActiveException(crate::types::error::CloudHsmClusterNotActiveException),
539    /// <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>
540    /// <p>This exception is thrown under the following conditions:</p>
541    /// <ul>
542    /// <li>
543    /// <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>
544    /// <li>
545    /// <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>
546    /// <li>
547    /// <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>
548    /// <li>
549    /// <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>
550    /// <li>
551    /// <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>
552    /// </ul>
553    CustomKeyStoreInvalidStateException(crate::types::error::CustomKeyStoreInvalidStateException),
554    /// <p>The request was rejected because KMS cannot find a custom key store with the specified key store name or ID.</p>
555    CustomKeyStoreNotFoundException(crate::types::error::CustomKeyStoreNotFoundException),
556    /// <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
557    KmsInternalException(crate::types::error::KmsInternalException),
558    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
559    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
560    variable wildcard pattern and check `.code()`:
561     \
562    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
563     \
564    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ConnectCustomKeyStoreError) for what information is available for the error.")]
565    Unhandled(crate::error::sealed_unhandled::Unhandled),
566}
567impl ConnectCustomKeyStoreError {
568    /// Creates the `ConnectCustomKeyStoreError::Unhandled` variant from any error type.
569    pub fn unhandled(
570        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
571    ) -> Self {
572        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
573            source: err.into(),
574            meta: ::std::default::Default::default(),
575        })
576    }
577
578    /// Creates the `ConnectCustomKeyStoreError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
579    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
580        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
581            source: err.clone().into(),
582            meta: err,
583        })
584    }
585    ///
586    /// Returns error metadata, which includes the error code, message,
587    /// request ID, and potentially additional information.
588    ///
589    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
590        match self {
591            Self::CloudHsmClusterInvalidConfigurationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
592            Self::CloudHsmClusterNotActiveException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
593            Self::CustomKeyStoreInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
594            Self::CustomKeyStoreNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
595            Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
596            Self::Unhandled(e) => &e.meta,
597        }
598    }
599    /// Returns `true` if the error kind is `ConnectCustomKeyStoreError::CloudHsmClusterInvalidConfigurationException`.
600    pub fn is_cloud_hsm_cluster_invalid_configuration_exception(&self) -> bool {
601        matches!(self, Self::CloudHsmClusterInvalidConfigurationException(_))
602    }
603    /// Returns `true` if the error kind is `ConnectCustomKeyStoreError::CloudHsmClusterNotActiveException`.
604    pub fn is_cloud_hsm_cluster_not_active_exception(&self) -> bool {
605        matches!(self, Self::CloudHsmClusterNotActiveException(_))
606    }
607    /// Returns `true` if the error kind is `ConnectCustomKeyStoreError::CustomKeyStoreInvalidStateException`.
608    pub fn is_custom_key_store_invalid_state_exception(&self) -> bool {
609        matches!(self, Self::CustomKeyStoreInvalidStateException(_))
610    }
611    /// Returns `true` if the error kind is `ConnectCustomKeyStoreError::CustomKeyStoreNotFoundException`.
612    pub fn is_custom_key_store_not_found_exception(&self) -> bool {
613        matches!(self, Self::CustomKeyStoreNotFoundException(_))
614    }
615    /// Returns `true` if the error kind is `ConnectCustomKeyStoreError::KmsInternalException`.
616    pub fn is_kms_internal_exception(&self) -> bool {
617        matches!(self, Self::KmsInternalException(_))
618    }
619}
620impl ::std::error::Error for ConnectCustomKeyStoreError {
621    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
622        match self {
623            Self::CloudHsmClusterInvalidConfigurationException(_inner) => ::std::option::Option::Some(_inner),
624            Self::CloudHsmClusterNotActiveException(_inner) => ::std::option::Option::Some(_inner),
625            Self::CustomKeyStoreInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
626            Self::CustomKeyStoreNotFoundException(_inner) => ::std::option::Option::Some(_inner),
627            Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
628            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
629        }
630    }
631}
632impl ::std::fmt::Display for ConnectCustomKeyStoreError {
633    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
634        match self {
635            Self::CloudHsmClusterInvalidConfigurationException(_inner) => _inner.fmt(f),
636            Self::CloudHsmClusterNotActiveException(_inner) => _inner.fmt(f),
637            Self::CustomKeyStoreInvalidStateException(_inner) => _inner.fmt(f),
638            Self::CustomKeyStoreNotFoundException(_inner) => _inner.fmt(f),
639            Self::KmsInternalException(_inner) => _inner.fmt(f),
640            Self::Unhandled(_inner) => {
641                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
642                    write!(f, "unhandled error ({code})")
643                } else {
644                    f.write_str("unhandled error")
645                }
646            }
647        }
648    }
649}
650impl ::aws_smithy_types::retry::ProvideErrorKind for ConnectCustomKeyStoreError {
651    fn code(&self) -> ::std::option::Option<&str> {
652        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
653    }
654    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
655        ::std::option::Option::None
656    }
657}
658impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ConnectCustomKeyStoreError {
659    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
660        match self {
661            Self::CloudHsmClusterInvalidConfigurationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
662            Self::CloudHsmClusterNotActiveException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
663            Self::CustomKeyStoreInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
664            Self::CustomKeyStoreNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
665            Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
666            Self::Unhandled(_inner) => &_inner.meta,
667        }
668    }
669}
670impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ConnectCustomKeyStoreError {
671    fn create_unhandled_error(
672        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
673        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
674    ) -> Self {
675        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
676            source,
677            meta: meta.unwrap_or_default(),
678        })
679    }
680}
681impl ::aws_types::request_id::RequestId for crate::operation::connect_custom_key_store::ConnectCustomKeyStoreError {
682    fn request_id(&self) -> Option<&str> {
683        self.meta().request_id()
684    }
685}
686
687pub use crate::operation::connect_custom_key_store::_connect_custom_key_store_input::ConnectCustomKeyStoreInput;
688
689pub use crate::operation::connect_custom_key_store::_connect_custom_key_store_output::ConnectCustomKeyStoreOutput;
690
691mod _connect_custom_key_store_input;
692
693mod _connect_custom_key_store_output;
694
695/// Builders
696pub mod builders;