aws_sdk_apigatewayv2/protocol_serde/
shape_update_authorizer.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_authorizer_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::update_authorizer::UpdateAuthorizerOutput, crate::operation::update_authorizer::UpdateAuthorizerError> {
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::update_authorizer::UpdateAuthorizerError::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::update_authorizer::UpdateAuthorizerError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "BadRequestException" => crate::operation::update_authorizer::UpdateAuthorizerError::BadRequestException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
25 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
26 .map_err(crate::operation::update_authorizer::UpdateAuthorizerError::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 "ConflictException" => crate::operation::update_authorizer::UpdateAuthorizerError::ConflictException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
40 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
41 .map_err(crate::operation::update_authorizer::UpdateAuthorizerError::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 "NotFoundException" => crate::operation::update_authorizer::UpdateAuthorizerError::NotFoundException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
55 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
56 .map_err(crate::operation::update_authorizer::UpdateAuthorizerError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 "TooManyRequestsException" => crate::operation::update_authorizer::UpdateAuthorizerError::TooManyRequestsException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
70 output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
71 .map_err(crate::operation::update_authorizer::UpdateAuthorizerError::unhandled)?;
72 let output = output.meta(generic);
73 output.build()
74 };
75 if tmp.message.is_none() {
76 tmp.message = _error_message;
77 }
78 tmp
79 }),
80 _ => crate::operation::update_authorizer::UpdateAuthorizerError::generic(generic),
81 })
82}
83
84#[allow(clippy::unnecessary_wraps)]
85pub fn de_update_authorizer_http_response(
86 _response_status: u16,
87 _response_headers: &::aws_smithy_runtime_api::http::Headers,
88 _response_body: &[u8],
89) -> std::result::Result<crate::operation::update_authorizer::UpdateAuthorizerOutput, crate::operation::update_authorizer::UpdateAuthorizerError> {
90 Ok({
91 #[allow(unused_mut)]
92 let mut output = crate::operation::update_authorizer::builders::UpdateAuthorizerOutputBuilder::default();
93 output = crate::protocol_serde::shape_update_authorizer::de_update_authorizer(_response_body, output)
94 .map_err(crate::operation::update_authorizer::UpdateAuthorizerError::unhandled)?;
95 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
96 output.build()
97 })
98}
99
100pub fn ser_update_authorizer_input(
101 input: &crate::operation::update_authorizer::UpdateAuthorizerInput,
102) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
103 let mut out = String::new();
104 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
105 crate::protocol_serde::shape_update_authorizer_input::ser_update_authorizer_input_input(&mut object, input)?;
106 object.finish();
107 Ok(::aws_smithy_types::body::SdkBody::from(out))
108}
109
110pub(crate) fn de_update_authorizer(
111 value: &[u8],
112 mut builder: crate::operation::update_authorizer::builders::UpdateAuthorizerOutputBuilder,
113) -> ::std::result::Result<
114 crate::operation::update_authorizer::builders::UpdateAuthorizerOutputBuilder,
115 ::aws_smithy_json::deserialize::error::DeserializeError,
116> {
117 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
118 let tokens = &mut tokens_owned;
119 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
120 loop {
121 match tokens.next().transpose()? {
122 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
123 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
124 "authorizerCredentialsArn" => {
125 builder = builder.set_authorizer_credentials_arn(
126 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
127 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
128 .transpose()?,
129 );
130 }
131 "authorizerId" => {
132 builder = builder.set_authorizer_id(
133 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
134 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
135 .transpose()?,
136 );
137 }
138 "authorizerPayloadFormatVersion" => {
139 builder = builder.set_authorizer_payload_format_version(
140 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
141 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
142 .transpose()?,
143 );
144 }
145 "authorizerResultTtlInSeconds" => {
146 builder = builder.set_authorizer_result_ttl_in_seconds(
147 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
148 .map(i32::try_from)
149 .transpose()?,
150 );
151 }
152 "authorizerType" => {
153 builder = builder.set_authorizer_type(
154 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
155 .map(|s| s.to_unescaped().map(|u| crate::types::AuthorizerType::from(u.as_ref())))
156 .transpose()?,
157 );
158 }
159 "authorizerUri" => {
160 builder = builder.set_authorizer_uri(
161 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
162 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
163 .transpose()?,
164 );
165 }
166 "enableSimpleResponses" => {
167 builder = builder.set_enable_simple_responses(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
168 }
169 "identitySource" => {
170 builder = builder.set_identity_source(crate::protocol_serde::shape_identity_source_list::de_identity_source_list(tokens)?);
171 }
172 "identityValidationExpression" => {
173 builder = builder.set_identity_validation_expression(
174 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
175 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
176 .transpose()?,
177 );
178 }
179 "jwtConfiguration" => {
180 builder = builder.set_jwt_configuration(crate::protocol_serde::shape_jwt_configuration::de_jwt_configuration(tokens)?);
181 }
182 "name" => {
183 builder = builder.set_name(
184 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
185 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
186 .transpose()?,
187 );
188 }
189 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
190 },
191 other => {
192 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
193 "expected object key or end object, found: {:?}",
194 other
195 )))
196 }
197 }
198 }
199 if tokens.next().is_some() {
200 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
201 "found more JSON tokens after completing parsing",
202 ));
203 }
204 Ok(builder)
205}