Skip to content

Commit

Permalink
Rust: Update for SDK HttpConnector changes. (#5483)
Browse files Browse the repository at this point in the history
* Rust: Update for SDK HttpConnector changes.

* Fix wasm connector

* Update from TestConnector to StaticReplayClient

* Remove deprecated aws-smithy-client

* Final refactor fo run_all.sh
  • Loading branch information
DavidSouther authored and ford-at-aws committed Dec 15, 2023
1 parent afe90c7 commit 5864ef3
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "
aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-sns = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"test-util",
] }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-types-convert ={ git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["convert-chrono"] }
aws_lambda_events = { version = "0.10.0", features = ["s3", "apigw"], default-features = false }
bytes = "1.4.0"
Expand All @@ -35,6 +33,7 @@ lambda_runtime = "0.8.0"
miniz_oxide = "0.7.1"
pin-project = "1.0.12"
pipe = "0.4.0"
sdk-examples-test-utils = { path = "../../test-utils" }
serde = { version = "1.0.159", features = ["derive"] }
serde_json = "1.0.95"
streaming-zip = "0.5.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ pub async fn handler(

#[cfg(test)]
mod test {
use sdk_examples_test_utils::single_shot_client;
use serde_json::json;

use crate::single_shot_client;

use super::{get_labels, Labels};

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod chunked_uploader;
pub mod common;
pub mod handlers;
pub mod test_utils;
pub mod uploader;

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion rust_dev_preview/cross_service/rest_ses/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"
aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-ses = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
chrono = { version = "0.4.22", default-features = false, features = [
"clock",
"serde",
Expand All @@ -44,7 +45,7 @@ uuid = { version = "1.2.1", features = ["v4", "serde"] }
xlsxwriter = "0.6.0"

[dev-dependencies]
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
fake = { version = "2.5.0", features = ["uuid"] }
once_cell = "1.15.0"
Expand Down
17 changes: 7 additions & 10 deletions rust_dev_preview/cross_service/rest_ses/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,20 @@ impl RdsClient {

#[cfg(test)]
mod rds_client_for_test {
use aws_smithy_http::body::SdkBody;
use aws_smithy_runtime::client::http::test_util::ReplayEvent;
use secrecy::Secret;

use super::RdsClient;
impl RdsClient {
pub fn for_test(
pairs: Vec<(
http::request::Request<SdkBody>,
http::response::Response<SdkBody>,
)>,
) -> Self {
pub fn for_test(pairs: Vec<ReplayEvent>) -> Self {
RdsClient {
client: aws_sdk_rdsdata::Client::from_conf(
sdk_examples_test_utils::client_config!(aws_sdk_rdsdata)
.http_connector(aws_smithy_client::test_connection::TestConnection::new(
pairs,
))
.http_client(
aws_smithy_runtime::client::http::test_util::StaticReplayClient::new(
pairs,
),
)
.build(),
),
secret_arn: Secret::from("secret".to_string()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ async fn describe_pool(client: &Client, id: &str) -> Result<(), Error> {
println!(" value: {}", value);
}

let open_id_arns = response.open_id_connect_provider_ar_ns();
let open_id_arns = response.open_id_connect_provider_arns();
println!(" Open ID provider ARNs:");
for arn in open_id_arns {
println!(" {}", arn);
}

let saml_arns = response.saml_provider_ar_ns();
let saml_arns = response.saml_provider_arns();
println!(" SAML provider ARNs:");
for arn in saml_arns {
println!(" {}", arn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ description = "An example demonstrating setting a custom root certificate with r

[dependencies]
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
# bringing our own HTTPs so no need for the default features
aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false }
tokio = { version = "1.21.2", features = ["full"] }
Expand Down
22 changes: 8 additions & 14 deletions rust_dev_preview/examples/dynamodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,24 @@ edition = "2021"

[dependencies]
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"client-hyper",
"rustls",
"rt-tokio",
] }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"rt-tokio",
] }
aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "rt-tokio", ] }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] }
aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
axum = "0.5.16"
http = "0.2.5"
clap = { version = "~4.2", features = ["derive"] }
futures = "0.3"
http = "0.2.5"
log = "0.4.17"
rand = "0.8.3"
sdk-examples-test-utils = { path = "../../test-utils" }
serde = {version = "1.0", features = ["derive"]}
serde_json = "1"
serde_dynamo = { version = "4", features = ["aws-sdk-dynamodb+0_22"] }
clap = { version = "~4.2", features = ["derive"] }
tracing = "0.1"
serde_json = "1"
thiserror = "1.0"
tokio = { version = "1.20.1", features = ["full"] }
tokio-stream = "0.1.8"
tower-http = { version = "0.3.0", features = ["cors"] }
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
8 changes: 4 additions & 4 deletions rust_dev_preview/examples/dynamodb/src/scenario/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ mod test_list_more_tables {
async fn test_list_tables_iterative() {
let client = aws_sdk_dynamodb::Client::from_conf(
sdk_examples_test_utils::client_config!(aws_sdk_dynamodb)
.http_connector(aws_smithy_client::test_connection::TestConnection::new(
vec![
.http_client(
aws_smithy_runtime::client::http::test_util::StaticReplayClient::new(vec![
test_event!(
"",
(
Expand All @@ -136,8 +136,8 @@ mod test_list_more_tables {
)
),
test_event!("", (200, r#"{"TableNames":["g","h"]}"#)),
],
))
]),
)
.build(),
);

Expand Down
5 changes: 0 additions & 5 deletions rust_dev_preview/examples/glue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"
aws-sdk-glue = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"client-hyper",
"rustls",
"rt-tokio",
] }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"rt-tokio",
] }
Expand Down
5 changes: 0 additions & 5 deletions rust_dev_preview/examples/kms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ description = "Example usage of the KMS service"
[dependencies]
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"client-hyper",
"rustls",
"rt-tokio",
] }
tokio = { version = "1.20.1", features = ["full"] }
base64 = "0.13.0"
clap = { version = "~4.2", features = ["derive"] }
Expand Down
4 changes: 1 addition & 3 deletions rust_dev_preview/examples/s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"
aws-endpoint = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
# snippet-end:[s3.rust.s3-object-lambda-cargo.toml]
aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"test-util",
] }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["rt-tokio"] }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
sdk-examples-test-utils = { path = "../../test-utils" }
bytes = "1.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ async fn put_object(client: &Client, opts: &Opt) -> Result<(), anyhow::Error> {
// ProgressBody wrapped implementation.
let customized = request
.customize()
.await?
.map_request(ProgressBody::<SdkBody>::replace);

