aws_sdk_imagebuilder/protocol_serde/
shape_update_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_update_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::update_infrastructure_configuration::UpdateInfrastructureConfigurationOutput,
9    crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError,
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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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        "IdempotentParameterMismatchException" => {
74            crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::IdempotentParameterMismatchException({
75                #[allow(unused_mut)]
76                let mut tmp = {
77                    #[allow(unused_mut)]
78                    let mut output = crate::types::error::builders::IdempotentParameterMismatchExceptionBuilder::default();
79                    output =
80                        crate::protocol_serde::shape_idempotent_parameter_mismatch_exception::de_idempotent_parameter_mismatch_exception_json_err(
81                            _response_body,
82                            output,
83                        )
84                        .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::unhandled)?;
85                    let output = output.meta(generic);
86                    output.build()
87                };
88                if tmp.message.is_none() {
89                    tmp.message = _error_message;
90                }
91                tmp
92            })
93        }
94        "InvalidRequestException" => {
95            crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::InvalidRequestException({
96                #[allow(unused_mut)]
97                let mut tmp = {
98                    #[allow(unused_mut)]
99                    let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
100                    output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
101                        .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::unhandled)?;
102                    let output = output.meta(generic);
103                    output.build()
104                };
105                if tmp.message.is_none() {
106                    tmp.message = _error_message;
107                }
108                tmp
109            })
110        }
111        "ResourceInUseException" => {
112            crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::ResourceInUseException({
113                #[allow(unused_mut)]
114                let mut tmp = {
115                    #[allow(unused_mut)]
116                    let mut output = crate::types::error::builders::ResourceInUseExceptionBuilder::default();
117                    output = crate::protocol_serde::shape_resource_in_use_exception::de_resource_in_use_exception_json_err(_response_body, output)
118                        .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::unhandled)?;
119                    let output = output.meta(generic);
120                    output.build()
121                };
122                if tmp.message.is_none() {
123                    tmp.message = _error_message;
124                }
125                tmp
126            })
127        }
128        "ServiceException" => crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::ServiceException({
129            #[allow(unused_mut)]
130            let mut tmp = {
131                #[allow(unused_mut)]
132                let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
133                output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
134                    .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::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        "ServiceUnavailableException" => {
144            crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::ServiceUnavailableException({
145                #[allow(unused_mut)]
146                let mut tmp = {
147                    #[allow(unused_mut)]
148                    let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
149                    output =
150                        crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
151                            .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::unhandled)?;
152                    let output = output.meta(generic);
153                    output.build()
154                };
155                if tmp.message.is_none() {
156                    tmp.message = _error_message;
157                }
158                tmp
159            })
160        }
161        _ => crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::generic(generic),
162    })
163}
164
165#[allow(clippy::unnecessary_wraps)]
166pub fn de_update_infrastructure_configuration_http_response(
167    _response_status: u16,
168    _response_headers: &::aws_smithy_runtime_api::http::Headers,
169    _response_body: &[u8],
170) -> std::result::Result<
171    crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationOutput,
172    crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError,
173> {
174    Ok({
175        #[allow(unused_mut)]
176        let mut output = crate::operation::update_infrastructure_configuration::builders::UpdateInfrastructureConfigurationOutputBuilder::default();
177        output = crate::protocol_serde::shape_update_infrastructure_configuration::de_update_infrastructure_configuration(_response_body, output)
178            .map_err(crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationError::unhandled)?;
179        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
180        output.build()
181    })
182}
183
184pub fn ser_update_infrastructure_configuration_input(
185    input: &crate::operation::update_infrastructure_configuration::UpdateInfrastructureConfigurationInput,
186) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
187    let mut out = String::new();
188    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
189    crate::protocol_serde::shape_update_infrastructure_configuration_input::ser_update_infrastructure_configuration_input_input(&mut object, input)?;
190    object.finish();
191    Ok(::aws_smithy_types::body::SdkBody::from(out))
192}
193
194pub(crate) fn de_update_infrastructure_configuration(
195    value: &[u8],
196    mut builder: crate::operation::update_infrastructure_configuration::builders::UpdateInfrastructureConfigurationOutputBuilder,
197) -> ::std::result::Result<
198    crate::operation::update_infrastructure_configuration::builders::UpdateInfrastructureConfigurationOutputBuilder,
199    ::aws_smithy_json::deserialize::error::DeserializeError,
200> {
201    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
202    let tokens = &mut tokens_owned;
203    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
204    loop {
205        match tokens.next().transpose()? {
206            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
207            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
208                "clientToken" => {
209                    builder = builder.set_client_token(
210                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
211                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
212                            .transpose()?,
213                    );
214                }
215                "infrastructureConfigurationArn" => {
216                    builder = builder.set_infrastructure_configuration_arn(
217                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
218                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
219                            .transpose()?,
220                    );
221                }
222                "requestId" => {
223                    builder = builder.set_request_id(
224                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
225                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
226                            .transpose()?,
227                    );
228                }
229                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
230            },
231            other => {
232                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
233                    "expected object key or end object, found: {:?}",
234                    other
235                )))
236            }
237        }
238    }
239    if tokens.next().is_some() {
240        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
241            "found more JSON tokens after completing parsing",
242        ));
243    }
244    Ok(builder)
245}