diff --git a/.doc_gen/metadata/qldb_metadata.yaml b/.doc_gen/metadata/qldb_metadata.yaml deleted file mode 100644 index 437fb915be1..00000000000 --- a/.doc_gen/metadata/qldb_metadata.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# zexi 0.4.0 -qldb_CreateLedger: - languages: - Rust: - versions: - - sdk_version: 1 - github: rustv1/examples/qldb - excerpts: - - description: - snippet_tags: - - qldb.rust.create-ledger - services: - qldb: {CreateLedger} -qldb_ListLedgers: - languages: - Rust: - versions: - - sdk_version: 1 - github: rustv1/examples/qldb - excerpts: - - description: - snippet_tags: - - qldb.rust.list-ledgers - services: - qldb: {ListLedgers} diff --git a/rustv1/examples/qldb/Cargo.toml b/rustv1/examples/qldb/Cargo.toml deleted file mode 100644 index 4f8c60ed470..00000000000 --- a/rustv1/examples/qldb/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "qldb-code-examples" -version = "0.1.0" -authors = [ - "Russell Cohen ", - "Doug Schwartz ", -] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -aws-config = { version = "1.0.1", features = ["behavior-version-latest"] } -aws-sdk-qldb = { version = "1.3.0" } -aws-sdk-qldbsession = { version = "1.3.0" } -tokio = { version = "1.20.1", features = ["full"] } -tokio-stream = { version = "0.1.9", features = ["default"] } -clap = { version = "4.4", features = ["derive"] } -tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rustv1/examples/qldb/README.md b/rustv1/examples/qldb/README.md deleted file mode 100644 index d2808c3027d..00000000000 --- a/rustv1/examples/qldb/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# Amazon QLDB code examples for the SDK for Rust - -## Overview - -Shows how to use the AWS SDK for Rust to work with Amazon Quantum Ledger Database (Amazon QLDB). - - - - -_Amazon QLDB is a fully managed ledger database that provides a transparent, immutable, and cryptographically verifiable transaction log owned by a central trusted authority._ - -## ⚠ Important - -* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/). -* Running the tests might result in charges to your AWS account. -* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). -* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). - - - - -## Code examples - -### Prerequisites - -For prerequisites, see the [README](../../README.md#Prerequisites) in the `rustv1` folder. - - - - - -### Single actions - -Code excerpts that show you how to call individual service functions. - -- [CreateLedger](src/bin/create-ledger.rs#L27) -- [ListLedgers](src/bin/list-ledgers.rs#L22) - - - - - -## Run the examples - -### Instructions - - - - - - - -### Tests - -⚠ Running tests might result in charges to your AWS account. - - -To find instructions for running these tests, see the [README](../../README.md#Tests) -in the `rustv1` folder. - - - - - - -## Additional resources - -- [Amazon QLDB Developer Guide](https://docs.aws.amazon.com/qldb/latest/developerguide/what-is.html) -- [Amazon QLDB API Reference](https://docs.aws.amazon.com/qldb/latest/developerguide/api-reference.html) -- [SDK for Rust Amazon QLDB reference](https://docs.rs/aws-sdk-qldb/latest/aws_sdk_qldb/) - - - - ---- - -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/rustv1/examples/qldb/src/bin/create-ledger.rs b/rustv1/examples/qldb/src/bin/create-ledger.rs deleted file mode 100644 index 2b0f440d9b0..00000000000 --- a/rustv1/examples/qldb/src/bin/create-ledger.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![allow(clippy::result_large_err)] - -use aws_config::meta::region::RegionProviderChain; -use aws_sdk_qldb::types::PermissionsMode; -use aws_sdk_qldb::{config::Region, meta::PKG_VERSION, Client, Error}; -use clap::Parser; - -#[derive(Debug, Parser)] -struct Opt { - /// The AWS Region. - #[structopt(short, long)] - region: Option, - - /// The name of the ledger. - #[structopt(short, long)] - ledger: String, - - /// Whether to display additional runtime information. - #[structopt(short, long)] - verbose: bool, -} - -// Create a ledger. -// snippet-start:[qldb.rust.create-ledger] -async fn make_ledger(client: &Client, ledger: &str) -> Result<(), Error> { - let result = client - .create_ledger() - .name(ledger) - .permissions_mode(PermissionsMode::AllowAll) - .send() - .await?; - - println!("ARN: {}", result.arn().unwrap()); - - Ok(()) -} -// snippet-end:[qldb.rust.create-ledger] - -/// Creates an Amazon Quantum Ledger Database (Amazon QLDB) ledger in the Region. -/// # Arguments -/// -/// * `-l LEDGER` - The name of the ledger. -/// * `[-r REGION]` - The Region in which the client is created. -/// If not supplied, uses the value of the **AWS_REGION** environment variable. -/// If the environment variable is not set, defaults to **us-west-2**. -/// * `[-v]` - Whether to display additional information. -#[tokio::main] -async fn main() -> Result<(), Error> { - tracing_subscriber::fmt::init(); - - let Opt { - ledger, - region, - verbose, - } = Opt::parse(); - - let region_provider = RegionProviderChain::first_try(region.map(Region::new)) - .or_default_provider() - .or_else(Region::new("us-west-2")); - - println!(); - - if verbose { - println!("QLDB client version: {}", PKG_VERSION); - println!( - "Region: {}", - region_provider.region().await.unwrap().as_ref() - ); - println!("Ledger: {}", &ledger); - println!(); - } - - let shared_config = aws_config::from_env().region(region_provider).load().await; - let client = Client::new(&shared_config); - - make_ledger(&client, &ledger).await -} diff --git a/rustv1/examples/qldb/src/bin/list-ledgers.rs b/rustv1/examples/qldb/src/bin/list-ledgers.rs deleted file mode 100644 index b959e0d57d4..00000000000 --- a/rustv1/examples/qldb/src/bin/list-ledgers.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![allow(clippy::result_large_err)] - -use aws_config::meta::region::RegionProviderChain; -use aws_sdk_qldb::{config::Region, meta::PKG_VERSION, Client as QLDBClient, Error}; -use clap::Parser; - -#[derive(Debug, Parser)] -struct Opt { - /// The AWS Region. - #[structopt(short, long)] - region: Option, - - /// Whether to display additional information. - #[structopt(short, long)] - verbose: bool, -} - -// List ledgers. -// snippet-start:[qldb.rust.list-ledgers] -async fn show_ledgers(client: &QLDBClient) -> Result<(), Error> { - let mut pages = client.list_ledgers().into_paginator().page_size(2).send(); - - while let Some(page) = pages.next().await { - println!("* {:?}", page); //Prints an entire page of ledgers. - for ledger in page.unwrap().ledgers() { - println!("* {:?}", ledger); //Prints the LedgerSummary of a single ledger. - } - } - - Ok(()) -} -// snippet-end:[qldb.rust.list-ledgers] - -/// Lists your Amazon Quantum Ledger Database (Amazon QLDB) ledgers. -/// # Arguments -/// -/// * `[-r REGION]` - The Region in which the client is created. -/// If not supplied, uses the value of the **AWS_REGION** environment variable. -/// If the environment variable is not set, defaults to **us-west-2**. -/// * `[-v]` - Whether to display additional information. -#[tokio::main] -async fn main() -> Result<(), Error> { - tracing_subscriber::fmt::init(); - - let Opt { region, verbose } = Opt::parse(); - - let region_provider = RegionProviderChain::first_try(region.map(Region::new)) - .or_default_provider() - .or_else(Region::new("us-west-2")); - - println!(); - - if verbose { - println!("OLDB client version: {}", PKG_VERSION); - println!( - "Region: {}", - region_provider.region().await.unwrap().as_ref() - ); - println!(); - } - - let shared_config = aws_config::from_env().region(region_provider).load().await; - let client = QLDBClient::new(&shared_config); - - show_ledgers(&client).await -} diff --git a/rustv1/examples/qldb/src/bin/qldb-helloworld.rs b/rustv1/examples/qldb/src/bin/qldb-helloworld.rs deleted file mode 100644 index 96068317393..00000000000 --- a/rustv1/examples/qldb/src/bin/qldb-helloworld.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![allow(clippy::result_large_err)] - -use aws_config::meta::region::RegionProviderChain; -use aws_sdk_qldbsession::types::StartSessionRequest; -use aws_sdk_qldbsession::{config::Region, meta::PKG_VERSION, Client, Error}; -use clap::Parser; - -#[derive(Debug, Parser)] -struct Opt { - /// The AWS Region. - #[structopt(short, long)] - region: Option, - - /// The name of the ledger. - #[structopt(short, long)] - ledger: String, - - /// Whether to display additional information. - #[structopt(short, long)] - verbose: bool, -} - -// Starts a session. -// snippet-start:[qldb.rust.qldb-helloworld] -async fn start(client: &Client, ledger: &str) -> Result<(), Error> { - let result = client - .send_command() - .start_session( - StartSessionRequest::builder() - .ledger_name(ledger) - .build() - .expect("building StartSessionRequest"), - ) - .send() - .await?; - - println!( - "Session id: {:?}", - result.start_session().unwrap().session_token() - ); - - Ok(()) -} -// snippet-end:[qldb.rust.qldb-helloworld] - -/// Creates a low-level Amazon Quantum Ledger Database (Amazon QLDB) session in the Region. -/// # Arguments -/// -/// * `-l LEDGER` - The name of the ledger to start a new session against. -/// * `[-r REGION]` - The Region in which the client is created. -/// If not supplied, uses the value of the **AWS_REGION** environment variable. -/// If the environment variable is not set, defaults to **us-west-2**. -/// * `[-v]` - Whether to display additional information. -#[tokio::main] -async fn main() -> Result<(), Error> { - tracing_subscriber::fmt::init(); - - let Opt { - ledger, - region, - verbose, - } = Opt::parse(); - - let region_provider = RegionProviderChain::first_try(region.map(Region::new)) - .or_default_provider() - .or_else(Region::new("us-west-2")); - - println!(); - - if verbose { - println!("OLDB client version: {}", PKG_VERSION); - println!( - "Region: {}", - region_provider.region().await.unwrap().as_ref() - ); - println!("Ledger: {}", ledger); - println!(); - } - - let shared_config = aws_config::from_env().region(region_provider).load().await; - let client = Client::new(&shared_config); - - start(&client, &ledger).await -}