aws_sdk_imagebuilder/protocol_serde/
shape_get_workflow_step_execution.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_workflow_step_execution_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::get_workflow_step_execution::GetWorkflowStepExecutionOutput,
9    crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError,
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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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::get_workflow_step_execution::GetWorkflowStepExecutionError::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        "InvalidRequestException" => crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::InvalidRequestException({
78            #[allow(unused_mut)]
79            let mut tmp = {
80                #[allow(unused_mut)]
81                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
82                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
83                    .map_err(crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::unhandled)?;
84                let output = output.meta(generic);
85                output.build()
86            };
87            if tmp.message.is_none() {
88                tmp.message = _error_message;
89            }
90            tmp
91        }),
92        "ServiceException" => crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::ServiceException({
93            #[allow(unused_mut)]
94            let mut tmp = {
95                #[allow(unused_mut)]
96                let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
97                output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
98                    .map_err(crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::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        "ServiceUnavailableException" => crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::ServiceUnavailableException({
108            #[allow(unused_mut)]
109            let mut tmp = {
110                #[allow(unused_mut)]
111                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
112                output =
113                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
114                        .map_err(crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::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        _ => crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::generic(generic),
124    })
125}
126
127#[allow(clippy::unnecessary_wraps)]
128pub fn de_get_workflow_step_execution_http_response(
129    _response_status: u16,
130    _response_headers: &::aws_smithy_runtime_api::http::Headers,
131    _response_body: &[u8],
132) -> std::result::Result<
133    crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionOutput,
134    crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError,
135> {
136    Ok({
137        #[allow(unused_mut)]
138        let mut output = crate::operation::get_workflow_step_execution::builders::GetWorkflowStepExecutionOutputBuilder::default();
139        output = crate::protocol_serde::shape_get_workflow_step_execution::de_get_workflow_step_execution(_response_body, output)
140            .map_err(crate::operation::get_workflow_step_execution::GetWorkflowStepExecutionError::unhandled)?;
141        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
142        output.build()
143    })
144}
145
146pub(crate) fn de_get_workflow_step_execution(
147    value: &[u8],
148    mut builder: crate::operation::get_workflow_step_execution::builders::GetWorkflowStepExecutionOutputBuilder,
149) -> ::std::result::Result<
150    crate::operation::get_workflow_step_execution::builders::GetWorkflowStepExecutionOutputBuilder,
151    ::aws_smithy_json::deserialize::error::DeserializeError,
152> {
153    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
154    let tokens = &mut tokens_owned;
155    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
156    loop {
157        match tokens.next().transpose()? {
158            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
159            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
160                "action" => {
161                    builder = builder.set_action(
162                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
163                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
164                            .transpose()?,
165                    );
166                }
167                "description" => {
168                    builder = builder.set_description(
169                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
170                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
171                            .transpose()?,
172                    );
173                }
174                "endTime" => {
175                    builder = builder.set_end_time(
176                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
177                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
178                            .transpose()?,
179                    );
180                }
181                "imageBuildVersionArn" => {
182                    builder = builder.set_image_build_version_arn(
183                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
184                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
185                            .transpose()?,
186                    );
187                }
188                "inputs" => {
189                    builder = builder.set_inputs(
190                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
191                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
192                            .transpose()?,
193                    );
194                }
195                "message" => {
196                    builder = builder.set_message(
197                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
198                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
199                            .transpose()?,
200                    );
201                }
202                "name" => {
203                    builder = builder.set_name(
204                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
205                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
206                            .transpose()?,
207                    );
208                }
209                "onFailure" => {
210                    builder = builder.set_on_failure(
211                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
212                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
213                            .transpose()?,
214                    );
215                }
216                "outputs" => {
217                    builder = builder.set_outputs(
218                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
219                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
220                            .transpose()?,
221                    );
222                }
223                "requestId" => {
224                    builder = builder.set_request_id(
225                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
226                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
227                            .transpose()?,
228                    );
229                }
230                "rollbackStatus" => {
231                    builder = builder.set_rollback_status(
232                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
233                            .map(|s| {
234                                s.to_unescaped()
235                                    .map(|u| crate::types::WorkflowStepExecutionRollbackStatus::from(u.as_ref()))
236                            })
237                            .transpose()?,
238                    );
239                }
240                "startTime" => {
241                    builder = builder.set_start_time(
242                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
243                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
244                            .transpose()?,
245                    );
246                }
247                "status" => {
248                    builder = builder.set_status(
249                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
250                            .map(|s| s.to_unescaped().map(|u| crate::types::WorkflowStepExecutionStatus::from(u.as_ref())))
251                            .transpose()?,
252                    );
253                }
254                "stepExecutionId" => {
255                    builder = builder.set_step_execution_id(
256                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
257                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
258                            .transpose()?,
259                    );
260                }
261                "timeoutSeconds" => {
262                    builder = builder.set_timeout_seconds(
263                        ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
264                            .map(i32::try_from)
265                            .transpose()?,
266                    );
267                }
268                "workflowBuildVersionArn" => {
269                    builder = builder.set_workflow_build_version_arn(
270                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
271                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
272                            .transpose()?,
273                    );
274                }
275                "workflowExecutionId" => {
276                    builder = builder.set_workflow_execution_id(
277                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
278                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
279                            .transpose()?,
280                    );
281                }
282                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
283            },
284            other => {
285                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
286                    "expected object key or end object, found: {:?}",
287                    other
288                )))
289            }
290        }
291    }
292    if tokens.next().is_some() {
293        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
294            "found more JSON tokens after completing parsing",
295        ));
296    }
297    Ok(builder)
298}