Commit Graph

1143 Commits

Author SHA1 Message Date
John DiSanti a550efbfff
Split JsonSerializerGenerator into its own file (#406) 2021-05-21 22:23:46 +00:00
John DiSanti 02c52b943b
Fix generated service docs (#404)
Fixes #375
2021-05-21 16:59:19 +00:00
Russell Cohen fe711eee1f
Support signing requests to S3 (#399)
* Support signing requests to S3

* Refactor to include support for signing streaming bodies (tested)

* Update stale comments

* Remove left-over `dbg!` invocation
2021-05-21 16:05:07 +00:00
Russell Cohen 84c258658f
Fix support of primitive headers with a default (#402) 2021-05-21 11:49:10 -04:00
Russell Cohen 2dc9da06b2
Add "S3 preview" service + codegen updates (#398)
This diff adds the S3 model & fixes compilation / clippy related codegen issues. I altered the SDK ID to be "S3 Preview". This means that all the generated code includes
"preview" because until a number of other fixes land, requests to S3 won't actually work.
2021-05-20 19:56:56 +00:00
John DiSanti d0eafbcf2e
Add request/response traces (#397)
* Add request/response traces

* Fix clippy lint
2021-05-20 12:19:26 -07:00
Russell Cohen 8b539938d2
restXML Protocol Serializers (#394)
* restXML Protocol tests passing

* Fix bug in namespace priority resolution

* Fix unit test

* CR feedback

* Fix handwritten serializer test

* Fix the test, take 2

* Update codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/parsers/XmlBindingTraitSerializerGenerator.kt

fix typo

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

Co-authored-by: John DiSanti <johndisanti@gmail.com>
2021-05-19 21:28:22 +00:00
Russell Cohen 392463d022
Add more XML protocol tests (#382)
* Add more XML protocol tests

* Update rest-xml-extras.smithy

* Update rest-xml-unwrapped-errors.smithy
2021-05-19 18:40:54 +00:00
John DiSanti 0e5828828d
Add SSM model and Get/PutParameter examples (#393)
* Add SSM model

* Add SSM PutParameter example

* Fix clippy errors on SSM generated code

* CR feedback

* Fix rustfmt
2021-05-19 09:55:29 -07:00
John DiSanti 9e05d1f0d0
Escape enum variants to avoid collision with generated Unknown variant (#388)
* Escape enum variants to avoid collision with generated Unknown variant

* Output enum documentation with unknown variant renaming note

* CR feedback
2021-05-18 12:58:00 -07:00
Russell Cohen 3eb5381828
Remove TODOs that were actually done (#392) 2021-05-18 17:11:25 +00:00
Russell Cohen edb5808e28
Write XML Encoding Abstractions (#389)
* Write XML Encoding Abstractions

This commit creates an XML encode & escaping abstraction that allows "fearless code generation"
(invalid XML is a compile error).

* Rename TagWriter to ScopeWriter
2021-05-18 15:20:49 +00:00
Russell Cohen 1b5d32044c
Implement XML normalization for protocol-test-helpers (#381)
* Implement XML normalization for protocol-test-helpers

* Update comment

* Clippy appeasement
2021-05-17 23:54:49 +00:00
Declan Kelly e84f48af37
Derive Debug on all FluentBuilders (#377)
Add test and example code for Debug impl on fluent builders

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-05-17 23:30:01 +00:00
John DiSanti 1abb0180cd
Introduce syntax sugar for accessing Smithy shape traits (#385) 2021-05-17 19:16:29 -04:00
John DiSanti 743d3e89bc
Add comments and rename synthetic shape ID extension functions (#384)
* Rename shape ID extension functions for clarity

* Add more comments to fallible builder decider logic

* Fix ktlint
2021-05-17 16:35:50 -04:00
Russell Cohen 92b9afa79b
Add support for the AWS_REGION environment variable (#362)
* Add support for the AWS_REGION environment variable

* Delete unnecessary function

* Disable clippy lint, add link
2021-05-17 17:50:40 +00:00
Russell Cohen 71111ac2c1
Misc encoding fixes (#379)
Found several bugs while adding some more protocol tests:
- whitespace characters were not properly handled by `dq()/doubleQuote()`. I found a proper implementation in Smithy I should have been using all along.
- I erred at some point when I used a Vim macro to setup the new percent encoder. This is been resolved & a test has been added
2021-05-17 12:37:09 +00:00
Richard H Boyd 3267c9b5a5
Added documentation to the invoke Lambda example (#376)
* document Lambda Invoke Example

* Update aws/sdk/examples/lambda-invoke-function/src/main.rs

Co-authored-by: Russell Cohen <russell.r.cohen@gmail.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-05-17 00:41:07 +00:00
Russell Cohen 15e21af3ff
Protocol unification & Add Rest XML deserialization support (#369)
* Refactor HttpBinding protocol

* Update XmlBindingTraitParserGenerator to fix new protocol tests

* Clear all warnings

* Major overhaul of Http Trait based protocols

* Remove pointless wrapping

* Nullable types fall through

* Cleanup JsonParserGenerator, refactor

* More Json parser generator cleanups

* Update test

* Fix unit test

* [cleanup] Move interfaces to their own files

* Use parser / serializer generators from AwsJson
2021-05-14 22:23:02 +00:00
Russell Cohen 47702e45b4
Gracefully handle alternate error message fields (#374)
Errors returned by AWS services may be stored at `Message`, `message` or `errorMessage`. This updates the relevant code to search all three locations when surfacing a clean error message to the customer. This diff also fixes a long-standing shortcoming of SdkError where it failed to provide a clean Display implementation.
2021-05-13 15:20:12 +00:00
Richard H Boyd 0654743567
add Lambda service model (#361)
* add Lambda service model

* Cleanup example

* Format

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-05-13 14:45:01 +00:00
Russell Cohen ee72a84dbb
New signer api (#341)
* Update signing API

Updates signing to the new API which accepts borrowed credentials. This ensures that credentials aren't copied unnecessarily which improves both security and performance.

* Roll back changes to user agent

* Remove local dependency, code is landed upstream

* Switch back to crates.io dependency

* Use double encoding

* Appease clippy
2021-05-13 09:50:27 -04:00
Russell Cohen ac05ffd822
Serialize Sets with Vecs (#270)
* Remove non-determinism and use Vecs always instead of Sets

* Remove special casing for sets
2021-05-12 19:48:44 +00:00
Russell Cohen c62afebd50
Redo url encoding (#368)
* Redo URL encoding to cover all cases

* Fix test that missed a couple of encodings

* Should have been escaping !
2021-05-12 17:45:20 +00:00
Russell Cohen 42c1f215a5
Http Protocol Refactor & Streaming Request bodies (breaking change) (#359)
* Refactor HttpProtocolGenerator body construction

* Well that was easy... (add streaming input support)

* Fix tests, clippy warning

* One more clippy wrap ignore

* Fix test that used private API

* Add test for default value
2021-05-12 00:04:29 +00:00
Russell Cohen 99693db02b
Update ci.yaml (#365)
* Update ci.yaml

Change CI to `pull_request` so that forks will also build PRs

* Update ci.yaml

all tags, pull requests
2021-05-11 18:07:55 -04:00
Russell Cohen afee2a662a
Support primitive ints in status bindings (#367) 2021-05-11 15:34:39 -04:00
Russell Cohen 6df93e093d
Parser Generator for XmlBindingTraits (#354)
* Parser Generator for XmlBindingTraits

This diff adds two components:
- `smithy-xml`: A scoped-reader XML abstraction on top of `xmlparser`
- `XmlBindingTraitParserGenerator`: A code generator for deserializing data targetted with the XmlBinding traits

This is not currently used outside of the tests, but this implementation passes all protocol tests expect for escaping (wiring is still WIP).

This commit also adds two inlinable abstractions for error parsing which can be swapped in at code generation time based on the service traits.

* Cleanup XmlError

* Add support for unescaping XML

* Back out changes to testutil

* Rename currentTarget to accum

* CR feedback

* Remove duplicate copyright & fix doc compilation

* CR feedback
2021-05-10 19:39:06 +00:00
Russell Cohen 72a5c5b3e8
Add initial set of docs (#313)
* Add initial set of docs

* More design documentation updates

* Updates to the docs

* Update tenets again to remove the dependeny tenet

* Remove `!`

* Add more design documentation

* More updates to tenets

* More tenets updates

* tenets typo

* Rephrase as 'AWS SDK for Rust'

* rephrase tenets
2021-05-06 22:59:12 +00:00
Russell Cohen 726747575a
Misc bug fixes discovered during restXML (#353)
- Support recursive inline dependencies & iterate to a fixed point properly
- Fix unit test function naming
- Record orginal id in synthetic inputs & outputs
- Instantiate recursive unions properly
2021-05-06 18:45:56 -04:00
Shing Lyu 4b16e27c75
Integration test for qldbsession request signing (#350)
* fix: typo in qldbsession example

* feat: test harness for QLDB signv4 service name

* fix: typo in qldbsession example

* feat: test harness for QLDB signv4 service name

* feat: integration test for qldbsession signing

* fix: request protocol version

* fix: test request protocol version

* fix: overwrite the user agent for test

Co-authored-by: Shing Lyu <shinglyu@amazon.nl>
2021-05-05 08:55:02 -04:00
Russell Cohen 7955da2e44
Add support for Streaming Response Bodies (#338)
* Assert field-by-field equality in protocol tests

Protocol tests currently use `PartialEq`, but when we add streaming members, we can no longer compare equality synchronously & without
side effects. This diff removes `PartialEq` from output shapes (we may re add it later for non-streaming shapes) & instead asserts equality of each output member in turn.

* Cleaner version of body streaming, still some work to get it to work with tests

* Finalize protocol test support

* Add default to the operation parsers

* Add helper for isStreaming on member shapes

* Cleanups & add test

* allow upper case keys in rustTemplate
2021-05-03 15:01:28 +00:00
Russell Cohen d4bf8e6e2a
Update rustfmt hook to run on all files (#348)
* Update rustfmt hook to run on all files

* Add missing --check
2021-04-30 17:33:20 -04:00
Russell Cohen 0bef36c603
Smithy 1.7 upgrade (#340)
* Upgrade to Smithy 1.7

Two changes:
1. Add support for shape renaming. Since renaming doesn't apply to operations, errors, or resources, this was actually a fairly narrow change. I intentionally
maintained the ability to generate a model without a service shape, I expect at some point, some one will just want to make some Rust structs.
2. Add support for map-driven query params.

* Update APIGW model

* Fix bugs in httpParams implementation

* Cleanup logic and add one more test
2021-04-29 17:55:19 -04:00
Russell Cohen c36afd610e
Fix StackOverflow in SdkBody Debug (#343)
* Fix StackOverflow in SdkBody Debug

An incorrect debug implementation lead to infinite recursion when printing `SdkBody` with the debug formatter

* CR Feedback
2021-04-29 15:26:39 +00:00
Doug d6e82f5f7e
Added Kinesis code examples (#306)
* Added Kinesis code examples

* Cleanup region handling

* Update Cargo.toml

* Update Cargo.toml for new crate names

* Updated Kinesis DeleteStream code example

* Updated Kinesis code examples after running clippy

* Updated Kinesis code examples with latest changes

* Updated Kinesis DescribeStream example.

* Update aws/sdk/examples/kinesis-put-record/src/main.rs

* Update aws/sdk/examples/kinesis-put-record/Cargo.toml

* Update aws/sdk/examples/kinesis-put-record/src/main.rs

Co-authored-by: Russell Cohen <russell.r.cohen@gmail.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-04-28 19:30:38 +00:00
Russell Cohen 409b6b9963
Assert field-by-field equality in protocol tests (#337)
Protocol tests currently use `PartialEq`, but when we add streaming members, we can no longer compare equality synchronously & without
side effects. This diff removes `PartialEq` from output shapes (we may re add it later for non-streaming shapes) & instead asserts equality of each output member in turn.
2021-04-28 13:11:13 +00:00
Russell Cohen 1d00f381d3
Protocol Test Updates (#336)
* Update procotol test generator to use the external parsing API
2021-04-27 11:21:17 -07:00
Doug 81a1ab6e3f
Doug dynamodb examples (#296)
* Added DynamoDB PutItem code example

* Added DynamoDB CreateTable, PutItem, and DeleteItem code examples

* Added DynamoDB ListTables, ListItems, and DeleteTable code examples

* Updated DynamoDB CreateTable code example

* Updated DynamoDB code examples after running clippy

* Updated DynamoDB code examples with latest changes

* Updated DynamoDB code examples

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-04-27 17:40:46 +00:00
Russell Cohen 265d414c90
Refactor Operation Code generation (#335)
* Refactor Operation Code generation

This all started when I wanted to the public API in my protocol tests but couldn't because it depended on the input. So began
a large sequence of refactoring that overall lead to major improvements.

1. `Operation` no longer carries an input around. This was originally done to support paginators, but we'll handle that differently later.
2. `Builders` are now uniform—no more special builders for operation shapes.
3. Idempotency token insertion is now handled during operation construction instead of during builder construction. This removes
a ton of special casing from various parts of the code base.
4. Protocol tests now use the public traits. This will enable us to generate protocol tests for streaming inputs without any
special casing.

This wasn't done originally because the main API was the low-level API and I didn't want `.build().make_operation()`. But now
that this is only an escape hatch, the double call isn't nearly as big of a deal.

* Delete unused variable

* Update other tests that used the LL API
2021-04-27 16:18:44 +00:00
Russell Cohen bc342293a1
Add ByteStream abstraction (#333)
* Add ByteStream abstraction

Introduce `ByteStream`, a wrapper around SdkBody to provide easy-to-use abstractions around streaming binary data.

* Updates for CR feedback
- `data` is renamed to `collect`
- Added `into_inner` so that you can use it as a body directly if desired
- Removed unecessary impl for io::Error
- Added `From<SdkBody> for ByteStream
- Project to remove need for `Unpin` in `Inner`
- Forward relevant method in `Buf` implementation
- Use `try_next` in example

* Fix missed `data -> Collect`

* Show don't tell in examples
2021-04-26 14:47:40 +00:00
Russell Cohen 849f849bab
Filter out EventStream operations from the model (#322) 2021-04-26 14:21:59 +00:00
Shing Lyu b7821e233a
Make `<servicename>::Client` `Clone + Debug` (#330)
* failed: add Debug trait to Client

* fix: KTLint fixes

* feat: derive Clone for Client

* feat: custom impl Debug for Config

* fix: revert the Debug derives inside Config

* doc: add comment explain why we do custom impl Debug for Config

Co-authored-by: Shing Lyu <shinglyu@amazon.nl>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-04-26 09:49:56 +00:00
Shing Lyu 521a201e6a
docs: update JDK version requirement (#329)
* docs: update JDK version requirement

* fix: stick with JDK 11

Co-authored-by: Shing Lyu <shinglyu@amazon.nl>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-04-26 09:30:12 +00:00
Marc Bowes a7bba453cc
Add qldb, qldbsession and small examples (#324)
* Add qldb, qldbsession and small examples

'Qldb' is an AWS database service. There are two webservices: qldb and
qldbsession. The former has APIs like Create, List and DeleteLedger. The
later is the dataplane API (like connecting to MySQL or Postgres).

QldbSession really has only 1 API, called "send command". A command is
something like "start a session", or "here is some sql".

The 'QldbSession' example isn't very useful, as customers would never
actually use the underlying API. Rather, they would use something like
the driver: https://github.com/awslabs/amazon-qldb-driver-rust.

The 'Qldb' is a simple list-ledgers example, similar to what's found for
other services.

* Update aws/sdk/examples/qldb-list-ledgers/src/main.rs

Co-authored-by: Marc Bowes <bowes@amazon.com>
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2021-04-23 16:27:18 -04:00
Russell Cohen aaaf97e9bd
Sdkbody redux (#327)
* Use SdkBody instead of hyper::Body

As part of the path to supporting streaming request & response bodies, we need to remove the need to have a generic request/response body. This commit hides hyper::Body inside of SdkBody & also introduces a dynamic alternative to enable supporting any HTTP Body implementation.

* Delete ResponseBody & Update usages

Now that SDK body has a visible "Bytes" variant, ResponseBody is no longer needed as a bridge to expose debug information about responses.

* Rename _cx => cx
2021-04-22 19:46:03 -04:00
Russell Cohen 25ea4a9770
Fix SigningRegion override Bug (#326)
This diff fixes a bug where the default AWS endpoint resolver was erroneously overriding the signing service with the name of the service, even when a signing service override was present in the models.
2021-04-22 21:10:44 +00:00
Russell Cohen f2b3442103
Update README.md 2021-04-22 16:02:22 -04:00
Russell Cohen e698ceae2e
Send Poll::Ready(None) on empty body (#325)
When used over H/2, sending an empty data frame for a GET can trigger some problematic behavior in Hyper. Hyper should probably handle this, but this ensures that we will
not hit this behavior.

When sending data to API Gateway services, we are getting GOAWAY because this causes to send duplicate empty data frames.
2021-04-22 15:33:13 -04:00