Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add send_with method to fluent builders #2652

Merged
merged 60 commits into from
Jun 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
88b3c43
- Add feature gates
thomas-k-cameron Apr 27, 2023
82d296c
Add CfgUnstable feature gate
thomas-k-cameron Apr 27, 2023
5cc6ac9
add serde to runtime type
thomas-k-cameron Apr 27, 2023
900cf67
Merge commit '82d296c38fa6794e7a986639d82456f1587b185f' into RFC30/ru…
thomas-k-cameron Apr 27, 2023
72ed5b7
Merge commit '900cf67356e3d697cf2e330708e00810aa8665da' into RFC30/fe…
thomas-k-cameron Apr 27, 2023
f701ae1
add set field
thomas-k-cameron Apr 27, 2023
78d2e0b
Merge commit '72ed5b78f1018e64095cfded1f5a9e756edff9ac' into RFC30/ad…
thomas-k-cameron Apr 27, 2023
356bde7
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Apr 29, 2023
c9a4ae0
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron May 31, 2023
893692a
Update FluentClientGenerator.kt
thomas-k-cameron May 31, 2023
c2cce08
update
thomas-k-cameron May 31, 2023
48c04f8
update
thomas-k-cameron Jun 1, 2023
bbd94ba
update
thomas-k-cameron Jun 1, 2023
75e84e7
Update FluentClientGenerator.kt
thomas-k-cameron Jun 1, 2023
7115727
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 1, 2023
ad8f413
update fluent client
thomas-k-cameron Jun 2, 2023
d1069dc
fix
thomas-k-cameron Jun 2, 2023
2cb1e9b
update
thomas-k-cameron Jun 2, 2023
663dff3
update
thomas-k-cameron Jun 2, 2023
8b38afc
update
thomas-k-cameron Jun 2, 2023
525f572
update
thomas-k-cameron Jun 2, 2023
e3367dd
update
thomas-k-cameron Jun 2, 2023
dc21f19
update
thomas-k-cameron Jun 2, 2023
5972800
update
thomas-k-cameron Jun 2, 2023
54a187b
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 2, 2023
e850ea2
update
thomas-k-cameron Jun 2, 2023
8b2877e
update
thomas-k-cameron Jun 2, 2023
ca47afe
change input path
thomas-k-cameron Jun 2, 2023
3bd1a7b
update
thomas-k-cameron Jun 2, 2023
a0a4651
update
thomas-k-cameron Jun 2, 2023
299e5ec
FIX
thomas-k-cameron Jun 3, 2023
605689e
updater
thomas-k-cameron Jun 3, 2023
ef38bbd
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 3, 2023
857f3d4
FIX
thomas-k-cameron Jun 3, 2023
7bd1365
asdf
thomas-k-cameron Jun 3, 2023
e5cd52f
update
thomas-k-cameron Jun 3, 2023
7908333
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 7, 2023
2e83422
update
thomas-k-cameron Jun 7, 2023
212506c
update
thomas-k-cameron Jun 7, 2023
54517f1
asdf
thomas-k-cameron Jun 7, 2023
140c040
precommit
thomas-k-cameron Jun 7, 2023
338ae8f
update
thomas-k-cameron Jun 7, 2023
edc62e8
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 7, 2023
3d29cf9
asdf
thomas-k-cameron Jun 7, 2023
7f44d06
Merge branch 'RFC30/add-set-fields' of https://github.com/thomas-k-ca…
thomas-k-cameron Jun 7, 2023
6cd4b6b
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 8, 2023
11af526
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 11, 2023
8fc4751
Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/cod…
thomas-k-cameron Jun 13, 2023
20ea34b
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 13, 2023
ddc8c71
update
thomas-k-cameron Jun 13, 2023
3531f10
update
thomas-k-cameron Jun 13, 2023
08440b8
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 13, 2023
c76dada
Merge branch 'main' into RFC30/add-set-fields
jdisanti Jun 13, 2023
79662af
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 14, 2023
4251f97
update changelog
thomas-k-cameron Jun 14, 2023
0e478b2
FIX
thomas-k-cameron Jun 14, 2023
fa6e681
update
thomas-k-cameron Jun 14, 2023
ef451bb
update
thomas-k-cameron Jun 14, 2023
d8c5135
Update CHANGELOG.next.toml
jdisanti Jun 14, 2023
073d873
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron Jun 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function will be just generally useful, so I would say let's remove the unstable attribute from it. May as well keep the supporting machinery around for your other PRs though.

/// 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)
Expand Down Expand Up @@ -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(
Expand All @@ -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<std::vec::Vec<crate::types::FieldValue>>,
// 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,
Expand Down