aws_sdk_codestarconnections/protocol_serde/
shape_create_sync_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_sync_configuration_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_sync_configuration::CreateSyncConfigurationOutput,
9    crate::operation::create_sync_configuration::CreateSyncConfigurationError,
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_sync_configuration::CreateSyncConfigurationError::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_sync_configuration::CreateSyncConfigurationError::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_sync_configuration::CreateSyncConfigurationError::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_sync_configuration::CreateSyncConfigurationError::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        "ConcurrentModificationException" => {
43            crate::operation::create_sync_configuration::CreateSyncConfigurationError::ConcurrentModificationException({
44                #[allow(unused_mut)]
45                let mut tmp = {
46                    #[allow(unused_mut)]
47                    let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
48                    output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
49                        _response_body,
50                        output,
51                    )
52                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::unhandled)?;
53                    let output = output.meta(generic);
54                    output.build()
55                };
56                if tmp.message.is_none() {
57                    tmp.message = _error_message;
58                }
59                tmp
60            })
61        }
62        "InternalServerException" => crate::operation::create_sync_configuration::CreateSyncConfigurationError::InternalServerException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
67                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
68                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::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        "InvalidInputException" => crate::operation::create_sync_configuration::CreateSyncConfigurationError::InvalidInputException({
78            #[allow(unused_mut)]
79            let mut tmp = {
80                #[allow(unused_mut)]
81                let mut output = crate::types::error::builders::InvalidInputExceptionBuilder::default();
82                output = crate::protocol_serde::shape_invalid_input_exception::de_invalid_input_exception_json_err(_response_body, output)
83                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::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        "LimitExceededException" => crate::operation::create_sync_configuration::CreateSyncConfigurationError::LimitExceededException({
93            #[allow(unused_mut)]
94            let mut tmp = {
95                #[allow(unused_mut)]
96                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
97                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
98                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::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        "ResourceAlreadyExistsException" => {
108            crate::operation::create_sync_configuration::CreateSyncConfigurationError::ResourceAlreadyExistsException({
109                #[allow(unused_mut)]
110                let mut tmp = {
111                    #[allow(unused_mut)]
112                    let mut output = crate::types::error::builders::ResourceAlreadyExistsExceptionBuilder::default();
113                    output = crate::protocol_serde::shape_resource_already_exists_exception::de_resource_already_exists_exception_json_err(
114                        _response_body,
115                        output,
116                    )
117                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::unhandled)?;
118                    let output = output.meta(generic);
119                    output.build()
120                };
121                if tmp.message.is_none() {
122                    tmp.message = _error_message;
123                }
124                tmp
125            })
126        }
127        "ThrottlingException" => crate::operation::create_sync_configuration::CreateSyncConfigurationError::ThrottlingException({
128            #[allow(unused_mut)]
129            let mut tmp = {
130                #[allow(unused_mut)]
131                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
132                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
133                    .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::unhandled)?;
134                let output = output.meta(generic);
135                output.build()
136            };
137            if tmp.message.is_none() {
138                tmp.message = _error_message;
139            }
140            tmp
141        }),
142        _ => crate::operation::create_sync_configuration::CreateSyncConfigurationError::generic(generic),
143    })
144}
145
146#[allow(clippy::unnecessary_wraps)]
147pub fn de_create_sync_configuration_http_response(
148    _response_status: u16,
149    _response_headers: &::aws_smithy_runtime_api::http::Headers,
150    _response_body: &[u8],
151) -> std::result::Result<
152    crate::operation::create_sync_configuration::CreateSyncConfigurationOutput,
153    crate::operation::create_sync_configuration::CreateSyncConfigurationError,
154> {
155    Ok({
156        #[allow(unused_mut)]
157        let mut output = crate::operation::create_sync_configuration::builders::CreateSyncConfigurationOutputBuilder::default();
158        output = crate::protocol_serde::shape_create_sync_configuration::de_create_sync_configuration(_response_body, output)
159            .map_err(crate::operation::create_sync_configuration::CreateSyncConfigurationError::unhandled)?;
160        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
161        crate::serde_util::create_sync_configuration_output_output_correct_errors(output).build()
162    })
163}
164
165pub fn ser_create_sync_configuration_input(
166    input: &crate::operation::create_sync_configuration::CreateSyncConfigurationInput,
167) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
168    let mut out = String::new();
169    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
170    crate::protocol_serde::shape_create_sync_configuration_input::ser_create_sync_configuration_input_input(&mut object, input)?;
171    object.finish();
172    Ok(::aws_smithy_types::body::SdkBody::from(out))
173}
174
175pub(crate) fn de_create_sync_configuration(
176    value: &[u8],
177    mut builder: crate::operation::create_sync_configuration::builders::CreateSyncConfigurationOutputBuilder,
178) -> ::std::result::Result<
179    crate::operation::create_sync_configuration::builders::CreateSyncConfigurationOutputBuilder,
180    ::aws_smithy_json::deserialize::error::DeserializeError,
181> {
182    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
183    let tokens = &mut tokens_owned;
184    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
185    loop {
186        match tokens.next().transpose()? {
187            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
188            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
189                "SyncConfiguration" => {
190                    builder = builder.set_sync_configuration(crate::protocol_serde::shape_sync_configuration::de_sync_configuration(tokens)?);
191                }
192                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
193            },
194            other => {
195                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
196                    "expected object key or end object, found: {:?}",
197                    other
198                )))
199            }
200        }
201    }
202    if tokens.next().is_some() {
203        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
204            "found more JSON tokens after completing parsing",
205        ));
206    }
207    Ok(builder)
208}