#[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 activate_key_signing_key;
mod associate_vpc_with_hosted_zone;
mod change_cidr_collection;
mod change_resource_record_sets;
mod change_tags_for_resource;
mod create_cidr_collection;
mod create_health_check;
mod create_hosted_zone;
mod create_key_signing_key;
mod create_query_logging_config;
mod create_reusable_delegation_set;
mod create_traffic_policy;
mod create_traffic_policy_instance;
mod create_traffic_policy_version;
mod create_vpc_association_authorization;
pub mod customize;
mod deactivate_key_signing_key;
mod delete_cidr_collection;
mod delete_health_check;
mod delete_hosted_zone;
mod delete_key_signing_key;
mod delete_query_logging_config;
mod delete_reusable_delegation_set;
mod delete_traffic_policy;
mod delete_traffic_policy_instance;
mod delete_vpc_association_authorization;
mod disable_hosted_zone_dnssec;
mod disassociate_vpc_from_hosted_zone;
mod enable_hosted_zone_dnssec;
mod get_account_limit;
mod get_change;
mod get_checker_ip_ranges;
mod get_dnssec;
mod get_geo_location;
mod get_health_check;
mod get_health_check_count;
mod get_health_check_last_failure_reason;
mod get_health_check_status;
mod get_hosted_zone;
mod get_hosted_zone_count;
mod get_hosted_zone_limit;
mod get_query_logging_config;
mod get_reusable_delegation_set;
mod get_reusable_delegation_set_limit;
mod get_traffic_policy;
mod get_traffic_policy_instance;
mod get_traffic_policy_instance_count;
mod list_cidr_blocks;
mod list_cidr_collections;
mod list_cidr_locations;
mod list_geo_locations;
mod list_health_checks;
mod list_hosted_zones;
mod list_hosted_zones_by_name;
mod list_hosted_zones_by_vpc;
mod list_query_logging_configs;
mod list_resource_record_sets;
mod list_reusable_delegation_sets;
mod list_tags_for_resource;
mod list_tags_for_resources;
mod list_traffic_policies;
mod list_traffic_policy_instances;
mod list_traffic_policy_instances_by_hosted_zone;
mod list_traffic_policy_instances_by_policy;
mod list_traffic_policy_versions;
mod list_vpc_association_authorizations;
mod test_dns_answer;
mod update_health_check;
mod update_hosted_zone_comment;
mod update_traffic_policy_comment;
mod update_traffic_policy_instance;