1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | /// Orchestration and serialization glue logic for `GreetingWithUnwrappedErrors`.
|
3 3 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
4 4 | #[non_exhaustive]
|
5 5 | pub struct GreetingWithUnwrappedErrors;
|
6 6 | impl GreetingWithUnwrappedErrors {
|
7 7 | /// Creates a new `GreetingWithUnwrappedErrors`
|
8 8 | pub fn new() -> Self {
|
9 9 | Self
|
10 10 | }
|
11 + | /// The schema for this operation's input shape.
|
12 + | pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
|
13 + | crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsInput::SCHEMA;
|
14 + | /// The schema for this operation's output shape.
|
15 + | pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
|
16 + | crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsOutput::SCHEMA;
|
11 17 | pub(crate) async fn orchestrate(
|
12 18 | runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
13 19 | input: crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsInput,
|
14 20 | ) -> ::std::result::Result<
|
15 21 | crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsOutput,
|
16 22 | ::aws_smithy_runtime_api::client::result::SdkError<
|
17 23 | crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsError,
|
18 24 | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
19 25 | >,
|
20 26 | > {
|
263 270 | .expect("the config must have a deserializer");
|
264 271 |
|
265 272 | let parsed = de.deserialize_streaming(&mut http_response);
|
266 273 | let parsed = parsed.unwrap_or_else(|| {
|
267 274 | let http_response = http_response.map(|body| {
|
268 275 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
269 276 | body.bytes().unwrap(),
|
270 277 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
271 278 | )))
|
272 279 | });
|
273 - | de.deserialize_nonstreaming(&http_response)
|
280 + | // Build a config bag with the protocol for schema-based deserialization
|
281 + | #[allow(unused_mut)]
|
282 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
283 + |
|
284 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
274 285 | });
|
275 286 | let parsed = parsed
|
276 287 | .expect("should be successful response")
|
277 288 | .downcast::<crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsOutput>()
|
278 289 | .unwrap();
|
279 290 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
280 291 | }
|
281 292 |
|
282 293 | /// Parses simple XML errors
|
283 294 | /// Test ID: InvalidGreetingErrorUnwrapped
|
284 295 | #[::tokio::test]
|
285 296 | #[::tracing_test::traced_test]
|
286 297 | async fn invalid_greeting_error_unwrapped_response() {
|
287 298 | let expected_output = crate::types::error::InvalidGreetingUnwrapped::builder()
|
288 299 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
289 300 | .build();
|
290 301 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
291 302 | .header("Content-Type", "application/xml")
|
292 303 | .status(400)
|
293 304 | .body(::aws_smithy_types::body::SdkBody::from(" <Error>\n <Type>Sender</Type>\n <Code>InvalidGreetingUnwrapped</Code>\n <Message>Hi</Message>\n <AnotherSetting>setting</AnotherSetting>\n <RequestId>foo-id</RequestId>\n </Error>\n"))
|
294 305 | .unwrap()
|
295 306 | ).unwrap();
|
296 307 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
297 308 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
298 309 |
|
299 310 | let op = crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrors::new();
|
300 311 | let config = op.config().expect("the operation has config");
|
301 312 | let de = config
|
302 313 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
303 314 | .expect("the config must have a deserializer");
|
304 315 |
|
305 316 | let parsed = de.deserialize_streaming(&mut http_response);
|
306 317 | let parsed = parsed.unwrap_or_else(|| {
|
307 318 | let http_response = http_response.map(|body| {
|
308 319 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
309 320 | body.bytes().unwrap(),
|
310 321 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
311 322 | )))
|
312 323 | });
|
313 - | de.deserialize_nonstreaming(&http_response)
|
324 + | // Build a config bag with the protocol for schema-based deserialization
|
325 + | #[allow(unused_mut)]
|
326 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
327 + |
|
328 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
314 329 | });
|
315 330 | let parsed = parsed.expect_err("should be error response");
|
316 331 | let parsed: &crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsError =
|
317 332 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
318 333 | if let crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsError::InvalidGreetingUnwrapped(parsed) = parsed {
|
319 334 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
320 335 | } else {
|
321 336 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
322 337 | }
|
323 338 | }
|
324 339 | /// Test ID: ComplexErrorUnwrapped
|
325 340 | #[::tokio::test]
|
326 341 | #[::tracing_test::traced_test]
|
327 342 | async fn complex_error_unwrapped_response() {
|
328 343 | let expected_output = crate::types::error::ComplexErrorUnwrapped::builder()
|
329 344 | .set_header(::std::option::Option::Some("Header".to_owned()))
|
330 345 | .set_top_level(::std::option::Option::Some("Top level".to_owned()))
|
331 346 | .set_nested(::std::option::Option::Some(
|
332 347 | crate::types::ComplexNestedErrorData::builder()
|
333 348 | .set_foo(::std::option::Option::Some("bar".to_owned()))
|
334 349 | .build(),
|
335 350 | ))
|
336 351 | .build();
|
337 352 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
338 353 | .header("Content-Type", "application/xml")
|
339 354 | .header("X-Header", "Header")
|
340 355 | .status(400)
|
341 356 | .body(::aws_smithy_types::body::SdkBody::from(" <Error>\n <Type>Sender</Type>\n <Code>ComplexErrorUnwrapped</Code>\n <Message>Hi</Message>\n <TopLevel>Top level</TopLevel>\n <Nested>\n <Foo>bar</Foo>\n </Nested>\n <RequestId>foo-id</RequestId>\n </Error>\n"))
|
342 357 | .unwrap()
|
343 358 | ).unwrap();
|
344 359 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
345 360 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
346 361 |
|
347 362 | let op = crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrors::new();
|
348 363 | let config = op.config().expect("the operation has config");
|
349 364 | let de = config
|
350 365 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
351 366 | .expect("the config must have a deserializer");
|
352 367 |
|
353 368 | let parsed = de.deserialize_streaming(&mut http_response);
|
354 369 | let parsed = parsed.unwrap_or_else(|| {
|
355 370 | let http_response = http_response.map(|body| {
|
356 371 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
357 372 | body.bytes().unwrap(),
|
358 373 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
359 374 | )))
|
360 375 | });
|
361 - | de.deserialize_nonstreaming(&http_response)
|
376 + | // Build a config bag with the protocol for schema-based deserialization
|
377 + | #[allow(unused_mut)]
|
378 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
379 + |
|
380 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
362 381 | });
|
363 382 | let parsed = parsed.expect_err("should be error response");
|
364 383 | let parsed: &crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsError =
|
365 384 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
366 385 | if let crate::operation::greeting_with_unwrapped_errors::GreetingWithUnwrappedErrorsError::ComplexErrorUnwrapped(parsed) = parsed {
|
367 386 | ::pretty_assertions::assert_eq!(parsed.header, expected_output.header, "Unexpected value for `header`");
|
368 387 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
369 388 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
370 389 | } else {
|
371 390 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|