Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export HttpRequest and HttpResponse in client crates #3762

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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"
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
""",
)
}
}
}
}