aws_sdk_codedeploy/protocol_serde/
shape_batch_get_deployment_groups.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_get_deployment_groups_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::batch_get_deployment_groups::BatchGetDeploymentGroupsOutput,
9 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError,
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::batch_get_deployment_groups::BatchGetDeploymentGroupsError::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::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "ApplicationDoesNotExistException" => {
28 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::ApplicationDoesNotExistException({
29 #[allow(unused_mut)]
30 let mut tmp = {
31 #[allow(unused_mut)]
32 let mut output = crate::types::error::builders::ApplicationDoesNotExistExceptionBuilder::default();
33 output = crate::protocol_serde::shape_application_does_not_exist_exception::de_application_does_not_exist_exception_json_err(
34 _response_body,
35 output,
36 )
37 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled)?;
38 let output = output.meta(generic);
39 output.build()
40 };
41 if tmp.message.is_none() {
42 tmp.message = _error_message;
43 }
44 tmp
45 })
46 }
47 "ApplicationNameRequiredException" => {
48 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::ApplicationNameRequiredException({
49 #[allow(unused_mut)]
50 let mut tmp = {
51 #[allow(unused_mut)]
52 let mut output = crate::types::error::builders::ApplicationNameRequiredExceptionBuilder::default();
53 output = crate::protocol_serde::shape_application_name_required_exception::de_application_name_required_exception_json_err(
54 _response_body,
55 output,
56 )
57 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::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 }
67 "BatchLimitExceededException" => crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::BatchLimitExceededException({
68 #[allow(unused_mut)]
69 let mut tmp = {
70 #[allow(unused_mut)]
71 let mut output = crate::types::error::builders::BatchLimitExceededExceptionBuilder::default();
72 output =
73 crate::protocol_serde::shape_batch_limit_exceeded_exception::de_batch_limit_exceeded_exception_json_err(_response_body, output)
74 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::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 "DeploymentConfigDoesNotExistException" => {
84 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::DeploymentConfigDoesNotExistException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::DeploymentConfigDoesNotExistExceptionBuilder::default();
89 output = crate::protocol_serde::shape_deployment_config_does_not_exist_exception::de_deployment_config_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::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 }
99 "DeploymentGroupNameRequiredException" => {
100 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::DeploymentGroupNameRequiredException({
101 #[allow(unused_mut)]
102 let mut tmp = {
103 #[allow(unused_mut)]
104 let mut output = crate::types::error::builders::DeploymentGroupNameRequiredExceptionBuilder::default();
105 output =
106 crate::protocol_serde::shape_deployment_group_name_required_exception::de_deployment_group_name_required_exception_json_err(
107 _response_body,
108 output,
109 )
110 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled)?;
111 let output = output.meta(generic);
112 output.build()
113 };
114 if tmp.message.is_none() {
115 tmp.message = _error_message;
116 }
117 tmp
118 })
119 }
120 "InvalidApplicationNameException" => {
121 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::InvalidApplicationNameException({
122 #[allow(unused_mut)]
123 let mut tmp = {
124 #[allow(unused_mut)]
125 let mut output = crate::types::error::builders::InvalidApplicationNameExceptionBuilder::default();
126 output = crate::protocol_serde::shape_invalid_application_name_exception::de_invalid_application_name_exception_json_err(
127 _response_body,
128 output,
129 )
130 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled)?;
131 let output = output.meta(generic);
132 output.build()
133 };
134 if tmp.message.is_none() {
135 tmp.message = _error_message;
136 }
137 tmp
138 })
139 }
140 "InvalidDeploymentGroupNameException" => {
141 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::InvalidDeploymentGroupNameException({
142 #[allow(unused_mut)]
143 let mut tmp = {
144 #[allow(unused_mut)]
145 let mut output = crate::types::error::builders::InvalidDeploymentGroupNameExceptionBuilder::default();
146 output =
147 crate::protocol_serde::shape_invalid_deployment_group_name_exception::de_invalid_deployment_group_name_exception_json_err(
148 _response_body,
149 output,
150 )
151 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled)?;
152 let output = output.meta(generic);
153 output.build()
154 };
155 if tmp.message.is_none() {
156 tmp.message = _error_message;
157 }
158 tmp
159 })
160 }
161 _ => crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::generic(generic),
162 })
163}
164
165#[allow(clippy::unnecessary_wraps)]
166pub fn de_batch_get_deployment_groups_http_response(
167 _response_status: u16,
168 _response_headers: &::aws_smithy_runtime_api::http::Headers,
169 _response_body: &[u8],
170) -> std::result::Result<
171 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsOutput,
172 crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError,
173> {
174 Ok({
175 #[allow(unused_mut)]
176 let mut output = crate::operation::batch_get_deployment_groups::builders::BatchGetDeploymentGroupsOutputBuilder::default();
177 output = crate::protocol_serde::shape_batch_get_deployment_groups::de_batch_get_deployment_groups(_response_body, output)
178 .map_err(crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsError::unhandled)?;
179 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
180 output.build()
181 })
182}
183
184pub fn ser_batch_get_deployment_groups_input(
185 input: &crate::operation::batch_get_deployment_groups::BatchGetDeploymentGroupsInput,
186) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
187 let mut out = String::new();
188 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
189 crate::protocol_serde::shape_batch_get_deployment_groups_input::ser_batch_get_deployment_groups_input_input(&mut object, input)?;
190 object.finish();
191 Ok(::aws_smithy_types::body::SdkBody::from(out))
192}
193
194pub(crate) fn de_batch_get_deployment_groups(
195 value: &[u8],
196 mut builder: crate::operation::batch_get_deployment_groups::builders::BatchGetDeploymentGroupsOutputBuilder,
197) -> ::std::result::Result<
198 crate::operation::batch_get_deployment_groups::builders::BatchGetDeploymentGroupsOutputBuilder,
199 ::aws_smithy_json::deserialize::error::DeserializeError,
200> {
201 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
202 let tokens = &mut tokens_owned;
203 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
204 loop {
205 match tokens.next().transpose()? {
206 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
207 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
208 "deploymentGroupsInfo" => {
209 builder = builder.set_deployment_groups_info(
210 crate::protocol_serde::shape_deployment_group_info_list::de_deployment_group_info_list(tokens)?,
211 );
212 }
213 "errorMessage" => {
214 builder = builder.set_error_message(
215 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
216 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
217 .transpose()?,
218 );
219 }
220 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
221 },
222 other => {
223 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
224 "expected object key or end object, found: {:?}",
225 other
226 )))
227 }
228 }
229 }
230 if tokens.next().is_some() {
231 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
232 "found more JSON tokens after completing parsing",
233 ));
234 }
235 Ok(builder)
236}