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