#[derive(Debug)]
pub(crate) struct Handle {
pub(crate) client: aws_smithy_client::Client<
aws_smithy_client::erase::DynConnector,
aws_smithy_client::erase::DynMiddleware<aws_smithy_client::erase::DynConnector>,
>,
pub(crate) conf: crate::Config,
}
#[derive(std::fmt::Debug)]
pub struct Client {
handle: std::sync::Arc<Handle>,
}
impl std::clone::Clone for Client {
fn clone(&self) -> Self {
Self {
handle: self.handle.clone(),
}
}
}
impl
From<
aws_smithy_client::Client<
aws_smithy_client::erase::DynConnector,
aws_smithy_client::erase::DynMiddleware<aws_smithy_client::erase::DynConnector>,
>,
> for Client
{
fn from(
client: aws_smithy_client::Client<
aws_smithy_client::erase::DynConnector,
aws_smithy_client::erase::DynMiddleware<aws_smithy_client::erase::DynConnector>,
>,
) -> Self {
Self::with_config(client, crate::Config::builder().build())
}
}
impl Client {
pub fn with_config(
client: aws_smithy_client::Client<
aws_smithy_client::erase::DynConnector,
aws_smithy_client::erase::DynMiddleware<aws_smithy_client::erase::DynConnector>,
>,
conf: crate::Config,
) -> Self {
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
pub fn conf(&self) -> &crate::Config {
&self.handle.conf
}
}
impl Client {
pub fn new(sdk_config: &aws_types::sdk_config::SdkConfig) -> Self {
Self::from_conf(sdk_config.into())
}
pub fn from_conf(conf: crate::Config) -> Self {
let retry_config = conf
.retry_config()
.cloned()
.unwrap_or_else(aws_smithy_types::retry::RetryConfig::disabled);
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let sleep_impl = conf.sleep_impl();
if (retry_config.has_retry() || timeout_config.has_timeouts()) && sleep_impl.is_none() {
panic!("An async sleep implementation is required for retries or timeouts to work. \
Set the `sleep_impl` on the Config passed into this function to fix this panic.");
}
let connector = conf.http_connector().and_then(|c| {
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let connector_settings =
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
);
c.connector(&connector_settings, conf.sleep_impl())
});
let builder = aws_smithy_client::Builder::new();
let builder = match connector {
Some(c) => builder.connector(c),
None => {
#[cfg(any(feature = "rustls", feature = "native-tls"))]
{
builder.dyn_https_connector(
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
),
)
}
#[cfg(not(any(feature = "rustls", feature = "native-tls")))]
{
panic!("No HTTP connector was available. Enable the `rustls` or `native-tls` crate feature or set a connector to fix this.");
}
}
};
let mut builder = builder
.middleware(aws_smithy_client::erase::DynMiddleware::new(
crate::middleware::DefaultMiddleware::new(),
))
.reconnect_mode(retry_config.reconnect_mode())
.retry_config(retry_config.into())
.operation_timeout_config(timeout_config.into());
builder.set_sleep_impl(sleep_impl);
let client = builder.build();
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
}
mod accept_certificate_transfer;
mod add_thing_to_billing_group;
mod add_thing_to_thing_group;
mod associate_targets_with_job;
mod attach_policy;
mod attach_principal_policy;
mod attach_security_profile;
mod attach_thing_principal;
mod cancel_audit_mitigation_actions_task;
mod cancel_audit_task;
mod cancel_certificate_transfer;
mod cancel_detect_mitigation_actions_task;
mod cancel_job;
mod cancel_job_execution;
mod clear_default_authorizer;
mod confirm_topic_rule_destination;
mod create_audit_suppression;
mod create_authorizer;
mod create_billing_group;
mod create_certificate_from_csr;
mod create_custom_metric;
mod create_dimension;
mod create_domain_configuration;
mod create_dynamic_thing_group;
mod create_fleet_metric;
mod create_job;
mod create_job_template;
mod create_keys_and_certificate;
mod create_mitigation_action;
mod create_ota_update;
mod create_policy;
mod create_policy_version;
mod create_provisioning_claim;
mod create_provisioning_template;
mod create_provisioning_template_version;
mod create_role_alias;
mod create_scheduled_audit;
mod create_security_profile;
mod create_stream;
mod create_thing;
mod create_thing_group;
mod create_thing_type;
mod create_topic_rule;
mod create_topic_rule_destination;
pub mod customize;
mod delete_account_audit_configuration;
mod delete_audit_suppression;
mod delete_authorizer;
mod delete_billing_group;
mod delete_ca_certificate;
mod delete_certificate;
mod delete_custom_metric;
mod delete_dimension;
mod delete_domain_configuration;
mod delete_dynamic_thing_group;
mod delete_fleet_metric;
mod delete_job;
mod delete_job_execution;
mod delete_job_template;
mod delete_mitigation_action;
mod delete_ota_update;
mod delete_policy;
mod delete_policy_version;
mod delete_provisioning_template;
mod delete_provisioning_template_version;
mod delete_registration_code;
mod delete_role_alias;
mod delete_scheduled_audit;
mod delete_security_profile;
mod delete_stream;
mod delete_thing;
mod delete_thing_group;
mod delete_thing_type;
mod delete_topic_rule;
mod delete_topic_rule_destination;
mod delete_v2_logging_level;
mod deprecate_thing_type;
mod describe_account_audit_configuration;
mod describe_audit_finding;
mod describe_audit_mitigation_actions_task;
mod describe_audit_suppression;
mod describe_audit_task;
mod describe_authorizer;
mod describe_billing_group;
mod describe_ca_certificate;
mod describe_certificate;
mod describe_custom_metric;
mod describe_default_authorizer;
mod describe_detect_mitigation_actions_task;
mod describe_dimension;
mod describe_domain_configuration;
mod describe_endpoint;
mod describe_event_configurations;
mod describe_fleet_metric;
mod describe_index;
mod describe_job;
mod describe_job_execution;
mod describe_job_template;
mod describe_managed_job_template;
mod describe_mitigation_action;
mod describe_provisioning_template;
mod describe_provisioning_template_version;
mod describe_role_alias;
mod describe_scheduled_audit;
mod describe_security_profile;
mod describe_stream;
mod describe_thing;
mod describe_thing_group;
mod describe_thing_registration_task;
mod describe_thing_type;
mod detach_policy;
mod detach_principal_policy;
mod detach_security_profile;
mod detach_thing_principal;
mod disable_topic_rule;
mod enable_topic_rule;
mod get_behavior_model_training_summaries;
mod get_buckets_aggregation;
mod get_cardinality;
mod get_effective_policies;
mod get_indexing_configuration;
mod get_job_document;
mod get_logging_options;
mod get_ota_update;
mod get_percentiles;
mod get_policy;
mod get_policy_version;
mod get_registration_code;
mod get_statistics;
mod get_topic_rule;
mod get_topic_rule_destination;
mod get_v2_logging_options;
mod list_active_violations;
mod list_attached_policies;
mod list_audit_findings;
mod list_audit_mitigation_actions_executions;
mod list_audit_mitigation_actions_tasks;
mod list_audit_suppressions;
mod list_audit_tasks;
mod list_authorizers;
mod list_billing_groups;
mod list_ca_certificates;
mod list_certificates;
mod list_certificates_by_ca;
mod list_custom_metrics;
mod list_detect_mitigation_actions_executions;
mod list_detect_mitigation_actions_tasks;
mod list_dimensions;
mod list_domain_configurations;
mod list_fleet_metrics;
mod list_indices;
mod list_job_executions_for_job;
mod list_job_executions_for_thing;
mod list_job_templates;
mod list_jobs;
mod list_managed_job_templates;
mod list_metric_values;
mod list_mitigation_actions;
mod list_ota_updates;
mod list_outgoing_certificates;
mod list_policies;
mod list_policy_principals;
mod list_policy_versions;
mod list_principal_policies;
mod list_principal_things;
mod list_provisioning_template_versions;
mod list_provisioning_templates;
mod list_related_resources_for_audit_finding;
mod list_role_aliases;
mod list_scheduled_audits;
mod list_security_profiles;
mod list_security_profiles_for_target;
mod list_streams;
mod list_tags_for_resource;
mod list_targets_for_policy;
mod list_targets_for_security_profile;
mod list_thing_groups;
mod list_thing_groups_for_thing;
mod list_thing_principals;
mod list_thing_registration_task_reports;
mod list_thing_registration_tasks;
mod list_thing_types;
mod list_things;
mod list_things_in_billing_group;
mod list_things_in_thing_group;
mod list_topic_rule_destinations;
mod list_topic_rules;
mod list_v2_logging_levels;
mod list_violation_events;
mod put_verification_state_on_violation;
mod register_ca_certificate;
mod register_certificate;
mod register_certificate_without_ca;
mod register_thing;
mod reject_certificate_transfer;
mod remove_thing_from_billing_group;
mod remove_thing_from_thing_group;
mod replace_topic_rule;
mod search_index;
mod set_default_authorizer;
mod set_default_policy_version;
mod set_logging_options;
mod set_v2_logging_level;
mod set_v2_logging_options;
mod start_audit_mitigation_actions_task;
mod start_detect_mitigation_actions_task;
mod start_on_demand_audit_task;
mod start_thing_registration_task;
mod stop_thing_registration_task;
mod tag_resource;
mod test_authorization;
mod test_invoke_authorizer;
mod transfer_certificate;
mod untag_resource;
mod update_account_audit_configuration;
mod update_audit_suppression;
mod update_authorizer;
mod update_billing_group;
mod update_ca_certificate;
mod update_certificate;
mod update_custom_metric;
mod update_dimension;
mod update_domain_configuration;
mod update_dynamic_thing_group;
mod update_event_configurations;
mod update_fleet_metric;
mod update_indexing_configuration;
mod update_job;
mod update_mitigation_action;
mod update_provisioning_template;
mod update_role_alias;
mod update_scheduled_audit;
mod update_security_profile;
mod update_stream;
mod update_thing;
mod update_thing_group;
mod update_thing_groups_for_thing;
mod update_topic_rule_destination;
mod validate_security_profile_behaviors;