aws_sdk_codedeploy/protocol_serde/
shape_get_deployment_target.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_deployment_target_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::get_deployment_target::GetDeploymentTargetOutput,
9 crate::operation::get_deployment_target::GetDeploymentTargetError,
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::get_deployment_target::GetDeploymentTargetError::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::get_deployment_target::GetDeploymentTargetError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "DeploymentDoesNotExistException" => crate::operation::get_deployment_target::GetDeploymentTargetError::DeploymentDoesNotExistException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::DeploymentDoesNotExistExceptionBuilder::default();
28 output = crate::protocol_serde::shape_deployment_does_not_exist_exception::de_deployment_does_not_exist_exception_json_err(
29 _response_body,
30 output,
31 )
32 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
33 let output = output.meta(generic);
34 output.build()
35 };
36 if tmp.message.is_none() {
37 tmp.message = _error_message;
38 }
39 tmp
40 }),
41 "DeploymentIdRequiredException" => crate::operation::get_deployment_target::GetDeploymentTargetError::DeploymentIdRequiredException({
42 #[allow(unused_mut)]
43 let mut tmp = {
44 #[allow(unused_mut)]
45 let mut output = crate::types::error::builders::DeploymentIdRequiredExceptionBuilder::default();
46 output = crate::protocol_serde::shape_deployment_id_required_exception::de_deployment_id_required_exception_json_err(
47 _response_body,
48 output,
49 )
50 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
51 let output = output.meta(generic);
52 output.build()
53 };
54 if tmp.message.is_none() {
55 tmp.message = _error_message;
56 }
57 tmp
58 }),
59 "DeploymentNotStartedException" => crate::operation::get_deployment_target::GetDeploymentTargetError::DeploymentNotStartedException({
60 #[allow(unused_mut)]
61 let mut tmp = {
62 #[allow(unused_mut)]
63 let mut output = crate::types::error::builders::DeploymentNotStartedExceptionBuilder::default();
64 output = crate::protocol_serde::shape_deployment_not_started_exception::de_deployment_not_started_exception_json_err(
65 _response_body,
66 output,
67 )
68 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
69 let output = output.meta(generic);
70 output.build()
71 };
72 if tmp.message.is_none() {
73 tmp.message = _error_message;
74 }
75 tmp
76 }),
77 "DeploymentTargetDoesNotExistException" => {
78 crate::operation::get_deployment_target::GetDeploymentTargetError::DeploymentTargetDoesNotExistException({
79 #[allow(unused_mut)]
80 let mut tmp = {
81 #[allow(unused_mut)]
82 let mut output = crate::types::error::builders::DeploymentTargetDoesNotExistExceptionBuilder::default();
83 output = crate::protocol_serde::shape_deployment_target_does_not_exist_exception::de_deployment_target_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
84 let output = output.meta(generic);
85 output.build()
86 };
87 if tmp.message.is_none() {
88 tmp.message = _error_message;
89 }
90 tmp
91 })
92 }
93 "DeploymentTargetIdRequiredException" => {
94 crate::operation::get_deployment_target::GetDeploymentTargetError::DeploymentTargetIdRequiredException({
95 #[allow(unused_mut)]
96 let mut tmp = {
97 #[allow(unused_mut)]
98 let mut output = crate::types::error::builders::DeploymentTargetIdRequiredExceptionBuilder::default();
99 output =
100 crate::protocol_serde::shape_deployment_target_id_required_exception::de_deployment_target_id_required_exception_json_err(
101 _response_body,
102 output,
103 )
104 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
105 let output = output.meta(generic);
106 output.build()
107 };
108 if tmp.message.is_none() {
109 tmp.message = _error_message;
110 }
111 tmp
112 })
113 }
114 "InvalidDeploymentIdException" => crate::operation::get_deployment_target::GetDeploymentTargetError::InvalidDeploymentIdException({
115 #[allow(unused_mut)]
116 let mut tmp = {
117 #[allow(unused_mut)]
118 let mut output = crate::types::error::builders::InvalidDeploymentIdExceptionBuilder::default();
119 output =
120 crate::protocol_serde::shape_invalid_deployment_id_exception::de_invalid_deployment_id_exception_json_err(_response_body, output)
121 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
122 let output = output.meta(generic);
123 output.build()
124 };
125 if tmp.message.is_none() {
126 tmp.message = _error_message;
127 }
128 tmp
129 }),
130 "InvalidDeploymentTargetIdException" => {
131 crate::operation::get_deployment_target::GetDeploymentTargetError::InvalidDeploymentTargetIdException({
132 #[allow(unused_mut)]
133 let mut tmp = {
134 #[allow(unused_mut)]
135 let mut output = crate::types::error::builders::InvalidDeploymentTargetIdExceptionBuilder::default();
136 output = crate::protocol_serde::shape_invalid_deployment_target_id_exception::de_invalid_deployment_target_id_exception_json_err(
137 _response_body,
138 output,
139 )
140 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
141 let output = output.meta(generic);
142 output.build()
143 };
144 if tmp.message.is_none() {
145 tmp.message = _error_message;
146 }
147 tmp
148 })
149 }
150 "InvalidInstanceNameException" => crate::operation::get_deployment_target::GetDeploymentTargetError::InvalidInstanceNameException({
151 #[allow(unused_mut)]
152 let mut tmp = {
153 #[allow(unused_mut)]
154 let mut output = crate::types::error::builders::InvalidInstanceNameExceptionBuilder::default();
155 output =
156 crate::protocol_serde::shape_invalid_instance_name_exception::de_invalid_instance_name_exception_json_err(_response_body, output)
157 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
158 let output = output.meta(generic);
159 output.build()
160 };
161 if tmp.message.is_none() {
162 tmp.message = _error_message;
163 }
164 tmp
165 }),
166 _ => crate::operation::get_deployment_target::GetDeploymentTargetError::generic(generic),
167 })
168}
169
170#[allow(clippy::unnecessary_wraps)]
171pub fn de_get_deployment_target_http_response(
172 _response_status: u16,
173 _response_headers: &::aws_smithy_runtime_api::http::Headers,
174 _response_body: &[u8],
175) -> std::result::Result<
176 crate::operation::get_deployment_target::GetDeploymentTargetOutput,
177 crate::operation::get_deployment_target::GetDeploymentTargetError,
178> {
179 Ok({
180 #[allow(unused_mut)]
181 let mut output = crate::operation::get_deployment_target::builders::GetDeploymentTargetOutputBuilder::default();
182 output = crate::protocol_serde::shape_get_deployment_target::de_get_deployment_target(_response_body, output)
183 .map_err(crate::operation::get_deployment_target::GetDeploymentTargetError::unhandled)?;
184 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
185 output.build()
186 })
187}
188
189pub fn ser_get_deployment_target_input(
190 input: &crate::operation::get_deployment_target::GetDeploymentTargetInput,
191) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
192 let mut out = String::new();
193 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
194 crate::protocol_serde::shape_get_deployment_target_input::ser_get_deployment_target_input_input(&mut object, input)?;
195 object.finish();
196 Ok(::aws_smithy_types::body::SdkBody::from(out))
197}
198
199pub(crate) fn de_get_deployment_target(
200 value: &[u8],
201 mut builder: crate::operation::get_deployment_target::builders::GetDeploymentTargetOutputBuilder,
202) -> ::std::result::Result<
203 crate::operation::get_deployment_target::builders::GetDeploymentTargetOutputBuilder,
204 ::aws_smithy_json::deserialize::error::DeserializeError,
205> {
206 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
207 let tokens = &mut tokens_owned;
208 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
209 loop {
210 match tokens.next().transpose()? {
211 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
212 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
213 "deploymentTarget" => {
214 builder = builder.set_deployment_target(crate::protocol_serde::shape_deployment_target::de_deployment_target(tokens)?);
215 }
216 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
217 },
218 other => {
219 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
220 "expected object key or end object, found: {:?}",
221 other
222 )))
223 }
224 }
225 }
226 if tokens.next().is_some() {
227 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
228 "found more JSON tokens after completing parsing",
229 ));
230 }
231 Ok(builder)
232}