Commit Graph

1143 Commits

Author SHA1 Message Date
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
Harry Barber d953a4466f
Add Server section to the Book (#1813)
* Move docs to server folder

* Index the Server folder

* Fix markdown lints

* Add basic overview.md to server folder
2022-10-05 17:10:43 +00:00
david-perez 4ba6063f25
Move all binaries in the Pokémon service example under `src/bin` (#1788)
We're currently being inconsistent in that only the TLS example is under
`src/bin`, but the other two are under `src/`.
2022-10-05 11:49:06 +00:00
John DiSanti 6322569ea7
Add GitHub Action to update `aws-sdk-rust/next` branch (#1774) 2022-10-04 23:14:35 +00:00
John DiSanti 38c32b792e
Update tool dependencies (#1808) 2022-10-04 11:09:19 -07: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
david-perez 39c0096c33
Remove unnecessary call to upgrade to a server protocol for `ServerServiceGeneratorV2` (#1805)
The protocol `ServerServiceGenerator` hosts is already typed as a
`ServerProtocol`.
2022-10-03 16:19:56 +00:00
Burak 7fb7e177d0
Simplify Python Pokemon service (#1773)
* Simplify Python Pokemon service

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

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

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

* Add comment about synchronization of `Context` class

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-10-03 15:03:17 +01:00
Matteo Bigoi 89a6e5894a
Add LukeMathWalker and jjant to the contributor list (#1791) 2022-09-30 17:40:31 +00:00
Luca Palmieri aea63544e1
Update MSRV policy state in the README (#1790)
* Update MSRV policy state in the README

* Beautify
2022-09-30 16:50:42 +01:00
Luca Palmieri 368e13f23d
Amend the example of generated code in the design docs to match current behaviour (#1789)
* Amend the example of generated code in the design docs to match current behaviour.

* A few more capitalization issues.
2022-09-30 12:44:13 +00:00
Luca Palmieri 4c5cbc3938
Fix a few rendering issues in the design docs (#1787)
* Fix backtick fences to render code block

* Render list as a list instead of a code block.

* Indent further to get nested code block.

* Remove `ignore` descriptors.
2022-09-30 12:30:47 +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 49cc08da22
Move core tests from `codegen-client` into `codegen-core` (#1776)
* Move `testutil` into `core` where possible
* Move `rustlang` tests into `core`
* Move remaining `util` tests to `core`
* Move and refactor `TopLevelErrorGeneratorTest` to not require `RustCodegenPlugin`
* Move protocols into `core`
* Move `generator` tests into `core`
* Move protocol ser/de tests into `core`
* Suppress deprecation warning in `TopLevelErrorGeneratorTest`
* Move `InlineFunctionNamerTest` into `core`
* Move model transform tests into `core`
* Rename `SymbolBuilderTest` to `SymbolVisitorTest` to match class under test
* Move server classes out of client
* Move core codegen tests into their own CI step
2022-09-28 17:46:28 +00:00
Harry Barber dcfb85578e
Add Instrumentation documentation (#1772)
* Add documentation covering instrumentation approaches for Smithy Rust.

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

* Update [Logging in the Presence of Sensitive Data](https://github.com/awslabs/smithy-rs/pull/1536) checklist.
* Rename `logging` module to `instrumentation` to improve coherence across struct names and documentation.
2022-09-28 12:57:48 +01:00
John DiSanti 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
david-perez 5b7aa7b803
Move more things into `codegen-core` (#1762)
This moves most things from `codegen-client` that should be in
`codegen-core` into `codegen-core`.

This is a continuation of the efforts started in #1697, #1730.
2022-09-27 14:33:50 +02:00
82marbag 911f2817b7
Docs: generation of Pokemon service (#1652)
* Docs: generation of Pokemon service

This is an overview of the Pokémon service. It describes:
* How a smithy-rs customer uses the vanilla SDK and writes their business logic
* What the runtime is and how code is generated
* The folder structure of the project

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-27 08:11:08 +00:00
John DiSanti 8e0b440437
Improve timeout config ergonomics and add SDK default timeouts (#1740)
* Overhaul timeout configuration
* Improve resiliency re-exports
* Refactor Smithy client retry config handling in builder
* Remove non-standard timeout env vars and profile keys
* Break operation customization codegen into its own file
* Move operation customization into a submodule
* Improve operation customization re-exports
* Add integration tests for read and connect timeouts
* Fix connector timeout config in the Smithy `Client` builder
* Rename `HttpSettings` to `ConnectorSettings`
2022-09-27 01:15:23 +00:00
Harry Barber 42a84576ac
Vend tracing instrumentation as a Plugin (#1738)
* Add InstrumentLayer and InstrumentPlugin

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

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

* Fix `httpPrefixHeader` false positive.

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

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

* Remove reuse of @output

* Add full-stops

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

* Symlink pokemon operations

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-09-23 17:37:32 +00:00
david-perez 6eccf70145
Remove `RemoveEventStreamOperations` model transformer from `ServerCodegenVisitor` (#1764)
This is a holdover from when the server subproject was started. We've
never utilized this model transformer, nor will we have any use for it
now, since event stream operations are supported in the server since #1479.

See https://github.com/awslabs/smithy-rs/pull/1762#discussion_r978151466.
2022-09-23 17:03:30 +00:00
Matteo Bigoi e5c8cf3061
[Python] Allow to run pure Python request middlewares inside a Tower service (#1734)
## Motivation and Context
* Customers want to be able to implement simple middleware directly in Python. This PR aims to add the initial support for it.
* Improve the idiomatic experience of logging by exposing a handler compatible with Python's standard library `logging` module.

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

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

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

Example:

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

app = App()

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

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

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

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

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

import logging
from sdk.logging import TracingHandler

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

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: Burak <burakvar@amazon.co.uk>
2022-09-22 18:01:48 +00:00
82marbag 997beeb442
Update security disclosure instructions (#1758)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-22 17:05:45 +00:00
david-perez e76a8a0e1b
Refactor `redactIfNecessary` function (#1746)
It's useful to call `redactIfNecessary` on arbitrary shape types, not
only member shapes.

It is now an extension function on `Shape`, with a specialization on
`MemberShape`, since note that the `sensitive` trait cannot be applied
to member shapes [0, 1], so we traverse to its target directly.

Ultimately this is just to make the diff of #1342 lighter.

[0]: https://awslabs.github.io/smithy/1.0/spec/core/documentation-traits.html#sensitive-trait
[1]: https://awslabs.github.io/smithy/1.0/spec/core/documentation-traits.html#sensitive-trait
2022-09-22 16:12:35 +00:00
82marbag 43e3e29840
Expand protocol layouts (#1753)
Split runtime protocols layout

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-22 09:10:51 +00:00
Nicolas Farrier ff13b087fe
Run `cargo clippy` when building the Pokémon Service (#1742) 2022-09-21 11:26:02 +00:00
John DiSanti 81eb73212f
Add `@awslabs/smithy-rs-server` as owners to `codegen-core` (#1739) 2022-09-20 18:09:54 +00:00
AWS SDK Rust Bot 7b27f376cd Update changelog 2022-09-20 12:42:29 +00:00
david-perez 3952a10c44
Version bump smithy-rs (#1749) 2022-09-20 13:11:04 +02: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
82marbag 0313a3c7b8
Allow third-party devs to write custom plugins for service builders (#1736)
* Allow custom layers to every operation

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

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

Signed-off-by: Harry Barber <hlbarber@amazon.co.uk>
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Harry Barber <hlbarber@amazon.co.uk>
2022-09-16 08:53:54 +00:00
John DiSanti c52bb03e41
Update CODEOWNERS (#1737) 2022-09-15 09:13:37 -07:00
John DiSanti e171ce0274
Move most utils and synthetic traits into core (#1730)
- Moves most of the `util` package from `codegen-client` into `codegen-core`
- Moves the synthetic traits into `codegen-core`
- Consolidates duplicated `RustTypesTest` files
- Corrects `lang` -> `rustlang` package name in `codegen-client` tests
- Moves `letIf` from `SymbolVisitor` into its own file in `codegen-core`
2022-09-14 22:03:12 +00:00
John DiSanti e6177b3dc2
Fix native Smithy client retry and retry response errors (#1717)
* Fix retry for native Smithy clients
* Treat `SdkError::ResponseError` as a retryable transient failure
* Rename `ClassifyResponse` to `ClassifyRetry`
* Rename 'policy' to 'classifier' in AWS SDK public API
* Rename `AwsResponseClassifier` to `AwsResponseRetryClassifier`

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-09-14 20:36:17 +00:00
Eduardo de Moura Rodrigues 5335e27f15
chore: upgrade dokka gradle plugin (#1722) 2022-09-13 15:16:14 -07:00
Harry Barber dc8d4436cd
Move methods from Protocol to ServerProtocol (#1731) 2022-09-13 21:15:45 +00:00
82marbag f324240b27
Unsupported content type (#1723)
Add validation for the Content-Type header and pass (remove from the failing
list) the relevant protocol tests

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-09-13 18:18:34 +00:00
John DiSanti 2312843197
Add test to verify retry of 401s in IMDS client (#1729) 2022-09-13 10:31:30 -07:00
david-perez b4ac306fc2
Use Rust 2021 edition with `rustfmt` in CI (#1728)
We've long migrated to the 2021 edition everywhere. See PRs #1388, #1328,
and #1268.

See issue #1332 too.
2022-09-13 13:10:54 +02:00
Harry Barber fd94858db8
Add new service builder codegen (#1693)
* Add `ServerProtocol` interface to allow for server side protocol specific methods.

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

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

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

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

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

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

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

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

* Use new service builder in protocol tests.
2022-09-12 14:27:41 +01:00
John DiSanti 56f4be3207
Add customization to retry STS `IDPCommunicationErrorException` (#1718) 2022-09-09 17:25:43 -07:00
John DiSanti 054d9229ad
Create initial `.git-blame-ignore-revs` (#1726)
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-09-09 14:09:06 -07:00
Weihang Lo f27aa54650
Test `httpRequestTests` against actual Services (#1708)
* Make Instantiator generate default values for required field on demand

* Move looping over operations into ServerProtocolTestGenerator

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Add protocol test helper functions

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Add method param to construct http request

* Put request validation logic inside closure

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Make protocol test response instantiate with default values

* Add module meta for helper module

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Apply suggestions from code review

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

* Address most style suggestions

* add companion object for attribute #[allow(dead_code)]

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Use writable to make code readable

* recursively call `filldefaultValue`

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>

* Exercise with `OperationExtension`

* Temporary protocol tests fix for awslabs/smithy#1391

Missing `X-Amz-Target` in response header

* Add `X-Amz-Target` for common models

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Co-authored-by: david-perez <d@vidp.dev>
Co-authored-by: Harry Barber <hlbarber@amazon.co.uk>
2022-09-09 20:07:21 +00:00