async fn resolve_endpoint(
client: &crate::Client,
) -> ::std::result::Result<(::aws_smithy_types::endpoint::Endpoint, ::std::time::SystemTime), ::aws_smithy_runtime_api::box_error::BoxError> {
let describe_endpoints = client.describe_endpoints().send().await?;
let endpoint = describe_endpoints.endpoints().first().unwrap();
let expiry = client.config().time_source().expect("checked when ep discovery was enabled").now()
+ ::std::time::Duration::from_secs(endpoint.cache_period_in_minutes() as u64 * 60);
Ok((
::aws_smithy_types::endpoint::Endpoint::builder()
.url(format!("https://{}", endpoint.address()))
.build(),
expiry,
))
}
impl Client {
pub async fn with_endpoint_discovery_enabled(
self,
) -> ::std::result::Result<(Self, crate::endpoint_discovery::ReloadEndpoint), ::aws_smithy_runtime_api::box_error::BoxError> {
let handle = self.handle.clone();
let client_without_discovery = self;
let (resolver, reloader) = crate::endpoint_discovery::create_cache(
move || {
let client = client_without_discovery.clone();
async move { resolve_endpoint(&client).await }
},
handle
.conf
.sleep_impl()
.expect("endpoint discovery requires the client config to have a sleep impl"),
handle
.conf
.time_source()
.expect("endpoint discovery requires the client config to have a time source"),
)
.await?;
use ::aws_smithy_runtime_api::shared::IntoShared;
let mut conf = handle.conf.to_builder();
conf.set_endpoint_resolver(Some(resolver.into_shared()));
let client_with_discovery = crate::Client::from_conf(conf.build());
Ok((client_with_discovery, reloader))
}
}
#[derive(Debug)]
pub(crate) struct Handle {
pub(crate) conf: crate::Config,
#[allow(dead_code)] pub(crate) runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
}
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct Client {
handle: ::std::sync::Arc<Handle>,
}
impl Client {
#[track_caller]
pub fn from_conf(conf: crate::Config) -> Self {
let handle = Handle {
conf: conf.clone(),
runtime_plugins: crate::config::base_client_runtime_plugins(conf),
};
if let Err(err) = Self::validate_config(&handle) {
panic!("Invalid client configuration: {err}");
}
Self {
handle: ::std::sync::Arc::new(handle),
}
}
pub fn config(&self) -> &crate::Config {
&self.handle.conf
}
fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
handle
.runtime_plugins
.apply_client_configuration(&mut cfg)?
.validate_base_client_config(&cfg)?;
Ok(())
}
}
impl Client {
#[track_caller]
pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
Self::from_conf(sdk_config.into())
}
}
mod create_batch_load_task;
mod create_database;
mod create_table;
pub mod customize;
mod delete_database;
mod delete_table;
mod describe_batch_load_task;
mod describe_database;
mod describe_endpoints;
mod describe_table;
mod list_batch_load_tasks;
mod list_databases;
mod list_tables;
mod list_tags_for_resource;
mod resume_batch_load_task;
mod tag_resource;
mod untag_resource;
mod update_database;
mod update_table;
mod write_records;