aws_sdk_codestarconnections/protocol_serde/
shape_list_sync_configurations.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_sync_configurations_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::list_sync_configurations::ListSyncConfigurationsOutput,
9    crate::operation::list_sync_configurations::ListSyncConfigurationsError,
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::list_sync_configurations::ListSyncConfigurationsError::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::list_sync_configurations::ListSyncConfigurationsError::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::list_sync_configurations::ListSyncConfigurationsError::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::list_sync_configurations::ListSyncConfigurationsError::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        "InternalServerException" => crate::operation::list_sync_configurations::ListSyncConfigurationsError::InternalServerException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
47                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::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        "InvalidInputException" => crate::operation::list_sync_configurations::ListSyncConfigurationsError::InvalidInputException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::InvalidInputExceptionBuilder::default();
62                output = crate::protocol_serde::shape_invalid_input_exception::de_invalid_input_exception_json_err(_response_body, output)
63                    .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::unhandled)?;
64                let output = output.meta(generic);
65                output.build()
66            };
67            if tmp.message.is_none() {
68                tmp.message = _error_message;
69            }
70            tmp
71        }),
72        "ResourceNotFoundException" => crate::operation::list_sync_configurations::ListSyncConfigurationsError::ResourceNotFoundException({
73            #[allow(unused_mut)]
74            let mut tmp = {
75                #[allow(unused_mut)]
76                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
77                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
78                    .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::unhandled)?;
79                let output = output.meta(generic);
80                output.build()
81            };
82            if tmp.message.is_none() {
83                tmp.message = _error_message;
84            }
85            tmp
86        }),
87        "ThrottlingException" => crate::operation::list_sync_configurations::ListSyncConfigurationsError::ThrottlingException({
88            #[allow(unused_mut)]
89            let mut tmp = {
90                #[allow(unused_mut)]
91                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
92                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
93                    .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::unhandled)?;
94                let output = output.meta(generic);
95                output.build()
96            };
97            if tmp.message.is_none() {
98                tmp.message = _error_message;
99            }
100            tmp
101        }),
102        _ => crate::operation::list_sync_configurations::ListSyncConfigurationsError::generic(generic),
103    })
104}
105
106#[allow(clippy::unnecessary_wraps)]
107pub fn de_list_sync_configurations_http_response(
108    _response_status: u16,
109    _response_headers: &::aws_smithy_runtime_api::http::Headers,
110    _response_body: &[u8],
111) -> std::result::Result<
112    crate::operation::list_sync_configurations::ListSyncConfigurationsOutput,
113    crate::operation::list_sync_configurations::ListSyncConfigurationsError,
114> {
115    Ok({
116        #[allow(unused_mut)]
117        let mut output = crate::operation::list_sync_configurations::builders::ListSyncConfigurationsOutputBuilder::default();
118        output = crate::protocol_serde::shape_list_sync_configurations::de_list_sync_configurations(_response_body, output)
119            .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::unhandled)?;
120        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
121        crate::serde_util::list_sync_configurations_output_output_correct_errors(output)
122            .build()
123            .map_err(crate::operation::list_sync_configurations::ListSyncConfigurationsError::unhandled)?
124    })
125}
126
127pub fn ser_list_sync_configurations_input(
128    input: &crate::operation::list_sync_configurations::ListSyncConfigurationsInput,
129) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
130    let mut out = String::new();
131    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
132    crate::protocol_serde::shape_list_sync_configurations_input::ser_list_sync_configurations_input_input(&mut object, input)?;
133    object.finish();
134    Ok(::aws_smithy_types::body::SdkBody::from(out))
135}
136
137pub(crate) fn de_list_sync_configurations(
138    value: &[u8],
139    mut builder: crate::operation::list_sync_configurations::builders::ListSyncConfigurationsOutputBuilder,
140) -> ::std::result::Result<
141    crate::operation::list_sync_configurations::builders::ListSyncConfigurationsOutputBuilder,
142    ::aws_smithy_json::deserialize::error::DeserializeError,
143> {
144    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
145    let tokens = &mut tokens_owned;
146    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
147    loop {
148        match tokens.next().transpose()? {
149            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
150            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
151                "SyncConfigurations" => {
152                    builder =
153                        builder.set_sync_configurations(crate::protocol_serde::shape_sync_configuration_list::de_sync_configuration_list(tokens)?);
154                }
155                "NextToken" => {
156                    builder = builder.set_next_token(
157                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
158                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
159                            .transpose()?,
160                    );
161                }
162                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
163            },
164            other => {
165                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
166                    "expected object key or end object, found: {:?}",
167                    other
168                )))
169            }
170        }
171    }
172    if tokens.next().is_some() {
173        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
174            "found more JSON tokens after completing parsing",
175        ));
176    }
177    Ok(builder)
178}