Skip to main content

aws_sdk_kms/operation/
generate_mac.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GenerateMac`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GenerateMac;
6impl GenerateMac {
7    /// Creates a new `GenerateMac`
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_mac::GenerateMacInput::SCHEMA;
13    /// The schema for this operation's output shape.
14    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::generate_mac::GenerateMacOutput::SCHEMA;
15    pub(crate) async fn orchestrate(
16        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17        input: crate::operation::generate_mac::GenerateMacInput,
18    ) -> ::std::result::Result<
19        crate::operation::generate_mac::GenerateMacOutput,
20        ::aws_smithy_runtime_api::client::result::SdkError<
21            crate::operation::generate_mac::GenerateMacError,
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_mac::GenerateMacError>()
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_mac::GenerateMacOutput>()
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_mac::GenerateMacInput,
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", "GenerateMac", 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.GenerateMac",
63                "rpc.service" = "KMS",
64                "rpc.method" = "GenerateMac",
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::DisabledException::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::DisabledException::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::DisabledException::deserialize(d)?))
109                        },
110                    )
111.insert_error_shape(
112                        crate::types::error::DryRunOperationException::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::DryRunOperationException::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::DryRunOperationException::deserialize(d)?))
118                        },
119                    )
120.insert_error_shape(
121                        crate::types::error::InvalidGrantTokenException::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::InvalidGrantTokenException::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::InvalidGrantTokenException::deserialize(d)?))
127                        },
128                    )
129.insert_error_shape(
130                        crate::types::error::InvalidKeyUsageException::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::InvalidKeyUsageException::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::InvalidKeyUsageException::deserialize(d)?))
136                        },
137                    )
138.insert_error_shape(
139                        crate::types::error::KmsInternalException::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::KmsInternalException::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::KmsInternalException::deserialize(d)?))
145                        },
146                    )
147.insert_error_shape(
148                        crate::types::error::KmsInvalidStateException::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::KmsInvalidStateException::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::KmsInvalidStateException::deserialize(d)?))
154                        },
155                    )
156.insert_error_shape(
157                        crate::types::error::KeyUnavailableException::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::KeyUnavailableException::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::KeyUnavailableException::deserialize(d)?))
163                        },
164                    )
165.insert_error_shape(
166                        crate::types::error::NotFoundException::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::NotFoundException::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::NotFoundException::deserialize(d)?))
172                        },
173                    )
174                            .build()
175    });
176}
177impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GenerateMac {
178    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
179        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GenerateMac");
180
181        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
182            GenerateMacRequestSerializer,
183        ));
184        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
185            GenerateMacResponseDeserializer,
186        ));
187
188        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
189            crate::config::auth::Params::builder()
190                .operation_name("GenerateMac")
191                .build()
192                .expect("required fields set"),
193        ));
194
195        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GenerateMac", "KMS"));
196        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
197        signing_options.double_uri_encode = true;
198        signing_options.content_sha256_header = false;
199        signing_options.normalize_uri_path = true;
200        signing_options.payload_override = None;
201
202        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
203            signing_options,
204            ..::std::default::Default::default()
205        });
206
207        ::std::option::Option::Some(cfg.freeze())
208    }
209
210    fn runtime_components(
211        &self,
212        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
213    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
214        #[allow(unused_mut)]
215        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GenerateMac")
216            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
217                GenerateMacTelemetryInputCaptureInterceptor,
218            ))
219            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
220                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
221            ))
222            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
223                GenerateMacEndpointParamsInterceptor,
224            ))
225            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
226                crate::operation::generate_mac::GenerateMacError,
227            >::new())
228            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
229                crate::operation::generate_mac::GenerateMacError,
230            >::new())
231            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
232                crate::operation::generate_mac::GenerateMacError,
233            >::new())
234            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
235                crate::operation::generate_mac::GenerateMacError,
236            >::new());
237
238        ::std::borrow::Cow::Owned(rcb)
239    }
240}
241
242#[derive(Debug)]
243struct GenerateMacTelemetryInputCaptureInterceptor;
244
245#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
246impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GenerateMacTelemetryInputCaptureInterceptor {
247    fn name(&self) -> &'static str {
248        "GenerateMacTelemetryInputCaptureInterceptor"
249    }
250
251    fn read_before_execution(
252        &self,
253        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
254            '_,
255            ::aws_smithy_runtime_api::client::interceptors::context::Input,
256            ::aws_smithy_runtime_api::client::interceptors::context::Output,
257            ::aws_smithy_runtime_api::client::interceptors::context::Error,
258        >,
259        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
260    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
261        // Nothing to do unless the customer opted in by naming members to record.
262        let ::std::option::Option::Some(requested) = cfg
263            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
264            .filter(|r| !r.is_empty())
265        else {
266            return ::std::result::Result::Ok(());
267        };
268
269        let ::std::option::Option::Some(input) = context.input().downcast_ref::<GenerateMacInput>() else {
270            // A mismatched input is not this interceptor's concern; skip quietly.
271            return ::std::result::Result::Ok(());
272        };
273
274        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
275        if requested.should_capture("KeyId") {
276            if let ::std::option::Option::Some(value) = input.key_id.as_deref() {
277                captured.insert("KeyId", value);
278            }
279        }
280
281        cfg.interceptor_state().store_put(captured);
282        ::std::result::Result::Ok(())
283    }
284}
285#[derive(Debug)]
286struct GenerateMacResponseDeserializer;
287impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GenerateMacResponseDeserializer {
288    fn deserialize_nonstreaming_with_config(
289        &self,
290        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
291        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
292    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
293        let (success, status) = (response.status().is_success(), response.status().as_u16());
294        // Load body and headers BEFORE BeforeParseResponse so customizations
295        // (e.g., S3's `body_is_error` check that detects errors returned with
296        // HTTP 200) can inspect them. The legacy non-streaming path also
297        // loads `body` before firing this hook.
298        #[allow(unused_variables)]
299        let body = response.body().bytes().expect("body loaded");
300        let headers = response.headers();
301        #[allow(unused_mut)]
302        let mut force_error = false;
303        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
304        if !success && status != 200 || force_error {
305            let protocol = _cfg
306                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
307                .expect("a SharedClientProtocol is required");
308            #[allow(unused_mut)]
309            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
310                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
311            })?;
312            generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
313            let generic = generic_builder.build();
314            let error_code = match generic.code() {
315                ::std::option::Option::Some(code) => code,
316                ::std::option::Option::None => {
317                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
318                        ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::generate_mac::GenerateMacError::unhandled(generic)),
319                    ))
320                }
321            };
322            let _error_message = generic.message().map(|msg| msg.to_owned());
323            let err = match error_code {
324                "DisabledException" => crate::operation::generate_mac::GenerateMacError::DisabledException({
325                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
326                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
327                            e,
328                        ))
329                    })?;
330                    let mut tmp = <crate::types::error::builders::DisabledExceptionBuilder>::default();
331                    tmp.deserialize_members(&mut *deser).map_err(|e| {
332                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
333                            e,
334                        ))
335                    })?;
336                    if tmp.message.is_none() {
337                        tmp.message = _error_message;
338                    }
339                    let tmp = tmp.meta(generic);
340                    tmp.build()
341                }),
342                "DryRunOperationException" => crate::operation::generate_mac::GenerateMacError::DryRunOperationException({
343                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
344                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
345                            e,
346                        ))
347                    })?;
348                    let mut tmp = <crate::types::error::builders::DryRunOperationExceptionBuilder>::default();
349                    tmp.deserialize_members(&mut *deser).map_err(|e| {
350                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
351                            e,
352                        ))
353                    })?;
354                    if tmp.message.is_none() {
355                        tmp.message = _error_message;
356                    }
357                    let tmp = tmp.meta(generic);
358                    tmp.build()
359                }),
360                "InvalidGrantTokenException" => crate::operation::generate_mac::GenerateMacError::InvalidGrantTokenException({
361                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
362                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
363                            e,
364                        ))
365                    })?;
366                    let mut tmp = <crate::types::error::builders::InvalidGrantTokenExceptionBuilder>::default();
367                    tmp.deserialize_members(&mut *deser).map_err(|e| {
368                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
369                            e,
370                        ))
371                    })?;
372                    if tmp.message.is_none() {
373                        tmp.message = _error_message;
374                    }
375                    let tmp = tmp.meta(generic);
376                    tmp.build()
377                }),
378                "InvalidKeyUsageException" => crate::operation::generate_mac::GenerateMacError::InvalidKeyUsageException({
379                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
380                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
381                            e,
382                        ))
383                    })?;
384                    let mut tmp = <crate::types::error::builders::InvalidKeyUsageExceptionBuilder>::default();
385                    tmp.deserialize_members(&mut *deser).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                    if tmp.message.is_none() {
391                        tmp.message = _error_message;
392                    }
393                    let tmp = tmp.meta(generic);
394                    tmp.build()
395                }),
396                "KeyUnavailableException" => crate::operation::generate_mac::GenerateMacError::KeyUnavailableException({
397                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
398                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
399                            e,
400                        ))
401                    })?;
402                    let mut tmp = <crate::types::error::builders::KeyUnavailableExceptionBuilder>::default();
403                    tmp.deserialize_members(&mut *deser).map_err(|e| {
404                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
405                            e,
406                        ))
407                    })?;
408                    if tmp.message.is_none() {
409                        tmp.message = _error_message;
410                    }
411                    let tmp = tmp.meta(generic);
412                    tmp.build()
413                }),
414                "KMSInternalException" => crate::operation::generate_mac::GenerateMacError::KmsInternalException({
415                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
416                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
417                            e,
418                        ))
419                    })?;
420                    let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
421                    tmp.deserialize_members(&mut *deser).map_err(|e| {
422                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
423                            e,
424                        ))
425                    })?;
426                    if tmp.message.is_none() {
427                        tmp.message = _error_message;
428                    }
429                    let tmp = tmp.meta(generic);
430                    tmp.build()
431                }),
432                "KMSInvalidStateException" => crate::operation::generate_mac::GenerateMacError::KmsInvalidStateException({
433                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
434                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
435                            e,
436                        ))
437                    })?;
438                    let mut tmp = <crate::types::error::builders::KmsInvalidStateExceptionBuilder>::default();
439                    tmp.deserialize_members(&mut *deser).map_err(|e| {
440                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
441                            e,
442                        ))
443                    })?;
444                    if tmp.message.is_none() {
445                        tmp.message = _error_message;
446                    }
447                    let tmp = tmp.meta(generic);
448                    tmp.build()
449                }),
450                "NotFoundException" => crate::operation::generate_mac::GenerateMacError::NotFoundException({
451                    let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
452                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
453                            e,
454                        ))
455                    })?;
456                    let mut tmp = <crate::types::error::builders::NotFoundExceptionBuilder>::default();
457                    tmp.deserialize_members(&mut *deser).map_err(|e| {
458                        ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
459                            e,
460                        ))
461                    })?;
462                    if tmp.message.is_none() {
463                        tmp.message = _error_message;
464                    }
465                    let tmp = tmp.meta(generic);
466                    tmp.build()
467                }),
468                _ => {
469                    // Registry-backed, operation-scoped reification of an error whose
470                    // code this operation does not model directly: the operation's own
471                    // error registry is consulted first, then the lookup widens to the
472                    // service-wide error registry. On a hit, the reified error is attached
473                    // as the source of the returned unhandled error while its metadata
474                    // (code, message, request id) is preserved; on a miss the generic
475                    // error is returned unchanged.
476                    match protocol
477                        .deserialize_error_response(response, _cfg)
478                        .ok()
479                        .and_then(|mut deser| {
480                            ::aws_smithy_schema::registry::reify_error(
481                                crate::operation::generate_mac::error_registry::REGISTRY
482                                    .or(&crate::error_type_registry::REGISTRY),
483                                error_code,
484                                &mut *deser,
485                            )
486                        }) {
487                        ::std::option::Option::Some(source) => <crate::operation::generate_mac::GenerateMacError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
488                        ::std::option::Option::None => crate::operation::generate_mac::GenerateMacError::generic(generic),
489                    }
490                }
491            };
492            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
493                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
494            ))
495        } else {
496            let protocol = _cfg
497                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
498                .expect("a SharedClientProtocol is required");
499            let mut deser = protocol.deserialize_response(response, GenerateMac::OUTPUT_SCHEMA, _cfg).map_err(|e| {
500                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
501            })?;
502            // `headers` is already in scope from the top of the function; alias it as
503            // `_response_headers` so MutateOutput customizations have a stable name to
504            // read from.
505            let _response_headers = headers;
506            // `mut` is required because `deserialize_members` and the `MutateOutput`
507            // builder setters take `&mut self`. Marked `allow(unused_mut)` because an
508            // empty output has no members and no customizations to run.
509            #[allow(unused_mut)]
510            let mut output = <crate::operation::generate_mac::builders::GenerateMacOutputBuilder>::default();
511            output.deserialize_members(&mut *deser).map_err(|e| {
512                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
513            })?;
514            output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
515            let output = output.build();
516            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
517        }
518    }
519}
520#[derive(Debug)]
521struct GenerateMacRequestSerializer;
522impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GenerateMacRequestSerializer {
523    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
524    fn serialize_input(
525        &self,
526        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
527        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
528    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
529        let input = input
530            .downcast::<crate::operation::generate_mac::GenerateMacInput>()
531            .expect("correct type");
532
533        let protocol = _cfg
534            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
535            .expect("a SharedClientProtocol is required");
536        let mut request = protocol
537            .serialize_request(&input, GenerateMac::INPUT_SCHEMA, "/", _cfg)
538            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
539
540        return ::std::result::Result::Ok(request);
541    }
542}
543#[derive(Debug)]
544struct GenerateMacEndpointParamsInterceptor;
545
546#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
547impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GenerateMacEndpointParamsInterceptor {
548    fn name(&self) -> &'static str {
549        "GenerateMacEndpointParamsInterceptor"
550    }
551
552    fn read_before_execution(
553        &self,
554        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
555            '_,
556            ::aws_smithy_runtime_api::client::interceptors::context::Input,
557            ::aws_smithy_runtime_api::client::interceptors::context::Output,
558            ::aws_smithy_runtime_api::client::interceptors::context::Error,
559        >,
560        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
561    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
562        let _input = context
563            .input()
564            .downcast_ref::<GenerateMacInput>()
565            .ok_or("failed to downcast to GenerateMacInput")?;
566
567        let params = crate::config::endpoint::Params::builder()
568            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
569            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
570            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
571            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
572            .build()
573            .map_err(|err| {
574                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
575            })?;
576        cfg.interceptor_state()
577            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
578        ::std::result::Result::Ok(())
579    }
580}
581
582// The get_* functions below are generated from JMESPath expressions in the
583// operationContextParams trait. They target the operation's input shape.
584
585/// Error type for the `GenerateMacError` operation.
586#[non_exhaustive]
587#[derive(::std::fmt::Debug)]
588pub enum GenerateMacError {
589    /// <p>The request was rejected because the specified KMS key is not enabled.</p>
590    DisabledException(crate::types::error::DisabledException),
591    /// <p>The request was rejected because the DryRun parameter was specified.</p>
592    DryRunOperationException(crate::types::error::DryRunOperationException),
593    /// <p>The request was rejected because the specified grant token is not valid.</p>
594    InvalidGrantTokenException(crate::types::error::InvalidGrantTokenException),
595    /// <p>The request was rejected for one of the following reasons:</p>
596    /// <ul>
597    /// <li>
598    /// <p>The <code>KeyUsage</code> value of the KMS key is incompatible with the API operation.</p></li>
599    /// <li>
600    /// <p>The encryption algorithm or signing algorithm specified for the operation is incompatible with the type of key material in the KMS key <code>(KeySpec</code>).</p></li>
601    /// </ul>
602    /// <p>For encrypting, decrypting, re-encrypting, and generating data keys, the <code>KeyUsage</code> must be <code>ENCRYPT_DECRYPT</code>. For signing and verifying messages, the <code>KeyUsage</code> must be <code>SIGN_VERIFY</code>. For generating and verifying message authentication codes (MACs), the <code>KeyUsage</code> must be <code>GENERATE_VERIFY_MAC</code>. For deriving key agreement secrets, the <code>KeyUsage</code> must be <code>KEY_AGREEMENT</code>. For encapsulating and decapsulating shared secrets, the <code>KeyUsage</code> must be <code>ENCAPSULATE_DECAPSULATE</code>. To find the <code>KeyUsage</code> of a KMS key, use the <code>DescribeKey</code> operation.</p>
603    /// <p>To find the encryption or signing algorithms supported for a particular KMS key, use the <code>DescribeKey</code> operation.</p>
604    InvalidKeyUsageException(crate::types::error::InvalidKeyUsageException),
605    /// <p>The request was rejected because the specified KMS key was not available. You can retry the request.</p>
606    KeyUnavailableException(crate::types::error::KeyUnavailableException),
607    /// <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
608    KmsInternalException(crate::types::error::KmsInternalException),
609    /// <p>The request was rejected because the state of the specified resource is not valid for this request.</p>
610    /// <p>This exceptions means one of the following:</p>
611    /// <ul>
612    /// <li>
613    /// <p>The key state of the KMS key is not compatible with the operation.</p>
614    /// <p>To find the key state, use the <code>DescribeKey</code> operation. For more information about which key states are compatible with each KMS operation, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">Key states of KMS keys</a> in the <i> <i>Key Management Service Developer Guide</i> </i>.</p></li>
615    /// <li>
616    /// <p>For cryptographic operations on KMS keys in custom key stores, this exception represents a general failure with many possible causes. To identify the cause, see the error message that accompanies the exception.</p></li>
617    /// </ul>
618    KmsInvalidStateException(crate::types::error::KmsInvalidStateException),
619    /// <p>The request was rejected because the specified entity or resource could not be found.</p>
620    NotFoundException(crate::types::error::NotFoundException),
621    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
622    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
623    variable wildcard pattern and check `.code()`:
624     \
625    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
626     \
627    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GenerateMacError) for what information is available for the error.")]
628    Unhandled(crate::error::sealed_unhandled::Unhandled),
629}
630impl GenerateMacError {
631    /// Creates the `GenerateMacError::Unhandled` variant from any error type.
632    pub fn unhandled(
633        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
634    ) -> Self {
635        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
636            source: err.into(),
637            meta: ::std::default::Default::default(),
638        })
639    }
640
641    /// Creates the `GenerateMacError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
642    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
643        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
644            source: err.clone().into(),
645            meta: err,
646        })
647    }
648    ///
649    /// Returns error metadata, which includes the error code, message,
650    /// request ID, and potentially additional information.
651    ///
652    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
653        match self {
654            Self::DisabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
655            Self::DryRunOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
656            Self::InvalidGrantTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
657            Self::InvalidKeyUsageException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
658            Self::KeyUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
659            Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
660            Self::KmsInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
661            Self::NotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
662            Self::Unhandled(e) => &e.meta,
663        }
664    }
665    /// Returns `true` if the error kind is `GenerateMacError::DisabledException`.
666    pub fn is_disabled_exception(&self) -> bool {
667        matches!(self, Self::DisabledException(_))
668    }
669    /// Returns `true` if the error kind is `GenerateMacError::DryRunOperationException`.
670    pub fn is_dry_run_operation_exception(&self) -> bool {
671        matches!(self, Self::DryRunOperationException(_))
672    }
673    /// Returns `true` if the error kind is `GenerateMacError::InvalidGrantTokenException`.
674    pub fn is_invalid_grant_token_exception(&self) -> bool {
675        matches!(self, Self::InvalidGrantTokenException(_))
676    }
677    /// Returns `true` if the error kind is `GenerateMacError::InvalidKeyUsageException`.
678    pub fn is_invalid_key_usage_exception(&self) -> bool {
679        matches!(self, Self::InvalidKeyUsageException(_))
680    }
681    /// Returns `true` if the error kind is `GenerateMacError::KeyUnavailableException`.
682    pub fn is_key_unavailable_exception(&self) -> bool {
683        matches!(self, Self::KeyUnavailableException(_))
684    }
685    /// Returns `true` if the error kind is `GenerateMacError::KmsInternalException`.
686    pub fn is_kms_internal_exception(&self) -> bool {
687        matches!(self, Self::KmsInternalException(_))
688    }
689    /// Returns `true` if the error kind is `GenerateMacError::KmsInvalidStateException`.
690    pub fn is_kms_invalid_state_exception(&self) -> bool {
691        matches!(self, Self::KmsInvalidStateException(_))
692    }
693    /// Returns `true` if the error kind is `GenerateMacError::NotFoundException`.
694    pub fn is_not_found_exception(&self) -> bool {
695        matches!(self, Self::NotFoundException(_))
696    }
697}
698impl ::std::error::Error for GenerateMacError {
699    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
700        match self {
701            Self::DisabledException(_inner) => ::std::option::Option::Some(_inner),
702            Self::DryRunOperationException(_inner) => ::std::option::Option::Some(_inner),
703            Self::InvalidGrantTokenException(_inner) => ::std::option::Option::Some(_inner),
704            Self::InvalidKeyUsageException(_inner) => ::std::option::Option::Some(_inner),
705            Self::KeyUnavailableException(_inner) => ::std::option::Option::Some(_inner),
706            Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
707            Self::KmsInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
708            Self::NotFoundException(_inner) => ::std::option::Option::Some(_inner),
709            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
710        }
711    }
712}
713impl ::std::fmt::Display for GenerateMacError {
714    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
715        match self {
716            Self::DisabledException(_inner) => _inner.fmt(f),
717            Self::DryRunOperationException(_inner) => _inner.fmt(f),
718            Self::InvalidGrantTokenException(_inner) => _inner.fmt(f),
719            Self::InvalidKeyUsageException(_inner) => _inner.fmt(f),
720            Self::KeyUnavailableException(_inner) => _inner.fmt(f),
721            Self::KmsInternalException(_inner) => _inner.fmt(f),
722            Self::KmsInvalidStateException(_inner) => _inner.fmt(f),
723            Self::NotFoundException(_inner) => _inner.fmt(f),
724            Self::Unhandled(_inner) => {
725                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
726                    write!(f, "unhandled error ({code})")
727                } else {
728                    f.write_str("unhandled error")
729                }
730            }
731        }
732    }
733}
734impl ::aws_smithy_types::retry::ProvideErrorKind for GenerateMacError {
735    fn code(&self) -> ::std::option::Option<&str> {
736        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
737    }
738    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
739        ::std::option::Option::None
740    }
741}
742impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GenerateMacError {
743    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
744        match self {
745            Self::DisabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
746            Self::DryRunOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
747            Self::InvalidGrantTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
748            Self::InvalidKeyUsageException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
749            Self::KeyUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
750            Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
751            Self::KmsInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
752            Self::NotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
753            Self::Unhandled(_inner) => &_inner.meta,
754        }
755    }
756}
757impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GenerateMacError {
758    fn create_unhandled_error(
759        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
760        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
761    ) -> Self {
762        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
763            source,
764            meta: meta.unwrap_or_default(),
765        })
766    }
767}
768impl ::aws_types::request_id::RequestId for crate::operation::generate_mac::GenerateMacError {
769    fn request_id(&self) -> Option<&str> {
770        self.meta().request_id()
771    }
772}
773
774pub use crate::operation::generate_mac::_generate_mac_input::GenerateMacInput;
775
776pub use crate::operation::generate_mac::_generate_mac_output::GenerateMacOutput;
777
778mod _generate_mac_input;
779
780mod _generate_mac_output;
781
782/// Builders
783pub mod builders;