1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ImportKeyMaterial;
6impl ImportKeyMaterial {
7 pub fn new() -> Self {
9 Self
10 }
11 pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::import_key_material::ImportKeyMaterialInput::SCHEMA;
13 pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::import_key_material::ImportKeyMaterialOutput::SCHEMA;
15 pub(crate) async fn orchestrate(
16 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17 input: crate::operation::import_key_material::ImportKeyMaterialInput,
18 ) -> ::std::result::Result<
19 crate::operation::import_key_material::ImportKeyMaterialOutput,
20 ::aws_smithy_runtime_api::client::result::SdkError<
21 crate::operation::import_key_material::ImportKeyMaterialError,
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::import_key_material::ImportKeyMaterialError>()
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::import_key_material::ImportKeyMaterialOutput>()
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::import_key_material::ImportKeyMaterialInput,
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", "ImportKeyMaterial", input, runtime_plugins, stop_point)
59 .instrument(::tracing::debug_span!(
62 "KMS.ImportKeyMaterial",
63 "rpc.service" = "KMS",
64 "rpc.method" = "ImportKeyMaterial",
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}
91pub(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::ExpiredImportTokenException::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::ExpiredImportTokenException::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::ExpiredImportTokenException::deserialize(d)?))
118 },
119 )
120.insert_error_shape(
121 crate::types::error::IncorrectKeyMaterialException::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::IncorrectKeyMaterialException::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::IncorrectKeyMaterialException::deserialize(d)?))
127 },
128 )
129.insert_error_shape(
130 crate::types::error::InvalidArnException::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::InvalidArnException::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::InvalidArnException::deserialize(d)?))
136 },
137 )
138.insert_error_shape(
139 crate::types::error::InvalidCiphertextException::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::InvalidCiphertextException::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::InvalidCiphertextException::deserialize(d)?))
145 },
146 )
147.insert_error_shape(
148 crate::types::error::InvalidImportTokenException::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::InvalidImportTokenException::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::InvalidImportTokenException::deserialize(d)?))
154 },
155 )
156.insert_error_shape(
157 crate::types::error::KmsInternalException::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::KmsInternalException::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::KmsInternalException::deserialize(d)?))
163 },
164 )
165.insert_error_shape(
166 crate::types::error::KmsInvalidStateException::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::KmsInvalidStateException::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::KmsInvalidStateException::deserialize(d)?))
172 },
173 )
174.insert_error_shape(
175 crate::types::error::NotFoundException::SCHEMA,
176 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
177 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::NotFoundException::deserialize(d)?))
178 },
179 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
180 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::NotFoundException::deserialize(d)?))
181 },
182 )
183.insert_error_shape(
184 crate::types::error::UnsupportedOperationException::SCHEMA,
185 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
186 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::UnsupportedOperationException::deserialize(d)?))
187 },
188 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
189 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::UnsupportedOperationException::deserialize(d)?))
190 },
191 )
192 .build()
193 });
194}
195impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ImportKeyMaterial {
196 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
197 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ImportKeyMaterial");
198
199 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
200 ImportKeyMaterialRequestSerializer,
201 ));
202 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
203 ImportKeyMaterialResponseDeserializer,
204 ));
205
206 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
207 crate::config::auth::Params::builder()
208 .operation_name("ImportKeyMaterial")
209 .build()
210 .expect("required fields set"),
211 ));
212
213 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("ImportKeyMaterial", "KMS"));
214 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
215 signing_options.double_uri_encode = true;
216 signing_options.content_sha256_header = false;
217 signing_options.normalize_uri_path = true;
218 signing_options.payload_override = None;
219
220 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
221 signing_options,
222 ..::std::default::Default::default()
223 });
224
225 ::std::option::Option::Some(cfg.freeze())
226 }
227
228 fn runtime_components(
229 &self,
230 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
231 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
232 #[allow(unused_mut)]
233 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ImportKeyMaterial")
234 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
235 ImportKeyMaterialTelemetryInputCaptureInterceptor,
236 ))
237 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
238 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
239 ))
240 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
241 ImportKeyMaterialEndpointParamsInterceptor,
242 ))
243 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
244 crate::operation::import_key_material::ImportKeyMaterialError,
245 >::new())
246 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
247 crate::operation::import_key_material::ImportKeyMaterialError,
248 >::new())
249 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
250 crate::operation::import_key_material::ImportKeyMaterialError,
251 >::new())
252 .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
253 crate::operation::import_key_material::ImportKeyMaterialError,
254 >::new());
255
256 ::std::borrow::Cow::Owned(rcb)
257 }
258}
259
260#[derive(Debug)]
261struct ImportKeyMaterialTelemetryInputCaptureInterceptor;
262
263#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
264impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ImportKeyMaterialTelemetryInputCaptureInterceptor {
265 fn name(&self) -> &'static str {
266 "ImportKeyMaterialTelemetryInputCaptureInterceptor"
267 }
268
269 fn read_before_execution(
270 &self,
271 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
272 '_,
273 ::aws_smithy_runtime_api::client::interceptors::context::Input,
274 ::aws_smithy_runtime_api::client::interceptors::context::Output,
275 ::aws_smithy_runtime_api::client::interceptors::context::Error,
276 >,
277 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
278 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
279 let ::std::option::Option::Some(requested) = cfg
281 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
282 .filter(|r| !r.is_empty())
283 else {
284 return ::std::result::Result::Ok(());
285 };
286
287 let ::std::option::Option::Some(input) = context.input().downcast_ref::<ImportKeyMaterialInput>() else {
288 return ::std::result::Result::Ok(());
290 };
291
292 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
293 if requested.should_capture("KeyId") {
294 if let ::std::option::Option::Some(value) = input.key_id.as_deref() {
295 captured.insert("KeyId", value);
296 }
297 }
298 if requested.should_capture("KeyMaterialDescription") {
299 if let ::std::option::Option::Some(value) = input.key_material_description.as_deref() {
300 captured.insert("KeyMaterialDescription", value);
301 }
302 }
303 if requested.should_capture("KeyMaterialId") {
304 if let ::std::option::Option::Some(value) = input.key_material_id.as_deref() {
305 captured.insert("KeyMaterialId", value);
306 }
307 }
308
309 cfg.interceptor_state().store_put(captured);
310 ::std::result::Result::Ok(())
311 }
312}
313#[derive(Debug)]
314struct ImportKeyMaterialResponseDeserializer;
315impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ImportKeyMaterialResponseDeserializer {
316 fn deserialize_nonstreaming_with_config(
317 &self,
318 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
319 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
320 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
321 let (success, status) = (response.status().is_success(), response.status().as_u16());
322 #[allow(unused_variables)]
327 let body = response.body().bytes().expect("body loaded");
328 let headers = response.headers();
329 #[allow(unused_mut)]
330 let mut force_error = false;
331 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
332 if !success && status != 200 || force_error {
333 let protocol = _cfg
334 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
335 .expect("a SharedClientProtocol is required");
336 #[allow(unused_mut)]
337 let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
338 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
339 })?;
340 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
341 let generic = generic_builder.build();
342 let error_code = match generic.code() {
343 ::std::option::Option::Some(code) => code,
344 ::std::option::Option::None => {
345 return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
346 ::aws_smithy_runtime_api::box_error::BoxError::from(
347 crate::operation::import_key_material::ImportKeyMaterialError::unhandled(generic),
348 ),
349 ))
350 }
351 };
352 let _error_message = generic.message().map(|msg| msg.to_owned());
353 let err = match error_code {
354 "DependencyTimeoutException" => crate::operation::import_key_material::ImportKeyMaterialError::DependencyTimeoutException({
355 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
356 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
357 e,
358 ))
359 })?;
360 let mut tmp = <crate::types::error::builders::DependencyTimeoutExceptionBuilder>::default();
361 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
367 tmp.message = _error_message;
368 }
369 let tmp = tmp.meta(generic);
370 tmp.build()
371 }),
372 "ExpiredImportTokenException" => crate::operation::import_key_material::ImportKeyMaterialError::ExpiredImportTokenException({
373 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
374 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
375 e,
376 ))
377 })?;
378 let mut tmp = <crate::types::error::builders::ExpiredImportTokenExceptionBuilder>::default();
379 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
385 tmp.message = _error_message;
386 }
387 let tmp = tmp.meta(generic);
388 tmp.build()
389 }),
390 "IncorrectKeyMaterialException" => crate::operation::import_key_material::ImportKeyMaterialError::IncorrectKeyMaterialException({
391 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
392 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
393 e,
394 ))
395 })?;
396 let mut tmp = <crate::types::error::builders::IncorrectKeyMaterialExceptionBuilder>::default();
397 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
403 tmp.message = _error_message;
404 }
405 let tmp = tmp.meta(generic);
406 tmp.build()
407 }),
408 "InvalidArnException" => crate::operation::import_key_material::ImportKeyMaterialError::InvalidArnException({
409 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
410 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
411 e,
412 ))
413 })?;
414 let mut tmp = <crate::types::error::builders::InvalidArnExceptionBuilder>::default();
415 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
421 tmp.message = _error_message;
422 }
423 let tmp = tmp.meta(generic);
424 tmp.build()
425 }),
426 "InvalidCiphertextException" => crate::operation::import_key_material::ImportKeyMaterialError::InvalidCiphertextException({
427 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
428 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
429 e,
430 ))
431 })?;
432 let mut tmp = <crate::types::error::builders::InvalidCiphertextExceptionBuilder>::default();
433 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
439 tmp.message = _error_message;
440 }
441 let tmp = tmp.meta(generic);
442 tmp.build()
443 }),
444 "InvalidImportTokenException" => crate::operation::import_key_material::ImportKeyMaterialError::InvalidImportTokenException({
445 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
446 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
447 e,
448 ))
449 })?;
450 let mut tmp = <crate::types::error::builders::InvalidImportTokenExceptionBuilder>::default();
451 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
457 tmp.message = _error_message;
458 }
459 let tmp = tmp.meta(generic);
460 tmp.build()
461 }),
462 "KMSInternalException" => crate::operation::import_key_material::ImportKeyMaterialError::KmsInternalException({
463 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
464 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
465 e,
466 ))
467 })?;
468 let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
469 tmp.deserialize_members(&mut *deser).map_err(|e| {
470 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
471 e,
472 ))
473 })?;
474 if tmp.message.is_none() {
475 tmp.message = _error_message;
476 }
477 let tmp = tmp.meta(generic);
478 tmp.build()
479 }),
480 "KMSInvalidStateException" => crate::operation::import_key_material::ImportKeyMaterialError::KmsInvalidStateException({
481 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
482 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
483 e,
484 ))
485 })?;
486 let mut tmp = <crate::types::error::builders::KmsInvalidStateExceptionBuilder>::default();
487 tmp.deserialize_members(&mut *deser).map_err(|e| {
488 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
489 e,
490 ))
491 })?;
492 if tmp.message.is_none() {
493 tmp.message = _error_message;
494 }
495 let tmp = tmp.meta(generic);
496 tmp.build()
497 }),
498 "NotFoundException" => crate::operation::import_key_material::ImportKeyMaterialError::NotFoundException({
499 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
500 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
501 e,
502 ))
503 })?;
504 let mut tmp = <crate::types::error::builders::NotFoundExceptionBuilder>::default();
505 tmp.deserialize_members(&mut *deser).map_err(|e| {
506 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
507 e,
508 ))
509 })?;
510 if tmp.message.is_none() {
511 tmp.message = _error_message;
512 }
513 let tmp = tmp.meta(generic);
514 tmp.build()
515 }),
516 "UnsupportedOperationException" => crate::operation::import_key_material::ImportKeyMaterialError::UnsupportedOperationException({
517 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
518 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
519 e,
520 ))
521 })?;
522 let mut tmp = <crate::types::error::builders::UnsupportedOperationExceptionBuilder>::default();
523 tmp.deserialize_members(&mut *deser).map_err(|e| {
524 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
525 e,
526 ))
527 })?;
528 if tmp.message.is_none() {
529 tmp.message = _error_message;
530 }
531 let tmp = tmp.meta(generic);
532 tmp.build()
533 }),
534 _ => {
535 match protocol
543 .deserialize_error_response(response, _cfg)
544 .ok()
545 .and_then(|mut deser| {
546 ::aws_smithy_schema::registry::reify_error(
547 crate::operation::import_key_material::error_registry::REGISTRY
548 .or(&crate::error_type_registry::REGISTRY),
549 error_code,
550 &mut *deser,
551 )
552 }) {
553 ::std::option::Option::Some(source) => <crate::operation::import_key_material::ImportKeyMaterialError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
554 ::std::option::Option::None => crate::operation::import_key_material::ImportKeyMaterialError::generic(generic),
555 }
556 }
557 };
558 ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
559 ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
560 ))
561 } else {
562 let protocol = _cfg
563 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
564 .expect("a SharedClientProtocol is required");
565 let mut deser = protocol
566 .deserialize_response(response, ImportKeyMaterial::OUTPUT_SCHEMA, _cfg)
567 .map_err(|e| {
568 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
569 })?;
570 let _response_headers = headers;
574 #[allow(unused_mut)]
578 let mut output = <crate::operation::import_key_material::builders::ImportKeyMaterialOutputBuilder>::default();
579 output.deserialize_members(&mut *deser).map_err(|e| {
580 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
581 })?;
582 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
583 let output = output.build();
584 ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
585 }
586 }
587}
588#[derive(Debug)]
589struct ImportKeyMaterialRequestSerializer;
590impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ImportKeyMaterialRequestSerializer {
591 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
592 fn serialize_input(
593 &self,
594 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
595 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
596 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
597 let input = input
598 .downcast::<crate::operation::import_key_material::ImportKeyMaterialInput>()
599 .expect("correct type");
600
601 let protocol = _cfg
602 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
603 .expect("a SharedClientProtocol is required");
604 let mut request = protocol
605 .serialize_request(&input, ImportKeyMaterial::INPUT_SCHEMA, "/", _cfg)
606 .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
607
608 return ::std::result::Result::Ok(request);
609 }
610}
611#[derive(Debug)]
612struct ImportKeyMaterialEndpointParamsInterceptor;
613
614#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
615impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ImportKeyMaterialEndpointParamsInterceptor {
616 fn name(&self) -> &'static str {
617 "ImportKeyMaterialEndpointParamsInterceptor"
618 }
619
620 fn read_before_execution(
621 &self,
622 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
623 '_,
624 ::aws_smithy_runtime_api::client::interceptors::context::Input,
625 ::aws_smithy_runtime_api::client::interceptors::context::Output,
626 ::aws_smithy_runtime_api::client::interceptors::context::Error,
627 >,
628 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
629 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
630 let _input = context
631 .input()
632 .downcast_ref::<ImportKeyMaterialInput>()
633 .ok_or("failed to downcast to ImportKeyMaterialInput")?;
634
635 let params = crate::config::endpoint::Params::builder()
636 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
637 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
638 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
639 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
640 .build()
641 .map_err(|err| {
642 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
643 })?;
644 cfg.interceptor_state()
645 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
646 ::std::result::Result::Ok(())
647 }
648}
649
650#[non_exhaustive]
655#[derive(::std::fmt::Debug)]
656pub enum ImportKeyMaterialError {
657 DependencyTimeoutException(crate::types::error::DependencyTimeoutException),
659 ExpiredImportTokenException(crate::types::error::ExpiredImportTokenException),
661 IncorrectKeyMaterialException(crate::types::error::IncorrectKeyMaterialException),
663 InvalidArnException(crate::types::error::InvalidArnException),
665 InvalidCiphertextException(crate::types::error::InvalidCiphertextException),
669 InvalidImportTokenException(crate::types::error::InvalidImportTokenException),
671 KmsInternalException(crate::types::error::KmsInternalException),
673 KmsInvalidStateException(crate::types::error::KmsInvalidStateException),
683 NotFoundException(crate::types::error::NotFoundException),
685 UnsupportedOperationException(crate::types::error::UnsupportedOperationException),
687 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
689 variable wildcard pattern and check `.code()`:
690 \
691 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
692 \
693 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ImportKeyMaterialError) for what information is available for the error.")]
694 Unhandled(crate::error::sealed_unhandled::Unhandled),
695}
696impl ImportKeyMaterialError {
697 pub fn unhandled(
699 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
700 ) -> Self {
701 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
702 source: err.into(),
703 meta: ::std::default::Default::default(),
704 })
705 }
706
707 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
709 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
710 source: err.clone().into(),
711 meta: err,
712 })
713 }
714 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
719 match self {
720 Self::DependencyTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
721 Self::ExpiredImportTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
722 Self::IncorrectKeyMaterialException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
723 Self::InvalidArnException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
724 Self::InvalidCiphertextException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
725 Self::InvalidImportTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
726 Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
727 Self::KmsInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
728 Self::NotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
729 Self::UnsupportedOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
730 Self::Unhandled(e) => &e.meta,
731 }
732 }
733 pub fn is_dependency_timeout_exception(&self) -> bool {
735 matches!(self, Self::DependencyTimeoutException(_))
736 }
737 pub fn is_expired_import_token_exception(&self) -> bool {
739 matches!(self, Self::ExpiredImportTokenException(_))
740 }
741 pub fn is_incorrect_key_material_exception(&self) -> bool {
743 matches!(self, Self::IncorrectKeyMaterialException(_))
744 }
745 pub fn is_invalid_arn_exception(&self) -> bool {
747 matches!(self, Self::InvalidArnException(_))
748 }
749 pub fn is_invalid_ciphertext_exception(&self) -> bool {
751 matches!(self, Self::InvalidCiphertextException(_))
752 }
753 pub fn is_invalid_import_token_exception(&self) -> bool {
755 matches!(self, Self::InvalidImportTokenException(_))
756 }
757 pub fn is_kms_internal_exception(&self) -> bool {
759 matches!(self, Self::KmsInternalException(_))
760 }
761 pub fn is_kms_invalid_state_exception(&self) -> bool {
763 matches!(self, Self::KmsInvalidStateException(_))
764 }
765 pub fn is_not_found_exception(&self) -> bool {
767 matches!(self, Self::NotFoundException(_))
768 }
769 pub fn is_unsupported_operation_exception(&self) -> bool {
771 matches!(self, Self::UnsupportedOperationException(_))
772 }
773}
774impl ::std::error::Error for ImportKeyMaterialError {
775 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
776 match self {
777 Self::DependencyTimeoutException(_inner) => ::std::option::Option::Some(_inner),
778 Self::ExpiredImportTokenException(_inner) => ::std::option::Option::Some(_inner),
779 Self::IncorrectKeyMaterialException(_inner) => ::std::option::Option::Some(_inner),
780 Self::InvalidArnException(_inner) => ::std::option::Option::Some(_inner),
781 Self::InvalidCiphertextException(_inner) => ::std::option::Option::Some(_inner),
782 Self::InvalidImportTokenException(_inner) => ::std::option::Option::Some(_inner),
783 Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
784 Self::KmsInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
785 Self::NotFoundException(_inner) => ::std::option::Option::Some(_inner),
786 Self::UnsupportedOperationException(_inner) => ::std::option::Option::Some(_inner),
787 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
788 }
789 }
790}
791impl ::std::fmt::Display for ImportKeyMaterialError {
792 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
793 match self {
794 Self::DependencyTimeoutException(_inner) => _inner.fmt(f),
795 Self::ExpiredImportTokenException(_inner) => _inner.fmt(f),
796 Self::IncorrectKeyMaterialException(_inner) => _inner.fmt(f),
797 Self::InvalidArnException(_inner) => _inner.fmt(f),
798 Self::InvalidCiphertextException(_inner) => _inner.fmt(f),
799 Self::InvalidImportTokenException(_inner) => _inner.fmt(f),
800 Self::KmsInternalException(_inner) => _inner.fmt(f),
801 Self::KmsInvalidStateException(_inner) => _inner.fmt(f),
802 Self::NotFoundException(_inner) => _inner.fmt(f),
803 Self::UnsupportedOperationException(_inner) => _inner.fmt(f),
804 Self::Unhandled(_inner) => {
805 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
806 write!(f, "unhandled error ({code})")
807 } else {
808 f.write_str("unhandled error")
809 }
810 }
811 }
812 }
813}
814impl ::aws_smithy_types::retry::ProvideErrorKind for ImportKeyMaterialError {
815 fn code(&self) -> ::std::option::Option<&str> {
816 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
817 }
818 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
819 ::std::option::Option::None
820 }
821}
822impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ImportKeyMaterialError {
823 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
824 match self {
825 Self::DependencyTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
826 Self::ExpiredImportTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
827 Self::IncorrectKeyMaterialException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
828 Self::InvalidArnException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
829 Self::InvalidCiphertextException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
830 Self::InvalidImportTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
831 Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
832 Self::KmsInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
833 Self::NotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
834 Self::UnsupportedOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
835 Self::Unhandled(_inner) => &_inner.meta,
836 }
837 }
838}
839impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ImportKeyMaterialError {
840 fn create_unhandled_error(
841 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
842 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
843 ) -> Self {
844 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
845 source,
846 meta: meta.unwrap_or_default(),
847 })
848 }
849}
850impl ::aws_types::request_id::RequestId for crate::operation::import_key_material::ImportKeyMaterialError {
851 fn request_id(&self) -> Option<&str> {
852 self.meta().request_id()
853 }
854}
855
856pub use crate::operation::import_key_material::_import_key_material_input::ImportKeyMaterialInput;
857
858pub use crate::operation::import_key_material::_import_key_material_output::ImportKeyMaterialOutput;
859
860mod _import_key_material_input;
861
862mod _import_key_material_output;
863
864pub mod builders;