aws_sdk_cognitoidentityprovider/
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 Amazon Cognito Identity Provider
10///
11/// Client for invoking operations on Amazon Cognito Identity Provider. Each operation on Amazon Cognito Identity Provider is a method on this
12/// this struct. `.send()` MUST be invoked on the generated operations to dispatch the request to the service.
13/// ## Constructing a `Client`
14///
15/// A [`Config`] is required to construct a client. For most use cases, the [`aws-config`]
16/// crate should be used to automatically resolve this config using
17/// [`aws_config::load_from_env()`], since this will resolve an [`SdkConfig`] which can be shared
18/// across multiple different AWS SDK clients. This config resolution process can be customized
19/// by calling [`aws_config::from_env()`] instead, which returns a [`ConfigLoader`] that uses
20/// the [builder pattern] to customize the default config.
21///
22/// In the simplest case, creating a client looks as follows:
23/// ```rust,no_run
24/// # async fn wrapper() {
25/// let config = aws_config::load_from_env().await;
26/// let client = aws_sdk_cognitoidentityprovider::Client::new(&config);
27/// # }
28/// ```
29///
30/// Occasionally, SDKs may have additional service-specific values that can be set on the [`Config`] that
31/// is absent from [`SdkConfig`], or slightly different settings for a specific client may be desired.
32/// The [`Builder`](crate::config::Builder) struct implements `From<&SdkConfig>`, so setting these specific settings can be
33/// done as follows:
34///
35/// ```rust,no_run
36/// # async fn wrapper() {
37/// let sdk_config = ::aws_config::load_from_env().await;
38/// let config = aws_sdk_cognitoidentityprovider::config::Builder::from(&sdk_config)
39/// # /*
40///     .some_service_specific_setting("value")
41/// # */
42///     .build();
43/// # }
44/// ```
45///
46/// See the [`aws-config` docs] and [`Config`] for more information on customizing configuration.
47///
48/// _Note:_ Client construction is expensive due to connection thread pool initialization, and should
49/// be done once at application start-up.
50///
51/// [`Config`]: crate::Config
52/// [`ConfigLoader`]: https://docs.rs/aws-config/*/aws_config/struct.ConfigLoader.html
53/// [`SdkConfig`]: https://docs.rs/aws-config/*/aws_config/struct.SdkConfig.html
54/// [`aws-config` docs]: https://docs.rs/aws-config/*
55/// [`aws-config`]: https://crates.io/crates/aws-config
56/// [`aws_config::from_env()`]: https://docs.rs/aws-config/*/aws_config/fn.from_env.html
57/// [`aws_config::load_from_env()`]: https://docs.rs/aws-config/*/aws_config/fn.load_from_env.html
58/// [builder pattern]: https://rust-lang.github.io/api-guidelines/type-safety.html#builders-enable-construction-of-complex-values-c-builder
59/// # Using the `Client`
60///
61/// A client has a function for every operation that can be performed by the service.
62/// For example, the [`AddCustomAttributes`](crate::operation::add_custom_attributes) operation has
63/// a [`Client::add_custom_attributes`], function which returns a builder for that operation.
64/// The fluent builder ultimately has a `send()` function that returns an async future that
65/// returns a result, as illustrated below:
66///
67/// ```rust,ignore
68/// let result = client.add_custom_attributes()
69///     .user_pool_id("example")
70///     .send()
71///     .await;
72/// ```
73///
74/// The underlying HTTP requests that get made by this can be modified with the `customize_operation`
75/// function on the fluent builder. See the [`customize`](crate::client::customize) module for more
76/// information.
77#[derive(::std::clone::Clone, ::std::fmt::Debug)]
78pub struct Client {
79    handle: ::std::sync::Arc<Handle>,
80}
81
82impl Client {
83    /// Creates a new client from the service [`Config`](crate::Config).
84    ///
85    /// # Panics
86    ///
87    /// This method will panic in the following cases:
88    ///
89    /// - Retries or timeouts are enabled without a `sleep_impl` configured.
90    /// - Identity caching is enabled without a `sleep_impl` and `time_source` configured.
91    /// - No `behavior_version` is provided.
92    ///
93    /// The panic message for each of these will have instructions on how to resolve them.
94    #[track_caller]
95    pub fn from_conf(conf: crate::Config) -> Self {
96        let handle = Handle {
97            conf: conf.clone(),
98            runtime_plugins: crate::config::base_client_runtime_plugins(conf),
99        };
100        if let Err(err) = Self::validate_config(&handle) {
101            panic!("Invalid client configuration: {err}");
102        }
103        Self {
104            handle: ::std::sync::Arc::new(handle),
105        }
106    }
107
108    /// Returns the client's configuration.
109    pub fn config(&self) -> &crate::Config {
110        &self.handle.conf
111    }
112
113    fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
114        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
115        handle
116            .runtime_plugins
117            .apply_client_configuration(&mut cfg)?
118            .validate_base_client_config(&cfg)?;
119        Ok(())
120    }
121}
122
123impl Client {
124    /// Creates a new client from an [SDK Config](::aws_types::sdk_config::SdkConfig).
125    ///
126    /// # Panics
127    ///
128    /// - This method will panic if the `sdk_config` is missing an async sleep implementation. If you experience this panic, set
129    ///   the `sleep_impl` on the Config passed into this function to fix it.
130    /// - This method will panic if the `sdk_config` is missing an HTTP connector. If you experience this panic, set the
131    ///   `http_connector` on the Config passed into this function to fix it.
132    /// - 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.
133    #[track_caller]
134    pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
135        Self::from_conf(sdk_config.into())
136    }
137}
138
139mod add_custom_attributes;
140
141mod admin_add_user_to_group;
142
143mod admin_confirm_sign_up;
144
145mod admin_create_user;
146
147mod admin_delete_user;
148
149mod admin_delete_user_attributes;
150
151mod admin_disable_provider_for_user;
152
153mod admin_disable_user;
154
155mod admin_enable_user;
156
157mod admin_forget_device;
158
159mod admin_get_device;
160
161mod admin_get_user;
162
163mod admin_initiate_auth;
164
165mod admin_link_provider_for_user;
166
167mod admin_list_devices;
168
169mod admin_list_groups_for_user;
170
171mod admin_list_user_auth_events;
172
173mod admin_remove_user_from_group;
174
175mod admin_reset_user_password;
176
177mod admin_respond_to_auth_challenge;
178
179mod admin_set_user_mfa_preference;
180
181mod admin_set_user_password;
182
183mod admin_set_user_settings;
184
185mod admin_update_auth_event_feedback;
186
187mod admin_update_device_status;
188
189mod admin_update_user_attributes;
190
191mod admin_user_global_sign_out;
192
193mod associate_software_token;
194
195mod change_password;
196
197mod complete_web_authn_registration;
198
199mod confirm_device;
200
201mod confirm_forgot_password;
202
203mod confirm_sign_up;
204
205mod create_group;
206
207mod create_identity_provider;
208
209mod create_managed_login_branding;
210
211mod create_resource_server;
212
213mod create_terms;
214
215mod create_user_import_job;
216
217mod create_user_pool;
218
219mod create_user_pool_client;
220
221mod create_user_pool_domain;
222
223/// Operation customization and supporting types.
224///
225/// The underlying HTTP requests made during an operation can be customized
226/// by calling the `customize()` method on the builder returned from a client
227/// operation call. For example, this can be used to add an additional HTTP header:
228///
229/// ```ignore
230/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_cognitoidentityprovider::Error> {
231/// # let client: aws_sdk_cognitoidentityprovider::Client = unimplemented!();
232/// use ::http::header::{HeaderName, HeaderValue};
233///
234/// let result = client.add_custom_attributes()
235///     .customize()
236///     .mutate_request(|req| {
237///         // Add `x-example-header` with value
238///         req.headers_mut()
239///             .insert(
240///                 HeaderName::from_static("x-example-header"),
241///                 HeaderValue::from_static("1"),
242///             );
243///     })
244///     .send()
245///     .await;
246/// # }
247/// ```
248pub mod customize;
249
250mod delete_group;
251
252mod delete_identity_provider;
253
254mod delete_managed_login_branding;
255
256mod delete_resource_server;
257
258mod delete_terms;
259
260mod delete_user;
261
262mod delete_user_attributes;
263
264mod delete_user_pool;
265
266mod delete_user_pool_client;
267
268mod delete_user_pool_domain;
269
270mod delete_web_authn_credential;
271
272mod describe_identity_provider;
273
274mod describe_managed_login_branding;
275
276mod describe_managed_login_branding_by_client;
277
278mod describe_resource_server;
279
280mod describe_risk_configuration;
281
282mod describe_terms;
283
284mod describe_user_import_job;
285
286mod describe_user_pool;
287
288mod describe_user_pool_client;
289
290mod describe_user_pool_domain;
291
292mod forget_device;
293
294mod forgot_password;
295
296mod get_csv_header;
297
298mod get_device;
299
300mod get_group;
301
302mod get_identity_provider_by_identifier;
303
304mod get_log_delivery_configuration;
305
306mod get_signing_certificate;
307
308mod get_tokens_from_refresh_token;
309
310mod get_ui_customization;
311
312mod get_user;
313
314mod get_user_attribute_verification_code;
315
316mod get_user_auth_factors;
317
318mod get_user_pool_mfa_config;
319
320mod global_sign_out;
321
322mod initiate_auth;
323
324mod list_devices;
325
326mod list_groups;
327
328mod list_identity_providers;
329
330mod list_resource_servers;
331
332mod list_tags_for_resource;
333
334mod list_terms;
335
336mod list_user_import_jobs;
337
338mod list_user_pool_clients;
339
340mod list_user_pools;
341
342mod list_users;
343
344mod list_users_in_group;
345
346mod list_web_authn_credentials;
347
348mod resend_confirmation_code;
349
350mod respond_to_auth_challenge;
351
352mod revoke_token;
353
354mod set_log_delivery_configuration;
355
356mod set_risk_configuration;
357
358mod set_ui_customization;
359
360mod set_user_mfa_preference;
361
362mod set_user_pool_mfa_config;
363
364mod set_user_settings;
365
366mod sign_up;
367
368mod start_user_import_job;
369
370mod start_web_authn_registration;
371
372mod stop_user_import_job;
373
374mod tag_resource;
375
376mod untag_resource;
377
378mod update_auth_event_feedback;
379
380mod update_device_status;
381
382mod update_group;
383
384mod update_identity_provider;
385
386mod update_managed_login_branding;
387
388mod update_resource_server;
389
390mod update_terms;
391
392mod update_user_attributes;
393
394mod update_user_pool;
395
396mod update_user_pool_client;
397
398mod update_user_pool_domain;
399
400mod verify_software_token;
401
402mod verify_user_attribute;