aws_sdk_kms/protocol_serde/
shape_delete_custom_key_store.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_custom_key_store_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::delete_custom_key_store::DeleteCustomKeyStoreOutput,
9    crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError,
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::delete_custom_key_store::DeleteCustomKeyStoreError::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::delete_custom_key_store::DeleteCustomKeyStoreError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "CustomKeyStoreHasCMKsException" => crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::CustomKeyStoreHasCmKsException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::CustomKeyStoreHasCmKsExceptionBuilder::default();
28                output = crate::protocol_serde::shape_custom_key_store_has_cmks_exception::de_custom_key_store_has_cmks_exception_json_err(
29                    _response_body,
30                    output,
31                )
32                .map_err(crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::unhandled)?;
33                let output = output.meta(generic);
34                output.build()
35            };
36            if tmp.message.is_none() {
37                tmp.message = _error_message;
38            }
39            tmp
40        }),
41        "CustomKeyStoreInvalidStateException" => {
42            crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::CustomKeyStoreInvalidStateException({
43                #[allow(unused_mut)]
44                let mut tmp = {
45                    #[allow(unused_mut)]
46                    let mut output = crate::types::error::builders::CustomKeyStoreInvalidStateExceptionBuilder::default();
47                    output =
48                        crate::protocol_serde::shape_custom_key_store_invalid_state_exception::de_custom_key_store_invalid_state_exception_json_err(
49                            _response_body,
50                            output,
51                        )
52                        .map_err(crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::unhandled)?;
53                    let output = output.meta(generic);
54                    output.build()
55                };
56                if tmp.message.is_none() {
57                    tmp.message = _error_message;
58                }
59                tmp
60            })
61        }
62        "CustomKeyStoreNotFoundException" => crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::CustomKeyStoreNotFoundException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder::default();
67                output = crate::protocol_serde::shape_custom_key_store_not_found_exception::de_custom_key_store_not_found_exception_json_err(
68                    _response_body,
69                    output,
70                )
71                .map_err(crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::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        "KMSInternalException" => crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::KmsInternalException({
81            #[allow(unused_mut)]
82            let mut tmp = {
83                #[allow(unused_mut)]
84                let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
85                output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
86                    .map_err(crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::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        _ => crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError::generic(generic),
96    })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_delete_custom_key_store_http_response(
101    _response_status: u16,
102    _response_headers: &::aws_smithy_runtime_api::http::Headers,
103    _response_body: &[u8],
104) -> std::result::Result<
105    crate::operation::delete_custom_key_store::DeleteCustomKeyStoreOutput,
106    crate::operation::delete_custom_key_store::DeleteCustomKeyStoreError,
107> {
108    Ok({
109        #[allow(unused_mut)]
110        let mut output = crate::operation::delete_custom_key_store::builders::DeleteCustomKeyStoreOutputBuilder::default();
111        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
112        output.build()
113    })
114}
115
116pub fn ser_delete_custom_key_store_input(
117    input: &crate::operation::delete_custom_key_store::DeleteCustomKeyStoreInput,
118) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
119    let mut out = String::new();
120    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
121    crate::protocol_serde::shape_delete_custom_key_store_input::ser_delete_custom_key_store_input_input(&mut object, input)?;
122    object.finish();
123    Ok(::aws_smithy_types::body::SdkBody::from(out))
124}