aws_sdk_codedeploy/protocol_serde/
shape_list_deployment_groups.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_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::list_deployment_groups::ListDeploymentGroupsOutput,
9 crate::operation::list_deployment_groups::ListDeploymentGroupsError,
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::list_deployment_groups::ListDeploymentGroupsError::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::list_deployment_groups::ListDeploymentGroupsError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ApplicationDoesNotExistException" => {
24 crate::operation::list_deployment_groups::ListDeploymentGroupsError::ApplicationDoesNotExistException({
25 #[allow(unused_mut)]
26 let mut tmp = {
27 #[allow(unused_mut)]
28 let mut output = crate::types::error::builders::ApplicationDoesNotExistExceptionBuilder::default();
29 output = crate::protocol_serde::shape_application_does_not_exist_exception::de_application_does_not_exist_exception_json_err(
30 _response_body,
31 output,
32 )
33 .map_err(crate::operation::list_deployment_groups::ListDeploymentGroupsError::unhandled)?;
34 let output = output.meta(generic);
35 output.build()
36 };
37 if tmp.message.is_none() {
38 tmp.message = _error_message;
39 }
40 tmp
41 })
42 }
43 "ApplicationNameRequiredException" => {
44 crate::operation::list_deployment_groups::ListDeploymentGroupsError::ApplicationNameRequiredException({
45 #[allow(unused_mut)]
46 let mut tmp = {
47 #[allow(unused_mut)]
48 let mut output = crate::types::error::builders::ApplicationNameRequiredExceptionBuilder::default();
49 output = crate::protocol_serde::shape_application_name_required_exception::de_application_name_required_exception_json_err(
50 _response_body,
51 output,
52 )
53 .map_err(crate::operation::list_deployment_groups::ListDeploymentGroupsError::unhandled)?;
54 let output = output.meta(generic);
55 output.build()
56 };
57 if tmp.message.is_none() {
58 tmp.message = _error_message;
59 }
60 tmp
61 })
62 }
63 "InvalidApplicationNameException" => crate::operation::list_deployment_groups::ListDeploymentGroupsError::InvalidApplicationNameException({
64 #[allow(unused_mut)]
65 let mut tmp = {
66 #[allow(unused_mut)]
67 let mut output = crate::types::error::builders::InvalidApplicationNameExceptionBuilder::default();
68 output = crate::protocol_serde::shape_invalid_application_name_exception::de_invalid_application_name_exception_json_err(
69 _response_body,
70 output,
71 )
72 .map_err(crate::operation::list_deployment_groups::ListDeploymentGroupsError::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 "InvalidNextTokenException" => crate::operation::list_deployment_groups::ListDeploymentGroupsError::InvalidNextTokenException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::InvalidNextTokenExceptionBuilder::default();
86 output = crate::protocol_serde::shape_invalid_next_token_exception::de_invalid_next_token_exception_json_err(_response_body, output)
87 .map_err(crate::operation::list_deployment_groups::ListDeploymentGroupsError::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::list_deployment_groups::ListDeploymentGroupsError::generic(generic),
97 })
98}
99
100#[allow(clippy::unnecessary_wraps)]
101pub fn de_list_deployment_groups_http_response(
102 _response_status: u16,
103 _response_headers: &::aws_smithy_runtime_api::http::Headers,
104 _response_body: &[u8],
105) -> std::result::Result<
106 crate::operation::list_deployment_groups::ListDeploymentGroupsOutput,
107 crate::operation::list_deployment_groups::ListDeploymentGroupsError,
108> {
109 Ok({
110 #[allow(unused_mut)]
111 let mut output = crate::operation::list_deployment_groups::builders::ListDeploymentGroupsOutputBuilder::default();
112 output = crate::protocol_serde::shape_list_deployment_groups::de_list_deployment_groups(_response_body, output)
113 .map_err(crate::operation::list_deployment_groups::ListDeploymentGroupsError::unhandled)?;
114 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
115 output.build()
116 })
117}
118
119pub fn ser_list_deployment_groups_input(
120 input: &crate::operation::list_deployment_groups::ListDeploymentGroupsInput,
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_list_deployment_groups_input::ser_list_deployment_groups_input_input(&mut object, input)?;
125 object.finish();
126 Ok(::aws_smithy_types::body::SdkBody::from(out))
127}
128
129pub(crate) fn de_list_deployment_groups(
130 value: &[u8],
131 mut builder: crate::operation::list_deployment_groups::builders::ListDeploymentGroupsOutputBuilder,
132) -> ::std::result::Result<
133 crate::operation::list_deployment_groups::builders::ListDeploymentGroupsOutputBuilder,
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 "applicationName" => {
144 builder = builder.set_application_name(
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 "deploymentGroups" => {
151 builder = builder.set_deployment_groups(crate::protocol_serde::shape_deployment_groups_list::de_deployment_groups_list(tokens)?);
152 }
153 "nextToken" => {
154 builder = builder.set_next_token(
155 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
156 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
157 .transpose()?,
158 );
159 }
160 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
161 },
162 other => {
163 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
164 "expected object key or end object, found: {:?}",
165 other
166 )))
167 }
168 }
169 }
170 if tokens.next().is_some() {
171 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
172 "found more JSON tokens after completing parsing",
173 ));
174 }
175 Ok(builder)
176}