-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conditionKeyValue and serviceResolvedConditionKeys (#1677)
* Adding conditionKeyValue and serviceResolvedConditionKeys traits * Update trait constructors to be public
- Loading branch information
Showing
24 changed files
with
441 additions
and
13 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
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.