aws_sdk_apigatewayv2/protocol_serde/
shape_get_integration_response.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_integration_response_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_integration_response::GetIntegrationResponseOutput,
9 crate::operation::get_integration_response::GetIntegrationResponseError,
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_integration_response::GetIntegrationResponseError::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::get_integration_response::GetIntegrationResponseError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "NotFoundException" => crate::operation::get_integration_response::GetIntegrationResponseError::NotFoundException({
28 #[allow(unused_mut)]
29 let mut tmp = {
30 #[allow(unused_mut)]
31 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
32 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
33 .map_err(crate::operation::get_integration_response::GetIntegrationResponseError::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 "TooManyRequestsException" => crate::operation::get_integration_response::GetIntegrationResponseError::TooManyRequestsException({
43 #[allow(unused_mut)]
44 let mut tmp = {
45 #[allow(unused_mut)]
46 let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
47 output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
48 .map_err(crate::operation::get_integration_response::GetIntegrationResponseError::unhandled)?;
49 let output = output.meta(generic);
50 output.build()
51 };
52 if tmp.message.is_none() {
53 tmp.message = _error_message;
54 }
55 tmp
56 }),
57 _ => crate::operation::get_integration_response::GetIntegrationResponseError::generic(generic),
58 })
59}
60
61#[allow(clippy::unnecessary_wraps)]
62pub fn de_get_integration_response_http_response(
63 _response_status: u16,
64 _response_headers: &::aws_smithy_runtime_api::http::Headers,
65 _response_body: &[u8],
66) -> std::result::Result<
67 crate::operation::get_integration_response::GetIntegrationResponseOutput,
68 crate::operation::get_integration_response::GetIntegrationResponseError,
69> {
70 Ok({
71 #[allow(unused_mut)]
72 let mut output = crate::operation::get_integration_response::builders::GetIntegrationResponseOutputBuilder::default();
73 output = crate::protocol_serde::shape_get_integration_response::de_get_integration_response(_response_body, output)
74 .map_err(crate::operation::get_integration_response::GetIntegrationResponseError::unhandled)?;
75 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
76 output.build()
77 })
78}
79
80pub(crate) fn de_get_integration_response(
81 value: &[u8],
82 mut builder: crate::operation::get_integration_response::builders::GetIntegrationResponseOutputBuilder,
83) -> ::std::result::Result<
84 crate::operation::get_integration_response::builders::GetIntegrationResponseOutputBuilder,
85 ::aws_smithy_json::deserialize::error::DeserializeError,
86> {
87 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
88 let tokens = &mut tokens_owned;
89 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
90 loop {
91 match tokens.next().transpose()? {
92 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
93 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
94 "contentHandlingStrategy" => {
95 builder = builder.set_content_handling_strategy(
96 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
97 .map(|s| s.to_unescaped().map(|u| crate::types::ContentHandlingStrategy::from(u.as_ref())))
98 .transpose()?,
99 );
100 }
101 "integrationResponseId" => {
102 builder = builder.set_integration_response_id(
103 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
104 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
105 .transpose()?,
106 );
107 }
108 "integrationResponseKey" => {
109 builder = builder.set_integration_response_key(
110 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
111 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
112 .transpose()?,
113 );
114 }
115 "responseParameters" => {
116 builder =
117 builder.set_response_parameters(crate::protocol_serde::shape_integration_parameters::de_integration_parameters(tokens)?);
118 }
119 "responseTemplates" => {
120 builder = builder.set_response_templates(crate::protocol_serde::shape_template_map::de_template_map(tokens)?);
121 }
122 "templateSelectionExpression" => {
123 builder = builder.set_template_selection_expression(
124 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
125 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
126 .transpose()?,
127 );
128 }
129 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
130 },
131 other => {
132 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
133 "expected object key or end object, found: {:?}",
134 other
135 )))
136 }
137 }
138 }
139 if tokens.next().is_some() {
140 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
141 "found more JSON tokens after completing parsing",
142 ));
143 }
144 Ok(builder)
145}