Skip to main content

aws_sdk_customerprofiles/protocol_serde/
shape_delete_integration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_integration_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::delete_integration::DeleteIntegrationOutput, crate::operation::delete_integration::DeleteIntegrationError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    let error_code = match generic.code() {
15        Some(code) => code,
16        None => return Err(crate::operation::delete_integration::DeleteIntegrationError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "AccessDeniedException" => crate::operation::delete_integration::DeleteIntegrationError::AccessDeniedException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
26                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
27                    .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
28                let output = output.meta(generic);
29                output.build()
30            };
31            if tmp.message.is_none() {
32                tmp.message = _error_message;
33            }
34            tmp
35        }),
36        "BadRequestException" => crate::operation::delete_integration::DeleteIntegrationError::BadRequestException({
37            #[allow(unused_mut)]
38            let mut tmp = {
39                #[allow(unused_mut)]
40                let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
41                output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
42                    .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
43                let output = output.meta(generic);
44                output.build()
45            };
46            if tmp.message.is_none() {
47                tmp.message = _error_message;
48            }
49            tmp
50        }),
51        "InternalServerException" => crate::operation::delete_integration::DeleteIntegrationError::InternalServerException({
52            #[allow(unused_mut)]
53            let mut tmp = {
54                #[allow(unused_mut)]
55                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
56                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
57                    .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
58                let output = output.meta(generic);
59                output.build()
60            };
61            if tmp.message.is_none() {
62                tmp.message = _error_message;
63            }
64            tmp
65        }),
66        "ResourceNotFoundException" => crate::operation::delete_integration::DeleteIntegrationError::ResourceNotFoundException({
67            #[allow(unused_mut)]
68            let mut tmp = {
69                #[allow(unused_mut)]
70                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
71                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
72                    .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
73                let output = output.meta(generic);
74                output.build()
75            };
76            if tmp.message.is_none() {
77                tmp.message = _error_message;
78            }
79            tmp
80        }),
81        "ThrottlingException" => crate::operation::delete_integration::DeleteIntegrationError::ThrottlingException({
82            #[allow(unused_mut)]
83            let mut tmp = {
84                #[allow(unused_mut)]
85                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
86                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
87                    .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
88                let output = output.meta(generic);
89                output.build()
90            };
91            if tmp.message.is_none() {
92                tmp.message = _error_message;
93            }
94            tmp
95        }),
96        _ => crate::operation::delete_integration::DeleteIntegrationError::generic(generic),
97    })
98}
99
100#[allow(clippy::unnecessary_wraps)]
101pub fn de_delete_integration_http_response(
102    _response_status: u16,
103    _response_headers: &::aws_smithy_runtime_api::http::Headers,
104    _response_body: &[u8],
105) -> std::result::Result<crate::operation::delete_integration::DeleteIntegrationOutput, crate::operation::delete_integration::DeleteIntegrationError>
106{
107    Ok({
108        #[allow(unused_mut)]
109        let mut output = crate::operation::delete_integration::builders::DeleteIntegrationOutputBuilder::default();
110        output = crate::protocol_serde::shape_delete_integration::de_delete_integration(_response_body, output)
111            .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?;
112        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
113        crate::serde_util::delete_integration_output_output_correct_errors(output)
114            .build()
115            .map_err(crate::operation::delete_integration::DeleteIntegrationError::unhandled)?
116    })
117}
118
119pub fn ser_delete_integration_input(
120    input: &crate::operation::delete_integration::DeleteIntegrationInput,
121) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
122    let mut out = String::new();
123    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
124    crate::protocol_serde::shape_delete_integration_input::ser_delete_integration_input_input(&mut object, input)?;
125    object.finish();
126    Ok(::aws_smithy_types::body::SdkBody::from(out))
127}
128
129pub(crate) fn de_delete_integration(
130    _value: &[u8],
131    mut builder: crate::operation::delete_integration::builders::DeleteIntegrationOutputBuilder,
132) -> ::std::result::Result<
133    crate::operation::delete_integration::builders::DeleteIntegrationOutputBuilder,
134    ::aws_smithy_json::deserialize::error::DeserializeError,
135> {
136    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
137    let tokens = &mut tokens_owned;
138    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
139    loop {
140        match tokens.next().transpose()? {
141            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
142            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
143                "Message" => {
144                    builder = builder.set_message(
145                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
146                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
147                            .transpose()?,
148                    );
149                }
150                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
151            },
152            other => {
153                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
154                    "expected object key or end object, found: {other:?}"
155                )))
156            }
157        }
158    }
159    if tokens.next().is_some() {
160        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
161            "found more JSON tokens after completing parsing",
162        ));
163    }
164    Ok(builder)
165}