aws_sdk_imagebuilder/protocol_serde/
shape_send_workflow_step_action.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_send_workflow_step_action_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::send_workflow_step_action::SendWorkflowStepActionOutput,
9    crate::operation::send_workflow_step_action::SendWorkflowStepActionError,
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::send_workflow_step_action::SendWorkflowStepActionError::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::send_workflow_step_action::SendWorkflowStepActionError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "CallRateLimitExceededException" => {
28            crate::operation::send_workflow_step_action::SendWorkflowStepActionError::CallRateLimitExceededException({
29                #[allow(unused_mut)]
30                let mut tmp = {
31                    #[allow(unused_mut)]
32                    let mut output = crate::types::error::builders::CallRateLimitExceededExceptionBuilder::default();
33                    output = crate::protocol_serde::shape_call_rate_limit_exceeded_exception::de_call_rate_limit_exceeded_exception_json_err(
34                        _response_body,
35                        output,
36                    )
37                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::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        "ClientException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ClientException({
48            #[allow(unused_mut)]
49            let mut tmp = {
50                #[allow(unused_mut)]
51                let mut output = crate::types::error::builders::ClientExceptionBuilder::default();
52                output = crate::protocol_serde::shape_client_exception::de_client_exception_json_err(_response_body, output)
53                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::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        "ForbiddenException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ForbiddenException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
67                output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_json_err(_response_body, output)
68                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::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        "IdempotentParameterMismatchException" => {
78            crate::operation::send_workflow_step_action::SendWorkflowStepActionError::IdempotentParameterMismatchException({
79                #[allow(unused_mut)]
80                let mut tmp = {
81                    #[allow(unused_mut)]
82                    let mut output = crate::types::error::builders::IdempotentParameterMismatchExceptionBuilder::default();
83                    output =
84                        crate::protocol_serde::shape_idempotent_parameter_mismatch_exception::de_idempotent_parameter_mismatch_exception_json_err(
85                            _response_body,
86                            output,
87                        )
88                        .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
89                    let output = output.meta(generic);
90                    output.build()
91                };
92                if tmp.message.is_none() {
93                    tmp.message = _error_message;
94                }
95                tmp
96            })
97        }
98        "InvalidParameterValueException" => {
99            crate::operation::send_workflow_step_action::SendWorkflowStepActionError::InvalidParameterValueException({
100                #[allow(unused_mut)]
101                let mut tmp = {
102                    #[allow(unused_mut)]
103                    let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
104                    output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
105                        _response_body,
106                        output,
107                    )
108                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
109                    let output = output.meta(generic);
110                    output.build()
111                };
112                if tmp.message.is_none() {
113                    tmp.message = _error_message;
114                }
115                tmp
116            })
117        }
118        "InvalidRequestException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::InvalidRequestException({
119            #[allow(unused_mut)]
120            let mut tmp = {
121                #[allow(unused_mut)]
122                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
123                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
124                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
125                let output = output.meta(generic);
126                output.build()
127            };
128            if tmp.message.is_none() {
129                tmp.message = _error_message;
130            }
131            tmp
132        }),
133        "ResourceInUseException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ResourceInUseException({
134            #[allow(unused_mut)]
135            let mut tmp = {
136                #[allow(unused_mut)]
137                let mut output = crate::types::error::builders::ResourceInUseExceptionBuilder::default();
138                output = crate::protocol_serde::shape_resource_in_use_exception::de_resource_in_use_exception_json_err(_response_body, output)
139                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
140                let output = output.meta(generic);
141                output.build()
142            };
143            if tmp.message.is_none() {
144                tmp.message = _error_message;
145            }
146            tmp
147        }),
148        "ResourceNotFoundException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ResourceNotFoundException({
149            #[allow(unused_mut)]
150            let mut tmp = {
151                #[allow(unused_mut)]
152                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
153                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
154                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
155                let output = output.meta(generic);
156                output.build()
157            };
158            if tmp.message.is_none() {
159                tmp.message = _error_message;
160            }
161            tmp
162        }),
163        "ServiceException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ServiceException({
164            #[allow(unused_mut)]
165            let mut tmp = {
166                #[allow(unused_mut)]
167                let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
168                output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
169                    .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
170                let output = output.meta(generic);
171                output.build()
172            };
173            if tmp.message.is_none() {
174                tmp.message = _error_message;
175            }
176            tmp
177        }),
178        "ServiceUnavailableException" => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::ServiceUnavailableException({
179            #[allow(unused_mut)]
180            let mut tmp = {
181                #[allow(unused_mut)]
182                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
183                output =
184                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
185                        .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
186                let output = output.meta(generic);
187                output.build()
188            };
189            if tmp.message.is_none() {
190                tmp.message = _error_message;
191            }
192            tmp
193        }),
194        _ => crate::operation::send_workflow_step_action::SendWorkflowStepActionError::generic(generic),
195    })
196}
197
198#[allow(clippy::unnecessary_wraps)]
199pub fn de_send_workflow_step_action_http_response(
200    _response_status: u16,
201    _response_headers: &::aws_smithy_runtime_api::http::Headers,
202    _response_body: &[u8],
203) -> std::result::Result<
204    crate::operation::send_workflow_step_action::SendWorkflowStepActionOutput,
205    crate::operation::send_workflow_step_action::SendWorkflowStepActionError,
206> {
207    Ok({
208        #[allow(unused_mut)]
209        let mut output = crate::operation::send_workflow_step_action::builders::SendWorkflowStepActionOutputBuilder::default();
210        output = crate::protocol_serde::shape_send_workflow_step_action::de_send_workflow_step_action(_response_body, output)
211            .map_err(crate::operation::send_workflow_step_action::SendWorkflowStepActionError::unhandled)?;
212        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
213        output.build()
214    })
215}
216
217pub fn ser_send_workflow_step_action_input(
218    input: &crate::operation::send_workflow_step_action::SendWorkflowStepActionInput,
219) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
220    let mut out = String::new();
221    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
222    crate::protocol_serde::shape_send_workflow_step_action_input::ser_send_workflow_step_action_input_input(&mut object, input)?;
223    object.finish();
224    Ok(::aws_smithy_types::body::SdkBody::from(out))
225}
226
227pub(crate) fn de_send_workflow_step_action(
228    value: &[u8],
229    mut builder: crate::operation::send_workflow_step_action::builders::SendWorkflowStepActionOutputBuilder,
230) -> ::std::result::Result<
231    crate::operation::send_workflow_step_action::builders::SendWorkflowStepActionOutputBuilder,
232    ::aws_smithy_json::deserialize::error::DeserializeError,
233> {
234    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
235    let tokens = &mut tokens_owned;
236    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
237    loop {
238        match tokens.next().transpose()? {
239            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
240            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
241                "clientToken" => {
242                    builder = builder.set_client_token(
243                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
244                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
245                            .transpose()?,
246                    );
247                }
248                "imageBuildVersionArn" => {
249                    builder = builder.set_image_build_version_arn(
250                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
251                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
252                            .transpose()?,
253                    );
254                }
255                "stepExecutionId" => {
256                    builder = builder.set_step_execution_id(
257                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
258                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
259                            .transpose()?,
260                    );
261                }
262                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
263            },
264            other => {
265                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
266                    "expected object key or end object, found: {:?}",
267                    other
268                )))
269            }
270        }
271    }
272    if tokens.next().is_some() {
273        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
274            "found more JSON tokens after completing parsing",
275        ));
276    }
277    Ok(builder)
278}