Skip to content

Commit

Permalink
Removed Rust SDK from repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug-AWS committed Apr 2, 2021
1 parent 3541506 commit beb99b5
Show file tree
Hide file tree
Showing 118 changed files with 205 additions and 110,445 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
.vscode
target/
aws-sdk-main-2021*/
2 changes: 0 additions & 2 deletions ALPHA/kms/CreateKey/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ALPHA/kms/CreateKey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ edition = "2018"
description = "Code example of the KMS CreateKey API"

[dependencies]
kms = { path = "../../../aws-sdk-main-2021-03-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-03-02/aws-hyper" }
kms = { path = "../../../aws-sdk-main-2021-04-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-04-02/aws-hyper" }
tokio = { version = "1", features = ["full"]}
# optional
env_logger = "0.8.2"
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
clap = { version = "2.33.3" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
35 changes: 0 additions & 35 deletions ALPHA/kms/CreateKey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
*/

use clap::{App, Arg};
// use serde::{Deserialize, Serialize};
// use serde_json::Value;
// use std::error::Error;
// use std::process;

use kms::operation::CreateKey;
use kms::Region;
Expand Down Expand Up @@ -44,8 +40,6 @@ async fn main() {
.await
.expect("failed to create key");

// println!("");
//println!("{:?}", data.key_metadata);
println!("");

match data.key_metadata {
Expand All @@ -55,33 +49,4 @@ async fn main() {
Some(k) => println!("{}", k),
},
}
/*
for item in data.key_metadata.iter() {
println!("{:?}", item)
}
// parse into generic JSON value
//let json_string: String = data.key_metadata.key_id;
let root: Value = serde_json::from_str("");
// access element using .get()
{
"data": [
{
"hostname": "a hostname"
}
]
}
let hostname: Option<&str> = root
.get("data")
.and_then(|value| value.get(0))
.and_then(|value| value.get("hostname"))
.and_then(|value| value.as_str());
// hostname is Some(string_value) if .data[0].hostname is a string,
// and None if it was not found
println!("hostname = {:?}", hostname); // = Some("a hostname")
*/
}
7 changes: 7 additions & 0 deletions ALPHA/kms/Decrypt/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ALPHA/kms/Decrypt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ edition = "2018"
description = "Code example of the KMS Decrypt API"

[dependencies]
kms = { path = "../../../aws-sdk-main-2021-03-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-03-02/aws-hyper" }
kms = { path = "../../../aws-sdk-main-2021-04-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-04-02/aws-hyper" }
tokio = { version = "1", features = ["full"]}
# optional
base64 = "0.13.0"
clap = { version = "2.33.3" }
env_logger = "0.8.2"
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
51 changes: 20 additions & 31 deletions ALPHA/kms/Decrypt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

use clap::{App, Arg};

extern crate base64;

use std::env;
use std::fs;
use std::process;
use std::str;

use kms::operation::Decrypt;
Expand All @@ -32,29 +34,31 @@ async fn main() {
.long("key")
.value_name("KEY")
.help("Specifies the encryption key")
.takes_value(true),
.takes_value(true)
.required(true),
)
.arg(
Arg::with_name("text")
.short("t")
.long("text")
.value_name("TEXT")
.help("Specifies file with encrypted text to decrypt")
.takes_value(true),
.takes_value(true)
.required(true),
)
.get_matches();

let region = matches.value_of("region").unwrap_or("us-west-2");
// Get value of AWS_DEFAULT_REGION, if set.
let default_region;
match env::var("AWS_DEFAULT_REGION") {
Ok(val) => default_region = val,
Err(_e) => default_region = "us-west-2".to_string(),
}

let region = matches.value_of("region").unwrap_or(&*default_region);
let key = matches.value_of("key").unwrap_or("");
let text = matches.value_of("text").unwrap_or("");

if region == "" || key == "" || text == "" {
println!("You must supply a value for region, key, and file containing encrypted text ([-r REGION] -k KEY -t TEXT-FILE)");
println!("If REGION is omitted, defaults to us-west-2");

process::exit(1);
}

SubscriberBuilder::default()
.with_env_filter("info")
.with_span_events(FmtSpan::CLOSE)
Expand All @@ -63,34 +67,19 @@ async fn main() {

let client = aws_hyper::Client::https();

// Vector to hold the string parts/u8 values
let mut v_bytes: Vec<u8> = Vec::new();
// Vector to hold the string once we decode it from base64.
let mut my_bytes: Vec<u8> = Vec::new();

// Open text file and get contents as a string
match fs::read_to_string(text) {
Ok(input) => {
// Split the string into parts by comma
let parts = input.split(",");
for s in parts {
// Trim any trailing line feed
let mut my_string = String::from(s);

let len = my_string.trim_end_matches(&['\r', '\n'][..]).len();
my_string.truncate(len);

match my_string.parse::<u8>() {
Ok(num) => v_bytes.push(num),
Err(e) => {
println!("Got an error parsing '{}'", s);
panic!("{}", e)
}
}
}
// input is a base-64 encoded string, so decode it:
my_bytes = base64::decode(input).unwrap();
}
Err(_) => println!("Could not parse {} as a string", text),
}

let blob = Blob::new(v_bytes);
let blob = Blob::new(my_bytes);

let resp = client
.call(
Expand Down
83 changes: 81 additions & 2 deletions ALPHA/kms/Encrypt/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions ALPHA/kms/Encrypt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ edition = "2018"
description = "Code example of the KMS Encrypt API"

[dependencies]
kms = { path = "../../../aws-sdk-main-2021-03-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-03-02/aws-hyper" }
kms = { path = "../../../aws-sdk-main-2021-04-02/kms" }
aws-hyper = { path = "../../../aws-sdk-main-2021-04-02/aws-hyper" }
tokio = { version = "1", features = ["full"]}
base64 = "0.13.0"
clap = { version = "2.33.3" }
# optional
env_logger = "0.8.2"
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
clap = { version = "2.33.3" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Loading

0 comments on commit beb99b5

Please sign in to comment.