aws_sdk_kms/protocol_serde/
shape_describe_custom_key_stores.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_custom_key_stores_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::describe_custom_key_stores::DescribeCustomKeyStoresOutput,
9    crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError,
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::describe_custom_key_stores::DescribeCustomKeyStoresError::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 => {
19            return Err(crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "CustomKeyStoreNotFoundException" => {
28            crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::CustomKeyStoreNotFoundException({
29                #[allow(unused_mut)]
30                let mut tmp = {
31                    #[allow(unused_mut)]
32                    let mut output = crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder::default();
33                    output = crate::protocol_serde::shape_custom_key_store_not_found_exception::de_custom_key_store_not_found_exception_json_err(
34                        _response_body,
35                        output,
36                    )
37                    .map_err(crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::unhandled)?;
38                    let output = output.meta(generic);
39                    output.build()
40                };
41                if tmp.message.is_none() {
42                    tmp.message = _error_message;
43                }
44                tmp
45            })
46        }
47        "InvalidMarkerException" => crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::InvalidMarkerException({
48            #[allow(unused_mut)]
49            let mut tmp = {
50                #[allow(unused_mut)]
51                let mut output = crate::types::error::builders::InvalidMarkerExceptionBuilder::default();
52                output = crate::protocol_serde::shape_invalid_marker_exception::de_invalid_marker_exception_json_err(_response_body, output)
53                    .map_err(crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::unhandled)?;
54                let output = output.meta(generic);
55                output.build()
56            };
57            if tmp.message.is_none() {
58                tmp.message = _error_message;
59            }
60            tmp
61        }),
62        "KMSInternalException" => crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::KmsInternalException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
67                output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
68                    .map_err(crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::unhandled)?;
69                let output = output.meta(generic);
70                output.build()
71            };
72            if tmp.message.is_none() {
73                tmp.message = _error_message;
74            }
75            tmp
76        }),
77        _ => crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::generic(generic),
78    })
79}
80
81#[allow(clippy::unnecessary_wraps)]
82pub fn de_describe_custom_key_stores_http_response(
83    _response_status: u16,
84    _response_headers: &::aws_smithy_runtime_api::http::Headers,
85    _response_body: &[u8],
86) -> std::result::Result<
87    crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresOutput,
88    crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError,
89> {
90    Ok({
91        #[allow(unused_mut)]
92        let mut output = crate::operation::describe_custom_key_stores::builders::DescribeCustomKeyStoresOutputBuilder::default();
93        output = crate::protocol_serde::shape_describe_custom_key_stores::de_describe_custom_key_stores(_response_body, output)
94            .map_err(crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError::unhandled)?;
95        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
96        output.build()
97    })
98}
99
100pub fn ser_describe_custom_key_stores_input(
101    input: &crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresInput,
102) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
103    let mut out = String::new();
104    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
105    crate::protocol_serde::shape_describe_custom_key_stores_input::ser_describe_custom_key_stores_input_input(&mut object, input)?;
106    object.finish();
107    Ok(::aws_smithy_types::body::SdkBody::from(out))
108}
109
110pub(crate) fn de_describe_custom_key_stores(
111    value: &[u8],
112    mut builder: crate::operation::describe_custom_key_stores::builders::DescribeCustomKeyStoresOutputBuilder,
113) -> Result<
114    crate::operation::describe_custom_key_stores::builders::DescribeCustomKeyStoresOutputBuilder,
115    ::aws_smithy_json::deserialize::error::DeserializeError,
116> {
117    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
118    let tokens = &mut tokens_owned;
119    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
120    loop {
121        match tokens.next().transpose()? {
122            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
123            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
124                "CustomKeyStores" => {
125                    builder = builder.set_custom_key_stores(crate::protocol_serde::shape_custom_key_stores_list::de_custom_key_stores_list(tokens)?);
126                }
127                "NextMarker" => {
128                    builder = builder.set_next_marker(
129                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
130                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
131                            .transpose()?,
132                    );
133                }
134                "Truncated" => {
135                    builder = builder.set_truncated(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
136                }
137                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
138            },
139            other => {
140                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
141                    "expected object key or end object, found: {:?}",
142                    other
143                )))
144            }
145        }
146    }
147    if tokens.next().is_some() {
148        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
149            "found more JSON tokens after completing parsing",
150        ));
151    }
152    Ok(builder)
153}