aws_sdk_apigatewayv2/protocol_serde/
shape_get_integration_responses.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_integration_responses_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_responses::GetIntegrationResponsesOutput,
9 crate::operation::get_integration_responses::GetIntegrationResponsesError,
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_responses::GetIntegrationResponsesError::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_responses::GetIntegrationResponsesError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "BadRequestException" => crate::operation::get_integration_responses::GetIntegrationResponsesError::BadRequestException({
28 #[allow(unused_mut)]
29 let mut tmp = {
30 #[allow(unused_mut)]
31 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
32 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
33 .map_err(crate::operation::get_integration_responses::GetIntegrationResponsesError::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 "NotFoundException" => crate::operation::get_integration_responses::GetIntegrationResponsesError::NotFoundException({
43 #[allow(unused_mut)]
44 let mut tmp = {
45 #[allow(unused_mut)]
46 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
47 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
48 .map_err(crate::operation::get_integration_responses::GetIntegrationResponsesError::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 "TooManyRequestsException" => crate::operation::get_integration_responses::GetIntegrationResponsesError::TooManyRequestsException({
58 #[allow(unused_mut)]
59 let mut tmp = {
60 #[allow(unused_mut)]
61 let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
62 output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
63 .map_err(crate::operation::get_integration_responses::GetIntegrationResponsesError::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_integration_responses::GetIntegrationResponsesError::generic(generic),
73 })
74}
75
76#[allow(clippy::unnecessary_wraps)]
77pub fn de_get_integration_responses_http_response(
78 _response_status: u16,
79 _response_headers: &::aws_smithy_runtime_api::http::Headers,
80 _response_body: &[u8],
81) -> std::result::Result<
82 crate::operation::get_integration_responses::GetIntegrationResponsesOutput,
83 crate::operation::get_integration_responses::GetIntegrationResponsesError,
84> {
85 Ok({
86 #[allow(unused_mut)]
87 let mut output = crate::operation::get_integration_responses::builders::GetIntegrationResponsesOutputBuilder::default();
88 output = crate::protocol_serde::shape_get_integration_responses::de_get_integration_responses(_response_body, output)
89 .map_err(crate::operation::get_integration_responses::GetIntegrationResponsesError::unhandled)?;
90 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
91 output.build()
92 })
93}
94
95pub(crate) fn de_get_integration_responses(
96 value: &[u8],
97 mut builder: crate::operation::get_integration_responses::builders::GetIntegrationResponsesOutputBuilder,
98) -> ::std::result::Result<
99 crate::operation::get_integration_responses::builders::GetIntegrationResponsesOutputBuilder,
100 ::aws_smithy_json::deserialize::error::DeserializeError,
101> {
102 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
103 let tokens = &mut tokens_owned;
104 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
105 loop {
106 match tokens.next().transpose()? {
107 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
108 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
109 "items" => {
110 builder = builder.set_items(crate::protocol_serde::shape_list_of_integration_response::de_list_of_integration_response(tokens)?);
111 }
112 "nextToken" => {
113 builder = builder.set_next_token(
114 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
115 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
116 .transpose()?,
117 );
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}