-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the `aws.protocols#awsQueryCompatible` trait which allows backward compatibility when migrating from awsQuery to awsJson1_0.
- Loading branch information
1 parent
4504cd0
commit 31ed5a3
Showing
11 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
smithy-aws-protocol-tests/model/awsJson1_0WithQueryCompatible/errors.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
$version: "2.0" | ||
|
||
namespace aws.protocoltests.json10 | ||
|
||
use aws.protocols#awsJson1_0 | ||
use aws.protocols#awsQueryError | ||
use smithy.test#httpRequestTests | ||
use smithy.test#httpResponseTests | ||
|
||
@idempotent | ||
operation GreetingWithError { | ||
input: GreetingWithErrorInput, | ||
output: GreetingWithErrorOutput, | ||
errors: [InvalidGreetingError] | ||
} | ||
|
||
@input | ||
structure GreetingWithErrorInput { | ||
greeting: String, | ||
} | ||
|
||
@output | ||
structure GreetingWithErrorOutput { | ||
greeting: String, | ||
} | ||
|
||
@awsQueryError( | ||
code: "CustomGreetingErrorCode", | ||
httpResponseCode: 402 | ||
) | ||
@error("client") | ||
structure InvalidGreetingError { | ||
Message: String, | ||
} | ||
|
||
apply InvalidGreeting @httpResponseTests([ | ||
{ | ||
id: "Json10WithQueryCompatibleGreetingError", | ||
documentation: "@awsQueryCompatible trait is applied to service", | ||
protocol: awsJson1_0, | ||
params: { | ||
Message: "Hi" | ||
}, | ||
code: 402, | ||
headers: { | ||
"Content-Type": "application/x-amz-json-1.0", | ||
"x-amzn-query-error": "CustomGreetingErrorCode;Sender" | ||
}, | ||
bodyMediaType: "application/json", | ||
body: "{\"__type\": \"InvalidGreetingError\",\"Message\": \"Hi\"}", | ||
appliesTo: "client" | ||
}, | ||
]) |
18 changes: 18 additions & 0 deletions
18
smithy-aws-protocol-tests/model/awsJson1_0WithQueryCompatible/main.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$version: "2.0" | ||
|
||
namespace aws.protocoltests.json10 | ||
|
||
use aws.api#service | ||
use aws.protocols#awsJson1_0 | ||
use aws.protocols#awsQueryCompatible | ||
use smithy.test#httpRequestTests | ||
use smithy.test#httpResponseTests | ||
|
||
|
||
@service(sdkId: "JSON RPC 10 with Query Compatible Trait") | ||
@awsQueryCompatible | ||
@awsJson1_0 | ||
service JsonRpc10WithQueryCompatible { | ||
version: "2020-07-14", | ||
operations: [GreetingWithErrors] | ||
} |
40 changes: 40 additions & 0 deletions
40
...ts/src/main/java/software/amazon/smithy/aws/traits/protocols/AwsQueryCompatibleTrait.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.aws.traits.protocols; | ||
|
||
import software.amazon.smithy.model.node.Node; | ||
import software.amazon.smithy.model.node.ObjectNode; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
import software.amazon.smithy.model.traits.AnnotationTrait; | ||
|
||
public final class AwsQueryCompatibleTrait extends AnnotationTrait { | ||
|
||
public static final ShapeId ID = ShapeId.from("aws.protocols#awsQueryCompatible"); | ||
|
||
public AwsQueryCompatibleTrait(ObjectNode node) { | ||
super(ID, node); | ||
} | ||
|
||
public AwsQueryCompatibleTrait() { | ||
this(Node.objectNode()); | ||
} | ||
|
||
public static final class Provider extends AnnotationTrait.Provider<AwsQueryCompatibleTrait> { | ||
public Provider() { | ||
super(ID, AwsQueryCompatibleTrait::new); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
23 changes: 23 additions & 0 deletions
23
...c/test/resources/software/amazon/smithy/aws/traits/errorfiles/aws-query-compatible.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
use aws.protocols#awsQueryCompatible | ||
use aws.protocols#awsQueryError | ||
use aws.protocols#awsJson1_0 | ||
|
||
@awsQueryCompatible | ||
@awsJson1_0 | ||
service MyService { | ||
version: "2020-02-05", | ||
errors: [InvalidThingException] | ||
} | ||
|
||
@awsQueryError( | ||
code: "InvalidThing", | ||
httpResponseCode: 400, | ||
) | ||
@error("client") | ||
structure InvalidThingException { | ||
message: String | ||
} |
2 changes: 2 additions & 0 deletions
2
...aws/traits/errorfiles/protocols/aws-query-compatible-does-not-support-non-aws-json.errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[WARNING] smithy.example#MyService: This shape applies a trait that is deprecated: aws.protocols#awsQuery | DeprecatedTrait | ||
[ERROR] smithy.example#MyService: Trait `aws.protocols#awsQueryCompatible` cannot be applied to `smithy.example#MyService`. This trait may only be applied to shapes that match the following selector: service [trait|aws.protocols#awsJson1_0] | TraitTarget |
24 changes: 24 additions & 0 deletions
24
...aws/traits/errorfiles/protocols/aws-query-compatible-does-not-support-non-aws-json.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
use aws.protocols#awsQueryCompatible | ||
use aws.protocols#awsQueryError | ||
use aws.protocols#awsQuery | ||
|
||
@awsQueryCompatible | ||
@awsQuery | ||
@xmlNamespace(uri: "https://example.com") | ||
service MyService { | ||
version: "2020-02-05", | ||
errors: [InvalidThingException] | ||
} | ||
|
||
@awsQueryError( | ||
code: "InvalidThing", | ||
httpResponseCode: 400, | ||
) | ||
@error("client") | ||
structure InvalidThingException { | ||
message: String | ||
} |