130 134 | crate::operation::escaped_string_values::EscapedStringValuesError,
|
131 135 | >::new());
|
132 136 |
|
133 137 | ::std::borrow::Cow::Owned(rcb)
|
134 138 | }
|
135 139 | }
|
136 140 |
|
137 141 | #[derive(Debug)]
|
138 142 | struct EscapedStringValuesResponseDeserializer;
|
139 143 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EscapedStringValuesResponseDeserializer {
|
140 - | fn deserialize_nonstreaming(
|
144 + | fn deserialize_nonstreaming_with_config(
|
141 145 | &self,
|
142 146 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
147 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
143 148 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
144 149 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
145 - | let headers = response.headers();
|
146 - | let body = response.body().bytes().expect("body loaded");
|
147 150 | #[allow(unused_mut)]
|
148 151 | let mut force_error = false;
|
149 152 |
|
150 - | let parse_result = if !success && status != 200 || force_error {
|
151 - | crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_error(status, headers, body)
|
153 + | if !success && status != 200 || force_error {
|
154 + | let headers = response.headers();
|
155 + | let body = response.body().bytes().expect("body loaded");
|
156 + | #[allow(unused_mut)]
|
157 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
158 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
159 + | })?;
|
160 + |
|
161 + | let generic = generic_builder.build();
|
162 + | let error_code = match generic.code() {
|
163 + | ::std::option::Option::Some(code) => code,
|
164 + | ::std::option::Option::None => {
|
165 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
166 + | ::aws_smithy_runtime_api::box_error::BoxError::from(
|
167 + | crate::operation::escaped_string_values::EscapedStringValuesError::unhandled(generic),
|
168 + | ),
|
169 + | ))
|
170 + | }
|
171 + | };
|
172 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
173 + | let protocol = _cfg
|
174 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
175 + | .expect("a SharedClientProtocol is required");
|
176 + | let err = match error_code {
|
177 + | "ValidationException" => crate::operation::escaped_string_values::EscapedStringValuesError::ValidationError({
|
178 + | let mut tmp = match protocol
|
179 + | .deserialize_response(response, crate::types::error::ValidationError::SCHEMA, _cfg)
|
180 + | .and_then(|mut deser| {
|
181 + | crate::types::error::ValidationError::deserialize_with_response(
|
182 + | &mut *deser,
|
183 + | response.headers(),
|
184 + | response.status().into(),
|
185 + | body,
|
186 + | )
|
187 + | }) {
|
188 + | ::std::result::Result::Ok(val) => val,
|
189 + | ::std::result::Result::Err(e) => {
|
190 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
191 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
192 + | ))
|
193 + | }
|
194 + | };
|
195 + | tmp.meta = generic;
|
196 + | tmp
|
197 + | }),
|
198 + | "ExtraError" => crate::operation::escaped_string_values::EscapedStringValuesError::ExtraError({
|
199 + | let mut tmp = match protocol
|
200 + | .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
|
201 + | .and_then(|mut deser| {
|
202 + | crate::types::error::ExtraError::deserialize_with_response(
|
203 + | &mut *deser,
|
204 + | response.headers(),
|
205 + | response.status().into(),
|
206 + | body,
|
207 + | )
|
208 + | }) {
|
209 + | ::std::result::Result::Ok(val) => val,
|
210 + | ::std::result::Result::Err(e) => {
|
211 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
212 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
213 + | ))
|
214 + | }
|
215 + | };
|
216 + | tmp.meta = generic;
|
217 + | if tmp.message.is_none() {
|
218 + | tmp.message = _error_message;
|
219 + | }
|
220 + | tmp
|
221 + | }),
|
222 + | _ => crate::operation::escaped_string_values::EscapedStringValuesError::generic(generic),
|
223 + | };
|
224 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
225 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
226 + | ))
|
152 227 | } else {
|
153 - | crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_response(status, headers, body)
|
154 - | };
|
155 - | crate::protocol_serde::type_erase_result(parse_result)
|
228 + | let protocol = _cfg
|
229 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
230 + | .expect("a SharedClientProtocol is required");
|
231 + | let mut deser = protocol
|
232 + | .deserialize_response(response, EscapedStringValues::OUTPUT_SCHEMA, _cfg)
|
233 + | .map_err(|e| {
|
234 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
235 + | })?;
|
236 + | let body = response.body().bytes().expect("body loaded");
|
237 + | let output = crate::operation::escaped_string_values::EscapedStringValuesOutput::deserialize_with_response(
|
238 + | &mut *deser,
|
239 + | response.headers(),
|
240 + | response.status().into(),
|
241 + | body,
|
242 + | )
|
243 + | .map_err(|e| {
|
244 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
245 + | })?;
|
246 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
247 + | }
|
156 248 | }
|
157 249 | }
|
158 250 | #[derive(Debug)]
|
159 251 | struct EscapedStringValuesRequestSerializer;
|
160 252 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EscapedStringValuesRequestSerializer {
|
161 253 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
162 254 | fn serialize_input(
|
163 255 | &self,
|
164 256 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
165 257 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
166 258 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
167 259 | let input = input
|
168 260 | .downcast::<crate::operation::escaped_string_values::EscapedStringValuesInput>()
|
169 261 | .expect("correct type");
|
170 - | let _header_serialization_settings = _cfg
|
171 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
172 - | .cloned()
|
173 - | .unwrap_or_default();
|
174 - | let mut request_builder = {
|
175 - | #[allow(clippy::uninlined_format_args)]
|
176 - | fn uri_base(
|
177 - | _input: &crate::operation::escaped_string_values::EscapedStringValuesInput,
|
178 - | output: &mut ::std::string::String,
|
179 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
180 - | use ::std::fmt::Write as _;
|
181 - | ::std::write!(output, "/escaped-string-values").expect("formatting should succeed");
|
182 - | ::std::result::Result::Ok(())
|
183 - | }
|
184 - | #[allow(clippy::unnecessary_wraps)]
|
185 - | fn update_http_builder(
|
186 - | input: &crate::operation::escaped_string_values::EscapedStringValuesInput,
|
187 - | builder: ::http_1x::request::Builder,
|
188 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
189 - | let mut uri = ::std::string::String::new();
|
190 - | uri_base(input, &mut uri)?;
|
191 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
192 - | }
|
193 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
194 - | builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/json");
|
195 - | builder
|
196 - | };
|
197 - | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_input(
|
198 - | &input,
|
199 - | )?);
|
200 - | if let Some(content_length) = body.content_length() {
|
201 - | let content_length = content_length.to_string();
|
202 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
203 - | }
|
204 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
262 + | let protocol = _cfg
|
263 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
264 + | .expect("a SharedClientProtocol is required");
|
265 + | let mut request = protocol
|
266 + | .serialize_request(&input, EscapedStringValues::INPUT_SCHEMA, "", _cfg)
|
267 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
268 + |
|
269 + | return ::std::result::Result::Ok(request);
|
205 270 | }
|
206 271 | }
|
207 272 | #[derive(Debug)]
|
208 273 | struct EscapedStringValuesEndpointParamsInterceptor;
|
209 274 |
|
210 275 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EscapedStringValuesEndpointParamsInterceptor {
|
211 276 | fn name(&self) -> &'static str {
|
212 277 | "EscapedStringValuesEndpointParamsInterceptor"
|
213 278 | }
|
214 279 |
|
311 376 | .expect("the config must have a deserializer");
|
312 377 |
|
313 378 | let parsed = de.deserialize_streaming(&mut http_response);
|
314 379 | let parsed = parsed.unwrap_or_else(|| {
|
315 380 | let http_response = http_response.map(|body| {
|
316 381 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
317 382 | body.bytes().unwrap(),
|
318 383 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
319 384 | )))
|
320 385 | });
|
321 - | de.deserialize_nonstreaming(&http_response)
|
386 + | // Build a config bag with the protocol for schema-based deserialization
|
387 + | #[allow(unused_mut)]
|
388 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
389 + | {
|
390 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
391 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
392 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
393 + | ));
|
394 + | test_cfg.push_shared_layer(layer.freeze());
|
395 + | }
|
396 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
322 397 | });
|
323 398 | let parsed = parsed
|
324 399 | .expect("should be successful response")
|
325 400 | .downcast::<crate::operation::escaped_string_values::EscapedStringValuesOutput>()
|
326 401 | .unwrap();
|
327 402 | ::pretty_assertions::assert_eq!(parsed.r#enum, expected_output.r#enum, "Unexpected value for `r#enum`");
|
328 403 | ::pretty_assertions::assert_eq!(parsed.some_string, expected_output.some_string, "Unexpected value for `some_string`");
|
329 404 | }
|
330 405 |
|
331 406 | /// Upper case error modeled lower case
|
332 407 | /// Test ID: ServiceLevelErrorClient
|
333 408 | #[::tokio::test]
|
334 409 | #[::tracing_test::traced_test]
|
335 410 | async fn service_level_error_client_response() {
|
336 411 | let expected_output = crate::types::error::ExtraError::builder().build();
|
337 412 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
338 413 | ::http_1x::response::Builder::new()
|
339 414 | .header("X-Amzn-Errortype", "ExtraError")
|
340 415 | .status(500)
|
341 416 | .body(::aws_smithy_types::body::SdkBody::from(""))
|
342 417 | .unwrap(),
|
343 418 | )
|
344 419 | .unwrap();
|
345 420 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
346 421 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
347 422 |
|
348 423 | let op = crate::operation::escaped_string_values::EscapedStringValues::new();
|
349 424 | let config = op.config().expect("the operation has config");
|
350 425 | let de = config
|
351 426 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
352 427 | .expect("the config must have a deserializer");
|
353 428 |
|
354 429 | let parsed = de.deserialize_streaming(&mut http_response);
|
355 430 | let parsed = parsed.unwrap_or_else(|| {
|
356 431 | let http_response = http_response.map(|body| {
|
357 432 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
358 433 | body.bytes().unwrap(),
|
359 434 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
360 435 | )))
|
361 436 | });
|
362 - | de.deserialize_nonstreaming(&http_response)
|
437 + | // Build a config bag with the protocol for schema-based deserialization
|
438 + | #[allow(unused_mut)]
|
439 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
440 + | {
|
441 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
442 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
443 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
444 + | ));
|
445 + | test_cfg.push_shared_layer(layer.freeze());
|
446 + | }
|
447 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
363 448 | });
|
364 449 | let parsed = parsed.expect_err("should be error response");
|
365 450 | let parsed: &crate::operation::escaped_string_values::EscapedStringValuesError =
|
366 451 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
367 452 | if let crate::operation::escaped_string_values::EscapedStringValuesError::ExtraError(parsed) = parsed {
|
368 453 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
369 454 | } else {
|
370 455 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
371 456 | }
|
372 457 | }
|