aws_sdk_ecs/protocol_serde/
shape_stop_service_deployment.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_stop_service_deployment_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::stop_service_deployment::StopServiceDeploymentOutput,
9    crate::operation::stop_service_deployment::StopServiceDeploymentError,
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::stop_service_deployment::StopServiceDeploymentError::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 => return Err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::AccessDeniedException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
28                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "ClientException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::ClientException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::ClientExceptionBuilder::default();
43                output = crate::protocol_serde::shape_client_exception::de_client_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "ConflictException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::ConflictException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
58                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
59                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
60                let output = output.meta(generic);
61                output.build()
62            };
63            if tmp.message.is_none() {
64                tmp.message = _error_message;
65            }
66            tmp
67        }),
68        "InvalidParameterException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::InvalidParameterException({
69            #[allow(unused_mut)]
70            let mut tmp = {
71                #[allow(unused_mut)]
72                let mut output = crate::types::error::builders::InvalidParameterExceptionBuilder::default();
73                output = crate::protocol_serde::shape_invalid_parameter_exception::de_invalid_parameter_exception_json_err(_response_body, output)
74                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
75                let output = output.meta(generic);
76                output.build()
77            };
78            if tmp.message.is_none() {
79                tmp.message = _error_message;
80            }
81            tmp
82        }),
83        "ServerException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::ServerException({
84            #[allow(unused_mut)]
85            let mut tmp = {
86                #[allow(unused_mut)]
87                let mut output = crate::types::error::builders::ServerExceptionBuilder::default();
88                output = crate::protocol_serde::shape_server_exception::de_server_exception_json_err(_response_body, output)
89                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
90                let output = output.meta(generic);
91                output.build()
92            };
93            if tmp.message.is_none() {
94                tmp.message = _error_message;
95            }
96            tmp
97        }),
98        "ServiceDeploymentNotFoundException" => {
99            crate::operation::stop_service_deployment::StopServiceDeploymentError::ServiceDeploymentNotFoundException({
100                #[allow(unused_mut)]
101                let mut tmp = {
102                    #[allow(unused_mut)]
103                    let mut output = crate::types::error::builders::ServiceDeploymentNotFoundExceptionBuilder::default();
104                    output = crate::protocol_serde::shape_service_deployment_not_found_exception::de_service_deployment_not_found_exception_json_err(
105                        _response_body,
106                        output,
107                    )
108                    .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::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        }
118        "UnsupportedFeatureException" => crate::operation::stop_service_deployment::StopServiceDeploymentError::UnsupportedFeatureException({
119            #[allow(unused_mut)]
120            let mut tmp = {
121                #[allow(unused_mut)]
122                let mut output = crate::types::error::builders::UnsupportedFeatureExceptionBuilder::default();
123                output =
124                    crate::protocol_serde::shape_unsupported_feature_exception::de_unsupported_feature_exception_json_err(_response_body, output)
125                        .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
126                let output = output.meta(generic);
127                output.build()
128            };
129            if tmp.message.is_none() {
130                tmp.message = _error_message;
131            }
132            tmp
133        }),
134        _ => crate::operation::stop_service_deployment::StopServiceDeploymentError::generic(generic),
135    })
136}
137
138#[allow(clippy::unnecessary_wraps)]
139pub fn de_stop_service_deployment_http_response(
140    _response_status: u16,
141    _response_headers: &::aws_smithy_runtime_api::http::Headers,
142    _response_body: &[u8],
143) -> std::result::Result<
144    crate::operation::stop_service_deployment::StopServiceDeploymentOutput,
145    crate::operation::stop_service_deployment::StopServiceDeploymentError,
146> {
147    Ok({
148        #[allow(unused_mut)]
149        let mut output = crate::operation::stop_service_deployment::builders::StopServiceDeploymentOutputBuilder::default();
150        output = crate::protocol_serde::shape_stop_service_deployment::de_stop_service_deployment(_response_body, output)
151            .map_err(crate::operation::stop_service_deployment::StopServiceDeploymentError::unhandled)?;
152        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
153        output.build()
154    })
155}
156
157pub fn ser_stop_service_deployment_input(
158    input: &crate::operation::stop_service_deployment::StopServiceDeploymentInput,
159) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
160    let mut out = String::new();
161    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
162    crate::protocol_serde::shape_stop_service_deployment_input::ser_stop_service_deployment_input_input(&mut object, input)?;
163    object.finish();
164    Ok(::aws_smithy_types::body::SdkBody::from(out))
165}
166
167pub(crate) fn de_stop_service_deployment(
168    value: &[u8],
169    mut builder: crate::operation::stop_service_deployment::builders::StopServiceDeploymentOutputBuilder,
170) -> ::std::result::Result<
171    crate::operation::stop_service_deployment::builders::StopServiceDeploymentOutputBuilder,
172    ::aws_smithy_json::deserialize::error::DeserializeError,
173> {
174    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
175    let tokens = &mut tokens_owned;
176    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
177    loop {
178        match tokens.next().transpose()? {
179            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
180            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
181                "serviceDeploymentArn" => {
182                    builder = builder.set_service_deployment_arn(
183                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
184                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
185                            .transpose()?,
186                    );
187                }
188                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
189            },
190            other => {
191                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
192                    "expected object key or end object, found: {:?}",
193                    other
194                )))
195            }
196        }
197    }
198    if tokens.next().is_some() {
199        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
200            "found more JSON tokens after completing parsing",
201        ));
202    }
203    Ok(builder)
204}