aws_sdk_pinpointsmsvoicev2/protocol_serde/
shape_update_event_destination.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_event_destination_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::update_event_destination::UpdateEventDestinationOutput,
9    crate::operation::update_event_destination::UpdateEventDestinationError,
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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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        "ConflictException" => crate::operation::update_event_destination::UpdateEventDestinationError::ConflictException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
47                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::update_event_destination::UpdateEventDestinationError::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        "InternalServerException" => crate::operation::update_event_destination::UpdateEventDestinationError::InternalServerException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
62                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
63                    .map_err(crate::operation::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::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        "ValidationException" => crate::operation::update_event_destination::UpdateEventDestinationError::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::update_event_destination::UpdateEventDestinationError::unhandled)?;
109                let output = output.meta(generic);
110                output.build()
111            };
112            if tmp.message.is_none() {
113                tmp.message = _error_message;
114            }
115            tmp
116        }),
117        _ => crate::operation::update_event_destination::UpdateEventDestinationError::generic(generic),
118    })
119}
120
121#[allow(clippy::unnecessary_wraps)]
122pub fn de_update_event_destination_http_response(
123    _response_status: u16,
124    _response_headers: &::aws_smithy_runtime_api::http::Headers,
125    _response_body: &[u8],
126) -> std::result::Result<
127    crate::operation::update_event_destination::UpdateEventDestinationOutput,
128    crate::operation::update_event_destination::UpdateEventDestinationError,
129> {
130    Ok({
131        #[allow(unused_mut)]
132        let mut output = crate::operation::update_event_destination::builders::UpdateEventDestinationOutputBuilder::default();
133        output = crate::protocol_serde::shape_update_event_destination::de_update_event_destination(_response_body, output)
134            .map_err(crate::operation::update_event_destination::UpdateEventDestinationError::unhandled)?;
135        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
136        output.build()
137    })
138}
139
140pub fn ser_update_event_destination_input(
141    input: &crate::operation::update_event_destination::UpdateEventDestinationInput,
142) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
143    let mut out = String::new();
144    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
145    crate::protocol_serde::shape_update_event_destination_input::ser_update_event_destination_input_input(&mut object, input)?;
146    object.finish();
147    Ok(::aws_smithy_types::body::SdkBody::from(out))
148}
149
150pub(crate) fn de_update_event_destination(
151    value: &[u8],
152    mut builder: crate::operation::update_event_destination::builders::UpdateEventDestinationOutputBuilder,
153) -> ::std::result::Result<
154    crate::operation::update_event_destination::builders::UpdateEventDestinationOutputBuilder,
155    ::aws_smithy_json::deserialize::error::DeserializeError,
156> {
157    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
158    let tokens = &mut tokens_owned;
159    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
160    loop {
161        match tokens.next().transpose()? {
162            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
163            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
164                "ConfigurationSetArn" => {
165                    builder = builder.set_configuration_set_arn(
166                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
167                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
168                            .transpose()?,
169                    );
170                }
171                "ConfigurationSetName" => {
172                    builder = builder.set_configuration_set_name(
173                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
174                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
175                            .transpose()?,
176                    );
177                }
178                "EventDestination" => {
179                    builder = builder.set_event_destination(crate::protocol_serde::shape_event_destination::de_event_destination(tokens)?);
180                }
181                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
182            },
183            other => {
184                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
185                    "expected object key or end object, found: {other:?}"
186                )))
187            }
188        }
189    }
190    if tokens.next().is_some() {
191        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
192            "found more JSON tokens after completing parsing",
193        ));
194    }
195    Ok(builder)
196}