Skip to main content

aws_sdk_ssooidc/
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 SSO OIDC
10///
11/// Client for invoking operations on AWS SSO OIDC. Each operation on AWS SSO OIDC is a method on this
12/// this struct. `.send()` MUST be invoked on the generated operations to dispatch the request to the service.
13/// # Using the `Client`
14///
15/// A client has a function for every operation that can be performed by the service.
16/// For example, the [`CreateToken`](crate::operation::create_token) operation has
17/// a [`Client::create_token`], function which returns a builder for that operation.
18/// The fluent builder ultimately has a `send()` function that returns an async future that
19/// returns a result, as illustrated below:
20///
21/// ```rust,ignore
22/// let result = client.create_token()
23///     .client_id("example")
24///     .send()
25///     .await;
26/// ```
27///
28/// The underlying HTTP requests that get made by this can be modified with the `customize_operation`
29/// function on the fluent builder. See the [`customize`](crate::client::customize) module for more
30/// information.
31#[derive(::std::clone::Clone, ::std::fmt::Debug)]
32pub struct Client {
33    handle: ::std::sync::Arc<Handle>,
34}
35
36impl Client {
37    /// Creates a new client from the service [`Config`](crate::Config).
38    ///
39    /// # Panics
40    ///
41    /// This method will panic in the following cases:
42    ///
43    /// - Retries or timeouts are enabled without a `sleep_impl` configured.
44    /// - Identity caching is enabled without a `sleep_impl` and `time_source` configured.
45    /// - No `behavior_version` is provided.
46    ///
47    /// The panic message for each of these will have instructions on how to resolve them.
48    #[track_caller]
49    pub fn from_conf(conf: crate::Config) -> Self {
50        let handle = Handle {
51            conf: conf.clone(),
52            runtime_plugins: crate::config::base_client_runtime_plugins(conf),
53        };
54        if let Err(err) = Self::validate_config(&handle) {
55            panic!("Invalid client configuration: {err}");
56        }
57        Self {
58            handle: ::std::sync::Arc::new(handle),
59        }
60    }
61
62    /// Returns the client's configuration.
63    pub fn config(&self) -> &crate::Config {
64        &self.handle.conf
65    }
66
67    fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
68        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
69        handle
70            .runtime_plugins
71            .apply_client_configuration(&mut cfg)?
72            .validate_base_client_config(&cfg)?;
73        Ok(())
74    }
75}
76
77impl Client {
78    /// Creates a new client from an [SDK Config](::aws_types::sdk_config::SdkConfig).
79    ///
80    /// # Panics
81    ///
82    /// - This method will panic if the `sdk_config` is missing an async sleep implementation. If you experience this panic, set
83    ///   the `sleep_impl` on the Config passed into this function to fix it.
84    /// - This method will panic if the `sdk_config` is missing an HTTP connector. If you experience this panic, set the
85    ///   `http_connector` on the Config passed into this function to fix it.
86    /// - 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.
87    #[track_caller]
88    pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
89        Self::from_conf(sdk_config.into())
90    }
91}
92
93impl Client {
94    /// Returns the type registry for this service.
95    ///
96    /// The registry contains an entry for every structure shape in the service
97    /// closure (excluding only synthetic operation input/output shapes),
98    /// keyed by [`ShapeId`](::aws_smithy_schema::ShapeId). It is primarily useful for deserializing
99    /// a [`Document`](::aws_smithy_types::Document) into a typed shape:
100    ///
101    /// ```ignore
102    /// let registry = MyClient::registry();
103    /// let typed = registry.deserialize_document(&doc)?;
104    /// // Downcast to the concrete type you expected.
105    /// ```
106    pub fn registry() -> &'static ::aws_smithy_schema::registry::TypeRegistry {
107        &crate::type_registry::REGISTRY
108    }
109}
110
111impl Client {
112    /// Returns the service-wide error registry.
113    ///
114    /// The registry contains an entry for every `@error`-trait structure shape
115    /// in the service closure, keyed by [`ShapeId`](::aws_smithy_schema::ShapeId). Use it to reify a
116    /// discriminated [`Document`](::aws_smithy_types::Document) into a typed error variant via
117    /// [`TypeRegistry::deserialize_document`](::aws_smithy_schema::registry::TypeRegistry::deserialize_document).
118    ///
119    /// This registry is provided for third-party `Document`-based error handling.
120    /// Internally it also serves as the widening fallback when the schema-serde
121    /// error path reifies an error code that an operation does not model directly
122    /// (the operation's own error registry is consulted first).
123    ///
124    /// ```ignore
125    /// let registry = MyClient::error_registry();
126    /// let typed = registry.deserialize_document(&doc)?;
127    /// // Downcast to the concrete error variant you expected.
128    /// ```
129    pub fn error_registry() -> &'static ::aws_smithy_schema::registry::TypeRegistry {
130        &crate::error_type_registry::REGISTRY
131    }
132}
133
134mod create_token;
135
136mod create_token_with_iam;
137
138/// Operation customization and supporting types.
139///
140/// The underlying HTTP requests made during an operation can be customized
141/// by calling the `customize()` method on the builder returned from a client
142/// operation call. For example, this can be used to add an additional HTTP header:
143///
144/// ```ignore
145/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_ssooidc::Error> {
146/// # let client: aws_sdk_ssooidc::Client = unimplemented!();
147/// use ::http_1x::header::{HeaderName, HeaderValue};
148///
149/// let result = client.create_token()
150///     .customize()
151///     .mutate_request(|req| {
152///         // Add `x-example-header` with value
153///         req.headers_mut()
154///             .insert(
155///                 HeaderName::from_static("x-example-header"),
156///                 HeaderValue::from_static("1"),
157///             );
158///     })
159///     .send()
160///     .await;
161/// # }
162/// ```
163pub mod customize;
164
165mod register_client;
166
167mod start_device_authorization;