1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct Decrypt;
6impl Decrypt {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::decrypt::DecryptInput,
14 ) -> ::std::result::Result<
15 crate::operation::decrypt::DecryptOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::decrypt::DecryptError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err =
22 |err: ::aws_smithy_runtime_api::client::result::SdkError<
23 ::aws_smithy_runtime_api::client::interceptors::context::Error,
24 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
25 >| { err.map_service_error(|err| err.downcast::<crate::operation::decrypt::DecryptError>().expect("correct error type")) };
26 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
27 .await
28 .map_err(map_err)?;
29 let output = context.finalize().map_err(map_err)?;
30 ::std::result::Result::Ok(
31 output
32 .downcast::<crate::operation::decrypt::DecryptOutput>()
33 .expect("correct output type"),
34 )
35 }
36
37 pub(crate) async fn orchestrate_with_stop_point(
38 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
39 input: crate::operation::decrypt::DecryptInput,
40 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
41 ) -> ::std::result::Result<
42 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
43 ::aws_smithy_runtime_api::client::result::SdkError<
44 ::aws_smithy_runtime_api::client::interceptors::context::Error,
45 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
46 >,
47 > {
48 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
49 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("kms", "Decrypt", input, runtime_plugins, stop_point).await
50 }
51
52 pub(crate) fn operation_runtime_plugins(
53 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
54 client_config: &crate::config::Config,
55 config_override: ::std::option::Option<crate::config::Builder>,
56 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
57 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
58 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
59 ::aws_runtime::auth::sigv4::SCHEME_ID,
60 ]));
61 if let ::std::option::Option::Some(config_override) = config_override {
62 for plugin in config_override.runtime_plugins.iter().cloned() {
63 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
64 }
65 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
66 config_override,
67 client_config.config.clone(),
68 &client_config.runtime_components,
69 ));
70 }
71 runtime_plugins
72 }
73}
74impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for Decrypt {
75 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
76 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("Decrypt");
77
78 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
79 DecryptRequestSerializer,
80 ));
81 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
82 DecryptResponseDeserializer,
83 ));
84
85 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
86 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
87 ));
88
89 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
90 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("Decrypt", "kms"));
91 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
92 signing_options.double_uri_encode = true;
93 signing_options.content_sha256_header = false;
94 signing_options.normalize_uri_path = true;
95 signing_options.payload_override = None;
96
97 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
98 signing_options,
99 ..::std::default::Default::default()
100 });
101
102 ::std::option::Option::Some(cfg.freeze())
103 }
104
105 fn runtime_components(
106 &self,
107 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
108 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
109 #[allow(unused_mut)]
110 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("Decrypt")
111 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
112 .with_interceptor(DecryptEndpointParamsInterceptor)
113 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
114 crate::operation::decrypt::DecryptError,
115 >::new())
116 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
117 crate::operation::decrypt::DecryptError,
118 >::new())
119 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
120 crate::operation::decrypt::DecryptError,
121 >::new());
122
123 ::std::borrow::Cow::Owned(rcb)
124 }
125}
126
127#[derive(Debug)]
128struct DecryptResponseDeserializer;
129impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for DecryptResponseDeserializer {
130 fn deserialize_nonstreaming(
131 &self,
132 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
133 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
134 let (success, status) = (response.status().is_success(), response.status().as_u16());
135 let headers = response.headers();
136 let body = response.body().bytes().expect("body loaded");
137 #[allow(unused_mut)]
138 let mut force_error = false;
139 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
140 let parse_result = if !success && status != 200 || force_error {
141 crate::protocol_serde::shape_decrypt::de_decrypt_http_error(status, headers, body)
142 } else {
143 crate::protocol_serde::shape_decrypt::de_decrypt_http_response(status, headers, body)
144 };
145 crate::protocol_serde::type_erase_result(parse_result)
146 }
147}
148#[derive(Debug)]
149struct DecryptRequestSerializer;
150impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DecryptRequestSerializer {
151 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
152 fn serialize_input(
153 &self,
154 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
155 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
156 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
157 let input = input.downcast::<crate::operation::decrypt::DecryptInput>().expect("correct type");
158 let _header_serialization_settings = _cfg
159 .load::<crate::serialization_settings::HeaderSerializationSettings>()
160 .cloned()
161 .unwrap_or_default();
162 let mut request_builder = {
163 fn uri_base(
164 _input: &crate::operation::decrypt::DecryptInput,
165 output: &mut ::std::string::String,
166 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
167 use ::std::fmt::Write as _;
168 ::std::write!(output, "/").expect("formatting should succeed");
169 ::std::result::Result::Ok(())
170 }
171 #[allow(clippy::unnecessary_wraps)]
172 fn update_http_builder(
173 input: &crate::operation::decrypt::DecryptInput,
174 builder: ::http::request::Builder,
175 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
176 let mut uri = ::std::string::String::new();
177 uri_base(input, &mut uri)?;
178 ::std::result::Result::Ok(builder.method("POST").uri(uri))
179 }
180 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
181 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/x-amz-json-1.1");
182 builder = _header_serialization_settings.set_default_header(
183 builder,
184 ::http::header::HeaderName::from_static("x-amz-target"),
185 "TrentService.Decrypt",
186 );
187 builder
188 };
189 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_decrypt::ser_decrypt_input(&input)?);
190 if let Some(content_length) = body.content_length() {
191 let content_length = content_length.to_string();
192 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
193 }
194 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
195 }
196}
197#[derive(Debug)]
198struct DecryptEndpointParamsInterceptor;
199
200impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DecryptEndpointParamsInterceptor {
201 fn name(&self) -> &'static str {
202 "DecryptEndpointParamsInterceptor"
203 }
204
205 fn read_before_execution(
206 &self,
207 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
208 '_,
209 ::aws_smithy_runtime_api::client::interceptors::context::Input,
210 ::aws_smithy_runtime_api::client::interceptors::context::Output,
211 ::aws_smithy_runtime_api::client::interceptors::context::Error,
212 >,
213 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
214 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
215 let _input = context
216 .input()
217 .downcast_ref::<DecryptInput>()
218 .ok_or("failed to downcast to DecryptInput")?;
219
220 let params = crate::config::endpoint::Params::builder()
221 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
222 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
223 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
224 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
225 .build()
226 .map_err(|err| {
227 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
228 })?;
229 cfg.interceptor_state()
230 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
231 ::std::result::Result::Ok(())
232 }
233}
234
235#[non_exhaustive]
240#[derive(::std::fmt::Debug)]
241pub enum DecryptError {
242 DependencyTimeoutException(crate::types::error::DependencyTimeoutException),
244 DisabledException(crate::types::error::DisabledException),
246 DryRunOperationException(crate::types::error::DryRunOperationException),
248 IncorrectKeyException(crate::types::error::IncorrectKeyException),
250 InvalidCiphertextException(crate::types::error::InvalidCiphertextException),
253 InvalidGrantTokenException(crate::types::error::InvalidGrantTokenException),
255 InvalidKeyUsageException(crate::types::error::InvalidKeyUsageException),
265 KeyUnavailableException(crate::types::error::KeyUnavailableException),
267 KmsInternalException(crate::types::error::KmsInternalException),
269 KmsInvalidStateException(crate::types::error::KmsInvalidStateException),
279 NotFoundException(crate::types::error::NotFoundException),
281 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
283 variable wildcard pattern and check `.code()`:
284 \
285 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
286 \
287 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-DecryptError) for what information is available for the error.")]
288 Unhandled(crate::error::sealed_unhandled::Unhandled),
289}
290impl DecryptError {
291 pub fn unhandled(
293 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
294 ) -> Self {
295 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
296 source: err.into(),
297 meta: ::std::default::Default::default(),
298 })
299 }
300
301 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
303 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
304 source: err.clone().into(),
305 meta: err,
306 })
307 }
308 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
313 match self {
314 Self::DependencyTimeoutException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
315 Self::DisabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
316 Self::DryRunOperationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
317 Self::IncorrectKeyException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
318 Self::InvalidCiphertextException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
319 Self::InvalidGrantTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
320 Self::InvalidKeyUsageException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
321 Self::KeyUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
322 Self::KmsInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
323 Self::KmsInvalidStateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
324 Self::NotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
325 Self::Unhandled(e) => &e.meta,
326 }
327 }
328 pub fn is_dependency_timeout_exception(&self) -> bool {
330 matches!(self, Self::DependencyTimeoutException(_))
331 }
332 pub fn is_disabled_exception(&self) -> bool {
334 matches!(self, Self::DisabledException(_))
335 }
336 pub fn is_dry_run_operation_exception(&self) -> bool {
338 matches!(self, Self::DryRunOperationException(_))
339 }
340 pub fn is_incorrect_key_exception(&self) -> bool {
342 matches!(self, Self::IncorrectKeyException(_))
343 }
344 pub fn is_invalid_ciphertext_exception(&self) -> bool {
346 matches!(self, Self::InvalidCiphertextException(_))
347 }
348 pub fn is_invalid_grant_token_exception(&self) -> bool {
350 matches!(self, Self::InvalidGrantTokenException(_))
351 }
352 pub fn is_invalid_key_usage_exception(&self) -> bool {
354 matches!(self, Self::InvalidKeyUsageException(_))
355 }
356 pub fn is_key_unavailable_exception(&self) -> bool {
358 matches!(self, Self::KeyUnavailableException(_))
359 }
360 pub fn is_kms_internal_exception(&self) -> bool {
362 matches!(self, Self::KmsInternalException(_))
363 }
364 pub fn is_kms_invalid_state_exception(&self) -> bool {
366 matches!(self, Self::KmsInvalidStateException(_))
367 }
368 pub fn is_not_found_exception(&self) -> bool {
370 matches!(self, Self::NotFoundException(_))
371 }
372}
373impl ::std::error::Error for DecryptError {
374 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
375 match self {
376 Self::DependencyTimeoutException(_inner) => ::std::option::Option::Some(_inner),
377 Self::DisabledException(_inner) => ::std::option::Option::Some(_inner),
378 Self::DryRunOperationException(_inner) => ::std::option::Option::Some(_inner),
379 Self::IncorrectKeyException(_inner) => ::std::option::Option::Some(_inner),
380 Self::InvalidCiphertextException(_inner) => ::std::option::Option::Some(_inner),
381 Self::InvalidGrantTokenException(_inner) => ::std::option::Option::Some(_inner),
382 Self::InvalidKeyUsageException(_inner) => ::std::option::Option::Some(_inner),
383 Self::KeyUnavailableException(_inner) => ::std::option::Option::Some(_inner),
384 Self::KmsInternalException(_inner) => ::std::option::Option::Some(_inner),
385 Self::KmsInvalidStateException(_inner) => ::std::option::Option::Some(_inner),
386 Self::NotFoundException(_inner) => ::std::option::Option::Some(_inner),
387 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
388 }
389 }
390}
391impl ::std::fmt::Display for DecryptError {
392 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
393 match self {
394 Self::DependencyTimeoutException(_inner) => _inner.fmt(f),
395 Self::DisabledException(_inner) => _inner.fmt(f),
396 Self::DryRunOperationException(_inner) => _inner.fmt(f),
397 Self::IncorrectKeyException(_inner) => _inner.fmt(f),
398 Self::InvalidCiphertextException(_inner) => _inner.fmt(f),
399 Self::InvalidGrantTokenException(_inner) => _inner.fmt(f),
400 Self::InvalidKeyUsageException(_inner) => _inner.fmt(f),
401 Self::KeyUnavailableException(_inner) => _inner.fmt(f),
402 Self::KmsInternalException(_inner) => _inner.fmt(f),
403 Self::KmsInvalidStateException(_inner) => _inner.fmt(f),
404 Self::NotFoundException(_inner) => _inner.fmt(f),
405 Self::Unhandled(_inner) => {
406 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
407 write!(f, "unhandled error ({code})")
408 } else {
409 f.write_str("unhandled error")
410 }
411 }
412 }
413 }
414}
415impl ::aws_smithy_types::retry::ProvideErrorKind for DecryptError {
416 fn code(&self) -> ::std::option::Option<&str> {
417 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
418 }
419 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
420 ::std::option::Option::None
421 }
422}
423impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for DecryptError {
424 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
425 match self {
426 Self::DependencyTimeoutException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
427 Self::DisabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
428 Self::DryRunOperationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
429 Self::IncorrectKeyException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
430 Self::InvalidCiphertextException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
431 Self::InvalidGrantTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
432 Self::InvalidKeyUsageException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::KeyUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::KmsInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::KmsInvalidStateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::NotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
437 Self::Unhandled(_inner) => &_inner.meta,
438 }
439 }
440}
441impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for DecryptError {
442 fn create_unhandled_error(
443 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
444 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
445 ) -> Self {
446 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
447 source,
448 meta: meta.unwrap_or_default(),
449 })
450 }
451}
452impl ::aws_types::request_id::RequestId for crate::operation::decrypt::DecryptError {
453 fn request_id(&self) -> Option<&str> {
454 self.meta().request_id()
455 }
456}
457
458pub use crate::operation::decrypt::_decrypt_output::DecryptOutput;
459
460pub use crate::operation::decrypt::_decrypt_input::DecryptInput;
461
462mod _decrypt_input;
463
464mod _decrypt_output;
465
466pub mod builders;