aws_sdk_codedeploy/protocol_serde/
shape_batch_get_deployment_targets.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_get_deployment_targets_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::batch_get_deployment_targets::BatchGetDeploymentTargetsOutput,
9    crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError,
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::batch_get_deployment_targets::BatchGetDeploymentTargetsError::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::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "DeploymentDoesNotExistException" => {
28            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentDoesNotExistException({
29                #[allow(unused_mut)]
30                let mut tmp = {
31                    #[allow(unused_mut)]
32                    let mut output = crate::types::error::builders::DeploymentDoesNotExistExceptionBuilder::default();
33                    output = crate::protocol_serde::shape_deployment_does_not_exist_exception::de_deployment_does_not_exist_exception_json_err(
34                        _response_body,
35                        output,
36                    )
37                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::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        "DeploymentIdRequiredException" => {
48            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentIdRequiredException({
49                #[allow(unused_mut)]
50                let mut tmp = {
51                    #[allow(unused_mut)]
52                    let mut output = crate::types::error::builders::DeploymentIdRequiredExceptionBuilder::default();
53                    output = crate::protocol_serde::shape_deployment_id_required_exception::de_deployment_id_required_exception_json_err(
54                        _response_body,
55                        output,
56                    )
57                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
58                    let output = output.meta(generic);
59                    output.build()
60                };
61                if tmp.message.is_none() {
62                    tmp.message = _error_message;
63                }
64                tmp
65            })
66        }
67        "DeploymentNotStartedException" => {
68            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentNotStartedException({
69                #[allow(unused_mut)]
70                let mut tmp = {
71                    #[allow(unused_mut)]
72                    let mut output = crate::types::error::builders::DeploymentNotStartedExceptionBuilder::default();
73                    output = crate::protocol_serde::shape_deployment_not_started_exception::de_deployment_not_started_exception_json_err(
74                        _response_body,
75                        output,
76                    )
77                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
78                    let output = output.meta(generic);
79                    output.build()
80                };
81                if tmp.message.is_none() {
82                    tmp.message = _error_message;
83                }
84                tmp
85            })
86        }
87        "DeploymentTargetDoesNotExistException" => {
88            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentTargetDoesNotExistException({
89                #[allow(unused_mut)]
90                let mut tmp = {
91                    #[allow(unused_mut)]
92                    let mut output = crate::types::error::builders::DeploymentTargetDoesNotExistExceptionBuilder::default();
93                    output = crate::protocol_serde::shape_deployment_target_does_not_exist_exception::de_deployment_target_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
94                    let output = output.meta(generic);
95                    output.build()
96                };
97                if tmp.message.is_none() {
98                    tmp.message = _error_message;
99                }
100                tmp
101            })
102        }
103        "DeploymentTargetIdRequiredException" => {
104            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentTargetIdRequiredException({
105                #[allow(unused_mut)]
106                let mut tmp = {
107                    #[allow(unused_mut)]
108                    let mut output = crate::types::error::builders::DeploymentTargetIdRequiredExceptionBuilder::default();
109                    output =
110                        crate::protocol_serde::shape_deployment_target_id_required_exception::de_deployment_target_id_required_exception_json_err(
111                            _response_body,
112                            output,
113                        )
114                        .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::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        }
124        "DeploymentTargetListSizeExceededException" => {
125            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::DeploymentTargetListSizeExceededException({
126                #[allow(unused_mut)]
127                let mut tmp = {
128                    #[allow(unused_mut)]
129                    let mut output = crate::types::error::builders::DeploymentTargetListSizeExceededExceptionBuilder::default();
130                    output = crate::protocol_serde::shape_deployment_target_list_size_exceeded_exception::de_deployment_target_list_size_exceeded_exception_json_err(_response_body, output).map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
131                    let output = output.meta(generic);
132                    output.build()
133                };
134                if tmp.message.is_none() {
135                    tmp.message = _error_message;
136                }
137                tmp
138            })
139        }
140        "InstanceDoesNotExistException" => {
141            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::InstanceDoesNotExistException({
142                #[allow(unused_mut)]
143                let mut tmp = {
144                    #[allow(unused_mut)]
145                    let mut output = crate::types::error::builders::InstanceDoesNotExistExceptionBuilder::default();
146                    output = crate::protocol_serde::shape_instance_does_not_exist_exception::de_instance_does_not_exist_exception_json_err(
147                        _response_body,
148                        output,
149                    )
150                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
151                    let output = output.meta(generic);
152                    output.build()
153                };
154                if tmp.message.is_none() {
155                    tmp.message = _error_message;
156                }
157                tmp
158            })
159        }
160        "InvalidDeploymentIdException" => {
161            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::InvalidDeploymentIdException({
162                #[allow(unused_mut)]
163                let mut tmp = {
164                    #[allow(unused_mut)]
165                    let mut output = crate::types::error::builders::InvalidDeploymentIdExceptionBuilder::default();
166                    output = crate::protocol_serde::shape_invalid_deployment_id_exception::de_invalid_deployment_id_exception_json_err(
167                        _response_body,
168                        output,
169                    )
170                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
171                    let output = output.meta(generic);
172                    output.build()
173                };
174                if tmp.message.is_none() {
175                    tmp.message = _error_message;
176                }
177                tmp
178            })
179        }
180        "InvalidDeploymentTargetIdException" => {
181            crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::InvalidDeploymentTargetIdException({
182                #[allow(unused_mut)]
183                let mut tmp = {
184                    #[allow(unused_mut)]
185                    let mut output = crate::types::error::builders::InvalidDeploymentTargetIdExceptionBuilder::default();
186                    output = crate::protocol_serde::shape_invalid_deployment_target_id_exception::de_invalid_deployment_target_id_exception_json_err(
187                        _response_body,
188                        output,
189                    )
190                    .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
191                    let output = output.meta(generic);
192                    output.build()
193                };
194                if tmp.message.is_none() {
195                    tmp.message = _error_message;
196                }
197                tmp
198            })
199        }
200        _ => crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::generic(generic),
201    })
202}
203
204#[allow(clippy::unnecessary_wraps)]
205pub fn de_batch_get_deployment_targets_http_response(
206    _response_status: u16,
207    _response_headers: &::aws_smithy_runtime_api::http::Headers,
208    _response_body: &[u8],
209) -> std::result::Result<
210    crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsOutput,
211    crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError,
212> {
213    Ok({
214        #[allow(unused_mut)]
215        let mut output = crate::operation::batch_get_deployment_targets::builders::BatchGetDeploymentTargetsOutputBuilder::default();
216        output = crate::protocol_serde::shape_batch_get_deployment_targets::de_batch_get_deployment_targets(_response_body, output)
217            .map_err(crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsError::unhandled)?;
218        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
219        output.build()
220    })
221}
222
223pub fn ser_batch_get_deployment_targets_input(
224    input: &crate::operation::batch_get_deployment_targets::BatchGetDeploymentTargetsInput,
225) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
226    let mut out = String::new();
227    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
228    crate::protocol_serde::shape_batch_get_deployment_targets_input::ser_batch_get_deployment_targets_input_input(&mut object, input)?;
229    object.finish();
230    Ok(::aws_smithy_types::body::SdkBody::from(out))
231}
232
233pub(crate) fn de_batch_get_deployment_targets(
234    value: &[u8],
235    mut builder: crate::operation::batch_get_deployment_targets::builders::BatchGetDeploymentTargetsOutputBuilder,
236) -> ::std::result::Result<
237    crate::operation::batch_get_deployment_targets::builders::BatchGetDeploymentTargetsOutputBuilder,
238    ::aws_smithy_json::deserialize::error::DeserializeError,
239> {
240    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
241    let tokens = &mut tokens_owned;
242    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
243    loop {
244        match tokens.next().transpose()? {
245            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
246            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
247                "deploymentTargets" => {
248                    builder = builder.set_deployment_targets(crate::protocol_serde::shape_deployment_target_list::de_deployment_target_list(tokens)?);
249                }
250                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
251            },
252            other => {
253                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
254                    "expected object key or end object, found: {:?}",
255                    other
256                )))
257            }
258        }
259    }
260    if tokens.next().is_some() {
261        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
262            "found more JSON tokens after completing parsing",
263        ));
264    }
265    Ok(builder)
266}