aws_sdk_quicksight/protocol_serde/
shape_start_dashboard_snapshot_job.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_start_dashboard_snapshot_job_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::start_dashboard_snapshot_job::StartDashboardSnapshotJobOutput,
9    crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError,
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::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::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::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "AccessDeniedException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::AccessDeniedException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
32                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::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        "InternalFailureException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::InternalFailureException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
47                output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        "InvalidParameterValueException" => {
58            crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::InvalidParameterValueException({
59                #[allow(unused_mut)]
60                let mut tmp = {
61                    #[allow(unused_mut)]
62                    let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
63                    output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
64                        _response_body,
65                        output,
66                    )
67                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
68                    let output = output.meta(generic);
69                    output.build()
70                };
71                if tmp.message.is_none() {
72                    tmp.message = _error_message;
73                }
74                tmp
75            })
76        }
77        "LimitExceededException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::LimitExceededException({
78            #[allow(unused_mut)]
79            let mut tmp = {
80                #[allow(unused_mut)]
81                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
82                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
83                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::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        "ResourceExistsException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::ResourceExistsException({
93            #[allow(unused_mut)]
94            let mut tmp = {
95                #[allow(unused_mut)]
96                let mut output = crate::types::error::builders::ResourceExistsExceptionBuilder::default();
97                output = crate::protocol_serde::shape_resource_exists_exception::de_resource_exists_exception_json_err(_response_body, output)
98                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::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        "ResourceNotFoundException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::ResourceNotFoundException({
108            #[allow(unused_mut)]
109            let mut tmp = {
110                #[allow(unused_mut)]
111                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
112                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
113                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
114                let output = output.meta(generic);
115                output.build()
116            };
117            if tmp.message.is_none() {
118                tmp.message = _error_message;
119            }
120            tmp
121        }),
122        "ThrottlingException" => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::ThrottlingException({
123            #[allow(unused_mut)]
124            let mut tmp = {
125                #[allow(unused_mut)]
126                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
127                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
128                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
129                let output = output.meta(generic);
130                output.build()
131            };
132            if tmp.message.is_none() {
133                tmp.message = _error_message;
134            }
135            tmp
136        }),
137        "UnsupportedPricingPlanException" => {
138            crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::UnsupportedPricingPlanException({
139                #[allow(unused_mut)]
140                let mut tmp = {
141                    #[allow(unused_mut)]
142                    let mut output = crate::types::error::builders::UnsupportedPricingPlanExceptionBuilder::default();
143                    output = crate::protocol_serde::shape_unsupported_pricing_plan_exception::de_unsupported_pricing_plan_exception_json_err(
144                        _response_body,
145                        output,
146                    )
147                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
148                    let output = output.meta(generic);
149                    output.build()
150                };
151                if tmp.message.is_none() {
152                    tmp.message = _error_message;
153                }
154                tmp
155            })
156        }
157        "UnsupportedUserEditionException" => {
158            crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::UnsupportedUserEditionException({
159                #[allow(unused_mut)]
160                let mut tmp = {
161                    #[allow(unused_mut)]
162                    let mut output = crate::types::error::builders::UnsupportedUserEditionExceptionBuilder::default();
163                    output = crate::protocol_serde::shape_unsupported_user_edition_exception::de_unsupported_user_edition_exception_json_err(
164                        _response_body,
165                        output,
166                    )
167                    .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
168                    let output = output.meta(generic);
169                    output.build()
170                };
171                if tmp.message.is_none() {
172                    tmp.message = _error_message;
173                }
174                tmp
175            })
176        }
177        _ => crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::generic(generic),
178    })
179}
180
181#[allow(clippy::unnecessary_wraps)]
182pub fn de_start_dashboard_snapshot_job_http_response(
183    _response_status: u16,
184    _response_headers: &::aws_smithy_runtime_api::http::Headers,
185    _response_body: &[u8],
186) -> std::result::Result<
187    crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobOutput,
188    crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError,
189> {
190    Ok({
191        #[allow(unused_mut)]
192        let mut output = crate::operation::start_dashboard_snapshot_job::builders::StartDashboardSnapshotJobOutputBuilder::default();
193        output = crate::protocol_serde::shape_start_dashboard_snapshot_job::de_start_dashboard_snapshot_job(_response_body, output)
194            .map_err(crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobError::unhandled)?;
195        output = output.set_status(Some(_response_status as _));
196        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
197        output.build()
198    })
199}
200
201pub fn ser_start_dashboard_snapshot_job_input(
202    input: &crate::operation::start_dashboard_snapshot_job::StartDashboardSnapshotJobInput,
203) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
204    let mut out = String::new();
205    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
206    crate::protocol_serde::shape_start_dashboard_snapshot_job_input::ser_start_dashboard_snapshot_job_input_input(&mut object, input)?;
207    object.finish();
208    Ok(::aws_smithy_types::body::SdkBody::from(out))
209}
210
211pub(crate) fn de_start_dashboard_snapshot_job(
212    value: &[u8],
213    mut builder: crate::operation::start_dashboard_snapshot_job::builders::StartDashboardSnapshotJobOutputBuilder,
214) -> ::std::result::Result<
215    crate::operation::start_dashboard_snapshot_job::builders::StartDashboardSnapshotJobOutputBuilder,
216    ::aws_smithy_json::deserialize::error::DeserializeError,
217> {
218    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
219    let tokens = &mut tokens_owned;
220    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
221    loop {
222        match tokens.next().transpose()? {
223            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
224            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
225                "Arn" => {
226                    builder = builder.set_arn(
227                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
228                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
229                            .transpose()?,
230                    );
231                }
232                "RequestId" => {
233                    builder = builder.set_request_id(
234                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
235                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
236                            .transpose()?,
237                    );
238                }
239                "SnapshotJobId" => {
240                    builder = builder.set_snapshot_job_id(
241                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
242                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
243                            .transpose()?,
244                    );
245                }
246                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
247            },
248            other => {
249                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
250                    "expected object key or end object, found: {:?}",
251                    other
252                )))
253            }
254        }
255    }
256    if tokens.next().is_some() {
257        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
258            "found more JSON tokens after completing parsing",
259        ));
260    }
261    Ok(builder)
262}