From eb261e63abbead8d9acb0d0fd705f2c7a936f4f5 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 13 Mar 2023 15:28:15 -0700 Subject: [PATCH] Enable crate reorganization for the SDK (#2433) * Enable the crate reorg for the SDK * Fix `aws-config` * Fix SDK integration tests * Fix event stream error module bug * Fix doc test imports * Fix some tests * Fix external type check * Fix the canary for both versions * Fix codegen crash for certain SDK models * Fix some doc compilation failures * Update the changelog * Fix presigning test merge conflict --- CHANGELOG.next.toml | 7 + .../aws-config/external-types.toml | 2 +- .../aws-config/src/imds/region.rs | 2 +- .../aws-config/src/profile/app_name.rs | 2 +- .../src/profile/credentials/exec.rs | 4 +- .../aws-config/src/profile/region.rs | 2 +- .../aws-config/src/provider_config.rs | 4 +- aws/rust-runtime/aws-config/src/sso.rs | 5 +- .../aws-config/src/sts/assume_role.rs | 13 +- aws/rust-runtime/aws-config/src/sts/util.rs | 2 +- .../aws-config/src/web_identity_token.rs | 7 +- aws/sdk-adhoc-test/build.gradle.kts | 6 +- .../smithy/rustsdk/AwsCrateDocsDecorator.kt | 13 +- .../rustsdk/endpoints/AwsEndpointDecorator.kt | 6 +- .../amazon/smithy/rustsdk/TestUtil.kt | 9 +- aws/sdk/build.gradle.kts | 2 +- .../dynamodb/benches/deserialization_bench.rs | 2 +- .../dynamodb/benches/serialization_bench.rs | 4 +- .../dynamodb/tests/endpoints.rs | 2 +- .../dynamodb/tests/movies.rs | 7 +- .../dynamodb/tests/paginators.rs | 2 +- .../dynamodb/tests/shared-config.rs | 2 +- .../dynamodb/tests/timeouts.rs | 2 +- .../integration-tests/ec2/tests/paginators.rs | 2 +- .../glacier/tests/custom-headers.rs | 4 +- .../iam/tests/resolve-global-endpoint.rs | 2 +- .../kms/tests/integration.rs | 13 +- .../kms/tests/sensitive-it.rs | 21 ++- .../lambda/tests/request_id.rs | 5 +- .../polly/tests/presigning.rs | 14 +- .../qldbsession/tests/integration.rs | 9 +- .../s3/tests/alternative-async-runtime.rs | 5 +- .../integration-tests/s3/tests/checksums.rs | 8 +- .../s3/tests/customizable-operation.rs | 3 +- .../integration-tests/s3/tests/endpoints.rs | 3 +- .../s3/tests/ignore-invalid-xml-body-root.rs | 2 +- .../s3/tests/naughty-string-metadata.rs | 2 +- .../s3/tests/normalize-uri-path.rs | 4 +- .../integration-tests/s3/tests/presigning.rs | 22 +-- .../query-strings-are-correctly-encoded.rs | 5 +- .../s3/tests/recursion-detection.rs | 3 +- .../integration-tests/s3/tests/request_id.rs | 6 +- .../s3/tests/required-query-params.rs | 8 +- .../s3/tests/select-object-content.rs | 5 +- .../integration-tests/s3/tests/signing-it.rs | 3 +- .../integration-tests/s3/tests/size-type.rs | 2 +- .../s3/tests/streaming-response.rs | 5 +- .../integration-tests/s3/tests/timeouts.rs | 5 +- .../s3/tests/user-agent-app-name.rs | 3 +- .../s3control/tests/signing-it.rs | 3 +- .../sts/tests/retry_idp_comms_err.rs | 3 +- .../integration-tests/sts/tests/signing-it.rs | 2 +- .../transcribestreaming/tests/test.rs | 12 +- .../client/smithy/ClientCodegenVisitor.kt | 2 +- .../codegen/client/smithy/ClientRustModule.kt | 9 +- .../error/OperationErrorGenerator.kt | 1 - .../protocol/ClientProtocolGenerator.kt | 3 +- tools/ci-cdk/canary-lambda/src/canary.rs | 4 +- tools/ci-cdk/canary-lambda/src/latest.rs | 8 + .../src/latest/paginator_canary.rs | 71 +++++++++ .../canary-lambda/src/latest/s3_canary.rs | 140 ++++++++++++++++++ .../src/latest/transcribe_canary.rs | 92 ++++++++++++ tools/ci-cdk/canary-lambda/src/main.rs | 37 ++--- .../canary-lambda/src/release_2023_01_26.rs | 8 + .../paginator_canary.rs | 0 .../src/{ => release_2023_01_26}/s3_canary.rs | 0 .../transcribe_canary.rs | 5 +- tools/ci-cdk/canary-runner/additional-ci | 5 - .../ci-cdk/canary-runner/src/build_bundle.rs | 22 ++- tools/ci-scripts/check-aws-sdk-canary | 5 +- 70 files changed, 520 insertions(+), 183 deletions(-) create mode 100644 tools/ci-cdk/canary-lambda/src/latest.rs create mode 100644 tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs create mode 100644 tools/ci-cdk/canary-lambda/src/latest/s3_canary.rs create mode 100644 tools/ci-cdk/canary-lambda/src/latest/transcribe_canary.rs create mode 100644 tools/ci-cdk/canary-lambda/src/release_2023_01_26.rs rename tools/ci-cdk/canary-lambda/src/{ => release_2023_01_26}/paginator_canary.rs (100%) rename tools/ci-cdk/canary-lambda/src/{ => release_2023_01_26}/s3_canary.rs (100%) rename tools/ci-cdk/canary-lambda/src/{ => release_2023_01_26}/transcribe_canary.rs (94%) delete mode 100755 tools/ci-cdk/canary-runner/additional-ci diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index bc37fcab3..d5b5e89a5 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -275,3 +275,10 @@ message = "Smithy members named `send` were previously renamed to `send_value` a references = ["smithy-rs#2382"] meta = { "breaking" = true, "tada" = false, "bug" = true, "target" = "server" } author = "jdisanti" + +[[aws-sdk-rust]] +message = "The modules in the SDK crates have been reorganized. See the [SDK Crate Reorganization Upgrade Guidance](https://github.com/awslabs/aws-sdk-rust/discussions/752) to see how to fix your code after this change." +references = ["smithy-rs#2433"] +meta = { "breaking" = true, "tada" = false, "bug" = false } +author = "jdisanti" + diff --git a/aws/rust-runtime/aws-config/external-types.toml b/aws/rust-runtime/aws-config/external-types.toml index 6935fe9bc..7e0257f46 100644 --- a/aws/rust-runtime/aws-config/external-types.toml +++ b/aws/rust-runtime/aws-config/external-types.toml @@ -7,7 +7,7 @@ allowed_external_types = [ "aws_credential_types::provider::ProvideCredentials", "aws_credential_types::provider::Result", "aws_credential_types::provider::SharedCredentialsProvider", - "aws_sdk_sts::model::PolicyDescriptorType", + "aws_sdk_sts::types::_policy_descriptor_type::PolicyDescriptorType", "aws_smithy_async::rt::sleep::AsyncSleep", "aws_smithy_client::bounds::SmithyConnector", "aws_smithy_client::erase::DynConnector", diff --git a/aws/rust-runtime/aws-config/src/imds/region.rs b/aws/rust-runtime/aws-config/src/imds/region.rs index 8679e3e75..bc784f8d4 100644 --- a/aws/rust-runtime/aws-config/src/imds/region.rs +++ b/aws/rust-runtime/aws-config/src/imds/region.rs @@ -117,7 +117,7 @@ mod test { use crate::imds::client::test::{imds_request, imds_response, token_request, token_response}; use crate::imds::region::ImdsRegionProvider; use crate::provider_config::ProviderConfig; - use aws_sdk_sts::Region; + use aws_sdk_sts::config::Region; use aws_smithy_async::rt::sleep::TokioSleep; use aws_smithy_client::erase::DynConnector; use aws_smithy_client::test_connection::TestConnection; diff --git a/aws/rust-runtime/aws-config/src/profile/app_name.rs b/aws/rust-runtime/aws-config/src/profile/app_name.rs index a49fefc8b..80a5f192c 100644 --- a/aws/rust-runtime/aws-config/src/profile/app_name.rs +++ b/aws/rust-runtime/aws-config/src/profile/app_name.rs @@ -103,7 +103,7 @@ mod tests { use super::ProfileFileAppNameProvider; use crate::provider_config::ProviderConfig; use crate::test_case::no_traffic_connector; - use aws_sdk_sts::AppName; + use aws_sdk_sts::config::AppName; use aws_types::os_shim_internal::{Env, Fs}; use tracing_test::traced_test; diff --git a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs index f930b1a8d..fda62d770 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs @@ -11,9 +11,9 @@ use crate::sso::{SsoConfig, SsoCredentialsProvider}; use crate::sts; use crate::web_identity_token::{StaticConfiguration, WebIdentityTokenCredentialsProvider}; use aws_credential_types::provider::{self, error::CredentialsError, ProvideCredentials}; -use aws_sdk_sts::input::AssumeRoleInput; use aws_sdk_sts::middleware::DefaultMiddleware; -use aws_sdk_sts::{Config, Credentials}; +use aws_sdk_sts::operation::assume_role::AssumeRoleInput; +use aws_sdk_sts::{config::Credentials, Config}; use aws_smithy_client::erase::DynConnector; use aws_types::region::Region; use std::fmt::Debug; diff --git a/aws/rust-runtime/aws-config/src/profile/region.rs b/aws/rust-runtime/aws-config/src/profile/region.rs index c58fce403..3cdcf8f7e 100644 --- a/aws/rust-runtime/aws-config/src/profile/region.rs +++ b/aws/rust-runtime/aws-config/src/profile/region.rs @@ -158,7 +158,7 @@ mod test { use crate::profile::ProfileFileRegionProvider; use crate::provider_config::ProviderConfig; use crate::test_case::no_traffic_connector; - use aws_sdk_sts::Region; + use aws_sdk_sts::config::Region; use aws_types::os_shim_internal::{Env, Fs}; use futures_util::FutureExt; use tracing_test::traced_test; diff --git a/aws/rust-runtime/aws-config/src/provider_config.rs b/aws/rust-runtime/aws-config/src/provider_config.rs index 9ca283d25..cb4bd5aa1 100644 --- a/aws/rust-runtime/aws-config/src/provider_config.rs +++ b/aws/rust-runtime/aws-config/src/provider_config.rs @@ -124,7 +124,7 @@ impl ProviderConfig { /// # #[cfg(any(feature = "rustls", feature = "native-tls"))] /// # fn example() { /// use aws_config::provider_config::ProviderConfig; - /// use aws_sdk_sts::Region; + /// use aws_sdk_sts::config::Region; /// use aws_config::web_identity_token::WebIdentityTokenCredentialsProvider; /// let conf = ProviderConfig::without_region().with_region(Some(Region::new("us-east-1"))); /// @@ -156,7 +156,7 @@ impl ProviderConfig { /// ```no_run /// # async fn test() { /// use aws_config::provider_config::ProviderConfig; - /// use aws_sdk_sts::Region; + /// use aws_sdk_sts::config::Region; /// use aws_config::web_identity_token::WebIdentityTokenCredentialsProvider; /// let conf = ProviderConfig::with_default_region().await; /// let credential_provider = WebIdentityTokenCredentialsProvider::builder().configure(&conf).build(); diff --git a/aws/rust-runtime/aws-config/src/sso.rs b/aws/rust-runtime/aws-config/src/sso.rs index 3881a217a..7c693bdf2 100644 --- a/aws/rust-runtime/aws-config/src/sso.rs +++ b/aws/rust-runtime/aws-config/src/sso.rs @@ -17,7 +17,8 @@ use crate::provider_config::ProviderConfig; use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials}; use aws_credential_types::Credentials; use aws_sdk_sso::middleware::DefaultMiddleware as SsoMiddleware; -use aws_sdk_sso::model::RoleCredentials; +use aws_sdk_sso::operation::get_role_credentials::GetRoleCredentialsInput; +use aws_sdk_sso::types::RoleCredentials; use aws_smithy_client::erase::DynConnector; use aws_smithy_json::deserialize::Token; use aws_smithy_types::date_time::Format; @@ -211,7 +212,7 @@ async fn load_sso_credentials( let config = aws_sdk_sso::Config::builder() .region(sso_config.region.clone()) .build(); - let operation = aws_sdk_sso::input::GetRoleCredentialsInput::builder() + let operation = GetRoleCredentialsInput::builder() .role_name(&sso_config.role_name) .access_token(&*token.access_token) .account_id(&sso_config.account_id) diff --git a/aws/rust-runtime/aws-config/src/sts/assume_role.rs b/aws/rust-runtime/aws-config/src/sts/assume_role.rs index ad24b11bb..35f2b3fa2 100644 --- a/aws/rust-runtime/aws-config/src/sts/assume_role.rs +++ b/aws/rust-runtime/aws-config/src/sts/assume_role.rs @@ -8,10 +8,9 @@ use crate::provider_config::ProviderConfig; use aws_credential_types::cache::CredentialsCache; use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials}; -use aws_sdk_sts::error::AssumeRoleError; -use aws_sdk_sts::input::AssumeRoleInput; use aws_sdk_sts::middleware::DefaultMiddleware; -use aws_sdk_sts::model::PolicyDescriptorType; +use aws_sdk_sts::operation::assume_role::{AssumeRoleError, AssumeRoleInput}; +use aws_sdk_sts::types::PolicyDescriptorType; use aws_smithy_client::erase::DynConnector; use aws_smithy_http::result::SdkError; use aws_smithy_types::error::display::DisplayErrorContext; @@ -49,7 +48,7 @@ pub struct AssumeRoleProvider { struct Inner { sts: aws_smithy_client::Client, conf: aws_sdk_sts::Config, - op: aws_sdk_sts::input::AssumeRoleInput, + op: AssumeRoleInput, } impl AssumeRoleProvider { @@ -128,7 +127,7 @@ impl AssumeRoleProviderBuilder { /// /// This parameter is optional /// For more information, see - /// [policy](aws_sdk_sts::input::assume_role_input::Builder::policy_arns) + /// [policy](aws_sdk_sts::operation::assume_role::builders::AssumeRoleInputBuilder::policy_arns) pub fn policy(mut self, policy: impl Into) -> Self { self.policy = Some(policy.into()); self @@ -138,7 +137,7 @@ impl AssumeRoleProviderBuilder { /// /// This parameter is optional. /// For more information, see - /// [policy_arns](aws_sdk_sts::input::assume_role_input::Builder::policy_arns) + /// [policy_arns](aws_sdk_sts::operation::assume_role::builders::AssumeRoleInputBuilder::policy_arns) pub fn policy_arns(mut self, policy_arns: Vec) -> Self { self.policy_arns = Some(policy_arns); self @@ -155,7 +154,7 @@ impl AssumeRoleProviderBuilder { /// but your administrator set the maximum session duration to 6 hours, you cannot assume the role. /// /// For more information, see - /// [duration_seconds](aws_sdk_sts::input::assume_role_input::Builder::duration_seconds) + /// [duration_seconds](aws_sdk_sts::operation::assume_role::builders::AssumeRoleInputBuilder::duration_seconds) pub fn session_length(mut self, length: Duration) -> Self { self.session_length = Some(length); self diff --git a/aws/rust-runtime/aws-config/src/sts/util.rs b/aws/rust-runtime/aws-config/src/sts/util.rs index 9ebdbe6f1..426d3eb40 100644 --- a/aws/rust-runtime/aws-config/src/sts/util.rs +++ b/aws/rust-runtime/aws-config/src/sts/util.rs @@ -5,7 +5,7 @@ use aws_credential_types::provider::{self, error::CredentialsError}; use aws_credential_types::Credentials as AwsCredentials; -use aws_sdk_sts::model::Credentials as StsCredentials; +use aws_sdk_sts::types::Credentials as StsCredentials; use std::convert::TryFrom; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/aws/rust-runtime/aws-config/src/web_identity_token.rs b/aws/rust-runtime/aws-config/src/web_identity_token.rs index 82c184897..dd13524b0 100644 --- a/aws/rust-runtime/aws-config/src/web_identity_token.rs +++ b/aws/rust-runtime/aws-config/src/web_identity_token.rs @@ -64,8 +64,9 @@ use crate::provider_config::ProviderConfig; use crate::sts; use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials}; +use aws_sdk_sts::config::Region; use aws_sdk_sts::middleware::DefaultMiddleware; -use aws_sdk_sts::Region; +use aws_sdk_sts::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityInput; use aws_smithy_client::erase::DynConnector; use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::os_shim_internal::{Env, Fs}; @@ -236,7 +237,7 @@ async fn load_credentials( .region(region.clone()) .build(); - let operation = aws_sdk_sts::input::AssumeRoleWithWebIdentityInput::builder() + let operation = AssumeRoleWithWebIdentityInput::builder() .role_arn(role_arn) .role_session_name(session_name) .web_identity_token(token) @@ -260,7 +261,7 @@ mod test { Builder, ENV_VAR_ROLE_ARN, ENV_VAR_SESSION_NAME, ENV_VAR_TOKEN_FILE, }; use aws_credential_types::provider::error::CredentialsError; - use aws_sdk_sts::Region; + use aws_sdk_sts::config::Region; use aws_smithy_async::rt::sleep::TokioSleep; use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::os_shim_internal::{Env, Fs}; diff --git a/aws/sdk-adhoc-test/build.gradle.kts b/aws/sdk-adhoc-test/build.gradle.kts index 41fcbdc88..c127b3ff9 100644 --- a/aws/sdk-adhoc-test/build.gradle.kts +++ b/aws/sdk-adhoc-test/build.gradle.kts @@ -45,7 +45,8 @@ val allCodegenTests = listOf( extraConfig = """ , "codegen": { - "includeFluentClient": false + "includeFluentClient": false, + "enableNewCrateOrganizationScheme": true }, "customizationConfig": { "awsSdk": { @@ -61,7 +62,8 @@ val allCodegenTests = listOf( extraConfig = """ , "codegen": { - "includeFluentClient": false + "includeFluentClient": false, + "enableNewCrateOrganizationScheme": true }, "customizationConfig": { "awsSdk": { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCrateDocsDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCrateDocsDecorator.kt index ee95163ef..a810b3e8a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCrateDocsDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCrateDocsDecorator.kt @@ -72,17 +72,14 @@ class AwsCrateDocsDecorator : ClientCodegenDecorator { } } - override fun clientConstructionDocs(codegenContext: ClientCodegenContext, baseDocs: Writable): Writable { - return if (generateReadme(codegenContext)) { - writable { - val serviceName = codegenContext.serviceShape.serviceNameOrDefault("the service") - docs("Client for calling $serviceName.") + override fun clientConstructionDocs(codegenContext: ClientCodegenContext, baseDocs: Writable): Writable = + writable { + val serviceName = codegenContext.serviceShape.serviceNameOrDefault("the service") + docs("Client for calling $serviceName.") + if (generateReadme(codegenContext)) { AwsDocs.clientConstructionDocs(codegenContext)(this) } - } else { - baseDocs } - } private fun generateReadme(codegenContext: ClientCodegenContext) = SdkSettings.from(codegenContext.settings).generateReadme diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt index 94013f1b8..41c8d29bd 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt @@ -168,11 +168,9 @@ class AwsEndpointDecorator : ClientCodegenDecorator { /// ## Examples /// ```no_run /// ## fn wrapper() -> Result<(), aws_smithy_http::endpoint::error::InvalidEndpointError> { - /// use #{aws_types}::region::Region; - /// use $moduleUseName::config::{Builder, Config}; - /// use $moduleUseName::Endpoint; + /// use $moduleUseName::config::{Config, Endpoint, Region}; /// - /// let config = $moduleUseName::Config::builder() + /// let config = Config::builder() /// .endpoint_resolver(Endpoint::immutable("http://localhost:8080")?) /// .build(); /// ## Ok(()) diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt index d0a619b46..f24dd8840 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt @@ -49,11 +49,18 @@ fun awsSdkIntegrationTest( .withMember( "awsSdk", ObjectNode.builder() + .withMember("generateReadme", false) .withMember("integrationTestPath", "../sdk/integration-tests") .build(), ).build(), ) - .withMember("codegen", ObjectNode.builder().withMember("includeFluentClient", false).build()).build(), + .withMember( + "codegen", + ObjectNode.builder() + .withMember("includeFluentClient", false) + .withMember("enableNewCrateOrganizationScheme", true) + .build(), + ).build(), ), test = test, ) diff --git a/aws/sdk/build.gradle.kts b/aws/sdk/build.gradle.kts index 314787770..936740ac1 100644 --- a/aws/sdk/build.gradle.kts +++ b/aws/sdk/build.gradle.kts @@ -100,7 +100,7 @@ fun generateSmithyBuild(services: AwsServices): String { "includeFluentClient": false, "renameErrors": false, "eventStreamAllowList": [$eventStreamAllowListMembers], - "enableNewCrateOrganizationScheme": false + "enableNewCrateOrganizationScheme": true }, "service": "${service.service}", "module": "$moduleName", diff --git a/aws/sdk/integration-tests/dynamodb/benches/deserialization_bench.rs b/aws/sdk/integration-tests/dynamodb/benches/deserialization_bench.rs index bea625d81..faf7eba2e 100644 --- a/aws/sdk/integration-tests/dynamodb/benches/deserialization_bench.rs +++ b/aws/sdk/integration-tests/dynamodb/benches/deserialization_bench.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_dynamodb::operation::Query; +use aws_sdk_dynamodb::operation::query::Query; use aws_smithy_http::response::ParseHttpResponse; use bytes::Bytes; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/aws/sdk/integration-tests/dynamodb/benches/serialization_bench.rs b/aws/sdk/integration-tests/dynamodb/benches/serialization_bench.rs index 694c7f791..82e37cfe8 100644 --- a/aws/sdk/integration-tests/dynamodb/benches/serialization_bench.rs +++ b/aws/sdk/integration-tests/dynamodb/benches/serialization_bench.rs @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_dynamodb::input::PutItemInput; -use aws_sdk_dynamodb::model::AttributeValue; +use aws_sdk_dynamodb::operation::put_item::PutItemInput; +use aws_sdk_dynamodb::types::AttributeValue; use aws_sdk_dynamodb::Config; use criterion::{criterion_group, criterion_main, Criterion}; use futures_util::FutureExt; diff --git a/aws/sdk/integration-tests/dynamodb/tests/endpoints.rs b/aws/sdk/integration-tests/dynamodb/tests/endpoints.rs index 4d3dedd71..6a01fedef 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/endpoints.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/endpoints.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_dynamodb::{config, Credentials, Region}; +use aws_sdk_dynamodb::config::{self, Credentials, Region}; use aws_types::SdkConfig; use http::Uri; diff --git a/aws/sdk/integration-tests/dynamodb/tests/movies.rs b/aws/sdk/integration-tests/dynamodb/tests/movies.rs index 918dc9c1b..a3eaa244a 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/movies.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/movies.rs @@ -6,12 +6,13 @@ use aws_sdk_dynamodb as dynamodb; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; -use dynamodb::model::{ +use dynamodb::config::{Credentials, Region}; +use dynamodb::operation::query::QueryOutput; +use dynamodb::types::{ AttributeDefinition, AttributeValue, KeySchemaElement, KeyType, ProvisionedThroughput, ScalarAttributeType, TableStatus, }; -use dynamodb::output::QueryOutput; -use dynamodb::{Client, Credentials, Region}; +use dynamodb::Client; use http::header::{HeaderName, AUTHORIZATION}; use http::Uri; use serde_json::Value; diff --git a/aws/sdk/integration-tests/dynamodb/tests/paginators.rs b/aws/sdk/integration-tests/dynamodb/tests/paginators.rs index 59aa6e610..807a11890 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/paginators.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/paginators.rs @@ -9,7 +9,7 @@ use std::iter::FromIterator; use tokio_stream::StreamExt; use aws_credential_types::Credentials; -use aws_sdk_dynamodb::model::AttributeValue; +use aws_sdk_dynamodb::types::AttributeValue; use aws_sdk_dynamodb::{Client, Config}; use aws_smithy_client::http_connector::HttpConnector; use aws_smithy_client::test_connection::{capture_request, TestConnection}; diff --git a/aws/sdk/integration-tests/dynamodb/tests/shared-config.rs b/aws/sdk/integration-tests/dynamodb/tests/shared-config.rs index aabccc837..3d5edf8cb 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/shared-config.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/shared-config.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_dynamodb::{Credentials, Region}; +use aws_sdk_dynamodb::config::{Credentials, Region}; use http::Uri; /// Iterative test of loading clients from shared configuration diff --git a/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs b/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs index 5695b403d..b566c598c 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs @@ -8,7 +8,7 @@ use std::time::Duration; use aws_credential_types::provider::SharedCredentialsProvider; use aws_credential_types::Credentials; -use aws_sdk_dynamodb::types::SdkError; +use aws_sdk_dynamodb::error::SdkError; use aws_smithy_async::rt::sleep::{AsyncSleep, Sleep}; use aws_smithy_client::never::NeverConnector; use aws_smithy_types::retry::RetryConfig; diff --git a/aws/sdk/integration-tests/ec2/tests/paginators.rs b/aws/sdk/integration-tests/ec2/tests/paginators.rs index 533e7d0df..83528f207 100644 --- a/aws/sdk/integration-tests/ec2/tests/paginators.rs +++ b/aws/sdk/integration-tests/ec2/tests/paginators.rs @@ -5,7 +5,7 @@ use tokio_stream::StreamExt; -use aws_sdk_ec2::{model::InstanceType, Client, Config, Credentials, Region}; +use aws_sdk_ec2::{config::Credentials, config::Region, types::InstanceType, Client, Config}; use aws_smithy_client::http_connector::HttpConnector; use aws_smithy_client::test_connection::TestConnection; diff --git a/aws/sdk/integration-tests/glacier/tests/custom-headers.rs b/aws/sdk/integration-tests/glacier/tests/custom-headers.rs index 5ab708ef0..00163b0a8 100644 --- a/aws/sdk/integration-tests/glacier/tests/custom-headers.rs +++ b/aws/sdk/integration-tests/glacier/tests/custom-headers.rs @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_glacier::types::ByteStream; -use aws_sdk_glacier::{Credentials, Region}; +use aws_sdk_glacier::config::{Credentials, Region}; +use aws_sdk_glacier::primitives::ByteStream; use aws_smithy_client::test_connection::capture_request; use aws_smithy_protocol_test::{assert_ok, validate_headers}; diff --git a/aws/sdk/integration-tests/iam/tests/resolve-global-endpoint.rs b/aws/sdk/integration-tests/iam/tests/resolve-global-endpoint.rs index 252cc5182..923bf568f 100644 --- a/aws/sdk/integration-tests/iam/tests/resolve-global-endpoint.rs +++ b/aws/sdk/integration-tests/iam/tests/resolve-global-endpoint.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_iam::{Credentials, Region}; +use aws_sdk_iam::config::{Credentials, Region}; use aws_smithy_client::test_connection::capture_request; // this test is ignored because pseudoregions have been removed. This test should be re-enabled diff --git a/aws/sdk/integration-tests/kms/tests/integration.rs b/aws/sdk/integration-tests/kms/tests/integration.rs index 8c9bd1e10..8d17e13d4 100644 --- a/aws/sdk/integration-tests/kms/tests/integration.rs +++ b/aws/sdk/integration-tests/kms/tests/integration.rs @@ -6,15 +6,14 @@ use aws_http::user_agent::AwsUserAgent; use aws_sdk_kms as kms; use aws_sdk_kms::middleware::DefaultMiddleware; -use aws_sdk_kms::types::RequestId; +use aws_sdk_kms::operation::RequestId; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_client::{Client as CoreClient, SdkError}; use aws_smithy_http::body::SdkBody; use http::header::AUTHORIZATION; use http::Uri; -use kms::operation::GenerateRandom; -use kms::Credentials; -use kms::{Config, Region}; +use kms::config::{Config, Credentials, Region}; +use kms::operation::generate_random::GenerateRandomInput; use std::time::{Duration, UNIX_EPOCH}; type Client = CoreClient; @@ -74,7 +73,7 @@ async fn generate_random() { .region(Region::new("us-east-1")) .credentials_provider(Credentials::for_tests()) .build(); - let mut op = GenerateRandom::builder() + let mut op = GenerateRandomInput::builder() .number_of_bytes(64) .build() .unwrap() @@ -112,7 +111,7 @@ async fn generate_random_malformed_response() { .region(Region::new("us-east-1")) .credentials_provider(Credentials::for_tests()) .build(); - let op = GenerateRandom::builder() + let op = GenerateRandomInput::builder() .number_of_bytes(64) .build() .unwrap() @@ -152,7 +151,7 @@ async fn generate_random_keystore_not_found() { .body(r#"{"__type":"CustomKeyStoreNotFoundException"}"#).unwrap()) ]); - let mut op = GenerateRandom::builder() + let mut op = GenerateRandomInput::builder() .number_of_bytes(64) .custom_key_store_id("does not exist") .build() diff --git a/aws/sdk/integration-tests/kms/tests/sensitive-it.rs b/aws/sdk/integration-tests/kms/tests/sensitive-it.rs index 00f3c8d95..2de72f327 100644 --- a/aws/sdk/integration-tests/kms/tests/sensitive-it.rs +++ b/aws/sdk/integration-tests/kms/tests/sensitive-it.rs @@ -12,17 +12,16 @@ use aws_smithy_http::result::SdkError; use aws_smithy_http::retry::ClassifyRetry; use aws_smithy_types::retry::{ErrorKind, RetryKind}; use bytes::Bytes; -use kms::error::CreateAliasError; -use kms::operation::{CreateAlias, GenerateRandom}; -use kms::output::GenerateRandomOutput; -use kms::types::Blob; +use kms::operation::create_alias::{CreateAlias, CreateAliasError, CreateAliasInput}; +use kms::operation::generate_random::{GenerateRandom, GenerateRandomOutput}; +use kms::primitives::Blob; #[test] fn validate_sensitive_trait() { let builder = GenerateRandomOutput::builder().plaintext(Blob::new("some output")); assert_eq!( format!("{:?}", builder), - "Builder { plaintext: \"*** Sensitive Data Redacted ***\", _request_id: None }" + "GenerateRandomOutputBuilder { plaintext: \"*** Sensitive Data Redacted ***\", _request_id: None }" ); let output = GenerateRandomOutput::builder() .plaintext(Blob::new("some output")) @@ -40,9 +39,9 @@ fn assert_debug() {} #[tokio::test] async fn types_are_send_sync() { assert_send_sync::(); - assert_send_sync::>(); - assert_send_sync::(); - assert_send_sync::(); + assert_send_sync::>(); + assert_send_sync::(); + assert_send_sync::(); assert_send_sync::(); assert_send_sync::(); let conf = kms::Config::builder().build(); @@ -71,13 +70,13 @@ async fn client_is_clone() { #[test] fn types_are_debug() { assert_debug::(); - assert_debug::(); - assert_debug::(); + assert_debug::(); + assert_debug::(); } async fn create_alias_op() -> Parts { let conf = kms::Config::builder().build(); - let (_, parts) = CreateAlias::builder() + let (_, parts) = CreateAliasInput::builder() .build() .unwrap() .make_operation(&conf) diff --git a/aws/sdk/integration-tests/lambda/tests/request_id.rs b/aws/sdk/integration-tests/lambda/tests/request_id.rs index ab3ede5f0..2bc465835 100644 --- a/aws/sdk/integration-tests/lambda/tests/request_id.rs +++ b/aws/sdk/integration-tests/lambda/tests/request_id.rs @@ -3,9 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_lambda::error::ListFunctionsError; -use aws_sdk_lambda::operation::ListFunctions; -use aws_sdk_lambda::types::RequestId; +use aws_sdk_lambda::operation::list_functions::{ListFunctions, ListFunctionsError}; +use aws_sdk_lambda::operation::RequestId; use aws_smithy_http::response::ParseHttpResponse; use bytes::Bytes; diff --git a/aws/sdk/integration-tests/polly/tests/presigning.rs b/aws/sdk/integration-tests/polly/tests/presigning.rs index 7dc40b8e5..bfb872916 100644 --- a/aws/sdk/integration-tests/polly/tests/presigning.rs +++ b/aws/sdk/integration-tests/polly/tests/presigning.rs @@ -4,19 +4,21 @@ */ use aws_sdk_polly as polly; -use aws_sdk_polly::model::{OutputFormat, VoiceId}; -use polly::presigning::config::PresigningConfig; +use polly::config::{Config, Credentials, Region}; +use polly::operation::synthesize_speech::SynthesizeSpeechInput; +use polly::presigning::PresigningConfig; +use polly::types::{OutputFormat, VoiceId}; use std::error::Error; use std::time::{Duration, SystemTime}; #[tokio::test] async fn test_presigning() -> Result<(), Box> { - let config = polly::Config::builder() - .credentials_provider(polly::Credentials::for_tests()) - .region(polly::Region::new("us-east-1")) + let config = Config::builder() + .credentials_provider(Credentials::for_tests()) + .region(Region::new("us-east-1")) .build(); - let input = polly::input::SynthesizeSpeechInput::builder() + let input = SynthesizeSpeechInput::builder() .output_format(OutputFormat::Mp3) .text("hello, world") .voice_id(VoiceId::Joanna) diff --git a/aws/sdk/integration-tests/qldbsession/tests/integration.rs b/aws/sdk/integration-tests/qldbsession/tests/integration.rs index 9e02690ac..680e1647d 100644 --- a/aws/sdk/integration-tests/qldbsession/tests/integration.rs +++ b/aws/sdk/integration-tests/qldbsession/tests/integration.rs @@ -9,11 +9,10 @@ use aws_smithy_client::test_connection::TestConnection; use aws_smithy_client::Client as CoreClient; use aws_smithy_http::body::SdkBody; use http::Uri; +use qldbsession::config::{Config, Credentials, Region}; use qldbsession::middleware::DefaultMiddleware; -use qldbsession::model::StartSessionRequest; -use qldbsession::operation::SendCommand; -use qldbsession::Credentials; -use qldbsession::{Config, Region}; +use qldbsession::operation::send_command::SendCommandInput; +use qldbsession::types::StartSessionRequest; use std::time::{Duration, UNIX_EPOCH}; pub type Client = CoreClient; @@ -46,7 +45,7 @@ async fn signv4_use_correct_service_name() { .credentials_provider(Credentials::for_tests()) .build(); - let mut op = SendCommand::builder() + let mut op = SendCommandInput::builder() .start_session( StartSessionRequest::builder() .ledger_name("not-real-ledger") diff --git a/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs b/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs index a1e44b2c7..209403de4 100644 --- a/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs +++ b/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs @@ -5,11 +5,12 @@ use aws_config::retry::RetryConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::model::{ +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::types::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, }; -use aws_sdk_s3::{Client, Config, Credentials, Region}; +use aws_sdk_s3::{Client, Config}; use aws_smithy_async::assert_elapsed; use aws_smithy_async::rt::sleep::{AsyncSleep, Sleep}; use aws_smithy_client::never::NeverConnector; diff --git a/aws/sdk/integration-tests/s3/tests/checksums.rs b/aws/sdk/integration-tests/s3/tests/checksums.rs index 79f00a2a3..cb1e574e4 100644 --- a/aws/sdk/integration-tests/s3/tests/checksums.rs +++ b/aws/sdk/integration-tests/s3/tests/checksums.rs @@ -6,7 +6,9 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{model::ChecksumAlgorithm, output::GetObjectOutput, Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; +use aws_sdk_s3::{operation::get_object::GetObjectOutput, types::ChecksumAlgorithm}; use aws_smithy_client::test_connection::{capture_request, TestConnection}; use aws_smithy_http::body::SdkBody; use http::header::AUTHORIZATION; @@ -69,7 +71,7 @@ async fn test_checksum_on_streaming_response( .get_object() .bucket("some-test-bucket") .key("test.txt") - .checksum_mode(aws_sdk_s3::model::ChecksumMode::Enabled) + .checksum_mode(aws_sdk_s3::types::ChecksumMode::Enabled) .customize() .await .unwrap() @@ -169,7 +171,7 @@ async fn test_checksum_on_streaming_request<'a>( use std::io::Write; file.write_all(body).unwrap(); - let body = aws_sdk_s3::types::ByteStream::read_from() + let body = aws_sdk_s3::primitives::ByteStream::read_from() .path(file.path()) .buffer_size(1024) .build() diff --git a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs index f0b584aa1..24b53523a 100644 --- a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs +++ b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs @@ -6,7 +6,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; diff --git a/aws/sdk/integration-tests/s3/tests/endpoints.rs b/aws/sdk/integration-tests/s3/tests/endpoints.rs index 02b171856..357c14290 100644 --- a/aws/sdk/integration-tests/s3/tests/endpoints.rs +++ b/aws/sdk/integration-tests/s3/tests/endpoints.rs @@ -6,7 +6,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::config::Builder; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::{capture_request, CaptureRequestReceiver}; use std::convert::Infallible; use std::time::{Duration, UNIX_EPOCH}; diff --git a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs index e2f850cb6..f4e870436 100644 --- a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs +++ b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs @@ -5,7 +5,7 @@ use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{model::ObjectAttributes, Client, Credentials, Region}; +use aws_sdk_s3::{config::Credentials, config::Region, types::ObjectAttributes, Client}; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; use aws_types::SdkConfig; diff --git a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs index fd537a539..eef5b0b14 100644 --- a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs +++ b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs @@ -5,7 +5,7 @@ use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{types::ByteStream, Client, Credentials, Region}; +use aws_sdk_s3::{config::Credentials, config::Region, primitives::ByteStream, Client}; use aws_smithy_client::test_connection::capture_request; use aws_types::SdkConfig; use http::HeaderValue; diff --git a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs index d039064cb..1f903abb7 100644 --- a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs +++ b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs @@ -6,8 +6,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::types::ByteStream; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::primitives::ByteStream; +use aws_sdk_s3::{config::Credentials, config::Region, Client}; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; use std::time::{Duration, UNIX_EPOCH}; diff --git a/aws/sdk/integration-tests/s3/tests/presigning.rs b/aws/sdk/integration-tests/s3/tests/presigning.rs index f2f0dcacc..6f8a33d57 100644 --- a/aws/sdk/integration-tests/s3/tests/presigning.rs +++ b/aws/sdk/integration-tests/s3/tests/presigning.rs @@ -4,10 +4,14 @@ */ use aws_sdk_s3 as s3; -use aws_sdk_s3::presigning::request::PresignedRequest; use http::header::{CONTENT_LENGTH, CONTENT_TYPE}; use http::{HeaderMap, HeaderValue}; -use s3::presigning::config::PresigningConfig; +use s3::config::{Credentials, Region}; +use s3::operation::get_object::GetObjectInput; +use s3::operation::head_object::HeadObjectInput; +use s3::operation::put_object::PutObjectInput; +use s3::operation::upload_part::UploadPartInput; +use s3::presigning::{PresignedRequest, PresigningConfig}; use std::error::Error; use std::time::{Duration, SystemTime}; @@ -15,10 +19,10 @@ use std::time::{Duration, SystemTime}; /// Assumes that that input has a `presigned` method on it. macro_rules! presign_input { ($input:expr) => {{ - let creds = s3::Credentials::for_tests(); + let creds = Credentials::for_tests(); let config = s3::Config::builder() .credentials_provider(creds) - .region(s3::Region::new("us-east-1")) + .region(Region::new("us-east-1")) .build(); let req: PresignedRequest = $input @@ -37,7 +41,7 @@ macro_rules! presign_input { #[tokio::test] async fn test_presigning() -> Result<(), Box> { - let presigned = presign_input!(s3::input::GetObjectInput::builder() + let presigned = presign_input!(GetObjectInput::builder() .bucket("test-bucket") .key("test-key") .build()?); @@ -74,7 +78,7 @@ async fn test_presigning() -> Result<(), Box> { #[tokio::test] async fn test_presigning_with_payload_headers() -> Result<(), Box> { - let presigned = presign_input!(s3::input::PutObjectInput::builder() + let presigned = presign_input!(PutObjectInput::builder() .bucket("test-bucket") .key("test-key") .content_length(12345) @@ -117,7 +121,7 @@ async fn test_presigning_with_payload_headers() -> Result<(), Box> { #[tokio::test] async fn test_presigned_upload_part() -> Result<(), Box> { - let presigned = presign_input!(s3::input::UploadPartInput::builder() + let presigned = presign_input!(UploadPartInput::builder() .content_length(12345) .bucket("bucket") .key("key") @@ -133,7 +137,7 @@ async fn test_presigned_upload_part() -> Result<(), Box> { #[tokio::test] async fn test_presigning_object_lambda() -> Result<(), Box> { - let presigned = presign_input!(s3::input::GetObjectInput::builder() + let presigned = presign_input!(GetObjectInput::builder() .bucket("arn:aws:s3-object-lambda:us-west-2:123456789012:accesspoint:my-banner-ap-name") .key("test2.txt") .build() @@ -145,7 +149,7 @@ async fn test_presigning_object_lambda() -> Result<(), Box> { #[tokio::test] async fn test_presigned_head_object() -> Result<(), Box> { - let presigned = presign_input!(s3::input::HeadObjectInput::builder() + let presigned = presign_input!(HeadObjectInput::builder() .bucket("bucket") .key("key") .build()?); diff --git a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs index 7714becfe..03393a5a7 100644 --- a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs +++ b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs @@ -6,7 +6,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; use std::time::{Duration, UNIX_EPOCH}; @@ -71,7 +72,7 @@ async fn test_s3_signer_query_string_with_all_valid_chars() { #[tokio::test] #[ignore] async fn test_query_strings_are_correctly_encoded() { - use aws_sdk_s3::error::ListObjectsV2Error; + use aws_sdk_s3::operation::list_objects_v2::ListObjectsV2Error; use aws_smithy_http::result::SdkError; tracing_subscriber::fmt::init(); diff --git a/aws/sdk/integration-tests/s3/tests/recursion-detection.rs b/aws/sdk/integration-tests/s3/tests/recursion-detection.rs index c4d739447..f0aa974d8 100644 --- a/aws/sdk/integration-tests/s3/tests/recursion-detection.rs +++ b/aws/sdk/integration-tests/s3/tests/recursion-detection.rs @@ -5,7 +5,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::capture_request; use http::HeaderValue; diff --git a/aws/sdk/integration-tests/s3/tests/request_id.rs b/aws/sdk/integration-tests/s3/tests/request_id.rs index 957dd8cb2..67d9523fb 100644 --- a/aws/sdk/integration-tests/s3/tests/request_id.rs +++ b/aws/sdk/integration-tests/s3/tests/request_id.rs @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_s3::error::GetObjectError; -use aws_sdk_s3::operation::{GetObject, ListBuckets}; -use aws_sdk_s3::types::{RequestId, RequestIdExt}; +use aws_sdk_s3::operation::get_object::{GetObject, GetObjectError}; +use aws_sdk_s3::operation::list_buckets::ListBuckets; +use aws_sdk_s3::operation::{RequestId, RequestIdExt}; use aws_smithy_http::body::SdkBody; use aws_smithy_http::operation; use aws_smithy_http::response::ParseHttpResponse; diff --git a/aws/sdk/integration-tests/s3/tests/required-query-params.rs b/aws/sdk/integration-tests/s3/tests/required-query-params.rs index 05124af0a..7cf6238da 100644 --- a/aws/sdk/integration-tests/s3/tests/required-query-params.rs +++ b/aws/sdk/integration-tests/s3/tests/required-query-params.rs @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_s3::operation::AbortMultipartUpload; -use aws_sdk_s3::Region; +use aws_sdk_s3::config::Region; +use aws_sdk_s3::operation::abort_multipart_upload::AbortMultipartUploadInput; use aws_smithy_http::operation::error::BuildError; #[tokio::test] @@ -13,7 +13,7 @@ async fn test_error_when_required_query_param_is_unset() { .region(Region::new("us-east-1")) .build(); - let err = AbortMultipartUpload::builder() + let err = AbortMultipartUploadInput::builder() .bucket("test-bucket") .key("test.txt") .build() @@ -33,7 +33,7 @@ async fn test_error_when_required_query_param_is_set_but_empty() { let conf = aws_sdk_s3::Config::builder() .region(Region::new("us-east-1")) .build(); - let err = AbortMultipartUpload::builder() + let err = AbortMultipartUploadInput::builder() .bucket("test-bucket") .key("test.txt") .upload_id("") diff --git a/aws/sdk/integration-tests/s3/tests/select-object-content.rs b/aws/sdk/integration-tests/s3/tests/select-object-content.rs index d68af2f68..eb4d7a055 100644 --- a/aws/sdk/integration-tests/s3/tests/select-object-content.rs +++ b/aws/sdk/integration-tests/s3/tests/select-object-content.rs @@ -5,11 +5,12 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::model::{ +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::types::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, SelectObjectContentEventStream, }; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::dvr::{Event, ReplayingConnection}; use aws_smithy_protocol_test::{assert_ok, validate_body, MediaType}; use std::error::Error; diff --git a/aws/sdk/integration-tests/s3/tests/signing-it.rs b/aws/sdk/integration-tests/s3/tests/signing-it.rs index 0efdc9a5f..6e20e187e 100644 --- a/aws/sdk/integration-tests/s3/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3/tests/signing-it.rs @@ -6,7 +6,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; use std::convert::Infallible; diff --git a/aws/sdk/integration-tests/s3/tests/size-type.rs b/aws/sdk/integration-tests/s3/tests/size-type.rs index 986daaaaf..d790b0a62 100644 --- a/aws/sdk/integration-tests/s3/tests/size-type.rs +++ b/aws/sdk/integration-tests/s3/tests/size-type.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_s3::model::Object; +use aws_sdk_s3::types::Object; // Tests that `com.amazonaws.s3#Size` is correctly customized to be a long instead of an int. #[test] diff --git a/aws/sdk/integration-tests/s3/tests/streaming-response.rs b/aws/sdk/integration-tests/s3/tests/streaming-response.rs index 8ff6d6eb3..50acb13b3 100644 --- a/aws/sdk/integration-tests/s3/tests/streaming-response.rs +++ b/aws/sdk/integration-tests/s3/tests/streaming-response.rs @@ -5,8 +5,9 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::{Client, Credentials, Region}; -use aws_smithy_types::error::display::DisplayErrorContext; +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::error::DisplayErrorContext; +use aws_sdk_s3::Client; use bytes::BytesMut; use std::future::Future; use std::net::SocketAddr; diff --git a/aws/sdk/integration-tests/s3/tests/timeouts.rs b/aws/sdk/integration-tests/s3/tests/timeouts.rs index 5d1cacc5a..e4d28b72f 100644 --- a/aws/sdk/integration-tests/s3/tests/timeouts.rs +++ b/aws/sdk/integration-tests/s3/tests/timeouts.rs @@ -5,11 +5,12 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::model::{ +use aws_sdk_s3::config::{Credentials, Region}; +use aws_sdk_s3::types::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, }; -use aws_sdk_s3::{Client, Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_async::assert_elapsed; use aws_smithy_async::rt::sleep::{default_async_sleep, TokioSleep}; use aws_smithy_client::never::NeverConnector; diff --git a/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs b/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs index 8d72c5287..2dfea8d37 100644 --- a/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs +++ b/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs @@ -5,7 +5,8 @@ use aws_config::SdkConfig; use aws_credential_types::provider::SharedCredentialsProvider; -use aws_sdk_s3::{AppName, Client, Credentials, Region}; +use aws_sdk_s3::config::{AppName, Credentials, Region}; +use aws_sdk_s3::Client; use aws_smithy_client::test_connection::capture_request; #[tokio::test] diff --git a/aws/sdk/integration-tests/s3control/tests/signing-it.rs b/aws/sdk/integration-tests/s3control/tests/signing-it.rs index 4a9857b17..f5c583bbc 100644 --- a/aws/sdk/integration-tests/s3control/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3control/tests/signing-it.rs @@ -5,7 +5,8 @@ use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; -use aws_sdk_s3control::{Client, Credentials, Region}; +use aws_sdk_s3control::config::{Credentials, Region}; +use aws_sdk_s3control::Client; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; use aws_types::SdkConfig; diff --git a/aws/sdk/integration-tests/sts/tests/retry_idp_comms_err.rs b/aws/sdk/integration-tests/sts/tests/retry_idp_comms_err.rs index 3b546bbb0..524278571 100644 --- a/aws/sdk/integration-tests/sts/tests/retry_idp_comms_err.rs +++ b/aws/sdk/integration-tests/sts/tests/retry_idp_comms_err.rs @@ -6,7 +6,8 @@ use aws_sdk_sts as sts; use aws_smithy_types::error::ErrorMetadata; use aws_smithy_types::retry::{ErrorKind, ProvideErrorKind}; -use sts::error::{AssumeRoleWithWebIdentityError, IdpCommunicationErrorException}; +use sts::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError; +use sts::types::error::IdpCommunicationErrorException; #[tokio::test] async fn idp_comms_err_retryable() { diff --git a/aws/sdk/integration-tests/sts/tests/signing-it.rs b/aws/sdk/integration-tests/sts/tests/signing-it.rs index 12c4d7808..f2c80bd9f 100644 --- a/aws/sdk/integration-tests/sts/tests/signing-it.rs +++ b/aws/sdk/integration-tests/sts/tests/signing-it.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_sdk_sts::{Credentials, Region}; +use aws_sdk_sts::config::{Credentials, Region}; use aws_smithy_client::test_connection::capture_request; #[tokio::test] diff --git a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs index fe6b02882..62654ebd8 100644 --- a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs +++ b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs @@ -4,13 +4,15 @@ */ use async_stream::stream; -use aws_sdk_transcribestreaming::error::{AudioStreamError, TranscriptResultStreamError}; -use aws_sdk_transcribestreaming::model::{ +use aws_sdk_transcribestreaming::config::{Credentials, Region}; +use aws_sdk_transcribestreaming::error::SdkError; +use aws_sdk_transcribestreaming::operation::start_stream_transcription::StartStreamTranscriptionOutput; +use aws_sdk_transcribestreaming::primitives::Blob; +use aws_sdk_transcribestreaming::types::error::{AudioStreamError, TranscriptResultStreamError}; +use aws_sdk_transcribestreaming::types::{ AudioEvent, AudioStream, LanguageCode, MediaEncoding, TranscriptResultStream, }; -use aws_sdk_transcribestreaming::output::StartStreamTranscriptionOutput; -use aws_sdk_transcribestreaming::types::{Blob, SdkError}; -use aws_sdk_transcribestreaming::{Client, Config, Credentials, Region}; +use aws_sdk_transcribestreaming::{Client, Config}; use aws_smithy_client::dvr::{Event, ReplayingConnection}; use aws_smithy_eventstream::frame::{DecodedFrame, HeaderValue, Message, MessageFrameDecoder}; use bytes::BufMut; diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenVisitor.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenVisitor.kt index 6629b480a..5a97b1ede 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenVisitor.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientCodegenVisitor.kt @@ -312,7 +312,7 @@ class ClientCodegenVisitor( UnionGenerator(model, symbolProvider, this, shape, renderUnknownVariant = true).render() } if (shape.isEventStream()) { - rustCrate.withModule(ClientRustModule.Error) { + rustCrate.withModule(symbolProvider.moduleForEventStreamError(shape)) { OperationErrorGenerator( model, symbolProvider, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt index 0f610a42c..a89aabb68 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt @@ -136,12 +136,13 @@ class ClientModuleDocProvider( private fun customizeModuleDoc(): Writable = writable { val model = codegenContext.model docs("Operation customization and supporting types.\n") - if (model.operationShapes.isNotEmpty()) { + if (codegenContext.serviceShape.operations.isNotEmpty()) { val opFnName = FluentClientGenerator.clientOperationFnName( codegenContext.serviceShape.operations.minOf { it } .let { model.expectShape(it, OperationShape::class.java) }, codegenContext.symbolProvider, ) + val moduleUseName = codegenContext.moduleUseName() docsTemplate( """ The underlying HTTP requests made during an operation can be customized @@ -149,8 +150,8 @@ class ClientModuleDocProvider( operation call. For example, this can be used to add an additional HTTP header: ```no_run - ## async fn wrapper() -> Result<(), crate::Error> { - ## let client: crate::Client = unimplemented!(); + ## async fn wrapper() -> Result<(), $moduleUseName::Error> { + ## let client: $moduleUseName::Client = unimplemented!(); use #{http}::header::{HeaderName, HeaderValue}; let result = client.$opFnName() @@ -196,7 +197,7 @@ object ClientModuleProvider : ModuleProvider { override fun moduleForEventStreamError( context: ModuleProviderContext, eventStream: UnionShape, - ): RustModule.LeafModule = ClientRustModule.Error + ): RustModule.LeafModule = ClientRustModule.Types.Error override fun moduleForBuilder(context: ModuleProviderContext, shape: Shape, symbol: Symbol): RustModule.LeafModule = RustModule.public("builders", parent = symbol.module(), documentationOverride = "Builders") diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/OperationErrorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/OperationErrorGenerator.kt index d9ef055a3..52894539e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/OperationErrorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/OperationErrorGenerator.kt @@ -50,7 +50,6 @@ class OperationErrorGenerator( private val customizations: List, ) { private val runtimeConfig = symbolProvider.config.runtimeConfig - private val symbol = symbolProvider.toSymbol(operationOrEventStream) private val errorMetadata = errorMetadata(symbolProvider.config.runtimeConfig) private val createUnhandledError = RuntimeType.smithyHttp(runtimeConfig).resolve("result::CreateUnhandledError") diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt index 31b1fb64a..8cd5fd933 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt @@ -86,7 +86,8 @@ open class ClientProtocolGenerator( Attribute.DocHidden.render(operationWriter) operationWriter.rust("pub struct $operationName;") operationWriter.implBlock(symbolProvider.toSymbol(operationShape)) { - rustBlock("pub(crate) fn new() -> Self") { + Attribute.DocHidden.render(operationWriter) + rustBlock("pub fn new() -> Self") { rust("Self") } diff --git a/tools/ci-cdk/canary-lambda/src/canary.rs b/tools/ci-cdk/canary-lambda/src/canary.rs index 9158b4751..a7d497b52 100644 --- a/tools/ci-cdk/canary-lambda/src/canary.rs +++ b/tools/ci-cdk/canary-lambda/src/canary.rs @@ -11,8 +11,8 @@ use std::pin::Pin; use aws_config::SdkConfig; use tracing::{info_span, Instrument}; -use crate::paginator_canary; -use crate::{s3_canary, transcribe_canary}; +use crate::current_canary::paginator_canary; +use crate::current_canary::{s3_canary, transcribe_canary}; #[macro_export] macro_rules! mk_canary { diff --git a/tools/ci-cdk/canary-lambda/src/latest.rs b/tools/ci-cdk/canary-lambda/src/latest.rs new file mode 100644 index 000000000..238c36116 --- /dev/null +++ b/tools/ci-cdk/canary-lambda/src/latest.rs @@ -0,0 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +pub(crate) mod paginator_canary; +pub(crate) mod s3_canary; +pub(crate) mod transcribe_canary; diff --git a/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs b/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs new file mode 100644 index 000000000..291f71798 --- /dev/null +++ b/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs @@ -0,0 +1,71 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +use crate::mk_canary; +use anyhow::bail; + +use aws_sdk_ec2 as ec2; +use aws_sdk_ec2::types::InstanceType; + +use crate::CanaryEnv; +use tokio_stream::StreamExt; + +mk_canary!( + "ec2_paginator", + |sdk_config: &aws_config::SdkConfig, env: &CanaryEnv| { + paginator_canary(ec2::Client::new(sdk_config), env.page_size) + } +); + +pub async fn paginator_canary(client: ec2::Client, page_size: usize) -> anyhow::Result<()> { + let mut history = client + .describe_spot_price_history() + .instance_types(InstanceType::M1Medium) + .into_paginator() + .page_size(page_size as i32) + .send(); + + let mut num_pages = 0; + while let Some(page) = history.try_next().await? { + let items_in_page = page.spot_price_history.unwrap_or_default().len(); + if items_in_page > page_size as usize { + bail!( + "failed to retrieve results of correct page size (expected {}, got {})", + page_size, + items_in_page + ) + } + num_pages += 1; + } + if dbg!(num_pages) < 2 { + bail!( + "expected 3+ pages containing ~60 results but got {} pages", + num_pages + ) + } + + // https://github.com/awslabs/aws-sdk-rust/issues/405 + let _ = client + .describe_vpcs() + .into_paginator() + .items() + .send() + .collect::, _>>() + .await?; + + Ok(()) +} + +#[cfg(test)] +mod test { + use crate::paginator_canary::paginator_canary; + + #[tokio::test] + async fn test_paginator() { + let conf = aws_config::load_from_env().await; + let client = aws_sdk_ec2::Client::new(&conf); + paginator_canary(client, 20).await.unwrap() + } +} diff --git a/tools/ci-cdk/canary-lambda/src/latest/s3_canary.rs b/tools/ci-cdk/canary-lambda/src/latest/s3_canary.rs new file mode 100644 index 000000000..fbcba976d --- /dev/null +++ b/tools/ci-cdk/canary-lambda/src/latest/s3_canary.rs @@ -0,0 +1,140 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +use crate::canary::CanaryError; +use crate::{mk_canary, CanaryEnv}; +use anyhow::Context; +use aws_config::SdkConfig; +use aws_sdk_s3 as s3; +use s3::presigning::PresigningConfig; +use s3::primitives::ByteStream; +use std::time::Duration; +use uuid::Uuid; + +const METADATA_TEST_VALUE: &str = "some value"; + +mk_canary!("s3", |sdk_config: &SdkConfig, env: &CanaryEnv| s3_canary( + s3::Client::new(sdk_config), + env.s3_bucket_name.clone() +)); + +pub async fn s3_canary(client: s3::Client, s3_bucket_name: String) -> anyhow::Result<()> { + let test_key = Uuid::new_v4().as_u128().to_string(); + + // Look for the test object and expect that it doesn't exist + match client + .get_object() + .bucket(&s3_bucket_name) + .key(&test_key) + .send() + .await + { + Ok(_) => { + return Err( + CanaryError(format!("Expected object {} to not exist in S3", test_key)).into(), + ); + } + Err(err) => { + let err = err.into_service_error(); + // If we get anything other than "No such key", we have a problem + if !err.is_no_such_key() { + return Err(err).context("unexpected s3::GetObject failure"); + } + } + } + + // Put the test object + client + .put_object() + .bucket(&s3_bucket_name) + .key(&test_key) + .body(ByteStream::from_static(b"test")) + .metadata("something", METADATA_TEST_VALUE) + .send() + .await + .context("s3::PutObject")?; + + // Get the test object and verify it looks correct + let output = client + .get_object() + .bucket(&s3_bucket_name) + .key(&test_key) + .send() + .await + .context("s3::GetObject[2]")?; + + // repeat the test with a presigned url + let uri = client + .get_object() + .bucket(&s3_bucket_name) + .key(&test_key) + .presigned(PresigningConfig::expires_in(Duration::from_secs(120)).unwrap()) + .await + .unwrap(); + let response = reqwest::get(uri.uri().to_string()) + .await + .context("s3::presigned")? + .text() + .await?; + if response != "test" { + return Err(CanaryError(format!("presigned URL returned bad data: {:?}", response)).into()); + } + + let mut result = Ok(()); + match output.metadata() { + Some(map) => { + // Option::as_deref doesn't work here since the deref of &String is String + let value = map.get("something").map(|s| s.as_str()).unwrap_or(""); + if value != METADATA_TEST_VALUE { + result = Err(CanaryError(format!( + "S3 metadata was incorrect. Expected `{}` but got `{}`.", + METADATA_TEST_VALUE, value + )) + .into()); + } + } + None => { + result = Err(CanaryError("S3 metadata was missing".into()).into()); + } + } + + let payload = output + .body + .collect() + .await + .context("download s3::GetObject[2] body")? + .into_bytes(); + if std::str::from_utf8(payload.as_ref()).context("s3 payload")? != "test" { + result = Err(CanaryError("S3 object body didn't match what was put there".into()).into()); + } + + // Delete the test object + client + .delete_object() + .bucket(&s3_bucket_name) + .key(&test_key) + .send() + .await + .context("s3::DeleteObject")?; + + result +} + +// This test runs against an actual AWS account. Comment out the `ignore` to run it. +// Be sure to set the `TEST_S3_BUCKET` environment variable to the S3 bucket to use, +// and also make sure the credential profile sets the region (or set `AWS_DEFAULT_PROFILE`). +#[ignore] +#[cfg(test)] +#[tokio::test] +async fn test_s3_canary() { + let config = aws_config::load_from_env().await; + let client = s3::Client::new(&config); + s3_canary( + client, + std::env::var("TEST_S3_BUCKET").expect("TEST_S3_BUCKET must be set"), + ) + .await + .expect("success"); +} diff --git a/tools/ci-cdk/canary-lambda/src/latest/transcribe_canary.rs b/tools/ci-cdk/canary-lambda/src/latest/transcribe_canary.rs new file mode 100644 index 000000000..8f6420fc1 --- /dev/null +++ b/tools/ci-cdk/canary-lambda/src/latest/transcribe_canary.rs @@ -0,0 +1,92 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +use crate::canary::CanaryError; +use crate::mk_canary; +use async_stream::stream; +use aws_config::SdkConfig; +use aws_sdk_transcribestreaming as transcribe; +use bytes::BufMut; +use transcribe::primitives::Blob; +use transcribe::types::{ + AudioEvent, AudioStream, LanguageCode, MediaEncoding, TranscriptResultStream, +}; + +const CHUNK_SIZE: usize = 8192; +use crate::canary::CanaryEnv; + +mk_canary!( + "transcribe_canary", + |sdk_config: &SdkConfig, env: &CanaryEnv| { + transcribe_canary( + transcribe::Client::new(sdk_config), + env.expected_transcribe_result.clone(), + ) + } +); + +pub async fn transcribe_canary( + client: transcribe::Client, + expected_transcribe_result: String, +) -> anyhow::Result<()> { + let input_stream = stream! { + let pcm = pcm_data(); + for chunk in pcm.chunks(CHUNK_SIZE) { + yield Ok(AudioStream::AudioEvent(AudioEvent::builder().audio_chunk(Blob::new(chunk)).build())); + } + }; + + let mut output = client + .start_stream_transcription() + .language_code(LanguageCode::EnGb) + .media_sample_rate_hertz(8000) + .media_encoding(MediaEncoding::Pcm) + .audio_stream(input_stream.into()) + .send() + .await?; + + let mut full_message = String::new(); + while let Some(event) = output.transcript_result_stream.recv().await? { + match event { + TranscriptResultStream::TranscriptEvent(transcript_event) => { + let transcript = transcript_event.transcript.unwrap(); + for result in transcript.results.unwrap_or_default() { + if !result.is_partial { + let first_alternative = &result.alternatives.as_ref().unwrap()[0]; + full_message += first_alternative.transcript.as_ref().unwrap(); + full_message.push(' '); + } + } + } + otherwise => panic!("received unexpected event type: {:?}", otherwise), + } + } + + if expected_transcribe_result != full_message.trim() { + Err(CanaryError(format!( + "Transcription from Transcribe doesn't look right:\n\ + Expected: `{}`\n\ + Actual: `{}`\n", + expected_transcribe_result, + full_message.trim() + )) + .into()) + } else { + Ok(()) + } +} + +fn pcm_data() -> Vec { + let reader = + hound::WavReader::new(&include_bytes!("../../audio/hello-transcribe-8000.wav")[..]) + .expect("valid wav data"); + let samples_result: hound::Result> = reader.into_samples::().collect(); + + let mut pcm: Vec = Vec::new(); + for sample in samples_result.unwrap() { + pcm.put_i16_le(sample); + } + pcm +} diff --git a/tools/ci-cdk/canary-lambda/src/main.rs b/tools/ci-cdk/canary-lambda/src/main.rs index 3bb723c80..688462031 100644 --- a/tools/ci-cdk/canary-lambda/src/main.rs +++ b/tools/ci-cdk/canary-lambda/src/main.rs @@ -19,35 +19,18 @@ use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::EnvFilter; use tracing_texray::TeXRayLayer; -/// Conditionally include the module based on the $version feature gate -/// -/// When the module is not included, an `mk_canary` function will be generated that returns `None`. -macro_rules! canary_module { - ($name: ident, since: $version: expr) => { - #[cfg(feature = $version)] - mod $name; - - #[cfg(not(feature = $version))] - mod $name { - pub(crate) fn mk_canary( - _clients: &aws_config::SdkConfig, - _env: &crate::canary::CanaryEnv, - ) -> Option<(&'static str, crate::canary::CanaryFuture)> { - tracing::warn!(concat!( - stringify!($name), - " is disabled because it is not supported by this version of the SDK." - )); - None - } - } - }; -} - mod canary; -mod s3_canary; -canary_module!(paginator_canary, since: "v0.4.1"); -mod transcribe_canary; +#[cfg(feature = "latest")] +mod latest; +#[cfg(feature = "latest")] +pub(crate) use latest as current_canary; + +// NOTE: This module can be deleted 3 releases after release-2023-01-26 +#[cfg(feature = "release-2023-01-26")] +mod release_2023_01_26; +#[cfg(feature = "release-2023-01-26")] +pub(crate) use release_2023_01_26 as current_canary; #[tokio::main] async fn main() -> Result<(), Error> { diff --git a/tools/ci-cdk/canary-lambda/src/release_2023_01_26.rs b/tools/ci-cdk/canary-lambda/src/release_2023_01_26.rs new file mode 100644 index 000000000..238c36116 --- /dev/null +++ b/tools/ci-cdk/canary-lambda/src/release_2023_01_26.rs @@ -0,0 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +pub(crate) mod paginator_canary; +pub(crate) mod s3_canary; +pub(crate) mod transcribe_canary; diff --git a/tools/ci-cdk/canary-lambda/src/paginator_canary.rs b/tools/ci-cdk/canary-lambda/src/release_2023_01_26/paginator_canary.rs similarity index 100% rename from tools/ci-cdk/canary-lambda/src/paginator_canary.rs rename to tools/ci-cdk/canary-lambda/src/release_2023_01_26/paginator_canary.rs diff --git a/tools/ci-cdk/canary-lambda/src/s3_canary.rs b/tools/ci-cdk/canary-lambda/src/release_2023_01_26/s3_canary.rs similarity index 100% rename from tools/ci-cdk/canary-lambda/src/s3_canary.rs rename to tools/ci-cdk/canary-lambda/src/release_2023_01_26/s3_canary.rs diff --git a/tools/ci-cdk/canary-lambda/src/transcribe_canary.rs b/tools/ci-cdk/canary-lambda/src/release_2023_01_26/transcribe_canary.rs similarity index 94% rename from tools/ci-cdk/canary-lambda/src/transcribe_canary.rs rename to tools/ci-cdk/canary-lambda/src/release_2023_01_26/transcribe_canary.rs index c0e2db2fd..554f4c3dd 100644 --- a/tools/ci-cdk/canary-lambda/src/transcribe_canary.rs +++ b/tools/ci-cdk/canary-lambda/src/release_2023_01_26/transcribe_canary.rs @@ -79,8 +79,9 @@ pub async fn transcribe_canary( } fn pcm_data() -> Vec { - let reader = hound::WavReader::new(&include_bytes!("../audio/hello-transcribe-8000.wav")[..]) - .expect("valid wav data"); + let reader = + hound::WavReader::new(&include_bytes!("../../audio/hello-transcribe-8000.wav")[..]) + .expect("valid wav data"); let samples_result: hound::Result> = reader.into_samples::().collect(); let mut pcm: Vec = Vec::new(); diff --git a/tools/ci-cdk/canary-runner/additional-ci b/tools/ci-cdk/canary-runner/additional-ci deleted file mode 100755 index 14e8002b8..000000000 --- a/tools/ci-cdk/canary-runner/additional-ci +++ /dev/null @@ -1,5 +0,0 @@ -# run build-bundle on musl to verify that everything works -cargo run -- build-bundle \ - --sdk-release-tag release-2022-12-14 \ - --canary-path ../canary-lambda \ - --rust-version stable --musl diff --git a/tools/ci-cdk/canary-runner/src/build_bundle.rs b/tools/ci-cdk/canary-runner/src/build_bundle.rs index 1f0c4a3f9..0d214f4d8 100644 --- a/tools/ci-cdk/canary-runner/src/build_bundle.rs +++ b/tools/ci-cdk/canary-runner/src/build_bundle.rs @@ -65,7 +65,7 @@ const REQUIRED_SDK_CRATES: &[&str] = &[ lazy_static! { static ref NOTABLE_SDK_RELEASE_TAGS: Vec = vec![ - ReleaseTag::from_str("v0.4.1").unwrap(), // first version to add support for paginators + ReleaseTag::from_str("release-2023-01-26").unwrap(), // last version before the crate reorg ]; } @@ -116,11 +116,14 @@ fn enabled_features(crate_source: &CrateSource) -> Vec { let mut enabled = Vec::new(); if let CrateSource::VersionsManifest { release_tag, .. } = crate_source { for notable in NOTABLE_SDK_RELEASE_TAGS.iter() { - if notable < release_tag { + if notable <= release_tag { enabled.push(notable.as_str().into()); } } } + if enabled.is_empty() { + enabled.push("latest".into()); + } enabled } @@ -158,11 +161,12 @@ fn generate_crate_manifest(crate_source: CrateSource) -> Result { } } write!(output, "\n[features]\n").unwrap(); + writeln!(output, "latest = []").unwrap(); for release_tag in NOTABLE_SDK_RELEASE_TAGS.iter() { writeln!( output, "\"{release_tag}\" = []", - release_tag = release_tag.as_str().replace('-', "_") + release_tag = release_tag.as_str() ) .unwrap(); } @@ -436,8 +440,9 @@ aws-sdk-ec2 = { path = "some/sdk/path/ec2" } aws-sdk-transcribestreaming = { path = "some/sdk/path/transcribestreaming" } [features] -"v0.4.1" = [] -default = [] +latest = [] +"release-2023-01-26" = [] +default = ["latest"] "#, generate_crate_manifest(CrateSource::Path("some/sdk/path".into())).expect("success") ); @@ -499,8 +504,9 @@ aws-sdk-ec2 = "0.19.0" aws-sdk-transcribestreaming = "0.16.0" [features] -"v0.4.1" = [] -default = ["v0.4.1"] +latest = [] +"release-2023-01-26" = [] +default = ["release-2023-01-26"] "#, generate_crate_manifest(CrateSource::VersionsManifest { versions: VersionsManifest { @@ -517,7 +523,7 @@ default = ["v0.4.1"] .collect(), release: None, }, - release_tag: ReleaseTag::from_str("release-2022-07-26").unwrap(), + release_tag: ReleaseTag::from_str("release-2023-05-26").unwrap(), }) .expect("success") ); diff --git a/tools/ci-scripts/check-aws-sdk-canary b/tools/ci-scripts/check-aws-sdk-canary index fbeb310e0..73ce35f04 100755 --- a/tools/ci-scripts/check-aws-sdk-canary +++ b/tools/ci-scripts/check-aws-sdk-canary @@ -20,10 +20,11 @@ pushd tools/ci-cdk/canary-lambda # The canary-lambda doesn't have a Cargo.toml in a fresh checkout of smithy-rs, so generate one before checks pushd ../canary-runner echo "${C_YELLOW}## Generating Cargo.toml for the canary-lambda...${C_RESET}" -cargo run -- build-bundle --manifest-only --canary-path ../canary-lambda --sdk-path "${SDK_PATH}" +cargo run -- build-bundle --manifest-only --canary-path ../canary-lambda --sdk-path "${SDK_PATH}" --musl popd +# Note: This only checks the `latest` canary, and not any previous version features echo "${C_YELLOW}## Running 'cargo clippy' for the canary-lambda...${C_RESET}" -cargo clippy --all-features +cargo clippy popd -- GitLab