From 88b3c435b4c646746b156f385c07a90f4cd392fa Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 27 Apr 2023 04:31:03 +0000 Subject: [PATCH 01/42] - Add feature gates - Add serde related attributes --- .../rust/codegen/core/rustlang/RustType.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt index 79dde7de12..007b1b9bed 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt @@ -475,6 +475,23 @@ class Attribute(val inner: Writable, val isDeriveHelper: Boolean = false) { } } + // These were supposed to be a part of companion object but we decided to move it out to here to avoid NPE + // You can find the discussion here. + // https://github.com/awslabs/smithy-rs/discussions/2248 + public fun SerdeSerialize(): Attribute { + return Attribute(cfgAttr(all(writable("aws_sdk_unstable"), feature("serde-serialize")), derive(RuntimeType.SerdeSerialize))) + } + public fun SerdeDeserialize(): Attribute { + return Attribute(cfgAttr(all(writable("aws_sdk_unstable"), feature("serde-deserialize")), derive(RuntimeType.SerdeDeserialize))) + } + public fun SerdeSkip(): Attribute { + return Attribute(cfgAttr(all(writable("aws_sdk_unstable"), any(feature("serde-serialize"), feature("serde-deserialize"))), serde("skip"))) + } + + public fun SerdeSerializeOrDeserialize(): Attribute { + return Attribute(cfg(all(writable("aws_sdk_unstable"), any(feature("serde-serialize"), feature("serde-deserialize"))))) + } + companion object { val AllowClippyBoxedLocal = Attribute(allow("clippy::boxed_local")) val AllowClippyLetAndReturn = Attribute(allow("clippy::let_and_return")) @@ -503,6 +520,7 @@ class Attribute(val inner: Writable, val isDeriveHelper: Boolean = false) { val Test = Attribute("test") val TokioTest = Attribute(RuntimeType.Tokio.resolve("test").writable) + val AwsSdkUnstableAttribute = Attribute(cfg("aws_sdk_unstable")) /** * [non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute) @@ -531,10 +549,12 @@ class Attribute(val inner: Writable, val isDeriveHelper: Boolean = false) { } fun all(vararg attrMacros: Writable): Writable = macroWithArgs("all", *attrMacros) + fun cfgAttr(vararg attrMacros: Writable): Writable = macroWithArgs("cfg_attr", *attrMacros) fun allow(lints: Collection): Writable = macroWithArgs("allow", *lints.toTypedArray()) fun allow(vararg lints: String): Writable = macroWithArgs("allow", *lints) fun deny(vararg lints: String): Writable = macroWithArgs("deny", *lints) + fun serde(vararg lints: String): Writable = macroWithArgs("serde", *lints) fun any(vararg attrMacros: Writable): Writable = macroWithArgs("any", *attrMacros) fun cfg(vararg attrMacros: Writable): Writable = macroWithArgs("cfg", *attrMacros) fun cfg(vararg attrMacros: String): Writable = macroWithArgs("cfg", *attrMacros) From 82d296c38fa6794e7a986639d82456f1587b185f Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 27 Apr 2023 04:33:55 +0000 Subject: [PATCH 02/42] Add CfgUnstable feature gate --- .../smithy/rust/codegen/core/rustlang/CargoDependency.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt index 2e372b4989..0ead4d6e7b 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt @@ -16,6 +16,7 @@ import java.nio.file.Path sealed class DependencyScope { object Dev : DependencyScope() object Compile : DependencyScope() + object CfgUnstable : DependencyScope() object Build : DependencyScope() } @@ -277,5 +278,8 @@ data class CargoDependency( fun smithyRuntimeApi(runtimeConfig: RuntimeConfig) = runtimeConfig.smithyRuntimeCrate("smithy-runtime-api") fun smithyTypes(runtimeConfig: RuntimeConfig) = runtimeConfig.smithyRuntimeCrate("smithy-types") fun smithyXml(runtimeConfig: RuntimeConfig) = runtimeConfig.smithyRuntimeCrate("smithy-xml") + + // behind feature-gate + val Serde = CargoDependency("serde", CratesIo("1.0"), features = setOf("derive"), scope = DependencyScope.CfgUnstable) } } From 5cc6ac97738eb917a08fc4644036c90f3aafa984 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 27 Apr 2023 04:36:36 +0000 Subject: [PATCH 03/42] add serde to runtime type --- .../amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index f8c656c08e..b1200b5cb2 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -249,6 +249,11 @@ data class RuntimeType(val path: String, val dependency: RustDependency? = null) val ConstrainedTrait = RuntimeType("crate::constrained::Constrained", InlineDependency.constrained()) val MaybeConstrained = RuntimeType("crate::constrained::MaybeConstrained", InlineDependency.constrained()) + // serde types. Gated behind `CfgUnstable`. + val Serde = CargoDependency.Serde.toType() + val SerdeSerialize = Serde.resolve("Serialize") + val SerdeDeserialize = Serde.resolve("Deserialize") + // smithy runtime types fun smithyAsync(runtimeConfig: RuntimeConfig) = CargoDependency.smithyAsync(runtimeConfig).toType() fun smithyChecksums(runtimeConfig: RuntimeConfig) = CargoDependency.smithyChecksums(runtimeConfig).toType() From f701ae18ba7d2216778fc4e1dc40c3a3ee74f235 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 27 Apr 2023 05:26:19 +0000 Subject: [PATCH 04/42] add set field --- .../client/FluentClientGenerator.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) 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 6c085fd673..77e4694241 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 @@ -267,6 +267,8 @@ class FluentClientGenerator( ) { val outputType = symbolProvider.toSymbol(operation.outputShape(model)) val errorType = symbolProvider.symbolForOperationError(operation) + val inputBuilderType = symbolProvider.symbolForBuilder(input) + val fnName = clientOperationFnName(operation, symbolProvider) rust("/// Creates a new `${operationSymbol.name}`.") withBlockTemplate( @@ -316,6 +318,7 @@ class FluentClientGenerator( .map_err(#{SdkError}::construction_failure)?; self.handle.client.call(op).await } + """, "CustomizableOperation" to ClientRustModule.Client.customize.toType() .resolve("CustomizableOperation"), @@ -331,6 +334,43 @@ class FluentClientGenerator( generics.toRustGenerics(), ), ) + + // this fixes this error + // error[E0592]: duplicate definitions with name `set_fields` + // --> sdk/connectcases/src/operation/update_case/builders.rs:115:5 + // | + // 78 | / pub fn set_fields( + // 79 | | mut self, + // 80 | | data: crate::operation::update_case::builders::UpdateCaseInputBuilder, + // 81 | | ) -> Self { + // | |_____________- other definition for `set_fields` + // ... + // 115 | / pub fn set_fields( + // 116 | | mut self, + // 117 | | input: std::option::Option>, + // 118 | | ) -> Self { + // | |_____________^ duplicate definitions for `set_fields` + if (inputBuilderType.toString().endsWith("Builder")) { + rustTemplate( + """ + ##[#{AwsSdkUnstableAttribute}] + /// This function replaces the parameter with new one. + /// It is useful when you want to replace the existing data with de-serialized data. + /// ```compile_fail + /// let result_future = async { + /// let deserialized_parameters: $inputBuilderType = serde_json::from_str(&json_string).unwrap(); + /// client.$fnName().set_fields(&deserialized_parameters).send().await + /// }; + /// ``` + pub fn set_fields(mut self, data: $inputBuilderType) -> Self { + self.inner = data; + self + } + """, + "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, + ) + } + if (enableNewSmithyRuntime) { rustTemplate( """ From 893692ac3ca9632d5dc6dfa7f78353ac93e0c38b Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 1 Jun 2023 00:31:56 +0900 Subject: [PATCH 05/42] Update FluentClientGenerator.kt --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7a62f01834..5997607333 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 @@ -483,7 +483,7 @@ class FluentClientGenerator( """, *middlewareScope, ) - } + } } if (smithyRuntimeMode.generateOrchestrator) { From c2cce088ba6445019b59f2ecb0a84105fcd3890b Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 31 May 2023 17:02:41 +0000 Subject: [PATCH 06/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 5997607333..dcb4747d7a 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 @@ -372,7 +372,7 @@ class FluentClientGenerator( } } } - + // this fixes this error // error[E0592]: duplicate definitions with name `set_fields` // --> sdk/connectcases/src/operation/update_case/builders.rs:115:5 @@ -408,7 +408,7 @@ class FluentClientGenerator( "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, ) } - + if (smithyRuntimeMode.generateMiddleware) { val middlewareScope = arrayOf( *preludeScope, From 48c04f8893b8527e696d54998462e0e4205733ca Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 1 Jun 2023 09:00:15 +0000 Subject: [PATCH 07/42] update --- .../client/FluentClientGenerator.kt | 60 +++++++------------ 1 file changed, 22 insertions(+), 38 deletions(-) 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 dcb4747d7a..ebb687cffa 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 @@ -30,10 +30,12 @@ import software.amazon.smithy.rust.codegen.core.rustlang.docLink import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.documentShape import software.amazon.smithy.rust.codegen.core.rustlang.escape +import software.amazon.smithy.rust.codegen.core.rustlang.implBlock import software.amazon.smithy.rust.codegen.core.rustlang.normalizeHtml import software.amazon.smithy.rust.codegen.core.rustlang.qualifiedName import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters @@ -319,9 +321,29 @@ class FluentClientGenerator( val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives // Filter out any derive that isn't Clone. Then add a Debug derive + // input name + val fluentBuilderName = operation.fluentBuilderType(symbolProvider).name + val fnName = clientOperationFnName(operation, symbolProvider) + implBlock(symbolProvider.symbolForBuilder(input)) { + rustTemplate( + """ + ##[#{AwsSdkUnstableAttribute}] + /// Creates a fluent builder from this builder. + pub fn into_fluent_builder(self, client: &crate::Client) -> $fluentBuilderName { + let fluent_builder = client.$fnName(); + fluent_builder.inner = self; + fluent_builder + } + """, + + "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, + ) + } + val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug docs("Fluent builder constructing a request to `${operationSymbol.name}`.\n") + val builderName = operation.fluentBuilderType(symbolProvider).name documentShape(operation, model, autoSuppressMissingDocs = false) deprecatedShape(operation) @@ -352,8 +374,6 @@ class FluentClientGenerator( ) { val outputType = symbolProvider.toSymbol(operation.outputShape(model)) val errorType = symbolProvider.symbolForOperationError(operation) - val inputBuilderType = symbolProvider.symbolForBuilder(input) - val fnName = clientOperationFnName(operation, symbolProvider) rust("/// Creates a new `${operationSymbol.name}`.") withBlockTemplate( @@ -373,42 +393,6 @@ class FluentClientGenerator( } } - // this fixes this error - // error[E0592]: duplicate definitions with name `set_fields` - // --> sdk/connectcases/src/operation/update_case/builders.rs:115:5 - // | - // 78 | / pub fn set_fields( - // 79 | | mut self, - // 80 | | data: crate::operation::update_case::builders::UpdateCaseInputBuilder, - // 81 | | ) -> Self { - // | |_____________- other definition for `set_fields` - // ... - // 115 | / pub fn set_fields( - // 116 | | mut self, - // 117 | | input: std::option::Option>, - // 118 | | ) -> Self { - // | |_____________^ duplicate definitions for `set_fields` - if (inputBuilderType.toString().endsWith("Builder")) { - rustTemplate( - """ - ##[#{AwsSdkUnstableAttribute}] - /// This function replaces the parameter with new one. - /// It is useful when you want to replace the existing data with de-serialized data. - /// ```compile_fail - /// let result_future = async { - /// let deserialized_parameters: $inputBuilderType = serde_json::from_str(&json_string).unwrap(); - /// client.$fnName().set_fields(&deserialized_parameters).send().await - /// }; - /// ``` - pub fn set_fields(mut self, data: $inputBuilderType) -> Self { - self.inner = data; - self - } - """, - "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, - ) - } - if (smithyRuntimeMode.generateMiddleware) { val middlewareScope = arrayOf( *preludeScope, From bbd94bad3a466c44b9c8eae7c2b29c4a2a8b5361 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 1 Jun 2023 09:10:01 +0000 Subject: [PATCH 08/42] update --- .../generators/client/FluentClientGenerator.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 ebb687cffa..2e3e5a1784 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 @@ -327,15 +327,15 @@ class FluentClientGenerator( implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ - ##[#{AwsSdkUnstableAttribute}] - /// Creates a fluent builder from this builder. - pub fn into_fluent_builder(self, client: &crate::Client) -> $fluentBuilderName { - let fluent_builder = client.$fnName(); - fluent_builder.inner = self; - fluent_builder - } + ##[#{AwsSdkUnstableAttribute}] + /// Creates a fluent builder from this builder. + pub fn into_fluent_builder(self, client: &crate::Client) -> $fluentBuilderName { + let fluent_builder = client.$fnName(); + fluent_builder.inner = self; + fluent_builder + } """, - + "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, ) } From 75e84e76ada8e28aa930feb599f60f8a4d05610c Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Thu, 1 Jun 2023 18:15:46 +0900 Subject: [PATCH 09/42] Update FluentClientGenerator.kt --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2e3e5a1784..53b8a10b8c 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 @@ -330,7 +330,7 @@ class FluentClientGenerator( ##[#{AwsSdkUnstableAttribute}] /// Creates a fluent builder from this builder. pub fn into_fluent_builder(self, client: &crate::Client) -> $fluentBuilderName { - let fluent_builder = client.$fnName(); + let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; fluent_builder } From ad8f413781a97aeb9a6cb84426ea6340a6ad8ade Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 09:39:25 +0000 Subject: [PATCH 10/42] update fluent client --- .../client/FluentClientGenerator.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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 53b8a10b8c..1a3e575c6a 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 @@ -317,6 +317,20 @@ class FluentClientGenerator( } private fun RustWriter.renderFluentBuilder(operation: OperationShape) { + val orchestratorScope = arrayOf( + *preludeScope, + "CustomizableOperation" to ClientRustModule.Client.customize.toType() + .resolve("orchestrator::CustomizableOperation"), + "HttpResponse" to RuntimeType.smithyRuntimeApi(runtimeConfig) + .resolve("client::orchestrator::HttpResponse"), + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SendResult" to ClientRustModule.Client.customize.toType() + .resolve("internal::SendResult"), + "SdkError" to RuntimeType.sdkError(runtimeConfig), + ) + val operationSymbol = symbolProvider.toSymbol(operation) val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives @@ -327,16 +341,15 @@ class FluentClientGenerator( implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ - ##[#{AwsSdkUnstableAttribute}] /// Creates a fluent builder from this builder. - pub fn into_fluent_builder(self, client: &crate::Client) -> $fluentBuilderName { + pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; fluent_builder } """, - - "AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, + *orchestratorScope ) } @@ -471,19 +484,6 @@ class FluentClientGenerator( } if (smithyRuntimeMode.generateOrchestrator) { - val orchestratorScope = arrayOf( - *preludeScope, - "CustomizableOperation" to ClientRustModule.Client.customize.toType() - .resolve("orchestrator::CustomizableOperation"), - "HttpResponse" to RuntimeType.smithyRuntimeApi(runtimeConfig) - .resolve("client::orchestrator::HttpResponse"), - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SendResult" to ClientRustModule.Client.customize.toType() - .resolve("internal::SendResult"), - "SdkError" to RuntimeType.sdkError(runtimeConfig), - ) rustTemplate( """ ##[doc(hidden)] From d1069dc82099b76bb2a8e7c4c97d74fb9b2792fa Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 09:43:10 +0000 Subject: [PATCH 11/42] fix --- .../smithy/generators/client/FluentClientGenerator.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 1a3e575c6a..3cb8b9669d 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 @@ -317,6 +317,9 @@ class FluentClientGenerator( } private fun RustWriter.renderFluentBuilder(operation: OperationShape) { + val outputType = symbolProvider.toSymbol(operation.outputShape(model)) + val errorType = symbolProvider.symbolForOperationError(operation) + val operationSymbol = symbolProvider.toSymbol(operation) val orchestratorScope = arrayOf( *preludeScope, "CustomizableOperation" to ClientRustModule.Client.customize.toType() @@ -331,7 +334,7 @@ class FluentClientGenerator( "SdkError" to RuntimeType.sdkError(runtimeConfig), ) - val operationSymbol = symbolProvider.toSymbol(operation) + val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives // Filter out any derive that isn't Clone. Then add a Debug derive @@ -385,9 +388,6 @@ class FluentClientGenerator( "client" to RuntimeType.smithyClient(runtimeConfig), "bounds" to generics.bounds, ) { - val outputType = symbolProvider.toSymbol(operation.outputShape(model)) - val errorType = symbolProvider.symbolForOperationError(operation) - rust("/// Creates a new `${operationSymbol.name}`.") withBlockTemplate( "pub(crate) fn new(handle: #{Arc}) -> Self {", From 2cb1e9bb27b5a7a648ddd02e0d7f2ed8b515f932 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 09:46:04 +0000 Subject: [PATCH 12/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3cb8b9669d..9af590d048 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 @@ -334,7 +334,7 @@ class FluentClientGenerator( "SdkError" to RuntimeType.sdkError(runtimeConfig), ) - + val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives // Filter out any derive that isn't Clone. Then add a Debug derive From 663dff3a6a8228232d5a80ab140d4a68706c818d Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 09:47:53 +0000 Subject: [PATCH 13/42] update --- .../smithy/generators/client/FluentClientGenerator.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 9af590d048..a18a07c2ea 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 @@ -35,7 +35,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.normalizeHtml import software.amazon.smithy.rust.codegen.core.rustlang.qualifiedName import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust -import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTypeParameters @@ -334,7 +333,6 @@ class FluentClientGenerator( "SdkError" to RuntimeType.sdkError(runtimeConfig), ) - val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives // Filter out any derive that isn't Clone. Then add a Debug derive @@ -343,7 +341,7 @@ class FluentClientGenerator( val fnName = clientOperationFnName(operation, symbolProvider) implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( - """ + """ /// Creates a fluent builder from this builder. pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { @@ -352,14 +350,13 @@ class FluentClientGenerator( fluent_builder } """, - *orchestratorScope + *orchestratorScope, ) } val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug docs("Fluent builder constructing a request to `${operationSymbol.name}`.\n") - val builderName = operation.fluentBuilderType(symbolProvider).name documentShape(operation, model, autoSuppressMissingDocs = false) deprecatedShape(operation) From 8b38afce204ac091381c23a0d3a5175cbf502816 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 09:50:27 +0000 Subject: [PATCH 14/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 a18a07c2ea..3e5fd3c6b1 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 @@ -337,17 +337,16 @@ class FluentClientGenerator( val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives // Filter out any derive that isn't Clone. Then add a Debug derive // input name - val fluentBuilderName = operation.fluentBuilderType(symbolProvider).name val fnName = clientOperationFnName(operation, symbolProvider) implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ /// Creates a fluent builder from this builder. - pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + async pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; - fluent_builder + fluent_builder.send().await } """, *orchestratorScope, From 525f5723e131ebdd4e6fb149a81041f95193d5f1 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 10:47:43 +0000 Subject: [PATCH 15/42] update --- .../client/FluentClientGenerator.kt | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) 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 3e5fd3c6b1..63e3ddc038 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 @@ -319,19 +319,6 @@ class FluentClientGenerator( val outputType = symbolProvider.toSymbol(operation.outputShape(model)) val errorType = symbolProvider.symbolForOperationError(operation) val operationSymbol = symbolProvider.toSymbol(operation) - val orchestratorScope = arrayOf( - *preludeScope, - "CustomizableOperation" to ClientRustModule.Client.customize.toType() - .resolve("orchestrator::CustomizableOperation"), - "HttpResponse" to RuntimeType.smithyRuntimeApi(runtimeConfig) - .resolve("client::orchestrator::HttpResponse"), - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SendResult" to ClientRustModule.Client.customize.toType() - .resolve("internal::SendResult"), - "SdkError" to RuntimeType.sdkError(runtimeConfig), - ) val input = operation.inputShape(model) val baseDerives = symbolProvider.toSymbol(input).expectRustMetadata().derives @@ -341,15 +328,21 @@ class FluentClientGenerator( implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ - /// Creates a fluent builder from this builder. - async pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> - #{send_bounds:W} { - let mut fluent_builder = client.$fnName(); - fluent_builder.inner = self; - fluent_builder.send().await - } - """, - *orchestratorScope, + /// Creates a fluent builder from this builder. + async pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + #{send_bounds:W} { + let mut fluent_builder = client.$fnName(); + fluent_builder.inner = self; + fluent_builder.send().await + } + """, + *preludeScope, + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), ) } @@ -480,6 +473,19 @@ class FluentClientGenerator( } if (smithyRuntimeMode.generateOrchestrator) { + val orchestratorScope = arrayOf( + *preludeScope, + "CustomizableOperation" to ClientRustModule.Client.customize.toType() + .resolve("orchestrator::CustomizableOperation"), + "HttpResponse" to RuntimeType.smithyRuntimeApi(runtimeConfig) + .resolve("client::orchestrator::HttpResponse"), + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SendResult" to ClientRustModule.Client.customize.toType() + .resolve("internal::SendResult"), + "SdkError" to RuntimeType.sdkError(runtimeConfig), + ) rustTemplate( """ ##[doc(hidden)] From e3367dd314149724beba290fab064bf303b2178c Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 11:05:56 +0000 Subject: [PATCH 16/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 63e3ddc038..6542758c42 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 @@ -325,11 +325,11 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) - implBlock(symbolProvider.symbolForBuilder(input)) { + implBlock(input) { rustTemplate( """ /// Creates a fluent builder from this builder. - async pub fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; From dc21f199fef5f5c85708ef97ebd504443dc683ff Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 11:34:58 +0000 Subject: [PATCH 17/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6542758c42..68284c0e05 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 @@ -325,7 +325,7 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) - implBlock(input) { + implBlock(symbolProvider.toSymbol(operation.inputShape(model))) { rustTemplate( """ /// Creates a fluent builder from this builder. From 5972800f0f12d5bd5fd6c20c2c437a2b4919a0e1 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 11:53:41 +0000 Subject: [PATCH 18/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 68284c0e05..8ef3e99f4f 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 @@ -329,7 +329,7 @@ class FluentClientGenerator( rustTemplate( """ /// Creates a fluent builder from this builder. - pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client>) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; @@ -337,6 +337,7 @@ class FluentClientGenerator( } """, *preludeScope, + "generics_decl" to generics.decl, "Operation" to operationSymbol, "OperationError" to errorType, "OperationOutput" to outputType, From e850ea29a600ff8144a294892afdef0a51ffcc47 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 12:22:03 +0000 Subject: [PATCH 19/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8ef3e99f4f..0f0ddc6fe9 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 @@ -329,7 +329,7 @@ class FluentClientGenerator( rustTemplate( """ /// Creates a fluent builder from this builder. - pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client>) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; From 8b2877e52e050d204f2181fee187809473f134da Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 14:03:32 +0000 Subject: [PATCH 20/42] update --- .../client/FluentClientGenerator.kt | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) 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 0f0ddc6fe9..cd18ac55d7 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 @@ -325,27 +325,28 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) - implBlock(symbolProvider.toSymbol(operation.inputShape(model))) { - rustTemplate( - """ - /// Creates a fluent builder from this builder. - pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> - #{send_bounds:W} { - let mut fluent_builder = client.$fnName(); - fluent_builder.inner = self; - fluent_builder.send().await - } - """, - *preludeScope, - "generics_decl" to generics.decl, - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SdkError" to RuntimeType.sdkError(runtimeConfig), - "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), - "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), - ) - } + rustTemplate( + """ + impl #{InputPath} { + /// Creates a fluent builder from this builder. + pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + #{send_bounds:W} { + let mut fluent_builder = client.$fnName(); + fluent_builder.inner = self; + fluent_builder.send().await + } + } + """, + *preludeScope, + "InputPath" to symbolProvider.toSymbol(input), + "generics_decl" to generics.decl, + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), + ) val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug docs("Fluent builder constructing a request to `${operationSymbol.name}`.\n") From ca47afee236f7a6c4ba8d1d75f690f73c34fd4a5 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 14:50:02 +0000 Subject: [PATCH 21/42] change input path --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cd18ac55d7..e1f7148a9e 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 @@ -338,7 +338,7 @@ class FluentClientGenerator( } """, *preludeScope, - "InputPath" to symbolProvider.toSymbol(input), + "InputPath" to symbolProvider.toSymbol(input).toBuilder(), "generics_decl" to generics.decl, "Operation" to operationSymbol, "OperationError" to errorType, From 3bd1a7b09e3ac0cfc1c3329f2bb6559de17f68cb Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 15:05:45 +0000 Subject: [PATCH 22/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e1f7148a9e..9481523f36 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 @@ -338,7 +338,7 @@ class FluentClientGenerator( } """, *preludeScope, - "InputPath" to symbolProvider.toSymbol(input).toBuilder(), + "InputPath" to symbolProvider.symbolForBuilder(input), "generics_decl" to generics.decl, "Operation" to operationSymbol, "OperationError" to errorType, From a0a4651907c82ea3e79daa1e066761b4542aab7d Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Fri, 2 Jun 2023 15:25:44 +0000 Subject: [PATCH 23/42] update --- .../client/FluentClientGenerator.kt | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) 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 9481523f36..199718c067 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 @@ -325,9 +325,9 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) - rustTemplate( - """ - impl #{InputPath} { + implBlock(symbolProvider.symbolForBuilder(input)) { + rustTemplate( + """ /// Creates a fluent builder from this builder. pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { @@ -335,18 +335,17 @@ class FluentClientGenerator( fluent_builder.inner = self; fluent_builder.send().await } - } """, - *preludeScope, - "InputPath" to symbolProvider.symbolForBuilder(input), - "generics_decl" to generics.decl, - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SdkError" to RuntimeType.sdkError(runtimeConfig), - "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), - "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), - ) + *preludeScope, + "generics_decl" to generics.decl, + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), + ) + } val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug docs("Fluent builder constructing a request to `${operationSymbol.name}`.\n") From 299e5ece68b99b78e92ea7bd1d94038a2986da1c Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Sat, 3 Jun 2023 06:21:36 +0000 Subject: [PATCH 24/42] FIX --- .../generators/client/FluentClientGenerator.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 199718c067..b50a423cb0 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 @@ -325,18 +325,24 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) + implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ - /// Creates a fluent builder from this builder. - pub async fn send_with(self, client: &crate::Client) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> - #{send_bounds:W} { + /// Sends a request with this input using the given client. + pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client<#{generics_decl}>) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; fluent_builder.send().await - } - """, + } + """, *preludeScope, + "RawResponseType" to if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response") + } else { + RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") + }, "generics_decl" to generics.decl, "Operation" to operationSymbol, "OperationError" to errorType, From 605689edc25c603a22c7fcc659bc70f1b9af73a0 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Sat, 3 Jun 2023 09:08:23 +0000 Subject: [PATCH 25/42] updater --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b50a423cb0..39147ffa14 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 @@ -330,7 +330,7 @@ class FluentClientGenerator( rustTemplate( """ /// Sends a request with this input using the given client. - pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client<#{generics_decl}>) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client#{generics_decl:W}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; From 857f3d462a78d0497247c76049b01d53e70d3a42 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Sat, 3 Jun 2023 09:31:23 +0000 Subject: [PATCH 26/42] FIX --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d670ca6c88..cbc4996618 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 @@ -330,7 +330,7 @@ class FluentClientGenerator( rustTemplate( """ /// Sends a request with this input using the given client. - pub async fn send_with<#{generics_decl:W}>(self, client: &crate::Client#{generics_decl:W}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with#{generics_decl:W}(self, client: &crate::Client#{generics_decl:W}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; From 7bd13651cbdd394de4097c54c9446ff79a1494c0 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Sat, 3 Jun 2023 09:46:35 +0000 Subject: [PATCH 27/42] asdf --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cbc4996618..fc8ab05567 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 @@ -343,7 +343,7 @@ class FluentClientGenerator( } else { RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") }, - "generics_decl" to generics.decl, + "generics_decl" to generics.smithyInst, "Operation" to operationSymbol, "OperationError" to errorType, "OperationOutput" to outputType, From e5cd52fea2f224108e0f212d342c108c886f9501 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Sat, 3 Jun 2023 13:31:55 +0000 Subject: [PATCH 28/42] update --- .../client/smithy/generators/client/FluentClientGenerator.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 fc8ab05567..fd694d8e67 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 @@ -325,12 +325,11 @@ class FluentClientGenerator( // Filter out any derive that isn't Clone. Then add a Debug derive // input name val fnName = clientOperationFnName(operation, symbolProvider) - implBlock(symbolProvider.symbolForBuilder(input)) { rustTemplate( """ /// Sends a request with this input using the given client. - pub async fn send_with#{generics_decl:W}(self, client: &crate::Client#{generics_decl:W}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}>> + pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> #{send_bounds:W} { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; @@ -343,7 +342,6 @@ class FluentClientGenerator( } else { RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") }, - "generics_decl" to generics.smithyInst, "Operation" to operationSymbol, "OperationError" to errorType, "OperationOutput" to outputType, From 2e8342257459ee7cbafcb6403d8ccc7e8da1bc9d Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 13:56:56 +0000 Subject: [PATCH 29/42] update --- .../client/FluentClientGenerator.kt | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) 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 fd694d8e67..45a6782993 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 @@ -23,6 +23,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter +import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asArgumentType import software.amazon.smithy.rust.codegen.core.rustlang.asOptional import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape @@ -326,7 +327,8 @@ class FluentClientGenerator( // input name val fnName = clientOperationFnName(operation, symbolProvider) implBlock(symbolProvider.symbolForBuilder(input)) { - rustTemplate( + if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + rustTemplate( """ /// Sends a request with this input using the given client. pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> @@ -336,19 +338,36 @@ class FluentClientGenerator( fluent_builder.send().await } """, - *preludeScope, - "RawResponseType" to if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { - RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response") - } else { - RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") - }, - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SdkError" to RuntimeType.sdkError(runtimeConfig), - "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), - "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), - ) + *preludeScope, + "RawResponseType" to RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response"), + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier) + + ) + } else { + rustTemplate( + """ + /// Sends a request with this input using the given client. + pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> { + let mut fluent_builder = client.$fnName(); + fluent_builder.inner = self; + fluent_builder.send().await + } + """, + *preludeScope, + "RawResponseType" to RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse"), + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig) + ) + + } } val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug From 212506cd68109e53218b72e6d0cd75eedb051a9e Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 14:56:30 +0000 Subject: [PATCH 30/42] update --- .../client/FluentClientGenerator.kt | 60 ++++++++----------- .../generators/client/FluentClientGenerics.kt | 16 +++++ 2 files changed, 42 insertions(+), 34 deletions(-) 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 45a6782993..8d4caba66b 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 @@ -23,7 +23,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.asArgumentType import software.amazon.smithy.rust.codegen.core.rustlang.asOptional import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape @@ -327,47 +326,40 @@ class FluentClientGenerator( // input name val fnName = clientOperationFnName(operation, symbolProvider) implBlock(symbolProvider.symbolForBuilder(input)) { - if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { - rustTemplate( - """ - /// Sends a request with this input using the given client. - pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> - #{send_bounds:W} { - let mut fluent_builder = client.$fnName(); - fluent_builder.inner = self; - fluent_builder.send().await + fun takeOutWhereClause(s: String): String { + val n = s.indexOf("where\n") + if (n == -1) { + return s + } else { + return s.removeRange(0, n) } - """, - *preludeScope, - "RawResponseType" to RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response"), - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SdkError" to RuntimeType.sdkError(runtimeConfig), - "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), - "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier) - - ) - } else { - rustTemplate( + } + rustTemplate( """ /// Sends a request with this input using the given client. - pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> { + pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> + #{send_bounds:W}, + #{boundsWithoutWhereClause:W} + { let mut fluent_builder = client.$fnName(); fluent_builder.inner = self; fluent_builder.send().await } """, - *preludeScope, - "RawResponseType" to RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse"), - "Operation" to operationSymbol, - "OperationError" to errorType, - "OperationOutput" to outputType, - "SdkError" to RuntimeType.sdkError(runtimeConfig), - "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig) - ) - - } + *preludeScope, + "RawResponseType" to if (codegenContext.smithyRuntimeMode.defaultToMiddleware) { + RuntimeType.smithyHttp(runtimeConfig).resolve("operation::Response") + } else { + RuntimeType.smithyRuntimeApi(runtimeConfig).resolve("client::orchestrator::HttpResponse") + }, + "Operation" to operationSymbol, + "OperationError" to errorType, + "OperationOutput" to outputType, + "SdkError" to RuntimeType.sdkError(runtimeConfig), + "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), + "boundsWithoutWhereClause" to generics.boundsWithoutWhereClause, + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier) + ) } val derives = baseDerives.filter { it == RuntimeType.Clone } + RuntimeType.Debug diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index d37fb89057..d953f9e010 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -34,6 +34,9 @@ interface FluentClientGenerics { /** Convert this `FluentClientGenerics` into the more general `RustGenerics` */ fun toRustGenerics(): RustGenerics + + /** Bounds without where clause. A clever hack to implement `fn send_with`. **/ + val boundsWithoutWhereClause: Writable } class NoClientGenerics(private val runtimeConfig: RuntimeConfig) : FluentClientGenerics { @@ -55,6 +58,8 @@ class NoClientGenerics(private val runtimeConfig: RuntimeConfig) : FluentClientG /** Trait bounds */ override val bounds = writable { } + override val boundsWithoutWhereClause = writable {} + /** Bounds for generated `send()` functions */ override fun sendBounds( operation: Symbol, @@ -102,6 +107,17 @@ data class FlexibleClientGenerics( ) } + override val boundsWithoutWhereClause = writable { + rustTemplate( + """ + C: #{client}::bounds::SmithyConnector, + M: #{client}::bounds::SmithyMiddleware, + R: #{client}::retry::NewRequestPolicy, + """, + "client" to client, + ) + } + /** Bounds for generated `send()` functions */ override fun sendBounds(operation: Symbol, operationOutput: Symbol, operationError: Symbol, retryClassifier: RuntimeType): Writable = writable { rustTemplate( From 54517f17ed67193a761dc9fb8e04e3165a4ea31b Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 14:57:25 +0000 Subject: [PATCH 31/42] asdf --- .../client/smithy/generators/client/FluentClientGenerics.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index d953f9e010..26b92078ff 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -35,7 +35,7 @@ interface FluentClientGenerics { /** Convert this `FluentClientGenerics` into the more general `RustGenerics` */ fun toRustGenerics(): RustGenerics - /** Bounds without where clause. A clever hack to implement `fn send_with`. **/ + /** bounds without where clause. If bounds does is not prefixed with `where\n`, then it gets the same value. **/ val boundsWithoutWhereClause: Writable } From 140c04067c377e8a1f0e195bb9d15d49b639cf01 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 15:11:22 +0000 Subject: [PATCH 32/42] precommit --- .../client/smithy/generators/client/FluentClientGenerator.kt | 2 +- .../client/smithy/generators/client/FluentClientGenerics.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8d4caba66b..72e317e433 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 @@ -358,7 +358,7 @@ class FluentClientGenerator( "SdkError" to RuntimeType.sdkError(runtimeConfig), "SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig), "boundsWithoutWhereClause" to generics.boundsWithoutWhereClause, - "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier) + "send_bounds" to generics.sendBounds(operationSymbol, outputType, errorType, retryClassifier), ) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index 26b92078ff..31d91edbe6 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -113,7 +113,7 @@ data class FlexibleClientGenerics( C: #{client}::bounds::SmithyConnector, M: #{client}::bounds::SmithyMiddleware, R: #{client}::retry::NewRequestPolicy, - """, + """, "client" to client, ) } From 338ae8f5c723d37c3c218744309c06491f0d8d4d Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 15:28:28 +0000 Subject: [PATCH 33/42] update --- .../smithy/generators/client/FluentClientGenerator.kt | 6 +++++- .../client/smithy/generators/client/FluentClientGenerics.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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 72e317e433..d9c608bdd3 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 @@ -334,11 +334,15 @@ class FluentClientGenerator( return s.removeRange(0, n) } } + val addThing = "" + if (generics.inst != generics.boundsWithoutWhereClause) { + addThing = "," + } rustTemplate( """ /// Sends a request with this input using the given client. pub async fn send_with${generics.inst}(self, client: &crate::Client${generics.inst}) -> #{Result}<#{OperationOutput}, #{SdkError}<#{OperationError}, #{RawResponseType}>> - #{send_bounds:W}, + #{send_bounds:W} #{boundsWithoutWhereClause:W} { let mut fluent_builder = client.$fnName(); diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index 31d91edbe6..ef1292f6ae 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -128,7 +128,7 @@ data class FlexibleClientGenerics( #{OperationOutput}, #{OperationError}, #{RetryClassifier} - > + >, """, "client" to client, "Operation" to operation, From 3d29cf9f78c21c54ae7ff2dabce7e19179660a44 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 7 Jun 2023 15:34:23 +0000 Subject: [PATCH 34/42] asdf --- .../client/smithy/generators/client/FluentClientGenerator.kt | 4 ---- 1 file changed, 4 deletions(-) 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 d9c608bdd3..85cb912425 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 @@ -334,10 +334,6 @@ class FluentClientGenerator( return s.removeRange(0, n) } } - val addThing = "" - if (generics.inst != generics.boundsWithoutWhereClause) { - addThing = "," - } rustTemplate( """ /// Sends a request with this input using the given client. From 8fc4751ec2fa13267f5223a5783823d42de1d9f8 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Tue, 13 Jun 2023 12:59:59 +0900 Subject: [PATCH 35/42] Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt Co-authored-by: John DiSanti --- .../smithy/generators/client/FluentClientGenerator.kt | 8 -------- 1 file changed, 8 deletions(-) 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 85cb912425..6e562b3317 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 @@ -326,14 +326,6 @@ class FluentClientGenerator( // input name val fnName = clientOperationFnName(operation, symbolProvider) implBlock(symbolProvider.symbolForBuilder(input)) { - fun takeOutWhereClause(s: String): String { - val n = s.indexOf("where\n") - if (n == -1) { - return s - } else { - return s.removeRange(0, n) - } - } rustTemplate( """ /// Sends a request with this input using the given client. From ddc8c718abcfb436b7bca0d1a92e19ed438117f6 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Tue, 13 Jun 2023 05:35:49 +0000 Subject: [PATCH 36/42] update --- .../client/smithy/generators/client/FluentClientGenerics.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index ef1292f6ae..cdd5ca1e1e 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -99,11 +99,9 @@ data class FlexibleClientGenerics( rustTemplate( """ where - C: #{client}::bounds::SmithyConnector, - M: #{client}::bounds::SmithyMiddleware, - R: #{client}::retry::NewRequestPolicy, + #{client} """, - "client" to client, + "client" to boundsWithoutWhereClause, ) } From 3531f10d13a56699341b1b36dd7e11226391404e Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Tue, 13 Jun 2023 05:36:45 +0000 Subject: [PATCH 37/42] update --- .../client/smithy/generators/client/FluentClientGenerics.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt index cdd5ca1e1e..a0b9f15c1a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerics.kt @@ -99,9 +99,9 @@ data class FlexibleClientGenerics( rustTemplate( """ where - #{client} + #{bounds} """, - "client" to boundsWithoutWhereClause, + "bounds" to boundsWithoutWhereClause, ) } From 4251f9798684dbe42dfe6f6861de6faa8f4d5a9c Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 14 Jun 2023 02:45:09 +0000 Subject: [PATCH 38/42] update changelog --- CHANGELOG.next.toml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 34fc2b7659..af26b7c5c4 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -375,3 +375,30 @@ let app = PokemonService::builder_with_plugins(scoped_plugin, IdentityPlugin) references = ["smithy-rs#2740"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "hlbarber" + +[[smithy-rs]] +message = """ +- rust runtime + - Implements serde support to `Number`, `Blob`, `Document`, `DateTime` +- Core codegen code + - Add a function on `Input` types for sending requests +- Client codegen code + - add `serde` as dependency behind feature gate +""" +author = "thomas-k-cameron" +references = ["smithy-rs#2652", "smithy-rs#2646", "smithy-rs#2645", "smithy-rs#2647", "smithy-rs#2638", "smithy-rs#2614"] +meta = { "breaking" = false, "tada" = false, "bug" = false } + +[[aws-sdk-rust]] +message = """ +- rust runtime + - Implements serde support to `Number`, `Blob`, `Document`, `DateTime` +- Core codegen code + - Add a function on `Input` types for sending requests +- Client codegen code + - add `serde` as dependency behind feature gate +""" +author = "thomas-k-cameron" +references = ["smithy-rs#2652", "smithy-rs#2646", "smithy-rs#2645", "smithy-rs#2647", "smithy-rs#2638", "smithy-rs#2614"] +meta = { "breaking" = false, "tada" = false, "bug" = false } + From 0e478b22850525653cd9b8d75972c7eaed188e46 Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 14 Jun 2023 12:39:58 +0000 Subject: [PATCH 39/42] FIX --- CHANGELOG.next.toml | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index af26b7c5c4..b1be40da5b 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -15,7 +15,7 @@ message = "Fix bug in AWS JSON 1.x routers where, if a service had more than 14 operations, the router was created without the route for the 15th operation." author = "thor-bjorgvinsson" references = ["smithy-rs#2733"] -meta = { "breaking" = false, "tada" = false, "bug" = true, "target" ="server" } +meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "server" } [[aws-sdk-rust]] message = "Remove native-tls and add a migration guide." @@ -66,7 +66,7 @@ author = "jdisanti" [[smithy-rs]] message = "For event stream operations, the `EventStreamSender` in inputs/outputs now requires the passed in `Stream` impl to implement `Sync`." references = ["smithy-rs#2673"] -meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all"} +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" } author = "jdisanti" [[aws-sdk-rust]] @@ -143,7 +143,7 @@ author = "jdisanti" [[smithy-rs]] message = "Update MSRV to Rust 1.68.2" references = ["smithy-rs#2745"] -meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all"} +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" } author = "jdisanti" [[smithy-rs]] @@ -377,28 +377,18 @@ meta = { "breaking" = true, "tada" = false, "bug" = false } author = "hlbarber" [[smithy-rs]] -message = """ -- rust runtime - - Implements serde support to `Number`, `Blob`, `Document`, `DateTime` -- Core codegen code - - Add a function on `Input` types for sending requests -- Client codegen code - - add `serde` as dependency behind feature gate -""" +message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" author = "thomas-k-cameron" -references = ["smithy-rs#2652", "smithy-rs#2646", "smithy-rs#2645", "smithy-rs#2647", "smithy-rs#2638", "smithy-rs#2614"] meta = { "breaking" = false, "tada" = false, "bug" = false } +references = [ + "smithy-rs#2647", + "smithy-rs#2645", + "smithy-rs#2646", + "smithy-rs#2616", +] [[aws-sdk-rust]] -message = """ -- rust runtime - - Implements serde support to `Number`, `Blob`, `Document`, `DateTime` -- Core codegen code - - Add a function on `Input` types for sending requests -- Client codegen code - - add `serde` as dependency behind feature gate -""" +message = "Add a function on `Input` types for sending requests" author = "thomas-k-cameron" -references = ["smithy-rs#2652", "smithy-rs#2646", "smithy-rs#2645", "smithy-rs#2647", "smithy-rs#2638", "smithy-rs#2614"] -meta = { "breaking" = false, "tada" = false, "bug" = false } - +references = ["smithy-rs#2652"] +meta = { "breaking" = false, "tada" = false, "bug" = false, target = "client" } From fa6e681d85126fb26f1f591a6d57de35515436ac Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 14 Jun 2023 13:10:51 +0000 Subject: [PATCH 40/42] update --- CHANGELOG.next.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index b1be40da5b..e137a80899 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -387,6 +387,17 @@ references = [ "smithy-rs#2616", ] +[[aws-sdk-rust]] +message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" +author = "thomas-k-cameron" +meta = { "breaking" = false, "tada" = false, "bug" = false, target = "all" } +references = [ + "smithy-rs#2647", + "smithy-rs#2645", + "smithy-rs#2646", + "smithy-rs#2616", +] + [[aws-sdk-rust]] message = "Add a function on `Input` types for sending requests" author = "thomas-k-cameron" From ef451bb6a679f82515721f6a738748211676767f Mon Sep 17 00:00:00 2001 From: Thomas Cameron Date: Wed, 14 Jun 2023 13:20:00 +0000 Subject: [PATCH 41/42] update --- CHANGELOG.next.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index e137a80899..274adc6875 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -379,7 +379,7 @@ author = "hlbarber" [[smithy-rs]] message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" author = "thomas-k-cameron" -meta = { "breaking" = false, "tada" = false, "bug" = false } +meta = { "breaking" = false, "tada" = false, "bug" = false, target = "all" } references = [ "smithy-rs#2647", "smithy-rs#2645", @@ -390,7 +390,7 @@ references = [ [[aws-sdk-rust]] message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" author = "thomas-k-cameron" -meta = { "breaking" = false, "tada" = false, "bug" = false, target = "all" } +meta = { "breaking" = false, "tada" = false, "bug" = false } references = [ "smithy-rs#2647", "smithy-rs#2645", @@ -402,4 +402,4 @@ references = [ message = "Add a function on `Input` types for sending requests" author = "thomas-k-cameron" references = ["smithy-rs#2652"] -meta = { "breaking" = false, "tada" = false, "bug" = false, target = "client" } +meta = { "breaking" = false, "tada" = false, "bug" = false } From d8c5135c6327bf1c91cd388e1d333475bee17ceb Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 14 Jun 2023 09:55:38 -0700 Subject: [PATCH 42/42] Update CHANGELOG.next.toml --- CHANGELOG.next.toml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 274adc6875..b5028732ba 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -377,9 +377,9 @@ meta = { "breaking" = true, "tada" = false, "bug" = false } author = "hlbarber" [[smithy-rs]] -message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" +message = "Implement unstable serde support for the `Number`, `Blob`, `Document`, `DateTime` primitives" author = "thomas-k-cameron" -meta = { "breaking" = false, "tada" = false, "bug" = false, target = "all" } +meta = { "breaking" = false, "tada" = true, "bug" = false, target = "all" } references = [ "smithy-rs#2647", "smithy-rs#2645", @@ -388,9 +388,9 @@ references = [ ] [[aws-sdk-rust]] -message = "Implements serde support to `Number`, `Blob`, `Document`, `DateTime`" +message = "Implement unstable serde support for the `Number`, `Blob`, `Document`, `DateTime` primitives" author = "thomas-k-cameron" -meta = { "breaking" = false, "tada" = false, "bug" = false } +meta = { "breaking" = false, "tada" = true, "bug" = false } references = [ "smithy-rs#2647", "smithy-rs#2645", @@ -398,8 +398,14 @@ references = [ "smithy-rs#2616", ] +[[smithy-rs]] +message = "Add a `send_with` function on `-Input` types for sending requests without fluent builders" +author = "thomas-k-cameron" +references = ["smithy-rs#2652"] +meta = { "breaking" = false, "tada" = true, "bug" = false, target = "client" } + [[aws-sdk-rust]] -message = "Add a function on `Input` types for sending requests" +message = "Add a `send_with` function on `-Input` types for sending requests without fluent builders" author = "thomas-k-cameron" references = ["smithy-rs#2652"] -meta = { "breaking" = false, "tada" = false, "bug" = false } +meta = { "breaking" = false, "tada" = true, "bug" = false }