diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index 2a558daf0..cf8b107a0 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -104,7 +104,7 @@ class AwsFluentClientDecorator : ClientCodegenDecorator { baseGenerator.operationShape, renderClientCreation = { params -> rust("let mut ${params.configBuilderName} = ${params.configBuilderName};") - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { // TODO(enableNewSmithyRuntimeLaunch): A builder field could not be accessed directly in the orchestrator // mode when this code change was made. smithy-rs#2792 will enable us to use getters in builders. // Make this `set_region` conditional by checking if `config_builder.region().is_none()` once the PR diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt index fc1833688..522b791fa 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt @@ -286,13 +286,13 @@ class AwsPresignedFluentBuilderMethod( """, *codegenScope, "OpError" to section.operationErrorType, - "RawResponseType" to if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + "RawResponseType" to if (codegenContext.smithyRuntimeMode.generateMiddleware) { RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response") } else { RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") }, ) { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { renderPresignedMethodBodyMiddleware() } else { renderPresignedMethodBody(section) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt index 4f826ef35..c25001cb3 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt @@ -66,7 +66,7 @@ class CredentialCacheConfig(codegenContext: ClientCodegenContext) : ConfigCustom override fun section(section: ServiceConfig) = writable { when (section) { ServiceConfig.ConfigStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( """pub(crate) credentials_cache: #{SharedCredentialsCache},""", *codegenScope, @@ -75,7 +75,7 @@ class CredentialCacheConfig(codegenContext: ClientCodegenContext) : ConfigCustom } ServiceConfig.ConfigImpl -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns the credentials cache. @@ -99,7 +99,7 @@ class CredentialCacheConfig(codegenContext: ClientCodegenContext) : ConfigCustom } ServiceConfig.BuilderStruct -> - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("credentials_cache: #{Option}<#{CredentialsCache}>,", *codegenScope) } @@ -116,7 +116,7 @@ class CredentialCacheConfig(codegenContext: ClientCodegenContext) : ConfigCustom *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the credentials cache for this service @@ -142,7 +142,7 @@ class CredentialCacheConfig(codegenContext: ClientCodegenContext) : ConfigCustom } ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ if let Some(credentials_provider) = layer.load::<#{SharedCredentialsProvider}>().cloned() { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index 6be60295d..0437075d3 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -80,7 +80,7 @@ class CredentialProviderConfig(codegenContext: ClientCodegenContext) : ConfigCus override fun section(section: ServiceConfig) = writable { when (section) { ServiceConfig.BuilderStruct -> { - if (smithyRuntimeMode.defaultToMiddleware) { + if (smithyRuntimeMode.generateMiddleware) { rustTemplate("credentials_provider: #{Option}<#{SharedCredentialsProvider}>,", *codegenScope) } } @@ -96,7 +96,7 @@ class CredentialProviderConfig(codegenContext: ClientCodegenContext) : ConfigCus *codegenScope, ) - if (smithyRuntimeMode.defaultToOrchestrator) { + if (smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the credentials provider for this service diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt index 1d79f10a6..e59eaa7bc 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt @@ -141,7 +141,7 @@ fun decoratorForBuiltIn( override fun loadBuiltInFromServiceConfig(parameter: Parameter, configRef: String): Writable? = when (parameter.builtIn) { builtIn.builtIn -> writable { - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { val newtype = configParamNewtype(parameter, name, codegenContext.runtimeConfig) val symbol = parameter.symbol().mapRustType { t -> t.stripOuter() } rustTemplate( @@ -151,7 +151,7 @@ fun decoratorForBuiltIn( } else { rust("$configRef.$name") } - if (codegenContext.smithyRuntimeMode.defaultToMiddleware && parameter.type == ParameterType.STRING) { + if (codegenContext.smithyRuntimeMode.generateMiddleware && parameter.type == ParameterType.STRING) { rust(".clone()") } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt index 911ec7ea2..d2d653e1b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt @@ -26,7 +26,7 @@ class HttpConnectorDecorator : ClientCodegenDecorator { codegenContext: ClientCodegenContext, baseCustomizations: List, ): List = - baseCustomizations.letIf(codegenContext.smithyRuntimeMode.exclusivelyGenerateMiddleware) { + baseCustomizations.letIf(codegenContext.smithyRuntimeMode.generateMiddleware) { it + HttpConnectorConfigCustomization(codegenContext) } } @@ -45,12 +45,12 @@ class HttpConnectorConfigCustomization( override fun section(section: ServiceConfig): Writable { return when (section) { is ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("http_connector: Option<#{HttpConnector}>,", *codegenScope) } } is ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Return an [`HttpConnector`](#{HttpConnector}) to use when making requests, if any. @@ -73,7 +73,7 @@ class HttpConnectorConfigCustomization( } } is ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("http_connector: Option<#{HttpConnector}>,", *codegenScope) } } @@ -157,7 +157,7 @@ class HttpConnectorConfigCustomization( """, *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_http_connector(&mut self, http_connector: #{Option}>) -> &mut Self { @@ -180,7 +180,7 @@ class HttpConnectorConfigCustomization( } } is ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("http_connector: self.http_connector,") } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index 5c9a0669f..5dacc952b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -131,7 +131,7 @@ class RegionDecorator : ClientCodegenDecorator { override fun loadBuiltInFromServiceConfig(parameter: Parameter, configRef: String): Writable? { return when (parameter.builtIn) { Builtins.REGION.builtIn -> writable { - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { rustTemplate( "$configRef.load::<#{Region}>().map(|r|r.as_ref().to_owned())", "Region" to region(codegenContext.runtimeConfig).resolve("Region"), @@ -171,12 +171,12 @@ class RegionProviderConfig(codegenContext: ClientCodegenContext) : ConfigCustomi override fun section(section: ServiceConfig) = writable { when (section) { ServiceConfig.ConfigStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("pub(crate) region: #{Option}<#{Region}>,", *codegenScope) } } ServiceConfig.ConfigImpl -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns the AWS region, if it was provided. @@ -200,7 +200,7 @@ class RegionProviderConfig(codegenContext: ClientCodegenContext) : ConfigCustomi } ServiceConfig.BuilderStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("pub(crate) region: #{Option}<#{Region}>,", *codegenScope) } } @@ -227,7 +227,7 @@ class RegionProviderConfig(codegenContext: ClientCodegenContext) : ConfigCustomi *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the AWS region to use when making requests. @@ -253,7 +253,7 @@ class RegionProviderConfig(codegenContext: ClientCodegenContext) : ConfigCustomi } ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("region: self.region,") } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt index a34c89f6e..c7ba6f9c6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SigV4SigningDecorator.kt @@ -110,7 +110,7 @@ class SigV4SigningConfig( ) } ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ layer.store_put(#{SigningService}::from_static(${sigV4Trait.name.dq()})); diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt index 0ca5ce335..bd38c4f7e 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/UserAgentDecorator.kt @@ -154,7 +154,7 @@ class UserAgentDecorator : ClientCodegenDecorator { override fun section(section: ServiceConfig): Writable = when (section) { is ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("app_name: #{Option}<#{AppName}>,", *codegenScope) } } @@ -174,7 +174,7 @@ class UserAgentDecorator : ClientCodegenDecorator { *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the name of the app that is using the client. @@ -206,7 +206,7 @@ class UserAgentDecorator : ClientCodegenDecorator { } is ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rust("layer.store_put(#T.clone());", ClientRustModule.Meta.toType().resolve("API_METADATA")) } else { rust("app_name: self.app_name,") @@ -214,13 +214,13 @@ class UserAgentDecorator : ClientCodegenDecorator { } is ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("app_name: #{Option}<#{AppName}>,", *codegenScope) } } is ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns the name of the app that is using the client, if it was provided. diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/DisabledAuthDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/DisabledAuthDecorator.kt index 6cc7345df..98a37d778 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/DisabledAuthDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/DisabledAuthDecorator.kt @@ -39,7 +39,7 @@ class DisabledAuthDecorator() : ClientCodegenDecorator { val optionalOperations = optionalAuth[service.id]!! return ModelTransformer.create().mapShapes(model) { if (optionalOperations.contains(it.id) && it is OperationShape) { - if (settings.codegenConfig.enableNewSmithyRuntime.defaultToOrchestrator) { + if (settings.codegenConfig.enableNewSmithyRuntime.generateOrchestrator) { it.toBuilder().addTrait(OptionalAuthTrait()).build() } else { // In middleware, having an empty @auth trait completely disabled diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/timestream/TimestreamDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/timestream/TimestreamDecorator.kt index 44c7767bd..57c033421 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/timestream/TimestreamDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/timestream/TimestreamDecorator.kt @@ -33,7 +33,7 @@ class TimestreamDecorator : ClientCodegenDecorator { override val order: Byte = -1 private fun applies(codegenContext: ClientCodegenContext): Boolean = - codegenContext.smithyRuntimeMode.defaultToOrchestrator + codegenContext.smithyRuntimeMode.generateOrchestrator override fun extraSections(codegenContext: ClientCodegenContext): List = emptyList().letIf(applies(codegenContext)) { diff --git a/aws/sdk-codegen/src/test/kotlin/SdkCodegenIntegrationTest.kt b/aws/sdk-codegen/src/test/kotlin/SdkCodegenIntegrationTest.kt index 8ece4a5aa..02ae9071d 100644 --- a/aws/sdk-codegen/src/test/kotlin/SdkCodegenIntegrationTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/SdkCodegenIntegrationTest.kt @@ -50,7 +50,7 @@ class SdkCodegenIntegrationTest { fun smokeTestSdkCodegen() { awsSdkIntegrationTest( model, - defaultToOrchestrator = true, + generateOrchestrator = true, ) { _, _ -> /* it should compile */ } } @@ -58,7 +58,7 @@ class SdkCodegenIntegrationTest { fun smokeTestSdkCodegenMiddleware() { awsSdkIntegrationTest( model, - defaultToOrchestrator = false, + generateOrchestrator = false, ) { _, _ -> /* it should compile */ } } } diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt index 6d1d7f8ad..960d3adba 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt @@ -48,7 +48,7 @@ internal class CredentialCacheConfigTest { @Test fun `config override for credentials`() { - awsSdkIntegrationTest(model, defaultToOrchestrator = true) { clientCodegenContext, rustCrate -> + awsSdkIntegrationTest(model, generateOrchestrator = true) { clientCodegenContext, rustCrate -> val runtimeConfig = clientCodegenContext.runtimeConfig val codegenScope = arrayOf( *RuntimeType.preludeScope, 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 ca5deedba..5638aca83 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 @@ -37,10 +37,10 @@ fun awsTestCodegenContext(model: Model? = null, settings: ClientRustSettings? = settings = settings ?: testClientRustSettings(runtimeConfig = AwsTestRuntimeConfig), ) -// TODO(enableNewSmithyRuntimeCleanup): Remove defaultToOrchestrator once the runtime switches to the orchestrator +// TODO(enableNewSmithyRuntimeCleanup): Remove generateOrchestrator once the runtime switches to the orchestrator fun awsSdkIntegrationTest( model: Model, - defaultToOrchestrator: Boolean = true, + generateOrchestrator: Boolean = true, test: (ClientCodegenContext, RustCrate) -> Unit = { _, _ -> }, ) = clientIntegrationTest( @@ -62,7 +62,7 @@ fun awsSdkIntegrationTest( "codegen", ObjectNode.builder() .withMember("includeFluentClient", false) - .letIf(defaultToOrchestrator) { + .letIf(generateOrchestrator) { it.withMember("enableNewSmithyRuntime", StringNode.from("orchestrator")) } .build(), diff --git a/aws/sra-test/build.gradle.kts b/aws/sra-test/build.gradle.kts index 669f23174..a9bb7c328 100644 --- a/aws/sra-test/build.gradle.kts +++ b/aws/sra-test/build.gradle.kts @@ -65,8 +65,8 @@ val allCodegenTests = servicesToGenerate.map { , "codegen": { "includeFluentClient": false, - ${ ""/* "enableNewSmithyRuntime": "both_default_middleware" */ } - "enableNewSmithyRuntime": "orchestrator" + "enableNewSmithyRuntime": "orchestrator", + "includeEndpointUrlConfig": false }, "customizationConfig": { "awsSdk": { diff --git a/aws/sra-test/integration-tests/aws-sdk-s3/Cargo.toml b/aws/sra-test/integration-tests/aws-sdk-s3/Cargo.toml index d8057c6de..82abf8c09 100644 --- a/aws/sra-test/integration-tests/aws-sdk-s3/Cargo.toml +++ b/aws/sra-test/integration-tests/aws-sdk-s3/Cargo.toml @@ -18,8 +18,8 @@ aws-types = { path = "../../../rust-runtime/aws-types" } criterion = { version = "0.4", features = ["async_tokio"] } http = "0.2.3" http-body = "0.4.5" -last-release-smithy-client = { version = "0.55", package = "aws-smithy-client", features = ["test-util", "rustls"] } -last-release-s3 = { version = "0.26", package = "aws-sdk-s3", features = ["test-util"] } +last-release-smithy-client = { version = "0.55.3", package = "aws-smithy-client", features = ["test-util", "rustls"] } +last-release-s3 = { version = "0.28", package = "aws-sdk-s3", features = ["test-util"] } tokio = { version = "1.23.1", features = ["macros", "test-util", "rt-multi-thread"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.15", features = ["env-filter", "json"] } diff --git a/aws/sra-test/integration-tests/aws-sdk-s3/benches/middleware_vs_orchestrator.rs b/aws/sra-test/integration-tests/aws-sdk-s3/benches/middleware_vs_orchestrator.rs index fd4e5440a..b728a6fa1 100644 --- a/aws/sra-test/integration-tests/aws-sdk-s3/benches/middleware_vs_orchestrator.rs +++ b/aws/sra-test/integration-tests/aws-sdk-s3/benches/middleware_vs_orchestrator.rs @@ -6,9 +6,6 @@ #[macro_use] extern crate criterion; use aws_sdk_s3 as s3; -use aws_smithy_runtime_api::client::interceptors::InterceptorRegistrar; -use aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin; -use aws_smithy_types::config_bag::ConfigBag; use criterion::{BenchmarkId, Criterion}; macro_rules! test_connection { @@ -92,7 +89,7 @@ async fn orchestrator(client: &s3::Client) { .list_objects_v2() .bucket("test-bucket") .prefix("prefix~") - .send_orchestrator() + .send() .await .expect("successful execution"); } diff --git a/aws/sra-test/integration-tests/aws-sdk-s3/tests/sra_test.rs b/aws/sra-test/integration-tests/aws-sdk-s3/tests/sra_test.rs deleted file mode 100644 index 3e6c64be5..000000000 --- a/aws/sra-test/integration-tests/aws-sdk-s3/tests/sra_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -mod util; - -use aws_sdk_s3::config::{Credentials, Region}; -use aws_sdk_s3::Client; -use aws_smithy_client::dvr; -use aws_smithy_client::dvr::MediaType; -use aws_smithy_client::erase::DynConnector; -use std::time::{Duration, UNIX_EPOCH}; - -const LIST_BUCKETS_PATH: &str = "test-data/list-objects-v2.json"; - -#[tokio::test] -async fn sra_test() { - tracing_subscriber::fmt::init(); - - let conn = dvr::ReplayingConnection::from_file(LIST_BUCKETS_PATH).unwrap(); - - let config = aws_sdk_s3::Config::builder() - .credentials_provider(Credentials::for_tests()) - .region(Region::new("us-east-1")) - .http_connector(DynConnector::new(conn.clone())) - .interceptor(util::TestUserAgentInterceptor) - .build(); - let client = Client::from_conf(config); - let fixup = util::FixupPlugin; - - let resp = dbg!( - client - .list_objects_v2() - .bucket("test-bucket") - .prefix("prefix~") - .send_orchestrator_with_plugin(Some(fixup)) - .await - ); - // To regenerate the test: - // conn.dump_to_file("test-data/list-objects-v2.json").unwrap(); - let resp = resp.expect("valid e2e test"); - assert_eq!(resp.name(), Some("test-bucket")); - conn.full_validate(MediaType::Xml).await.expect("success") -} 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 93a0c2de1..afe7b7057 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 @@ -78,7 +78,7 @@ object ClientRustModule { val Endpoint = RustModule.public("endpoint") // TODO(enableNewSmithyRuntimeCleanup): Just use Config.endpoint directly and delete this function - fun endpoint(codegenContext: ClientCodegenContext): RustModule.LeafModule = if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + fun endpoint(codegenContext: ClientCodegenContext): RustModule.LeafModule = if (codegenContext.smithyRuntimeMode.generateMiddleware) { Endpoint } else { Config.endpoint diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt index 908c936be..ca532b19b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt @@ -74,36 +74,16 @@ data class ClientRustSettings( // TODO(enableNewSmithyRuntimeCleanup): Remove this mode after switching to the orchestrator enum class SmithyRuntimeMode { - Middleware, BothDefaultMiddleware, BothDefaultOrchestrator, Orchestrator, + Middleware, Orchestrator, ; - val exclusivelyGenerateMiddleware: Boolean get() = generateMiddleware && !generateOrchestrator - - val generateMiddleware: Boolean - get() = when (this) { - Middleware, BothDefaultMiddleware, BothDefaultOrchestrator -> true - else -> false - } - - val generateOrchestrator: Boolean - get() = when (this) { - Orchestrator, BothDefaultMiddleware, BothDefaultOrchestrator -> true - else -> false - } - - val defaultToMiddleware: Boolean - get() = when (this) { - Middleware, BothDefaultMiddleware -> true - else -> false - } - val defaultToOrchestrator: Boolean get() = !defaultToMiddleware + val generateMiddleware: Boolean get() = this == Middleware + val generateOrchestrator: Boolean get() = this == Orchestrator companion object { fun fromString(value: String): SmithyRuntimeMode = when (value) { "middleware" -> Middleware "orchestrator" -> Orchestrator - "both_default_middleware" -> BothDefaultMiddleware - "both_default_orchestrator" -> BothDefaultOrchestrator else -> throw IllegalArgumentException("unknown runtime mode: $value") } } @@ -123,7 +103,7 @@ data class ClientCodegenConfig( val addMessageToErrors: Boolean = defaultAddMessageToErrors, // TODO(EventStream): [CLEANUP] Remove this property when turning on Event Stream for all services val eventStreamAllowList: Set = defaultEventStreamAllowList, - // TODO(SmithyRuntime): Remove this once we commit to switch to aws-smithy-runtime and aws-smithy-runtime-api + // TODO(enableNewSmithyRuntimeCleanup): Remove this once we commit to switch to aws-smithy-runtime and aws-smithy-runtime-api val enableNewSmithyRuntime: SmithyRuntimeMode = defaultEnableNewSmithyRuntime, /** If true, adds `endpoint_url`/`set_endpoint_url` methods to the service config */ val includeEndpointUrlConfig: Boolean = defaultIncludeEndpointUrlConfig, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt index 8c48d4ce1..fb02e2827 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt @@ -189,19 +189,19 @@ private class ApiKeyConfigCustomization(codegenContext: ClientCodegenContext) : ) } is ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rust("layer.store_or_unset(self.api_key);") } else { rust("api_key: self.api_key,") } } is ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("api_key: #{Option}<#{ApiKey}>,", *codegenScope) } } is ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns API key used by the client, if it was provided. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpConnectorConfigDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpConnectorConfigDecorator.kt index 94e0f47da..49dbce324 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpConnectorConfigDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpConnectorConfigDecorator.kt @@ -115,13 +115,13 @@ private class HttpConnectorConfigCustomization( override fun section(section: ServiceConfig): Writable { return when (section) { is ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("http_connector: Option<#{HttpConnector}>,", *codegenScope) } } is ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Return the [`SharedHttpConnector`](#{SharedHttpConnector}) to use when making requests, if any. @@ -145,7 +145,7 @@ private class HttpConnectorConfigCustomization( } is ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("http_connector: Option<#{HttpConnector}>,", *codegenScope) } } @@ -229,7 +229,7 @@ private class HttpConnectorConfigCustomization( """, *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_http_connector(&mut self, http_connector: Option>) -> &mut Self { @@ -253,7 +253,7 @@ private class HttpConnectorConfigCustomization( } is ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( "#{set_connector}(&mut resolver);", "set_connector" to setConnectorFn(), @@ -264,7 +264,7 @@ private class HttpConnectorConfigCustomization( } is ServiceConfig.OperationConfigOverride -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( "#{set_connector}(&mut resolver);", "set_connector" to setConnectorFn(), diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt index fc74d456c..a79e2be68 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ResiliencyConfigCustomization.kt @@ -51,7 +51,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon writable { when (section) { is ServiceConfig.ConfigStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( """ retry_config: #{Option}<#{RetryConfig}>, @@ -64,7 +64,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon } is ServiceConfig.ConfigImpl -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Return a reference to the retry configuration contained in this config, if any. @@ -117,7 +117,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon } is ServiceConfig.BuilderStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( """ retry_config: #{Option}<#{RetryConfig}>, @@ -167,7 +167,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_retry_config(&mut self, retry_config: #{Option}<#{RetryConfig}>) -> &mut Self { @@ -245,7 +245,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_sleep_impl(&mut self, sleep_impl: #{Option}<#{SharedAsyncSleep}>) -> &mut Self { @@ -313,7 +313,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_timeout_config(&mut self, timeout_config: #{Option}<#{TimeoutConfig}>) -> &mut Self { @@ -335,7 +335,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon ) } - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { Attribute.DocHidden.render(this) rustTemplate( """ @@ -367,7 +367,7 @@ class ResiliencyConfigCustomization(private val codegenContext: ClientCodegenCon } is ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ let retry_partition = layer.load::<#{RetryPartition}>().cloned().unwrap_or_else(|| #{RetryPartition}::new("${codegenContext.serviceShape.sdkId()}")); diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/TimeSourceCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/TimeSourceCustomization.kt index 44579aec5..ab9a96155 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/TimeSourceCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/TimeSourceCustomization.kt @@ -29,7 +29,7 @@ class TimeSourceCustomization(codegenContext: ClientCodegenContext) : ConfigCust writable { when (section) { is ServiceConfig.ConfigStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( """ pub(crate) time_source: #{SharedTimeSource}, @@ -45,7 +45,7 @@ class TimeSourceCustomization(codegenContext: ClientCodegenContext) : ConfigCust "pub fn time_source(&self) -> #{Option}<#{SharedTimeSource}>", *codegenScope, ) { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """self.runtime_components.time_source()""", *codegenScope, @@ -57,7 +57,7 @@ class TimeSourceCustomization(codegenContext: ClientCodegenContext) : ConfigCust } is ServiceConfig.BuilderStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( "time_source: #{Option}<#{SharedTimeSource}>,", *codegenScope, @@ -80,7 +80,7 @@ class TimeSourceCustomization(codegenContext: ClientCodegenContext) : ConfigCust *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the time source used for this service @@ -112,7 +112,7 @@ class TimeSourceCustomization(codegenContext: ClientCodegenContext) : ConfigCust } ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ if self.runtime_components.time_source().is_none() { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt index 1cd523ad0..b1871c6ff 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt @@ -45,7 +45,7 @@ internal class EndpointConfigCustomization( val resolverTrait = "#{SmithyResolver}<#{Params}>" when (section) { is ServiceConfig.ConfigStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( "pub (crate) endpoint_resolver: $sharedEndpointResolver,", *codegenScope, @@ -54,7 +54,7 @@ internal class EndpointConfigCustomization( } is ServiceConfig.ConfigImpl -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns the endpoint resolver. @@ -78,7 +78,7 @@ internal class EndpointConfigCustomization( } is ServiceConfig.BuilderStruct -> { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate( "endpoint_resolver: #{Option}<$sharedEndpointResolver>,", *codegenScope, @@ -181,7 +181,7 @@ internal class EndpointConfigCustomization( *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_endpoint_resolver(&mut self, endpoint_resolver: #{Option}<$sharedEndpointResolver>) -> &mut Self { @@ -205,7 +205,7 @@ internal class EndpointConfigCustomization( } ServiceConfig.BuilderBuild -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( "#{set_endpoint_resolver}(&mut resolver);", "set_endpoint_resolver" to setEndpointResolverFn(), @@ -224,7 +224,7 @@ internal class EndpointConfigCustomization( } is ServiceConfig.OperationConfigOverride -> { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( "#{set_endpoint_resolver}(&mut resolver);", "set_endpoint_resolver" to setEndpointResolverFn(), diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt index 6b9941051..2cd374ad6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt @@ -106,7 +106,7 @@ class EndpointParamsInterceptorGenerator( val builtInParams = params.toList().filter { it.isBuiltIn } // first load builtins and their defaults builtInParams.forEach { param -> - val config = if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + val config = if (codegenContext.smithyRuntimeMode.generateOrchestrator) { "cfg" } else { "_config" diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt index 3f86fe720..f68aed2de 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt @@ -204,14 +204,14 @@ class PaginatorGenerator private constructor( "items_fn" to itemsFn(), "output_token" to outputTokenLens, "item_type" to writable { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rustTemplate("#{Result}<#{Output}, #{SdkError}<#{Error}>>", *codegenScope) } else { rustTemplate("#{Result}<#{Output}, #{SdkError}<#{Error}, #{HttpResponse}>>", *codegenScope) } }, "orchestrate" to writable { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rustTemplate( """ { @@ -237,7 +237,7 @@ class PaginatorGenerator private constructor( } }, "runtime_plugin_init" to writable { - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ let runtime_plugins = #{operation}::operation_runtime_plugins( @@ -317,7 +317,7 @@ class PaginatorGenerator private constructor( paginationInfo.itemsMemberPath, ), "item_type" to writable { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rustTemplate("#{Result}<${itemType()}, #{SdkError}<#{Error}>>", *codegenScope) } else { rustTemplate("#{Result}<${itemType()}, #{SdkError}<#{Error}, #{HttpResponse}>>", *codegenScope) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt index 4046d29e7..5c2c4e63e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt @@ -374,7 +374,7 @@ fun renderCustomizableOperationSend(codegenContext: ClientCodegenContext, generi """, *codegenScope, ) - } else if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + } else if (codegenContext.smithyRuntimeMode.generateMiddleware) { writer.rustTemplate( """ impl#{combined_generics_decl:W} CustomizableOperation#{combined_generics_decl:W} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 368d70ae4..d7fb4560b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -347,7 +347,7 @@ class FluentClientGenerator( } """, *preludeScope, - "RawResponseType" to if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + "RawResponseType" to if (codegenContext.smithyRuntimeMode.generateMiddleware) { RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response") } else { RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") @@ -437,36 +437,7 @@ class FluentClientGenerator( generics.toRustGenerics(), ), ) - rustTemplate( - """ - // This function will go away in the near future. Do not rely on it. - ##[doc(hidden)] - pub async fn customize_middleware(self) -> #{Result}< - #{CustomizableOperation}#{customizable_op_type_params:W}, - #{SdkError}<#{OperationError}> - > #{send_bounds:W} { - let handle = self.handle.clone(); - let operation = self.inner.build().map_err(#{SdkError}::construction_failure)? - .make_operation(&handle.conf) - .await - .map_err(#{SdkError}::construction_failure)?; - #{Ok}(#{CustomizableOperation} { handle, operation }) - } - - // This function will go away in the near future. Do not rely on it. - ##[doc(hidden)] - pub async fn send_middleware(self) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> - #{send_bounds:W} { - let op = self.inner.build().map_err(#{SdkError}::construction_failure)? - .make_operation(&self.handle.conf) - .await - .map_err(#{SdkError}::construction_failure)?; - self.handle.client.call(op).await - } - """, - *middlewareScope, - ) - if (smithyRuntimeMode.defaultToMiddleware) { + if (smithyRuntimeMode.generateMiddleware) { rustTemplate( """ /// Sends the request and returns the response. @@ -479,7 +450,11 @@ class FluentClientGenerator( /// set when configuring the client. pub async fn send(self) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { - self.send_middleware().await + let op = self.inner.build().map_err(#{SdkError}::construction_failure)? + .make_operation(&self.handle.conf) + .await + .map_err(#{SdkError}::construction_failure)?; + self.handle.client.call(op).await } /// Consumes this builder, creating a customizable operation that can be modified before being @@ -488,7 +463,12 @@ class FluentClientGenerator( #{CustomizableOperation}#{customizable_op_type_params:W}, #{SdkError}<#{OperationError}> > #{send_bounds:W} { - self.customize_middleware().await + let handle = self.handle.clone(); + let operation = self.inner.build().map_err(#{SdkError}::construction_failure)? + .make_operation(&handle.conf) + .await + .map_err(#{SdkError}::construction_failure)?; + #{Ok}(#{CustomizableOperation} { handle, operation }) } """, *middlewareScope, @@ -511,45 +491,7 @@ class FluentClientGenerator( .resolve("internal::SendResult"), "SdkError" to RuntimeType.sdkError(runtimeConfig), ) - rustTemplate( - """ - ##[doc(hidden)] - pub async fn send_orchestrator(self) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{HttpResponse}>> { - let input = self.inner.build().map_err(#{SdkError}::construction_failure)?; - let runtime_plugins = #{Operation}::operation_runtime_plugins( - self.handle.runtime_plugins.clone(), - &self.handle.conf, - self.config_override, - ); - #{Operation}::orchestrate(&runtime_plugins, input).await - } - - ##[doc(hidden)] - // TODO(enableNewSmithyRuntimeCleanup): Remove `async` once we switch to orchestrator - pub async fn customize_orchestrator( - self, - ) -> #{CustomizableOperation}< - #{OperationOutput}, - #{OperationError}, - > - { - #{CustomizableOperation} { - customizable_send: #{Box}::new(move |config_override| { - #{Box}::pin(async { - self.config_override(config_override) - .send_orchestrator() - .await - }) - }), - config_override: None, - interceptors: vec![], - runtime_plugins: vec![], - } - } - """, - *orchestratorScope, - ) - if (smithyRuntimeMode.defaultToOrchestrator) { + if (smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ /// Sends the request and returns the response. @@ -561,7 +503,13 @@ class FluentClientGenerator( /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be /// set when configuring the client. pub async fn send(self) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{HttpResponse}>> { - self.send_orchestrator().await + let input = self.inner.build().map_err(#{SdkError}::construction_failure)?; + let runtime_plugins = #{Operation}::operation_runtime_plugins( + self.handle.runtime_plugins.clone(), + &self.handle.conf, + self.config_override, + ); + #{Operation}::orchestrate(&runtime_plugins, input).await } /// Consumes this builder, creating a customizable operation that can be modified before being @@ -577,7 +525,18 @@ class FluentClientGenerator( #{SdkError}<#{OperationError}>, > { - #{Ok}(self.customize_orchestrator().await) + #{Ok}(#{CustomizableOperation} { + customizable_send: #{Box}::new(move |config_override| { + #{Box}::pin(async { + self.config_override(config_override) + .send() + .await + }) + }), + config_override: None, + interceptors: vec![], + runtime_plugins: vec![], + }) } """, *orchestratorScope, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt index 58a3a6743..2606ff5f4 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt @@ -29,13 +29,13 @@ class IdempotencyTokenProviderCustomization(codegenContext: ClientCodegenContext override fun section(section: ServiceConfig): Writable { return when (section) { is ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("pub (crate) idempotency_token_provider: #{IdempotencyTokenProvider},", *codegenScope) } } ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Returns a copy of the idempotency token provider. @@ -63,7 +63,7 @@ class IdempotencyTokenProviderCustomization(codegenContext: ClientCodegenContext } ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rustTemplate("idempotency_token_provider: #{Option}<#{IdempotencyTokenProvider}>,", *codegenScope) } } @@ -80,7 +80,7 @@ class IdempotencyTokenProviderCustomization(codegenContext: ClientCodegenContext *codegenScope, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ /// Sets the idempotency token provider to use for service calls that require tokens. @@ -106,7 +106,7 @@ class IdempotencyTokenProviderCustomization(codegenContext: ClientCodegenContext } ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ if !resolver.is_set::<#{IdempotencyTokenProvider}>() { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt index ba400c85b..bfa244e8d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt @@ -196,7 +196,7 @@ fun standardConfigParam(param: ConfigParam, codegenContext: ClientCodegenContext override fun section(section: ServiceConfig): Writable { return when (section) { ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { docsOrFallback(param.getterDocs) val t = when (param.optional) { true -> param.type.makeOptional() @@ -207,7 +207,7 @@ fun standardConfigParam(param: ConfigParam, codegenContext: ClientCodegenContext } ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("${param.name}: #T,", param.type.makeOptional()) } } @@ -224,7 +224,7 @@ fun standardConfigParam(param: ConfigParam, codegenContext: ClientCodegenContext ) docsOrFallback(param.setterDocs) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub fn set_${param.name}(&mut self, ${param.name}: Option<#{T}>) -> &mut Self { @@ -249,7 +249,7 @@ fun standardConfigParam(param: ConfigParam, codegenContext: ClientCodegenContext } ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { val default = "".letIf(!param.optional) { ".unwrap_or_default() " } rust("${param.name}: self.${param.name}$default,") } @@ -334,7 +334,7 @@ class ServiceConfigGenerator( Attribute(Attribute.derive(RuntimeType.Debug)).render(writer) } writer.rustBlock("pub struct Config") { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ // Both `config` and `cloneable` are the same config, but the cloneable one @@ -353,7 +353,7 @@ class ServiceConfigGenerator( } } - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { // Custom implementation for Debug so we don't need to enforce Debug down the chain writer.rustBlock("impl std::fmt::Debug for Config") { writer.rustTemplate( @@ -374,7 +374,7 @@ class ServiceConfigGenerator( pub fn builder() -> Builder { Builder::default() } """, ) - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { writer.rustTemplate( """ /// Converts this config back into a builder so that it can be tweaked. @@ -394,13 +394,13 @@ class ServiceConfigGenerator( } writer.docs("Builder for creating a `Config`.") - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { Attribute(Attribute.derive(RuntimeType.Clone, RuntimeType.Default)).render(writer) } else { Attribute(Attribute.derive(RuntimeType.Clone, RuntimeType.Debug)).render(writer) } writer.rustBlock("pub struct Builder") { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ pub(crate) config: #{CloneableLayer}, @@ -415,7 +415,7 @@ class ServiceConfigGenerator( } } - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { // Custom implementation for Debug so we don't need to enforce Debug down the chain writer.rustBlock("impl std::fmt::Debug for Builder") { writer.rustTemplate( @@ -498,7 +498,7 @@ class ServiceConfigGenerator( } docs("Builds a [`Config`].") - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rust("##[allow(unused_mut)]") rustBlock("pub fn build(mut self) -> Config") { rustTemplate( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index e3f61df3b..583324b0b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -70,7 +70,7 @@ class DefaultProtocolTestGenerator( override val operationShape: OperationShape, private val renderClientCreation: RustWriter.(ClientCreationParams) -> Unit = { params -> - if (params.codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (params.codegenContext.smithyRuntimeMode.generateMiddleware) { rustTemplate( """ let smithy_client = #{Builder}::new() @@ -347,7 +347,7 @@ class DefaultProtocolTestGenerator( """, RT.sdkBody(runtimeConfig = rc), ) - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rust( "let mut op_response = #T::new(http_response);", RT.operationModule(rc).resolve("Response"), @@ -397,7 +397,7 @@ class DefaultProtocolTestGenerator( val errorSymbol = codegenContext.symbolProvider.symbolForOperationError(operationShape) val errorVariant = codegenContext.symbolProvider.toSymbol(expectedShape).name rust("""let parsed = parsed.expect_err("should be error response");""") - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { rustTemplate( """let parsed: &#{Error} = parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();""", "Error" to codegenContext.symbolProvider.symbolForOperationError(operationShape), @@ -410,7 +410,7 @@ class DefaultProtocolTestGenerator( rust("panic!(\"wrong variant: Got: {:?}. Expected: {:?}\", parsed, expected_output);") } } else { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rust("let parsed = parsed.unwrap();") } else { rustTemplate( diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt index 0f96cf3e0..dbfa3b3c6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestConfigCustomization.kt @@ -31,12 +31,12 @@ fun stubConfigCustomization(name: String, codegenContext: ClientCodegenContext): override fun section(section: ServiceConfig): Writable = writable { when (section) { ServiceConfig.ConfigStruct -> { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rust("_$name: u64,") } } ServiceConfig.ConfigImpl -> { - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ ##[allow(missing_docs)] @@ -61,12 +61,12 @@ fun stubConfigCustomization(name: String, codegenContext: ClientCodegenContext): } } ServiceConfig.BuilderStruct -> { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rust("_$name: Option,") } } ServiceConfig.BuilderImpl -> { - if (codegenContext.smithyRuntimeMode.defaultToOrchestrator) { + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ /// docs! @@ -93,7 +93,7 @@ fun stubConfigCustomization(name: String, codegenContext: ClientCodegenContext): } } ServiceConfig.BuilderBuild -> { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + if (codegenContext.smithyRuntimeMode.generateMiddleware) { rust( """ _$name: self._$name.unwrap_or(123), diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpAuthDecoratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpAuthDecoratorTest.kt index 474ed7b43..29f25e98a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpAuthDecoratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpAuthDecoratorTest.kt @@ -57,7 +57,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -91,7 +91,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -136,7 +136,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -182,7 +182,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -228,7 +228,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -274,7 +274,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); @@ -316,7 +316,7 @@ class HttpAuthDecoratorTest { .build_dyn(); let client = $moduleName::Client::with_config(smithy_client, config); let _ = client.some_operation() - .send_orchestrator() + .send() .await .expect("success"); connector.assert_requests_match(&[]); diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/ClientContextConfigCustomizationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/ClientContextConfigCustomizationTest.kt index 94bd6524a..b855c3136 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/ClientContextConfigCustomizationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/ClientContextConfigCustomizationTest.kt @@ -41,7 +41,7 @@ class ClientContextConfigCustomizationTest { val smithyRuntimeMode = SmithyRuntimeMode.fromString(smithyRuntimeModeStr) val context = testClientCodegenContext(model).withSmithyRuntimeMode(smithyRuntimeMode) project.unitTest { - if (smithyRuntimeMode.defaultToOrchestrator) { + if (smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ use #{RuntimePlugin}; @@ -74,7 +74,7 @@ class ClientContextConfigCustomizationTest { } // unset fields project.unitTest { - if (smithyRuntimeMode.defaultToOrchestrator) { + if (smithyRuntimeMode.generateOrchestrator) { rustTemplate( """ use #{RuntimePlugin}; diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt index 9f8056931..fc439f764 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt @@ -96,13 +96,13 @@ internal class ServiceConfigGeneratorTest { return when (section) { ServiceConfig.ConfigStructAdditionalDocs -> emptySection ServiceConfig.ConfigStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("config_field: u64,") } } ServiceConfig.ConfigImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ ##[allow(missing_docs)] @@ -128,12 +128,12 @@ internal class ServiceConfigGeneratorTest { } ServiceConfig.BuilderStruct -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("config_field: Option") } } ServiceConfig.BuilderImpl -> writable { - if (runtimeMode.defaultToOrchestrator) { + if (runtimeMode.generateOrchestrator) { rustTemplate( """ ##[allow(missing_docs)] @@ -150,7 +150,7 @@ internal class ServiceConfigGeneratorTest { } } ServiceConfig.BuilderBuild -> writable { - if (runtimeMode.defaultToMiddleware) { + if (runtimeMode.generateMiddleware) { rust("config_field: self.config_field.unwrap_or_default(),") } } @@ -170,7 +170,7 @@ internal class ServiceConfigGeneratorTest { val project = TestWorkspace.testProject(symbolProvider) project.withModule(ClientRustModule.config) { sut.render(this) - if (smithyRuntimeMode.defaultToOrchestrator) { + if (smithyRuntimeMode.generateOrchestrator) { unitTest( "set_config_fields", """