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