diff --git a/.doc_gen/metadata/aurora_metadata.yaml b/.doc_gen/metadata/aurora_metadata.yaml index 62a8e0facb8..0014407b09b 100644 --- a/.doc_gen/metadata/aurora_metadata.yaml +++ b/.doc_gen/metadata/aurora_metadata.yaml @@ -39,10 +39,8 @@ aurora_Hello: - sdk_version: 1 github: rust_dev_preview/examples/aurora excerpts: - - snippet_tags: - - rust.aurora.get_cluster.usage - - rust.aurora.describe_db_clusters.wrapper - - rust.aurora.get_cluster.test + - snippet_files: + - rust_dev_preview/examples/aurora/src/bin/hello-world.rs services: aurora: {DescribeDBClusters} aurora_DescribeDBClusterParameterGroups: diff --git a/rust_dev_preview/examples/aurora/src/bin/hello-world.rs b/rust_dev_preview/examples/aurora/src/bin/hello-world.rs new file mode 100644 index 00000000000..15999ea1f15 --- /dev/null +++ b/rust_dev_preview/examples/aurora/src/bin/hello-world.rs @@ -0,0 +1,39 @@ +use aws_sdk_rds::Client; + +#[derive(Debug)] +struct Error(String); +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} +impl std::error::Error for Error {} + +#[tokio::main] +async fn main() -> Result<(), Error> { + tracing_subscriber::fmt::init(); + let sdk_config = aws_config::from_env().load().await; + let client = Client::new(&sdk_config); + + let describe_db_clusters_output = client + .describe_db_clusters() + .send() + .await + .map_err(|e| Error(e.to_string()))?; + println!( + "Found {} clusters:", + describe_db_clusters_output.db_clusters().len() + ); + for cluster in describe_db_clusters_output.db_clusters() { + let name = cluster.database_name().unwrap_or("Unknown"); + let engine = cluster.engine().unwrap_or("Unknown"); + let id = cluster.db_cluster_identifier().unwrap_or("Unknown"); + let class = cluster.db_cluster_instance_class().unwrap_or("Unknown"); + println!("\tDatabase: {name}",); + println!("\t Engine: {engine}",); + println!("\t ID: {id}",); + println!("\tInstance: {class}",); + } + + Ok(()) +}