266 266 | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
267 267 | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
268 268 | .allow_no_auth()
|
269 269 | .endpoint_url("https://example.com");
|
270 270 |
|
271 271 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
272 272 | let result = client
|
273 273 | .http_query_params_only_operation()
|
274 274 | .set_query_map(::std::option::Option::Some({
|
275 275 | let mut ret = ::std::collections::HashMap::new();
|
276 - | ret.insert("shouldExpandRoles".to_owned(), "true".to_owned());
|
277 - | ret.insert("shouldShowOnlyAuthForThisDocument".to_owned(), "false".to_owned());
|
276 + | ret.insert("a".to_owned(), "b".to_owned());
|
277 + | ret.insert("c".to_owned(), "d".to_owned());
|
278 278 | ret
|
279 279 | }))
|
280 280 | .send()
|
281 281 | .await;
|
282 282 | let _ = dbg!(result);
|
283 283 | let http_request = request_receiver.expect_request();
|
284 - | let expected_query_params = &["shouldExpandRoles=true", "shouldShowOnlyAuthForThisDocument=false"];
|
284 + | let expected_query_params = &["a=b", "c=d"];
|
285 285 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_query_string(&http_request, expected_query_params));
|
286 286 | let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
|
287 287 | ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
|
288 288 | ::pretty_assertions::assert_eq!(uri.path(), "/http-query-params-only", "path was incorrect");
|
289 289 | }
|
290 290 |
|
291 291 | /// Test that empty httpQueryParams map results in no query parameters
|
292 292 | /// Test ID: HttpQueryParamsOnlyEmptyRequest
|
293 293 | #[::tokio::test]
|
294 294 | #[::tracing_test::traced_test]
|
295 295 | async fn http_query_params_only_empty_request_request() {
|
296 296 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
297 297 | let config_builder = crate::config::Config::builder()
|
298 298 | .with_test_defaults()
|
299 299 | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
300 300 | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
301 301 | .allow_no_auth()
|
302 302 | .endpoint_url("https://example.com");
|
303 303 |
|
304 304 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
305 305 | let result = client
|
306 306 | .http_query_params_only_operation()
|
307 307 | .set_query_map(::std::option::Option::Some(::std::collections::HashMap::new()))
|
308 308 | .send()
|
309 309 | .await;
|
310 310 | let _ = dbg!(result);
|
311 311 | let http_request = request_receiver.expect_request();
|
312 312 | let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
|
313 313 | ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
|
314 314 | ::pretty_assertions::assert_eq!(uri.path(), "/http-query-params-only", "path was incorrect");
|
315 315 | }
|
316 - |
|
317 - | /// Upper case error modeled lower case
|
318 - | /// Test ID: ServiceLevelErrorClient
|
319 - | #[::tokio::test]
|
320 - | #[::tracing_test::traced_test]
|
321 - | async fn service_level_error_client_response() {
|
322 - | let expected_output = crate::types::error::ExtraError::builder().build();
|
323 - | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
324 - | ::http_1x::response::Builder::new()
|
325 - | .header("X-Amzn-Errortype", "ExtraError")
|
326 - | .status(500)
|
327 - | .body(::aws_smithy_types::body::SdkBody::from(""))
|
328 - | .unwrap(),
|
329 - | )
|
330 - | .unwrap();
|
331 - | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
332 - | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
333 - |
|
334 - | let op = crate::operation::http_query_params_only_operation::HttpQueryParamsOnlyOperation::new();
|
335 - | let config = op.config().expect("the operation has config");
|
336 - | let de = config
|
337 - | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
338 - | .expect("the config must have a deserializer");
|
339 - |
|
340 - | let parsed = de.deserialize_streaming(&mut http_response);
|
341 - | let parsed = parsed.unwrap_or_else(|| {
|
342 - | let http_response = http_response.map(|body| {
|
343 - | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
344 - | body.bytes().unwrap(),
|
345 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
346 - | )))
|
347 - | });
|
348 - | de.deserialize_nonstreaming(&http_response)
|
349 - | });
|
350 - | let parsed = parsed.expect_err("should be error response");
|
351 - | let parsed: &crate::operation::http_query_params_only_operation::HttpQueryParamsOnlyOperationError =
|
352 - | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
353 - | if let crate::operation::http_query_params_only_operation::HttpQueryParamsOnlyOperationError::ExtraError(parsed) = parsed {
|
354 - | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
355 - | } else {
|
356 - | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
357 - | }
|
358 - | }
|
359 316 | }
|
360 317 |
|
361 318 | /// Error type for the `HttpQueryParamsOnlyOperationError` operation.
|
362 319 | #[non_exhaustive]
|
363 320 | #[derive(::std::fmt::Debug)]
|
364 321 | pub enum HttpQueryParamsOnlyOperationError {
|
365 - | #[allow(missing_docs)] // documentation missing in model
|
366 - | ExtraError(crate::types::error::ExtraError),
|
367 322 | /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
|
368 323 | #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
|
369 324 | variable wildcard pattern and check `.code()`:
|
370 325 | \
|
371 326 | `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
|
372 327 | \
|
373 328 | See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-HttpQueryParamsOnlyOperationError) for what information is available for the error.")]
|
374 329 | Unhandled(crate::error::sealed_unhandled::Unhandled),
|
375 330 | }
|
376 331 | impl HttpQueryParamsOnlyOperationError {
|
377 332 | /// Creates the `HttpQueryParamsOnlyOperationError::Unhandled` variant from any error type.
|
378 333 | pub fn unhandled(
|
379 334 | err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
|
380 335 | ) -> Self {
|
381 336 | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
382 337 | source: err.into(),
|
383 338 | meta: ::std::default::Default::default(),
|
384 339 | })
|
385 340 | }
|
386 341 |
|
387 342 | /// Creates the `HttpQueryParamsOnlyOperationError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
|
388 343 | pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
|
389 344 | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
390 345 | source: err.clone().into(),
|
391 346 | meta: err,
|
392 347 | })
|
393 348 | }
|
394 349 | ///
|
395 350 | /// Returns error metadata, which includes the error code, message,
|
396 351 | /// request ID, and potentially additional information.
|
397 352 | ///
|
398 353 | pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
399 354 | match self {
|
400 - | Self::ExtraError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
|
401 355 | Self::Unhandled(e) => &e.meta,
|
402 356 | }
|
403 357 | }
|
404 - | /// Returns `true` if the error kind is `HttpQueryParamsOnlyOperationError::ExtraError`.
|
405 - | pub fn is_extra_error(&self) -> bool {
|
406 - | matches!(self, Self::ExtraError(_))
|
407 - | }
|
408 358 | }
|
409 359 | impl ::std::error::Error for HttpQueryParamsOnlyOperationError {
|
410 360 | fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
|
411 361 | match self {
|
412 - | Self::ExtraError(_inner) => ::std::option::Option::Some(_inner),
|
413 362 | Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
|
414 363 | }
|
415 364 | }
|
416 365 | }
|
417 366 | impl ::std::fmt::Display for HttpQueryParamsOnlyOperationError {
|
418 367 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
419 368 | match self {
|
420 - | Self::ExtraError(_inner) => _inner.fmt(f),
|
421 369 | Self::Unhandled(_inner) => {
|
422 370 | if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
|
423 371 | write!(f, "unhandled error ({code})")
|
424 372 | } else {
|
425 373 | f.write_str("unhandled error")
|
426 374 | }
|
427 375 | }
|
428 376 | }
|
429 377 | }
|
430 378 | }
|
431 379 | impl ::aws_smithy_types::retry::ProvideErrorKind for HttpQueryParamsOnlyOperationError {
|
432 380 | fn code(&self) -> ::std::option::Option<&str> {
|
433 381 | ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
|
434 382 | }
|
435 383 | fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
|
436 384 | ::std::option::Option::None
|
437 385 | }
|
438 386 | }
|
439 387 | impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for HttpQueryParamsOnlyOperationError {
|
440 388 | fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
441 389 | match self {
|
442 - | Self::ExtraError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
|
443 390 | Self::Unhandled(_inner) => &_inner.meta,
|
444 391 | }
|
445 392 | }
|
446 393 | }
|
447 394 | impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for HttpQueryParamsOnlyOperationError {
|
448 395 | fn create_unhandled_error(
|
449 396 | source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
|
450 397 | meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
|
451 398 | ) -> Self {
|
452 399 | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
453 400 | source,
|
454 401 | meta: meta.unwrap_or_default(),
|
455 402 | })
|
456 403 | }
|
457 404 | }
|
458 405 |
|
459 - | pub use crate::operation::http_query_params_only_operation::_http_query_params_only_operation_output::HttpQueryParamsOnlyOperationOutput;
|
460 - |
|
461 406 | pub use crate::operation::http_query_params_only_operation::_http_query_params_only_operation_input::HttpQueryParamsOnlyOperationInput;
|
462 407 |
|
408 + | pub use crate::operation::http_query_params_only_operation::_http_query_params_only_operation_output::HttpQueryParamsOnlyOperationOutput;
|
409 + |
|
463 410 | mod _http_query_params_only_operation_input;
|
464 411 |
|
465 412 | mod _http_query_params_only_operation_output;
|
466 413 |
|
467 414 | /// Builders
|
468 415 | pub mod builders;
|