aws_sdk_codedeploy/protocol_serde/
shape_stop_deployment.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_stop_deployment_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::stop_deployment::StopDeploymentOutput, crate::operation::stop_deployment::StopDeploymentError> {
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::stop_deployment::StopDeploymentError::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::stop_deployment::StopDeploymentError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "DeploymentAlreadyCompletedException" => crate::operation::stop_deployment::StopDeploymentError::DeploymentAlreadyCompletedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::DeploymentAlreadyCompletedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_deployment_already_completed_exception::de_deployment_already_completed_exception_json_err(
26 _response_body,
27 output,
28 )
29 .map_err(crate::operation::stop_deployment::StopDeploymentError::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 "DeploymentDoesNotExistException" => crate::operation::stop_deployment::StopDeploymentError::DeploymentDoesNotExistException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::DeploymentDoesNotExistExceptionBuilder::default();
43 output = crate::protocol_serde::shape_deployment_does_not_exist_exception::de_deployment_does_not_exist_exception_json_err(
44 _response_body,
45 output,
46 )
47 .map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
48 let output = output.meta(generic);
49 output.build()
50 };
51 if tmp.message.is_none() {
52 tmp.message = _error_message;
53 }
54 tmp
55 }),
56 "DeploymentGroupDoesNotExistException" => {
57 crate::operation::stop_deployment::StopDeploymentError::DeploymentGroupDoesNotExistException({
58 #[allow(unused_mut)]
59 let mut tmp = {
60 #[allow(unused_mut)]
61 let mut output = crate::types::error::builders::DeploymentGroupDoesNotExistExceptionBuilder::default();
62 output = crate::protocol_serde::shape_deployment_group_does_not_exist_exception::de_deployment_group_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
63 let output = output.meta(generic);
64 output.build()
65 };
66 if tmp.message.is_none() {
67 tmp.message = _error_message;
68 }
69 tmp
70 })
71 }
72 "DeploymentIdRequiredException" => crate::operation::stop_deployment::StopDeploymentError::DeploymentIdRequiredException({
73 #[allow(unused_mut)]
74 let mut tmp = {
75 #[allow(unused_mut)]
76 let mut output = crate::types::error::builders::DeploymentIdRequiredExceptionBuilder::default();
77 output = crate::protocol_serde::shape_deployment_id_required_exception::de_deployment_id_required_exception_json_err(
78 _response_body,
79 output,
80 )
81 .map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
82 let output = output.meta(generic);
83 output.build()
84 };
85 if tmp.message.is_none() {
86 tmp.message = _error_message;
87 }
88 tmp
89 }),
90 "InvalidDeploymentIdException" => crate::operation::stop_deployment::StopDeploymentError::InvalidDeploymentIdException({
91 #[allow(unused_mut)]
92 let mut tmp = {
93 #[allow(unused_mut)]
94 let mut output = crate::types::error::builders::InvalidDeploymentIdExceptionBuilder::default();
95 output =
96 crate::protocol_serde::shape_invalid_deployment_id_exception::de_invalid_deployment_id_exception_json_err(_response_body, output)
97 .map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
98 let output = output.meta(generic);
99 output.build()
100 };
101 if tmp.message.is_none() {
102 tmp.message = _error_message;
103 }
104 tmp
105 }),
106 "UnsupportedActionForDeploymentTypeException" => {
107 crate::operation::stop_deployment::StopDeploymentError::UnsupportedActionForDeploymentTypeException({
108 #[allow(unused_mut)]
109 let mut tmp = {
110 #[allow(unused_mut)]
111 let mut output = crate::types::error::builders::UnsupportedActionForDeploymentTypeExceptionBuilder::default();
112 output = crate::protocol_serde::shape_unsupported_action_for_deployment_type_exception::de_unsupported_action_for_deployment_type_exception_json_err(_response_body, output).map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
113 let output = output.meta(generic);
114 output.build()
115 };
116 if tmp.message.is_none() {
117 tmp.message = _error_message;
118 }
119 tmp
120 })
121 }
122 _ => crate::operation::stop_deployment::StopDeploymentError::generic(generic),
123 })
124}
125
126#[allow(clippy::unnecessary_wraps)]
127pub fn de_stop_deployment_http_response(
128 _response_status: u16,
129 _response_headers: &::aws_smithy_runtime_api::http::Headers,
130 _response_body: &[u8],
131) -> std::result::Result<crate::operation::stop_deployment::StopDeploymentOutput, crate::operation::stop_deployment::StopDeploymentError> {
132 Ok({
133 #[allow(unused_mut)]
134 let mut output = crate::operation::stop_deployment::builders::StopDeploymentOutputBuilder::default();
135 output = crate::protocol_serde::shape_stop_deployment::de_stop_deployment(_response_body, output)
136 .map_err(crate::operation::stop_deployment::StopDeploymentError::unhandled)?;
137 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
138 output.build()
139 })
140}
141
142pub fn ser_stop_deployment_input(
143 input: &crate::operation::stop_deployment::StopDeploymentInput,
144) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
145 let mut out = String::new();
146 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
147 crate::protocol_serde::shape_stop_deployment_input::ser_stop_deployment_input_input(&mut object, input)?;
148 object.finish();
149 Ok(::aws_smithy_types::body::SdkBody::from(out))
150}
151
152pub(crate) fn de_stop_deployment(
153 value: &[u8],
154 mut builder: crate::operation::stop_deployment::builders::StopDeploymentOutputBuilder,
155) -> ::std::result::Result<
156 crate::operation::stop_deployment::builders::StopDeploymentOutputBuilder,
157 ::aws_smithy_json::deserialize::error::DeserializeError,
158> {
159 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
160 let tokens = &mut tokens_owned;
161 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
162 loop {
163 match tokens.next().transpose()? {
164 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
165 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
166 "status" => {
167 builder = builder.set_status(
168 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
169 .map(|s| s.to_unescaped().map(|u| crate::types::StopStatus::from(u.as_ref())))
170 .transpose()?,
171 );
172 }
173 "statusMessage" => {
174 builder = builder.set_status_message(
175 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
176 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
177 .transpose()?,
178 );
179 }
180 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
181 },
182 other => {
183 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
184 "expected object key or end object, found: {:?}",
185 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}