aws_sdk_kafkaconnect/protocol_serde/
shape_delete_connector.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_connector_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_connector::DeleteConnectorOutput, crate::operation::delete_connector::DeleteConnectorError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::delete_connector::DeleteConnectorError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "BadRequestException" => crate::operation::delete_connector::DeleteConnectorError::BadRequestException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
25                output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
26                    .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        "ForbiddenException" => crate::operation::delete_connector::DeleteConnectorError::ForbiddenException({
36            #[allow(unused_mut)]
37            let mut tmp = {
38                #[allow(unused_mut)]
39                let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
40                output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_json_err(_response_body, output)
41                    .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
42                let output = output.meta(generic);
43                output.build()
44            };
45            if tmp.message.is_none() {
46                tmp.message = _error_message;
47            }
48            tmp
49        }),
50        "InternalServerErrorException" => crate::operation::delete_connector::DeleteConnectorError::InternalServerErrorException({
51            #[allow(unused_mut)]
52            let mut tmp = {
53                #[allow(unused_mut)]
54                let mut output = crate::types::error::builders::InternalServerErrorExceptionBuilder::default();
55                output =
56                    crate::protocol_serde::shape_internal_server_error_exception::de_internal_server_error_exception_json_err(_response_body, output)
57                        .map_err(crate::operation::delete_connector::DeleteConnectorError::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        "NotFoundException" => crate::operation::delete_connector::DeleteConnectorError::NotFoundException({
67            #[allow(unused_mut)]
68            let mut tmp = {
69                #[allow(unused_mut)]
70                let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
71                output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
72                    .map_err(crate::operation::delete_connector::DeleteConnectorError::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        "ServiceUnavailableException" => crate::operation::delete_connector::DeleteConnectorError::ServiceUnavailableException({
82            #[allow(unused_mut)]
83            let mut tmp = {
84                #[allow(unused_mut)]
85                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
86                output =
87                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
88                        .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
89                let output = output.meta(generic);
90                output.build()
91            };
92            if tmp.message.is_none() {
93                tmp.message = _error_message;
94            }
95            tmp
96        }),
97        "TooManyRequestsException" => crate::operation::delete_connector::DeleteConnectorError::TooManyRequestsException({
98            #[allow(unused_mut)]
99            let mut tmp = {
100                #[allow(unused_mut)]
101                let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
102                output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
103                    .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
104                let output = output.meta(generic);
105                output.build()
106            };
107            if tmp.message.is_none() {
108                tmp.message = _error_message;
109            }
110            tmp
111        }),
112        "UnauthorizedException" => crate::operation::delete_connector::DeleteConnectorError::UnauthorizedException({
113            #[allow(unused_mut)]
114            let mut tmp = {
115                #[allow(unused_mut)]
116                let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
117                output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
118                    .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
119                let output = output.meta(generic);
120                output.build()
121            };
122            if tmp.message.is_none() {
123                tmp.message = _error_message;
124            }
125            tmp
126        }),
127        _ => crate::operation::delete_connector::DeleteConnectorError::generic(generic),
128    })
129}
130
131#[allow(clippy::unnecessary_wraps)]
132pub fn de_delete_connector_http_response(
133    _response_status: u16,
134    _response_headers: &::aws_smithy_runtime_api::http::Headers,
135    _response_body: &[u8],
136) -> std::result::Result<crate::operation::delete_connector::DeleteConnectorOutput, crate::operation::delete_connector::DeleteConnectorError> {
137    Ok({
138        #[allow(unused_mut)]
139        let mut output = crate::operation::delete_connector::builders::DeleteConnectorOutputBuilder::default();
140        output = crate::protocol_serde::shape_delete_connector::de_delete_connector(_response_body, output)
141            .map_err(crate::operation::delete_connector::DeleteConnectorError::unhandled)?;
142        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
143        output.build()
144    })
145}
146
147pub(crate) fn de_delete_connector(
148    value: &[u8],
149    mut builder: crate::operation::delete_connector::builders::DeleteConnectorOutputBuilder,
150) -> ::std::result::Result<
151    crate::operation::delete_connector::builders::DeleteConnectorOutputBuilder,
152    ::aws_smithy_json::deserialize::error::DeserializeError,
153> {
154    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
155    let tokens = &mut tokens_owned;
156    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
157    loop {
158        match tokens.next().transpose()? {
159            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
160            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
161                "connectorArn" => {
162                    builder = builder.set_connector_arn(
163                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
164                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
165                            .transpose()?,
166                    );
167                }
168                "connectorState" => {
169                    builder = builder.set_connector_state(
170                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
171                            .map(|s| s.to_unescaped().map(|u| crate::types::ConnectorState::from(u.as_ref())))
172                            .transpose()?,
173                    );
174                }
175                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
176            },
177            other => {
178                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
179                    "expected object key or end object, found: {:?}",
180                    other
181                )))
182            }
183        }
184    }
185    if tokens.next().is_some() {
186        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
187            "found more JSON tokens after completing parsing",
188        ));
189    }
190    Ok(builder)
191}