aws_sdk_paymentcryptography/operation/
get_key.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetKey;
6impl GetKey {
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::get_key::GetKeyInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_key::GetKeyOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_key::GetKeyError,
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::get_key::GetKeyError>().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(output.downcast::<crate::operation::get_key::GetKeyOutput>().expect("correct output type"))
31 }
32
33 pub(crate) async fn orchestrate_with_stop_point(
34 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
35 input: crate::operation::get_key::GetKeyInput,
36 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
37 ) -> ::std::result::Result<
38 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
39 ::aws_smithy_runtime_api::client::result::SdkError<
40 ::aws_smithy_runtime_api::client::interceptors::context::Error,
41 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
42 >,
43 > {
44 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
45 use ::tracing::Instrument;
46 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Payment Cryptography", "GetKey", input, runtime_plugins, stop_point)
47 .instrument(::tracing::debug_span!(
50 "Payment Cryptography.GetKey",
51 "rpc.service" = "Payment Cryptography",
52 "rpc.method" = "GetKey",
53 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
54 "rpc.system" = "aws-api",
55 ))
56 .await
57 }
58
59 pub(crate) fn operation_runtime_plugins(
60 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
61 client_config: &crate::config::Config,
62 config_override: ::std::option::Option<crate::config::Builder>,
63 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
64 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
65
66 if let ::std::option::Option::Some(config_override) = config_override {
67 for plugin in config_override.runtime_plugins.iter().cloned() {
68 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
69 }
70 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
71 config_override,
72 client_config.config.clone(),
73 &client_config.runtime_components,
74 ));
75 }
76 runtime_plugins
77 }
78}
79impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetKey {
80 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
81 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetKey");
82
83 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
84 GetKeyRequestSerializer,
85 ));
86 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
87 GetKeyResponseDeserializer,
88 ));
89
90 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
91 crate::config::auth::Params::builder()
92 .operation_name("GetKey")
93 .build()
94 .expect("required fields set"),
95 ));
96
97 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
98 "GetKey",
99 "Payment Cryptography",
100 ));
101 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
102 signing_options.double_uri_encode = true;
103 signing_options.content_sha256_header = false;
104 signing_options.normalize_uri_path = true;
105 signing_options.payload_override = None;
106
107 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
108 signing_options,
109 ..::std::default::Default::default()
110 });
111
112 ::std::option::Option::Some(cfg.freeze())
113 }
114
115 fn runtime_components(
116 &self,
117 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
118 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
119 #[allow(unused_mut)]
120 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetKey")
121 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
122 GetKeyTelemetryInputCaptureInterceptor,
123 ))
124 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
125 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
126 ))
127 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
128 GetKeyEndpointParamsInterceptor,
129 ))
130 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
131 crate::operation::get_key::GetKeyError,
132 >::new())
133 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
134 crate::operation::get_key::GetKeyError,
135 >::new())
136 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
137 crate::operation::get_key::GetKeyError,
138 >::new());
139
140 ::std::borrow::Cow::Owned(rcb)
141 }
142}
143
144#[derive(Debug)]
145struct GetKeyTelemetryInputCaptureInterceptor;
146
147#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
148impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetKeyTelemetryInputCaptureInterceptor {
149 fn name(&self) -> &'static str {
150 "GetKeyTelemetryInputCaptureInterceptor"
151 }
152
153 fn read_before_execution(
154 &self,
155 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
156 '_,
157 ::aws_smithy_runtime_api::client::interceptors::context::Input,
158 ::aws_smithy_runtime_api::client::interceptors::context::Output,
159 ::aws_smithy_runtime_api::client::interceptors::context::Error,
160 >,
161 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
162 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
163 let ::std::option::Option::Some(requested) = cfg
165 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
166 .filter(|r| !r.is_empty())
167 else {
168 return ::std::result::Result::Ok(());
169 };
170
171 let ::std::option::Option::Some(input) = context.input().downcast_ref::<GetKeyInput>() else {
172 return ::std::result::Result::Ok(());
174 };
175
176 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
177 if requested.should_capture("KeyIdentifier") {
178 if let ::std::option::Option::Some(value) = input.key_identifier.as_deref() {
179 captured.insert("KeyIdentifier", value);
180 }
181 }
182
183 cfg.interceptor_state().store_put(captured);
184 ::std::result::Result::Ok(())
185 }
186}
187#[derive(Debug)]
188struct GetKeyResponseDeserializer;
189impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetKeyResponseDeserializer {
190 fn deserialize_nonstreaming_with_config(
191 &self,
192 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
193 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
194 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
195 let (success, status) = (response.status().is_success(), response.status().as_u16());
196 let headers = response.headers();
197 let body = response.body().bytes().expect("body loaded");
198 #[allow(unused_mut)]
199 let mut force_error = false;
200 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
201 let parse_result = if !success && status != 200 || force_error {
202 crate::protocol_serde::shape_get_key::de_get_key_http_error(status, headers, body)
203 } else {
204 crate::protocol_serde::shape_get_key::de_get_key_http_response(status, headers, body)
205 };
206 crate::protocol_serde::type_erase_result(parse_result)
207 }
208}
209#[derive(Debug)]
210struct GetKeyRequestSerializer;
211impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetKeyRequestSerializer {
212 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
213 fn serialize_input(
214 &self,
215 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
216 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
217 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
218 let input = input.downcast::<crate::operation::get_key::GetKeyInput>().expect("correct type");
219 let _header_serialization_settings = _cfg
220 .load::<crate::serialization_settings::HeaderSerializationSettings>()
221 .cloned()
222 .unwrap_or_default();
223 let mut request_builder = {
224 #[allow(clippy::uninlined_format_args)]
225 fn uri_base(
226 _input: &crate::operation::get_key::GetKeyInput,
227 output: &mut ::std::string::String,
228 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
229 use ::std::fmt::Write as _;
230 ::std::write!(output, "/").expect("formatting should succeed");
231 ::std::result::Result::Ok(())
232 }
233 #[allow(clippy::unnecessary_wraps)]
234 fn update_http_builder(
235 input: &crate::operation::get_key::GetKeyInput,
236 builder: ::http_1x::request::Builder,
237 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
238 let mut uri = ::std::string::String::new();
239 uri_base(input, &mut uri)?;
240 ::std::result::Result::Ok(builder.method("POST").uri(uri))
241 }
242 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
243 builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.0");
244 builder = _header_serialization_settings.set_default_header(
245 builder,
246 ::http_1x::header::HeaderName::from_static("x-amz-target"),
247 "PaymentCryptographyControlPlane.GetKey",
248 );
249 builder
250 };
251 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_get_key::ser_get_key_input(&input)?);
252 if let Some(content_length) = body.content_length() {
253 let content_length = content_length.to_string();
254 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
255 }
256 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
257 }
258}
259#[derive(Debug)]
260struct GetKeyEndpointParamsInterceptor;
261
262#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
263impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetKeyEndpointParamsInterceptor {
264 fn name(&self) -> &'static str {
265 "GetKeyEndpointParamsInterceptor"
266 }
267
268 fn read_before_execution(
269 &self,
270 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
271 '_,
272 ::aws_smithy_runtime_api::client::interceptors::context::Input,
273 ::aws_smithy_runtime_api::client::interceptors::context::Output,
274 ::aws_smithy_runtime_api::client::interceptors::context::Error,
275 >,
276 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
277 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
278 let _input = context.input().downcast_ref::<GetKeyInput>().ok_or("failed to downcast to GetKeyInput")?;
279
280 let params = crate::config::endpoint::Params::builder()
281 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
282 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
283 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
284 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
285 .build()
286 .map_err(|err| {
287 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
288 })?;
289 cfg.interceptor_state()
290 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
291 ::std::result::Result::Ok(())
292 }
293}
294
295#[non_exhaustive]
300#[derive(::std::fmt::Debug)]
301pub enum GetKeyError {
302 AccessDeniedException(crate::types::error::AccessDeniedException),
305 InternalServerException(crate::types::error::InternalServerException),
308 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
311 ServiceUnavailableException(crate::types::error::ServiceUnavailableException),
314 ThrottlingException(crate::types::error::ThrottlingException),
317 ValidationException(crate::types::error::ValidationException),
320 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
322 variable wildcard pattern and check `.code()`:
323 \
324 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
325 \
326 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetKeyError) for what information is available for the error.")]
327 Unhandled(crate::error::sealed_unhandled::Unhandled),
328}
329impl GetKeyError {
330 pub fn unhandled(
332 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
333 ) -> Self {
334 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
335 source: err.into(),
336 meta: ::std::default::Default::default(),
337 })
338 }
339
340 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
342 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
343 source: err.clone().into(),
344 meta: err,
345 })
346 }
347 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
352 match self {
353 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
354 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
355 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
356 Self::ServiceUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
357 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
358 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
359 Self::Unhandled(e) => &e.meta,
360 }
361 }
362 pub fn is_access_denied_exception(&self) -> bool {
364 matches!(self, Self::AccessDeniedException(_))
365 }
366 pub fn is_internal_server_exception(&self) -> bool {
368 matches!(self, Self::InternalServerException(_))
369 }
370 pub fn is_resource_not_found_exception(&self) -> bool {
372 matches!(self, Self::ResourceNotFoundException(_))
373 }
374 pub fn is_service_unavailable_exception(&self) -> bool {
376 matches!(self, Self::ServiceUnavailableException(_))
377 }
378 pub fn is_throttling_exception(&self) -> bool {
380 matches!(self, Self::ThrottlingException(_))
381 }
382 pub fn is_validation_exception(&self) -> bool {
384 matches!(self, Self::ValidationException(_))
385 }
386}
387impl ::std::error::Error for GetKeyError {
388 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
389 match self {
390 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
391 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
392 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
393 Self::ServiceUnavailableException(_inner) => ::std::option::Option::Some(_inner),
394 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
395 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
396 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
397 }
398 }
399}
400impl ::std::fmt::Display for GetKeyError {
401 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
402 match self {
403 Self::AccessDeniedException(_inner) => _inner.fmt(f),
404 Self::InternalServerException(_inner) => _inner.fmt(f),
405 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
406 Self::ServiceUnavailableException(_inner) => _inner.fmt(f),
407 Self::ThrottlingException(_inner) => _inner.fmt(f),
408 Self::ValidationException(_inner) => _inner.fmt(f),
409 Self::Unhandled(_inner) => {
410 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
411 write!(f, "unhandled error ({code})")
412 } else {
413 f.write_str("unhandled error")
414 }
415 }
416 }
417 }
418}
419impl ::aws_smithy_types::retry::ProvideErrorKind for GetKeyError {
420 fn code(&self) -> ::std::option::Option<&str> {
421 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
422 }
423 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
424 ::std::option::Option::None
425 }
426}
427impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetKeyError {
428 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
429 match self {
430 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
431 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
432 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::ServiceUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::Unhandled(_inner) => &_inner.meta,
437 }
438 }
439}
440impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetKeyError {
441 fn create_unhandled_error(
442 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
443 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
444 ) -> Self {
445 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
446 source,
447 meta: meta.unwrap_or_default(),
448 })
449 }
450}
451impl ::aws_types::request_id::RequestId for crate::operation::get_key::GetKeyError {
452 fn request_id(&self) -> Option<&str> {
453 self.meta().request_id()
454 }
455}
456
457pub use crate::operation::get_key::_get_key_input::GetKeyInput;
458
459pub use crate::operation::get_key::_get_key_output::GetKeyOutput;
460
461mod _get_key_input;
462
463mod _get_key_output;
464
465pub mod builders;