aws_sdk_imagebuilder/protocol_serde/
shape_delete_infrastructure_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_infrastructure_configuration_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_infrastructure_configuration::DeleteInfrastructureConfigurationOutput,
9    crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError,
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_infrastructure_configuration::DeleteInfrastructureConfigurationError::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_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "CallRateLimitExceededException" => {
24            crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::CallRateLimitExceededException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::CallRateLimitExceededExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_call_rate_limit_exceeded_exception::de_call_rate_limit_exceeded_exception_json_err(
30                        _response_body,
31                        output,
32                    )
33                    .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
34                    let output = output.meta(generic);
35                    output.build()
36                };
37                if tmp.message.is_none() {
38                    tmp.message = _error_message;
39                }
40                tmp
41            })
42        }
43        "ClientException" => crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::ClientException({
44            #[allow(unused_mut)]
45            let mut tmp = {
46                #[allow(unused_mut)]
47                let mut output = crate::types::error::builders::ClientExceptionBuilder::default();
48                output = crate::protocol_serde::shape_client_exception::de_client_exception_json_err(_response_body, output)
49                    .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
50                let output = output.meta(generic);
51                output.build()
52            };
53            if tmp.message.is_none() {
54                tmp.message = _error_message;
55            }
56            tmp
57        }),
58        "ForbiddenException" => crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::ForbiddenException({
59            #[allow(unused_mut)]
60            let mut tmp = {
61                #[allow(unused_mut)]
62                let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
63                output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_json_err(_response_body, output)
64                    .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
65                let output = output.meta(generic);
66                output.build()
67            };
68            if tmp.message.is_none() {
69                tmp.message = _error_message;
70            }
71            tmp
72        }),
73        "InvalidRequestException" => {
74            crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::InvalidRequestException({
75                #[allow(unused_mut)]
76                let mut tmp = {
77                    #[allow(unused_mut)]
78                    let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
79                    output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
80                        .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
81                    let output = output.meta(generic);
82                    output.build()
83                };
84                if tmp.message.is_none() {
85                    tmp.message = _error_message;
86                }
87                tmp
88            })
89        }
90        "ResourceDependencyException" => {
91            crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::ResourceDependencyException({
92                #[allow(unused_mut)]
93                let mut tmp = {
94                    #[allow(unused_mut)]
95                    let mut output = crate::types::error::builders::ResourceDependencyExceptionBuilder::default();
96                    output =
97                        crate::protocol_serde::shape_resource_dependency_exception::de_resource_dependency_exception_json_err(_response_body, output)
98                            .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
99                    let output = output.meta(generic);
100                    output.build()
101                };
102                if tmp.message.is_none() {
103                    tmp.message = _error_message;
104                }
105                tmp
106            })
107        }
108        "ServiceException" => crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::ServiceException({
109            #[allow(unused_mut)]
110            let mut tmp = {
111                #[allow(unused_mut)]
112                let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
113                output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
114                    .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
115                let output = output.meta(generic);
116                output.build()
117            };
118            if tmp.message.is_none() {
119                tmp.message = _error_message;
120            }
121            tmp
122        }),
123        "ServiceUnavailableException" => {
124            crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::ServiceUnavailableException({
125                #[allow(unused_mut)]
126                let mut tmp = {
127                    #[allow(unused_mut)]
128                    let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
129                    output =
130                        crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
131                            .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
132                    let output = output.meta(generic);
133                    output.build()
134                };
135                if tmp.message.is_none() {
136                    tmp.message = _error_message;
137                }
138                tmp
139            })
140        }
141        _ => crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::generic(generic),
142    })
143}
144
145#[allow(clippy::unnecessary_wraps)]
146pub fn de_delete_infrastructure_configuration_http_response(
147    _response_status: u16,
148    _response_headers: &::aws_smithy_runtime_api::http::Headers,
149    _response_body: &[u8],
150) -> std::result::Result<
151    crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationOutput,
152    crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError,
153> {
154    Ok({
155        #[allow(unused_mut)]
156        let mut output = crate::operation::delete_infrastructure_configuration::builders::DeleteInfrastructureConfigurationOutputBuilder::default();
157        output = crate::protocol_serde::shape_delete_infrastructure_configuration::de_delete_infrastructure_configuration(_response_body, output)
158            .map_err(crate::operation::delete_infrastructure_configuration::DeleteInfrastructureConfigurationError::unhandled)?;
159        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
160        output.build()
161    })
162}
163
164pub(crate) fn de_delete_infrastructure_configuration(
165    value: &[u8],
166    mut builder: crate::operation::delete_infrastructure_configuration::builders::DeleteInfrastructureConfigurationOutputBuilder,
167) -> ::std::result::Result<
168    crate::operation::delete_infrastructure_configuration::builders::DeleteInfrastructureConfigurationOutputBuilder,
169    ::aws_smithy_json::deserialize::error::DeserializeError,
170> {
171    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
172    let tokens = &mut tokens_owned;
173    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
174    loop {
175        match tokens.next().transpose()? {
176            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
177            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
178                "infrastructureConfigurationArn" => {
179                    builder = builder.set_infrastructure_configuration_arn(
180                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
181                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
182                            .transpose()?,
183                    );
184                }
185                "requestId" => {
186                    builder = builder.set_request_id(
187                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
188                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
189                            .transpose()?,
190                    );
191                }
192                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
193            },
194            other => {
195                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
196                    "expected object key or end object, found: {:?}",
197                    other
198                )))
199            }
200        }
201    }
202    if tokens.next().is_some() {
203        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
204            "found more JSON tokens after completing parsing",
205        ));
206    }
207    Ok(builder)
208}