aws_sdk_apigatewayv2/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 "NotFoundException" => crate::operation::get_deployment::GetDeploymentError::NotFoundException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
25 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
26 .map_err(crate::operation::get_deployment::GetDeploymentError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "TooManyRequestsException" => crate::operation::get_deployment::GetDeploymentError::TooManyRequestsException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
40 output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
41 .map_err(crate::operation::get_deployment::GetDeploymentError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 _ => crate::operation::get_deployment::GetDeploymentError::generic(generic),
51 })
52}
53
54#[allow(clippy::unnecessary_wraps)]
55pub fn de_get_deployment_http_response(
56 _response_status: u16,
57 _response_headers: &::aws_smithy_runtime_api::http::Headers,
58 _response_body: &[u8],
59) -> std::result::Result<crate::operation::get_deployment::GetDeploymentOutput, crate::operation::get_deployment::GetDeploymentError> {
60 Ok({
61 #[allow(unused_mut)]
62 let mut output = crate::operation::get_deployment::builders::GetDeploymentOutputBuilder::default();
63 output = crate::protocol_serde::shape_get_deployment::de_get_deployment(_response_body, output)
64 .map_err(crate::operation::get_deployment::GetDeploymentError::unhandled)?;
65 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
66 output.build()
67 })
68}
69
70pub(crate) fn de_get_deployment(
71 value: &[u8],
72 mut builder: crate::operation::get_deployment::builders::GetDeploymentOutputBuilder,
73) -> ::std::result::Result<
74 crate::operation::get_deployment::builders::GetDeploymentOutputBuilder,
75 ::aws_smithy_json::deserialize::error::DeserializeError,
76> {
77 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
78 let tokens = &mut tokens_owned;
79 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
80 loop {
81 match tokens.next().transpose()? {
82 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
83 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
84 "autoDeployed" => {
85 builder = builder.set_auto_deployed(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
86 }
87 "createdDate" => {
88 builder = builder.set_created_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
89 tokens.next(),
90 ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
91 )?);
92 }
93 "deploymentId" => {
94 builder = builder.set_deployment_id(
95 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
96 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
97 .transpose()?,
98 );
99 }
100 "deploymentStatus" => {
101 builder = builder.set_deployment_status(
102 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
103 .map(|s| s.to_unescaped().map(|u| crate::types::DeploymentStatus::from(u.as_ref())))
104 .transpose()?,
105 );
106 }
107 "deploymentStatusMessage" => {
108 builder = builder.set_deployment_status_message(
109 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
110 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
111 .transpose()?,
112 );
113 }
114 "description" => {
115 builder = builder.set_description(
116 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
117 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
118 .transpose()?,
119 );
120 }
121 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
122 },
123 other => {
124 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
125 "expected object key or end object, found: {:?}",
126 other
127 )))
128 }
129 }
130 }
131 if tokens.next().is_some() {
132 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
133 "found more JSON tokens after completing parsing",
134 ));
135 }
136 Ok(builder)
137}