1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct Encrypt;
6impl Encrypt {
7 pub fn new() -> Self {
9 Self
10 }
11 pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::encrypt::EncryptInput::SCHEMA;
13 pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::encrypt::EncryptOutput::SCHEMA;
15 pub(crate) async fn orchestrate(
16 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17 input: crate::operation::encrypt::EncryptInput,
18 ) -> ::std::result::Result<
19 crate::operation::encrypt::EncryptOutput,
20 ::aws_smithy_runtime_api::client::result::SdkError<
21 crate::operation::encrypt::EncryptError,
22 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
23 >,
24 > {
25 let map_err =
26 |err: ::aws_smithy_runtime_api::client::result::SdkError<
27 ::aws_smithy_runtime_api::client::interceptors::context::Error,
28 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
29 >| { err.map_service_error(|err| err.downcast::<crate::operation::encrypt::EncryptError>().expect("correct error type")) };
30 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31 .await
32 .map_err(map_err)?;
33 let output = context.finalize().map_err(map_err)?;
34 ::std::result::Result::Ok(
35 output
36 .downcast::<crate::operation::encrypt::EncryptOutput>()
37 .expect("correct output type"),
38 )
39 }
40
41 pub(crate) async fn orchestrate_with_stop_point(
42 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43 input: crate::operation::encrypt::EncryptInput,
44 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45 ) -> ::std::result::Result<
46 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47 ::aws_smithy_runtime_api::client::result::SdkError<
48 ::aws_smithy_runtime_api::client::interceptors::context::Error,
49 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50 >,
51 > {
52 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53 use ::tracing::Instrument;
54 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("KMS", "Encrypt", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "KMS.Encrypt",
59 "rpc.service" = "KMS",
60 "rpc.method" = "Encrypt",
61 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62 "rpc.system" = "aws-api",
63 ))
64 .await
65 }
66
67 pub(crate) fn operation_runtime_plugins(
68 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69 client_config: &crate::config::Config,
70 config_override: ::std::option::Option<crate::config::Builder>,
71 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74 if let ::std::option::Option::Some(config_override) = config_override {
75 for plugin in config_override.runtime_plugins.iter().cloned() {
76 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77 }
78 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79 config_override,
80 client_config.config.clone(),
81 &client_config.runtime_components,
82 ));
83 }
84 runtime_plugins
85 }
86}
87pub(crate) mod error_registry {
96 pub(crate) static REGISTRY: ::std::sync::LazyLock<::aws_smithy_schema::registry::TypeRegistry> = ::std::sync::LazyLock::new(|| {
97 ::aws_smithy_schema::registry::TypeRegistry::builder()
98 .insert_error_shape(
99 crate::types::error::DependencyTimeoutException::SCHEMA,
100 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
101 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::DependencyTimeoutException::deserialize(d)?))
102 },
103 |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> {
104 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::DependencyTimeoutException::deserialize(d)?))
105 },
106 )
107.insert_error_shape(
108 crate::types::error::DisabledException::SCHEMA,
109 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
110 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::DisabledException::deserialize(d)?))
111 },
112 |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> {
113 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::DisabledException::deserialize(d)?))
114 },
115 )
116.insert_error_shape(
117 crate::types::error::DryRunOperationException::SCHEMA,
118 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
119 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::DryRunOperationException::deserialize(d)?))
120 },
121 |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> {
122 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::DryRunOperationException::deserialize(d)?))
123 },
124 )
125.insert_error_shape(
126 crate::types::error::InvalidGrantTokenException::SCHEMA,
127 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
128 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::InvalidGrantTokenException::deserialize(d)?))
129 },
130 |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> {
131 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::InvalidGrantTokenException::deserialize(d)?))
132 },
133 )
134.insert_error_shape(
135 crate::types::error::InvalidKeyUsageException::SCHEMA,
136 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
137 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::InvalidKeyUsageException::deserialize(d)?))
138 },
139 |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> {
140 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::InvalidKeyUsageException::deserialize(d)?))
141 },
142 )
143.insert_error_shape(
144 crate::types::error::KmsInternalException::SCHEMA,
145 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
146 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::KmsInternalException::deserialize(d)?))
147 },
148 |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> {
149 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::KmsInternalException::deserialize(d)?))
150 },
151 )
152.insert_error_shape(
153 crate::types::error::KmsInvalidStateException::SCHEMA,
154 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
155 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::KmsInvalidStateException::deserialize(d)?))
156 },
157 |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> {
158 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::KmsInvalidStateException::deserialize(d)?))
159 },
160 )
161.insert_error_shape(
162 crate::types::error::KeyUnavailableException::SCHEMA,
163 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
164 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::KeyUnavailableException::deserialize(d)?))
165 },
166 |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> {
167 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::KeyUnavailableException::deserialize(d)?))
168 },
169 )
170.insert_error_shape(
171 crate::types::error::NotFoundException::SCHEMA,
172 |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
173 ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::NotFoundException::deserialize(d)?))
174 },
175 |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> {
176 ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::NotFoundException::deserialize(d)?))
177 },
178 )
179 .build()
180 });
181}
182impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for Encrypt {
183 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
184 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("Encrypt");
185
186 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
187 EncryptRequestSerializer,
188 ));
189 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
190 EncryptResponseDeserializer,
191 ));
192
193 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
194 crate::config::auth::Params::builder()
195 .operation_name("Encrypt")
196 .build()
197 .expect("required fields set"),
198 ));
199
200 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("Encrypt", "KMS"));
201 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
202 signing_options.double_uri_encode = true;
203 signing_options.content_sha256_header = false;
204 signing_options.normalize_uri_path = true;
205 signing_options.payload_override = None;
206
207 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
208 signing_options,
209 ..::std::default::Default::default()
210 });
211
212 ::std::option::Option::Some(cfg.freeze())
213 }
214
215 fn runtime_components(
216 &self,
217 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
218 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
219 #[allow(unused_mut)]
220 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("Encrypt")
221 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
222 EncryptTelemetryInputCaptureInterceptor,
223 ))
224 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
225 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
226 ))
227 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
228 EncryptEndpointParamsInterceptor,
229 ))
230 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
231 crate::operation::encrypt::EncryptError,
232 >::new())
233 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
234 crate::operation::encrypt::EncryptError,
235 >::new())
236 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
237 crate::operation::encrypt::EncryptError,
238 >::new())
239 .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
240 crate::operation::encrypt::EncryptError,
241 >::new());
242
243 ::std::borrow::Cow::Owned(rcb)
244 }
245}
246
247#[derive(Debug)]
248struct EncryptTelemetryInputCaptureInterceptor;
249
250#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
251impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EncryptTelemetryInputCaptureInterceptor {
252 fn name(&self) -> &'static str {
253 "EncryptTelemetryInputCaptureInterceptor"
254 }
255
256 fn read_before_execution(
257 &self,
258 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
259 '_,
260 ::aws_smithy_runtime_api::client::interceptors::context::Input,
261 ::aws_smithy_runtime_api::client::interceptors::context::Output,
262 ::aws_smithy_runtime_api::client::interceptors::context::Error,
263 >,
264 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
265 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
266 let ::std::option::Option::Some(requested) = cfg
268 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
269 .filter(|r| !r.is_empty())
270 else {
271 return ::std::result::Result::Ok(());
272 };
273
274 let ::std::option::Option::Some(input) = context.input().downcast_ref::<EncryptInput>() else {
275 return ::std::result::Result::Ok(());
277 };
278
279 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
280 if requested.should_capture("KeyId") {
281 if let ::std::option::Option::Some(value) = input.key_id.as_deref() {
282 captured.insert("KeyId", value);
283 }
284 }
285
286 cfg.interceptor_state().store_put(captured);
287 ::std::result::Result::Ok(())
288 }
289}
290#[derive(Debug)]
291struct EncryptResponseDeserializer;
292impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EncryptResponseDeserializer {
293 fn deserialize_nonstreaming_with_config(
294 &self,
295 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
296 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
297 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
298 let (success, status) = (response.status().is_success(), response.status().as_u16());
299 #[allow(unused_variables)]
304 let body = response.body().bytes().expect("body loaded");
305 let headers = response.headers();
306 #[allow(unused_mut)]
307 let mut force_error = false;
308 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
309 if !success && status != 200 || force_error {
310 let protocol = _cfg
311 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
312 .expect("a SharedClientProtocol is required");
313 #[allow(unused_mut)]
314 let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
315 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
316 })?;
317 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
318 let generic = generic_builder.build();
319 let error_code = match generic.code() {
320 ::std::option::Option::Some(code) => code,
321 ::std::option::Option::None => {
322 return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
323 ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::encrypt::EncryptError::unhandled(generic)),
324 ))
325 }
326 };
327 let _error_message = generic.message().map(|msg| msg.to_owned());
328 let err = match error_code {
329 "DependencyTimeoutException" => crate::operation::encrypt::EncryptError::DependencyTimeoutException({
330 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
331 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
332 e,
333 ))
334 })?;
335 let mut tmp = <crate::types::error::builders::DependencyTimeoutExceptionBuilder>::default();
336 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
342 tmp.message = _error_message;
343 }
344 let tmp = tmp.meta(generic);
345 tmp.build()
346 }),
347 "DisabledException" => crate::operation::encrypt::EncryptError::DisabledException({
348 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
349 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
350 e,
351 ))
352 })?;
353 let mut tmp = <crate::types::error::builders::DisabledExceptionBuilder>::default();
354 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
360 tmp.message = _error_message;
361 }
362 let tmp = tmp.meta(generic);
363 tmp.build()
364 }),
365 "DryRunOperationException" => crate::operation::encrypt::EncryptError::DryRunOperationException({
366 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
367 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
368 e,
369 ))
370 })?;
371 let mut tmp = <crate::types::error::builders::DryRunOperationExceptionBuilder>::default();
372 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
378 tmp.message = _error_message;
379 }
380 let tmp = tmp.meta(generic);
381 tmp.build()
382 }),
383 "InvalidGrantTokenException" => crate::operation::encrypt::EncryptError::InvalidGrantTokenException({
384 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
385 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
386 e,
387 ))
388 })?;
389 let mut tmp = <crate::types::error::builders::InvalidGrantTokenExceptionBuilder>::default();
390 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
396 tmp.message = _error_message;
397 }
398 let tmp = tmp.meta(generic);
399 tmp.build()
400 }),
401 "InvalidKeyUsageException" => crate::operation::encrypt::EncryptError::InvalidKeyUsageException({
402 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
403 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
404 e,
405 ))
406 })?;
407 let mut tmp = <crate::types::error::builders::InvalidKeyUsageExceptionBuilder>::default();
408 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
414 tmp.message = _error_message;
415 }
416 let tmp = tmp.meta(generic);
417 tmp.build()
418 }),
419 "KeyUnavailableException" => crate::operation::encrypt::EncryptError::KeyUnavailableException({
420 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
421 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
422 e,
423 ))
424 })?;
425 let mut tmp = <crate::types::error::builders::KeyUnavailableExceptionBuilder>::default();
426 tmp.deserialize_members(&mut *deser).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 if tmp.message.is_none() {
432 tmp.message = _error_message;
433 }
434 let tmp = tmp.meta(generic);
435 tmp.build()
436 }),
437 "KMSInternalException" => crate::operation::encrypt::EncryptError::KmsInternalException({
438 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
439 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
440 e,
441 ))
442 })?;
443 let mut tmp = <crate::types::error::builders::KmsInternalExceptionBuilder>::default();
444 tmp.deserialize_members(&mut *deser).map_err(|e| {
445 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
446 e,
447 ))
448 })?;
449 if tmp.message.is_none() {
450 tmp.message = _error_message;
451 }
452 let tmp = tmp.meta(generic);
453 tmp.build()
454 }),
455 "KMSInvalidStateException" => crate::operation::encrypt::EncryptError::KmsInvalidStateException({
456 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
457 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
458 e,
459 ))
460 })?;
461 let mut tmp = <crate::types::error::builders::KmsInvalidStateExceptionBuilder>::default();
462 tmp.deserialize_members(&mut *deser).map_err(|e| {
463 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
464 e,
465 ))
466 })?;
467 if tmp.message.is_none() {
468 tmp.message = _error_message;
469 }
470 let tmp = tmp.meta(generic);
471 tmp.build()
472 }),
473 "NotFoundException" => crate::operation::encrypt::EncryptError::NotFoundException({
474 let mut deser = protocol.deserialize_error_response(response, _cfg).map_err(|e| {
475 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
476 e,
477 ))
478 })?;
479 let mut tmp = <crate::types::error::builders::NotFoundExceptionBuilder>::default();
480 tmp.deserialize_members(&mut *deser).map_err(|e| {
481 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(
482 e,
483 ))
484 })?;
485 if tmp.message.is_none() {
486 tmp.message = _error_message;
487 }
488 let tmp = tmp.meta(generic);
489 tmp.build()
490 }),
491 _ => {
492 match protocol
500 .deserialize_error_response(response, _cfg)
501 .ok()
502 .and_then(|mut deser| {
503 ::aws_smithy_schema::registry::reify_error(
504 crate::operation::encrypt::error_registry::REGISTRY
505 .or(&crate::error_type_registry::REGISTRY),
506 error_code,
507 &mut *deser,
508 )
509 }) {
510 ::std::option::Option::Some(source) => <crate::operation::encrypt::EncryptError as ::aws_smithy_runtime_api::client::result::CreateUnhandledError>::create_unhandled_error(source, ::std::option::Option::Some(generic)),
511 ::std::option::Option::None => crate::operation::encrypt::EncryptError::generic(generic),
512 }
513 }
514 };
515 ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
516 ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
517 ))
518 } else {
519 let protocol = _cfg
520 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
521 .expect("a SharedClientProtocol is required");
522 let mut deser = protocol.deserialize_response(response, Encrypt::OUTPUT_SCHEMA, _cfg).map_err(|e| {
523 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
524 })?;
525 let _response_headers = headers;
529 #[allow(unused_mut)]
533 let mut output = <crate::operation::encrypt::builders::EncryptOutputBuilder>::default();
534 output.deserialize_members(&mut *deser).map_err(|e| {
535 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
536 })?;
537 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
538 let output = output.build();
539 ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
540 }
541 }
542}
543#[derive(Debug)]
544struct EncryptRequestSerializer;
545impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EncryptRequestSerializer {
546 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
547 fn serialize_input(
548 &self,
549 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
550 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
551 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
552 let input = input.downcast::<crate::operation::encrypt::EncryptInput>().expect("correct type");
553
554 let protocol = _cfg
555 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
556 .expect("a SharedClientProtocol is required");
557 let mut request = protocol
558 .serialize_request(&input, Encrypt::INPUT_SCHEMA, "/", _cfg)
559 .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
560
561 return ::std::result::Result::Ok(request);
562 }
563}
564#[derive(Debug)]
565struct EncryptEndpointParamsInterceptor;
566
567#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
568impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EncryptEndpointParamsInterceptor {
569 fn name(&self) -> &'static str {
570 "EncryptEndpointParamsInterceptor"
571 }
572
573 fn read_before_execution(
574 &self,
575 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
576 '_,
577 ::aws_smithy_runtime_api::client::interceptors::context::Input,
578 ::aws_smithy_runtime_api::client::interceptors::context::Output,
579 ::aws_smithy_runtime_api::client::interceptors::context::Error,
580 >,
581 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
582 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
583 let _input = context
584 .input()
585 .downcast_ref::<EncryptInput>()
586 .ok_or("failed to downcast to EncryptInput")?;
587
588 let params = crate::config::endpoint::Params::builder()
589 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
590 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
591 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
592 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
593 .build()
594 .map_err(|err| {
595 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
596 })?;
597 cfg.interceptor_state()
598 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
599 ::std::result::Result::Ok(())
600 }
601}
602
603#[non_exhaustive]
608#[derive(::std::fmt::Debug)]
609pub enum EncryptError {
610 DependencyTimeoutException(crate::types::error::DependencyTimeoutException),
612 DisabledException(crate::types::error::DisabledException),
614 DryRunOperationException(crate::types::error::DryRunOperationException),
616 InvalidGrantTokenException(crate::types::error::InvalidGrantTokenException),
618 InvalidKeyUsageException(crate::types::error::InvalidKeyUsageException),
628 KeyUnavailableException(crate::types::error::KeyUnavailableException),
630 KmsInternalException(crate::types::error::KmsInternalException),
632 KmsInvalidStateException(crate::types::error::KmsInvalidStateException),
642 NotFoundException(crate::types::error::NotFoundException),
644 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
646 variable wildcard pattern and check `.code()`:
647 \
648 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
649 \
650 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-EncryptError) for what information is available for the error.")]
651 Unhandled(crate::error::sealed_unhandled::Unhandled),
652}
653impl EncryptError {
654 pub fn unhandled(
656 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
657 ) -> Self {
658 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
659 source: err.into(),
660 meta: ::std::default::Default::default(),
661 })
662 }
663
664 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
666 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
667 source: err.clone().into(),
668 meta: err,
669 })
670 }
671 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
676 match self {
677 Self::DependencyTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
678 Self::DisabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
679 Self::DryRunOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
680 Self::InvalidGrantTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
681 Self::InvalidKeyUsageException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
682 Self::KeyUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
683 Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
684 Self::KmsInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
685 Self::NotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
686 Self::Unhandled(e) => &e.meta,
687 }
688 }
689 pub fn is_dependency_timeout_exception(&self) -> bool {
691 matches!(self, Self::DependencyTimeoutException(_))
692 }
693 pub fn is_disabled_exception(&self) -> bool {
695 matches!(self, Self::DisabledException(_))
696 }
697 pub fn is_dry_run_operation_exception(&self) -> bool {
699 matches!(self, Self::DryRunOperationException(_))
700 }
701 pub fn is_invalid_grant_token_exception(&self) -> bool {
703 matches!(self, Self::InvalidGrantTokenException(_))
704 }
705 pub fn is_invalid_key_usage_exception(&self) -> bool {
707 matches!(self, Self::InvalidKeyUsageException(_))
708 }
709 pub fn is_key_unavailable_exception(&self) -> bool {
711 matches!(self, Self::KeyUnavailableException(_))
712 }
713 pub fn is_kms_internal_exception(&self) -> bool {
715 matches!(self, Self::KmsInternalException(_))
716 }
717 pub fn is_kms_invalid_state_exception(&self) -> bool {
719 matches!(self, Self::KmsInvalidStateException(_))
720 }
721 pub fn is_not_found_exception(&self) -> bool {
723 matches!(self, Self::NotFoundException(_))
724 }
725}
726impl ::std::error::Error for EncryptError {
727 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
728 match self {
729 Self::DependencyTimeoutException(_inner) => ::std::option::Option::Some(_inner),
730 Self::DisabledException(_inner) => ::std::option::Option::Some(_inner),
731 Self::DryRunOperationException(_inner) => ::std::option::Option::Some(_inner),
732 Self::InvalidGrantTokenException(_inner) => ::std::option::Option::Some(_inner),
733 Self::InvalidKeyUsageException(_inner) => ::std::option::Option::Some(_inner),
734 Self::KeyUnavailableException(_inner) => ::std::option::Option::Some(_inner),
735 Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
736 Self::KmsInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
737 Self::NotFoundException(_inner) => ::std::option::Option::Some(_inner),
738 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
739 }
740 }
741}
742impl ::std::fmt::Display for EncryptError {
743 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
744 match self {
745 Self::DependencyTimeoutException(_inner) => _inner.fmt(f),
746 Self::DisabledException(_inner) => _inner.fmt(f),
747 Self::DryRunOperationException(_inner) => _inner.fmt(f),
748 Self::InvalidGrantTokenException(_inner) => _inner.fmt(f),
749 Self::InvalidKeyUsageException(_inner) => _inner.fmt(f),
750 Self::KeyUnavailableException(_inner) => _inner.fmt(f),
751 Self::KmsInternalException(_inner) => _inner.fmt(f),
752 Self::KmsInvalidStateException(_inner) => _inner.fmt(f),
753 Self::NotFoundException(_inner) => _inner.fmt(f),
754 Self::Unhandled(_inner) => {
755 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
756 write!(f, "unhandled error ({code})")
757 } else {
758 f.write_str("unhandled error")
759 }
760 }
761 }
762 }
763}
764impl ::aws_smithy_types::retry::ProvideErrorKind for EncryptError {
765 fn code(&self) -> ::std::option::Option<&str> {
766 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
767 }
768 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
769 ::std::option::Option::None
770 }
771}
772impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for EncryptError {
773 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
774 match self {
775 Self::DependencyTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
776 Self::DisabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
777 Self::DryRunOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
778 Self::InvalidGrantTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
779 Self::InvalidKeyUsageException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
780 Self::KeyUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
781 Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
782 Self::KmsInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
783 Self::NotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
784 Self::Unhandled(_inner) => &_inner.meta,
785 }
786 }
787}
788impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for EncryptError {
789 fn create_unhandled_error(
790 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
791 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
792 ) -> Self {
793 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
794 source,
795 meta: meta.unwrap_or_default(),
796 })
797 }
798}
799impl ::aws_types::request_id::RequestId for crate::operation::encrypt::EncryptError {
800 fn request_id(&self) -> Option<&str> {
801 self.meta().request_id()
802 }
803}
804
805pub use crate::operation::encrypt::_encrypt_input::EncryptInput;
806
807pub use crate::operation::encrypt::_encrypt_output::EncryptOutput;
808
809mod _encrypt_input;
810
811mod _encrypt_output;
812
813pub mod builders;