Commit Graph

548 Commits

Author SHA1 Message Date
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 529024116a
Merge changelog from the `smithy-rs-release-0.55.x` branch (#2731)
## Motivation and Context
This PR merges the changelog changes made by the release script from the
`smithy-rs-release-0.55.x` branch.

----

_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: AWS SDK Rust Bot <aws-sdk-rust-primary@amazon.com>
2023-05-26 00:39:17 +00:00
ysaito1001 7ccac0607c
Add `NoCredentialsCache` that offers no caching ability (#2720)
## Motivation and Context
Related to https://github.com/awslabs/aws-sdk-rust/issues/809

## Description
It has been discovered that when `AssumeRoleProvider` is used, the Rust
SDK emits `credentials cache miss occurred` twice per request. The
reason why that log is shown twice is illustrated in the following
diagram:

![Screenshot 2023-05-19 at 4 10 20
PM](https://github.com/awslabs/smithy-rs/assets/15333866/c6cce018-c821-4b46-8d47-b414af7b4d1e)

One of the cache miss messages is due to the fact `AssumeRoleProvider`
internally uses an STS client, which, in turn, is wrapped by a
`LazyCredentialsCache` by default. However, that use of
`LazyCredentialsCache` is pointless because caching is already in effect
with the outermost `LazyCredentialsCache`.

This PR adds a new kind of `CredentialsCache`, `NoCredentialsCache`. As
its name suggests, it simplify delegates `provide_cached_credentials` to
the underlying provider's `provide_credentials` with no caching
functionality. We then update `SsoCredentialsProvider`,
`AssumeRoleProvider`, and `WebIdentityTokenCredentialsProvider` to use
`NoCredentialsCache` for their STS clients so the logs won't show
`credentials cache miss occurred` twice per request.

## Testing
- Added unit tests for `NoCredentialsCache`
- Updated unit test for `AssumeRoleProvider` to verify
`NoCredentialsCache` is used by default

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

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-05-24 21:53:30 +00:00
Russell Cohen bbe9d52a76
Fix the error message for SSO credential providers (#2722)
## Motivation and Context
The current error if the SSO error message is not enabled is inscrutable
and doesn't point the customer towards the removed feature.

## Description
Fix the error message, add tests.

## Testing
tests

## 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-23 19:15:47 +00:00
John DiSanti 040d0e42d5
Fix client operation name collisions with the standard library prelude (#2696)
## Motivation and Context
Operations named `Send` or `Sync` (and probably others) were colliding
with the types in the standard library prelude and causing compiler
errors. This PR adds tests that include all the type names from the Rust
prelude, and fixes the compiler errors they cause.

In the future, the `no_implicit_prelude` attribute can be added to
certain code generated modules to better enforce that there can't be
name collisions, but for now, the `tokio::test` macro doesn't compile
with that attribute enabled (and likely other macros from other
libraries).

## 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-12 22:47:31 +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
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
ysaito1001 91194e786c
Avoid extending IMDS credentials expiry unconditionally (#2694)
## Motivation and Context
Fixes https://github.com/awslabs/smithy-rs/issues/2687

## Description
The implementation for IMDS static stability support introduced a bug
where returned credentials from IMDS are extended unconditionally, even
though the credentials are not stale. The amount by which credentials
are extended is randomized and it can incorrectly extend the expiry
beyond what's originally set. IMDS produces credentials that last 6
hours, and extending them by at most 25 minutes usually won't be an
issue but when other tools such as Kube2iam and AWSVault are used, the
expiry can be set much shorter than that, causing the issue to occur.

This PR will conditionally extend the credentials' expiry only when the
returned credentials have been expired with respect to the current wall
clock time. Also, the constant values have been adjusted according to
our internal spec.

## Testing
- Added a new unit test for the IMDS credentials provider

## 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 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>
2023-05-11 00:46:33 +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
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
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 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
Burak cfd22450ee
Remove `CHANGELOG.next.toml` entries that have been released with `v0.55.2` (#2624)
## Motivation and Context
Removes changelog entries that have been released with `v0.55.2`
(https://github.com/awslabs/smithy-rs/pull/2623)

## Description
<!--- Describe your changes in detail -->

## 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-04-26 17:14:46 +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
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
david-perez 63a1e78f58
Fix server code generation of `@httpPayload`-bound constrained shapes (#2584)
The issue is we're not changing the return type of the payload
deserializing function to be the unconstrained type (e.g. the builder in
case of an `@httpPayload`-bound structure shape) when the shape is
constrained.

Yet another example of why code-generating `constraints.smithy` (see
#2101)
is important.

Closes #2583.

## Testing

The added integration test operation fails to compile without this
patch.

## 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-04-19 09:48:34 +00:00
david-perez 80f25d42dc
Fix generation of constrained shapes reaching `@sensitive` shapes (#2585)
Constrained shapes should always be able to `#[derive(Debug)]`.

Fixes #2582.

## Testing

The modified integration test fails without this patch applied.

## 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: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-04-18 10:35:22 +00:00
John DiSanti 04cf5e6c2c
Fix typo in changelog entry (#2587)
_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-18 09:41:00 +00:00
Antoine Büsch fc63800f6a
Implement `StdError::source()` for Error enum (#2564)
## Motivation and Context
This is an attempt at fixing
https://github.com/awslabs/aws-sdk-rust/issues/784.

The service-level `Error` enum implements `std::error::Error` but does
not implement its `source()` method. This means that an error library
like `anyhow` or `eyre` won't be able to display the root cause of an
error, which is especially problematic for the `Unhandled` variant.

## Description
I modified `ServiceErrorGenerator` in the `codegen-client` crate and
replaced the line that output `impl std::error::Error for Error {}` with
an impl block that implements the `source()` method by delegating to the
inner error structure.

## Testing
I've added a simple unit test to `ServiceErrorGeneratorTest`.

## 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-04-17 13:51:01 +00:00
ysaito1001 35f2f27a83
Re-export `aws_smithy_types::date_time::Format` in service client crates (#2534)
* Add more client crate re-exports

This commit adds two more client re-exports that were not included
in smithy-rs#2437:
- `aws_smithy_http::byte_stream::Length`
- `aws_smithy_types::date_time::Format`

* Remove re-export of `aws_smithy_http::byte_stream::Length`

This commit removes re-export of `aws_smithy_http::byte_stream::Length`
for now as it is a feature-gated type, which requires further consideration.

* CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-04-13 22:58:43 +00:00
Zelda Hessler 33b24bb7f3
fix: signing params debug impl (#2562)
* fix: redact credentials when debug logging signing params

* update: CHANGELOG.next.toml

* yuki makes a good point
2023-04-10 18:46:07 +00:00
Russell Cohen ee324f2724
Fix bug in WriteGetObjectResponse endpoint (#2560) 2023-04-10 15:24:00 +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
Martin Jesper Low Madsen b023426d1c
Add support for omitting session token in canonical requests (#2473)
* Add support for omitting session token in canonical request

* Add tests to cover session token exclusion in signed headers

* Remove redundant session token insertion

* Drop mut canonical_headers

* Skip adding x-amz-security-token to signed headers if excluded

* 📎

* cargofmt

* Update changelog

* Update CHANGELOG.next.toml

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

---------

Co-authored-by: Russell Cohen <rcoh@amazon.com>
Co-authored-by: John DiSanti <johndisanti@gmail.com>
2023-03-30 18:11:16 +00:00
ysaito1001 aae9ee1aec
Make AppName configurable from within ConfigLoader (#2513)
* Add setter for `app_name` in `ConfigLoader`

This commit adds a setter for `app_name` in `ConfigLoader`. Prior to the
commit, the field was settable only from `SdkConfig` onward.

* Update CHANGELOG.next.toml

* 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 aws/rust-runtime/aws-config/src/lib.rs

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

* Make empty string an invalid AppName

This commit addresses https://github.com/awslabs/smithy-rs/pull/2513#discussion_r1153074370

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-03-30 16:57:56 +00:00
Zelda Hessler 1d7dbd6b1f
fix: handling of S3 part-level checksums (#2512)
* fix: handling of S3 part-level checksums

* add: CHANGELOG.next.toml entry

* add: missing integration test dep to codegen

* fix: use - instead of _
2023-03-30 15:33:12 +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 48bd719743
Remove `enableNewCrateOrganizationScheme` codegen flag (#2507) 2023-03-29 16:57:32 +00:00
John DiSanti b65a645ce1
Fix request ID logging for streaming operations (#2495) 2023-03-27 21:34:38 +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
John DiSanti 3f738ca7c8
Update changelog (#2497)
Co-authored-by: AWS SDK Rust Bot <aws-sdk-rust-primary@amazon.com>
2023-03-24 17:54:26 +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
Russell Cohen de97b3d7f3
Remove deprecated ResolveAwsEndpoint and related interfaces. (#2464)
* Remove deprecated ResolveAwsEndpoint and related interfaces.

* update changelog with pointer

* Rename AwsEndpointDecorator to have a more appropriate name

* Allow endpoint resolver to be omitted
2023-03-21 12:43:04 +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 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
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
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 eb261e63ab
Enable crate reorganization for the SDK (#2433)
* Enable the crate reorg for the SDK

* Fix `aws-config`

* Fix SDK integration tests

* Fix event stream error module bug

* Fix doc test imports

* Fix some tests

* Fix external type check

* Fix the canary for both versions

* Fix codegen crash for certain SDK models

* Fix some doc compilation failures

* Update the changelog

* Fix presigning test merge conflict
2023-03-13 22:28:15 +00:00
Zelda Hessler 06b865bcd7
update: enable presigned S3 HeadObject requests (#2451)
* update: enable presigned S3 HeadObject requests

* add: CHANGELOG entry

* Update CHANGELOG.next.toml

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

---------

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-03-13 20:08:54 +00: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
ysaito1001 7f4152cc93
Add more client re-exports (#2437)
* Add more client re-exports

This commit adds more client re-exports proposed in
https://github.com/awslabs/smithy-rs/issues/1759.
Specifically, it re-exports the following types:
- `aws_smithy_http::body::SdkBody`
- `aws_smithy_http::byte_stream::error::Error`
- `aws_smithy_http::operation::{Request, Response}`

* Update CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-03-09 17:13:03 +00: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
John DiSanti 7ce80320ed
Make it possible to create `SdkError` context structs for tests (#2428) 2023-03-03 17:12:45 +00:00
Harry Barber 530386e504
Update changelog to reflect 0.54.x branch releases (#2411) 2023-02-23 19:48:37 +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
Fahad Zubair 3d007674b9
Constraint member types are refactored as standalone shapes. (#2256)
* Constraint member types are refactored as standalone shapes.

* ModelModule to ServerRustModule.model

* Constraints are written to the correct module

* Code generates for non-public constrained types.

* Removed a comment

* Using ConcurrentHashmap just to be on the safe side

* Clippy warnings removed on constraints, k.into() if gated

* Wordings for some of the checks changed

* Test need to call rustCrate.renderInlineMemoryModules

* ktlintFormat related changes

* RustCrate need to be passed for server builder

* Param renamed in getParentAndInlineModuleForConstrainedMember

* pubCrate to publicConstrainedType rename

* PythonServer symbol builder needed to pass publicConstrainedTypes

* @required still remains on the member shape after transformation

* ConcurrentLinkedQueue used for root RustWriters

* runTestCase does not run the tests but just sets them up, hence has been renamed

* CHANGELOG added

---------

Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
2023-02-17 19:21:01 +00:00
82marbag 5a5a7c44d6
Nested server structure member shapes targeting simple shapes with default trait (#2352)
* Nested server structure member shapes targeting simple shapes with `@default`

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

* Add changelog entry

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

* Update CHANGELOG

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

* Add unit test

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

* Add integration test

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

* Change method

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

* Include comment to describe the test

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

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-02-17 18:19:34 +00:00
Zelda Hessler d54c005ade
add: deprecation notice to deprecated fluent builder methods (#2386)
* add: deprecation notice to deprecated fluent builder methods

* add: CHANGELOG.next.toml notes
2023-02-16 17:50:42 +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
Harry Barber 9ecd7f0a30
Fix consistent service naming and add test coverage (#2349)
* Make service name casing consistent

* Add naming-obstacle-course-casing.smithy

* Add missing import

* Relax obstacle course even further

* Better TODO

* Add CHANGELOG.next.toml
2023-02-13 18:25:56 +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
ysaito1001 0a11d519c6
Add jitter to `LazyCredentialsCache` (#2335)
* Add jitter to `LazyCredentialsCache`

This commit adds jitter to `LazyCredentialsCache`. A jitter provides a
mechanism for randomizing the buffer time for credentials. This allows
credentials with the same expiry to expire at slightly different times,
thereby preventing thundering herds.

* Update CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-10 23:03:38 +00: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
Luca Palmieri 18bfa20712
Remove entries that have been released in 0.54.2. (#2323) 2023-02-07 15:25:37 +00: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
Nipunn Koorapati f8a799db2a
Fix handling of repeated headers in AWS request canonicalization (#2261) 2023-02-03 18:15:25 +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
ysaito1001 ac7fdf21c0
Fix broken doc link to `tokio_stream::Stream` (#2271)
* Fix broken doc link to `Stream`

This commit fixes broken doc link to `Stream` in codegen clients. That
target is `tokio_stream::Stream`, which in turn is a re-export of
`futures_core::Stream`. Since we do not have a good way to link to the
re-export, we remove a hyper link and just put `Stream`.

* Update CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-02 18:56:29 +00:00
ysaito1001 681d3b33af
Add static stability support to IMDS credentials provider (#2258)
* Add static stability support to ImdsCredentialsProvider

This commit adds static stability support to `ImdsCredentialsProvider`.
Static stability refers to continued availability of a service in the
face of impaired dependencies. In case IMDS is not available, we still
allow requests to be dispatched with expired credentials. This, in turn,
allows the target service to makes the ultimate decision as to whether
requests sent are valid or not instead of the client SDK determining
their validity.

The way it is implemented is `ImdsCredentialsProvider` now stores a last
retrieved credentials which will later be served when IMDS is unreachable.

* Add tests to IMDS credentials provider

This commit adds tests to IMDS credentials providers for static stability
support. These tests are prescribed in https://github.com/awslabs/smithy-rs/issues/2117.
From an IMDS credentials provider' perspective, however, some of the tests
are considered to fall under the same equivalence class with others.
Therefore, a single test can cover multiple test cases.

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

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

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-02-02 00:56:06 +00:00
david-perez 52cb0fc8e8
Add support for `@uniqueItems` (#2232)
This commit adds support for the `@uniqueItems` trait on `list` shapes
in server SDKs. Requests with duplicate values for `list` shapes
constrained with `@uniqueItems` will be rejected by servers.
2023-02-01 12:43:12 +00:00
ysaito1001 980b5c441c
Add fallback_on_interrupt to the ProvideCredentials trait (#2246)
* Implement RFC for providing fallback credentials

This commit implements the changes checklist in the RFC for providing
fallback credentials.

* Remove needless lifetime parameter

* Update CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-01-27 19:34:39 +00:00
AWS SDK Rust Bot 0965f12ff6 Update changelog 2023-01-25 15:31:25 +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
AWS SDK Rust Bot 701d294c6a Update changelog 2023-01-24 16:22:51 +00:00
Harry Barber 4257a188d0
Add changelog entry for "Remove old service builder machinery" (#2242) 2023-01-23 09:48:18 -06:00
Russell Cohen 5fa0f8b29e
Changelog fix (#2234)
* Fix changelog
* Add missing changelog entries
2023-01-19 20:13:34 +00:00
ysaito1001 10e915b6ac
Replace Arc with SharedCredentialsProvider in credentials_provider builder methods (#2227)
* Stop exposing `Arc` in `credentials_provider` builder methods

This commit rectifies the signature changes made to `credentials_provider`
builder methods in https://github.com/awslabs/smithy-rs/pull/2122.
The PR in question removed `SharedCredentialsProvider` and the builder
methods started taking `ProvideCredentials` in `Arc` instead. This causes
a problem for us to evolve the API in the future as the API forces the user
to be aware of the implementation detail that we use `Arc`.

* Update comments for `SharedCredentialsCache`

* Fix unresolved doc links to `ProvideCredentials`

This commit fixes unresolved doc links to `ProvideCredentials` in
`aws_credential_types::lazy_caching`.

* Update CHANGELOG.next.toml

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-01-19 16:48:55 +00:00
Luca Palmieri d9ea56d387
Remove old entries from CHANGELOG.next.toml (#2228)
* Remove old entries from CHANGELOG.next.toml

* Update CHANGELOG.next.toml
2023-01-19 15:14:48 +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
ysaito1001 d040f76fd1
Ensure SDK credential cache type safety (#2122)
* Add the `aws-credential-types` crate

This commit adds a new crate `aws-credential-types` to the `rust-runtime`
workspace. This lays the groundwork for being able to create a
`LazyCachingCredentialsProvider` outside the `aws-config` crate according
to the proposed solution in https://github.com/awslabs/smithy-rs/pull/2082.

We have moved the following into this new crate:
- Items in aws_types::credentials and and their dependencies
- Items in aws_config::meta::credentials and their dependencies

Finally, the crate comes with auxiliary files that are present in the
other crates in the `rust-runtime` workspace such as `external-types.toml`.

* Make `aws-types` depend on `aws-credential-types`

The credentials module has been moved from the `aws-types` crate to the
`aws-credential-types` crate. This leads to some of the items in the
`aws-types` crate adjusting their use statements to point to
`aws-credential-types`.

The `TimeSource` struct has also been moved to `aws-credential-types`
because it is used by `LazyCachingCredentialsProvider`. We have decided
to move it instead of duplicating it because `aws-config` was creating
a `TimeSource` from `aws-types` and then passing it to the builder for
`LazyCachingCredentialsProvider`. If we had duplicated the implementation
of `TimeSource` in `aws-credential-types`, two `TimeSource` implementations
would have been considered different types and the said use case in
`aws-config` would have been broken.

* Make `aws-config` depend on `aws-credential-types`

The `cache` module and modules in `meta::credentials` (except for `chain`)
have been moved to `aws-credential-types`. Again, the goal of restructuring
is to allow `LazyCachingCredentialsProvider` to be created outside the
`aws-config` crate. While doing so, we try not moving all the default
credential provider implementations.

* Make `aws-http` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `aws-inlineable` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `aws-sig-auth` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Emit `aws-credential-types` to the build directory

This commit adds `aws-credential-types` to AWS_SDK_RUNTIME so that
the build command `/gradlew :aws:sdk:assemble` can generate the crate
into sdk/build/aws-sdk.

* Make codegen aware of `aws-credential-types`

This commit allows the codegen to handle the `aws-credential-types` crate.
The items that have been moved from `aws-types` should now be prefixed with
`aws-credential-types` when generating fully qualified names.

* Make `dynamo-tests` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `s3-tests` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `s3control` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Update external-types.xml in rust-runtime crates

This commit fixes CI failures related to `cargo check-external-types`
in ec994be.

* Update the file permission on additional-ci

* Remove unused dependency from aws-credential-types

* Clean up features for aws-credential-types

This commit fixes a CI failure where the feature hardcoded-credentials
needed other features, aws-smithy-async/rt-tokio and tokio/rt, for the
test code to compile with --no-default-features.

* Update sdk-external-types.toml

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

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

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Update aws/rust-runtime/aws-credential-types/additional-ci

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

* Update aws/rust-runtime/aws-credential-types/src/lib.rs

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

* Reduce re-exports from `aws-credential-types`

This commit reduces the number of re-exports from `aws-credential-types`.
The rationale here is that if we add more items to this crate later on,
we may get some name collisions in root. Since this crate is not used by
our customers directly, it is acceptable for items to take a bit of typing
to get to.

* Fix broken intra doc link

This commit fixes a broken intra doc link that went unnoticed because the
offending link was behind the feature `hardcoded-credentials`.

* Introduce type and trait for credential caching

This commit introduces the following items in the `aws-credential-types`
crate:
* CredentialsCache
* ProvideCachedCredentials

`CredentialsCache` is a struct a user will be interacting with when creating
a credentials cache; the user no longer creates a concrete credentials cache
directly, and instead it is taken care of by `CredentialsCache` behind the
scene.
`ProvideCachedCredentials` is a trait that will be implemented by concrete
credentials caches.

Furthermore, this commit renames the following structs according to the RFC
https://github.com/awslabs/smithy-rs/pull/1842:
* SharedCredentialsProvider -> SharedCredentialsCache
* LazyCachingCredentialsProvider -> LazyCredentialsCache

* Add `credentials_cache` to `SdkConfig` and to builder

This commit adds a new field `credentials_cache` to `SdkConfig`. It also
adds a new method `credentials_cache` to `sdk_config::Builder`. They
will help a `CredentialsCache` be threaded through from `ConfigLoader`
to a service specific client's `config::Builder`, which will be
implemented in a subsequent commit.

* Put `SharedCredentialsCache` into the property bag

This commit updates what goes into the property bag. Now that
`SharedCredentialsProvider` has been renamed to `SharedCredentialsCache`,
that's what goes into the property bag. Once a `SharedCredentialsCache`
is retrieved from the bag, credentials can be obtained by calling
`provide_cached_credentials`.

* Thread through `credentials_cache` to service client

This commit threads through `credentials_cache` to service client's
`Config` and its builder. The builder will be the single-sourced place
for creating a credentials cache.

* Update `aws-config` to use `CredentialsCache`

This commit updates `aws-config` to use `CredentialsCache`. Specifically,
* `ConfigLoader` now has `credentials_cache` to take `CredentialsCache`
* No more `LazyCachingCredentialsProvider` in `DefaultCredentialsChain`
* No more `LazyCachingCredentialsProvider` in `AssumeRoleProvider`

The second and third bullet points are a result of a credentials cache
being composed in a service client's `config::Builder` rather than
`DefaultCredentialsChain` or `AssumeRoleProvider` holding it as its field.

* Update sdk integration tests

This commit bulk updates the integration tests for SDK. Most updates
replace the previous `SharedCredentialsProvider::new` with `Arc::new`.

A more subtle but important change is to respect the `sleep_impl` field
within the build method of a Config builder, making sure to thread it
a default `LazyCredentialsCache` created within the build method. If we
missed this step, the default constructed `LazyCredentialsCache` would
later use the default Tokio sleep impl even during tests that exercise
different async runtime, causing them to fail.

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Rename variants of `aws_credential_types::time_source::Inner`

This commit addresses https://github.com/awslabs/smithy-rs/pull/2108#discussion_r1053637722

* Split the unit test for `time_source` into two

This commit addresses https://github.com/awslabs/smithy-rs/pull/2108#discussion_r1053638381

* Update CHANGELOG.next.toml

* Fix test failures in CI coming from `aws-inlineable`

This commit fixes test failures in CI coming from the integration test in
the `aws-inlineable` crate. Commit ea47572 should have included this
change.

* Update external-types TOML files

* Clean up offending use statements left after merging main

* Remove moved module wrongly brought in after merging main

* Remove `credentials_cache` from `Builder` for `DefaultCredentialsChain`

This commit removes a field `credentials_cache` from the `Builder` for
`DefaultCredentialsChain` as it no longer stores `LazyCredentialsCache`.
Furthermore, we have also removed methods on the builder that referred
to the field `credentials_cache`.

After this commit, certain use cases will be broken, i.e. when a user
sets timeout for loading credentials via `load_timeout` on the builder,
the configured timeout will be dropped on the floor because it will not
be threaded through the field `credentials_cache`. We will later provide
instructions for how to update those use cases with our new set of APIs.

* Remove `configure` from `LazyCredentialsCache` builder

This commit removes the `configure` method from the builder for
`LazyCredentialsCache`. We tried our best to keep it when we had moved
the builder from `aws-config` but had to modify the method signature to
destructure `ProviderCondig` to obtain the two fields out of it
(`ProviderConfig` lives in `aws-config` so cannot be passed to the builder
for `LazyCredentialsCache` which lives in `aws-credential-types`).

Given `configure` is technically meant for credentials providers, which
`LazyCredentialsCache` is not anymore, we might as well remove it and
accomplish the same effect by having customers use both `time_source` and
`set_sleep` on the builder instead.

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

* Use unwrap_or_else to simplify two assignments

This commit addresses https://github.com/awslabs/smithy-rs/pull/2122#discussion_r1056497419

* Add doc link to `CredentialsCache` to builder method

This commit addresses https://github.com/awslabs/smithy-rs/pull/2122#discussion_r1056500448.
In addition, it moves rustdoc for `LazyCredentialsCache` to `LazyBuilder`
as `LazyCredentialsCache` has been made `pub(crate)` from `pub` and
`LazyBuilder` is now a `pub` item instead.

* Make `CredentialsCache` configurable in `AssumeRoleProviderBuilder`

This commit addresses https://github.com/awslabs/smithy-rs/pull/2122#discussion_r1066400431.
It allows users to pass their `CredentialsCache` to the builder just as
they do in `SdkConfig`.

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/2122#discussion_r1066400431.

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-01-17 17:18:18 +00:00
david-perez 9f905179cd
Support `@sparse` constrained map shapes and list shapes (#2213)
Turns out we've never supported them, neither directly constrained nor
with constrained members, because of a lack of tests. Yet another data
point to prioritize working on code-generating `constraints.smithy` (see
https://github.com/awslabs/smithy-rs/issues/2101).

The implementation is simple: we just need to call the symbol provider
on the member symbols instead of on the target symbols so we get
`Option<T>` list members / map values if applicable, and handle the
wrapper when converting between unconstrained and constrained types with
help from `match` and `Option<T>::map`.
2023-01-17 14:58:42 +00:00
AWS SDK Rust Bot f5c56b66e9 Update changelog 2023-01-12 14:29:49 +00: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
AWS SDK Rust Bot bcea15ad4a Update changelog 2023-01-11 15:22:58 +00:00
82marbag 81f435bee2
Update changelog with request ID (#2193)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-01-10 17:06:11 +00:00
Russell Cohen aaac83f972
Enable FIPS and dual-stack from SDK config (#2168)
* Enable FIPS and dual-stack from SDK config

* Update changelog

* Appease clippy

* refactor to use docs_for macro
2023-01-06 22:17:53 +00:00
Russell Cohen 4768926b06
Remove webpki feature dependency (#2170) 2023-01-05 11:42:33 +00:00
Russell Cohen 4750723284
Create `StandardProperty` in aws-config (#2162)
* Create standard_property and refactor retry_config to use standard_property

* Add docs

* backout changes to dualstack

* cleanup more dualstack stuff

* remove extra code

* more dual stack detritus

* Fix clippy

* Update changelog
2023-01-04 21:10:02 +00:00
Russell Cohen 5392a66808
Fix bug where string builtIns were not supported (#2150) 2023-01-04 18:01:37 +00:00
Russell Cohen 88afcf8c68
Refactor configuration loading to parse profile files only once (#2152)
* Draft PR to only parse configuration once

* Update docs & and add test

* Fix bug where cache was being cleared by mistake

* Add additional docs

* Apply suggestions from code review

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

* Apply suggestions from code review

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

* fix name of field

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-01-03 14:37:33 -05:00
82marbag 51915bed5f
Update CHANGELOG (#2136)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-12-23 14:35:18 +00:00
ysaito1001 bb5bbeb5cf
Move types for AWS SDK credentials to a separate crate (#2108)
* Add the `aws-credential-types` crate

This commit adds a new crate `aws-credential-types` to the `rust-runtime`
workspace. This lays the groundwork for being able to create a
`LazyCachingCredentialsProvider` outside the `aws-config` crate according
to the proposed solution in https://github.com/awslabs/smithy-rs/pull/2082.

We have moved the following into this new crate:
- Items in aws_types::credentials and and their dependencies
- Items in aws_config::meta::credentials and their dependencies

Finally, the crate comes with auxiliary files that are present in the
other crates in the `rust-runtime` workspace such as `external-types.toml`.

* Make `aws-types` depend on `aws-credential-types`

The credentials module has been moved from the `aws-types` crate to the
`aws-credential-types` crate. This leads to some of the items in the
`aws-types` crate adjusting their use statements to point to
`aws-credential-types`.

The `TimeSource` struct has also been moved to `aws-credential-types`
because it is used by `LazyCachingCredentialsProvider`. We have decided
to move it instead of duplicating it because `aws-config` was creating
a `TimeSource` from `aws-types` and then passing it to the builder for
`LazyCachingCredentialsProvider`. If we had duplicated the implementation
of `TimeSource` in `aws-credential-types`, two `TimeSource` implementations
would have been considered different types and the said use case in
`aws-config` would have been broken.

* Make `aws-config` depend on `aws-credential-types`

The `cache` module and modules in `meta::credentials` (except for `chain`)
have been moved to `aws-credential-types`. Again, the goal of restructuring
is to allow `LazyCachingCredentialsProvider` to be created outside the
`aws-config` crate. While doing so, we try not moving all the default
credential provider implementations.

* Make `aws-http` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `aws-inlineable` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `aws-sig-auth` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Emit `aws-credential-types` to the build directory

This commit adds `aws-credential-types` to AWS_SDK_RUNTIME so that
the build command `/gradlew :aws:sdk:assemble` can generate the crate
into sdk/build/aws-sdk.

* Make codegen aware of `aws-credential-types`

This commit allows the codegen to handle the `aws-credential-types` crate.
The items that have been moved from `aws-types` should now be prefixed with
`aws-credential-types` when generating fully qualified names.

* Make `dynamo-tests` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `s3-tests` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Make `s3control` depend on `aws-credential-types`

This commit adjusts the use statements for the items that have been moved
from the `aws-types` crate to the `aws-credential-types` crate.

* Update external-types.xml in rust-runtime crates

This commit fixes CI failures related to `cargo check-external-types`
in ec994be.

* Update the file permission on additional-ci

* Remove unused dependency from aws-credential-types

* Clean up features for aws-credential-types

This commit fixes a CI failure where the feature hardcoded-credentials
needed other features, aws-smithy-async/rt-tokio and tokio/rt, for the
test code to compile with --no-default-features.

* Update sdk-external-types.toml

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

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

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Update aws/rust-runtime/aws-credential-types/additional-ci

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

* Update aws/rust-runtime/aws-credential-types/src/lib.rs

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

* Reduce re-exports from `aws-credential-types`

This commit reduces the number of re-exports from `aws-credential-types`.
The rationale here is that if we add more items to this crate later on,
we may get some name collisions in root. Since this crate is not used by
our customers directly, it is acceptable for items to take a bit of typing
to get to.

* Fix broken intra doc link

This commit fixes a broken intra doc link that went unnoticed because the
offending link was behind the feature `hardcoded-credentials`.

* Update aws/rust-runtime/aws-credential-types/README.md

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

* Rename variants of `aws_credential_types::time_source::Inner`

This commit addresses https://github.com/awslabs/smithy-rs/pull/2108#discussion_r1053637722

* Split the unit test for `time_source` into two

This commit addresses https://github.com/awslabs/smithy-rs/pull/2108#discussion_r1053638381

* Update CHANGELOG.next.toml

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-12-21 19:12:53 +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
david-perez 0dd6c82ec4
Fix `@length`-constrained collection shapes whose members are not constrained (#2103)
* Fix `@length`-constrained collection shapes whose members are not constrained

The generated code these should have emitted was fixed in #2085 (it's
bug number 2), but code generation is still crashing because the call to
calculate the inner constraint violation symbol is performed _before_
checking that the collection's member can reach a constrained shape.

The test that #2085 added in `constraints.smithy`:

```smithy
@length(max: 69)
list LengthList {
    member: ConB
}
```

was not exercising what it should have, since `ConB`, is its name hints
at, is a constrained structure shape.

* Add changelog entry

Co-authored-by: Julian Antonielli <julianantonielli@gmail.com>
2022-12-15 15:10:32 +00: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
AWS SDK Rust Bot b2b8e7e424 Update changelog 2022-12-12 15:37:03 +00:00
Luca Palmieri c29e3ad709
Prepare 0.52.0 release of smithy-rs (#2084)
* Prepare 0.52.0 release of smithy-rs

* Add PR number
2022-12-09 12:27:15 +00:00
John DiSanti d5bcd4f3c7
Improve credentials tracing (#2062)
* Add `info` event for credentials cache miss
* Remove duplicate credential provider spans
* Touch up some credentials events/spans
2022-12-08 00:22:15 +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
ysaito1001 577c90b7a7
Render a Union member of type Unit to an enum variant without inner data (#1989)
* Avoid explicitly emitting Unit type within Union

This commit addresses #1546. Previously, the Unit type in a Union was
rendered as an enum variant whose inner data was crate::model::Unit.
The way such a variant appears in Rust code feels a bit odd as it
usually does not carry inner data for `()`. We now render a Union
member of type Unit to an enum variant without inner data.

* Address test failures washed out in CI

This commit updates places that need to be aware of the Unit type attached
to a Union member. Those places will render the Union member in a way that
the generated Rust code does not include inner data of type Unit. It should
help pass `codegen-client-test:test` and `codegen-server-test:test`.

Further refactoring is required because each place we updated performs an
explicit if-else check for special casing, which we should avoid.

* Update codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/UnionGeneratorTest.kt

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

* Remove commented-out code

* Add a helper for comparing against ShapeId for Unit

This commit adds a helper for checking whether MemberShape targets the
ShapeId of the Unit type. The benefit of the helper is that each call
site does not have to construct a ShapeId for the Unit type every time
comparison is made.

* Move Unit type bifurcation logic to jsonObjectWriter

This commit moves the if-else expression hard-coded in the StructureShape
matching case within RustWriter.serializeMemberValue to jsonObjectWriter.
The previous approach of inlining the if-else expression out of
jsonObjectWriter to the StructureShape case and tailoring it to the call
site violated the DRY principle.

* Make QuerySerializerGenerator in sync with the change

This commit brings the Unit type related change we've made so far to
QuerySerializerGenerator. All tests in CI passed even without this
commit, but noticing how similar QuerySerializerGenerator is to
JsonSerializerGenerator, we should make the former in sync with the
latter.

* Update CHANGELOG.next.toml

* Refactor ofTypeUnit -> isTargetUnit

This commit addresses https://github.com/awslabs/smithy-rs/pull/1989#discussion_r1035372417.
The extension should be renamed to isTargetUnit and moved to Smithy.kt.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt

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

* Simplify if-else in jsonObjectWriter

This commit addresses https://github.com/awslabs/smithy-rs/pull/1989#discussion_r1037651893

* Avoid the union member's reference name being empty

This commit addresses https://github.com/awslabs/smithy-rs/pull/1989#discussion_r1037654601
Even if member's reference name "inner" is present, it will not be an
issue when the member is the Unit type where the reference name "inner"
cannot be extracted. The reason is jsonObjectWriter won't render the
serialization function if the member is the Unit type.

That said, the same change in QuerySerializerGenerator may not be the
case so we'll run the tests in CI and see what breaks.

* Ensure Union with Unit target can be serialized

This commit updates serialization of a Union with a Unit target in
different types of serializers. We first updated protocol tests by
adding a new field of type Unit and some of them failed as expected.
We worked our way back from those failed tests and fixed the said
implementation for serialization accordingly.

* Ensure Union with Unit target can be parsed

This commit handles deserialization of a Union with a Unit target in
XmlBindingTraitParserGenerator. Prior to the commit, we already handled
the said deserialization correctly in JsonParserGenerator but missed it
in XmlBindingTraitParserGenerator. We added a new field of type Unit to
a Union in parser protocols tests, ran them, and worked our way back from
the failed tests.

* Ensure match arm for Unit works in custom Debug impl

This commit handles a use case that came up as a result of combining two
updates, implementing a custom Debug impl for a Union and avoid rendering
the Unit type in a Union. In the custom Debug impl, we now make sure that
if the target is of type Unit, we render the corresponding match arm
without the inner data. We add a new unit test in UnionGeneratorTest.

* Fix unused variables warnings in CI

This commit adds the #[allow(unused_variables)] annotation to a block of code
generated for a member being the Unit type. The annotation is put before we
call the handleOptional function so that it covers the whole block that the
function generates.

* Fix E0658 on unused_variables

This commit fixes an error where attributes on expressions are experimental.
It does so by rearranging code in a way that achieves the same effect but
without #[allow(unused_variables)] on an expression.

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-12-07 21:23:21 +00:00
John DiSanti 31f1d35b62
Establish default max idle connections on default connectors (#2064) 2022-12-07 20:00:36 +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
John DiSanti 18fc6923c5
Remove client body callbacks (#2065) 2022-12-06 20:18:48 +00:00
ysaito1001 5487e364be
Respect the sensitive trait on container shapes (#1983)
* Make enum forward-compatible

This commit implements the suggested approach described in
https://github.com/awslabs/smithy-rs/issues/627#issuecomment-995923092

The idea is that once the user writes a match expression against an enum
and assumes that an execution path comes to a particular match arm, we
should guarantee that when the user upgrades a version of SDK, the
execution path should come to the same match arm as before.

* Add unit test to ensure enums are forward-compatible

The test first mimics the user's interaction with the enum generated from
a model where the user writes a match expression on the enum, wishing to
hit the match arm corresponding to Variant3, which is not yet supported
by the model. The test then simulates a scenario where the user now has
access to the updated enum generated from the next version of the model
that does support Variant3.
The user's code should compile in both of the use cases.

* Generate rustdoc for enum's forward-compatibility

This commits generates rustdoc explaining to the users how they might
write a match expression against a generated enum so their code is
forward-compatible. While it is explained in
https://github.com/awslabs/smithy-rs/issues/627#issuecomment-995923092,
it can be helpful if the users can read it in rustdoc right below where
the enum's definition is shown.

* Make snippet in rustdoc text

This commit updates a rustdoc code snippet generated for an enum from
`rust,no_run` to `text`. We observed that the snippet fails to compile
in CI because the name of the enum was not fully qualified; code in
rustdoc is treated in a similar way that code in integration tests is
treated as being outside of a crate, but not part of the crate, which
means the name of the crate needs to be spelled out for a `use` statement
if we want to import the enum to the code in rustdoc. However, the name
of the crate is usually one-off, generated on the fly for testing, making
it not obvious to hard-code it or obtain it programmatically from within
Kotlin code.

* Suppress missing doc lint for UnknownVariantValue

This commit marks UnknownVariantValue as `#[allow(missing_docs)]` because
failing to do so will cause tests in CI to fail.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

Co-authored-by: Russell Cohen <rcoh@amazon.com>

* Generate UnknownVariantValue via forInlineFun

This commit attempts to create UnknownVariantValue using
RuntimeType.forInlineFun. Prior to this commit, it was generated per enum
but that caused multiple definitions of UnknownVariantValue in a single
file as there can be multiple enums in the file.
By using RuntimeType.forInlineFun, we can generate a single UnknownVariantValue
per module and the enums within the module can refer to the same instance.

This commit, however, fails to pass the unit tests in EnumGeneratorTest.
The issue seems to be that a RustWriter used in the tests does not end up
calling the finalize method, failing to render inline functions.

* Replace "target == CodegenTarget.CLIENT" with a helper

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1014390811
but uses an existing helper CodegenTarget.renderUnknownVariant.

* Update EnumGeneratorTests to use TestWorkspace

This commit addresses failures for unit tests in EnumGeneratorTests.
Now that we use RuntimeType.forInlineFcn in EnumGenerator, we need
to ensure that the inline functions should be rendered to a Rust
source file during testing. RustWriter, used in EnumGeneratorTests
prior to this commit, was not capable of doing so. We thus update
EnumGeneratorTests to use TestWorkspace by which we ensure that the
inline functions are rendered during testing.

* Make sure to use the passed-in variable for shapeId

This commit fixes a copy-and-paste error introduced in 712c983. The
function should use the passed-in variable rather than the hard-coded
literal "test#SomeEnum".

* Address https://github.com/awslabs/smithy-rs/pull/1945\#discussion_r1014389852

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1017235315

* Avoid potential name collisions by UnknownVariantValue

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1017237745.
It changes the module in which the `UnknownVariantValue` is rendered.
Before the commit, it was emitted to the `model` module but that might cause
name collisions in the future when a Smithy model has a shape named
`UnknownVariantValue`. After this commit, we render it to the `types` module.

* Move re-exports from lib.rs to types.rs

This commit moves re-export statements in client crates from `lib.rs` to
`types.rs`. The motivation is that now that we render the struct
`UnknownVariantValue` in a separate file for the `types` module, we can
no longer have a `pub mod types {...}` block in `lib.rs` as it cannot
coexist with `pub mod types;`.

* Add docs on UnknownVariantValue

This commit adds public docs on `UnknownVariantValue`. Since it is
rendered in `types.rs`, the users may not find the `Unknown` variant
of an enum in the same file and may wonder what this struct is for when
seeing it in isolation.

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1020414459

* Update the module documentation for types

This commit updates rustdoc for the types module to reflect that fact
that the module now contains not only re-exports but also an auxiliary
struct `UnknownVariantValue`.

* Add extensions to run code block depending on the target

This commit introduces extensions on CodegenTarget that execute the block
of code depending on the target is for client or for server. These
extensions are intended to replace if-else expressions throughout the
codebase explicitly checking whether the target is for client or for server.
We do not update such if-else expressions all at once in this commit.
Rather, we are planning to make incremental changes to update them
opportunistically.

* Respect the sensitive trait on enums

This commit fixes #1745. It allows enums to respect the sensitive trait.
When annotated as such, an enum will not display its data and instead
will show the redacted text upon debug print.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

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

* Move extensions into CodegenTarget as methods

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1021952411.
By moving extensions into the CodegenTarget enum, no separate import is
required to use them.

* Update codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGeneratorTest.kt

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

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

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

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

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

* Update CHANGELOG.next.toml

* Configure the (in|ex)clusion of the Debug trait for containers per members' sensitive trait (#2029)

* Removes Debug for shape with sensitive trait

This commit centralizes a place where the codegen excludes the Debug
trait if a shape has the sensitive trait. Previously the exclusion was
handled locally in each shape, e.g. StructureGenerator and EnumGenerator.
However, that approach may overlook a certain shape we also need to treat
as such. We now handle the exclusion of the Debug trait in one place,
BaseSymbolMetadataProvider.

* Stop excluding the Debug trait locally

This commit updates EnumGenerator and StructureGenerator based on the
change made to BaseSymbolMetadataProvider in the previous commit.
Now that the exclusion of the Debug trait was centralized, those
classes in question no longer need to do so individually.

* Implement a custom Debug trait in BuilderGenerator

This commit implements a custom Debug trait in BuilderGenerator now that
the derived Debug trait is excluded from BaseSymbolMetadataProvider for
the structure container. The implementation of the custom Debug trait
pretty much follows that of StructureGenerator.

* Implement a custom Debug trait in UnionGenerator

This commit implements a custom Debug trait in BuilderGenerator now that
the derived Debug trait is excluded from BaseSymbolMetadataProvider for
the union container. The implementation of the custom Debug trait pretty
much follows that of EnumGenerator.

* Implement a custom Debug trait in ServerBuilderGenerator

This commit implements a custom Debug trait in ServerBuilderGenerator now
that the derived Debug trait is excluded from BaseSymbolMetadataProvider
for the structure container. The implementation of the custom Debug trait
pretty much follows that of StructureGenerator.

* Add the Copyright header

* Update CHANGELOG.next.toml

* Update Debug impl for UnionGenerator

This commit updates the implementation of a custom Debug trait impl for
UnionGenerator. Turns out that in a Union, a member target can be marked
as sensitive separately outside the Union. Therefore, the implementation
of a custom Debug trait has two cases depending on where the sensitive
trait appears, either it is applied to the whole Union or to a member
target.

* Peek at member sensitivity for Debug trait (in|ex)clusion

This commit addresses https://github.com/awslabs/smithy-rs/pull/2029#discussion_r1034205685.
With this change, structure shapes no longer need to exclude the Debug
trait unconditionally. The upshot is that we may be able to avoid a
custom Debug impl for a structure where the derived Debug will do, i.e.
when there is no sensitive trait either at a container level or at a
member level.

* Remove statement that does not seem to take effect

This commit addresses https://github.com/awslabs/smithy-rs/pull/2029#discussion_r1036288146

* Rename renderDebugImplForUnion -> renderFullyRedactedDebugImpl

This commit addresses https://github.com/awslabs/smithy-rs/pull/2029#discussion_r1036290722

* Rename renderDebugImplForUnionMemberWise -> renderDebugImpl

This commit addresses https://github.com/awslabs/smithy-rs/pull/2029#discussion_r1036291209

Co-authored-by: Yuki Saito <awsaito@amazon.com>

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: david-perez <d@vidp.dev>
2022-12-05 19:44:25 +00:00
ysaito1001 5dd5f3f80f
Normalize URI paths during signing (except for S3) (#2018)
* De-dupe multiple leading forward slashes in request

This commit fixes a bug reported in
https://github.com/awslabs/aws-sdk-rust/issues/661.
Note that this de-duping is not part of URI path normalization because it
must happen to a request for any service, including S3.

* Normalize URI paths for canonical requests

This commit enables URI path normalization in aws-sigv4. It follows
https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
to create the canonical URI that is part of the canonical request.

* Avoid using OS specific path separator

This commit updates the implementation of normalize_path_segment so that it
does not use an OS specific path separator, specifically "\\" on Windows and
always uses a forward slash "/". It addresses a test failure on Windows:
https://github.com/awslabs/smithy-rs/actions/runs/3518627877/jobs/5897764889.

* Fix the rustdoc::bare_urls warning from cargo doc

* Fix a typo Normalzie -> Normalize

* Limit de-duping multiple leading forward slashes to S3

This commit addresses https://github.com/awslabs/smithy-rs/pull/2018#issuecomment-1325283254.
There is a case  where an empty string between leading double forward
slashes is meaningful so blindly de-duping them breaks the use case.
Therefore, handling multiple leading forward slashes in this manner
should be applied only to S3.

* Add an integration test per https://github.com/awslabs/aws-sdk-rust/issues/661

This commit adds an integration test verifying the special rule for URI
path normalization applies to S3. That is, leading forward slashes should
be de-deduped and normalizing URI paths as prescribed in RFC 3986 should
be ignored.

* Update CHANGELOG.next.toml

* Revert 87b749c

This commit reverts 87b749c, the reason being that we need to better
understand the requirement for de-duplicating leading forward slashes
in requests, i.e. do we even need to do it or if so where should we
perform the de-dupe operation?

* Revert naming of UriPathNormalizationMode variants

This commit reverts the naming of variants in UriPathNormalizationMode.
They were PerRfc3986 and ForS3, but they should be more generic like
Enabled and Disabled as we had before.

* Update CHANGELOG.next.toml

* Simplify integration test using capture_request

This commit simplifies the integration test normalize-uri-path for s3.
Previously, the test used ReplayingConnection but it was an overkill
to test something as simple as whether the generated request contained
the expected URI and signature.

* Update aws/rust-runtime/aws-sigv4/src/http_request/settings.rs

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

* Update aws/rust-runtime/aws-sigv4/src/http_request/settings.rs

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

* Update aws/rust-runtime/aws-sigv4/src/http_request/uri_path_normalization.rs

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

* Address review feedback on normalize_path_segment

This commit addresses the following code review feedback:
https://github.com/awslabs/smithy-rs/pull/2018#discussion_r1034192229
https://github.com/awslabs/smithy-rs/pull/2018#discussion_r1034194621
https://github.com/awslabs/smithy-rs/pull/2018#discussion_r1034195625

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/2018#discussion_r1034198861

* Preallocate the Vec capacity for normalize_path_segment

This commit addresses https://github.com/awslabs/smithy-rs/pull/2018#discussion_r1034195625.
It counts the number of slashes to preallocate the capacity of a Vec used
in normalize_path_segment.

* Address https://github.com/awslabs/smithy-rs/pull/2018\#discussion_r1034188849

* Update aws/rust-runtime/aws-sigv4/src/http_request/settings.rs

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

* Update aws/rust-runtime/aws-sigv4/src/http_request/settings.rs

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

* Update aws/rust-runtime/aws-sigv4/src/http_request/settings.rs

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

Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-12-02 19:58:18 +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
Julian Antonielli 6ca5ed2197
Implement `@length` on collections (#2028)
* Refactor `ConstrainedMapGenerator` slightly

* Add `@length` list operation in `constraints.smithy`

* Add more setup required for rendering constraint `list`s

* Add initial draft of `ConstrainedCollectionGenerator`

* Add license header to `LengthTraitCommon`

* Add draft of collection constraint violation generation

Copy `MapCostraintViolationGenerator` into
`CollectionConstraintViolationGenerator` for now.

* Add `Visibility.toRustQualifier`

* Implement `CollectionConstraintViolationGenerator`

* Use `TraitInfo` on `CollectionConstraintViolationGenerator`

* Update docs on `ConstrainedCollectionGenerator`

* Improve formatting on rust code

* Don't generate `ConstraintViolation` enum twice

* Make symbol provider work with constrained lists

* Fix call to `ConstraintViolation::Member`

* Render constraint validation functions for lists

* Fix call to `usize::to_string`

* Use map json customisation for collections as well

* Update to use overhauled module system

* Add constraint traits check for collection shapes

* Remove test checking that `@length` is not used in `list`s

* Refactor use of `shape.isDirectlyConstrained`

* Fix failing `UnconstrainedCollectionGeneratorTest` test

* Fix test

* Actually fix the test

* Update changelog

* Fix `constrainedCollectionCheck`

* Add tests for `ConstrainedCollectionGenerator`

* Make tests work for when sets are implemented

* Remove mention of `set` in changelog

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

* Fix styling in `constraints.smithy`

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

* Use `check` instead of `assert`

* Grammar fix in comment about `Option<Box<_>>`

* Rename unsupported length data class for blobs

- `UnsupportedLengthTraitOnCollectionOrOnBlobShape` -> `UnsupportedLengthTraitOnBlobShape`

* Add TODO about `uniqueItems` not being implemented yet

* Change error message: `unconstrained` -> `not constrained`

* Add imports to fix docs

* Remove unused `modelsModuleWriter` parameter

* Use `filterIsInstance` and coalesce `filter + map`

* Add `check` in json customization

* Use `Set` instead of `List` for supported contraints

* Use `toMutableList` to avoid creating an extra list

* Add `@length` list to `ConA`

* Add `@httpQuery`-bound `@length` list example

* Add `@httpHeader`-bound `@length` list

* Fix `UnconstrainedCollectionGeneratorTest` test

* Fix rendering of constrained lists as header values

* Split very long line

* Add docs for `ConstraintViolation::Member` for lists

* Pass `length` variable name to `LengthTrait.rustCondition`

* Refactor long conditional

* Homogenise conditional

Co-authored-by: david-perez <d@vidp.dev>
2022-11-30 16:39:10 +00:00
Luca Palmieri 4c77965126
Implement @range on long and byte shapes (#2036)
* Group all override-related test cases together.

* Add @range examples for both byte and long in constraints.smithy.

* Implement @range for long and byte shapes.

* Update CHANGELOG

* Fix unit tests.

* Address comments

* Dry up further.
2022-11-29 17:04:54 +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
Luca Palmieri 0adad6a72d
Implement @range on short (#2034)
* Extract a ConstrainedNumberGenerator from ConstrainedIntegerGenerator

* Update tests' expectations to assume that we support @range for short

* Add ShortShape to all the key places to get @range support

* Generalize generator tests.

* Add tests for the @range trait on short to our constraints.smithy model.

* Update changelog

* Fix type in constraints.smithy
2022-11-29 14:07:24 +00:00
Luca Palmieri ec9588b151
@range implementation for integer shapes (#2005)
* Draft of @range implementation for integer shapes

* Green tests.

* Fix serialization of constrained integers.

* Fix tagger to include Integer simple shapes.
Fix de/serialization codegen.

* Add range trait to the entry about constraint traits in our changelog.

* Bind a range-constrained integer to various HTTP parts to test our implementation.

* Rename ConstrainedIntGeneratorTest to ConstrainedIntegerGeneratorTest for consistency.

* Remove AsRef implementation.

* Fix constraints models.

* Fix conversion.

* Use ReturnSymbolToParse to dry up.

* Fix builder when constrained types should not be exposed.

* Add customisation to unwrap constrained integers.

* Getting closer - collections need to be handled differently to make everything fall into place.

* Refactor `renderHeaders`

* Fix constraints test.

* Fix ebs.

* Rename for clarity.

* Remove unnecessary From implementation.

* Rename `Size` variant to `Range`.

* Remove stray comments.

* Rename for clarity

* Rename for consistency

* Add test to guard against types for which we do not support range yet

* DRY up branches and the relevant tests.

* Fix header name.

* Fix serialization bug for default values in headers.

* Fix serialization issue for primitive headers.

* Remove SetOfRangeInteger

* Fix pubcrateconstrained unit test.

* Remove duplication

* Revert "Remove SetOfRangeInteger"

This reverts commit f37a560bd0.

* Reintroduce `SetOfRangeInteger`, but keep them commented out.

* Ignore leading whitespace.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt

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

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt

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

* Update codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt

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

* Update codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ConstrainedIntegerGeneratorTest.kt

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

* Unify with a single rustTemplate invocation.

* Rename `Type` to `NumberType`

* Update codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstrainedShapeSymbolProviderTest.kt

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

* Formatting issue.

* Move and rename test helper.

* Dry up the logic for default serialization.

* Ooops, I swapped the two branches.

* Add a wrapper block

* Fix support detection.

* Fix CHANGELOG.

* Add (failing) protocol tests for @range on byte/integer/long.

* Fix validation message.
Fix test definitions.

* Mark some tests as expected to fail.
Rename service.

* Use ValueExpression everywhere for more granular control of the ownership component.

* Use the new enhanced module facilities

* Fixes.

* Fix formatting

* Remove unnecessary when.

* Update codegen-core/common-test-models/constraints.smithy

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

* Remove unused shapes.

* Avoid mixing concerns in our test shapes for integer constraints.

* Reuse the trait info machinery

* Update stale comment

* Fix unused attribute.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt

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

* Avoid unnecessary bindings by manipulating the serialization context directly in the customisations.

* Avoid unnecessary bindings in header serialization by introducing and manipulating the header value serialization context directly in the customisations.

* Add code examples.

* Move `safeName` call into the if branch.

Co-authored-by: david-perez <d@vidp.dev>
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-11-28 15:47:33 +00:00
Julian Antonielli eafbe8087d
Implement `@pattern` on `string` shapes (#1998)
* Refactor `ConstrainedStringGenerator` to extract length checking

* Extract `TryFrom` rendering into its own function

* Extract `ConstraintViolation` definition to separate function

* Add pattern check mock for `@pattern` trait

* Add `regex` to list of server dependencies

* Use real regex check in `check_pattern`

* Add `@pattern` to traits that make `string` shapes directly constrained

* Remove unsupported validation for `@pattern` on strings

* Fix test cases in `ConstraintsTest`

* Remove test disallowing `@pattern` on strings

* Add first test case for `@pattern` on strings

* Fix codegen in `ConstraintViolation::as_validation_exception_field`

* Use `OnceCell` to store `@pattern`'s regex

* Tidy up `ConstrainedStringGenerator` to work with many constraints

* Rename `handleTrait` -> `fromTrait` and make it a static method

* Add docs for `ConstraintViolation` variants

* Fix unescaped slashes in regexes

* Quick hack to get tests compiling

* Fix `sensitive_string_display_implementation` test

* Use new fn name: `asType` -> `toType`

* Refactor `ConstrainedStringGenerator` to not pass in `constraints`

* Add `@pattern` test

* Use `Lazy` instead of `OnceCell`

* Store `&'static str` in `Pattern` error instead of `String`

* Move `TraitInfo` to the bottom

* Extract branches in `TraitInfo.fromTrait` into separate functions

* Add `PatternTrait.validationErrorMessage`

* Add more tests for `@pattern`

* Add entry to `CHANGELOG.next.toml`

* Fix a `@length` + `@pattern` test case

* Remove unused binding in `ConstrainedStringGeneratorTest`

* Remove calls to `trimIndent`

* Use raw Rust strings instead of `escapedPattern`

* Require `regex 1.5.5` instead of `1.7.0`

* Use `Writable`s in `TraitInfo`

* Use single `rust` call for `impl $name` block

* Move `supportedStringConstraintTraits` to `Constraints.kt`

* Fix error message mentioning wrong `ignoreUnsupportedConstraintTraits` key

* Fix usage of `:W` in `rustTemplate` and raw Rust strings

* Use shorthand form for `PatternTrait.validationErrorMessage`

* Fix protocol tests by adjusting the validation message

* Add uses of `@pattern` in `constraints.smithy` model

* Fix broken `RestJsonMalformedPatternReDOSString` test

* Move `TraitInfo` to its own module and separate string-specific details

* Update codegen-core/common-test-models/constraints.smithy

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

* Fix nits in `constraints.smithy`

* Add license to `TraitInfo.kt`

* Make `StringTraitInfo.fromTrait` not return a nullable

* Remove overzealous formatting

* Add some padding to json in `fixRestJsonMalformedPatternReDOSString`

* Add `compile_regex` function for `@pattern` strings

* Add helpful error message when regexes fail to compile

* Add missing coverage in `constraints.smithy`

* Fix examples in `constraints.smithy`

* Fix failing test

* Combine writables in `ConstrainedStringGenerator`

* Fix uses of `Writable.join`

* Use `expect` over `unwrap_or_else`

* Use `once_cell::sync::Lazy` over `once_cell::sync::OnceCell`

Co-authored-by: david-perez <d@vidp.dev>
2022-11-23 15:02:55 +00:00
Lindsay Roberts 0f26eade60
Add const to generated enum values() (#2011)
* Add const to generated enum values()

Enum values() functions return static arrays of static strings and could
be of compile time use. Make callable in const contexts.

* Add reference to PR in changelog next for const enum values()

* Correct changelog next target to all for const enum values()

Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
2022-11-22 13:25:10 +00:00
Zelda Hessler 0a610ec4a6
Always write required query param keys, even if value is unset or empty (#1973)
* fix: issues when sending multipart-upload-related operations with no upload ID by making upload ID required
add: Mandatory trait
add: S3 customization to make Upload Ids mandatory

* add: CHANGELOG.next.toml entry

* update: strategy for tagging shapes as mandatory

* remove: Mandatory trait
undo: S3Decorator changes
add: codegen to generate "else" branch after required query string serialization `if let Some` check
add: missing tokio feature to `TokioTest`

* update: mandatory-query-param.rs tests

* format: run cargo fmt

* update: return BuildError for missing required query params
update: required-query-params.rs tests

* formatting: make RustWriter.paramList more readable
fix: code broken by merge from `main`

* fix: handling of enum strings

* add: codegen tests for required query params
update: required enum query param codegen
add: smithy-rs CHANGELOG.next.toml entry

* fix: presigning.rs test

* fix: use `toType` instead of `asType`
fix: indentation in test
2022-11-18 17:35:42 +00:00
david-perez c187e3d5e0
Render full shape IDs in server error responses (#1982)
RestJson1 implementations can denote errors in responses in several
ways. New server-side protocol implementations MUST use a header field
named `X-Amzn-Errortype`.

Note that the spec says that implementations SHOULD strip the error
shape ID's namespace. However, our server implementation renders the
full shape ID (including namespace), since some existing clients rely on
it to deserialize the error shape and fail if only the shape name is
present. This is compliant with the spec, see
https://github.com/awslabs/smithy/pull/1493.

See https://github.com/awslabs/smithy/issues/1494 too.
2022-11-17 16:51:51 +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
ysaito1001 cdb4a3f351
Rework enum for forward-compatibility (#1945)
* Make enum forward-compatible

This commit implements the suggested approach described in
https://github.com/awslabs/smithy-rs/issues/627#issuecomment-995923092

The idea is that once the user writes a match expression against an enum
and assumes that an execution path comes to a particular match arm, we
should guarantee that when the user upgrades a version of SDK, the
execution path should come to the same match arm as before.

* Add unit test to ensure enums are forward-compatible

The test first mimics the user's interaction with the enum generated from
a model where the user writes a match expression on the enum, wishing to
hit the match arm corresponding to Variant3, which is not yet supported
by the model. The test then simulates a scenario where the user now has
access to the updated enum generated from the next version of the model
that does support Variant3.
The user's code should compile in both of the use cases.

* Generate rustdoc for enum's forward-compatibility

This commits generates rustdoc explaining to the users how they might
write a match expression against a generated enum so their code is
forward-compatible. While it is explained in
https://github.com/awslabs/smithy-rs/issues/627#issuecomment-995923092,
it can be helpful if the users can read it in rustdoc right below where
the enum's definition is shown.

* Make snippet in rustdoc text

This commit updates a rustdoc code snippet generated for an enum from
`rust,no_run` to `text`. We observed that the snippet fails to compile
in CI because the name of the enum was not fully qualified; code in
rustdoc is treated in a similar way that code in integration tests is
treated as being outside of a crate, but not part of the crate, which
means the name of the crate needs to be spelled out for a `use` statement
if we want to import the enum to the code in rustdoc. However, the name
of the crate is usually one-off, generated on the fly for testing, making
it not obvious to hard-code it or obtain it programmatically from within
Kotlin code.

* Suppress missing doc lint for UnknownVariantValue

This commit marks UnknownVariantValue as `#[allow(missing_docs)]` because
failing to do so will cause tests in CI to fail.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

Co-authored-by: Russell Cohen <rcoh@amazon.com>

* Generate UnknownVariantValue via forInlineFun

This commit attempts to create UnknownVariantValue using
RuntimeType.forInlineFun. Prior to this commit, it was generated per enum
but that caused multiple definitions of UnknownVariantValue in a single
file as there can be multiple enums in the file.
By using RuntimeType.forInlineFun, we can generate a single UnknownVariantValue
per module and the enums within the module can refer to the same instance.

This commit, however, fails to pass the unit tests in EnumGeneratorTest.
The issue seems to be that a RustWriter used in the tests does not end up
calling the finalize method, failing to render inline functions.

* Replace "target == CodegenTarget.CLIENT" with a helper

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1014390811
but uses an existing helper CodegenTarget.renderUnknownVariant.

* Update EnumGeneratorTests to use TestWorkspace

This commit addresses failures for unit tests in EnumGeneratorTests.
Now that we use RuntimeType.forInlineFcn in EnumGenerator, we need
to ensure that the inline functions should be rendered to a Rust
source file during testing. RustWriter, used in EnumGeneratorTests
prior to this commit, was not capable of doing so. We thus update
EnumGeneratorTests to use TestWorkspace by which we ensure that the
inline functions are rendered during testing.

* Make sure to use the passed-in variable for shapeId

This commit fixes a copy-and-paste error introduced in 712c983. The
function should use the passed-in variable rather than the hard-coded
literal "test#SomeEnum".

* Address https://github.com/awslabs/smithy-rs/pull/1945\#discussion_r1014389852

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1017235315

* Avoid potential name collisions by UnknownVariantValue

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1017237745.
It changes the module in which the `UnknownVariantValue` is rendered.
Before the commit, it was emitted to the `model` module but that might cause
name collisions in the future when a Smithy model has a shape named
`UnknownVariantValue`. After this commit, we render it to the `types` module.

* Move re-exports from lib.rs to types.rs

This commit moves re-export statements in client crates from `lib.rs` to
`types.rs`. The motivation is that now that we render the struct
`UnknownVariantValue` in a separate file for the `types` module, we can
no longer have a `pub mod types {...}` block in `lib.rs` as it cannot
coexist with `pub mod types;`.

* Add docs on UnknownVariantValue

This commit adds public docs on `UnknownVariantValue`. Since it is
rendered in `types.rs`, the users may not find the `Unknown` variant
of an enum in the same file and may wonder what this struct is for when
seeing it in isolation.

* Update CHANGELOG.next.toml

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1020414459

* Update the module documentation for types

This commit updates rustdoc for the types module to reflect that fact
that the module now contains not only re-exports but also an auxiliary
struct `UnknownVariantValue`.

* Add extensions to run code block depending on the target

This commit introduces extensions on CodegenTarget that execute the block
of code depending on the target is for client or for server. These
extensions are intended to replace if-else expressions throughout the
codebase explicitly checking whether the target is for client or for server.
We do not update such if-else expressions all at once in this commit.
Rather, we are planning to make incremental changes to update them
opportunistically.

* Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt

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

* Move extensions into CodegenTarget as methods

This commit addresses https://github.com/awslabs/smithy-rs/pull/1945#discussion_r1021952411.
By moving extensions into the CodegenTarget enum, no separate import is
required to use them.

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
Co-authored-by: Yuki Saito <awsaito@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-11-16 21:03:36 +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
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 7477cfbc7e
Add error refactor changelog entries and re-export `DisplayErrorContext` (#1951)
* Re-export `DisplayErrorContext`
* Update changelog
2022-11-12 00:35:41 +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
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 e2e0d93545
Fix retry config doc comments and remove re-export (#1935) 2022-11-04 00:09:10 +00:00
Alberto Rosado 8ba894b6cf
Allow user to set 'policy' and 'policy_arns' in AssumeRoleProvider bu… (#1892) 2022-11-03 23:24:02 +00:00
ysaito1001 beb8a68786
Fix cargo audit issue on criterion (#1923)
* Depend on criterion 0.4.0

This updates criterion from 0.3.6 to 0.4.0 to avoid RUSTSEC-2021-0127
where criterion 0.3.6 depends upon an unmaintained crate `serde_cbor`.

* Update CHANGELOG.next.toml

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
2022-11-01 12:22:40 -05: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 2aafd044e2
update: to smithy v1.26 (#1929)
* update: to smithy v1.26

* add: entry to CHANGELOG.next.toml
2022-10-31 13:39:19 -05: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
Zelda Hessler 1ca52459a6
Add a test ensuring streamed response will error if `EOF` is received early (#1906)
* add: test ensuring streamed response will error if eof is received early
formatting: sort s3 integration test cargo toml deps
update: CHANGELOG.next.toml

* formatting: run cargo fmt
remove: commented out logging init
add: comment for CRLF check
update: read Ok(0) case to say note that it's unreachable and why that's the case
update: debug messages

* update: test to use OS-assigned port instead of 3000
2022-10-26 16:34:54 +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
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
AWS SDK Rust Bot 3e24477ae7 Update changelog 2022-10-24 17:47:44 +00:00
ysaito1001 ca2c7883e7
Add test to exercise excluded headers in aws-sigv4 (#1890)
* Add test for excluded headers list

This commit adds a test for the functionality added in #1381. Technically,
there was an existing test `presigning_header_exclusion` that exercised
the said functionality but it only covered the behavior partially, i.e.
only a case where the `excluded_headers` field in `SigningSettings`
contained just `user-agent`.

The new test will randomly add headers to `excluded_headers` and verify
the functionality works as expected.

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

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

Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-10-21 20:47:48 +00:00
ysaito1001 521fa8d0dc
Fix aws-sigv4 canonical request formatting fallibility (#1656)
* Fix panic occurred in formatting CanonicalRequest

This commit addresses panic in the case of formatting a CanonicalRequest
containing invalid UTF-8 in the header value.

The commit aims for the least disturbance to the codebase in order to
pass a given failing test in the PR. We want to quickly determine if
this low-cost approach addresses the problem before we commit ourselves
to start refactoring CanonicalRequest to have a special format function.

Fixes #711

* Update test_signing_utf8_headers to proptest

This commit converts test_signing_utf8_headers to a proptest. The
original test only specified hardcoded non-UTF8 bytes in a request
header. To ensure that `crate::http_request::sign` does not panic no
matter what valid byte sequence for HeaderValue is, the proptest covers
a wider range of inputs.

For consistency, the test has been moved from `canonical_request.rs` to
`sign.rs`.

* Add InvalidHeaderError to make the error explicit

This commit introduces an error type InvalidHeaderError to indicate that
we ran into a problem in handling a HeaderValue within CanonicalRequest.

The error type contains a source error such as Utf8Error so a diagnostic
message can be printed if needed.

* Remove InvalidHeaderError for error refactoring

This commit effectively reverts 739b32c. Knowing that we will be cleaning
up error types, having InvalidHeaderError is too narrow a solution and
does not add value to the codebase.

* Update CHANGELOG.next.toml

Co-authored-by: Russell Cohen <rcoh@amazon.com>
Co-authored-by: Saito <awsaito@c889f3b5ddc4.ant.amazon.com>
2022-10-18 21:28:46 -05:00
Kevin Park 374a0a25f8
Ability to override the IMDS client in `DefaultCredentialsChain` (#1867) 2022-10-18 15:23:25 -07:00
David Oguns 9260781f45
Add mavenLocal repo to allow for local dependency override (#1852) 2022-10-17 14:03:42 -07: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
ethyi 057fe971b8
Update with flexible zeroize version (#1817) 2022-10-11 17:15:07 +00:00
Harry Barber 78022d69ef
Remove Protocol enum (#1829)
* Remove Protocol enum

* Update Python implementation
2022-10-10 14:29:37 +01:00
Julian Antonielli 238cf8b434
Fix @sensitive handling in Display implementations on error shapes (#1802)
* Use `Sensitive` wrapper in Debug impl for structures

* Fix using the wrong import path for `Sensitive`

* Use redactMemberIfNecessary

* Fix display implementation on errors to respect @sensitive trait

* Don't use Sensitive type just yet

* Add entry in changelog

* Improve redaction of sensitive error message

* Use correct flags in changelog

* Run ktlint
2022-10-07 14:44:11 +01:00
Kevin Park e78da5598a
Fix regression: Use `connect_timeout` and `read_timeout` again (#1822) (#1823) 2022-10-07 00:10:14 +00: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
Luca Palmieri 917d0a62b5
Do not generate public empty modules (#1803)
* Mark `operation_handler` module as private in the generated server code since it does not contain any public type.
Tune the visibility of the 'operation' module based on the rendering context

* Add changelog.next entry.

* Rename `operationModule` to `operation`.

* Ensure that `operation` is added to the list of public modules for the generated client.

* Remove DefaultModules from codegen-core

* Fix Python server.

* Expose TestDefaultPublicModules.
2022-10-04 17:15:22 +01:00
kastolars 4cfac14d49
Getters added to ConfigImpl (#1761) 2022-09-29 16:43:07 +00:00
John DiSanti a11ea2a008
Fix changelog entry (#1781) 2022-09-28 13:08:08 -07:00
John DiSanti 7b96ae418a
Don't error on duplicate pagination token (#1748) 2022-09-27 17:05:23 +00:00
John DiSanti ef85116f77
Add ability to programmatically customize profile files (#1770) 2022-09-27 09:33:16 -07: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
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
Nicolas Farrier ff13b087fe
Run `cargo clippy` when building the Pokémon Service (#1742) 2022-09-21 11:26:02 +00:00
AWS SDK Rust Bot 7b27f376cd Update changelog 2022-09-20 12:42:29 +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
Manuel Sugawara ffafbec885
Correctly determine nullability of members in IDLv2 models (#1725) 2022-09-16 17:11:09 -07: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
John DiSanti 56f4be3207
Add customization to retry STS `IDPCommunicationErrorException` (#1718) 2022-09-09 17:25:43 -07:00
Zelda Hessler 4809a5b4fd
Remove the need for operation type aliasing in codegen (#1710)
* remove: need for operation type aliasing
rename: FluentClientGenerics.sendBounds params to be more accurate
update: FlexibleClientGenerics.sendBounds impl for readability
update: type of FluentClientGenerator input param `retryPolicyType` to be `Any` with a default of `RustType.Unit`
update: PaginatorGenerator to take retryPolicy as an input
chore: fix some spelling and grammar issues
remove: redundant `nextTokenEmpty` function from PaginatorGenerator

* Update CHANGELOG.next.toml

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

* add: `writable` property to RustType that returns the type as a Writable
add: test for RustType writable
add: `writable` property to RuntimeType that returns the type as a Writable
update: FluentClientGenerator to take a writable for retry

* format: run formatter

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-09-07 17:26:56 +00:00
David Oguns e3239e1a17
Flatten and remove mixins from code generation (#1680) 2022-09-06 16:00:42 -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
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
AWS SDK Rust Bot 2cb76641b6 Update changelog 2022-08-31 09:48:52 +00:00
Zelda Hessler 63afb41022
Add "invalid xml body root" check exemption for S3's `GetObjectAttributes` (#1665)
* add: ability for certain operations to be exempt from XML body root checking
* add: XML body root checking exemption for com.amazonaws.s3#GetObjectAttributesOutput
2022-08-27 02:08:02 +00:00
Zelda Hessler a65b1aaa8d
Update MSRV to 1.61.0 (#1672) 2022-08-25 15:43:35 -07: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
David Oguns 7f4dad62a4
Update Smithy to 1.23.1 to support IDL 2 (#1623) 2022-08-19 13:29:05 -07: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
Weihang Lo e185990a0e
Support granular control of specifying runtime crate versions (#1635)
* Support granular control of specifying runtime crate versions

**BREAKING**: after this PR, `in smity-build.json` the path
`rust-codegen.runtimeConfig.version` no longer exists. Instead, a new
field `versions` comes in. It's an object mapping a runtime crate name
to a version string. There is also a special key `DEFAULT`, which is
presetted as detected runtime version but open to override. Crates
without version specified would be set as the same version as which
associated to key `DEFAULT`.

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
2022-08-17 22:20:44 +00:00
Zelda Hessler e4e9a1d34f
fix: move smithy config customization into the smithy code generator (#1599)
* fix: move smithy config customization into the smithy code generator

* add: CHANGELOG entry

* update: tests

* fix: config codegen tests

* update: hide config fields and provide accessors instead

* fix: usage of private fields
add: accessor docs

* format: run ktlint

* fix: update more old code

* update: clone sleep_impl since that's why people access it

* update: CHANGELOG.next.toml

* Update CHANGELOG.next.toml

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

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-08-16 15:47:07 -05:00
John DiSanti 0f47f69ddf
Fix changelog template (#1638) 2022-08-16 18:59:10 +00:00
Burak 610d963df6
Add codegen version to generated package (#1621)
* Add codegen version to generated package metadata

* Update `CHANGELOG.next.toml`

* Remove unnecessary try-catch block from `smithyCodegenVersion`

* Add git commit hash to version

* Fix version filename

* Add tests for `Version`

* Store version in "$smithyRsVersion\n$gitCommitHash" format

* Make version parsing more strict
2022-08-12 11:35:55 +01:00
AWS SDK Rust Bot db48039065 Update changelog 2022-08-04 01:37:32 +00:00
John DiSanti a2ccdf70fb
Add `#[doc(hidden)]` to struct fields to encourage accessor use (#1573) 2022-08-03 01:26:04 +00:00
Weihang Lo e38db43ceb
Basic support of @deprecated trait in Smithy model (#1570)
* Add helper for creating deprecated attribute

* `Attribute.Custom.deprecated` is the main logic for building up
  `#[deprecated]` attribute
* `RustWriter.deprecatedShape` is the counterpart of `documentShape`,
  but we do not going to generalize it as what `documentShape` does.
  Deprecated is only for Rust code and probably won't be used in other
  output language.

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Test `@deprecated` trait for RustWriter

* Support `@deprecated` trait for StructureGenerator

* Support `@deprecated` trait for UnionGenerator

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Support `@deprecated` trait for EnumGenerator

* Support `@deprecated` trait for TopLevelErrorGenerator

* Support `@deprecated` trait for CombinedErrorGenerator

* Support `@deprecated` trait for ServerCombinedErrorGenerator

* Support `@deprecated` trait for FluentClient

* Support `@deprecated` trait for BuilderGenerator

* Cleanup leftover in test

* Use `dq()` helper method instead of escaping by hands

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Leverage Kotlin null safety well

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Allow `deprecated` rustc lint rule

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Allow deprecated in unit tests

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Leverage kotlin null safety check again

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* changelog: Support @deprecated trait

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-07-28 19:02:55 +00:00
Oleksandr Kolomiiets 0f2fae1183
Change detailed logs in CredentialsProviderChain from info to debug (#1578) 2022-07-26 18:38:28 -07:00
Matteo Bigoi c7b97dcc02
Codegenerate Python application example and add explicit cast during JSON deserialization (#1520)
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-07-26 15:53:42 +00:00
Zelda Hessler 2ad87c0eed
feature: support flexible checksums (#1561)
feature: support flexible checksums
update: s3 model
update: CHANGELOG.next.toml
2022-07-26 15:14:49 +00:00
John DiSanti 7d2a6595f7
Add client creation example to SDK crate READMEs (#1571) 2022-07-25 22:30:03 +00:00
82marbag 3610085af9
Support server event streams (#1479)
* Support server event streams
* Rename EventStreamInput to EventStreamSender
* Custom event stream errors
* EventStreamSender and Receiver are parametrized also on event stream error types
* Pokemon service model updated
* Pokemon server event handler
* Pokemon client to test event streams
* EventStreamDecorator to make optional using SigV4 signing
* Use forInlineFun for all errors

Closes: #1157

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

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-07-25 13:24:06 -04:00
AWS SDK Rust Bot 700cee65ca Update changelog 2022-07-20 17:48:27 +00:00
John DiSanti 010a234832 Expose `sleep_impl` configuration in `SdkConfig` (#1556) 2022-07-20 09:42:28 -07:00
John DiSanti 1023c5035a Make `imds::Client` implement `Clone` (#1557) 2022-07-20 09:42:28 -07:00
John DiSanti d9ac9959de Don't warn about home dir expansion for default profile paths (#1558) 2022-07-20 09:42:28 -07:00
John DiSanti 32122ce285 Remove warning for valid IMDS provider use-case (#1559) 2022-07-20 09:42:28 -07:00
John DiSanti 6143d90197
Enable independent crate versioning for SDK crates (#1540)
* Update `hydrate-readmes` to take versions from `versions.toml`
* Add cleanup TODO comments to `changelogger`
* Update SDK readme template
* Split up `generate-version-manifest` subcommand
* Eliminate the `aws.sdk.version` property
* Fallback to model hash comparison if model metadata claims no changes
* Add `acquire-base-image` to `release.yml`
* Use empty model metadata for SDK generation in CI
* Fix the `aws-config` version number in SDK crate readmes
2022-07-19 12:27:45 -07:00
Zelda Hessler 298748a606
fix: misspelled name (#1554) 2022-07-19 17:21:19 +00:00
Zelda Hessler b32395bfcc
Feature: checksum related body-wrappers (#1502)
* add: checksum related body-wrappers
add: tests for checksum related body-wrappers

* add: aws-smithy-checksums to CrateSet.key

* add: missing base64::encoded_length fn

* update: use the checksum digest trait's output_size method to get checksum size
add: proptest for base64 encoded length
remove: old base64 encoded length test
remove: incorrect leftover comments and comment quotes

* remove: unnecessary pin

* remove: use of clone during checksum finalization
refactor: checksum fns are no longer fallible
refactor: HttpChecksum is now responsible for reporting size correctly
fix: don't consider trailers as part of ChecksumBody size hint

* remove: Taken error state
update: prefer if-let to match
fix: incorrect is_end_stream impl
refactor: use default trait impl for HttpChecksum::header_value

* fix: clippy lint

* add: header value tests

* undo: accidental retry changes

* add: http-checksum-related errors

* refactor: break up and modularize body wrappers
update: docs
update: ChecksumValidatedBody::new now takes a Box<dyn HttpChecksum>

* fix: broken test

* refactor: rename checksum body structs to be differentiated only by their module
2022-07-18 12:51:10 -05:00
Zelda Hessler 70c6a02555
update: impl From<DynConnector> for HttpConnector (#1549)
update: CHANGELOG.next.toml
2022-07-18 15:33:48 +00:00
Zelda Hessler e6005fb191
Feature: make retry strategy exponential backoff multiplier configurable (#1548)
* feature: make retry strategy backoff configurable
update: smithy client to respect configurable backoff
update: CHANGELOG.next.toml

* fix: calculate_exponential_backoff

* update: make the backoff calculation simpler
update: default backoff multiplier to be 1 second to better match previous retry behavior

* update: retry builder backoff multiplier default

* rename: backoff_multiplier to initial_backoff
update: calculate_exponential_backoff tests for readability

* remove: copypasted code

* update: CHANGELOG.next.toml
2022-07-15 11:22:47 -05:00
Josh Triplett c6193bd31d
`aws-config`: Fix compilation error with `rustls` and `native-tls` disabled (#1533)
* `aws-config`: Fix compilation error with `rustls` and `native-tls` disabled

The `ProviderConfig::with_tcp_connector` method uses
`aws_smithy_client::hyper_ext`, which only exists with the
`client-hyper` feature enabled. Add a feature enabling that, and enable
it by default.

Introducing this feature does not cause breakage, because aws-config
did not previously compile with `default-features = false` and neither
`rustls` nor `native-tls` enabled.

* CHANGELOG.next.toml: Update for aws-config compilation fix

* Fix doctest by adding feature gate

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-07-13 11:26:09 -05:00
David Calavera b1d50b5611
Re-export aws_types::SdkConfig in aws_config (#1457)
* Re-export aws_types::SdkConfig in aws_config

This way people that want to access that structure don't have to add aws_types.

Signed-off-by: David Calavera <david.calavera@gmail.com>

* Add entry about SdkConfig to the changelog

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-07-06 00:05:30 +00:00
Zelda Hessler b77c66cbf7
Feature: add support for aws-chunked content encoding (#1501)
* add: support for unsigned aws-chunked content encoding

* add: aws-smithy-checksums to CrateSet.key

* refactor: API of AwsChunkedBodyOptions
update: AwsChunkedBody to note we only support single chunks
remove: unnecessary `Option`s
remove: overly smart total_length_of_trailers_in_bytes in trailers_as_aws_chunked_bytes
update: use "where"-style declaration for `impl<Inner> Body for AwsChunkedBody<Inner>`
add: helpful data to trace logging
add: trailer len double check in AwsChunkedBody::poll_data
add: test for trailer len double check
add: assert to size_hint
fix: incorrect body emitted when body is empty
add: test for empty encoded body

* Update CHANGELOG.next.toml

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

* update: CHANGELOG.next.toml message

* refactor: aws-chunked trailer encoding and size calculation
update: when aws-chunked formatting a `HeaderMap`, header names with multiple values will be written out one value per line
remove: unnecessary AwsChunkedBodyOptions::stream_length method
add: trace fields
refactor: make inserting the final body CRLF more explicit
add: test to ensure trailer encoding and trailer len calculation stay in sync

* udpate: emit error instead of panicking for incorrect trailer length

* add: test ensuring trailer serialization and length calculation stay in sync for empty HeaderMap

* update: avoid repeated allocations in trailers_as_aws_chunked_bytes
fix: don't convert to str before getting len of HeaderValue

* add: aws-chunked body test for inner bodies that emit intermittent chunks
add: double check that stream_length used to create an `AwsChunkedBody` is correct.

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-07-05 11:36:14 -05:00
AWS SDK Rust Bot 334f6dd203 Update changelog 2022-06-28 23:05:33 +00:00
Zelda Hessler 3f108165aa
Update: swap pin-project for pin-project-lite (#1503)
* update: swap pin-project for pin-project-lite
* remove: pin attribute from `aws_smithy_http::body::Inner::Once` enum variant
* remove: unnecessary usage of pin-project
* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-06-28 14:01:39 -05:00
Kyle Thomson ed04cbcfe8
Fix platform issue when determining module name from file (#1505) 2022-06-28 11:56:59 +00:00
Joseph Klix 424d736768
Docker hop limit (#1449)
* Docker settings

add note on settings needed when using sdk inside docker container

* update changelog.next

* move to group relevant info

* mark code snippet as txt
2022-06-27 17:07:23 -04:00
Russell Cohen b88d72e237
Add a trailing slash to iam/security-credentials/ when querying IMDS (#1487) 2022-06-23 20:09:54 +00:00
Russell Cohen edb1394561
Upgrade to Gradle 7 (#1411)
* Upgrade to Gradle 7

* Document the upgrade and update changelogs
2022-06-23 12:27:43 -04:00
AWS SDK Rust Bot 5b49350037 Update changelogs 2022-06-22 21:20:42 +00:00
Russell Cohen 1446681c0a
Add support for retrying individual call timeouts (#1478)
When timeout support was added initially, the resulting error `SdkError::TimeoutError` was never added to the retry policy which prevented these errors from being retried. This was a bug—This commit rectifies the and adds two integration-level tests that ensure that timeouts are properly retried.
2022-06-21 17:37:04 +00:00
Zelda Hessler 2f2db5a637
rename: hosted_zone_preprocessor.rs to route53_resource_id_preprocess… (#1472)
* rename: hosted_zone_preprocessor.rs to route53_resource_id_preprocessor.rs
update: trim_hosted_zone to work for more resource ids
add: new Route53 protocol test for GetChange resource id trimming
update: InlineDependency.forRustFile to accept filenames with a ".rs" extension
add: CHANGELOG.next.toml entry
2022-06-16 14:37:01 -05:00
Zelda Hessler 04eeb4ff13
update: simplify and fix a latent issue with bytestream's streaming impl (#1461)
update: print helpful panic message for users on 32bit systems that try to stream large bodies
update: CHANGELOG.next.toml
2022-06-15 20:18:20 +00:00
Russell Cohen b45c1f03d8
Fixes for RustWriter bugs #1465 & #1459 (#1467) 2022-06-15 16:20:47 +00:00
John DiSanti ea2ae7bfc6
Add lints to `aws-config` (#1421)
* Add `unreachable_pub` lint to `aws-config`
* Add `missing_debug_implementations` lint to `aws-config`
* Add `rust_2018_idioms` lint to `aws-config`
* Update changelog
2022-06-13 20:34:11 +00:00
Russell Cohen 6e3e010e91
Relax behavior of profile parser (#1458)
- Fixes aws-sdk-rust#547

Previously, if no default profile was defined and no explicit profile was selected, the profile file provider would return an error. This relaxes that behavior to allow provider chains to move onto the next provider when that is the case.
2022-06-13 14:47:59 +00:00
AWS SDK Rust Bot 7b5954ed8f Update changelogs 2022-06-09 22:53:53 +00:00
Jesse Szwedko 53fab07a46
Add support for `credential_process` from profiles (#1356)
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-05-26 14:01:50 -07:00
Petros Angelatos bb9f2dc111
Use md5 implementation of RustCrypto organization (#1404) 2022-05-24 10:36:03 -07:00
Zelda Hessler 75d50dd157
feature: conversion method for `ByteStream` into `AsyncRead` implementor (#1391)
* feature: conversion method for ByteStream into AsyncRead implementor
add: impl From<byte_stream::Error> for std::io::Error
add: CHANGELOG.next.toml entries

* fix: unused dep

* add: docs
2022-05-16 22:34:54 +00:00
alonlud 5620922d23
Add excluded headers option to `aws-sigv4` (#1381) 2022-05-16 14:02:02 -07:00
AWS SDK Rust Bot 9db2a737c4 Update changelogs 2022-05-13 17:56:33 +00:00
82marbag 154c5d1bd0
Update crates to Rust 2021 (#1388)
Generate crates using Rust 2021 instead of Rust 2018
Remove use std::convert::TryFrom which is in the prelude

Closes #1332

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-05-13 14:28:52 +01:00
Zelda Hessler 34369e2dc0
Update `FsBuilder`-based `ByteStreams` to support file offsets (#1361)
* add: offset setter to FsBuilder
remove: file_size setter from FsBuilder
add: length setter to FsBuilder
add: test for ByteStream w/ offset
add: test for ByteStream w/ length less than file size
update: path_based_bytestreams_with_builder test

* add: test ensuring offset and length work correctly together
add: test ensuring that no data is returned when offset is greater than file size
add: test ensuring that nothing breaks if length to read is larger than file size

* add: chunking test
add: CHANGELOG.next.toml entry
refactor: new code based on PR comments

* remove: unused use statement

* refactor: length API

* update: prefer unwrap() to returning error in tests

* update: prefer unwrap() to returning error in tests
add: test for Length::Exact behavior

* update: error if offset is greater than file length

* fix: test to work with new offset error

* update: error test to be more specific
2022-05-10 21:41:24 +00:00
John DiSanti 3aab82749b
Add a debug log entry for retries (#1352) 2022-05-02 18:02:09 +00:00
Russell Cohen 9b6210c105
Release (#1351)
* Bump version numbers in gradle.properties

* Add auto-changelog script

* Update models, holding back S3

* Update CI to 1.58.1
2022-04-28 22:24:21 +00:00
Ryan Scott Brown bea5f1d2c3
fix: Silence home directory warning in Lambda Extensions (#1344)
* fix: Silence home directory warning in Lambda Extensions

This PR follows on to https://github.com/awslabs/smithy-rs/pull/893 which added
LAMBDA_TASK_ROOT check. When running as a [Lambda Extension][ext]
the environment variable for TASK_ROOT is redacted, so it is not
reliable for testing whether you are in Lambda.

Related commit: fbb4bc

[ext]: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html

* update changelog

* fixup: use AWS_LAMBDA_FUNCTION_NAME which is available in both environments

* Update CHANGELOG.next.toml

* Fix failing unit test

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-04-26 20:19:34 -07:00
Zelda Hessler 1372754f42
add: callback trait proposed in rfc#0012 (#1329)
* add: callback trait proposed in rfc#0012
add: callback setting API to ByteStream
add: callback setting API to SdkBody
add: callback tests for streaming and buffered data
add: private callback fns for calculating checksums
udpate: pub methods on private struct `Inner` to be private
update: changelog
remove: Sync bound from SdkBody test "sdk_body_is_send()"
add: fn to merge `HeaderMap`s by appending
add: tests for new functionality

* add: Sync bound to callbacks
refactor: poll_trailers method
update: split out checksum callbacks into their own module
formatting: use throwaway let binding instead of allow unused variable

* add: license file to new crate
add: readme file to new crate

* add: missing anchor to Cargo.toml

* rename: aws-smithy-checksum-callbacks to aws-smithy-checksums
add: two more append_merge_header_maps tests
update: make append_merge_header_maps pub(crate)
remove: check for non-existent log line

* remove: doc test for private fn

* update: checksum callback struct names
2022-04-21 12:51:01 -05:00
John DiSanti 27acbc6d30
Upgrade Smithy (#1330)
* Upgrade to Smithy 1.16.2

* Remove extra test fixed in Smithy 1.16.2

* Upgrade to Smithy 1.16.3

* Remove extra test fixed in Smithy 1.16.3

* Remove failing expectation from server tests

* Upgrade to Smithy 1.17.0

* Upgrade to Smithy 1.18.1

* Upgrade to Smithy 1.19.0

* Upgrade to Smithy 1.21.0

* Update changelog

* Fix Gradle repositories
2022-04-21 09:22:35 -04:00
Zelda Hessler 52b808ec13
update: MSRV from 1.56.1 to 1.58.1 (#1325)
* update: MSRV from 1.56.1 to 1.58.1

* update: CHANGELOG.next.toml
fix: cdk rust issues

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml
2022-04-15 14:01:18 -05:00
Zelda Hessler d16ee113ad
Prepare for 2022-04-13 release (#1317)
* update: models for release

* update: Changelogs for release
update: gradle properties for release
2022-04-13 11:00:30 -05:00
Nikhil Benesch b7a8eb5824
Add endpoint resolver to SdkConfig (#1300)
* Add endpoint resolver to SdkConfig

This commit adds an `endpoint_resolver` field to SdkConfig, which flows
through to the `endpoint_resolver` field on each individual service
configuration. To avoid a circular dependency between the aws-types
crate and the aws-endpoint crate, the `AwsEndpoint` type and its
dependencies are moved from the aws-endpoint crate to the aws-types
crate, then rexported in aws-endpoint.

Fix aws-labs/aws-sdk-rust#396.

* impl From<'static str> for signing service and signing region

* Code generate for the static string implementation

* Add EndpointResolver to aws_config

* Add docs and adapt test

* Fix test

* Fix endpoint config customizations test to remove dead code

* Re-add `.set_endpoint`

* Remove print and update changelog

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-04-12 17:51:50 +00:00
Nikhil Benesch 3aa1e36b6f
aws-smithy-query: bump to urlencoding v2.1 (#1301)
* aws-smithy-query: bump to urlencoding v2.1

* Add changelog entry for urlencoding update

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-04-04 15:05:18 -07:00
Russell Cohen 6e8c1d873e
Improve AssumeRoleProvider (#1296)
This adds to improvements to `AssumeRoleProvider`:
1. This adds a cache aroudn this provider. Since this provider is intended to be used directly by customers,
it should be cached to improve performance and predictability.

2. Add support for configuring the role session length.
2022-04-01 12:30:53 -07:00
Rob Speller bd38d0dd1e
fix: treat blank env credentials as missing (#1272) 2022-03-29 16:53:13 -07:00
Zelda Hessler da8d59e0a1
fix: incorrect issue reference (#1270) 2022-03-22 22:23:35 +00:00
Zelda Hessler b2c989630f
Update to Rust Edition 2021 (#1268)
* update: set rust edition to 2021
update: strict param of intoCrate to set clippy to set #![deny(clippy::all)]

* add: changelog entry
2022-03-22 21:29:04 +00:00
Bin Liu 622712058f
Fix developer guide URL (#1262)
* Update README.md to fix invalid Developer Guide URL

The old guide:
https://github.com/awslabs/aws-sdk-rust/blob/main/Guide.md

has been deleted and changed to:
https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html

See: https://github.com/awslabs/aws-sdk-rust/pull/325

Signed-off-by: bin liu <liubin0329@gmail.com>

* Update invalid Developer Guide URL in AwsReadmeDecorator.kt

The old guide:
https://github.com/awslabs/aws-sdk-rust/blob/main/Guide.md

has been deleted and changed to:
https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html

See: https://github.com/awslabs/aws-sdk-rust/pull/325

Signed-off-by: bin liu <liubin0329@gmail.com>

* Add fixing Developer Guide link to  CHANGELOG.next.toml

Signed-off-by: bin liu <liubin0329@gmail.com>

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-03-21 15:20:25 +00:00
John DiSanti 61b0a8a8e5
Prepare for release (#1261)
* Update AWS models

* Version bump

* Revert S3 model update

* Update changelogs

* Update endpoints config
2022-03-17 14:18:46 -07:00
Zelda Hessler 3eaddcf738
Add default list of http versions to request property bag (#1258)
* add: default list of http versions
add: type alias for list of http versions
add: decorator to add desired http versions to property bag
fix: gradle warning for argument "model"
update: CHANGELOG

* fix: clippy lint

* update: use more accurate name for test RustCodegenDecorators
rename: HttpVersionListGenerator.kt to HttpVersionListCustomization.kt
update: HttpVersionListCustomization to grab versions from models when possible
fix: various docs issues reported by IDE
add: new "Extras" section to ServiceConfig
update: code broke by "Extras" change
add: tests for http version sniffing
2022-03-17 08:09:01 -05:00
Zelda Hessler 107194f106
Timeouts refactor (#1246)
* rename: in aws_smithy_types, timeout::TimeoutConfig is now timeout::Config
update: timeout::Config now wraps 3 config structs (Http, Tcp, Api)
update: aws_config timeout setting to work with timeout::Config changes
update: providers to work with new timeout config structure
update: codegen to work with new timeout config structure
update: CHANGELOG.next.toml

* add: missing copyright header

* update: impl From instead of Into for timeout conf
fix: clippy lints

* fix: service config codegen for timeouts

* fix: broken doc tests

* fix: bad doc link

* update: transfer aws_types::Config changes to new aws_types::SdkConfig

* fix: two outdated doc tests

* Apply suggestions from code review

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

* undo: doc change for timeout env vars
refactor: move parse_str_as_timeout to aws_config and privatize it
update: aws_config code for parse_str_as_timeout
move
remove: comments from private struct members
update: comments for pub struct methods

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-03-11 11:35:13 -06:00
Zelda Hessler e6d09ea686
Rename `aws_types::config::Config` to `sdk_config::SdkConfig` (#1241)
* rename: aws_types::config::Config to sdk_config::SdkConfig
update: code affected by SdkConfig rename
update: CHANGELOG.next.toml

* update: reëxport SdkConfig from aws_types root module

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

* Update CHANGELOG.next.toml

Co-authored-by: Russell Cohen <rcoh@amazon.com>

* add: deprecated config helper
update: use reexported SdkConfig in docs referencing it

* fix: bad doc link
fix: wrong deprecation version

* Revert "fix: bad doc link"

This reverts commit eaa1b68e3b.

* fix: try new link style

* add: deprecation notice for `aws_types::config` module

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-03-10 19:55:08 +00:00
Russell Cohen 3a54b91359
Enable presigning for two more S3 operations (#1242) 2022-03-09 13:27:03 -05:00
Zelda Hessler e42aa10ac3
Update: impl `Clone` for `DynMiddleware` (#1226)
* update: make DynMiddleware cloneable
rename: BoxCloneLayer to ArcCloneLayer
update: make ArcCloneLayer cloneable

* update: CHANGELOG.next.toml
2022-02-25 10:58:41 -06:00
John DiSanti f7e1f0836e
Prepare for `v0.38.0` release (#1223)
* Update changelogs

* Update AWS models

* Version bump
2022-02-24 19:51:00 +00:00
John DiSanti 4ff8dc6d8b
Make it possible to configure the default credentials cache (#1220)
* Make it possible to configure the default credentials cache

* Update changelog

* Add settings directly to the `DefaultCredentialsChain` builder

* Improve doc comments for `load_timeout`
2022-02-24 19:04:45 +00:00
John DiSanti b989a8d059
Fix presigning bug with `content-length` and `content-type` in S3 (#1216)
* Fix presigning bug with `content-length` and `content-type` in S3

* Fix presigning test in `aws-sigv4`

* Update changelog

* Clean when generating code for diff preview

* Incorporate feedback

* Fix server codegen

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-02-24 11:30:45 -06:00
John DiSanti 801808061a
Make `rustls` and `native_tls` client builder helpers dyn (#1217)
* Make `rustls` and `native_tls` client builder helpers dyn

* Update changelog
2022-02-23 10:58:10 -08:00
John DiSanti e1099324e1
Replenish cross-request retry allowance on successful response (#1197)
* Replenish cross-request retry allowance on successful response

* Update changelog

* Rename `NotRetryable` to `UnretryableFailure` and fix credential retry classifiers

* Incorporate feedback
2022-02-22 12:58:24 -08:00
John DiSanti 375e0b2b82
Hide external buffer types used by `primitive::Encoder` in aws-smithy-types (#1209)
* Fix exit status in `api-linter`

* Run `api-linter` against `aws-smithy-types` in CI

* Hide external buffer types used by `primitive::Encoder`

* Unpin nightly in CI

* Make `Encoder` a struct and split out an inner enum

* Update changelog
2022-02-22 20:05:02 +00:00
Russell Cohen 058f28e4a6
Release 0.7.0 (#1202)
* Update changelogs

* Sync models

* bump versions
2022-02-18 10:31:13 -05:00
John DiSanti 548f6ed430
Fix the hardcoded credentials example in `aws-types` (#1180) 2022-02-11 16:16:53 -08:00
Zelda Hessler bd6b65bd6b
fix: region provider now respects chained profiles (#1183)
* fix: region provider now respects chained profiles
update: profile chain creation for load_credentials

* update: CHANGELOG.next.toml

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

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

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-02-11 22:39:22 +00:00
Zelda Hessler a1f065272b
HTTP Connectors Refactor pt.1 - Laying the groundwork (#1144)
* refactor: HttpSettings, HttpConnection location
update: replace timeout::Settings with TimeoutConfig
add: HttpConnector to aws_types::Config and Builder
refactor: divide default_provider.rs modules into separate files

* add: missing copyright headers

* add: missing http_connector accessor to Config

* remove: unused import

* update: undo changes to aws_config::connector module
remove: impl Default for HttpConnector

* update: CHANGELOG.next.toml
2022-02-04 20:17:31 +00:00
Zelda Hessler 4c7515f6a8
fix: Client's fluent builder doc links now correctly link to raw identifiers (#1142)
* fix: don't escape member names in doc links

* update: CHANGELOG.next.toml

* update: use docLink to format builderInputLink

* Apply suggestions from code review

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

* remove: "r#" prefix from reserved word names in docs

* leave: "r#" prefix from reserved word names in docs
giving the people what they want

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-02-02 18:42:14 +00:00
John DiSanti 4029afd439
Eliminate SDK client generics (#1132) 2022-02-01 13:52:45 -08:00
Russell Cohen b79cb2658b
Remove unneeded doc parser (#1123)
* Remove unneeded doc parser

* Maintain identical behavior for empty documents

* Changelog
2022-01-28 18:18:56 -05:00
John DiSanti a183f1246b
Move re-exports into `types` and re-export `AggregatedBytes` (#1085)
* Move re-exports into `types` and re-export `AggregatedBytes`

* Remove extra newline from changelog generator

* Only re-export types when they're used

* Re-export `Config` and `Client` with `#[doc(inline)]`

* Update changelog

* Fix the canary build

* Don't check examples in full services check
2022-01-28 10:11:42 -08:00
John DiSanti dac48166c1
Bump MSRV to `1.56.1` (#1130) 2022-01-27 17:36:55 -08:00
John DiSanti ed3daf613e
Prepare smithy-rs `0.36.0` release (#1122)
* Version bump

* Update service models

* Update changelogs
2022-01-26 10:47:42 -08:00
Zelda Hessler 5b6965aae1
Add conversion methods for `PresignedRequest` and update docs (#1116)
* update: s3 presigning example with curl command generator
add: impl into for PresignedRequest -> http::request::Builder
sort: cargo deps

* update: CHANGELOG.next.toml

* appease: clippy

* add: struct conversion doc links
add: fn for PresignedRequest -> http::Request<B>
update: expand presigning example

* update: changelog
move: declaration of From<PresignedRequest> for http::request::Builder

* remove: leftover import
2022-01-26 18:09:31 +00:00
mchoicpe-amazon e0f01933ae
Provide SigningService creation via owned String (#1114) (#1120) 2022-01-25 15:23:21 -08:00
John DiSanti 39e33163e6
Take SDK examples from `awsdocs/aws-doc-sdk-examples` (#1118)
* Split SDK service checks from example checks

* Delete examples

* Take examples from `aws-doc-sdk-examples`

* Fix example checkout

* Fix example manifests after relocation

* Update changelog
2022-01-25 22:24:13 +00:00
Russell Cohen a411bc3b34
Endpoint docs & aws-config spans (#1087)
* Add more details to custom endpoint docs

* Cleanup aws-config spans

* Cleanup aws-config spans

* Cleanups & update changelog
2022-01-25 21:16:42 +00:00
Zelda Hessler f4d3910f22
prepare for release of 0.35.2/0.5.2 (#1103) 2022-01-20 14:06:33 -08:00
Russell Cohen 88aaa3308b
Sync script needs gradle clean (#1100)
* Sync script needs gradle clean

* Update changelogs
2022-01-20 12:30:47 -05:00
Russell Cohen 18998f3ff3
Changelogs (#1090)
* Update changelogs

* Update versions
2022-01-19 14:58:50 -08:00
Russell Cohen 3e15e4a90c
Add SSO to the list of circular dep supressions (#1089)
* Add SSO to the list of circular dep supressions

* Update CHANGELOG.next.toml

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

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-01-19 22:08:53 +00:00
Zelda Hessler c7ff41707c
release v0.35.0 (#1088)
* release v0.35.0

* update: aws models
2022-01-19 16:23:44 +00:00
Russell Cohen 21ffa905db
Fix paginator bug where `None` was returned immediately (#1083)
* Fix paginator bug where `None` was returned immediately

The escape hatch added by aws-sdk-rust#391 did not properly handle the case where the first response was `None` and _not_ the empty string. This diff:
- Checks for emptiness for both maps and strings
- Fixes the check so that an initial `None` input does not cause an incorrect paginator error

* Update changelog

* Apply suggestions from code review

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

* rustfmt

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-01-18 12:46:53 -05:00
John DiSanti 38fc65da5f
Add changelog entry for #1065 (#1074) 2022-01-13 18:13:26 -08:00
John DiSanti 4bbc677c5a
Fix several warnings and reduce Rust target clobbering (#1069) 2022-01-13 16:45:04 -08:00
John DiSanti c25c24d0f9
Upgrade Smithy to 1.16.1 (#1053) 2022-01-12 15:35:40 -08:00
Russell Cohen 00bc624a87
Add Support for SSO (#1051)
* Add Support for SSO

This commit adds support for the SSO credential provider, which enables the aws-config to support using SSO when specified in `~/.aws/config`.

* Rename & add test of configuration failure

* Add SSO to the smoke test list

* CR improvements

- Improve error messages
- zeroize token
- add track_caller to improve test failure error messages

* Apply suggestions from code review

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

* Update changelogs

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-01-11 13:42:11 -05:00
Zelda Hessler 15eb1c0841
add: links to related types for fluent builders (#1022)
* add: links to related types for fluent builders

* update: CHANGELOG.next.toml

* update: generate fancy documented lists

* refactor: put docs on client builder methods instead of fluent builder
rename: generateShapeMemberList -> generateShapeMemberDocs
refactor: move generateShapeMemberList to FluentClientDecorator.kt
update: appease spellchecker

* remove: extra line in docs

* remove: unnecessary snake case conversion
2022-01-11 00:46:34 +00:00
Russell Cohen 2b90cc9b11
Cut release (#1055) 2022-01-10 18:19:44 +00:00
Russell Cohen 2e50dab45d
Fix bug where paginators looped forever on empty string next token (#1054)
* Fix bug where paginators looped forever on empty string next token

* Update changelogs
2022-01-10 11:38:29 -05:00
Nicolas Moutschen a5554e0691
fix: typo for _X_AMZN_TRACE_ID (#1052)
* fix: typo for _X_AMZN_TRACE_ID

* chore: add entry to CHANGELOG.next.toml

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2022-01-10 09:35:59 -05:00
Zelda Hessler 9be54c9ee6
prepare for release of smithy-rs 0.34 (#1047)
* prepare for release

* remove: extra backtick
2022-01-06 19:04:35 +00:00
Russell Cohen 0592a1bad4
Fix IMDS bug where the profile was cached (#1046)
* Fix IMDS bug where the profile was cached

* Update changelog

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-01-06 11:19:30 -06:00
Zelda Hessler df150737a3
remove: telephone-game example (#1043)
update: CHANGELOG.next.toml
2022-01-06 15:57:14 +00:00
Russell Cohen a77c5ca2a9
Add support for Paginators (#1006)
* Add Support for Paginators

This commit adds pagination support for both clients. It does this via the `FnStream` abstraction which combines a rendezvous-channel with a closure to produce a stream. When the stream is polled, the underlying closure is polled to advance the computation which then pushes data into the channel.

Two paginators are generated:
1. `.paginate()` which produces a stream of `Result<Page, Err>`
2. `.paginate().items()` which produces a stream of `Result<Item, Err>` where items are flattened from the individual pages. This uses `TryFlatMap` to support conveniently generating a flat page iterator.

In addition, docs are generated to point customers towards the paginators.

* Add RFC, more tests

* backout unrelated changes

* Fix paginators for glacier

* Fix clippy error

* Add test for paginators that point to maps & fix apigateway paginator

* Fix docs

* remove extraeneous println

* Fix DynamoDB examples

* Disallow paginating operations with the idempotency token trait

* Apply suggestions from code review

misc typos / cleanups

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

* CR feedback

* Fix typo

* Update changelog

* Apply suggestions from code review

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

* CR feedback round 1

* Rename paginate to into_paginator()

* update pr bot comment

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-01-05 17:46:57 +00:00
Kyle Thomson 36faba8ee6
add: function that exposes profile names (#1021)
* add: function that exposes profile names

* code style

* formatting

* changelog
2021-12-30 23:24:59 +00:00
Zelda Hessler 4dc75bb21c
fix: in generated docs, convert bare anchor tags to pre (#1019)
* fix: in generated docs, convert bare anchor tags to pre

* update: CHANGELOG.next.toml

* update: use html transformation instead of regex find/replace

* Update codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustWriter.kt
2021-12-30 15:38:10 -06:00
Russell Cohen 40cab68886
Aws config feature simplification (#1017)
* Massively simplify features in aws-config

* Update example

* Update changelog

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2021-12-30 18:41:10 +00:00
Jacco Kulman 9708aa8307
Clone-able structs (#985)
* Clone-able structs

* Change log entry

* Update CHANGELOG.next.toml

Co-authored-by: Russell Cohen <russell.r.cohen@gmail.com>

* Added two Clone directives and integration test

Co-authored-by: Russell Cohen <russell.r.cohen@gmail.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-12-30 11:15:01 -05:00
Jacco Kulman 1992bf3fa6
Examples for Config builder region function (#1008)
* region function documented

* Example changelogs back

* Solve doc error

* text fixes (still fails)

* added back changelog items accidently removed

* refactor and fix test

* fix test

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-12-30 15:02:09 +00:00
Zelda Hessler d9ffac3c96
update: don't generate useless Into<impl T> (#1010)
* update: don't generate useless Into<impl T>

* update: changelog

* remove: unnecessary into

* update: use helper fns to generate shared code

* refactor: simplify type-to-argument converter and make it act on all RustTypes
update: fixes predating this PR
2021-12-29 16:57:19 -05:00
Russell Cohen cbd61ab1ff
Add recursion detection middleware to the default middleware stack (#1003)
* Add recursion detection middleware to the default middleware stack

Side refactorings:
- move AWS retry logic into its own module
- small update to protocol test to make it a little easier to use

* fixups

* Fix clippy

* Add more tests and comments
2021-12-27 18:04:10 +00:00
Russell Cohen e9bd850d1a
Add Clone derive to aws_types::Config (#1002)
* Add Clone derive to aws_types::Config

* changelog

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2021-12-23 15:03:26 -05:00
Russell Cohen e559e4cf59
Add Route53 Hosted Zone Trimming (#999)
* Add Route53 Hosted Zone Trimming

Route53 requires a customization where `/hostedzone/` is stripped from hosted zone arguments when round-tripped. This adds a trait and customization to the route53 model to trim hosted zone prefixes.

* Add missing copyright header

* Also allow no leading slash

* Add route53 to smoke test because it has unit tests

* Update changelog

* Add missing call to flush()

* Remove unused env_logger depedendency
2021-12-21 19:19:32 +00:00
Russell Cohen 898cc93d28
[fix] Sleep not passed to ECS provider (#998)
* [fix] Sleep not passed to ECS provider

When constructing an ECS credential provider, sleep_impl was not properly passed along from the provider config. This adds a test that asserts that retries will be made, and fixes the bug.

* Fix clippy lint

* Update changelog

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2021-12-21 13:36:40 -05:00
Russell Cohen 2e7ed94351
Fix numerous todos & attach them to issues (#973)
* Fix numerous todos & attach them to issues

* Update changelog

* remove unused import in sigv4
2021-12-16 16:27:47 +00:00
John DiSanti 6325c8a277
Move additional-ci step into SDK smoke test (#961)
* Move additional-ci step into SDK smoke test

* Add `cargo hack` test to `aws-config` and make it pass

* Fix warning introduced by merge

* Incorporate feedback

* Fix native-tls example
2021-12-15 18:40:51 -08:00
Russell Cohen 35ac555e0f
Release v0.33.1 (#980)
* Bump version

* Changelogs
2021-12-15 12:46:07 -05:00
Russell Cohen cf2034f9cf
Smithy Client cannot be an optional dependency (#979)
* Smithy Client cannot be an optional dependency

* Update changelogs
2021-12-15 16:57:46 +00:00
John DiSanti d5750d48af
Include non-service-specific examples in the generated workspace (#957)
* Include non-service-specific examples in the generated workspace

* Update changelog

* Fix missing dependency for compilation

* Fix typo in Kinesis example
2021-12-15 00:58:16 +00:00
Russell Cohen b9d5923ab3
Release 0.3.0 / 0.33.0 (#974)
* Fixup changelog generation

* Delete superceded changlog guidance

* Update changelogs

* Bump version numbers
2021-12-14 16:43:17 -05:00
Zelda Hessler e63b827ada
Fix query string signing bug (#965)
* update: use shared encoder definition when encoding url paths, query strings
add: query string writer test
add: changelog entry for bugfix

* format: test file

* fix: integration test
add: ", ^, `, \, (space), {, }, and | to list of chars to percent encode

* add: tracing and tracing-subscriber dep to generated integration tests

* add: canonical req query param test
remove: obsolete LABEL_SET ascii set

* fix: outdated aws-hyper import
2021-12-14 10:12:45 -06:00
Russell Cohen 6e16e2ba82
remove aws-hyper (#959)
* Replace generated code references to AwsMiddleware from hyper with inline dependency

* remove usages of aws-hyper

* RIP aws-hyper

* rename AwsMiddleware to default Middleware

* Delete unused aws-hyper deps

* Update changelog

* Update RFC

* Add deprecation note to aws-hyper
2021-12-13 13:07:10 -05:00
Zelda Hessler 979c703424
add: example showing how to use native-tls (#946)
* add: native-tls example and test
update: aws-config to correctly separate the native-tls and rustls features for its dependencies
fix: native-tls feature gate typo
update: prefix unused id field with an underscore

* update: CHANGELOG.next.toml

* remove: unnecessary aws-sdk-sts feature deps from aws-config

* remove: obsolete dep features
2021-12-09 21:23:51 +00:00
Zelda Hessler 953c774c81
Update CHANGELOG.next.toml (#955) 2021-12-09 17:13:51 +00:00
Russell Cohen fe0b125dd7
Fix label & query URI encoding (#953)
* Fix label & query URI encoding

https://github.com/awslabs/aws-sdk-rust/issues/331 demonstrated that we were failing to properly encode characters for URI path components and query components in several situation. This:
- Fixes the specific bugs
- Adds proptests (run locally with 16K cases) to verify that this is the complete set.
- Adds an S3-specific protocol test that targets this issue

* Make the test a bit stronger

* Update changelog
2021-12-09 11:57:05 -05:00
Russell Cohen cb67d8004b
Cleanup AWS Hyper Features (#947)
* Cleanup features from aws-hyper

* Update codegen

* Update changelog

* Fix examples

* Update CHANGELOG.next.toml

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

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2021-12-08 17:10:05 -05:00
Zelda Hessler b5f53bed35
remove: default features from runtime crates (#935)
* remove: default features from runtime crates
update: tests and examples broken by default feature change
update: code generation broken by default feature change
fix: follow lint suggestion to lowercase variable names

* update: CHANGELOG.next.toml

* fix: add missing feature
fix: typo
formatting: sort imports

* update: make SDK changelog less worrying for SDK users not depending on a runtime crate
update: undo default feature change for SDK
fix: tests broken by default feature change
fix: examples broken by default feature change

* remove: empty defaults
add: doc w/ feature grid to aws-smithy-client
add: doc w/ feature grid to aws-smithy-http

* add: upgrade helper table to changelog
undo: bad formatting
formatting: add backticks to feature names in doc table

* remove: bytestream-util feature usage where possible
formatting: update CHANGELOG.next.toml

* remove: the client feature from generated SDKs
rename: feature "bytestream-util" to "rt-tokio"
update: mark "tower" dep as non-optional in SDKs
docs: update aws-smithy-http docs and README.md

* Update CHANGELOG.next.toml

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

* Update rust-runtime/aws-smithy-http/README.md

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

* revert: aws-sigv4 changes
update: CHANGELOG.next.toml
remove: rt-tokio dep feature for aws-smithy-async usage in aws-types

* fix: don't gate entire byte_stream module on rt-tokio feature
fix: typos

* remove: rt-tokio feature from SDKs generated with EventStreamSymbolProvider.kt
fix: incorrect doc comment

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2021-12-08 16:57:12 +00:00
Russell Cohen 4073ebab5c
Fix several bugs associated with retry/sleep (#940)
* Fix several bugs associated with retry/sleep

The sleep implementation was late-bound but early loaded in retry which created a large surface area for bugs & meant that we emitted a lot of spurious warnings. This commit:
- Removes more kruft from aws-hyper and deals with the consequences
- Cleans up the way that HTTP clients are generated
- Passes in sleep to each incarnation of the retry controller to work around issues caused by late-binding vs. early binding sleep.

* first round of cleanups

* delete unused import

* Update integration tests

* Fix examples

* Fix aws-smithy-client docs

* Clippy fix

* fix flaky test

* Fix  which relies on tokio/io
2021-12-08 11:29:25 -05:00
John DiSanti 3bf906fe09
Improve log messaging around missing sleep implementation (#907)
* Improve missing sleep warning

* Update changelog

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-12-07 13:43:52 -08:00
Russell Cohen 8136ba4a01
Use provided sleep_impl in aws-smithy-client::retry (#923)
* Use provided sleep_impl in aws-smithy-client::retry

Previously, aws_smithy_client was hard coded to use tokio::sleep. This change:
- threads the sleep implementation into the retry controller
- moves the integration test out of aws-hyper and into aws-smithy-client
- takes a first pass at fixing the cargo featres (cargo hack --feature-powerset passes now)

* cleanups

* several test fixups

* Use tristate to conditionally log

* Update changelog
2021-12-06 16:49:13 +00:00
Russell Cohen d4bc9d60b0
Changelog Automation (#922)
* Automate changelog update process

* Update PR template

* Update references

* Cleanups and comments
2021-12-03 11:47:52 -08:00