aws_sdk_kms/protocol_serde/
shape_rotate_key_on_demand.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_rotate_key_on_demand_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::rotate_key_on_demand::RotateKeyOnDemandOutput,
9    crate::operation::rotate_key_on_demand::RotateKeyOnDemandError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => return Err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "ConflictException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::ConflictException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
28                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "DependencyTimeoutException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::DependencyTimeoutException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::DependencyTimeoutExceptionBuilder::default();
43                output = crate::protocol_serde::shape_dependency_timeout_exception::de_dependency_timeout_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "DisabledException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::DisabledException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::DisabledExceptionBuilder::default();
58                output = crate::protocol_serde::shape_disabled_exception::de_disabled_exception_json_err(_response_body, output)
59                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
60                let output = output.meta(generic);
61                output.build()
62            };
63            if tmp.message.is_none() {
64                tmp.message = _error_message;
65            }
66            tmp
67        }),
68        "InvalidArnException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::InvalidArnException({
69            #[allow(unused_mut)]
70            let mut tmp = {
71                #[allow(unused_mut)]
72                let mut output = crate::types::error::builders::InvalidArnExceptionBuilder::default();
73                output = crate::protocol_serde::shape_invalid_arn_exception::de_invalid_arn_exception_json_err(_response_body, output)
74                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
75                let output = output.meta(generic);
76                output.build()
77            };
78            if tmp.message.is_none() {
79                tmp.message = _error_message;
80            }
81            tmp
82        }),
83        "KMSInternalException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::KmsInternalException({
84            #[allow(unused_mut)]
85            let mut tmp = {
86                #[allow(unused_mut)]
87                let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
88                output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
89                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
90                let output = output.meta(generic);
91                output.build()
92            };
93            if tmp.message.is_none() {
94                tmp.message = _error_message;
95            }
96            tmp
97        }),
98        "KMSInvalidStateException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::KmsInvalidStateException({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::KmsInvalidStateExceptionBuilder::default();
103                output = crate::protocol_serde::shape_kms_invalid_state_exception::de_kms_invalid_state_exception_json_err(_response_body, output)
104                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
105                let output = output.meta(generic);
106                output.build()
107            };
108            if tmp.message.is_none() {
109                tmp.message = _error_message;
110            }
111            tmp
112        }),
113        "LimitExceededException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::LimitExceededException({
114            #[allow(unused_mut)]
115            let mut tmp = {
116                #[allow(unused_mut)]
117                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
118                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
119                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
120                let output = output.meta(generic);
121                output.build()
122            };
123            if tmp.message.is_none() {
124                tmp.message = _error_message;
125            }
126            tmp
127        }),
128        "NotFoundException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::NotFoundException({
129            #[allow(unused_mut)]
130            let mut tmp = {
131                #[allow(unused_mut)]
132                let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
133                output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
134                    .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
135                let output = output.meta(generic);
136                output.build()
137            };
138            if tmp.message.is_none() {
139                tmp.message = _error_message;
140            }
141            tmp
142        }),
143        "UnsupportedOperationException" => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::UnsupportedOperationException({
144            #[allow(unused_mut)]
145            let mut tmp = {
146                #[allow(unused_mut)]
147                let mut output = crate::types::error::builders::UnsupportedOperationExceptionBuilder::default();
148                output =
149                    crate::protocol_serde::shape_unsupported_operation_exception::de_unsupported_operation_exception_json_err(_response_body, output)
150                        .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
151                let output = output.meta(generic);
152                output.build()
153            };
154            if tmp.message.is_none() {
155                tmp.message = _error_message;
156            }
157            tmp
158        }),
159        _ => crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::generic(generic),
160    })
161}
162
163#[allow(clippy::unnecessary_wraps)]
164pub fn de_rotate_key_on_demand_http_response(
165    _response_status: u16,
166    _response_headers: &::aws_smithy_runtime_api::http::Headers,
167    _response_body: &[u8],
168) -> std::result::Result<
169    crate::operation::rotate_key_on_demand::RotateKeyOnDemandOutput,
170    crate::operation::rotate_key_on_demand::RotateKeyOnDemandError,
171> {
172    Ok({
173        #[allow(unused_mut)]
174        let mut output = crate::operation::rotate_key_on_demand::builders::RotateKeyOnDemandOutputBuilder::default();
175        output = crate::protocol_serde::shape_rotate_key_on_demand::de_rotate_key_on_demand(_response_body, output)
176            .map_err(crate::operation::rotate_key_on_demand::RotateKeyOnDemandError::unhandled)?;
177        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
178        output.build()
179    })
180}
181
182pub fn ser_rotate_key_on_demand_input(
183    input: &crate::operation::rotate_key_on_demand::RotateKeyOnDemandInput,
184) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
185    let mut out = String::new();
186    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
187    crate::protocol_serde::shape_rotate_key_on_demand_input::ser_rotate_key_on_demand_input_input(&mut object, input)?;
188    object.finish();
189    Ok(::aws_smithy_types::body::SdkBody::from(out))
190}
191
192pub(crate) fn de_rotate_key_on_demand(
193    value: &[u8],
194    mut builder: crate::operation::rotate_key_on_demand::builders::RotateKeyOnDemandOutputBuilder,
195) -> Result<crate::operation::rotate_key_on_demand::builders::RotateKeyOnDemandOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
196{
197    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
198    let tokens = &mut tokens_owned;
199    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
200    loop {
201        match tokens.next().transpose()? {
202            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
203            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
204                "KeyId" => {
205                    builder = builder.set_key_id(
206                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
207                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
208                            .transpose()?,
209                    );
210                }
211                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
212            },
213            other => {
214                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
215                    "expected object key or end object, found: {:?}",
216                    other
217                )))
218            }
219        }
220    }
221    if tokens.next().is_some() {
222        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
223            "found more JSON tokens after completing parsing",
224        ));
225    }
226    Ok(builder)
227}