From 23687c8f9199047d3a289e3b53524bb70583087c Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 15 Jul 2024 15:54:59 -0500 Subject: [PATCH 1/4] Re-export `HttpRequest`, `HttpResponse` from smithy runtime --- .../codegen/client/smithy/ClientRustModule.kt | 10 ++- .../ClientRuntimeTypesReExportGenerator.kt | 10 +++ ...ClientRuntimeTypesReExportGeneratorTest.kt | 68 +++++++++++++++++++ 3 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGeneratorTest.kt 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 ccd21edc6e..64197ddc7e 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 @@ -68,14 +68,17 @@ object ClientRustModule { /** crate::config::endpoint */ val endpoint = RustModule.public("endpoint", parent = self) + /** crate::config::http */ + val http = RustModule.public("http", parent = self) + + /** crate::config::interceptors */ + val interceptors = RustModule.public("interceptors", parent = self) + /** crate::config::retry */ val retry = RustModule.public("retry", parent = self) /** crate::config::timeout */ val timeout = RustModule.public("timeout", parent = self) - - /** crate::config::interceptors */ - val interceptors = RustModule.public("interceptors", parent = self) } val Error = RustModule.public("error") @@ -122,6 +125,7 @@ class ClientModuleDocProvider( ClientRustModule.Config.endpoint -> strDoc("Types needed to configure endpoint resolution.") ClientRustModule.Config.retry -> strDoc("Retry configuration.") ClientRustModule.Config.timeout -> strDoc("Timeout configuration.") + ClientRustModule.Config.http -> strDoc("HTTP request and response types.") ClientRustModule.Config.interceptors -> strDoc("Types needed to implement [`Intercept`](crate::config::Intercept).") ClientRustModule.Error -> strDoc("Common errors and error handling utilities.") ClientRustModule.Operation -> strDoc("All operations that this crate can perform.") diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGenerator.kt index 0951ce1d71..70681ebcaf 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGenerator.kt @@ -56,6 +56,16 @@ class ClientRuntimeTypesReExportGenerator( "ShouldAttempt" to smithyRuntimeApi.resolve("client::retries::ShouldAttempt"), ) } + rustCrate.withModule(ClientRustModule.Config.http) { + rustTemplate( + """ + pub use #{HttpRequest}; + pub use #{HttpResponse}; + """, + "HttpRequest" to smithyRuntimeApi.resolve("client::orchestrator::HttpRequest"), + "HttpResponse" to smithyRuntimeApi.resolve("client::orchestrator::HttpResponse"), + ) + } rustCrate.withModule(ClientRustModule.Config.interceptors) { rustTemplate( """ diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGeneratorTest.kt new file mode 100644 index 0000000000..3280683b3f --- /dev/null +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientRuntimeTypesReExportGeneratorTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.client.smithy.generators + +import org.junit.jupiter.api.Test +import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel +import software.amazon.smithy.rust.codegen.core.testutil.unitTest + +class ClientRuntimeTypesReExportGeneratorTest { + private val model = + """ + namespace test + use aws.protocols#awsJson1_0 + + @awsJson1_0 + service HelloService { + operations: [], + version: "1" + } + """.asSmithyModel() + + @Test + fun `it should reexport client runtime types`() { + clientIntegrationTest(model) { _, crate -> + crate.unitTest { + rust( + """ + ##[allow(unused_imports)] + { + use crate::config::ConfigBag; + use crate::config::RuntimeComponents; + use crate::config::IdentityCache; + + use crate::config::endpoint::SharedEndpointResolver; + use crate::config::endpoint::EndpointFuture; + use crate::config::endpoint::Endpoint; + + use crate::config::retry::ClassifyRetry; + use crate::config::retry::RetryAction; + use crate::config::retry::ShouldAttempt; + + use crate::config::http::HttpRequest; + use crate::config::http::HttpResponse; + + use crate::config::interceptors::AfterDeserializationInterceptorContextRef; + use crate::config::interceptors::BeforeDeserializationInterceptorContextMut; + use crate::config::interceptors::BeforeDeserializationInterceptorContextRef; + use crate::config::interceptors::BeforeSerializationInterceptorContextMut; + use crate::config::interceptors::BeforeSerializationInterceptorContextRef; + use crate::config::interceptors::BeforeTransmitInterceptorContextMut; + use crate::config::interceptors::BeforeTransmitInterceptorContextRef; + use crate::config::interceptors::FinalizerInterceptorContextMut; + use crate::config::interceptors::FinalizerInterceptorContextRef; + use crate::config::interceptors::InterceptorContext; + + use crate::error::BoxError; + } + """, + ) + } + } + } +} From 2b3c8ef9169d4016f842b89a01ed87e2ece2efb2 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 15 Jul 2024 16:03:50 -0500 Subject: [PATCH 2/4] Update CHANGELOG.next.toml --- CHANGELOG.next.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 39b4f1c678..f62f791a8d 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -22,3 +22,15 @@ message = "Add support for `operationContextParams` Endpoints trait" references = ["smithy-rs#3755"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"} author = "landonxjames" + +[[aws-sdk-rust]] +message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported AWS SDK clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." +references = ["smithy-rs#3591"] +meta = { "breaking" = false, "tada" = false, "bug" = false } +author = "ysaito1001" + +[[smithy-rs]] +message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in generated clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." +references = ["smithy-rs#3591"] +meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } +author = "ysaito1001" From a6c87d4c8056d8fcbd655dce31cba0817289273f Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 15 Jul 2024 16:13:06 -0500 Subject: [PATCH 3/4] Fix missing `in` in the changelog --- CHANGELOG.next.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index f62f791a8d..1d739ec1a0 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -24,7 +24,7 @@ meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"} author = "landonxjames" [[aws-sdk-rust]] -message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported AWS SDK clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." +message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in AWS SDK clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." references = ["smithy-rs#3591"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "ysaito1001" From ee42b69b29070f6c59821a431617af0f23494e93 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 15 Jul 2024 16:14:10 -0500 Subject: [PATCH 4/4] Fix more typos in the changelog --- CHANGELOG.next.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 1d739ec1a0..a168393287 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -24,13 +24,13 @@ meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"} author = "landonxjames" [[aws-sdk-rust]] -message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in AWS SDK clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." +message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in AWS SDK clients so that using these types does not require directly depending on `aws-smithy-runtime-api`." references = ["smithy-rs#3591"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "ysaito1001" [[smithy-rs]] -message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in generated clients so that using these types doen not require directly depending on `aws-smithy-runtime-api`." +message = "`aws_smithy_runtime_api::client::orchestrator::HttpRequest` and `aws_smithy_runtime_api::client::orchestrator::HttpResponse` are now re-exported in generated clients so that using these types does not require directly depending on `aws-smithy-runtime-api`." references = ["smithy-rs#3591"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } author = "ysaito1001"