-
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.
Closes #300
- Loading branch information
Showing
9 changed files
with
176 additions
and
6 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
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
42 changes: 42 additions & 0 deletions
42
smithy-model/src/main/java/software/amazon/smithy/model/traits/NoReplaceTrait.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,42 @@ | ||
/* | ||
* Copyright 2020 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.model.traits; | ||
|
||
import software.amazon.smithy.model.SourceLocation; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
|
||
/** | ||
* Indicates that the put lifecycle operation of a resource | ||
* can only be used to create a resource and cannot replace | ||
* an existing resource. | ||
*/ | ||
public final class NoReplaceTrait extends BooleanTrait { | ||
public static final ShapeId ID = ShapeId.from("smithy.api#noReplace"); | ||
|
||
public NoReplaceTrait(SourceLocation sourceLocation) { | ||
super(ID, sourceLocation); | ||
} | ||
|
||
public NoReplaceTrait() { | ||
this(SourceLocation.NONE); | ||
} | ||
|
||
public static final class Provider extends BooleanTrait.Provider<NoReplaceTrait> { | ||
public Provider() { | ||
super(ID, NoReplaceTrait::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
1 change: 1 addition & 0 deletions
1
...test/resources/software/amazon/smithy/model/errorfiles/validators/no-replace-trait.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 @@ | ||
[ERROR] ns.foo#InvalidResource: Trait `noReplace` cannot be applied to `ns.foo#InvalidResource`. This trait may only be applied to shapes that match the following selector: resource:test(-[put]->) | TraitTarget |
38 changes: 38 additions & 0 deletions
38
...c/test/resources/software/amazon/smithy/model/errorfiles/validators/no-replace-trait.json
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,38 @@ | ||
{ | ||
"smithy": "0.5.0", | ||
"shapes": { | ||
"ns.foo#Service": { | ||
"type": "service", | ||
"version": "2019-06-27", | ||
"resources": [ | ||
{ | ||
"target": "ns.foo#ValidResource" | ||
}, | ||
{ | ||
"target": "ns.foo#InvalidResource" | ||
} | ||
] | ||
}, | ||
"ns.foo#ValidResource": { | ||
"type": "resource", | ||
"put": { | ||
"target": "ns.foo#PutValidResource" | ||
}, | ||
"traits": { | ||
"smithy.api#noReplace": true | ||
} | ||
}, | ||
"ns.foo#PutValidResource": { | ||
"type": "operation", | ||
"traits": { | ||
"smithy.api#idempotent": true | ||
} | ||
}, | ||
"ns.foo#InvalidResource": { | ||
"type": "resource", | ||
"traits": { | ||
"smithy.api#noReplace": true | ||
} | ||
} | ||
} | ||
} |