Commit Graph

763 Commits

Author SHA1 Message Date
Zelda Hessler 312d190535
Update standard orchestrator retries with token bucket and more tests (#2764)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
addresses #2743 

## Description
<!--- Describe your changes in detail -->
- add more standard retry tests
- add optional standard retries token bucket

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
tests are included

----

_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 <jdisanti@amazon.com>
2023-06-13 23:49:43 +00:00
Russell Cohen 5473192d3f
Update runtime plugin trait (#2754)
## Motivation and Context
Update the RuntimePlugin trait based on discussion:
1. Methods are infallible
2. Split out `Config` and `Interceptors`
3. `ConfigBag` now has an explicit field `interceptor_state`
4. Refactor `ConfigBagAccessors` so that we can build the core around
the trait and keep the trait together with a `where Self` trick

## Description
- Update the `RuntimePlugin` trait
- Deal with resulting implications
## Testing
- [x] CI


----

_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 <jdisanti@amazon.com>
2023-06-13 19:43:03 +00:00
John DiSanti 8e37d42f3c
Unpin the `arbitrary` and `derive-arbitrary` dependencies (#2765)
These no longer need to be pinned since the current MSRV is compatible
with their latest versions.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-13 15:58:27 +00:00
John DiSanti cfff41a883
Upgrade MSRV to 1.68.2 (#2745)
## Motivation and Context
This PR upgrades the MSRV to 1.68.2.

## Checklist
- [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: Zelda Hessler <zhessler@amazon.com>
Co-authored-by: 82marbag <69267416+82marbag@users.noreply.github.com>
2023-06-13 15:23:04 +00:00
Zelda Hessler 8c4d186487
Update dependencies flagged by cargo audit (#2753)
Also, sort `Cargo.toml` dependencies if they were disordered.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-12 17:09:29 +00:00
Harry Barber 11cf41d944
Simplify `Plugin` trait (#2740)
## Motivation and Context

https://github.com/awslabs/smithy-rs/issues/2444

## Description

- Simplify `Plugin`, make it closer to `Layer`.
- Remove `Operation`.
2023-06-12 16:46:58 +00:00
82marbag 5eb0927514
OperationShape::NAME as ShapeId (#2678) (#2717)
See https://github.com/awslabs/smithy-rs/issues/2634

## 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
- [ ] 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._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Harry Barber <106155934+hlbarber@users.noreply.github.com>
2023-06-09 13:33:40 +00:00
Russell Cohen dabbfaa8e3
Add the ability to disable interceptors via the config bag (#2757)
This replaces the existing custom interceptor disable logic with shared
logic to allow generally disabling any public interceptors from Runtime
plugins. The previous behavior was very brittle because it relied
heavily on runtime plugin execution order.

## Motivation and Context
- simplify presigning behavior
- generalize logic to disable interceptors

## Description
Create `disable_interceptor` struct, which, when inserted into the
configuration bag can disable an interceptor via the `Interceptors`
execution interface.

## Testing
- ` (cd aws/sdk/build/aws-sdk/sdk/s3 && cargo test --test presigning)`

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] 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._
2023-06-08 17:31:52 +00:00
Russell Cohen 334891d98f
Remove Debug bound from struct definition (#2749)
## Description
the debug bound on the struct definition is redundant and is viral,
making the code harder to use

## Testing
code compiles


----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-07 13:31:39 +00:00
Russell Cohen 3285c43b42
Runtime config refactors (#2748)
## Motivation and Context
Part of refactoring config bag to work with the new RuntimePlugin API

## Description
- change config bag to a vector instead of a linked list

## Testing
- existing UTs

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-06 18:58:30 +00:00
Thomas Cameron 77395c3582
Add serde support to Blob type (#2647)
## Motivation and Context
This is a child PR of https://github.com/awslabs/smithy-rs/pull/2616

The changes that this PR introduces is same as the ones that were merged
to `unstable-serde-support` branch before.

Initially, we tried to make commit to unstable-serde-support branch and
merge changes one by one in small PRs. However, in order to make it up
to date with the main branch, we would need to go through a large PR of
over 700 files.

Thus, I decided to create individual PRs that commits directly to `main`
branch.

## Description
- Implements `serde` support to `Blob`

## Testing
- Test checks whether the serialized/de-serialized data matches with the
expected value

## Checklist
NA

----

_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 <johndisanti@gmail.com>
2023-06-06 16:16:56 +00:00
Thomas Cameron 74a7204123
Add serde support to date time (#2646)
## Motivation and Context
This is a child PR of https://github.com/awslabs/smithy-rs/pull/2616

The changes that this PR introduces is same as the ones that were merged
to `unstable-serde-support` branch before.

Initially, we tried to make commit to unstable-serde-support branch and
merge changes one by one in small PRs. However, in order to make it up
to date with the main branch, we would need to go through a large PR of
over 700 files.

Thus, I decided to create individual PRs that commits directly to `main`
branch.

## Description
- Implements `serde` support to `DateTime`

## Testing
- Test checks whether the serialized/de-serialized data matches with the
expected value

## Checklist
NA

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-05 19:25:27 +00:00
John DiSanti ccc3474d5b
Fix S3 presigning in the orchestrator (#2738)
## Motivation and Context
This PR fixes S3 presigning in the client orchestrator implementation. A
Polly presigning fix will come in a separate PR.

This PR also:
- Renames `ClientProtocolGenerator` to `OperationGenerator` to better
represent what its generating.
- Moves `OperationCustomization` into `codegen-client` since it is
client specific and unused by the server codegen.
- Deletes the `ProtocolGenerator` base class in `codegen-core` since it
wasn't adding any value.
- Adds the concept of stop points to the orchestrator so that
orchestration can be halted before transmitting a request.
- Adds `DisableInvocationIdInterceptor`,
`DisableRequestInfoInterceptor`, `DisableUserAgentInterceptor`, and
`HeaderSerializationSettings` config bag configs to facilitate
presigning requirements.
- Fixes compilation of all S3 and Polly tests when in orchestrator mode.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-02 17:01:18 -07:00
ysaito1001 500aef3957
Add SharedAsyncSleep wrapping Arc<dyn AsyncSleep> (#2742)
## Motivation and Context
Add `SharedAsyncSleep` wrapping `Arc<dyn AsyncSleep>` and update call
sites of `Arc<dyn AsyncSleep>` to use `SharedAsyncSleep`

## Description
Public APIs that take/return a trait object for `AsyncSleep` have been
using `Arc<dyn AsyncSleep>` in the codebase. This has a downside of
exposing a bare `Arc`, making it difficult to change the APIs in the
future without breaking backwards compatibility. This PR adds a newtype
wrapper `SharedAsyncSleep` that hides `Arc<dyn AsyncSleep>` to alleviate
the said issue (the idiom of having `SharedXXX` has been seen in the
codebase, e.g. `SharedTimeSource`, `SharedCredentialsProvider`, and so
on).

## Testing
- [x] Passed tests in CI

## 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: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-06-02 20:33:23 +00:00
Zelda Hessler 7ea3ed92f8
No really, add the standard retry strategy to the orchestrator (#2741)
## Description
<!--- Describe your changes in detail -->
This PR adds support for the Standard retry strategy. The standard
strategy will be inserted into a service's config bag if a retry config
was set. Otherwise, unless another retry strategy was already set, a
`NeverRetryStrategy` will be set. This seemed like a reasonable default,
but I'm open to suggestions.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
tests are included

---

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-02 15:18:10 +00:00
Zelda Hessler 303d99b688
Fix various small issues with the orchestrator (#2736)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
This change fixes many of the smaller issues I ran into during the
implementation of standard retries for the orchestrator. Merges from
`main` were getting difficult with my [other
PR](https://github.com/awslabs/smithy-rs/pull/2725) so I'm breaking
things up.

## Description
<!--- Describe your changes in detail -->
- when orchestrator attempt timeout occurs, error is now set in context
- update test connection to allow defining connection events with
optional latency simulation update orchestrator attempt loop to track
iteration count
- set request attempts from the attempt loop
- add comment explaining "rewind" step of making request attempts add
`doesnt_matter` method to `TypeErasedBox`, useful when testing update
tests to use the new `TypeErasedBox::doesnt_matter` method
- add more doc comments
- add `set_subsec_nanos` method to `DateTime`.
- I added this to make it easier to string-format a datetime that didn't
include the nanos.
- fix Invocation ID interceptor not inserting the expected header update
input type for `OperationError::other` to be more user-friendly
- add `test-util` feature to `aws-smithy-runtime-api`
- add `test-util` feature to `aws-runtime`
- fix presigining inlineable to pull in tower dep during codegen

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
tests have been updated where necessary
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-01 18:44:05 +00:00
Zelda Hessler 0cba3d892a
Update retry classifiers to act on InterceptorContext instead of OrchestratorError (#2737)
## Description
<!--- Describe your changes in detail -->
- update retry classifiers to act directly on the `InterceptorContext`
- add codegen method for inserting retry classifiers into the config bag
- update `InterceptorContext` to return options instead of panicking

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Tests were updated as needed.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-01 15:59:49 +00:00
ysaito1001 40612a9308
Move `config_bag` and `type_erasure` to `aws-smithy-types` (#2735)
## Motivation and Context
This PR moves types and traits in those modules to the
`aws-smithy-types` crate.

## Description
This is to prepare for the upcoming refactoring where `SdkConfig` and
service configs (and both of their builders) will be backed by
`ConfigBag`.

## Testing
- [x] Pass tests in CI


## 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~~

----

_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: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-05-31 21:49:52 +00:00
Russell Cohen 8c045d271c
Add support for TimeStreamWrite and TimeStreamQuery (#2707)
TODO:
- [x] docs
- [x] integration test (canary even?)
- [x] customize README for timestream
## Motivation and Context
- #613 
- https://github.com/awslabs/aws-sdk-rust/issues/114


## Description
This adds support for TSW and TSQ by adding endpoint discovery as a
customization. This is made much simpler by the fact that endpoint
discovery for these services **has no parameters** which means that
there is no complexity from caching the returned endpoint.

Customers call `.enable_endpoint_discovery()` on the client to create a
version of the client with endpoint discovery enabled. This returns a
new client and a Reloader from which customers must spawn the reload
task if they want endpoint discovery to rerun.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- 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 -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] 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._
2023-05-31 18:08:51 +00:00
Harry Barber 7347c58458
Remove `PollError` from server type parameters (#2457)
## Motivation and Context

https://github.com/awslabs/smithy-rs/issues/2444

## Description

Remove `PollError` from the implementation and documentation.
2023-05-30 20:13:53 +00:00
Thomas Cameron 840221dddb
Add serde support to number type (#2645)
## Motivation and Context
This is a child PR of https://github.com/awslabs/smithy-rs/pull/2616

The changes that this PR introduces is same as the ones that were merged
to `unstable-serde-support` branch before.

Initially, we tried to make commit to unstable-serde-support branch and
merge changes one by one in small PRs. However, in order to make it up
to date with the main branch, we would need to go through a large PR of
over 700 files.

Thus, I decided to create individual PRs that commits directly to `main`
branch.

## Description
- Implements `serde` support to `Number`

## Testing
- Test checks whether the serialized/de-serialized data matches with the
expected value

## Checklist
NA

----

_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 <johndisanti@gmail.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-05-30 18:47:41 +00:00
Russell Cohen b30b063e1e
Integrate TimeSource into the orchestrator and middleware (breaking change warning is spurious) (#2728)
## Motivation and Context
- #2262 
- #2087 
- #2707 

This adds `TimeSource` in SDK and service configs so we can effectively
control time when executing requests with the SDK at the client level.

_note:_ the breaking change is in a trait implementation of a struct
we're going to delete, not a real breaking change

## Description
- Add `SharedTimeSource` and use it in SdkConfig / `aws-config` /
<service>::Config
- Wire up the signer and other uses of `SystemTime::now()` that I could
find
- track down broken tests

## Testing
- [x] various unit tests that all still pass

## 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._
2023-05-30 15:52:11 +00:00
david-perez cf292d5817
Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685) (#2691)
This is https://github.com/awslabs/smithy-rs/pull/2685 again, which was
merged
prematurely and reverted in
https://github.com/awslabs/smithy-rs/pull/2690.

This time we won't merge it until it's due time.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-30 14:47:20 +00:00
Thor Bjorgvinsson 5126a61489
Fix tiny_map from_iter where one operation was being dropped (#2733)
## Motivation and Context
15th operation was being dropped when iterator was being read into a
TinyMap

## Description
The 15th operation was being dropped when the if statement was caught
because the operation had been popped of the iterator but hadn't been
added to the vec of operations before the two iterators were being
chained and collected into a

## Testing
Added unit tests that reproduced the issue and verified that the issue
is fixed

## 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
- [ ] 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: david-perez <d@vidp.dev>
Co-authored-by: Fahad Zubair <fahadzubair@gmail.com>
2023-05-30 11:46:07 +00:00
John DiSanti d91232667f
Set up a default connector for generic clients in the orchestrator implementation (#2693)
## Motivation and Context
This PR makes generic clients default to the built-in rustls HTTPS
connector when no override is provided, but only for the new
orchestrator implementation.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-26 17:12:55 +00:00
John DiSanti c6e537969e
Fix event streams in the orchestrator implementation (#2673)
## Motivation and Context
This PR gets event streams working in the client orchestrator
implementation, and depends on #2671.

The orchestrator's `TypeErasedBox` enforces a `Send + Sync` requirement
on inputs and outputs. For the most part, this isn't an issue since
almost all generated inputs/outputs are `Send + Sync`, but it turns out
the `EventStreamSender` wasn't `Sync` due to an omission of the `Sync`
bound. Thus, this PR is a breaking change, as it adds a `Sync`
requirement for anyone who passes a stream to an event stream operation.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-26 16:46:39 +00:00
John DiSanti 8773a70428
Simplify event stream message signer configuration (#2671)
## Motivation and Context

This PR creates a `DeferredSigner` implementation that allows for the
event stream message signer to be wired up by the signing implementation
later in the request lifecycle rather than by adding an event stream
signer method to the config.

Refactoring this brings the middleware client implementation closer to
how the orchestrator implementation will work, which unblocks the work
required to make event streams work in the orchestrator.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-26 15:49:56 +00:00
82marbag d083c6f271
remove native-tls (#2675)
* Show how to plug a connector
* For TLS: keep rustls, only

## 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._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-05-26 10:18:29 +00:00
John DiSanti f89b14337c
Port Glacier customizations to the orchestrator (#2704)
## Motivation and Context
This PR gets the Glacier integration tests to pass against the
orchestrator implementation by porting the Glacier customizations from
`make_operation` changes to interceptors.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-25 19:50:37 +00:00
John DiSanti 3c68521cd9
Remove middleware code when generating the orchestrator exclusively (#2723)
## Motivation and Context
This PR removes all the middleware code from generated clients when the
`smithy.runtime.mode` flag is set to `orchestrator`. It also changes the
`aws-config` crate to use the fluent client instead of the Smithy client
for STS and SSO based credential providers.

The `polly` test no longer compiles in orchestrator mode with these
changes since presigning directly references middleware code. This will
get fixed in a later PR.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-25 17:12:51 +00:00
Russell Cohen c0345a5b5f
Add timesource abstration to aws-smithy-async (#2721)
## Motivation and Context
- Controlling time is required for several testing use cases
- #2087 
- #2262 

## Description
Introduce `TimeSource` trait, a real implementation, and a test
implementation.

## Testing
These changes are used in the timestream PR

## Checklist
No changelog, these changes have no impact since the code is not yet
utilized

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-23 18:16:28 +00:00
ysaito1001 61b7a774b4
Allow integration tests to run in both runtime modes (#2709)
## Description
This will allow integration tests under `aws/sdk/integration-tests` to
run in both smithy runtime modes. Prior to the PR, the integration tests
use `map_operation` to customize operations, which is not supported in
the orchestrator, preventing us from running them in the orchestrator
mode. Fortunately, all the usages of `map_operation` in the integration
tests involve setting a test request time and a test user agent in a
property bag.

This PR stops using `map_operation` in those tests and instead
introduces separate test helper methods in both runtime modes: one for
setting a test request and the other for setting a test user agent. They
allow the integration tests to compile and run in both modes.

Note that the integration tests in the orchestrator do not necessarily
pass at this time. We'll address the failures subsequently.

## Testing
Confirmed integration tests continue passing with the changes when run
in the middleware . Confirmed those complied (but not necessarily
passed) in the orchestrator.

----

_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: Yuki Saito <awsaito@amazon.com>
2023-05-19 18:29:39 +00:00
John DiSanti 9bfe936fbc
Make the SDK ad hoc tests pass against the orchestrator (#2708)
## Motivation and Context
This PR refactors the client protocol test generator machinery to use a
client instead of calling `make_operation` directly, and then fixes the
ad hoc tests for the orchestrator.

The ad hoc tests revealed that overriding the signing region/service via
endpoint config was lost when porting SigV4 signing to the orchestrator,
so this PR updates the SigV4 `HttpRequestSigner` implementation to
restore this functionality. It is doing this in the signer directly
rather than via an interceptor since it should only run this logic when
SigV4 is the selected auth scheme.

Other notable changes:
- Adds `--no-fail-fast` arg to `cargoTest` targets so that all Rust
tests run in CI rather than stopping on the first failure
- Changes `EndpointResolver::resolve_and_apply_endpoint` to just
`resolve_endpoint` so that the orchestrator can place the endpoint
config into the request state, which is required for the signer to make
use of it
- Adds a `set_region` method to SDK service configs
- Deletes the API Gateway model and integration test from the SDK smoke
test since it is covered by the ad hoc tests
- Adds a comment explaining where the API Gateway model comes from in
the ad hoc tests
- Adds a `smithy.runtime.mode` Gradle property to `aws:sdk` and
`aws:sdk-adhoc-test` to trivially switch between middleware and
orchestrator when testing/generating locally

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-19 16:58:28 +00:00
Zelda Hessler 4cc4fb1181
fix type-erasure bug for errors (#2713)
## Description
<!--- Describe your changes in detail -->
We were unintentionally double-boxing type-erased errors. This fix
correctly de-references the errors, solving the problem.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
I wrote a test.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-18 17:42:36 +00:00
Zelda Hessler a9e22ce17a
Fix: orchestrator flow (#2699)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Necessary before we can implement retries.

## Description
<!--- Describe your changes in detail -->
I noticed that we weren't handling the flow quite right when errors
occurred. This PR fixes that and adds interceptor-based tests to ensure
things are working right. I still think we could use more tests but the
PR is already quite large.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This PR contains tests

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-18 14:59:36 +00:00
John DiSanti a514793fa8
Port API Gateway customizations to the orchestrator (#2705)
## Motivation and Context
This PR ports the API Gateway `Accept` header customization into the
orchestrator implementation. The original implementation of this
customization in #287 didn't include a test, so this PR also adds an
integration test for it.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-17 23:31:35 +00:00
ysaito1001 3b95b9706c
Port customizable operation to orchestrator (#2706)
## Motivation and Context
Port [Customizable
Operation](https://github.com/awslabs/smithy-rs/pull/1647) to
orchestrator

## Description
This PR implements `CustomizableOperation` in the orchestrator. Just
like the counterpart in the middleware, it is created when the
`customize` method (in the orchestrator mode) on a fluent builder is
called. The `customize` method in the orchestrator could technically be
made a synchronous method because there is no need to create an
operation, which requires `async`, therefore making the `customize`
method in the middleware `async`. However, during the transition from
the middleware to the orchestrator, the integration tests
([example](31c152d9af/aws/sdk/integration-tests/s3/tests/signing-it.rs (L36)))
need to be able to run in both modes. For this reason, the `customize`
method in the orchestrator is temporarily marked as `async`.

Regarding methods defined on the new `CustomizableOperation`, they
include `mutate_request` and `map_request` from the counterpart in the
middleware. However, it did not port `map_operation` because there is no
operation to map on. Most use cases for `map_operation` is put things in
a property bag. The new `CustomizableOperation` provides an
`interceptor` method to accomplish the same, i.e putting things in a
config bag.

Finally, for integration tests to run in both modes, the code gen emits
the implementation of the `customize` method differently depending on
the active Smithy runtime mode, similar to what the implementation of
`send` method does.

## Testing
Added one `sra-test` for mutating a request.

----

_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: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-05-17 21:31:23 +00:00
Zelda Hessler 33e1a67b22
add: request information header interceptors and plugins (#2641)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#1793 

## Description
<!--- Describe your changes in detail -->
This adds a runtime plugin which provides support for a request info
header.
The plugin depends upon three interceptors:
- `ServiceClockSkewInterceptor` - tracks the approximate latency between
the client and server
- `RequestAttemptsInterceptor` - tracks the number of attempts made for
a single operation
- `RequestInfoInterceptor` - adds request metadata to outgoing requests.
Works by setting a header.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
I wrote one test but need to implement several more

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-17 16:30:45 +00:00
ysaito1001 92b26df402
Allow for configuring interceptors on generic client (#2697)
## Description
This PR allows users to pass-in interceptors to a generic client.
Client-level configured interceptors are eventually added to
`client_interceptors` and operation-level interceptors to
`operation_interceptors`, both of which are fields in the
`aws-smithy-runtime-api::client::interceptors::Interceptors`. The
relevant code is generated only in the orchestrator mode.

The SDK registers a default set of (client-level & operation-level)
interceptors, and the passed-in interceptors by a user will run _after_
those default interceptors.

## Testing
- Added integration tests `operation_interceptor_test` and
`interceptor_priority` in `sra_test`.

----

_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: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-05-12 18:12:05 +00:00
82marbag c2da4cf16d
Revert "OperationShape::NAME as ShapeId (#2678)" (#2698)
This reverts https://github.com/awslabs/smithy-rs/pull/2678.

It is a breaking change and it will be included in the next release.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-12 09:07:52 +00:00
John DiSanti 0e90d6502d
Fix KMS tests by fixing `Send` bound on fluent send method (#2695)
## Motivation and Context
This PR fixes the KMS tests when the generating code in orchestrator
mode by ensuring the `Future` returned by `send()` implements `Send`,
and also adds a codegen unit test for this so that it's checked at the
generic client level.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-11 19:50:13 +00:00
82marbag 9b340fb89e
OperationShape::NAME as ShapeId (#2678)
See https://github.com/awslabs/smithy-rs/issues/2634

## 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
- [ ] 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._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-05-11 15:02:03 +00:00
david-perez a78ac591fe
Revert "Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685)" (#2690)
This reverts commit 04db5e3572.

This is a breaking change that needs to wait to be merged in until the
next breaking release.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 10:41:28 +00:00
david-perez 04db5e3572
Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685)
This patch also removes the unneeded dependency on `lambda_runtime` by
`aws-smithy-http-server-python`.

This patch also refactors `LambdaHandler`'s `convert_event` to avoid
cloning the URI path when not needed.

This is a breaking change. See #2676 why.

This patch also bumps `aws-smithy-http-server` dependency on `mime` to
0.3.4.

`cargo +nightly-2022-11-16 minimal-versions check --all-features`
otherwise
fails when using 0.3.0, because we require `impl fmt::Display for
mime::FromStrError`, which was first introduced in 0.3.4.

As to why `minimal-versions` is now picking `mime` 0.3.0 with this
patch, it's
because in `lambda_http` 0.7.3, they had [`mime =

"0.3.16"`](99dba64472/lambda-http/Cargo.toml (L35-L35)),
and in `lambda_http` 0.8.0, they've now relaxed that to [`mime =

"0.3"`](393d6447be/lambda-http/Cargo.toml (L36)).


## 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

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 09:39:15 +00:00
david-perez c3e6ed96df
Document compatibility of `aws-smithy-http-server` with `lambda_http` (#2683)
See #2676.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 08:18:21 +00:00
Henrik Sjööh 2b165037fd
Use `as_nanos` in `Ord` impl for `DateTime` (#2656)
## Motivation and Context
This PR adresses on [feedback from my previous
PR](https://github.com/awslabs/smithy-rs/pull/2653#pullrequestreview-1404515899).


## Description
- use `as_nanos` in `Ord` impl for `DateTime` instead of manual impl.

## Testing
- add proptest that checks that `Ord` impl matches RFC 3339 comparison.

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or 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._
2023-05-09 23:31:51 +00:00
Zelda Hessler 97c70c429c
add: tests to ensure all interceptors are run if an error occurs in one (#2664)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#2662

## Description
<!--- Describe your changes in detail -->
This PR adds tests for all interceptor hooks to ensure the correct error
handling behavior and defines a set of stub components for orchestrator
testing.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This PR includes tests.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-08 21:28:50 +00:00
John DiSanti beedd2c70d
Refactor interceptor phases to improve optionality inside interceptors (#2670)
## Motivation and Context
This PR:
- Deletes `TraceProbe`
- Replaces the orchestrator's `Phase` helper with a couple of macros
- Introduces the concept of phases into `InterceptorContext` so that
input/output/error/request/response accessors don't need option wrappers
- Adds `TypeErasedError` so that `orchestrator::Error` can implement
`Error`
- Rewinds the interceptor context in the retry loop

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-03 21:29:40 +00:00
Zelda Hessler c75807ce37
fix/format: various code that's escaped the linter (#2667)
_Every once in a while I run clippy and the pre-commit checks on
everything b/c stuff seems to fall through the cracks._

- fix: various code that's escaped the linter
- format: various code that's escaped the formatter
- update: `chrono` because a test was using a method only available in
v0.4.23 _(I don't know why that didn't fail in CI)_


_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-03 15:46:18 +00:00
John DiSanti e1cf72e52d
Make the `Debug` impl on `TypeErasedBox` useful (#2665)
## Motivation and Context
This PR ports @rcoh's addition of `Debug` in `ConfigBag` to the
`TypeErasedBox`.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-02 21:37:47 +00:00
John DiSanti 23d0f5ec67
Implement timeouts in the orchestrator (#2661)
## Motivation and Context
This PR implements timeouts in the orchestrator.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-02 17:56:57 +00:00
Russell Cohen bf23d57aa3
Adds an experimental store/load add to config bag (#2654)
## Motivation and Context
- store multiple objects of the same type in the bag
- obtain mutable access to items in the bag

## Description
This adds `store_append` to enable storing multiple items of the same
type in the bag and `get_mut`, `get_mut_or_else` and
`get_mut_or_default` to reduce clones when possible

## Testing
UTs

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-02 14:00:49 +00:00
Russell Cohen 2fb21f6405
split out interceptors (#2639)
## Motivation and Context
- split out interceptors from config bag to simplify orchestrator

## Description
- update runtime plugin trait to split out interceptors
- remove interceptor generics 
- update interceptors struct to remove locking and indirection

## Testing
- [x] ```./gradlew :aws:sra-test:assemble && (cd
aws/sra-test/integration-tests/aws-sdk-s3 && cargo test)```



----

_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: Zelda Hessler <zhessler@amazon.com>
2023-05-01 16:01:06 +00:00
John DiSanti b1ce5e3c6c
Recalculate signing time for every retry attempt (#2643)
## Motivation and Context
When SigV4 signing was ported over to the orchestrator, the request time
got calculated once before the retry loop, which was incorrect. This PR
moves that request time calculation into the request signer so that it
happens on every attempt (unless there is a configured request time
override).

This PR also refactors auth to use the `ConfigBag` instead of a separate
signing properties `PropertyBag`.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-27 17:26:33 +00:00
Henrik Sjööh 5a8fff7a32
implement `Ord` and `PartialOrd` for `DateTime` (#2653)
## Motivation and Context

This change will allow easy sorting or comparing anything that contains
a DateTime. My example is wanting to sort a list of S3 objects by last
modified.

This PR fixes #2406

## Description
It's a pretty small PR, it implements the `Ord` trait for `DateTime` by
comparing the `seconds` property of `self` and `other`, if they are
equal it compares the `subsec_nanos` properties instead.

The `PartialOrd` trait is implemented by calling the `Ord` trait.

## Testing
I added a unit test that compares a number of `DateTime` values with
different combinations of positive/zero/negative
`seconds`/`subsec_nanos`.

## Checklist
- [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._
2023-04-27 16:16:01 +00:00
Russell Cohen a85cef6d1e
Add configurable runtime plugin to send_v2 so that it is usable (#2635)
## Motivation and Context
- `send_v2()` doesn't work for a very small number of reasons—allow it
one last final runtime_plugin so that we can use it to make an e2e
request

## Description
- update a few decorators to be deterministic
## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- 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 -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] 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 <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-04-27 00:09:53 +00:00
Russell Cohen 6af5d40d3b
Add useful Debug impl to PropertyBag and ConfigBag (#2612)
## Motivation and Context
- it's hard to debug what properties are set, especially for layered
configuration

## Description
Add Debug Info for PropertyBag and Config bag:
```
PropertyBag { contents: ["aws_smithy_http::property_bag::test::test_extensions::MyType"] }
```

```

ConfigBag {
    layers: [
        Layer {
            name: "c",
            properties: [
                "aws_smithy_runtime_api::config_bag::Value<aws_smithy_runtime_api::config_bag::test::layered_property_bag::Prop3>",
                "aws_smithy_runtime_api::config_bag::Value<aws_smithy_runtime_api::config_bag::test::layered_property_bag::Prop4>",
            ],
        },
        Layer {
            name: "b",
            properties: [
                "aws_smithy_runtime_api::config_bag::Value<aws_smithy_runtime_api::config_bag::test::layered_property_bag::Prop3>",
                "aws_smithy_runtime_api::config_bag::Value<aws_smithy_runtime_api::config_bag::test::layered_property_bag::Prop2>",
            ],
        },
        Layer {
            name: "a",
            properties: [
                "aws_smithy_runtime_api::config_bag::Value<aws_smithy_runtime_api::config_bag::test::layered_property_bag::Prop1>",
            ],
        },
        Layer {
            name: "base",
            properties: [],
        },
    ],
}
```

There is still some work to do, but this is a start

## Testing
- [x] UT

## 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 <jdisanti@amazon.com>
2023-04-26 20:19:47 +00:00
ysaito1001 f7265aeb49
Port fix for debug bound on ResolveEndpoint (#2636)
## Motivation and Context
Port https://github.com/awslabs/smithy-rs/pull/2630 to the `main`
branch.

## Description
Adding `Debug` bound on `ResolveEndpoint` in
https://github.com/awslabs/smithy-rs/pull/2577 was a breaking change.
Unfortunately, the semvar check that ran in that PR barked at a
different thing (i.e. barked at moving `StaticUriEndpointResolver` and
`DefaultEndpointResolver` from `aws-smithy-runtime-api` to
`aws-smithy-runtime`). Eventually the breaking change got merged to the
`main` branch.

This PR reverts the change in question and implements the `Debug` trait
for `ResolveEndpoint` in a semvar non-breaking way.

## Testing
- [ ] Passed tests in CI

----

_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: Yuki Saito <awsaito@amazon.com>
2023-04-26 17:14:16 +00:00
Thomas Cameron d729759940
Refactor aws smithy types (#2638)
## Motivation and Context
This PR refactors `aws-smithy-types` crate. 
`Blob`, `Datetime`, `Number` and `Document` structs now goes to it's own
files.
No changes on feature is introduced.

This is a child-PR of https://github.com/awslabs/smithy-rs/pull/2616 .
However, it is completely independent.

PR that introduces same changes were previously merged to
`unstable-serde` branch, however, it has not been merged to main branch.

## Testing
NA

## Checklist
This PR does not introduce API changes.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-26 14:55:39 +00:00
82marbag bc4c1862ae
Lazy initialize mime accept header (#2629)
## Description

Do not parse and initialize the mime, known at compile time, on every
request.

See
https://github.com/awslabs/smithy-rs/pull/2607#discussion_r1172607704


## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] 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._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-04-26 08:52:47 +00:00
Zelda Hessler ae995fbadb
feature: orchestrator retry classifiers (#2621)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
To retry a response, we must first classify it as retryable.

## Description
<!--- Describe your changes in detail -->
feature: add AWS error code classifier
feature: add x-amz-retry-after header classifier
feature: add smithy modeled retry classifier
feature: add error type classifier
feature: add HTTP status code classifier
add: tests for classifiers
remove: redundant `http` dep from `aws-http`
move: `NeverRetryStrategy` to smithy-runtime crate
add: RuntimePluginImpls codegen section for operation-specific runtime
plugin definitions
update: orchestrator retries to work with `ShouldAttempt`
add: retry classifier config bag accessor
add: raw response getter to SdkError
update: RetryStrategy trait signatures to use `ShouldAttempt`
add: `RetryClassifiers` struct for holding and calling retry classifiers
update: `RetryClassifierDecorator` to define orchestrator classifiers
add: `default_retry_classifiers` fn to codegen
update: `ServiceGenerator` to add feature flag for
aws-smithy-runtime/test-util
update: SRA integration test to insert retry classifier plugin

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
this change includes tests

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-25 20:51:30 +00:00
John DiSanti e07aa7660d
Add HTTP basic and bearer auth support to the orchestrator (#2622)
## Motivation and Context
This PR adds support for Smithy's `@httpBasicAuth` and `@httpBearerAuth`
auth schemes, and ports the `@httpApiKeyAuth` scheme to the
orchestrator. This is prerequisite work for supporting Amazon
CodeCatalyst since that requires bearer auth.

This PR also fixes a bug in auth orchestrator that caused an error if no
identity is present for a scheme even when an identity for a lower
priority scheme is available.

----

_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: Zelda Hessler <zhessler@amazon.com>
2023-04-24 21:06:31 +00:00
Julian Antonielli 2de6815c10
Add `AlbHealthCheckLayer` (#2540)
## Motivation and Context
Services often need the ability to report health status via health
checks (see [ALB Health
Checks](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html)).
This PR adds a simple layer that allows configuring your service to
respond to these health check requests.

## Description
Adds `AlbHealthCheckLayer`, and `AlbHealthCheckService`.

## Testing
Added this layer to the `pokemon-service` binary, and added an
integration test for it.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-24 10:25:27 +00:00
John DiSanti 1a65a44e53
Upgrade MSRV to Rust 1.67.1 (#2611)
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-21 17:26:27 +00:00
ysaito1001 3d8c52a676
Follow up on DefaultEndpointResolver in the orchestrator (#2592)
## Motivation and Context
This PR incorporates post-merge feedback left in #2577.

----

_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: Yuki Saito <awsaito@amazon.com>
2023-04-21 17:16:28 +00:00
Russell Cohen 9a41e359dd
Add credentials exposure test & fix STS + SSO (#2603)
## Motivation and Context
- credentials providers may leak credentials in the HTTP body at the
debug level

## Description
This adds a test to aws-config that looks for leaked credentials in all
of our provider integration tests—since these test use AWS APIs under
the hood, this also serves to test AWS services in general.

To support this, `sensitive` was added to the ParseHttpResponse trait
and code was generated to take action based on this change.

- [x] Add environment variable to force logging of the body
- [x] consider if we want to suppress request body logging as well

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- 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 <jdisanti@amazon.com>
2023-04-20 17:26:01 +00:00
Matteo Bigoi 9c585a223b
[Python] Improve Python stubs generation (#2606)
## Motivation and Context
This PR improves the Python stubs generation.

## Description
The main change is about avoiding to setup a placeholder for the Python
module and use the real module name, which allows to generate correct
docstrings during codegeneration.

We also change the stubs layout on disk, with the main stub entrypoint
called `__init__.pyi` instead of `$module_name.pyi`.

The README from the Rust runtime crate has been moved completely to the
example folder and I run autoformatting and style checks on the Python
example code.

----

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

---------

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: Burak <unexge@gmail.com>
2023-04-20 14:18:15 +00:00
david-perez c805f89be6
Undeprecate `{content_type,accept}_header_classifier` from `aws-smithy-http-server` (#2604)
These functions were mistakenly deprecated when deprecating the old
service builder API in #1886.

However, they're fine, and they're internally used by the generated
server SDKs.
The module they reside in is `#[doc(hidden)]`.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-20 11:45:08 +00:00
ysaito1001 165253cdbc
Add skeleton for supporting operation level config (#2589)
## Motivation and Context
This PR adds skeleton code for supporting operation level config behind
`enableNewSmithyRuntime`.

## Description
The approach is described in
https://github.com/awslabs/smithy-rs/pull/2527, where fluent builders
now have a new method, `config_override`, that takes a service config
builder. The builder implements the `RuntimePlugin` trait and once
`TODO(RuntimePlugins)` is implemented, allows itself to put field values
into a config bag within `send_v2`.

## Testing
Added a line of code to an ignored test in `sra_test`, which, however,
does check compilation.

----

_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: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-04-19 21:44:03 +00:00
david-perez 2f70ac8ec0
`DEBUG`-log server request rejections (#2597)
This commit logs server request rejections at the `DEBUG` level in an
operation's `FromRequest` implementation.

This commit is analogous to the one in PR #2524 for response rejections.
However, request rejections are _not_ errors, so they shouldn't be
logged at the `ERROR` level. Indeed, they happen every time the server
rejects a malformed request.

Prior to this commit, the `RuntimeError::NotAcceptable` variant was the
only `RuntimeError` variant that was manually constructed. This commit
makes it so that it now results from a conversion from a new
`RequestRejection::NotAcceptable` variant.

We now leverage `futures_util::future::TryFutureExt::map` to map a
future
that uses `RequestRejection` as its error into a future that uses
`RuntimeError`, and centrally log the rejection there. `futures_util` is
already a transitive dependency of server SDKs (via e.g. `hyper` and
`tower`), so adding it is a direct dependency is not worse.

This helps with #2521.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-19 11:00:17 +00:00
ysaito1001 7cb9d6af3e
Add DefaultEndpointResolver to the orchestrator (#2577)
## Motivation and Context
This PR adds `DefaultEndpointResolver`, a default implementer of the
[EndpointResolver](1e27efe05f/rust-runtime/aws-smithy-runtime-api/src/client/orchestrator.rs (L182-L184))
trait, to the orchestrator.

## Description
Roughly speaking, the endpoint-related work is currently done by
`make_operation` and `SmithyEndpointStage`, where `make_operation`
constructs endpoint params and applies an endpoint resolver and the
`SmithyEndpointStage` later updates the request header based on the
resolved endpoint. In the orchestrator world, that work is handled by
`DefaultEndpointResolver::resolve_and_apply_endpoint`.

The way endpoint parameters and an endpoint prefix are made available to
`DefaultEndpointResolver::resolve_and_apply_endpoint` is done by
interceptors because they _may_ require pieces of information only
available in an operation input struct. The place that has access to
both an operation input struct and a config bag happens to be an
interceptor.

There are two interceptors `<Operation>EndpointParamsInterceptor` and
`<Operation>EndpointParamsFinalizerInterceptor` per operation. We pass
around endpoint params _builder_ through interceptors to allow it to be
configured with more information at a later point; An end point
parameters builder is first initialized within the
`ServiceRuntimePlugin` with the field values obtained from the service
config, and is stored in a config bag. The finalizer interceptor "seals"
the builder and creates the actual endpoint params before it is passed
to `DefaultEndpointResolver::resolve_and_apply_endpoint`. These
interceptors implement `read_before_execution` because they need to
access an operation input before it gets serialized (otherwise,
`context.input()` would return a `None`).

## Testing
Replaced `StaticUriEndpointResolver` with `DefaultEndpointResolver` in
`sra_test` and verified the test continued passing.

UPDATE: The test currently fails in the `main` branch (it returns a
`None` when extracting `SigV4OperationSigningConfig` from the config bag
in `OverrideSigningTimeInterceptor`, hence `unwrap` fails), and by
merging the `main` branch this PR no longer passes the test, but it does
not add new failures either.

----

_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: Yuki Saito <awsaito@amazon.com>
2023-04-17 20:59:49 +00:00
Matteo Bigoi a2d37ad261
[Python] Automatically generate stubs (#2576)
## Motivation and Context
We want to automatically generate stubs in the codegen diff to ensure
they can be reviewed and have a simple way to generate and include the
stubs inside the Maturin wheel.

## Description
The Python example has been moved to the `examples` folder and
refactored. The refactoring
ensures the script `stubgen.py` is included in the codegeneration of the
SDK crate. The script is later used to generate stubs automatically
during testing and can be used by customers to add their own stubs
before the Maturin build

----

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

----

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

---------

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: Burak <unexge@gmail.com>
2023-04-17 16:19:12 +00:00
John DiSanti 1e27efe05f
Make a minor optimization to `AuthOptionResolver` (#2557) 2023-04-11 15:05:03 +00:00
John DiSanti eff74374a1
Fix the `HttpSigner` trait args (#2558)
This trait should have been taking a `PropertyBag` that originates from
`HttpAuthOption` rather than the `ConfigBag`.
2023-04-11 15:04:20 +00:00
Burak 1a7a495df5
Python: Event Streaming (#2482)
* Add `RustType.Application` and `PythonType.Application` variants

* Use `RustType.Application` for event streaming symbols

* Call symbol provider to get `Receiver` type instead of hardcoding

* Add Python specific event streaming symbol provider

* Add event streaming wrapper generator

* Generate correct type information for event streaming types

* Add `CapturePokemon` operation to Python Pokemon service

* Add `InternalServerError` variant to all event streaming errors

* Use `PythonServerCargoDependency` for PyO3Asyncio imports

* Return an attribute error instead of panicking in `IntoPy` impls of wrappers

* Add `Sync` bound to `new` methods of wrappers

* Revert "Add `InternalServerError` variant to all event streaming errors"

This reverts commit b610cb27c7532102e3a3ec15a59da6c56b60c318.

* Add `PythonServerEventStreamErrorGenerator` to generate Python specific error types for unions

* Try to extract error type or inner type from incoming streaming value and ignore the value otherwise for now

* Allow missing type-stubs for `aiohttp`

* Propogate modelled errors through stream

* Raise modelled exceptions rather than sending through stream

* Allow senders from Python side to raise modelled exceptions

* Update `EventStreamSymbolProviderTest` to use `Application` type instead of `Opaque` type

* Fix `ktlint` issues

* Group up common variables in `codegenScope`

* Document `RustType.Application`

* Format `codegen-server-test/python/model/pokemon.smithy`

* Use `tokio-stream` crate instead of `futures` crate

* Use a better error message if user tries to reuse a stream

* Add some details about event streams to example Pokemon service

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-04-11 11:21:16 +00:00
John DiSanti 093b65afc4
Implement the `UserAgentInterceptor` for the SDK (#2550)
* Implement the `UserAgentInterceptor` for the SDK

* Refactor interceptor errors

* Centralize config/interceptor registration in codegen
2023-04-07 15:58:34 +00:00
Matteo Bigoi 3862ca0a37
Initial implementation of Typescript server bindings (#2277)
* A barely working code generation in typescript

* Extract shared socket into feature inside aws-smithy-http-server

* Building a fully functional application, I think

* Add NAPI build.rs

* Refactor all names to use typescript instead of js

* Add (hopefully) the PR bot for TS

* Clippy fixes

* Fix documentation

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* set_reuse_port in socket not on windows

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add example implementation

* Allow the new application to build

* Remove all occurrences of Python

* Simplify README

* Fix issue with the codegen-diff-revision script

* Try to prevent the ci-lint to bother us with TODO at this stage of development

* Remove codegen-client from typescript dependencies

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Add CODEOWNERS and fix some other linting issues

* Add license

* Prevent from running tests on typescript in Windows

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Initial work to remove error from this PR

* Update to call_async

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* types/node in package.json

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Generate app.ts

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Improve makefile

* Adapting code to the latest changes and removing runtime dependency (for now).

* Removing rust-runtime/aws-smithy-http-server-typescript.

* Making CI happy.

* Restoring ServerCodegenDecorator to be like main.

* Adding back the aws-smithy-http-server-typescript crate back.

* Removing index.js file.

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: 82marbag <69267416+82marbag@users.noreply.github.com>
Co-authored-by: Alberto Pose <albepose@amazon.com>
2023-04-06 15:27:17 +00:00
John DiSanti 9006fe8775
Add SigV4 support to the orchestrator (#2533)
* Create the `aws-runtime` and `aws-runtime-api` crates

* Implement SigV4 in the orchestrator

* CI fixes

* Connect the service config http connector to the orchestrator

* Make it possible to register interceptors, and get signing to pass tests

* Fix allowed types lint

* Add missing docs.rs metadata
2023-04-05 17:33:03 +00:00
david-perez c7c8285598
Tighten server rejection types (#2542)
Rejection types used to be loose, but now that they are
protocol-specific (see #2517), they can be tightened up to be more
useful.

Where possible, variants now no longer take in the dynamic
`crate::Error`, instead taking in concrete error types arising from
particular fallible invocations in the generated SDKs.This makes it
easier to see how errors arise, and allows for more specific and helpful
error messages that can be logged.

We `#[derive(thiserror::Error)]` on rejection types to cut down on
boilerplate code.

This commit removes the dependency on `strum_macros`.
2023-04-05 10:38:22 +00:00
david-perez f2abe7c695
Improve invalid HTTP status code responses failure mode handling (#2522)
If the model only uses the `@http` trait to define the response code,
Smithy already checks that this is a valid status code, so the
conversion cannot fail, and we can avoid rejecting with
`ResponseRejection::InvalidHttpStatusCode`.

This commit also removes this variant from RPC protocols, where HTTP
binding traits are not allowed, and so this failure mode can never
happen.
2023-04-04 07:58:24 +00:00
david-perez f036223291
Use `aws_smithy_types::primitive::Parse` in the server (#2528)
This further reduces the number of request rejection variants.
https://docs.rs/aws-smithy-types/latest/aws_smithy_types/primitive/trait.Parse.html

Closes #1232.
2023-04-03 14:43:58 +00:00
david-perez f7080760d9
Split `RuntimeError` and `RequestRejection` by protocol (#2517)
As outlined in the [Protocol Specific Errors] of the [Service Builder
Improvements RFC], `RuntimeError` should be split up into smaller,
protocol specific, errors which accurately model the failure cases of
each protocol.

The same goes for `RequestRejection`.

Closes #1703.

[Protocol Specific Errors]: https://github.com/awslabs/smithy-rs/blob/main/design/src/rfcs/rfc0020_service_builder.md#protocol-specific-errors
[Service Builder Improvements RFC]: https://github.com/awslabs/smithy-rs/blob/main/design/src/rfcs/rfc0020_service_builder.md
2023-04-03 13:07:09 +00:00
Parker Timmerman a20889a278
runtime: add a method `into_segments` to `AggregatedBytes` (#2525)
* start, add a method to AggregatedBytes called into_segments

* update CHANGELOG.next.toml
2023-03-31 21:26:19 +00:00
Zelda Hessler 637333c144
Add stubs to make SRA test fully runnable (#2519)
* add: stubs to make sra test fully runnable (but not useful 😅)

* fix: disable build.gradle enableNewSmithyRuntime option

* fix: clippy lints
add: feature gate for test connection

* fix: doc comment

* move: connections module from API to runtime

* update: TODO message
add: exceptions for external types

* Fix external types lint

---------

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-03-30 22:40:02 +00:00
John DiSanti d14357c2e2
Generate `RequestSerializer` traits for client operations (#2510)
* Clean up client deserialization generation logic

* Generate `RequestSerializer` traits

* Fix property access issue for customizations

* Move `aws-smithy-runtime-test` into `aws/sra-test`

* Generate operation runtime plugins to register ser/de

* Add `send_v2` to fluent builders that uses the orchestrator

* Fixes
2023-03-30 17:06:31 +00:00
Eduardo de Moura Rodrigues 65058d9d5a
feat: support compiling to webassembly (#2254)
* feat(aws-config): define default feature for sso

* chore(aws): disable unused features

* chore(rust-runtime): disable unused features

* chore: add missing tokio fs feature

* chore: disable spawn blocking on wasm

* chore: fix sso feature

* chore: allow unused variables when not sso

* chore: remove unnecessary dependency filter for wasm

* chore: add integration test for wasm

* chore: ensure test-util feature is applied to dev dependencies

* chore: disable retry config

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* chore: simplify features as suggested

* chore: no default features for aws types

* chore: rename credentials-sso feature

* Revert "chore: simplify features as suggested"

This reverts commit d8fcf4912f.

* chore: set right name in default features

* chore: create smithy client test util in runtime types

* Update aws/rust-runtime/aws-types/Cargo.toml

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update aws/rust-runtime/aws-inlineable/Cargo.toml

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update aws/rust-runtime/aws-config/src/lib.rs

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* chore: use hardcoded credentials feature

* chore: make wasm example for s3 instead

* chore: fix formatting

* chore: fix kotlin formatting

* chore: fix kotlin unit tests

* chore: use timeout config from smithy types

* chore: move tests into main file

* chore: add vscode setttings to target wasi by default

* chore: fix test-util feature for smithy client

* chore: separate adapter into own module

* chore: fix test with no default features

* Fix typo

* Update changelog

* Check compilation of `aws-config` against `wasm32` in CI

* Fix Dockerfile issue and use correct cargo-wasi command

* Small Dockerfile fix

* Add missing `tar` binary to Docker image

---------

Co-authored-by: Eduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: John DiSanti <johndisanti@gmail.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2023-03-29 19:29:02 +00:00
John DiSanti 6b21e46ef1
Orchestrator `ResponseDeserializer` codegen and auth (#2494)
* Convert interceptor fns to macro invocations

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Add unmodeled error to ServiceError and bring in EventLog

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Simplify and test `EventLog`

* Attempt to integrate the event log with the orchestrator

* fix: error type in integration test
update: retry handling in orchestrator

* update: set the runtime plugins to do nothing instead of panic when called on

* Introduce a construct for type erasure

* Eliminate several generics and add phased error handling

* Code generate the `ResponseDeserializer` trait impls

* CI fixes

* Reorganize the new runtime crates

* Create the `Identity` type

* Reorganize orchestrator traits and accessors

* Set up code generated test environment for the new runtime

* Add initial auth orchestration implementation

* Fix clippy lint

* Incorporate feedback

* Fix external types lint

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-03-27 23:15:36 +00:00
John DiSanti db76db93af
Fix lack of the `Sync` auto trait on event stream outputs (#2496) 2023-03-24 21:55:17 +00:00
82marbag d89a90d631
Add request ID to response headers (#2438)
* Add request ID to response headers

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add parsing test

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Style

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Fix import

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Panic if ServerRequestIdProviderLayer is not present

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Own value

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Correct docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add order of layer to expect() message

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove Box

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Require order of request ID layers

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Revert "Require order of request ID layers"

This reverts commit 147eef26d5f8972b810dc5994e57865a872e44b0.

* One layer to generate and inject the header

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* HeaderName for header name

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove additional layer

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove to_owned

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add tests, remove unnecessary clone

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* take() ResponsePackage instead

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* cargo fmt

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-03-23 09:17:36 +00:00
Harry Barber abbf78fdb9
Make service builder handler setters more flexible (#2442)
* Add generic parameter to the handler setter

* Constrain Pl::Service in Upgrade rather than S

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-22 15:35:35 +00:00
Harry Barber a737694f73
Move examples to root, refactor to workspace, and refactor integration tests (#2481)
* Move examples

* Update documentation

* Add to CI

* Fix CI

* Cleanup

* Fix clippy lints

* Fix documentation

* Bump example dependencies

* Cleanup

* Update documentation

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-22 14:00:21 +00:00
82marbag f3e44742e3
Explicit list of TLS cipher suites (#2422)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-03-22 11:19:01 +00:00
DanielBauman88 bebc58ac35
fix: small comment update (#2304)
The comment talked about the server hanging up while
the response was being read.

The server hanging up while the response is read should not
be a problem. The client will still read whatever the server
has sent before getting to the fin/rst that closes the connection.

This error should only (I think) happen if the server hangs up
before sending a complete response or if the server sends an
invalid response.

Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-03-21 13:50:05 +00:00
Russell Cohen 05f920f672
Upgrade Tokio to 1.23.1 (RUSTSEC-2023-0001) (#2474) 2023-03-20 17:44:00 +00:00
Russell Cohen 1e71992d7b
Add docs and more color to configbag (#2469)
* Add docs and more color to configbag

* Add delegating add_layer to configbag

* Fix lints / docs

* namespace links
2023-03-20 17:38:36 +00:00
John DiSanti 87a62ae30f
Eliminate dependency on `futures-macros` (#2460)
The `futures-macros` crate is pulled in by default by `futures-util`,
and depends on `syn`. None of this functionality is used by smithy-rs.
2023-03-17 21:28:54 +00:00
Zelda Hessler b4a969838a
Add: runtime plugin placeholder code to Smithy Orchestrator (#2465)
* update: add placeholder impl of runtime plugins
update: separate client and operation interceptors

* add: stub endpoint orchestrator to integration test

* add: endpoints runtime plugin to integration test

* fix: compilation issues

* format: run cargo fmt
2023-03-17 15:09:50 +00:00
Matteo Bigoi 48eda40437
Implement Python unions (#2427)
* Add initial implementation of unions with very broken symbol provider

* Add support for creating new unions in Python

* Generate getters and static methods for unions

* Allow to compile misc model

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Doesn't work

* Now it works

* Simplify code a little

* Remove leftover from the many tries I did

* Finally fixed model generation with unions

* Fix wrong import

* Update to reflect changes in decorators

* Remove debugging output

* Simplify symbol provider

* Follow PR suggestions

* Remove union operation from python example

* Return `PyUnionMarker` for wrapped type in `IntoPy` impl

---------

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: Burak Varlı <burakvar@amazon.co.uk>
2023-03-17 15:02:31 +00:00
Russell Cohen d8a7d9998f
Fix bug in default HTTP Connector provided by aws-config (#2471)
* Fix bug in default HTTP Connector provided by aws-config

* Fix clippy lint

---------

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-03-16 23:53:13 +00:00
Julian Antonielli 89b5a7e508
Fix rust doc list (#2466) 2023-03-16 23:07:14 +00:00
Zelda Hessler 92952cbe51
Update MSRV to 1.66.1 (#2468)
* update: MSRV to 1.66.1

* add: CHANGELOG.next.toml entry

* update: Dockerfile too

* fix: clippy lints

* fix: sigv4 event_stream.rs clippy lint
update: codegen clippy lint allowlist

* fix: doc lint that's nightly only
add: docs for aws-smithy-http
add: docs for aws-smithy-client
add: docs for aws-smithy-async

* add: more missing docs.

* fix: add more missing docs

* remove: unnecessary & in HttpBindingGenerator
fix: lint name

* fix: another doc import

* fix: test broken by changing compiler error

* fix: even more lints\nadd: lint warns to all smithy runtime crates

* fix: broken doc links

* fix: clippy bug

* fix: don't use modules named lib in codegen tests

* fix: the paginator_canary.rs unnecessary cast
2023-03-16 21:58:14 +00:00
Zelda Hessler bde362e8b9
Feature: Add smithy orchestrator (#2447)
* add: WIP for smithy orchestrator

* add: publish = false to the new, unreleased crates

* undo: more extraneous changes

* fix: correctly declare `publish = false`

* feature: add layered config bag

* Update aws/sdk/integration-tests/smithy_orchestrator/Cargo.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* add: READMEs to new crates
add: external-types.toml to new crates
add: LICENSEs to new crates
update: crate organization and naming
update: interceptor errors per RFC 22
update: token bucket errors per RFC 22

* fix: bad imports in integration test

* fix: error struct naming

* fix: err source issue

* fix: clippy lints
fix: TODOs with no subject

* fix: broken token bucket test
add: docs.rs metadata to cargo toml of new crates

* update: crate naming

* fix: broken test import

* fix: cargo doc issues

* update: aws-smithy-runtime external-types.toml

* remove: unused deps
fix: move allowed external types to correct crate

* add: exception for aws_smithy_types

---------

Co-authored-by: Russell Cohen <rcoh@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-03-14 21:44:43 +00:00
Russell Cohen c3c747a1ed
Upgrade to Smithy 1.27.2 (#2226)
* Upgrade to Smithy 1.27.1

* Fix bugs exposed by 1.27.1

* Fix rules engine customization

* update rfc3339 parsing test

* refactor timestamp format & remove upstreamed test

* Update changelog

* rename test

* fix datetime parsing on server and clients

* fix up a few more failing tests

* precommit lints

* Fix bad merge
2023-03-14 21:14:27 +00:00
Russell Cohen 61934da044
Add connection poisoning to aws-smithy-client (#2445)
* Add Connection Poisoning to aws-smithy-client

* Fix doc links

* Remove required tokio dependency from aws-smithy-client

* Remove external type exposed

* Rename, re-add tokio dependency

* Change IP to 127.0.0.1 to attempt to fix windows

* Add dns::Name to external types

* Remove non_exhaustive not needed

* Add client target to changelog
2023-03-14 20:08:35 +00:00
John DiSanti 358d13a09a
Enable the crate reorganization for generic clients (#2448) 2023-03-13 19:00:11 -07:00
John DiSanti 4835af9d6b
Make `RustReservedWordsSymbolProvider` configurable (#2382)
* Remove `toEnumVariantName` from `RustSymbolProvider`

The `toEnumVariantName` function existed on symbol provider to work
around enum definitions not being shapes. In the future when we refactor
to use `EnumShape` instead of `EnumTrait`, there will be `MemberShape`s
for each enum member. This change incrementally moves us to that future
by creating fake `MemberShape`s in the enum generator from the enum
definition.

* Fix escaping of `Self` in symbol providers

* Clean up an old hack

* Make `RustReservedWordsSymbolProvider` configurable

* Update changelog

* Incorporate feedback
2023-03-13 19:15:55 +00:00
John DiSanti 2f60a5e090
Update top level docs for crate reorganization (#2432) 2023-03-10 10:49:25 -08:00
Harry Barber b17a86753a
Use a bespoke version of `Either` (#2441)
* Add Plugin impl for &Plugin

* Add bespoke Either implementation

* Use Either in FilterByOperationName

* Add CHANGELOG.next.toml

* Rename A and B to Left and Right

* Re-export Either
2023-03-08 23:03:36 +00:00
Harry Barber bec93c8a5e
Remove uncessary type parameter and constraints from `Upgrade` service (#2436)
* Remove B from Upgrade service

* Remove duplicated bounds on Upgradable

* Update documentation

* Add CHANGELOG.next.toml entry
2023-03-08 15:56:56 +00:00
Burak 26cb37afb0
Python: Add tests and fix the issues with `Timestamp` and `ByteStream` (#2431)
* Add `timestamp` type test and fix the conversion error

* Add some tests for `ByteStream` and fix async issues

* Use `__anext__` method instead of `anext`

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-07 10:04:56 +00:00
John DiSanti 7ce80320ed
Make it possible to create `SdkError` context structs for tests (#2428) 2023-03-03 17:12:45 +00:00
Julian Antonielli c3ae6f7eaf
Refactor event stream tests with `{client,server}IntegrationTest`s (#2342)
* Refactor `ClientEventStreamUnmarshallerGeneratorTest` to use `clientIntegrationTest` (WIP)

* Refactor `ClientEventStreamUnmarshallerGeneratorTest` with `clientIntegrationTest`

* Refactor `ClientEventStreamUnmarshallerGeneratorTest` to use generic test cases

* Start refactoring `ServerEventStreamUnmarshallerGeneratorTest`

* Make `ServerEventStreamUnmarshallerGeneratorTest` tests work

* Uncomment other test models

* Allow unused on `parse_generic_error`

* Rename `ServerEventStreamUnmarshallerGeneratorTest`

* Make `EventStreamUnmarshallTestCases` codegenTarget-agnostic

* Refactor `ClientEventStreamMarshallerGeneratorTest`: Tests run but fail

* Refactor `ServerEventStreamMarshallerGeneratorTest`

* Move `.into()` calls to `conditionalBuilderInput`

* Add "context" to TODO

* Fix client unmarshall tests

* Fix clippy lint

* Fix more clippy lints

* Add docs for `event_stream_serde` module

* Fix client tests

* Remove `#[allow(missing_docs)]` from event stream module

* Remove unused `EventStreamTestTools`

* Add `smithy-validation-model` test dep to `codegen-client`

* Temporarily add docs to make tests compile

* Undo change in model

* Make event stream unmarshaller tests a unit test

* Remove unused code

* Make `ServerEventStreamUnmarshallerGeneratorTest` a unit test

* Make `ServerEventStreamMarshallerGeneratorTest` a unit test

* Make `ServerEventStreamMarshallerGeneratorTest` pass

* Make remaining tests non-integration tests

* Make event stream serde module private again

* Remove unnecessary clippy allowances

* Remove clippy allowance

* Remove docs for `event_stream_serde` module

* Remove docs for `$unmarshallerTypeName::new`

* Remove more unnecessary docs

* Remove more superfluous docs

* Undo unnecessary diffs

* Uncomment last test

* Make `conditionalBuilderInput` internal
2023-02-28 20:26:20 +00:00
Julian Antonielli 9f7c49a04e
Remove unused `wrk-api-bench` dependency (#2331)
* Remove unused `wrk-api-bench` dependency

* Remove benchmark file
2023-02-27 12:12:37 +00:00
ysaito1001 e23790e13a
Remove InvalidUri from external-types.toml (#2414)
Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-24 00:29:53 +00:00
John DiSanti 14bd80920c
Add builder symbol/module resolution to symbol providers (#2395)
* Add builder symbol/module resolution to symbol providers

* Back out breaking changes

* Reduce codegen diff

* Fix server example clippy lints

* Associate #2396 with TODO comments

* Improve doc comment

* Revert doc hidden change
2023-02-23 17:19:27 +00:00
ysaito1001 da264056eb
Add support for the awsQueryCompatible trait (#2398)
* Add support for the awsQueryCompatible trait

This commit adds support for the awsQueryCompatible trait. This allows
services already supporting custom error codes through the AWS Query
protocol with the awsQueryError trait to continue supporting them after
the services switch to the AWS JSON 1.0 protocol.

* Add copyright header

* Fix clippy warning for clippy::manual-map

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

* Remove unused variables from `errorScope`

This commit addresses https://github.com/awslabs/smithy-rs/pull/2398#discussion_r1114763528

* Reorder arguments for test verification

This commit addresses https://github.com/awslabs/smithy-rs/pull/2398#discussion_r1114766817

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-22 21:04:48 +00:00
John DiSanti 85d2ace0d6
Upgrade Kotlin and Ktlint (#2392)
* Upgrade Kotlin to 1.7.21

* Upgrade Ktlint to 0.48.2

* Run `pre-commit run --all-files` to fix broken Ktlints

* Fix string comparison broken by code formatting
2023-02-22 18:21:06 +00:00
ysaito1001 ec1a5515ad
Address clippy warnings in pokemon-service (#2399)
Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-21 20:44:15 +00:00
Nugine 42671ddc36
Upgrade `base64-simd` to 0.8 (#2384) 2023-02-16 15:53:19 +00:00
Eduardo de Moura Rodrigues 1d1e68aeba
feat(smithy-http-auth): add api key auth types (#2153)
* feat(aws-types): add api key to configuration

* chore: set package version to 0.52.0

* feat(aws-smithy-types): create auth types

* chore: use auth from smithy types

* chore: fix return self type

* chore: create http auth definition type

* chore: add constructor for http auth definition

* chore: ensure properties are not moved

* chore: create convenience constructors

* chore: add some todo comments

* feat: move query writer to aws-smithy-http crate

* chore(codegen): expose smithy http tower dependency

* chore: remove setters for auth definition

* chore: fix logical error for scheme not allowed

* chore: add constructor for basic and digest auth

* chore: allow equality comparision for api key

* Revert "chore: set package version to 0.52.0"

This reverts commit da660fcf16.

* chore: fix additional references to querywriter

* chore: implement from string for api key struct

* chore: disallow none api key in sdk config

* chore: fix formatting

* chore: add unit tests for auth types

* chore: add auth api key to external types

* chore: make query writer doc hidden

* feat: create aws-smithy-http-auth crate

* chore: use zeroing for auth api key

* chore: use builder pattern for auth definition

* chore: restructure http auth package

* chore: define default lint warning

* chore: include http auth in runtime common list

* chore: define setter for optional scheme

* chore: should panic while building auth definition

* chore: return missing required field error

* chore: make few code simplications for api key

* Revert "chore: add auth api key to external types"

This reverts commit b2318b0230.

* chore: revert api key from sdk config

* chore: panic on missing required field

* Opt out of `clippy::derive_partial_eq_without_eq`

---------

Co-authored-by: Eduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-02-13 23:07:06 +00:00
Zelda Hessler 10520d7fd7
Fix: native-tls client creation to support HTTPS again (#2360)
* update: use `enforce_http = false` when creating native-tls hyper connector
refactor: move smithy conns module to its own file
add: sanity tests ensuring we can make HTTP and HTTPS requests with the rustls and native-tls connectors
remove: `use crate::*` imports in favor of explicit imports

* update: CHANGELOG.next.toml

* add: feature gate to conns tests
2023-02-13 22:45:50 +00:00
John DiSanti d48878ee01
Implement request ID access for SDK clients RFC (#2129)
* Add `RequestId` trait
* Implement `RequestId` for generated AWS client errors
* Move `RustWriter.implBlock` out of `StructureGenerator`
* Create structure/builder customization hooks
* Customize `_request_id` into AWS outputs
* Set request ID on outputs
* Refactor SDK service decorators
* Refactor S3's extended request ID implementation
* Combine `Error` and `ErrorKind`
* Add test for service error conversion
* Move error generators into `codegen-client` and fix tests
* Re-export `ErrorMetadata`
* Add request IDs to trace logs
* Simplify some error trait handling
* Rename `ClientContextParamDecorator` to `ClientContextConfigCustomization`
* Add deprecated alias to guide customers through upgrading
* Rename the `ErrorMetadata` trait to `ProvideErrorMetadata`
* Rename `aws_smithy_types::Error` to `ErrorMetadata`
2023-02-10 17:36:48 -08:00
Nugine de186678ee
Bump Rust MSRV to 1.63.0 (#2222)
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-02-10 12:59:31 -08:00
Burak e84ef6c7e2
Python: Type-stub generation for SSDKs (#2149)
* Initial Python stub generation

* Handle default values correctly

* Only generate `__init__` for classes that have constructor signatures

* Preserve doc comments

* Make context class generic

* Put type hint into a string to fix runtime error

* Run `mypy` on CI

* Use `make` to build Python SSDKs while generating diffs

* Escape Python types in Rust comments

* Only mark class methods with

* Sort imports to minimize diffs

* Add type annotations for `PySocket`

* Dont extend classes from `object` as every class already implicitly extended from `object`

* Use `vars` instead of `inspect.getmembers` to skip inherited members of a class

* Fix linting issues

* Add some tests for stubgen and refactor it

* Add type annotations to `PyMiddlewareException`

* Fix tests on Python 3.7

Python 3.7 doesn't support reading signatures from `__text_signature__`
for non-builtin functions (i.e. C/Rust functions). For testing we're using
regular Python syntax for defining signature.

* Provide default values for `typing.Optional[T]` types in type-stubs

* Update `is_fn_like` to cover more cases

* Remove `tools/smithy-rs-tool-common/`

* Make `DECORATORS` an array instead of a list

* Ignore missing type stub errors for `aiohttp`
2023-02-10 14:00:53 +00:00
Zelda Hessler bae93805de
Update pretty_assertions (#2332)
* update: pretty_assertions

* update: just use v1.3
2023-02-09 11:02:19 -06:00
Luca Palmieri a389ea2d4e
Enforce the same minimum TLS version (1.2) for both TLS backends (#2312)
* Enforce the same minimum TLS version (1.2) for both TLS backends

* Add CHANGELOG entry

* Add documentation for both `https` and `native_tls`.

* Remove unnecessary mut
2023-02-06 16:30:33 +00:00
Harry Barber 3ee5d069cc
Make `OperationExtension` store the absolute shape ID (#2276)
* Do not alter Operation shape ID

* Add OperationExtensionExt test

* Add CHANGELOG.next.toml entry

* Apply suggestions from code review

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>

---------

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
2023-02-03 13:50:15 +00:00
John DiSanti bed7b97ff8
Reduce Docker image rebuilds (#2269)
* Move `acquire-build-image` into `.github`
* Move the `tools-hash` script into `.github`
* Upload to ECR from PRs as well
* Move build tools into `tools/ci-build/`
* Move CI scripts out of `ci-build`
* Split CI for forks/non-forks
* Remove `fetch-depth: 0` from PR workflows
2023-02-01 18:41:31 +00:00
Burak 861d1d89db
Python: Support `document` type (#2188)
* Add Python wrapper for `aws_smithy_types::Document`

* Remove unused type

* Make sure Python SSDKs uses Python specific `Document` type

* Allow Python specific `Document` type to be used in serialization and deserialization

* Make `pyo3/extension-module` a default feature

* Add `PythonServerTypesTest`

* Fix linting issues
2023-01-30 12:21:13 +00:00
Harry Barber ebdf59750a
Fix `OperationExtensionFuture` poll order (#2247)
* Fix `OperationExtensionFuture` poll order

* Add CHANGELOG.next.toml entry

Co-authored-by: AWS SDK Rust Bot <97246200+aws-sdk-rust-ci@users.noreply.github.com>
2023-01-25 14:53:20 +00:00
Harry Barber 4436d9adc2
Remove old service builder machinery (#2161)
* Remove HandlerGenerator and RegistryGenerator

* Shrink RequestRejection

* Remove inlineable

* Remove Router and RequestParts

* Remove old service builder tests

* Add missing test dependency

* Add missing dev dependency

* Remove unused test

* Move Router types

* Switch AllowUnused to AllowUnusedVariables
2023-01-20 17:24:31 +00:00
Zelda Hessler a559048ad8
formatting: run pre-commit on all files (#2236)
* formatting: run pre-commit on all files

* fix: test broken by string indent
2023-01-20 16:02:26 +00:00
82marbag 6d6d8d14d6
Remove MissingHttpStatusCode (#2231)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-01-20 07:29:11 +00:00
david-perez adf30a8eee
Derive `Eq` and `Hash` wherever possible (#2223)
In server SDKs, these traits can be implemented by any shape _except_ if
the shape's closure contains:

1. A `float`, `double`, or `document` shape: floating point types in
   Rust do not implement `Eq`. Similarly, [`document` shapes] may
   contain arbitrary JSON-like data containing floating point values.
2. A [@streaming] shape: all the streaming data would need to be
   buffered first to compare it.

Additionally, the `Hash` trait cannot be implemented by shapes whose
closure contains:

1. A `map` shape: we render `map` shapes as `std::collections::HashMap`,
   which _do not_ implement `Hash`. See
   https://github.com/awslabs/smithy/issues/1567.

In **client SDKs, these traits cannot be derived on any code-generated
Rust types corresponding to Smithy shapes**, since e.g. adding new
optional members to a structure [is a backwards-compatible change], and
doing so alters the semantics of these traits.

However, this commit does implement these traits for the
`aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob`
runtime types.

This change is necessary to efficiently implement the `@uniqueItems`
constraint trait in server SDKs.

[`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
[`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html
[`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document
[@streaming]: https://smithy.io/2.0/spec/streaming.html
[is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures
2023-01-19 13:25:00 +01:00
Russell Cohen 95dc365db9
Endpoint operation input tests (#2204)
* Add support for operationInput tests

* More unfication, fix tests, docs

* Set endpoint_url only when endpoint_url is used

* Fix test-util feature

* CR feedback

* fix missing path
2023-01-18 14:12:48 -05:00
david-perez 8d09dade44
Fix query string decoding (#2201)
`serde_urlencoded` can't decode into `Vec<(&str, &str)` query string
slices that need percent decoding.
2023-01-12 13:10:54 +01:00
Harry Barber f75d4f9995
Undeprecate `OperationExtension` and add `Plugin` (#2157)
* Undeprecate OperationExtension

* Introduce OperationExtensionPlugin

* insert_operation_extension into example responses
2023-01-10 15:51:16 +00:00
Harry Barber e311ebf4b2
Rename `PokemonService` `NotAuthorized` to `StorageAccessNotAuthorized` (#2176) 2023-01-06 16:21:33 +00:00
Russell Cohen 4768926b06
Remove webpki feature dependency (#2170) 2023-01-05 11:42:33 +00:00
82marbag 5363c41c6a
Support @default (#1879)
* Default trait in server

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: david-perez <d@vidp.dev>
2022-12-23 09:20:41 +00:00
82marbag 87e45f6016
Request IDs (#2054)
* Request IDs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-12-22 17:31:05 +00:00
Russell Cohen 2e3fa573d9
Add initial RFC document (endpoints 2.0) (#1637)
* Add initial RFC document

* CR feedback

* RFC updates

* Rename doc, add to summary / overview

* Apply suggestions from code review

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Update design/src/rfcs/rfc_0020_endpoints_20.md

Co-authored-by: Zelda Hessler <zhessler@amazon.com>

* RFC updates

* More cleanups

* Delete old file

* rfc updates

* delete old file

* fix merge

Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-12-21 16:03:33 +00:00
Russell Cohen 29abdc9b42
Enable Endpoints 2.0 (#2074)
* wip

* Fix region decorator

* Update S3 tests to succeed

* Create 'endpoint_url' setters

* Fix SDK adhoc tests

* Fix endpoint tests

* Fix protocol test generator to have a stub endpoint resolver

* Fix some more tests

* Fix aws rust runtime tests

* Update generator to appease clippy

* CR feedback

* Fix compilation

* Fix tests

* Fix doc links

* Fix SDK integration tests

* Update changelog

* Fix s3 control by adding transformer

* Throw a specific exception if the service doesn't have ep rules

* Add codecatalyst to the list of custom services
2022-12-16 12:56:16 -05:00
Zelda Hessler 59de022029
update: retry config setter docs (#2109)
update: timeout config setter docs
2022-12-15 12:42:12 -06:00
John DiSanti 5970ef7725
Break up `RustCodegenDecorator` (#2099)
This change creates `ClientCodegenDecorator` and
`ServerCodegenDecorator` in `codegen-client` and `codegen-server`
respectively to replace `RustCodegenDecorator`. Client/server
equivalents are created to replace `CombinedCodegenDecorator` as well.

This eliminates the need for the `supportsCodegenContext` method since
the decorator interface is no longer generic, so the `ServiceLoader` is
now powerful enough to differentiate.

The largest benefit, however, is that now clients and servers can have
separate customizations.
2022-12-14 13:26:55 -08:00
Burak 2cc7c24be4
Python: Use Maturin to build SDKs (#2025)
* Remove `lib` prefix from generated module names

* Build Pokemon service with `Maturin`

* Fix Maturin build on CI

* Generate minimal `pyproject.toml` for generated SDKs to build from source using Maturin

* Fix `ktlint` issues

* Bring back type stubs for Pokemon service

* Update instructions for Lambda

* Make `build-wheel` and `build-wheel-release` to depend on `codegen`
2022-12-14 12:12:58 +00:00
Burak 3fb90968d7
Python: Allow injecting Lambda Context (#1985)
* Provide Python wrappers for Lambda related types

* Introduce `PyContext` to wrap raw context object

* Use new `PyContext` in handlers

* Expose `lambda` module to Python

* Use `LambdaContext` in example service

* Start Lambda handler in a different thread

* Print summary of Lambda context in Pokemon service

* Make sure to include Python `builtins` in tests

* Make `lambda_ctx` optional

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>

* Only inject types if they are type-hinted as `Optional[T]`

* Export Lambda module as `aws_lambda` instead of `lambda_`

* Comment why we need to run Hyper server in a background thread

* Move `is_optional_of` to `util` module

* Use `HeaderMap::from_iter` to build headers

* Support edge case of `(None, T)` in `util::is_optional_of`

* Make Lambda related types feature gated

* Remove feature gate for Lambda

* Make `xray_trace_id` an `Option`

* Remove `aws-lambda` feature from generated `Cargo.toml`s

* Fix linting issues

* Pin `lambda_runtime` to `0.7.1`

* Remove duplicate dependency in `Cargo.toml`

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-12-12 17:42:40 +00:00
Burak 9d2d08802e
Python: TLS Support for servers (#2002)
* Add `PyTlsConfig` struct

* Support TLS server

* Add TLS support to Pokemon service

* Make sure to create `tokio::net::TcpListener` in a Tokio context

* Fix doc link

* Add missing imports in tests

* Add `tls::Listener`

* Reload TLS config periodically

* Add context to `TODO`

* Return `&'static str` from `base_url()`

* Flatten `match` in `tls::Listener`

* Propogate listener errors but ignore handshake errors in `tls::Listener`

* Add tests to `tls::Listener`

* Add test to `tls::Listener` to make sure we are propogating listener errors

* Use `PathBuf` instead of plain `String`s for paths
2022-12-12 16:53:11 +00:00
Zelda Hessler f3e05625e1
Fix clippy lints and run formatter (#2080)
* fix: clippy lints in integration tests
format: integration tests

* fix: clippy lints in runtime crates
format: runtime crates

* fix: clippy lints in tools
format: tools

* fix: undo clippy lint change that doesn't compile with tracing v0.1
2022-12-09 19:00:02 +00:00
Julian Antonielli 6eca6a87f2
Don't require `thiserror` 1.0.36 (#2076) 2022-12-08 14:52:00 +00:00
John DiSanti bf6cf7508a
Add `tracing` events to signing and event streams (#2057)
* Emit a trace with the string to sign when signing
* Add traces to event stream message send/receive
* Add a message to dispatch trace
2022-12-07 23:43:00 +00:00
John DiSanti 3cdf49e6cb
Improve client tracing spans (#2044)
* Emit spans for implementers of map request middleware traits
* Instrument dispatch with its own span
* Fix trace span hierarchy
* Partially flatten the middleware span hierarchy
* Make `MapRequest::name` required
* Add sub-spans to the `load_response` span
2022-12-07 23:06:16 +00:00
John DiSanti 31f1d35b62
Establish default max idle connections on default connectors (#2064) 2022-12-07 20:00:36 +00:00
Russell Cohen ddf1421be2
allow parse_url functions to be unused (#2071) 2022-12-07 19:15:57 +00:00
Russell Cohen 6beec943ab
Endpoints 2.0 Integration pre-work (#2063)
* Split endpoint resolution middleware into two parts & refactor endpoint generation

* Endpoints 2.0 Integration pre-work

This PR does a 3 bits of pre-work ahead of ep2 integration:
1. Split endpoint resolution into two separate middlewares:
  1. A smithy native middleware that applies URI and headers
  2. An AWS middleware that applies the auth schemes
2. Add vendorParams support to the ProtocolTestGenerator so that protocol tests can insert a region.
3. Simplify endpoint resolution logic by allowing `make_operation` to fail when an endpoint cannot be resolved.

* Back out previous change to insert endpoint directly into the bag

* backout changes to property bag

* Update changelog & add more docs

* Fix AWS test

* Fix test
2022-12-07 13:24:34 -05:00
82marbag 4eccaada5b
Implement FromParts for Option, Result (#2068)
* Implement FromParts for Option, Result

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-12-07 12:04:00 +00:00
John DiSanti 18fc6923c5
Remove client body callbacks (#2065) 2022-12-06 20:18:48 +00:00
82marbag 3ecefff7bb
Tracing output json (#2060)
* Tracing output json

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-12-06 12:04:58 +00:00
Harry Barber 17cb98c975
Unhide new service builder and deprecate the prior (#1886)
Co-authored-by: david-perez <d@vidp.dev>
2022-12-02 18:31:00 +00:00
Harry Barber 5073a25bdb
Various small corrections to server documentation (#2050)
* Link to super from Handler and OperationService

* Note that structure documentation is from model

* Don't refer to ZSTs in operation_shape.rs opener

* Re-export everything from service to root

* Add reference to root documentation on service

* Fix spelling of MissingOperationsError

* #[doc(hidden)] for opaque_future

* Rename from-parts.md to from_parts.md

* Fix Connected link

* Use S type parameter and service as variable name

* Remove MissingOperation dead code

* Remove Operation header from operation.rs

* Remove reference to closures

* Document ConnectInfo<T> .0

* Add BoxBody documentation

* Rephrase operation.rs documentation

* Reference PluginPipeline from PluginStack

* Move the BoxBody documentation

* Document Plugin associated types

* Add example implementation for Plugin

* Link to plugin module from Plugin

* Improve FromParts/FromRequest documentation

* Remove links to doc(hidden) RuntimeError

* Add link from Upgradable to operation module
2022-12-02 13:56:35 +00:00
Russell Cohen 84ed110fcb
Add Endpoint Resolver Implementation (#2030)
* Add Endpoint Resolver Implementation

This commit adds `EndpointDecorator`, standard libary + tests that can be used to add endpoints 2.0 to the AWS SDK.

It _does not_ actually wire these things up. We'll follow up with a PR that actually integrates everything.

* CR Feedback

* CR feedback II
2022-12-01 19:39:19 +00:00
Luca Palmieri 3652538cb8
The TODO comment should not be visible in the public docs. (#2045) 2022-12-01 12:30:59 +00:00
Harry Barber 9057bd1f61
Improve extractor errors (#2041)
Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
2022-11-30 18:03:59 +00:00
Harry Barber 97b9bb7664
Add lambda extractors (#2038) 2022-11-30 15:28:56 +00:00
Harry Barber b67f49284e
Restore `into_make_service_with_connect_info` module (#2039) 2022-11-30 13:01:43 +00:00
Luca Palmieri 3a9a42bb16
Introduce an `aws-lambda` feature. (#2035)
* Introduce an `aws-lambda` feature.

* Add CHANGELOG

* Use the new and shiny feature syntax to avoid creating an implicit `lambda_http` feature.

* Add `aws-lambda` feature to the Python server. Enable the `aws-lambda` feature in our example. Be explicit in providing an implementation of request rejection for Box<dyn Error>.

* Add an `aws-lambda` feature flag to the generated Python-specific crate. We enable it by default to make sure the Lambda method ends up visible in the final Python wrapper library.
2022-11-29 15:48:48 +00:00
Harry Barber 27020be342
Improve service documentation (#2020)
Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>

* Add module documentation to `plugin.rs`.

* Remove reference to `FromRequest` in `FromParts`.

* Improve `Route` documentation.
2022-11-25 18:14:28 +00:00
Harry Barber 86fd8f595a
Collect extractors into `request` module (#2008) 2022-11-22 11:51:17 +00:00
82marbag b2d280fcac
Multiple FromParts in handlers (#1999)
* Multiple FromParts in handlers

Handlers can have up to 8 extensions:
```
pub async fn handler(
    input: input::Input,
    ext0: Extension<...>,
    ext1: Extension<...>,
    ext2: Extension<...>,
    ext3: Extension<...>,
    ext4: Extension<...>,
    ext5: Extension<...>,
    ext6: Extension<...>,
    ext7: Extension<...>,
) -> Result<output::Output, error::Error> { ... }
```

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Harry Barber <hlbarber@amazon.co.uk>
2022-11-18 12:16:36 +00:00
Harry Barber ed5cd6e3af
Improve `Plugin` toolkit (#2003)
Co-authored-by: Julian Antonielli <julianantonielli@gmail.com>
Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
2022-11-18 11:47:13 +00:00
John DiSanti 06c23f65cc
Improve `Endpoint` panic-safety and ergonomics (#1984)
- `Endpoint::set_endpoint` no longer panics when called on an endpoint
  without a scheme
- `Endpoint::mutable` and `Endpoint::immutable` now both return a result
  so that constructing an endpoint without a scheme is an error
- `Endpoint::mutable` and `Endpoint::immutable` both now take a string
  instead of a `Uri` as a convenience
- `Endpoint::mutable_uri` and `Endpoint::immutable_uri` were added
  to construct an endpoint directly from a `Uri`
2022-11-17 00:17:22 +00:00
John DiSanti 8ef985ec49
Improve error doc comments around logging errors (#1990) 2022-11-16 19:51:15 +00:00
Luca Palmieri 044ebeac6f
Implement RFC 23, Part 2 - Plugin pipeline (#1971)
* Implement RFC 23, with the exception of PluginBuilder

* Update documentation.

* Avoid star re-exports.

* Elide implementation details in `Upgradable`.

* Update wording in docs to avoid personal pronouns.

* Update `Upgradable`'s documentation.

* Template the service builder name.

* Template MissingOperationsError directly.

* Code-generate an array directly.

* Sketch out the implementation of `PluginPipeline`.
Remove `PluginExt`.
Add a public constructor for `FilterByOperationName`.

* Ask for a `PluginPipeline` as input for the generated builder.

* Rename `add` to `push`.

* Remove Pluggable.
Rename `composer` module to `pipeline`.

* Remove all mentions of `Pluggable` from docs and examples.

* Fix punctuation.

* Rename variable from `composer` to `pipeline` in doc examples.

* Add a free-standing function for filtering.

* Rename.

* Rename.

* Update design/src/server/anatomy.md

Co-authored-by: david-perez <d@vidp.dev>

* Use `rust` where we do not need templating.

* Remove unused variable.

* Add `expect` message to point users at our issue board in case a panic slips through.

* Typo.

* Update `expect` error message.

* Refactor the `for` loop in ``requestSpecMap` into an `associateWith` call.

* Remove unnecessary bound - since `new` is private, the condition is already enforced via `filter_by_operation_name`.

* Use `Self` in `new`.

* Rename `inner` to `into_inner`

* Rename `concat` to `append` to correctly mirror Vec's API terminology.

* Fix codegen to use renamed method.

* Cut down the public API surface to key methods for a sequence-like interface.

* Add a note about ordering.

* Add method docs.

* Add Default implementation.

* Fix new pokemon bin example.

* Fix new pokemon bin example.

* Fix code-generated builder.

* Fix unresolved symbolProvider.

* Assign the `expect` error message to a variable.

* Do not require a PluginPipeline as input to `builder_with_plugins`.

* Reverse plugin application order.

* Upgrade documentation.

* Add a test to verify that plugin layers are executed in registration order.

* Add license header.

* Update middleware.md

* Typo.

* Fix more builder() calls.

Co-authored-by: david-perez <d@vidp.dev>
2022-11-16 18:10:51 +00:00
Luca Palmieri f13bb260a7
Implement RFC23 - Evolve the new service builder API (#1954)
* Implement RFC 23, with the exception of PluginBuilder

* Update documentation.

* Elide implementation details in `Upgradable`.

* Update wording in docs to avoid personal pronouns.

* Update `Upgradable`'s documentation.

* Template the service builder name.

* Template MissingOperationsError directly.

* Code-generate an array directly.

* Update design/src/server/anatomy.md

Co-authored-by: david-perez <d@vidp.dev>

* Use `rust` where we do not need templating.

* Remove unused variable.

* Add `expect` message to point users at our issue board in case a panic slips through.

* Typo.

* Update `expect` error message.

* Refactor the `for` loop in ``requestSpecMap` into an `associateWith` call.

* Fix new pokemon bin example.

* Fix new pokemon bin example.

* Fix unresolved symbolProvider.

* Assign the `expect` error message to a variable.

* Omit additional generic parameters in Upgradable when it's first introduced.

Co-authored-by: david-perez <d@vidp.dev>
2022-11-16 12:32:43 +00:00
John DiSanti 9f0bc36fa7
Make `SdkError::into_service_error` infallible (#1974) 2022-11-16 02:17:44 +00:00
John DiSanti 8dfe5a1f70
Revamp errors in `aws-smithy-types-convert` and `aws-smithy-xml` (#1917) 2022-11-15 23:21:46 +00:00
John DiSanti e36d34692a
Revamp errors in `aws-smithy-types` (#1893) 2022-11-15 21:27:46 +00:00
John DiSanti 7b6d2d4b25
Revamp errors in `aws-smithy-json` (#1888) 2022-11-15 20:35:55 +00:00
John DiSanti fba88df3ee
Revamp errors in `aws-smithy-http` (#1884) 2022-11-15 19:18:26 +00:00
david-perez b43905eabc
Builders of builders (#1342)
This patchset, affectionately called "Builders of builders", lays the
groundwork for fully implementing [Constraint traits] in the server SDK
generator. [The RFC] illustrates what the end goal looks like, and is
recommended prerrequisite reading to understanding this cover letter.

This commit makes the sever deserializers work with _unconstrained_ types
during request parsing, and only after the entire request is parsed are
constraints enforced. Values for a constrained shape are stored in the
correspondingly unconstrained shape, and right before the operation input is
built, the values are constrained via a `TryFrom<UnconstrainedShape> for
ConstrainedShape` implementation that all unconstrained types enjoy. The
service owner only interacts with constrained types, the unconstrained ones are
`pub(crate)` and for use by the framework only.

In the case of structure shapes, the corresponding unconstrained shape is their
builders. This is what gives this commit its title: during request
deserialization, arbitrarily nested structures are parsed into _builders that
hold builders_. Builders keep track of whether their members are constrained or
not by storing its members in a `MaybeConstrained`
[Cow](https://doc.rust-lang.org/std/borrow/enum.Cow.html)-like `enum` type:

```rust
pub(crate) trait Constrained {
    type Unconstrained;
}

#[derive(Debug, Clone)]
pub(crate) enum MaybeConstrained<T: Constrained> {
    Constrained(T),
    Unconstrained(T::Unconstrained),
}
```

Consult the documentation for the generator in `ServerBuilderGenerator.kt` for
more implementation details and for the differences with the builder types the
server has been using, generated by `BuilderGenerator.kt`, which after this
commit are exclusively used by clients.

Other shape types, when they are constrained, get generated with their
correspondingly unconstrained counterparts. Their Rust types are essentially
wrapper newtypes, and similarly enjoy `TryFrom` converters to constrain them.
See the documentation in `UnconstrainedShapeSymbolProvider.kt` for details and
an example.

When constraints are not met, the converters raise _constraint violations_.
These are currently `enum`s holding the _first_ encountered violation.

When a shape is _transitively but not directly_ constrained, newtype wrappers
are also generated to hold the nested constrained values. To illustrate their
need, consider for example a list of `@length` strings. Upon request parsing,
the server deserializers need a way to hold a vector of unconstrained regular
`String`s, and a vector of the constrained newtyped `LengthString`s. The former
requirement is already satisfied by the generated unconstrained types, but for
the latter we need to generate an intermediate constrained
`ListUnconstrained(Vec<LengthString>)` newtype that will eventually be
unwrapped into the `Vec<LengthString>` the user is handed. This is the purpose
of the `PubCrate*` generators: consult the documentation in
`PubCrateConstrainedShapeSymbolProvider.kt`,
`PubCrateConstrainedCollectionGenerator.kt`, and
`PubCrateConstrainedMapGenerator.kt` for more details. As their name implies,
all of these types are `pub(crate)`, and the user never interacts with them.

For users that would not like their application code to make use of constrained
newtypes for their modeled constrained shapes, a `codegenConfig` setting
`publicConstrainedTypes` has been added. They opt out of these by setting it to
`false`, and use the inner types directly: the framework will still enforce
constraints upon request deserialization, but once execution enters an
application handler, the user is on their own to honor (or not) the modeled
constraints. No user interest has been expressed for this feature, but I expect
we will see demand for it. Moreover, it's a good stepping stone for users that
want their services to honor constraints, but are not ready to migrate their
application code to constrained newtypes. As for how it's implemented, several
parts of the codebase inspect the setting and toggle or tweak generators based
on its value. Perhaps the only detail worth mentioning in this commit message
is that the structure shape builder types are generated by a much simpler and
entirely different generator, in
`ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt`. Note that this
builder _does not_ enforce constraints, except for `required` and `enum`, which
are always (and already) baked into the type system. When
`publicConstrainedTypes` is disabled, this is the builder that end users
interact with, while the one that enforces all constraints,
`ServerBuilderGenerator`, is now generated as `pub(crate)` and left for
exclusive use by the deserializers. See the relevant documentation for the
details and differences among the builder types.

As proof that these foundations are sound, this commit also implements the
`length` constraint trait on Smithy map and string shapes. Likewise, the
`required` and `enum` traits, which were already baked in the generated types
as non-`Option`al and `enum` Rust types, respectively, are now also treated
like the rest of constraint traits upon request deserialization. See the
documentation in `ConstrainedMapGenerator.kt` and
`ConstrainedStringGenerator.kt` for details.

The rest of the constraint traits and target shapes are left as an exercise to
the reader, but hopefully the reader has been convinced that all of them can be
enforced within this framework, paving the way for straightforward
implementations. The diff is already large as it is. Any reamining work is
being tracked in #1401; this and other issues are referenced in the code as
TODOs.

So as to not give users the impression that the server SDK plugin _fully_
honors constraints as per the Smithy specification, a validator in
`ValidateUnsupportedConstraintsAreNotUsed.kt` has been added. This traverses
the model and detects yet-unsupported parts of the spec, aborting code
generation and printing informative warnings referencing the relevant tracking
issues. This is a regression in that models that used constraint traits
previously built fine (even though the constraint traits were silently not
being honored), and now they will break. To unblock generation of these models,
this commit adds another `codegenConfig` setting,
`ignoreUnsupportedConstraints`, that users can opt into.

Closes #1714.

Testing
-------

Several Kotlin unit test classes exercising the finer details of the added
generators and symbol providers have been added. However, the best way to test
is to generate server SDKs from models making use of constraint traits. The
biggest assurances come from the newly added `constraints.smithy` model, an
"academic" service that _heavily_ exercises constraint traits. It's a
`restJson1` service that also tests binding of constrained shapes to different
parts of the HTTP message. Deeply nested hierarchies and recursive shapes are
also featured.

```sh
./gradlew -P modules='constraints' codegen-server-test:build
```

This model is _additionally_ generated in CI with the `publicConstrainedTypes`
setting disabled:

```sh
./gradlew -P modules='constraints_without_public_constrained_types' codegen-server-test:build
``````

Similarly, models using currently unsupported constraints are now being
generated with the `ignoreUnsupportedConstraints` setting enabled.

See `codegen-server-test/build.gradle.kts` for more details.

[Constraint traits]: https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html
[The RFC]: https://github.com/awslabs/smithy-rs/pull/1199
2022-11-15 14:06:23 +00:00
82marbag a438b7c6eb
Service with ConnectInfo (#1955)
* Service with ConnectInfo

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-11-15 10:44:22 +00:00
Zelda Hessler 15f2fbb773
Feature: configurable connectors for AWS clients (#1918)
* feature: make HTTP connectors configurable

* add: test for HTTP connector configuration customization
add: impl<B> From<TestConnection<B>> for HttpConnector
add: impl From<CaptureRequestHandler> for HttpConnector
add: impl From<NeverConnector> for HttpConnector
add: impl From<ReplayingConnection> for HttpConnector

* add: to_vec method to AggregatedBytes
update: method param names of FluentClientGenerics.sendBounds to be more explicit
update: restructure s3/s3control tests to be uniform in structure

* update: CHANGELOG.next.toml
update: codegen `impl From<&SdkConfig> for Builder` to support HTTP connectors

* update: CHANGELOG entry references

* add: missing copyright header

* fix: clippy lint

* format: run cargo fmt

* format: run cargo fmt on aws_smithy_client::dvr modules

* format: run ktlintFormat

* refactor: use from_conf instead of from_conf_conn
remove: from_conf_conn

* update: impl From<SmithyConnector> for HttpConnector
remove: other From<T> for HttpConnector impls
update: HttpConnector config setter examples

* update: CHANGELOG.next.toml

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* update: CHANGELOG.next.toml
remove: obsolete test
update: `ConfigLoader::http_connector` setter method

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Apply suggestions from code review

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* update: aws_config::loader::ConfigLoader doc comments
update: CHANGELOG.next.toml examples

* fix: doc issues
add: reëxport aws_smithy_types::endpoint module to aws-config

* format: run rustfmt in the weird CI way to get it to actually format.

* fix: incorrect reëxport

* add: "aws_smithy_http::endpoint" to allowed external types for aws-config

* update: move `hyper-rustls` to deps so that it doesn't break exotic arch CI check

* remove: `hyper-rustls` dep because it's not actually needed

* fix: aws-types dep issue blocking exotic arch CI check

* fix: broken doc comment

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-11-14 20:58:44 +00:00
82marbag 9abad1acf0
Do not use deprecated from_timestamp from chrono (#1980)
* Do not use deprecated from_timestamp from chrono

CI is failing because
[from_timestamp](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDateTime.html#method.from_timestamp)
is now deprecated.

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update changelog

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Fix error

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Use with_ymd_and_hms

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-11-14 12:27:04 -05:00
John DiSanti 12f217b38f
Revamp errors in `aws-smithy-eventstream` (#1873) 2022-11-11 23:25:13 +00:00
John DiSanti 6aef53a0b3
Revamp errors in `aws-smithy-checksums` (#1850) 2022-11-11 22:29:36 +00:00
Russell Cohen 16d212e2b7
Smithy 1.26.2 upgrade / ensure that even empty lists are serialized (#1972)
* Ensure that even empty lists are serialized

* Add must_use annotation & unit test

* Add changelog entry

* Remove test from list of failing tests
2022-11-10 17:09:43 +00:00
Burak 4f76e35f2a
Python: map Python middlewares to Tower layers (#1871)
* Python: map Python middlewares to Tower layers

* Make middleware layer infallible

* Use message and status code from `PyMiddlewareException`

* Introduce `FuncMetadata` to represent some information about a Python function

* Improve middleware errors

* Add missing copyright headers

* Allow accessing and changing request body

* Allow changing response

* Add some documentation about moving data back-and-forth between Rust and Python

* Add `mypy` to Pokemon service and update typings and comments for middlewares

* Add or update comments on the important types

* Add Rust equivalent of `collections.abc.MutableMapping`

* Add `PyHeaderMap` to make `HeaderMap` accessible from Python

* Apply suggestions from code review

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>

* Improve logging

* Add `RichPyErr` to have a better output for `PyErr`s

* Better error messages for `PyMiddlewareError` variants

* Factor out repeating patterns in tests

* Preserve `__builtins__` in `globals` to fix tests in Python 3.7.10 (our CI version)

* Export `RichPyErr` to fix `cargo doc` error

* Apply suggestions from code review

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>

* Add missing SPDX headers

* Document that `keys`, `values` and `items` on `PyMutableMapping` causes clones

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-11-10 16:22:43 +00:00
Julian Antonielli 1844660c61
Remove our `base64` implementation in favour of `base64-simd` (#1938)
* Replace our base64 implementation with one based on `base64-simd`

* Bump Rust MSRV to 1.62.1

* Unmark base64-related tests as failing

* Use `usize` for `base64::encoded_length`

* Run Rust 1.62.1 on CI

* Don't use external `base64_simd::Error` type in public interface

* Add initial criterion bench setup for base64

* Compare `base64_simd::encode` vs Smithy's `encode`

* Use string length for `BenchmarkId`

* Compare `base64_simd::decode` vs Smithy's `decode`

* Compare `base64_simd::encoded_length` vs Smithy's `encoded_length`
2022-11-09 12:08:17 +00:00
John DiSanti 9a6de1f533
Create `DisplayErrorContext` and use it in tracing statements (#1848)
* Add `DisplayErrorContext` to `aws-smithy-types`
* Apply `DisplayErrorContext` to all tracing statements
2022-11-04 21:09:15 +00:00
John DiSanti e2e0d93545
Fix retry config doc comments and remove re-export (#1935) 2022-11-04 00:09:10 +00:00
Harry Barber a026f6f6d6
Add FromParts documentation (#1930) 2022-11-01 18:04:39 +00:00
ysaito1001 f0b7f55bf5
Fix cargo audit issue on chrono (#1907)
* Avoid the chrono crate depending on the time crate

This commit is in response to RUSTSEC-2020-0071 where there is a
potential segfault in the time crate. The aws-smithy-types-convert
crate now disables the default features of the chrono crate so that
it will not depend on the time crate.

* Depend on lambda_http without RUSTSEC-2020-0071

This commit updates the version of lambda_http used by aws-smithy-http-server
and aws-smithy-http-server-python to 0.7.0. The prior version 0.6.0 of
lambda_http used the chrono crate in a way that exposed a security issue
described in RUSTSEC-2020-0071. By switching to 0.7.0 of lambda_http, those
two crates do not exhibit vulnerabilities as reported by cargo audit.

* Bump minor version of lambda_http in pokemon-service

This commit updates the version of `lambda_http` used by `pokemon-service`
from 0.6.0 to 0.7.0. This is in sync with the fact that both
`aws-smithy-http-server` and `aws-smithy-http-server-python` now depend
on 0.7.0 of `lambda_http`. Failing to do so would cause `pokemon-service`
to fail to compile due to an error at `lambda_http::run(handler)` in the
main function of the `pokemon-service-lambda` binary:
the trait `Service<lambda_http::http::Request<lambda_http::Body>>` is not
implemented for `LambdaHandler<aws_smithy_http_server::routing::Router>`

* Depend on lambda-http 0.7.1

This commit updates the version of `lambda_http` from 0.7.0 to 0.7.1 in
the crates within the top-level `rust-runtime` workspace. These updates
are needed to solve the issue described in awslabs/aws-lambda-rust-runtime#556

* Update CHANGELOG.next.toml

* Address https://github.com/awslabs/smithy-rs/pull/1907\#pullrequestreview-1161609833

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-10-31 20:06:09 +00:00
Zelda Hessler 4c852b1d0b
Add operation metadata to property bag just before sending request through middleware (#1920)
* update: add operation metadata to property bag during `make_operation`
add: test ensuring metadata is added to property bag
add: CHANGELOG.next.toml entry

* update: use new strategy for op metadata insertion
update: a new strategy requires a new test
update: CHANGELOG.next.toml

* format: run cargo fmt
2022-10-28 15:30:41 -05:00
Russell Cohen fc57e13cad
Update changelog and use you task::spawn helper (#1915) 2022-10-27 15:09:18 +00:00
david-perez f92855f6e0
Bump `wrk-api-bench` to v0.0.8 (#1908)
The current version is vulnerable. See
https://github.com/crisidev/wrk-api-bench-rs/pull/1.
2022-10-27 14:13:37 +00:00
Russell Cohen 16e34a5dec
Fix FnStream generator polling to prevent poll-after-ready (#1903)
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-10-26 17:32:24 +00:00
david-perez fb631b4f4c
Export `Router` from `aws-smithy-http-server` crate root again (#1910)
This reverts unintentional breakage introduced in
`aws-smithy-http-server` v0.51.0.
2022-10-26 17:09:05 +02:00
82marbag 50e85724b4
Route::new in upgrade (#1891)
* Route::new in upgrade

Move the creation of Routes in Upgradable to have a cleaner sequence of
constraints in ServiceBuilder::build

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-10-26 09:44:37 +00:00
ysaito1001 b4f294c277
Replace bool with enum for a function parameter of label::fmt_string (#1875)
* Replace bool with enum in label::fmt_string

This commit addresses code smell where the said function takes a bool
to decide whether it percent-encodes the UTF-8 encoding of the given
string. For clarity, we define an enum EncodingStrategy so that we
can see the callers' intent at the call sites by reading the variant
names rather than true/false.

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Make test use updated function signature of fmt_string

This commit modifies a call site for the updated function signature of
`aws_smithy_http:🏷️:fmt_string`, otherwise the test would fail to
compile, leading to a failure in CI.

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-10-25 20:39:28 +00:00
Matteo Bigoi 7e666dab8b
Support PowerPC architecture for sigv4 signature (#1847)
* Use hmac and sha2 instead of ring on powerpc

* Enable aws-sig-auth in CI

* Update CHANGELOG

* Run tests against exotic platforms

* Run tests only against aws rust runtime

* PowerPC 32 and 64 bit should be fully testable now

* Maybe this time build and test will work

* Add licence header to hmac.rs

* Properly use finalized_fixed

* Revert leftover

* Temporary disable crc32c test on powerpc

* Temporary disable system_time_conversion_test on 32bit CPUs

* Disable other 3 tests on 32bit

* Temporarily disable last test

* Update CHANGELOG and document TODOs with issues

* Run aws-smithy-client tests in CI with crosscompiled local openssl

* Simplify CI script

* Use correct curl options

* Use the right OS for i686

* Looks like I finally foung the right os type for i686

* Add `tcp` feature to `hyper` to get tests compiling.

* Enable verbose logging to debug CI failure in cross.

* Use pre-built openSSL on i686

* Fix empty spaces.

* Set environment variables based on matrix.target

* Remove all usages of `ring` from `aws-sigv4`. It ensures broader platform compatibility and higher performance.

* Update changelog entries.

* Remove redundant dev dependencies.

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
2022-10-25 17:05:55 +00:00
Harry Barber c18b1a0ab7
Add middleware documentation (#1844)
* Tweak plugin.rs documentation

* Add middleware.md
2022-10-25 12:21:20 +00:00
John DiSanti 03b83473ff
Pin `derive_arbitrary` version (#1887) 2022-10-21 09:40:28 -05:00
Zelda Hessler b4f0b28b5c
update: aws-smithy-xml "xmlparser" dep to v0.13.5 (#1880)
rename: aws-smithy-xml test with misleading name
Co-authored-by: dvc94ch <david@craven.ch>
2022-10-19 18:45:31 +00:00
Julian Antonielli 007f1bfc7c
Use pin-utils crate instead of vendoring pin_mut (#1862) 2022-10-19 10:28:56 +01:00
Burak c5dae879a5
Python: Migrate to new service builder (#1846)
* Python: Migrate to new service builder

* Fix orderings of imports
2022-10-17 15:52:37 +01:00
Harry Barber 55d16b1131
Make protocol ZSTs match shape ID names (#1858) 2022-10-17 14:00:43 +00:00
Luca Palmieri 18d969e160
Upgrade to Rust 1.62.0 (#1825)
* Run clippy --fix for Rust 1.62.0 and format the resulting code

* Run clippy --fix on all targets

* Run clippy --fix with all features enabled

* Avoid extra allocation

* Use more idiomatic assert

* Ignore noisy lint

* Update pyo3 and pyo3-asyncio to 0.17.0

* Implement Eq on aws-smithy-checksums::Error

* Implement Eq on Protocol

* Replace conditionals with range-containment

* Implement Eq on types in aws-smithy-types

* Implement Eq on types in aws-smithy-http-server-python

* Implement Eq on types in aws-smithy-eventstream

* Implement Eq on types in aws-smithy-xml

* Implement Eq on aws-sigv4

* Update CI to use Rust 1.62.0

* Add Eq for generated types that implement PartialEq

* Allow clippy::needless_return in generated code

* Remove unnecessary reborrow in http_serde

* Remove unnecessary borrow in operation_deser

* Add CHANGELOG entries

* Revert "Add Eq for generated types that implement PartialEq"

This reverts commit 5169bd95aa.

* Update pyo3 and pyo3-asyncio in generated code for python server

* Allow clippy::derive_partial_eq_without_eq on structs and builders

* Run clippy on tools

* Fix accidental move in generated code

* Revert "Allow clippy::derive_partial_eq_without_eq on structs and builders"

This reverts commit 068c63ca20.

* Fix another accidental move in generated code

* Undo unwanted change to model

* Re-add reborrow in HttpBindingGenerator

* Fix clippy::format-push-string in changelogger

* Fix more uses of str.push_str(&format!(...))

* Remove unnecessary parenthesis

* Run ktlint

* Update aws/rust-runtime/aws-http/src/content_encoding.rs

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Update aws/rust-runtime/aws-http/src/content_encoding.rs

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Ignore doctest for non-exported macro

Rust 1.62 introduced a breaking change where doctests for non-exported
macros are now run by default. These don't compile because the macro
can't be imported in it.
See https://github.com/rust-lang/rust/issues/97030 for more info.

* Run cargo fmt

* Use $crate instead of crate in macro

* Revert "Implement Eq on types in aws-smithy-types"

This reverts commit c45a6b5a56.

* Revert "Implement Eq on types in aws-smithy-eventstream"

This reverts commit 78f4b07344.

* Revert "Implement Eq on types in aws-smithy-xml"

This reverts commit 590f01af73.

* Revert "Implement Eq on aws-sigv4"

This reverts commit d78bb62124.

* Revert "Implement Eq on types in aws-smithy-http-server-python"

This reverts commit f2cd901884.

* Revert "Implement Eq on aws-smithy-checksums::Error"

This reverts commit 5da170405e.

Co-authored-by: Julian Antonielli <julianantonielli@gmail.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-10-17 09:32:12 +01:00
Harry Barber d879da1f14
Add PluginExt extension trait and FilterByOperationName plugin (#1837)
* Make Operation fields public

* Split into modules and add FilterByOperationName
2022-10-11 22:54:24 +00:00
Harry Barber bf3fbc2e1d
Add "Anatomy of a Service" documentation (#1782)
* Rust documentation improvements

* Add "Anatomy of a Service" documentation
2022-10-11 18:40:49 +00:00
Burak eb6ffe3520
Lambda support for Python servers (#1807)
* Allow running Python servers with Lambda handler

* Fix doctests

* Add `Running servers on AWS Lambda` section to docs

* Remove empty spaces from `README` to make linter happy

* Rename `run_lambda_server` to `run_lambda_handler`

* Add more comments to example `Dockerfile`

* Fix capitalization of logs

* Preserve original formatting of `PythonApplicationGenerator.kt`
2022-10-11 12:03:44 +01:00
Luca Palmieri b547045a5a
Add a new CI job to check that smithy-rs compiles on 32bit Linux-based targets (#1812)
* Replace AtomicU64 with AtomicUsize to prevent compilation issues on 32 bits platforms.

* Make sure that Rust tests compile on MacOS.

* Add CHANGELOG next entry.

* Add a new CI job to check that smithy-rs compiles on 32bit Linux-based targets.

* No trailing commas pretty please.

* Point cross at the manifest explicitly.

* Skip crates with a Python dependency. Exercise all features.

* Install required dependencies.

* Do not fail fast, we want to see the result on all platforms.

* Set paths for both commands.

* Openssl must be installed inside the cross Docker container, not on the host machine.

* Fix connector setup if `rustls` feature is not enabled.

* Restrict feature set on powerpc.

* Pass openssl env variables to the cross Docker container

* Split in two commands.

* Enable debug level logs.

* Remove openssl feature (temporarily).

* Raise verbosity.

* Trigger CI

* `native-tls`, here we go again.

* Clean up.

* Trigger CI

* Trigger CI

* Add pkg-config.

* Change include path to include arch

* Trigger CI

* Allow workflow_dispatch on ci-pr to enable triggering this CI workflow from the GitHub web interface.

* Trigger CI? Why are you doing this to me GitHub?

* Trigger CI? Are you alive GitHub?

* Fix env variables for openssl

* Use features only for rust-runtime crates.

* Check all feature combinations for aws-smithy-client

* Dry-up env variables.

* A rogue `echo` was missing

* Feature-gate doc tests based on the features they require.

* Put .github folder under shared ownership.

* Fix docs.

* Fix feature selection for doctest.

* We are using methods that are only available if rustls is enabled - adjust feature gates accordingly.

* Remove workflow dispatch trigger.
2022-10-10 17:50:37 +00:00
Harry Barber 78022d69ef
Remove Protocol enum (#1829)
* Remove Protocol enum

* Update Python implementation
2022-10-10 14:29:37 +01:00
Luca Palmieri 1b2b42d6ae
Support 32bits targets (#1811)
* Replace AtomicU64 with AtomicUsize to prevent compilation issues on 32 bits platforms.

* Make sure that Rust tests compile on MacOS.

* Add CHANGELOG next entry.
2022-10-06 10:17:47 +01:00
david-perez 4ba6063f25
Move all binaries in the Pokémon service example under `src/bin` (#1788)
We're currently being inconsistent in that only the TLS example is under
`src/bin`, but the other two are under `src/`.
2022-10-05 11:49:06 +00:00
Burak 7fb7e177d0
Simplify Python Pokemon service (#1773)
* Simplify Python Pokemon service

* Use `threading.Lock` instead of `multiprocessing.Lock`

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>

* Explain why we need to pass `force=True`

* Add comment about synchronization of `Context` class

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-10-03 15:03:17 +01:00
kastolars 4cfac14d49
Getters added to ConfigImpl (#1761) 2022-09-29 16:43:07 +00:00
Harry Barber dcfb85578e
Add Instrumentation documentation (#1772)
* Add documentation covering instrumentation approaches for Smithy Rust.

* Tweak the logging in the Pokemon service to better exemplify instrumentation.
    * Remove `TraceLayer` which violates sensitivity contract.
    * Switch to [Pretty](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/format/struct.Pretty.html) logs to better showcase the outputs.

* Update [Logging in the Presence of Sensitive Data](https://github.com/awslabs/smithy-rs/pull/1536) checklist.
* Rename `logging` module to `instrumentation` to improve coherence across struct names and documentation.
2022-09-28 12:57:48 +01:00
John DiSanti 8e0b440437
Improve timeout config ergonomics and add SDK default timeouts (#1740)
* Overhaul timeout configuration
* Improve resiliency re-exports
* Refactor Smithy client retry config handling in builder
* Remove non-standard timeout env vars and profile keys
* Break operation customization codegen into its own file
* Move operation customization into a submodule
* Improve operation customization re-exports
* Add integration tests for read and connect timeouts
* Fix connector timeout config in the Smithy `Client` builder
* Rename `HttpSettings` to `ConnectorSettings`
2022-09-27 01:15:23 +00:00
Harry Barber 42a84576ac
Vend tracing instrumentation as a Plugin (#1738)
* Add InstrumentLayer and InstrumentPlugin

* Add Sensitivity codegen
2022-09-26 19:33:41 +01:00
Harry Barber 004eb68793
Updates and fixes to HttpSensitivityGenerator (#1755)
* Simplify sensitivity detection logic by assuming bindings only exist at top level input/output.

* Fix greedy label logic - they can now exist alongside of normal labels.

* Fix `httpPrefixHeader` false positive.

* Export `RequestFmt` and `ResponseFmt` types alongside the closures.

* More extensive use of `Writable` to improve readability.
2022-09-26 16:33:57 +01:00
Harry Barber 9405f00014
Cleanup pokemon.smithy (#1763)
* Remove Operation suffix

* Remove reuse of @output

* Add full-stops

* Rename to {Verb}{Qualifier}{Noun}

* Symlink pokemon operations

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-09-23 17:37:32 +00:00
Matteo Bigoi e5c8cf3061
[Python] Allow to run pure Python request middlewares inside a Tower service (#1734)
## Motivation and Context
* Customers want to be able to implement simple middleware directly in Python. This PR aims to add the initial support for it.
* Improve the idiomatic experience of logging by exposing a handler compatible with Python's standard library `logging` module.

## Description
### Middleware
A middleware is defined as a sync or async Python function that can return multiple values, following these rules:

* Middleware not returning will let the execution continue without changing the original request.
* Middleware returning a modified Request will update the original request before continuing the execution.
* Middleware returning a Response will immediately terminate the request handling and return the response constructed from Python.
* Middleware raising MiddlewareException will immediately terminate the request handling and return a protocol specific error, with the option of setting the HTTP return code.
* Middleware raising any other exception will immediately terminate the request handling and return a protocol specific error, with HTTP status code 500.

Middlewares are registered into the Python application and executed in order of registration.

Example:

from sdk import App
from sdk.middleware import Request, MiddlewareException

app = App()

@app.request_middleware
def inject_header(request: Request):
    request.set_header("x-amzn-answer", "42")
    return request

@app.request_middleare
def check_header(request: Request):
    if request.get_header("x-amzn-answer") != "42":
        raise MiddlewareException("Wrong answer", 404)

@app.request_middleware
def dump_headers(request: Request):
    logging.debug(f"Request headers after middlewares: {request.headers()}")

**NOTE: this PR only adds support for request middlewares, which are executed before the operation handler. Response middlewares, executed after the operation are tracked here: https://github.com/awslabs/smithy-rs/issues/1754.**

### Logging
To improve the idiomatic experience, now logging need to be configured from the Python side by using the standard `logging` module. This allows customers to opt-out of our `tracing` based logging implementation and use their own and logging level is now driven by Python.

import logging
from sdk.logging import TracingHandler

logging.basicConfig(level=logging.INFO, handlers=[TracingHandler.handle()])

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: Burak <burakvar@amazon.co.uk>
2022-09-22 18:01:48 +00:00
82marbag 43e3e29840
Expand protocol layouts (#1753)
Split runtime protocols layout

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-22 09:10:51 +00:00
Nicolas Farrier ff13b087fe
Run `cargo clippy` when building the Pokémon Service (#1742) 2022-09-21 11:26:02 +00:00
Vojtech Kral b02f9ade3c
aws-smithy-http-tower: Lower log level of two info logs (#1735) 2022-09-19 17:40:26 +00:00
82marbag 0313a3c7b8
Allow third-party devs to write custom plugins for service builders (#1736)
* Allow custom layers to every operation

Third-party developers can add custom functions to a service builder,
through a `BuilderModifier`.
These functionalities are applied to every operation of that service.

An example of a builder modifier can be found in
rust-runtime/aws-smithy-http-server/examples/pokemon-service/lib.rs

Signed-off-by: Harry Barber <hlbarber@amazon.co.uk>
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Harry Barber <hlbarber@amazon.co.uk>
2022-09-16 08:53:54 +00:00
John DiSanti e6177b3dc2
Fix native Smithy client retry and retry response errors (#1717)
* Fix retry for native Smithy clients
* Treat `SdkError::ResponseError` as a retryable transient failure
* Rename `ClassifyResponse` to `ClassifyRetry`
* Rename 'policy' to 'classifier' in AWS SDK public API
* Rename `AwsResponseClassifier` to `AwsResponseRetryClassifier`

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-09-14 20:36:17 +00:00
82marbag f324240b27
Unsupported content type (#1723)
Add validation for the Content-Type header and pass (remove from the failing
list) the relevant protocol tests

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-13 18:18:34 +00:00
Harry Barber fd94858db8
Add new service builder codegen (#1693)
* Add `ServerProtocol` interface to allow for server side protocol specific methods.

* Make public the structs merged in https://github.com/awslabs/smithy-rs/pull/1679.

* Add `ServerOperationGenerator`, which generates a ZST and implements `OperationShape` on it.

* Add `ServerServiceGeneratorV2`, which generates the service newtype around a router and a service builder.

* Add `hidden` argument to `RustModule` which allows modules to be marked with `#[doc(hidden)]`.

* Add `BuildModifier` trait to provide a common interface for extending service builders.

* Add `Upgradable` trait to simplifying bounds when upgrading from an `Operation` to a HTTP service.

* Add `FromRequest`, `FromParts`, and `IntoResponse` implementations.

* Make `RoutingService` accept general body types `B` for the inner services `http::Response<B>`.

* Use new service builder in protocol tests.
2022-09-12 14:27:41 +01:00
Harry Barber e0083877a0
Escape routing regex in path segment literals (#1719)
* Add unsanitary_path test

* Escape literals
2022-09-08 14:54:18 +00:00
John DiSanti 96e9f61fee
Establish the `codegen-core` module (#1697)
* Create the `codegen-core` module
* Move the `Version` class into `codegen-core`
* Rename `codegen` to `codegen-client`
* Rename `codegen-test` to `codegen-client-test`
* Move shared test models to common location
* Fix Smithy validation errors in `misc.smithy`
2022-09-07 09:31:46 -07:00
Zelda Hessler 50d88a5bf5
Feature: Customizable Operations (#1647)
feature: customizable operations
update: CHANGELOG.next.toml
update: RFC0017
update: add IntelliJ idea folder to .gitignore
add: GenericsGenerator with tests and docs
add: rustTypeParameters helper fn with tests and docs
add: RetryPolicy optional arg to FluentClientGenerator
move: FluentClientGenerator into its own file
2022-09-02 17:47:25 -05:00
Russell Cohen 373d866aa4
Bump minimum regex version (#1684) 2022-09-02 04:42:16 +00:00
John DiSanti 353d81c539
Improve manual config experience for SDK retries and timeouts (#1603)
* Remove `Default` implementation from `RetryConfig`
* Add use case integration tests
* Panic when retries/timeouts are enabled without a `sleep_impl`
* Combine the sleep, retry, and timeout customizations
* Add `sleep_impl` validation to the Smithy client builder
2022-09-01 17:12:06 +00:00
John DiSanti 31c5a91a25
Upgrade min versions of tokio, tracing-subscriber, and criterion (#1662)
* Upgrade minimum Tokio version to 1.8.4

This addresses RUSTSEC-2021-0072 and RUSTSEC-2021-0124.
The SDK, runtime crates, and server are set to the minimum secure
version of Tokio to allow a larger range of versions to be used by
consumers of those libraries. The tools and the Python server are
both set to the latest Tokio version since they are not intended
to be consumed as a libraries.

* Upgrade `tracing-subscriber` to 0.3.15

* Upgrade `criterion` to 0.3.6

This addresses RUSTSEC-2021-0093 by upgrading `criterion`, which
upgrades `rayon`, which upgrades `crossbeam-deque`.
2022-08-31 21:19:04 +00:00
Harry Barber 66f96a542a
Add new service builder machinery (#1679)
* Add protocol specific `FromRequest` and `FromParts`.

* Add `OperationShape` trait to model Smithy operations.

* Add `Handler` and `OperationService` traits.

* Add `Upgrade` `Service` and `UpgradeLayer` `Layer`.
2022-08-31 14:39:27 +00:00
Russell Cohen 6e96137ca7
Add partition function (#1682) 2022-08-30 18:18:27 +00:00
John DiSanti 2bcf4da6b8
Fix CI by pinning version of `arbitrary` (#1681) 2022-08-30 09:13:45 -05:00
Russell Cohen 0ea576fc4e
Endpoints 2.0 Standard Library functions (#1667)
* Endpoints 2.0 Standard Library functions

* Endpoints Standard Library Cleanups
2022-08-29 16:05:26 +00:00
Weihang Lo df077c9787
Use `tokio::sync::Mutex` to make lock get across yield point (#1677) 2022-08-26 18:12:32 +00:00
Harry Barber 778539f452
Add protocol specific routers (#1666)
* Add protocol specific routers

* Replace internals of `Router` with protocol specific routers
2022-08-26 17:53:34 +01:00
Zelda Hessler a65b1aaa8d
Update MSRV to 1.61.0 (#1672) 2022-08-25 15:43:35 -07:00
Matteo Bigoi 6b356c4859
Reference issue for unsupported media type (#1664) 2022-08-24 10:54:11 +00:00
Russell Cohen fc1e1799da
Refactor endpoints to be Smithy-native (#1641)
* Refactor endpoints to be Smithy-native

* Add test to DynamoDb

* Fix clippy

* Fix some clippy errors and update changelog
2022-08-23 19:19:16 +00:00
Harry Barber 613da81594
Use . delimiter in OperationExtension (#1651)
* Change OperationExtension to require "."

* Switch codegeneration to use "."
2022-08-23 10:20:59 +00:00
82marbag 9bfd1b2c0a
Forbid inf/nan in epochs (#1650)
* Forbid inf/nan in epochs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-08-22 20:36:50 +00:00
Matteo Bigoi 5455c4e9cc
Fix bug in coroutine scheduling. Add ByteStream implementation and simplify Python symbol visitor. (#1633)
* Fix bug in coroutine scheduling. Add ByteStream implementation and simplify Python symbol visitor.

* Bug in coroutine scheduling:

In the previous iteration, the runtime crate aws-smithy-http-server-python
was exposing the python application implementation as a struct, which
was wrapped by the codegenerated App to allow to dynamically building
the router.

This caused scheduling of coroutines (handlers prefixed with async def)
to block becuse we were passing the Python eventloop of the parent
process that was stored pre-fork().

This commit changes the runtime PyApp to become a trait, allowing us to
dynamically build the router post-fork() and with the right event loop.

This change also allowed us to remove a bunch of unnecessary Arc(s).

* Add ByteStream implementation

Implementation of a ByteStream type for Python that can be roughly used like this:

let b = await ByteStream.from_path("file.txt")
async for chunk in b:
    print(chunk)

Implement futures_core::stream::Stream for Python ByteStream wrapper.

The BytesStream implementation in python can now use a sync Mutex from
parking_lot because we are now using pyo3_asyncio::tokio::local_future_into_py()
to read a chunk, which supports !Send futures.

This allows to simply forward the implementation of Stream (poll_next()
and size_hint()) directly to our inner SDK ByteStream.

* Simplify Python symbol visitor

Inherit from Symbol visitor and override just what is needed to swap Python complex
types.

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
2022-08-19 19:09:10 +01:00
david-perez 7e7d571845
Refactor converters to numeric types for `aws_smithy_types::Number` (#1274)
Currently, conversions from `aws_smithy_types::Number` into numeric Rust
types (`{i,u}{8, 16, 32, 64}` and `f{32, 64}`) are always lossy, because
they use the `as` Rust keyword to cast into the target type. This means
that clients and servers are accepting lossy data: for example, if an
operation is modeled to take in a 32-bit integer as input, and a client
incorrectly sends an integer number that does not fit in 32 bits, the
server will silently accept the truncated input. There are malformed
request protocol tests that verify that servers must reject these
requests.

This commit removes the lossy `to_*` methods on `Number` and instead
implements `TryFrom<$typ> for Number` for the target numeric type
`$typ`. These converters will attempt their best to perform the
conversion safely, and fail if it is lossy.

The code-generated JSON parsers will now fail with
`aws_smithy_json::deserialize::ErrorReason::InvalidNumber` if the number
in the JSON document cannot be converted into the modeled integer type
without losing precision. For floating point target types, lossy
conversions are still performed, via `Number::to_f32_lossy` and
`Number::to_f64_lossy`.
2022-08-19 11:42:14 +00:00
Hugo Bastien 9ee45bfd44
feat: support for server `lambda_http::Request` (#1551)
Co-authored-by: david-perez <d@vidp.dev>
2022-08-19 10:13:07 +00:00
82marbag b98b160799
Allow `*` in ACCEPT header (#1646)
Allow `*` in ACCEPT header

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-08-18 17:20:59 +00:00