aws_sdk_signin/
client.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[derive(Debug)]
3pub(crate) struct Handle {
4    pub(crate) conf: crate::Config,
5    #[allow(dead_code)] // unused when a service does not provide any operations
6    pub(crate) runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
7}
8
9/// Client for AWS Sign-In Service
10///
11/// Client for invoking operations on AWS Sign-In Service. Each operation on AWS Sign-In Service is a method on this
12/// this struct. `.send()` MUST be invoked on the generated operations to dispatch the request to the service.
13#[derive(::std::clone::Clone, ::std::fmt::Debug)]
14pub struct Client {
15    handle: ::std::sync::Arc<Handle>,
16}
17
18impl Client {
19    /// Creates a new client from the service [`Config`](crate::Config).
20    ///
21    /// # Panics
22    ///
23    /// This method will panic in the following cases:
24    ///
25    /// - Retries or timeouts are enabled without a `sleep_impl` configured.
26    /// - Identity caching is enabled without a `sleep_impl` and `time_source` configured.
27    /// - No `behavior_version` is provided.
28    ///
29    /// The panic message for each of these will have instructions on how to resolve them.
30    #[track_caller]
31    pub fn from_conf(conf: crate::Config) -> Self {
32        let handle = Handle {
33            conf: conf.clone(),
34            runtime_plugins: crate::config::base_client_runtime_plugins(conf),
35        };
36        if let Err(err) = Self::validate_config(&handle) {
37            panic!("Invalid client configuration: {err}");
38        }
39        Self {
40            handle: ::std::sync::Arc::new(handle),
41        }
42    }
43
44    /// Returns the client's configuration.
45    pub fn config(&self) -> &crate::Config {
46        &self.handle.conf
47    }
48
49    fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
50        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
51        handle
52            .runtime_plugins
53            .apply_client_configuration(&mut cfg)?
54            .validate_base_client_config(&cfg)?;
55        Ok(())
56    }
57}
58
59impl Client {
60    /// Creates a new client from an [SDK Config](::aws_types::sdk_config::SdkConfig).
61    ///
62    /// # Panics
63    ///
64    /// - This method will panic if the `sdk_config` is missing an async sleep implementation. If you experience this panic, set
65    ///   the `sleep_impl` on the Config passed into this function to fix it.
66    /// - This method will panic if the `sdk_config` is missing an HTTP connector. If you experience this panic, set the
67    ///   `http_connector` on the Config passed into this function to fix it.
68    /// - This method will panic if no `BehaviorVersion` is provided. If you experience this panic, set `behavior_version` on the Config or enable the `behavior-version-latest` Cargo feature.
69    #[track_caller]
70    pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
71        Self::from_conf(sdk_config.into())
72    }
73}
74
75mod create_o_auth2_token;
76
77/// Operation customization and supporting types.
78///
79/// The underlying HTTP requests made during an operation can be customized
80/// by calling the `customize()` method on the builder returned from a client
81/// operation call. For example, this can be used to add an additional HTTP header:
82///
83/// ```ignore
84/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_signin::Error> {
85/// # let client: aws_sdk_signin::Client = unimplemented!();
86/// use ::http::header::{HeaderName, HeaderValue};
87///
88/// let result = client.create_o_auth2_token()
89///     .customize()
90///     .mutate_request(|req| {
91///         // Add `x-example-header` with value
92///         req.headers_mut()
93///             .insert(
94///                 HeaderName::from_static("x-example-header"),
95///                 HeaderValue::from_static("1"),
96///             );
97///     })
98///     .send()
99///     .await;
100/// # }
101/// ```
102pub mod customize;