-
Notifications
You must be signed in to change notification settings - Fork 214
Add send_with method to fluent builders #2652
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
Changes from 11 commits
88b3c43
82d296c
5cc6ac9
900cf67
72ed5b7
f701ae1
78d2e0b
356bde7
c9a4ae0
893692a
c2cce08
48c04f8
bbd94ba
75e84e7
7115727
ad8f413
d1069dc
2cb1e9b
663dff3
8b38afc
525f572
e3367dd
dc21f19
5972800
54a187b
e850ea2
8b2877e
ca47afe
3bd1a7b
a0a4651
299e5ec
605689e
ef38bbd
857f3d4
7bd1365
e5cd52f
7908333
2e83422
212506c
54517f1
140c040
338ae8f
edc62e8
3d29cf9
7f44d06
6cd4b6b
11af526
8fc4751
20ea34b
ddc8c71
3531f10
08440b8
c76dada
79662af
4251f97
0e478b2
fa6e681
ef451bb
d8c5135
073d873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,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( | ||
|
@@ -370,6 +372,43 @@ 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to go in the other direction and have an input take a client to form a fluent builder? Something like: SomeInput::builder()
.some_field("foo")
.with_client(client) // returns the fluent builder corresponding to the SomeInput operation
.send()
.await My reasoning is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is lot better. I'm not quite sure if you can do this though. Let me investigate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I implemented like this. Example::builder().into_fluent_builder(client).send().await; Example: impl AddPermissionInputBuilder {
#[cfg(aws_sdk_unstable)]
/// Creates a fluent builder from this builder.
pub fn into_fluent_builder(self, client: &crate::Client) -> AddPermissionFluentBuilder {
let fluent_builder = client.add_permission();
fluent_builder.inner = self;
fluent_builder
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talking to the team a bit more about this, would making this into a SomeInput::builder()
.some_field("foo")
.send_with(&client)
.await |
||
self.inner = data; | ||
self | ||
} | ||
""", | ||
"AwsSdkUnstableAttribute" to Attribute.AwsSdkUnstableAttribute.inner, | ||
) | ||
} | ||
|
||
if (smithyRuntimeMode.generateMiddleware) { | ||
val middlewareScope = arrayOf( | ||
*preludeScope, | ||
|
Uh oh!
There was an error while loading. Please reload this page.