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 Accessors to Builders #2791

Closed
DavidSouther opened this issue Jun 20, 2023 · 0 comments · Fixed by #2792
Closed

Add Accessors to Builders #2791

DavidSouther opened this issue Jun 20, 2023 · 0 comments · Fixed by #2792
Assignees

Comments

@DavidSouther
Copy link
Contributor

Currently, there is no way to get the information in a Builder while creating a request. It would be nice to have some way to get that information. This would be helpful in testing, to be able to verify the contents of a Builder without mocking the request. It may also be useful for implementing a multi stage request, where one builder is passed through several functions that make changes to the request based on prior information.

For an example of a test that would be improved by this pattern, see this commit.

@DavidSouther DavidSouther self-assigned this Jun 20, 2023
github-merge-queue bot pushed a commit that referenced this issue Jun 21, 2023
…ers. (#2792)

This allows testing, as well as making decisions while creating
builders. The references are not mutable, so these props remain read
only keeping the Builder invariants.

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
Some operations are built up using various logic (for instance, choosing
an S3 bucket based on a logged in user). It is a lot of overhead to test
at the mock level, and the Debug formatting is typically not stable.
<!--- If it fixes an open issue, please link to the issue here -->
Closes #2791 

## Description
<!--- Describe your changes in detail -->
1. Add `get_foo(&self) -> &Option<Foo>` to Builders
2. Add `as_input(&self) -> &OperationInputBuilder` to Fluent Builders
3. Add `get_foo(&self) -> &Option<Foo>` to FluentBuilder which delegates
to Builders


## Testing
<!--- Please describe in detail how you tested your changes -->
Included unit tests, as well as [proof of concept
tests](DavidSouther/aws-doc-sdk-examples@017e8a2)
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [X] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [X] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: John DiSanti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant