aws_sdk_proton/protocol_serde/
shape_create_template_sync_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_template_sync_config_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::create_template_sync_config::CreateTemplateSyncConfigOutput,
9    crate::operation::create_template_sync_config::CreateTemplateSyncConfigError,
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::create_template_sync_config::CreateTemplateSyncConfigError::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::create_template_sync_config::CreateTemplateSyncConfigError::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::create_template_sync_config::CreateTemplateSyncConfigError::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::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
34                let output = output.meta(generic);
35                crate::serde_util::access_denied_exception_correct_errors(output)
36                    .build()
37                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
38            };
39            tmp
40        }),
41        "ConflictException" => crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::ConflictException({
42            #[allow(unused_mut)]
43            let mut tmp = {
44                #[allow(unused_mut)]
45                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
46                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
47                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
48                let output = output.meta(generic);
49                crate::serde_util::conflict_exception_correct_errors(output)
50                    .build()
51                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
52            };
53            tmp
54        }),
55        "InternalServerException" => crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::InternalServerException({
56            #[allow(unused_mut)]
57            let mut tmp = {
58                #[allow(unused_mut)]
59                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
60                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
61                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
62                let output = output.meta(generic);
63                crate::serde_util::internal_server_exception_correct_errors(output)
64                    .build()
65                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
66            };
67            tmp
68        }),
69        "ServiceQuotaExceededException" => {
70            crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::ServiceQuotaExceededException({
71                #[allow(unused_mut)]
72                let mut tmp = {
73                    #[allow(unused_mut)]
74                    let mut output = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
75                    output = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
76                        _response_body,
77                        output,
78                    )
79                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
80                    let output = output.meta(generic);
81                    crate::serde_util::service_quota_exceeded_exception_correct_errors(output)
82                        .build()
83                        .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
84                };
85                tmp
86            })
87        }
88        "ThrottlingException" => crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::ThrottlingException({
89            #[allow(unused_mut)]
90            let mut tmp = {
91                #[allow(unused_mut)]
92                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
93                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
94                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
95                let output = output.meta(generic);
96                crate::serde_util::throttling_exception_correct_errors(output)
97                    .build()
98                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
99            };
100            tmp
101        }),
102        "ValidationException" => crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::ValidationException({
103            #[allow(unused_mut)]
104            let mut tmp = {
105                #[allow(unused_mut)]
106                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
107                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
108                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
109                let output = output.meta(generic);
110                crate::serde_util::validation_exception_correct_errors(output)
111                    .build()
112                    .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?
113            };
114            tmp
115        }),
116        _ => crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::generic(generic),
117    })
118}
119
120#[allow(clippy::unnecessary_wraps)]
121pub fn de_create_template_sync_config_http_response(
122    _response_status: u16,
123    _response_headers: &::aws_smithy_runtime_api::http::Headers,
124    _response_body: &[u8],
125) -> std::result::Result<
126    crate::operation::create_template_sync_config::CreateTemplateSyncConfigOutput,
127    crate::operation::create_template_sync_config::CreateTemplateSyncConfigError,
128> {
129    Ok({
130        #[allow(unused_mut)]
131        let mut output = crate::operation::create_template_sync_config::builders::CreateTemplateSyncConfigOutputBuilder::default();
132        output = crate::protocol_serde::shape_create_template_sync_config::de_create_template_sync_config(_response_body, output)
133            .map_err(crate::operation::create_template_sync_config::CreateTemplateSyncConfigError::unhandled)?;
134        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
135        output.build()
136    })
137}
138
139pub fn ser_create_template_sync_config_input(
140    input: &crate::operation::create_template_sync_config::CreateTemplateSyncConfigInput,
141) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
142    let mut out = String::new();
143    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
144    crate::protocol_serde::shape_create_template_sync_config_input::ser_create_template_sync_config_input_input(&mut object, input)?;
145    object.finish();
146    Ok(::aws_smithy_types::body::SdkBody::from(out))
147}
148
149pub(crate) fn de_create_template_sync_config(
150    value: &[u8],
151    mut builder: crate::operation::create_template_sync_config::builders::CreateTemplateSyncConfigOutputBuilder,
152) -> ::std::result::Result<
153    crate::operation::create_template_sync_config::builders::CreateTemplateSyncConfigOutputBuilder,
154    ::aws_smithy_json::deserialize::error::DeserializeError,
155> {
156    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
157    let tokens = &mut tokens_owned;
158    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
159    loop {
160        match tokens.next().transpose()? {
161            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
162            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
163                "templateSyncConfig" => {
164                    builder = builder.set_template_sync_config(crate::protocol_serde::shape_template_sync_config::de_template_sync_config(tokens)?);
165                }
166                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
167            },
168            other => {
169                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
170                    "expected object key or end object, found: {:?}",
171                    other
172                )))
173            }
174        }
175    }
176    if tokens.next().is_some() {
177        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
178            "found more JSON tokens after completing parsing",
179        ));
180    }
181    Ok(builder)
182}