aws_sdk_codedeploy/protocol_serde/
shape_get_deployment.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_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::get_deployment::GetDeploymentOutput, crate::operation::get_deployment::GetDeploymentError> {
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::get_deployment::GetDeploymentError::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::get_deployment::GetDeploymentError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "DeploymentDoesNotExistException" => crate::operation::get_deployment::GetDeploymentError::DeploymentDoesNotExistException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::DeploymentDoesNotExistExceptionBuilder::default();
25 output = crate::protocol_serde::shape_deployment_does_not_exist_exception::de_deployment_does_not_exist_exception_json_err(
26 _response_body,
27 output,
28 )
29 .map_err(crate::operation::get_deployment::GetDeploymentError::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 "DeploymentIdRequiredException" => crate::operation::get_deployment::GetDeploymentError::DeploymentIdRequiredException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::DeploymentIdRequiredExceptionBuilder::default();
43 output = crate::protocol_serde::shape_deployment_id_required_exception::de_deployment_id_required_exception_json_err(
44 _response_body,
45 output,
46 )
47 .map_err(crate::operation::get_deployment::GetDeploymentError::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 "InvalidDeploymentIdException" => crate::operation::get_deployment::GetDeploymentError::InvalidDeploymentIdException({
57 #[allow(unused_mut)]
58 let mut tmp = {
59 #[allow(unused_mut)]
60 let mut output = crate::types::error::builders::InvalidDeploymentIdExceptionBuilder::default();
61 output =
62 crate::protocol_serde::shape_invalid_deployment_id_exception::de_invalid_deployment_id_exception_json_err(_response_body, output)
63 .map_err(crate::operation::get_deployment::GetDeploymentError::unhandled)?;
64 let output = output.meta(generic);
65 output.build()
66 };
67 if tmp.message.is_none() {
68 tmp.message = _error_message;
69 }
70 tmp
71 }),
72 _ => crate::operation::get_deployment::GetDeploymentError::generic(generic),
73 })
74}
75
76#[allow(clippy::unnecessary_wraps)]
77pub fn de_get_deployment_http_response(
78 _response_status: u16,
79 _response_headers: &::aws_smithy_runtime_api::http::Headers,
80 _response_body: &[u8],
81) -> std::result::Result<crate::operation::get_deployment::GetDeploymentOutput, crate::operation::get_deployment::GetDeploymentError> {
82 Ok({
83 #[allow(unused_mut)]
84 let mut output = crate::operation::get_deployment::builders::GetDeploymentOutputBuilder::default();
85 output = crate::protocol_serde::shape_get_deployment::de_get_deployment(_response_body, output)
86 .map_err(crate::operation::get_deployment::GetDeploymentError::unhandled)?;
87 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
88 output.build()
89 })
90}
91
92pub fn ser_get_deployment_input(
93 input: &crate::operation::get_deployment::GetDeploymentInput,
94) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
95 let mut out = String::new();
96 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
97 crate::protocol_serde::shape_get_deployment_input::ser_get_deployment_input_input(&mut object, input)?;
98 object.finish();
99 Ok(::aws_smithy_types::body::SdkBody::from(out))
100}
101
102pub(crate) fn de_get_deployment(
103 value: &[u8],
104 mut builder: crate::operation::get_deployment::builders::GetDeploymentOutputBuilder,
105) -> ::std::result::Result<
106 crate::operation::get_deployment::builders::GetDeploymentOutputBuilder,
107 ::aws_smithy_json::deserialize::error::DeserializeError,
108> {
109 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
110 let tokens = &mut tokens_owned;
111 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
112 loop {
113 match tokens.next().transpose()? {
114 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
115 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
116 "deploymentInfo" => {
117 builder = builder.set_deployment_info(crate::protocol_serde::shape_deployment_info::de_deployment_info(tokens)?);
118 }
119 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
120 },
121 other => {
122 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
123 "expected object key or end object, found: {:?}",
124 other
125 )))
126 }
127 }
128 }
129 if tokens.next().is_some() {
130 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
131 "found more JSON tokens after completing parsing",
132 ));
133 }
134 Ok(builder)
135}