aws_sdk_iot/
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 IoT
10///
11/// Client for invoking operations on AWS IoT. Each operation on AWS IoT 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_iot::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_iot::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 [`AcceptCertificateTransfer`](crate::operation::accept_certificate_transfer) operation has
63/// a [`Client::accept_certificate_transfer`], 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.accept_certificate_transfer()
69///     .certificate_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 accept_certificate_transfer;
140
141mod add_thing_to_billing_group;
142
143mod add_thing_to_thing_group;
144
145mod associate_sbom_with_package_version;
146
147mod associate_targets_with_job;
148
149mod attach_policy;
150
151mod attach_principal_policy;
152
153mod attach_security_profile;
154
155mod attach_thing_principal;
156
157mod cancel_audit_mitigation_actions_task;
158
159mod cancel_audit_task;
160
161mod cancel_certificate_transfer;
162
163mod cancel_detect_mitigation_actions_task;
164
165mod cancel_job;
166
167mod cancel_job_execution;
168
169mod clear_default_authorizer;
170
171mod confirm_topic_rule_destination;
172
173mod create_audit_suppression;
174
175mod create_authorizer;
176
177mod create_billing_group;
178
179mod create_certificate_from_csr;
180
181mod create_certificate_provider;
182
183mod create_command;
184
185mod create_custom_metric;
186
187mod create_dimension;
188
189mod create_domain_configuration;
190
191mod create_dynamic_thing_group;
192
193mod create_fleet_metric;
194
195mod create_job;
196
197mod create_job_template;
198
199mod create_keys_and_certificate;
200
201mod create_mitigation_action;
202
203mod create_ota_update;
204
205mod create_package;
206
207mod create_package_version;
208
209mod create_policy;
210
211mod create_policy_version;
212
213mod create_provisioning_claim;
214
215mod create_provisioning_template;
216
217mod create_provisioning_template_version;
218
219mod create_role_alias;
220
221mod create_scheduled_audit;
222
223mod create_security_profile;
224
225mod create_stream;
226
227mod create_thing;
228
229mod create_thing_group;
230
231mod create_thing_type;
232
233mod create_topic_rule;
234
235mod create_topic_rule_destination;
236
237/// Operation customization and supporting types.
238///
239/// The underlying HTTP requests made during an operation can be customized
240/// by calling the `customize()` method on the builder returned from a client
241/// operation call. For example, this can be used to add an additional HTTP header:
242///
243/// ```ignore
244/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_iot::Error> {
245/// # let client: aws_sdk_iot::Client = unimplemented!();
246/// use ::http::header::{HeaderName, HeaderValue};
247///
248/// let result = client.accept_certificate_transfer()
249///     .customize()
250///     .mutate_request(|req| {
251///         // Add `x-example-header` with value
252///         req.headers_mut()
253///             .insert(
254///                 HeaderName::from_static("x-example-header"),
255///                 HeaderValue::from_static("1"),
256///             );
257///     })
258///     .send()
259///     .await;
260/// # }
261/// ```
262pub mod customize;
263
264mod delete_account_audit_configuration;
265
266mod delete_audit_suppression;
267
268mod delete_authorizer;
269
270mod delete_billing_group;
271
272mod delete_ca_certificate;
273
274mod delete_certificate;
275
276mod delete_certificate_provider;
277
278mod delete_command;
279
280mod delete_command_execution;
281
282mod delete_custom_metric;
283
284mod delete_dimension;
285
286mod delete_domain_configuration;
287
288mod delete_dynamic_thing_group;
289
290mod delete_fleet_metric;
291
292mod delete_job;
293
294mod delete_job_execution;
295
296mod delete_job_template;
297
298mod delete_mitigation_action;
299
300mod delete_ota_update;
301
302mod delete_package;
303
304mod delete_package_version;
305
306mod delete_policy;
307
308mod delete_policy_version;
309
310mod delete_provisioning_template;
311
312mod delete_provisioning_template_version;
313
314mod delete_registration_code;
315
316mod delete_role_alias;
317
318mod delete_scheduled_audit;
319
320mod delete_security_profile;
321
322mod delete_stream;
323
324mod delete_thing;
325
326mod delete_thing_group;
327
328mod delete_thing_type;
329
330mod delete_topic_rule;
331
332mod delete_topic_rule_destination;
333
334mod delete_v2_logging_level;
335
336mod deprecate_thing_type;
337
338mod describe_account_audit_configuration;
339
340mod describe_audit_finding;
341
342mod describe_audit_mitigation_actions_task;
343
344mod describe_audit_suppression;
345
346mod describe_audit_task;
347
348mod describe_authorizer;
349
350mod describe_billing_group;
351
352mod describe_ca_certificate;
353
354mod describe_certificate;
355
356mod describe_certificate_provider;
357
358mod describe_custom_metric;
359
360mod describe_default_authorizer;
361
362mod describe_detect_mitigation_actions_task;
363
364mod describe_dimension;
365
366mod describe_domain_configuration;
367
368mod describe_encryption_configuration;
369
370mod describe_endpoint;
371
372mod describe_event_configurations;
373
374mod describe_fleet_metric;
375
376mod describe_index;
377
378mod describe_job;
379
380mod describe_job_execution;
381
382mod describe_job_template;
383
384mod describe_managed_job_template;
385
386mod describe_mitigation_action;
387
388mod describe_provisioning_template;
389
390mod describe_provisioning_template_version;
391
392mod describe_role_alias;
393
394mod describe_scheduled_audit;
395
396mod describe_security_profile;
397
398mod describe_stream;
399
400mod describe_thing;
401
402mod describe_thing_group;
403
404mod describe_thing_registration_task;
405
406mod describe_thing_type;
407
408mod detach_policy;
409
410mod detach_principal_policy;
411
412mod detach_security_profile;
413
414mod detach_thing_principal;
415
416mod disable_topic_rule;
417
418mod disassociate_sbom_from_package_version;
419
420mod enable_topic_rule;
421
422mod get_behavior_model_training_summaries;
423
424mod get_buckets_aggregation;
425
426mod get_cardinality;
427
428mod get_command;
429
430mod get_command_execution;
431
432mod get_effective_policies;
433
434mod get_indexing_configuration;
435
436mod get_job_document;
437
438mod get_logging_options;
439
440mod get_ota_update;
441
442mod get_package;
443
444mod get_package_configuration;
445
446mod get_package_version;
447
448mod get_percentiles;
449
450mod get_policy;
451
452mod get_policy_version;
453
454mod get_registration_code;
455
456mod get_statistics;
457
458mod get_thing_connectivity_data;
459
460mod get_topic_rule;
461
462mod get_topic_rule_destination;
463
464mod get_v2_logging_options;
465
466mod list_active_violations;
467
468mod list_attached_policies;
469
470mod list_audit_findings;
471
472mod list_audit_mitigation_actions_executions;
473
474mod list_audit_mitigation_actions_tasks;
475
476mod list_audit_suppressions;
477
478mod list_audit_tasks;
479
480mod list_authorizers;
481
482mod list_billing_groups;
483
484mod list_ca_certificates;
485
486mod list_certificate_providers;
487
488mod list_certificates;
489
490mod list_certificates_by_ca;
491
492mod list_command_executions;
493
494mod list_commands;
495
496mod list_custom_metrics;
497
498mod list_detect_mitigation_actions_executions;
499
500mod list_detect_mitigation_actions_tasks;
501
502mod list_dimensions;
503
504mod list_domain_configurations;
505
506mod list_fleet_metrics;
507
508mod list_indices;
509
510mod list_job_executions_for_job;
511
512mod list_job_executions_for_thing;
513
514mod list_job_templates;
515
516mod list_jobs;
517
518mod list_managed_job_templates;
519
520mod list_metric_values;
521
522mod list_mitigation_actions;
523
524mod list_ota_updates;
525
526mod list_outgoing_certificates;
527
528mod list_package_versions;
529
530mod list_packages;
531
532mod list_policies;
533
534mod list_policy_principals;
535
536mod list_policy_versions;
537
538mod list_principal_policies;
539
540mod list_principal_things;
541
542mod list_principal_things_v2;
543
544mod list_provisioning_template_versions;
545
546mod list_provisioning_templates;
547
548mod list_related_resources_for_audit_finding;
549
550mod list_role_aliases;
551
552mod list_sbom_validation_results;
553
554mod list_scheduled_audits;
555
556mod list_security_profiles;
557
558mod list_security_profiles_for_target;
559
560mod list_streams;
561
562mod list_tags_for_resource;
563
564mod list_targets_for_policy;
565
566mod list_targets_for_security_profile;
567
568mod list_thing_groups;
569
570mod list_thing_groups_for_thing;
571
572mod list_thing_principals;
573
574mod list_thing_principals_v2;
575
576mod list_thing_registration_task_reports;
577
578mod list_thing_registration_tasks;
579
580mod list_thing_types;
581
582mod list_things;
583
584mod list_things_in_billing_group;
585
586mod list_things_in_thing_group;
587
588mod list_topic_rule_destinations;
589
590mod list_topic_rules;
591
592mod list_v2_logging_levels;
593
594mod list_violation_events;
595
596mod put_verification_state_on_violation;
597
598mod register_ca_certificate;
599
600mod register_certificate;
601
602mod register_certificate_without_ca;
603
604mod register_thing;
605
606mod reject_certificate_transfer;
607
608mod remove_thing_from_billing_group;
609
610mod remove_thing_from_thing_group;
611
612mod replace_topic_rule;
613
614mod search_index;
615
616mod set_default_authorizer;
617
618mod set_default_policy_version;
619
620mod set_logging_options;
621
622mod set_v2_logging_level;
623
624mod set_v2_logging_options;
625
626mod start_audit_mitigation_actions_task;
627
628mod start_detect_mitigation_actions_task;
629
630mod start_on_demand_audit_task;
631
632mod start_thing_registration_task;
633
634mod stop_thing_registration_task;
635
636mod tag_resource;
637
638mod test_authorization;
639
640mod test_invoke_authorizer;
641
642mod transfer_certificate;
643
644mod untag_resource;
645
646mod update_account_audit_configuration;
647
648mod update_audit_suppression;
649
650mod update_authorizer;
651
652mod update_billing_group;
653
654mod update_ca_certificate;
655
656mod update_certificate;
657
658mod update_certificate_provider;
659
660mod update_command;
661
662mod update_custom_metric;
663
664mod update_dimension;
665
666mod update_domain_configuration;
667
668mod update_dynamic_thing_group;
669
670mod update_encryption_configuration;
671
672mod update_event_configurations;
673
674mod update_fleet_metric;
675
676mod update_indexing_configuration;
677
678mod update_job;
679
680mod update_mitigation_action;
681
682mod update_package;
683
684mod update_package_configuration;
685
686mod update_package_version;
687
688mod update_provisioning_template;
689
690mod update_role_alias;
691
692mod update_scheduled_audit;
693
694mod update_security_profile;
695
696mod update_stream;
697
698mod update_thing;
699
700mod update_thing_group;
701
702mod update_thing_groups_for_thing;
703
704mod update_thing_type;
705
706mod update_topic_rule_destination;
707
708mod validate_security_profile_behaviors;