Skip to content

Commit

Permalink
Re-architected Rust alpha code examples to use one Cargo.toml file pe…
Browse files Browse the repository at this point in the history
…r service; fixed issues with comments and region
  • Loading branch information
Doug-AWS committed May 27, 2021
1 parent 0b5336f commit b3c0b64
Show file tree
Hide file tree
Showing 65 changed files with 288 additions and 644 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
[package]
name = "dynamodb-crud"
name = "dynamodb-code-examples"
version = "0.1.0"
authors = ["Doug Schwartz <[email protected]>"]
authors = ["Russell Cohen <[email protected]>", "Doug Schwartz <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "aws-sdk-dynamodb" }
aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "aws-http"}
aws-hyper = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "aws-hyper"}
aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "aws-types" }
smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "smithy-http" }
smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.4-alpha", package = "smithy-types" }

dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "aws-sdk-dynamodb" }
aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "aws-http"}
aws-hyper = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "aws-hyper"}
aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "aws-types" }
smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "smithy-http" }
smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.5-alpha", package = "smithy-types" }

async-std = "1.9.0"
rand = "0.8.3"
serde_json = "1"
structopt = { version = "0.3", default-features = false }
tokio = { version = "1", features = ["full"] }
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }

16 changes: 0 additions & 16 deletions .rust_alpha/dynamodb/add-item/Cargo.toml

This file was deleted.

16 changes: 0 additions & 16 deletions .rust_alpha/dynamodb/create-table/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions .rust_alpha/dynamodb/delete-item/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions .rust_alpha/dynamodb/delete-table/Cargo.toml

This file was deleted.

18 changes: 0 additions & 18 deletions .rust_alpha/dynamodb/helloworld/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions .rust_alpha/dynamodb/helloworld/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions .rust_alpha/dynamodb/helloworld/docker-compose.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .rust_alpha/dynamodb/list-items/Cargo.toml

This file was deleted.

14 changes: 0 additions & 14 deletions .rust_alpha/dynamodb/list-tables/Cargo.toml

This file was deleted.

23 changes: 0 additions & 23 deletions .rust_alpha/dynamodb/movies/Cargo.toml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ use tracing_subscriber::fmt::SubscriberBuilder;

#[derive(Debug, StructOpt)]
struct Opt {
/// The permission type of the user, standard_user or admin
/// The permission type of the user, standard_user or admin.
#[structopt(short, long)]
p_type: String,

/// The user's age
/// The user's age.
#[structopt(short, long)]
age: String,

/// The user's username
/// The user's username.
#[structopt(short, long)]
username: String,

/// The user's first name
/// The user's first name.
#[structopt(short, long)]
first: String,

/// The user's last name
/// The user's last name.
#[structopt(short, long)]
last: String,

/// The table name
/// The table name.
#[structopt(short, long)]
table: String,

/// The region
/// The AWS Region.
#[structopt(short, long)]
default_region: Option<String>,

/// Activate verbose mode
/// Whether to display additional information.
#[structopt(short, long)]
verbose: bool,
}
Expand All @@ -58,7 +58,7 @@ struct Opt {
/// * `-a AGE` - The age of the user.
/// * `-f FIRST` - The first name of the user.
/// * `-l LAST` - The last name of the user.
/// * `[-d DEFAULT-REGION]` - The region containing the table.
/// * `[-d DEFAULT-REGION]` - The AWS Region containing the table.
/// If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
/// If the environment variable is not set, defaults to **us-west-2**.
/// * `[-v]` - Whether to display additional information.
Expand Down Expand Up @@ -90,13 +90,13 @@ async fn main() {

if verbose {
println!("DynamoDB client version: {}\n", dynamodb::PKG_VERSION);
println!("Region: {:?}", &region);
println!("Table: {}", table);
println!("User: {}", username);
println!("Type: {}", p_type);
println!("Age: {}", age);
println!("First: {}", first);
println!("Last: {}\n", last);
println!("AWS Region: {:?}", &region);
println!("Table: {}", table);
println!("User: {}", username);
println!("Type: {}", p_type);
println!("Age: {}", age);
println!("First: {}", first);
println!("Last: {}\n", last);

SubscriberBuilder::default()
.with_env_filter("info")
Expand Down Expand Up @@ -126,7 +126,7 @@ async fn main() {
.await
{
Ok(_) => println!(
"Added user {}, {} {}, age {} as {} user",
"Added user {}, {} {}, age {} as {} user.",
username, first, last, age, p_type
),
Err(e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ use tracing_subscriber::fmt::SubscriberBuilder;

#[derive(Debug, StructOpt)]
struct Opt {
/// The region
/// The AWS Region.
#[structopt(short, long)]
default_region: Option<String>,

/// The table name
/// The table name.
#[structopt(short, long)]
table: String,

/// The region
/// The primary key for the table.
#[structopt(short, long)]
key: String,

/// Activate verbose mode
/// Whether to display additional information.
#[structopt(short, long)]
verbose: bool,
}
Expand All @@ -41,7 +41,7 @@ struct Opt {
///
/// * `-t TABLE` - The name of the table.
/// * `-k KEY` - The primary key for the table.
/// * `[-d DEFAULT-REGION]` - The region in which the table is created.
/// * `[-d DEFAULT-REGION]` - The AWS Region in which the table is created.
/// If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
/// If the environment variable is not set, defaults to **us-west-2**.
/// * `[-v]` - Whether to display additional information.
Expand All @@ -62,9 +62,9 @@ async fn main() {

if verbose {
println!("DynamoDB client version: {}\n", dynamodb::PKG_VERSION);
println!("Region: {:?}", &region);
println!("Table: {}", table);
println!("Key: {}\n", key);
println!("AWS Region: {:?}", &region);
println!("Table: {}", table);
println!("Key: {}\n", key);

SubscriberBuilder::default()
.with_env_filter("info")
Expand Down
Loading

0 comments on commit b3c0b64

Please sign in to comment.