-
Notifications
You must be signed in to change notification settings - Fork 220
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
Smithy Rules engine #1356
Smithy Rules engine #1356
Conversation
85cfd83
to
84ebd09
Compare
59861f7
to
9919d96
Compare
eb43dc73...c92510ca
* smithy-rules-engine trait fixes * Integrate of smithy-rules-engine traits
e7abe9c
to
034bd7b
Compare
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.
Partially through, posting so edits can be made while review continues.
* The type of validation error that has occurred. | ||
*/ | ||
@SmithyUnstableApi | ||
public enum ValidationErrorType { |
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.
This can be an inner enum of ValidationError
as Type
if it sticks around, otherwise it seems like these are event ids.
builder.type(ParameterType.BOOLEAN); | ||
break; | ||
default: | ||
throw new IllegalArgumentException(java.lang.String.format( |
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.
Why a separate exception and not a validation event?
public final class EndpointTestsTraitValidator extends AbstractValidator { | ||
@Override | ||
public List<ValidationEvent> validate(Model model) { | ||
return null; |
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.
Looks like this validation is missing or somewhere else meaning the class isn't needed anymore.
...c/main/java/software/amazon/smithy/rulesengine/language/syntax/parameters/ParameterType.java
Show resolved
Hide resolved
private StandaloneRulesetValidator() { | ||
} | ||
|
||
public static Stream<ValidationError> validate(EndpointRuleSet ruleset, EndpointTestsTrait testSuite) { |
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.
How is this wired up to validate definitions automatically?
Why do the validators listed here not use the built in ValidationEvent
system? I don't see anything in the validators that preclude using it. Multiple event IDs can be generated from the same validator by using the Builder
instead of the ease-of-use functions.
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/Endpoint.java
Show resolved
Hide resolved
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/Endpoint.java
Show resolved
Hide resolved
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/Endpoint.java
Show resolved
Hide resolved
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/Endpoint.java
Show resolved
Hide resolved
...-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/EndpointRuleSet.java
Show resolved
Hide resolved
...-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/EndpointRuleSet.java
Show resolved
Hide resolved
* A set of EndpointRules. Endpoint Rules describe the endpoint resolution behavior for a service. | ||
*/ | ||
@SmithyUnstableApi | ||
public final class EndpointRuleSet extends MandatorySourceLocation implements TypeCheck, ToNode { |
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.
Public methods are missing javadoc.
} | ||
|
||
@Override | ||
public Type typeCheck(Scope<Type> scope) { |
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.
Could use some internal documentation.
}); | ||
} | ||
|
||
public void typecheck() { |
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.
This has different casing from typeCheck
. It's also only used in a test and doesn't have the same return type. Is it needed?
private Node rulesNode() { | ||
ArrayNode.Builder node = ArrayNode.builder(); | ||
rules.forEach(node::withValue); | ||
return node.build(); |
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.
This will return an empty array node []
even if there are no rules.
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.rulesengine.language.impl; |
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.
This is the only thing in this package and it's AWS specific, should it move?
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/impl/AwsArn.java
Show resolved
Hide resolved
this.service = SmithyBuilder.requiredState("service", builder.service); | ||
this.region = SmithyBuilder.requiredState("region", builder.region); | ||
this.accountId = SmithyBuilder.requiredState("accountId", builder.accountId); | ||
this.resource = builder.resource.copy(); |
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.
Is this required as well?
* An AWS ARN. | ||
*/ | ||
@SmithyUnstableApi | ||
public final class AwsArn implements ToSmithyBuilder<AwsArn> { |
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.
Needs builder and method level javadoc.
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.rulesengine.language.stdlib; |
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.
Maybe functions
instead of stdlib
?
Looks like Windows CI is failing as well, these are usually due to a path issue around |
Implementation of the Smithy Rules Engine Language