Skip to main content

aws_sdk_kms/operation/
generate_random.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GenerateRandom`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GenerateRandom;
6impl GenerateRandom {
7    /// Creates a new `GenerateRandom`
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::generate_random::GenerateRandomInput::SCHEMA;
13    /// The schema for this operation's output shape.
14    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::generate_random::GenerateRandomOutput::SCHEMA;
15    pub(crate) async fn orchestrate(
16        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17        input: crate::operation::generate_random::GenerateRandomInput,
18    ) -> ::std::result::Result<
19        crate::operation::generate_random::GenerateRandomOutput,
20        ::aws_smithy_runtime_api::client::result::SdkError<
21            crate::operation::generate_random::GenerateRandomError,
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::generate_random::GenerateRandomError>()
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::generate_random::GenerateRandomOutput>()
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::generate_random::GenerateRandomInput,
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", "GenerateRandom", 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.GenerateRandom",
63                "rpc.service" = "KMS",
64                "rpc.method" = "GenerateRandom",
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::CustomKeyStoreInvalidStateException::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::CustomKeyStoreInvalidStateException::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::CustomKeyStoreInvalidStateException::deserialize(d)?))
109                        },
110                    )
111.insert_error_shape(
112                        crate::types::error::CustomKeyStoreNotFoundException::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::CustomKeyStoreNotFoundException::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::CustomKeyStoreNotFoundException::deserialize(d)?))
118                        },
119                    )
120.insert_error_shape(
121                        crate::types::error::DependencyTimeoutException::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::DependencyTimeoutException::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::DependencyTimeoutException::deserialize(d)?))
127                        },
128                    )
129.insert_error_shape(
130                        crate::types::error::KmsInternalException::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::KmsInternalException::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::KmsInternalException::deserialize(d)?))
136                        },
137                    )
138.insert_error_shape(
139                        crate::types::error::UnsupportedOperationException::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::UnsupportedOperationException::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::UnsupportedOperationException::deserialize(d)?))
145                        },
146                    )
147                            .build()
148    });
149}
150impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GenerateRandom {
151    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
152        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GenerateRandom");
153
154        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
155            GenerateRandomRequestSerializer,
156        ));
157        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
158            GenerateRandomResponseDeserializer,
159        ));
160
161        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
162            crate::config::auth::Params::builder()
163                .operation_name("GenerateRandom")
164                .build()
165                .expect("required fields set"),
166        ));
167
168        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
169        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GenerateRandom", "KMS"));
170        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
171        signing_options.double_uri_encode = true;
172        signing_options.content_sha256_header = false;
173        signing_options.normalize_uri_path = true;
174        signing_options.payload_override = None;
175
176        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
177            signing_options,
178            ..::std::default::Default::default()
179        });
180
181        ::std::option::Option::Some(cfg.freeze())
182    }
183
184    fn runtime_components(
185        &self,
186        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
187    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
188        #[allow(unused_mut)]
189        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GenerateRandom")
190            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
191                GenerateRandomTelemetryInputCaptureInterceptor,
192            ))
193            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
194                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
195            ))
196            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
197                GenerateRandomEndpointParamsInterceptor,
198            ))
199            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
200                crate::operation::generate_random::GenerateRandomError,
201            >::new())
202            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
203                crate::operation::generate_random::GenerateRandomError,
204            >::new())
205            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
206                crate::operation::generate_random::GenerateRandomError,
207            >::new())
208            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
209                crate::operation::generate_random::GenerateRandomError,
210            >::new());
211
212        ::std::borrow::Cow::Owned(rcb)
213    }
214}
215
216#[derive(Debug)]
217struct GenerateRandomTelemetryInputCaptureInterceptor;
218
219#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
220impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GenerateRandomTelemetryInputCaptureInterceptor {
221    fn name(&self) -> &'static str {
222        "GenerateRandomTelemetryInputCaptureInterceptor"
223    }
224
225    fn read_before_execution(
226        &self,
227        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
228            '_,
229            ::aws_smithy_runtime_api::client::interceptors::context::Input,
230            ::aws_smithy_runtime_api::client::interceptors::context::Output,
231            ::aws_smithy_runtime_api::client::interceptors::context::Error,
232        >,
233        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
234    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
235        // Nothing to do unless the customer opted in by naming members to record.
236        let ::std::option::Option::Some(requested) = cfg
237            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
238            .filter(|r| !r.is_empty())
239        else {
240            return ::std::result::Result::Ok(());
241        };
242
243        let ::std::option::Option::Some(input) = context.input().downcast_ref::<GenerateRandomInput>() else {
244            // A mismatched input is not this interceptor's concern; skip quietly.
245            return ::std::result::Result::Ok(());
246        };
247
248        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
249        if requested.should_capture("CustomKeyStoreId") {
250            if let ::std::option::Option::Some(value) = input.custom_key_store_id.as_deref() {
251                captured.insert("CustomKeyStoreId", value);
252            }
253        }
254
255        cfg.interceptor_state().store_put(captured);
256        ::std::result::Result::Ok(())
257    }
258}
259#[derive(Debug)]
260struct GenerateRandomResponseDeserializer;
261impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GenerateRandomResponseDeserializer {
262    fn deserialize_nonstreaming_with_config(
263        &self,
264        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
265        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
266    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
267        let (success, status) = (response.status().is_success(), response.status().as_u16());
268        // Load body and headers BEFORE BeforeParseResponse so customizations
269        // (e.g., S3's `body_is_error` check that detects errors returned with
270        // HTTP 200) can inspect them. The legacy non-streaming path also
271        // loads `body` before firing this hook.
272        #[allow(unused_variables)]
273        let body = response.body().bytes().expect("body loaded");
274        let headers = response.headers();
275        #[allow(unused_mut)]
276        let mut force_error = false;
277        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
278        if !success && status != 200 || force_error {
279            let protocol = _cfg
280                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
281                .expect("a SharedClientProtocol is required");
282            #[allow(unused_mut)]
283            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
284                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
285            })?;
286            generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
287            let generic = generic_builder.build();
288            let error_code = match generic.code() {
289                ::std::option::Option::Some(code) => code,
290                ::std::option::Option::None => {
291                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
292                        ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::generate_random::GenerateRandomError::unhandled(
293                            generic,
294                        )),
295                    ))
296                }
297            };
298            let _error_message = generic.message().map(|msg| msg.to_owned());
299            let err = match error_code {
300                "CustomKeyStoreInvalidStateException" => {
301                    crate::operation::generate_random::GenerateRandomError::CustomKeyStoreInvalidStateException({
302                        let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
303                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
304                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
305                            )
306                        })?;
307                        let mut tmp = <crate::types::error::builders::CustomKeyStoreInvalidStateExceptionBuilder>::default();
308                        tmp.deserialize_members(&mut *deser).map_err(|e| {
309                            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
310                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
311                            )
312                        })?;
313                        if tmp.message.is_none() {
314                            tmp.message = _error_message;
315                        }
316                        let tmp = tmp.meta(generic);
317                        tmp.build()
318                    })
319                }
320                "CustomKeyStoreNotFoundException" => crate::operation::generate_random::GenerateRandomError::CustomKeyStoreNotFoundException({
321                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
322                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
323                            e,
324                        ))
325                    })?;
326                    let mut tmp = <crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder>::default();
327                    tmp.deserialize_members(&mut *deser).map_err(|e| {
328                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
329                            e,
330                        ))
331                    })?;
332                    if tmp.message.is_none() {
333                        tmp.message = _error_message;
334                    }
335                    let tmp = tmp.meta(generic);
336                    tmp.build()
337                }),
338                "DependencyTimeoutException" => crate::operation::generate_random::GenerateRandomError::DependencyTimeoutException({
339                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
340                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
341                            e,
342                        ))
343                    })?;
344                    let mut tmp = <crate::types::error::builders::DependencyTimeoutExceptionBuilder>::default();
345                    tmp.deserialize_members(&mut *deser).map_err(|e| {
346                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
347                            e,
348                        ))
349                    })?;
350                    if tmp.message.is_none() {
351                        tmp.message = _error_message;
352                    }
353                    let tmp = tmp.meta(generic);
354                    tmp.build()
355                }),
356                "KMSInternalException" => crate::operation::generate_random::GenerateRandomError::KmsInternalException({
357                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
358                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
359                            e,
360                        ))
361                    })?;
362                    let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
363                    tmp.deserialize_members(&mut *deser).map_err(|e| {
364                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
365                            e,
366                        ))
367                    })?;
368                    if tmp.message.is_none() {
369                        tmp.message = _error_message;
370                    }
371                    let tmp = tmp.meta(generic);
372                    tmp.build()
373                }),
374                "UnsupportedOperationException" => crate::operation::generate_random::GenerateRandomError::UnsupportedOperationException({
375                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
376                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
377                            e,
378                        ))
379                    })?;
380                    let mut tmp = <crate::types::error::builders::UnsupportedOperationExceptionBuilder>::default();
381                    tmp.deserialize_members(&mut *deser).map_err(|e| {
382                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
383                            e,
384                        ))
385                    })?;
386                    if tmp.message.is_none() {
387                        tmp.message = _error_message;
388                    }
389                    let tmp = tmp.meta(generic);
390                    tmp.build()
391                }),
392                _ => {
393                    // Registry-backed, operation-scoped reification of an error whose
394                    // code this operation does not model directly: the operation's own
395                    // error registry is consulted first, then the lookup widens to the
396                    // service-wide error registry. On a hit, the reified error is attached
397                    // as the source of the returned unhandled error while its metadata
398                    // (code, message, request id) is preserved; on a miss the generic
399                    // error is returned unchanged.
400                    match protocol
401                        .deserialize_error_response(response, _cfg)
402                        .ok()
403                        .and_then(|mut deser| {
404                            ::aws_smithy_schema::registry::reify_error(
405                                crate::operation::generate_random::error_registry::REGISTRY
406                                    .or(&crate::error_type_registry::REGISTRY),
407                                error_code,
408                                &mut *deser,
409                            )
410                        }) {
411                        ::std::option::Option::Some(source) => <crate::operation::generate_random::GenerateRandomError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
412                        ::std::option::Option::None => crate::operation::generate_random::GenerateRandomError::generic(generic),
413                    }
414                }
415            };
416            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
417                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
418            ))
419        } else {
420            let protocol = _cfg
421                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
422                .expect("a SharedClientProtocol is required");
423            let mut deser = protocol
424                .deserialize_response(response, GenerateRandom::OUTPUT_SCHEMA, _cfg)
425                .map_err(|e| {
426                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
427                })?;
428            // `headers` is already in scope from the top of the function; alias it as
429            // `_response_headers` so MutateOutput customizations have a stable name to
430            // read from.
431            let _response_headers = headers;
432            // `mut` is required because `deserialize_members` and the `MutateOutput`
433            // builder setters take `&mut self`. Marked `allow(unused_mut)` because an
434            // empty output has no members and no customizations to run.
435            #[allow(unused_mut)]
436            let mut output = <crate::operation::generate_random::builders::GenerateRandomOutputBuilder>::default();
437            output.deserialize_members(&mut *deser).map_err(|e| {
438                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
439            })?;
440            output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
441            let output = output.build();
442            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
443        }
444    }
445}
446#[derive(Debug)]
447struct GenerateRandomRequestSerializer;
448impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GenerateRandomRequestSerializer {
449    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
450    fn serialize_input(
451        &self,
452        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
453        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
454    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
455        let input = input
456            .downcast::<crate::operation::generate_random::GenerateRandomInput>()
457            .expect("correct type");
458
459        let protocol = _cfg
460            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
461            .expect("a SharedClientProtocol is required");
462        let mut request = protocol
463            .serialize_request(&input, GenerateRandom::INPUT_SCHEMA, "/", _cfg)
464            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
465
466        return ::std::result::Result::Ok(request);
467    }
468}
469#[derive(Debug)]
470struct GenerateRandomEndpointParamsInterceptor;
471
472#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
473impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GenerateRandomEndpointParamsInterceptor {
474    fn name(&self) -> &'static str {
475        "GenerateRandomEndpointParamsInterceptor"
476    }
477
478    fn read_before_execution(
479        &self,
480        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
481            '_,
482            ::aws_smithy_runtime_api::client::interceptors::context::Input,
483            ::aws_smithy_runtime_api::client::interceptors::context::Output,
484            ::aws_smithy_runtime_api::client::interceptors::context::Error,
485        >,
486        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
487    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
488        let _input = context
489            .input()
490            .downcast_ref::<GenerateRandomInput>()
491            .ok_or("failed to downcast to GenerateRandomInput")?;
492
493        let params = crate::config::endpoint::Params::builder()
494            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
495            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
496            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
497            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
498            .build()
499            .map_err(|err| {
500                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
501            })?;
502        cfg.interceptor_state()
503            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
504        ::std::result::Result::Ok(())
505    }
506}
507
508// The get_* functions below are generated from JMESPath expressions in the
509// operationContextParams trait. They target the operation's input shape.
510
511/// Error type for the `GenerateRandomError` operation.
512#[non_exhaustive]
513#[derive(::std::fmt::Debug)]
514pub enum GenerateRandomError {
515    /// <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>
516    /// <p>This exception is thrown under the following conditions:</p>
517    /// <ul>
518    /// <li>
519    /// <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>
520    /// <li>
521    /// <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>
522    /// <li>
523    /// <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>
524    /// <li>
525    /// <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>
526    /// <li>
527    /// <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>
528    /// </ul>
529    CustomKeyStoreInvalidStateException(crate::types::error::CustomKeyStoreInvalidStateException),
530    /// <p>The request was rejected because KMS cannot find a custom key store with the specified key store name or ID.</p>
531    CustomKeyStoreNotFoundException(crate::types::error::CustomKeyStoreNotFoundException),
532    /// <p>The system timed out while trying to fulfill the request. You can retry the request.</p>
533    DependencyTimeoutException(crate::types::error::DependencyTimeoutException),
534    /// <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
535    KmsInternalException(crate::types::error::KmsInternalException),
536    /// <p>The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.</p>
537    UnsupportedOperationException(crate::types::error::UnsupportedOperationException),
538    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
539    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
540    variable wildcard pattern and check `.code()`:
541     \
542    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
543     \
544    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GenerateRandomError) for what information is available for the error.")]
545    Unhandled(crate::error::sealed_unhandled::Unhandled),
546}
547impl GenerateRandomError {
548    /// Creates the `GenerateRandomError::Unhandled` variant from any error type.
549    pub fn unhandled(
550        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
551    ) -> Self {
552        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
553            source: err.into(),
554            meta: ::std::default::Default::default(),
555        })
556    }
557
558    /// Creates the `GenerateRandomError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
559    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
560        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
561            source: err.clone().into(),
562            meta: err,
563        })
564    }
565    ///
566    /// Returns error metadata, which includes the error code, message,
567    /// request ID, and potentially additional information.
568    ///
569    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
570        match self {
571            Self::CustomKeyStoreInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
572            Self::CustomKeyStoreNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
573            Self::DependencyTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
574            Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
575            Self::UnsupportedOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
576            Self::Unhandled(e) => &e.meta,
577        }
578    }
579    /// Returns `true` if the error kind is `GenerateRandomError::CustomKeyStoreInvalidStateException`.
580    pub fn is_custom_key_store_invalid_state_exception(&self) -> bool {
581        matches!(self, Self::CustomKeyStoreInvalidStateException(_))
582    }
583    /// Returns `true` if the error kind is `GenerateRandomError::CustomKeyStoreNotFoundException`.
584    pub fn is_custom_key_store_not_found_exception(&self) -> bool {
585        matches!(self, Self::CustomKeyStoreNotFoundException(_))
586    }
587    /// Returns `true` if the error kind is `GenerateRandomError::DependencyTimeoutException`.
588    pub fn is_dependency_timeout_exception(&self) -> bool {
589        matches!(self, Self::DependencyTimeoutException(_))
590    }
591    /// Returns `true` if the error kind is `GenerateRandomError::KmsInternalException`.
592    pub fn is_kms_internal_exception(&self) -> bool {
593        matches!(self, Self::KmsInternalException(_))
594    }
595    /// Returns `true` if the error kind is `GenerateRandomError::UnsupportedOperationException`.
596    pub fn is_unsupported_operation_exception(&self) -> bool {
597        matches!(self, Self::UnsupportedOperationException(_))
598    }
599}
600impl ::std::error::Error for GenerateRandomError {
601    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
602        match self {
603            Self::CustomKeyStoreInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
604            Self::CustomKeyStoreNotFoundException(_inner) => ::std::option::Option::Some(_inner),
605            Self::DependencyTimeoutException(_inner) => ::std::option::Option::Some(_inner),
606            Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
607            Self::UnsupportedOperationException(_inner) => ::std::option::Option::Some(_inner),
608            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
609        }
610    }
611}
612impl ::std::fmt::Display for GenerateRandomError {
613    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
614        match self {
615            Self::CustomKeyStoreInvalidStateException(_inner) => _inner.fmt(f),
616            Self::CustomKeyStoreNotFoundException(_inner) => _inner.fmt(f),
617            Self::DependencyTimeoutException(_inner) => _inner.fmt(f),
618            Self::KmsInternalException(_inner) => _inner.fmt(f),
619            Self::UnsupportedOperationException(_inner) => _inner.fmt(f),
620            Self::Unhandled(_inner) => {
621                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
622                    write!(f, "unhandled error ({code})")
623                } else {
624                    f.write_str("unhandled error")
625                }
626            }
627        }
628    }
629}
630impl ::aws_smithy_types::retry::ProvideErrorKind for GenerateRandomError {
631    fn code(&self) -> ::std::option::Option<&str> {
632        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
633    }
634    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
635        ::std::option::Option::None
636    }
637}
638impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GenerateRandomError {
639    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
640        match self {
641            Self::CustomKeyStoreInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
642            Self::CustomKeyStoreNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
643            Self::DependencyTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
644            Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
645            Self::UnsupportedOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
646            Self::Unhandled(_inner) => &_inner.meta,
647        }
648    }
649}
650impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GenerateRandomError {
651    fn create_unhandled_error(
652        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
653        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
654    ) -> Self {
655        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
656            source,
657            meta: meta.unwrap_or_default(),
658        })
659    }
660}
661impl ::aws_types::request_id::RequestId for crate::operation::generate_random::GenerateRandomError {
662    fn request_id(&self) -> Option<&str> {
663        self.meta().request_id()
664    }
665}
666
667pub use crate::operation::generate_random::_generate_random_input::GenerateRandomInput;
668
669pub use crate::operation::generate_random::_generate_random_output::GenerateRandomOutput;
670
671mod _generate_random_input;
672
673mod _generate_random_output;
674
675/// Builders
676pub mod builders;