aws_sdk_kms/protocol_serde/
shape_list_key_rotations.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_key_rotations_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::list_key_rotations::ListKeyRotationsOutput, crate::operation::list_key_rotations::ListKeyRotationsError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "InvalidArnException" => crate::operation::list_key_rotations::ListKeyRotationsError::InvalidArnException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::InvalidArnExceptionBuilder::default();
25                output = crate::protocol_serde::shape_invalid_arn_exception::de_invalid_arn_exception_json_err(_response_body, output)
26                    .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        "InvalidMarkerException" => crate::operation::list_key_rotations::ListKeyRotationsError::InvalidMarkerException({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::InvalidMarkerExceptionBuilder::default();
40                output = crate::protocol_serde::shape_invalid_marker_exception::de_invalid_marker_exception_json_err(_response_body, output)
41                    .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
42                let output = output.meta(generic);
43                output.build()
44            };
45            if tmp.message.is_none() {
46                tmp.message = _error_message;
47            }
48            tmp
49        }),
50        "KMSInternalException" => crate::operation::list_key_rotations::ListKeyRotationsError::KmsInternalException({
51            #[allow(unused_mut)]
52            let mut tmp = {
53                #[allow(unused_mut)]
54                let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
55                output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
56                    .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
57                let output = output.meta(generic);
58                output.build()
59            };
60            if tmp.message.is_none() {
61                tmp.message = _error_message;
62            }
63            tmp
64        }),
65        "KMSInvalidStateException" => crate::operation::list_key_rotations::ListKeyRotationsError::KmsInvalidStateException({
66            #[allow(unused_mut)]
67            let mut tmp = {
68                #[allow(unused_mut)]
69                let mut output = crate::types::error::builders::KmsInvalidStateExceptionBuilder::default();
70                output = crate::protocol_serde::shape_kms_invalid_state_exception::de_kms_invalid_state_exception_json_err(_response_body, output)
71                    .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
72                let output = output.meta(generic);
73                output.build()
74            };
75            if tmp.message.is_none() {
76                tmp.message = _error_message;
77            }
78            tmp
79        }),
80        "NotFoundException" => crate::operation::list_key_rotations::ListKeyRotationsError::NotFoundException({
81            #[allow(unused_mut)]
82            let mut tmp = {
83                #[allow(unused_mut)]
84                let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
85                output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
86                    .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
87                let output = output.meta(generic);
88                output.build()
89            };
90            if tmp.message.is_none() {
91                tmp.message = _error_message;
92            }
93            tmp
94        }),
95        "UnsupportedOperationException" => crate::operation::list_key_rotations::ListKeyRotationsError::UnsupportedOperationException({
96            #[allow(unused_mut)]
97            let mut tmp = {
98                #[allow(unused_mut)]
99                let mut output = crate::types::error::builders::UnsupportedOperationExceptionBuilder::default();
100                output =
101                    crate::protocol_serde::shape_unsupported_operation_exception::de_unsupported_operation_exception_json_err(_response_body, output)
102                        .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::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        _ => crate::operation::list_key_rotations::ListKeyRotationsError::generic(generic),
112    })
113}
114
115#[allow(clippy::unnecessary_wraps)]
116pub fn de_list_key_rotations_http_response(
117    _response_status: u16,
118    _response_headers: &::aws_smithy_runtime_api::http::Headers,
119    _response_body: &[u8],
120) -> std::result::Result<crate::operation::list_key_rotations::ListKeyRotationsOutput, crate::operation::list_key_rotations::ListKeyRotationsError> {
121    Ok({
122        #[allow(unused_mut)]
123        let mut output = crate::operation::list_key_rotations::builders::ListKeyRotationsOutputBuilder::default();
124        output = crate::protocol_serde::shape_list_key_rotations::de_list_key_rotations(_response_body, output)
125            .map_err(crate::operation::list_key_rotations::ListKeyRotationsError::unhandled)?;
126        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
127        output.build()
128    })
129}
130
131pub fn ser_list_key_rotations_input(
132    input: &crate::operation::list_key_rotations::ListKeyRotationsInput,
133) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
134    let mut out = String::new();
135    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
136    crate::protocol_serde::shape_list_key_rotations_input::ser_list_key_rotations_input_input(&mut object, input)?;
137    object.finish();
138    Ok(::aws_smithy_types::body::SdkBody::from(out))
139}
140
141pub(crate) fn de_list_key_rotations(
142    value: &[u8],
143    mut builder: crate::operation::list_key_rotations::builders::ListKeyRotationsOutputBuilder,
144) -> Result<crate::operation::list_key_rotations::builders::ListKeyRotationsOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
145    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
146    let tokens = &mut tokens_owned;
147    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
148    loop {
149        match tokens.next().transpose()? {
150            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
151            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
152                "Rotations" => {
153                    builder = builder.set_rotations(crate::protocol_serde::shape_rotations_list::de_rotations_list(tokens)?);
154                }
155                "NextMarker" => {
156                    builder = builder.set_next_marker(
157                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
158                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
159                            .transpose()?,
160                    );
161                }
162                "Truncated" => {
163                    builder = builder.set_truncated(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
164                }
165                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
166            },
167            other => {
168                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
169                    "expected object key or end object, found: {:?}",
170                    other
171                )))
172            }
173        }
174    }
175    if tokens.next().is_some() {
176        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
177            "found more JSON tokens after completing parsing",
178        ));
179    }
180    Ok(builder)
181}