aws_sdk_kms/protocol_serde/
shape_enable_key_rotation.rs
1#[allow(clippy::unnecessary_wraps)]
3pub fn de_enable_key_rotation_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::enable_key_rotation::EnableKeyRotationOutput, crate::operation::enable_key_rotation::EnableKeyRotationError>
8{
9 #[allow(unused_mut)]
10 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
12 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13 let generic = generic_builder.build();
14 let error_code = match generic.code() {
15 Some(code) => code,
16 None => return Err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "DependencyTimeoutException" => crate::operation::enable_key_rotation::EnableKeyRotationError::DependencyTimeoutException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::DependencyTimeoutExceptionBuilder::default();
26 output = crate::protocol_serde::shape_dependency_timeout_exception::de_dependency_timeout_exception_json_err(_response_body, output)
27 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
28 let output = output.meta(generic);
29 output.build()
30 };
31 if tmp.message.is_none() {
32 tmp.message = _error_message;
33 }
34 tmp
35 }),
36 "DisabledException" => crate::operation::enable_key_rotation::EnableKeyRotationError::DisabledException({
37 #[allow(unused_mut)]
38 let mut tmp = {
39 #[allow(unused_mut)]
40 let mut output = crate::types::error::builders::DisabledExceptionBuilder::default();
41 output = crate::protocol_serde::shape_disabled_exception::de_disabled_exception_json_err(_response_body, output)
42 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
43 let output = output.meta(generic);
44 output.build()
45 };
46 if tmp.message.is_none() {
47 tmp.message = _error_message;
48 }
49 tmp
50 }),
51 "InvalidArnException" => crate::operation::enable_key_rotation::EnableKeyRotationError::InvalidArnException({
52 #[allow(unused_mut)]
53 let mut tmp = {
54 #[allow(unused_mut)]
55 let mut output = crate::types::error::builders::InvalidArnExceptionBuilder::default();
56 output = crate::protocol_serde::shape_invalid_arn_exception::de_invalid_arn_exception_json_err(_response_body, output)
57 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
58 let output = output.meta(generic);
59 output.build()
60 };
61 if tmp.message.is_none() {
62 tmp.message = _error_message;
63 }
64 tmp
65 }),
66 "KMSInternalException" => crate::operation::enable_key_rotation::EnableKeyRotationError::KmsInternalException({
67 #[allow(unused_mut)]
68 let mut tmp = {
69 #[allow(unused_mut)]
70 let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
71 output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
72 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
73 let output = output.meta(generic);
74 output.build()
75 };
76 if tmp.message.is_none() {
77 tmp.message = _error_message;
78 }
79 tmp
80 }),
81 "KMSInvalidStateException" => crate::operation::enable_key_rotation::EnableKeyRotationError::KmsInvalidStateException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::KmsInvalidStateExceptionBuilder::default();
86 output = crate::protocol_serde::shape_kms_invalid_state_exception::de_kms_invalid_state_exception_json_err(_response_body, output)
87 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
88 let output = output.meta(generic);
89 output.build()
90 };
91 if tmp.message.is_none() {
92 tmp.message = _error_message;
93 }
94 tmp
95 }),
96 "NotFoundException" => crate::operation::enable_key_rotation::EnableKeyRotationError::NotFoundException({
97 #[allow(unused_mut)]
98 let mut tmp = {
99 #[allow(unused_mut)]
100 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
101 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
102 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
103 let output = output.meta(generic);
104 output.build()
105 };
106 if tmp.message.is_none() {
107 tmp.message = _error_message;
108 }
109 tmp
110 }),
111 "UnsupportedOperationException" => crate::operation::enable_key_rotation::EnableKeyRotationError::UnsupportedOperationException({
112 #[allow(unused_mut)]
113 let mut tmp = {
114 #[allow(unused_mut)]
115 let mut output = crate::types::error::builders::UnsupportedOperationExceptionBuilder::default();
116 output =
117 crate::protocol_serde::shape_unsupported_operation_exception::de_unsupported_operation_exception_json_err(_response_body, output)
118 .map_err(crate::operation::enable_key_rotation::EnableKeyRotationError::unhandled)?;
119 let output = output.meta(generic);
120 output.build()
121 };
122 if tmp.message.is_none() {
123 tmp.message = _error_message;
124 }
125 tmp
126 }),
127 _ => crate::operation::enable_key_rotation::EnableKeyRotationError::generic(generic),
128 })
129}
130
131#[allow(clippy::unnecessary_wraps)]
132pub fn de_enable_key_rotation_http_response(
133 _response_status: u16,
134 _response_headers: &::aws_smithy_runtime_api::http::Headers,
135 _response_body: &[u8],
136) -> std::result::Result<crate::operation::enable_key_rotation::EnableKeyRotationOutput, crate::operation::enable_key_rotation::EnableKeyRotationError>
137{
138 Ok({
139 #[allow(unused_mut)]
140 let mut output = crate::operation::enable_key_rotation::builders::EnableKeyRotationOutputBuilder::default();
141 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
142 output.build()
143 })
144}
145
146pub fn ser_enable_key_rotation_input(
147 input: &crate::operation::enable_key_rotation::EnableKeyRotationInput,
148) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
149 let mut out = String::new();
150 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
151 crate::protocol_serde::shape_enable_key_rotation_input::ser_enable_key_rotation_input_input(&mut object, input)?;
152 object.finish();
153 Ok(::aws_smithy_types::body::SdkBody::from(out))
154}