let out = customized.send().await?;
Expand Down
6 changes: 3 additions & 3 deletions rust_dev_preview/examples/s3/src/s3-service-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub async fn create_bucket(
mod test {
use std::env::temp_dir;

use aws_smithy_client::test_connection::TestConnection;
use aws_smithy_runtime::client::http::test_util::StaticReplayClient;
use sdk_examples_test_utils::{client_config, single_shot_client, test_event};
use tokio::{fs::File, io::AsyncWriteExt};
use uuid::Uuid;
Expand All @@ -190,7 +190,7 @@ mod test {
async fn test_delete_objects() {
let client = aws_sdk_s3::Client::from_conf(
client_config!(aws_sdk_s3)
.http_connector(TestConnection::new(vec![
.http_client(StaticReplayClient::new(vec![
// client.list_objects_v2().bucket(bucket_name)
test_event!(
r#""#,
Expand Down Expand Up @@ -241,7 +241,7 @@ mod test {
async fn test_delete_objects_failed() {
let client = aws_sdk_s3::Client::from_conf(
client_config!(aws_sdk_s3)
.http_connector(TestConnection::new(vec![
.http_client(StaticReplayClient::new(vec![
// client.list_objects_v2().bucket(bucket_name)
test_event!(
r#""#,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ reqwest = "0.11"
clap = { version = "~4.2", features = ["derive"] }
tokio = { version = "1.20.1", features = ["full"] }
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
hyper-tls = "0.5.0"
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn print_as_curl_request(presigned_req: &PresignedRequest, body: Option<&str>) {

/// This function demonstrates how you can send a presigned request using [hyper](https://crates.io/crates/hyper)
async fn send_presigned_request_with_hyper(req: PresignedRequest, body: hyper::Body) {
let conn = aws_smithy_client::conns::https();
let conn = hyper_tls::HttpsConnector::new();
let client = hyper::Client::builder().build(conn);
let req = req.to_http_request(body).unwrap();

Expand Down
3 changes: 0 additions & 3 deletions rust_dev_preview/examples/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ async-trait = "0.1.51"
# snippet-end:[testing.rust.Cargo.toml]
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
"test-util",
] }
aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [
Expand Down
2 changes: 1 addition & 1 deletion rust_dev_preview/examples/tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ path = "src/lib.rs"

[dependencies]
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" }
aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false }
webpki-roots = "0.22.4"
tokio = { version = "1.20.1", features = ["full"] }
Expand Down
Loading

0 comments on commit 5864ef3

Please sign in to comment.