-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding conditionKeyValue and conditionKeysResolvedByService traits #1677
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 29 additions & 0 deletions
29
...am-traits/src/main/java/software/amazon/smithy/aws/iam/traits/ConditionKeyValueTrait.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,29 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.aws.iam.traits; | ||
|
||
import software.amazon.smithy.model.FromSourceLocation; | ||
import software.amazon.smithy.model.SourceLocation; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
import software.amazon.smithy.model.traits.StringTrait; | ||
|
||
public final class ConditionKeyValueTrait extends StringTrait { | ||
public static final ShapeId ID = ShapeId.from("aws.iam#conditionKeyValue"); | ||
|
||
public ConditionKeyValueTrait(String conditionKey) { | ||
super(ID, conditionKey, SourceLocation.NONE); | ||
} | ||
|
||
public ConditionKeyValueTrait(String conditionKey, FromSourceLocation sourceLocation) { | ||
super(ID, conditionKey, sourceLocation); | ||
} | ||
|
||
public static final class Provider extends StringTrait.Provider<ConditionKeyValueTrait> { | ||
public Provider() { | ||
super(ID, ConditionKeyValueTrait::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
30 changes: 30 additions & 0 deletions
30
...rc/main/java/software/amazon/smithy/aws/iam/traits/ServiceResolvedConditionKeysTrait.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,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.aws.iam.traits; | ||
|
||
import java.util.List; | ||
import software.amazon.smithy.model.FromSourceLocation; | ||
import software.amazon.smithy.model.SourceLocation; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
import software.amazon.smithy.model.traits.StringListTrait; | ||
|
||
public final class ServiceResolvedConditionKeysTrait extends StringListTrait { | ||
public static final ShapeId ID = ShapeId.from("aws.iam#serviceResolvedConditionKeys"); | ||
|
||
public ServiceResolvedConditionKeysTrait(List<String> conditionKeys) { | ||
super(ID, conditionKeys, SourceLocation.NONE); | ||
} | ||
|
||
public ServiceResolvedConditionKeysTrait(List<String> conditionKeys, FromSourceLocation sourceLocation) { | ||
super(ID, conditionKeys, sourceLocation); | ||
} | ||
|
||
public static final class Provider extends StringListTrait.Provider<ServiceResolvedConditionKeysTrait> { | ||
public Provider() { | ||
super(ID, ServiceResolvedConditionKeysTrait::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
24 changes: 24 additions & 0 deletions
24
...raits/src/test/java/software/amazon/smithy/aws/iam/traits/ConditionKeyValueTraitTest.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,24 @@ | ||
package software.amazon.smithy.aws.iam.traits; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.shapes.Shape; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ConditionKeyValueTraitTest { | ||
@Test | ||
public void loadsFromModel() { | ||
Model result = Model.assembler() | ||
.discoverModels(getClass().getClassLoader()) | ||
.addImport(getClass().getResource("condition-key-value.smithy")) | ||
.assemble() | ||
.unwrap(); | ||
|
||
Shape shape = result.expectShape(ShapeId.from("smithy.example#EchoInput$id1")); | ||
ConditionKeyValueTrait trait = shape.expectTrait(ConditionKeyValueTrait.class); | ||
assertThat(trait.getValue(), equalTo("smithy:ActionContextKey1")); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
...est/java/software/amazon/smithy/aws/iam/traits/ServiceResolvedConditionKeysTraitTest.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,26 @@ | ||
package software.amazon.smithy.aws.iam.traits; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.shapes.Shape; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ServiceResolvedConditionKeysTraitTest { | ||
@Test | ||
public void loadsFromModel() { | ||
Model result = Model.assembler() | ||
.discoverModels(getClass().getClassLoader()) | ||
.addImport(getClass().getResource("service-resolved-condition-keys.smithy")) | ||
.assemble() | ||
.unwrap(); | ||
|
||
Shape shape = result.expectShape(ShapeId.from("smithy.example#MyService")); | ||
ServiceResolvedConditionKeysTrait trait = shape.expectTrait(ServiceResolvedConditionKeysTrait.class); | ||
assertThat(trait.getValues(), equalTo(Collections.singletonList("smithy:ServiceResolveContextKey"))); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of content changed in this file that wasn't actually the specific test additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this file and applied only the new tests.