Skip to main content

aws_sdk_kms/operation/
enable_key_rotation.rs

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