Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ tasks {
duplicatesStrategy = DuplicatesStrategy.WARN
}
}

// We don't need to lint benchmarks.
tasks.findByName("spotbugsJmh")?.apply {
enabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public OpenApi after(Context<? extends Trait> context, OpenApi openapi) {

// Check if the service has a request validator.
String serviceValidator = null;
if (context.getService().getTrait(RequestValidatorTrait.class).isPresent()) {
serviceValidator = context.getService().getTrait(RequestValidatorTrait.class).get().getValue();
if (context.getService().hasTrait(RequestValidatorTrait.ID)) {
serviceValidator = context.getService().expectTrait(RequestValidatorTrait.class).getValue();
validators.add(serviceValidator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private Set<Mutability> getDefaultIdentifierMutabilities(ResourceShape resource)
private List<Map<String, ShapeId>> computeResourceAdditionalIdentifiers(StructureShape readInput) {
List<Map<String, ShapeId>> identifiers = new ArrayList<>();
for (MemberShape member : readInput.members()) {
if (!member.hasTrait(CfnAdditionalIdentifierTrait.class)) {
if (!member.hasTrait(CfnAdditionalIdentifierTrait.ID)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ public void loadsFromModel() {
.unwrap();

Shape fooResource = result.expectShape(ShapeId.from("smithy.example#FooResource"));
assertTrue(fooResource.hasTrait(CfnResourceTrait.class));
assertTrue(fooResource.hasTrait(CfnResourceTrait.ID));
CfnResourceTrait fooTrait = fooResource.expectTrait(CfnResourceTrait.class);
assertFalse(fooTrait.getName().isPresent());
assertTrue(fooTrait.getAdditionalSchemas().isEmpty());

Shape barResource = result.expectShape(ShapeId.from("smithy.example#BarResource"));
assertTrue(barResource.hasTrait(CfnResourceTrait.class));
assertTrue(barResource.hasTrait(CfnResourceTrait.ID));
CfnResourceTrait barTrait = barResource.expectTrait(CfnResourceTrait.class);
assertThat(barTrait.getName().get(), equalTo("CustomResource"));
assertFalse(barTrait.getAdditionalSchemas().isEmpty());
assertThat(barTrait.getAdditionalSchemas(), contains(ShapeId.from("smithy.example#ExtraBarRequest")));

Shape tadResource = result.expectShape(ShapeId.from("smithy.example#TadResource"));
assertTrue(tadResource.hasTrait(CfnResourceTrait.class));
assertTrue(tadResource.hasTrait(CfnResourceTrait.ID));
CfnResourceTrait tadTrait = tadResource.expectTrait(CfnResourceTrait.class);
assertFalse(tadTrait.getName().isPresent());
assertTrue(tadTrait.getAdditionalSchemas().isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private List<ConversionEnvironment> createConversionEnvironments(Model model) {
// Create an environment for each of the resources to be converted with.
List<ConversionEnvironment> environments = new ArrayList<>();
for (ResourceShape resourceShape : resourceShapes) {
if (resourceShape.getTrait(CfnResourceTrait.class).isPresent()) {
if (resourceShape.hasTrait(CfnResourceTrait.ID)) {
ConversionEnvironment environment = createConversionEnvironment(model, serviceShape, resourceShape);
environments.add(environment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void before(Context context, ResourceSchema.Builder resourceSchema) {
.orElse(SetUtils.of());
createPermissions.addAll(putPermissions);
// Put operations without the noReplace trait are used for updates.
if (!resource.hasTrait(NoReplaceTrait.class)) {
if (!resource.hasTrait(NoReplaceTrait.ID)) {
updatePermissions.addAll(putPermissions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void injectTagsMember(
StructureShape.Builder builder
) {
String tagMemberName = getTagMemberName(config, resource);
if (resource.hasTrait(TaggableTrait.class)) {
if (resource.hasTrait(TaggableTrait.ID)) {
AwsTagIndex tagIndex = AwsTagIndex.of(model);
TaggableTrait trait = resource.expectTrait(TaggableTrait.class);
CfnResourceIndex resourceIndex = CfnResourceIndex.of(model);
Expand All @@ -68,7 +68,7 @@ public static void injectTagsMember(
@Override
public ResourceSchema after(Context context, ResourceSchema resourceSchema) {
ResourceShape resourceShape = context.getResource();
if (!resourceShape.hasTrait(TaggableTrait.class)) {
if (!resourceShape.hasTrait(TaggableTrait.ID)) {
return resourceSchema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ private void compute(

// Continue recursing into resources and computing keys.
subject.asResourceShape().ifPresent(resource -> {
boolean disableConditionKeyInference = resource.hasTrait(DisableConditionKeyInferenceTrait.class)
|| service.hasTrait(DisableConditionKeyInferenceTrait.class);
boolean disableConditionKeyInference = resource.hasTrait(DisableConditionKeyInferenceTrait.ID)
|| service.hasTrait(DisableConditionKeyInferenceTrait.ID);

// Add any inferred resource identifiers to the resource and to the service-wide definitions.
Map<String, String> childIdentifiers = !disableConditionKeyInference
Expand Down Expand Up @@ -218,7 +218,7 @@ private Map<String, String> inferChildResourceIdentifiers(
// Only infer identifiers introduced by a child. Children should
// use their parent identifiers and not duplicate them.
ConditionKeyDefinition.Builder builder = ConditionKeyDefinition.builder();
if (shape.hasTrait(ArnReferenceTrait.class)) {
if (shape.hasTrait(ArnReferenceTrait.ID)) {
// Use an ARN type if the targeted shape has the arnReference trait.
builder.type(ARN_TYPE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public List<ValidationEvent> validate(Model model) {
OperationIndex operationIndex = OperationIndex.of(model);

return model.shapes(ServiceShape.class)
.filter(service -> service.hasTrait(ServiceTrait.class))
.filter(service -> service.hasTrait(ServiceTrait.ID))
.flatMap(service -> {
List<ValidationEvent> results = new ArrayList<>();
Set<String> knownKeys = conditionIndex.getDefinedConditionKeys(service).keySet();
Set<String> serviceResolvedKeys = Collections.emptySet();

if (service.hasTrait(ServiceResolvedConditionKeysTrait.class)) {
if (service.hasTrait(ServiceResolvedConditionKeysTrait.ID)) {
ServiceResolvedConditionKeysTrait trait =
service.expectTrait(ServiceResolvedConditionKeysTrait.class);
//assign so we can compare against condition key values for any intersection
Expand Down Expand Up @@ -83,7 +83,7 @@ public List<ValidationEvent> validate(Model model) {
}

for (MemberShape memberShape : operationIndex.getInputMembers(operation).values()) {
if (memberShape.hasTrait(ConditionKeyValueTrait.class)) {
if (memberShape.hasTrait(ConditionKeyValueTrait.ID)) {
ConditionKeyValueTrait trait = memberShape.expectTrait(ConditionKeyValueTrait.class);
String conditionKey = trait.getValue();
if (!knownKeys.contains(conditionKey)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public List<ValidationEvent> validate(Model model) {
for (ResourceShape resource : model.getResourceShapesWithTrait(IamResourceTrait.class)) {
// If the resource has both the IamResourceTrait and Arn trait,
// check that the resource name is consistent between the two traits
if (resource.hasTrait(ArnTrait.class)) {
if (resource.hasTrait(ArnTrait.ID)) {
String resourceName = resource.expectTrait(IamResourceTrait.class)
.getName()
.orElseGet(() -> StringUtils.lowerCase(resource.getId().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void loadsFromModel() {

Shape fooOperation = result.expectShape(ID);

assertTrue(fooOperation.hasTrait(IamActionTrait.class));
assertTrue(fooOperation.hasTrait(IamActionTrait.ID));
IamActionTrait trait = fooOperation.expectTrait(IamActionTrait.class);
assertEquals(trait.getName().get(), "foo");
assertEquals(trait.getDocumentation().get(), "docs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void loadsFromModel() {

Shape superResource = result.expectShape(ID);

assertTrue(superResource.hasTrait(IamResourceTrait.class));
assertTrue(superResource.hasTrait(IamResourceTrait.ID));
assertEquals(superResource.expectTrait(IamResourceTrait.class).getName().get(), "super");
assertEquals(superResource.expectTrait(IamResourceTrait.class).getRelativeDocumentation().get(),
"API-Super.html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void loadsFromModel() {

Shape myOperation = result.expectShape(ShapeId.from("smithy.example#MyOperation"));

assertTrue(myOperation.hasTrait(RequiredActionsTrait.class));
assertTrue(myOperation.hasTrait(RequiredActionsTrait.ID));
assertThat(myOperation.expectTrait(RequiredActionsTrait.class).getValues(),
containsInAnyOrder(
"iam:PassRole",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public void loadsFromModel() {
Shape myService = result.expectShape(ShapeId.from("smithy.example#MyService"));
Shape myOperation = result.expectShape(ShapeId.from("smithy.example#MyOperation"));

assertTrue(myService.hasTrait(SupportedPrincipalTypesTrait.class));
assertTrue(myService.hasTrait(SupportedPrincipalTypesTrait.ID));
assertThat(myService.expectTrait(SupportedPrincipalTypesTrait.class).getValues(),
containsInAnyOrder(
"IAMUser",
"IAMRole"));

assertTrue(myOperation.hasTrait(SupportedPrincipalTypesTrait.class));
assertTrue(myOperation.hasTrait(SupportedPrincipalTypesTrait.ID));
assertThat(myOperation.expectTrait(SupportedPrincipalTypesTrait.class).getValues(),
containsInAnyOrder(
"Root",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ArnIndex(Model model) {
// Pre-compute all of the ARN templates in a service shape.
TopDownIndex topDownIndex = TopDownIndex.of(model);
List<ServiceShape> services = model.shapes(ServiceShape.class)
.filter(shape -> shape.hasTrait(ServiceTrait.class))
.filter(shape -> shape.hasTrait(ServiceTrait.ID))
.collect(Collectors.toList());

templates = unmodifiableMap(services.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void validate(Model model, ServiceShape service, List<ValidationEvent> e
renames.keySet().forEach(shapeId -> {
Optional<Shape> shape = model.getShape(shapeId);

if (!shape.isPresent() || !shape.get().hasTrait(ErrorTrait.class)) {
if (!shape.isPresent() || !shape.get().hasTrait(ErrorTrait.ID)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ private Plane resolvePlane(ToShapeId service, ShapeId operationOrResource) {
}

private Plane extractPlane(Shape shape) {
if (shape.hasTrait(ControlPlaneTrait.class)) {
if (shape.hasTrait(ControlPlaneTrait.ID)) {
return Plane.CONTROL;
} else if (shape.hasTrait(DataPlaneTrait.class)) {
} else if (shape.hasTrait(DataPlaneTrait.ID)) {
return Plane.DATA;
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private Set<Shape> getOperationsToUpdate(
ClientEndpointDiscoveryIndex discoveryIndex = ClientEndpointDiscoveryIndex.of(model);
Set<ShapeId> stillBoundOperations = model.shapes(ServiceShape.class)
// Get all endpoint discovery services
.filter(service -> service.hasTrait(ClientEndpointDiscoveryTrait.class))
.filter(service -> service.hasTrait(ClientEndpointDiscoveryTrait.ID))
.map(Shape::getId)
// Get those services who aren't having their discovery traits removed
.filter(service -> !updatedServices.contains(service))
Expand All @@ -96,7 +96,7 @@ private Set<Shape> getOperationsToUpdate(
private Set<Shape> getMembersToUpdate(Model model, Set<ShapeId> updatedOperations) {
Set<ShapeId> stillBoundMembers = model.shapes(OperationShape.class)
// Get all endpoint discovery operations
.filter(operation -> operation.hasTrait(ClientDiscoveredEndpointTrait.class))
.filter(operation -> operation.hasTrait(ClientDiscoveredEndpointTrait.ID))
// Filter out the ones which are having their endpoint discovery traits removed
.filter(operation -> !updatedOperations.contains(operation.getId()))
// Get the input shapes of those operations
Expand All @@ -109,7 +109,7 @@ private Set<Shape> getMembersToUpdate(Model model, Set<ShapeId> updatedOperation

return model.shapes(MemberShape.class)
// Get all members which have the endpoint discovery id trait
.filter(member -> member.hasTrait(ClientEndpointDiscoveryIdTrait.class))
.filter(member -> member.hasTrait(ClientEndpointDiscoveryIdTrait.ID))
// Get those which are on structures that aren't still bound to endpoint discovery operations
.filter(member -> !stillBoundMembers.contains(member.getId()))
// Remove the trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private Map<ShapeId, ClientEndpointDiscoveryInfo> getOperations(
private List<MemberShape> getDiscoveryIds(OperationIndex opIndex, OperationShape operation) {
List<MemberShape> discoveryIds = new ArrayList<>();
for (MemberShape member : opIndex.expectInputShape(operation).getAllMembers().values()) {
if (member.hasTrait(ClientEndpointDiscoveryIdTrait.class)) {
if (member.hasTrait(ClientEndpointDiscoveryIdTrait.ID)) {
discoveryIds.add(member);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private List<ValidationEvent> validateOperations(
Map<ServiceShape, ClientEndpointDiscoveryTrait> endpointDiscoveryServices
) {
return model.shapes(OperationShape.class)
.filter(operation -> operation.hasTrait(ClientDiscoveredEndpointTrait.class))
.filter(operation -> operation.hasTrait(ClientDiscoveredEndpointTrait.ID))
.map(operation -> {
List<ClientEndpointDiscoveryInfo> infos = endpointDiscoveryServices.keySet()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private void computeResourceTagLocations(Model model, ResourceShape resource) {
// Put is always a create operation
resourceIsTagOnCreate.add(resource.getId());
// and it's also an update when not annotated with `@noReplace`.
if (!resource.hasTrait(NoReplaceTrait.class)) {
if (!resource.hasTrait(NoReplaceTrait.ID)) {
resourceIsTagOnUpdate.add(resource.getId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private List<ValidationEvent> validateService(

int taggableResourceCount = 0;
for (ResourceShape resource : topDownIndex.getContainedResources(service)) {
if (resource.hasTrait(TaggableTrait.class)) {
if (resource.hasTrait(TaggableTrait.ID)) {
++taggableResourceCount;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public List<ValidationEvent> validate(Model model) {
for (ServiceShape service : model.getServiceShapes()) {
for (ResourceShape resource : topDownIndex.getContainedResources(service)) {
boolean resourceLikelyTaggable = false;
if (resource.hasTrait(TaggableTrait.class)) {
if (resource.hasTrait(TaggableTrait.ID)) {
events.addAll(validateResource(model, resource, service, tagIndex));
resourceLikelyTaggable = true;
} else if (resource.hasTrait(ArnTrait.class) && tagIndex.serviceHasTagApis(service)) {
} else if (resource.hasTrait(ArnTrait.ID) && tagIndex.serviceHasTagApis(service)) {
// If a resource does not have the taggable trait, but has an ARN, and the service has tag
// operations, it is most likely a mistake.
events.add(warning(resource, "Resource is likely missing `aws.api#taggable` trait."));
resourceLikelyTaggable = true;
}

// It's possible the resource was marked as taggable but the service isn't tagEnabled.
if (resourceLikelyTaggable && !service.hasTrait(TagEnabledTrait.class)) {
if (resourceLikelyTaggable && !service.hasTrait(TagEnabledTrait.ID)) {
events.add(warning(service,
"Service has resources with `aws.api#taggable` applied but does not "
+ "have the `aws.api#tagEnabled` trait."));
Expand Down Expand Up @@ -81,7 +81,7 @@ private List<ValidationEvent> validateResource(
boolean isServiceWideTaggable = awsTagIndex.serviceHasTagApis(service.getId());
boolean isInstanceOpTaggable = isTaggableViaInstanceOperations(model, resource);

if (isServiceWideTaggable && !isInstanceOpTaggable && !resource.hasTrait(ArnTrait.class)) {
if (isServiceWideTaggable && !isInstanceOpTaggable && !resource.hasTrait(ArnTrait.ID)) {
events.add(error(resource,
"Resource is taggable only via service-wide tag operations."
+ " It must use the `aws.api@arn` trait."));
Expand Down
Loading
Loading