diff --git a/build.gradle b/build.gradle index b01224d40..e83da7ff6 100644 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,7 @@ dependencies { implementation 'com.google.guava:guava:23.0' implementation 'com.psddev:dari-util:3.3.607-xe0f27a' implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0' - implementation enforcedPlatform('software.amazon.awssdk:bom:2.24.6') + implementation enforcedPlatform('software.amazon.awssdk:bom:2.25.5') implementation 'software.amazon.awssdk:apache-client' implementation 'software.amazon.awssdk:apigatewayv2' implementation 'software.amazon.awssdk:autoscaling' diff --git a/src/main/java/gyro/aws/wafv2/RateBasedStatementResource.java b/src/main/java/gyro/aws/wafv2/RateBasedStatementResource.java index 081be6c82..70ce996ae 100644 --- a/src/main/java/gyro/aws/wafv2/RateBasedStatementResource.java +++ b/src/main/java/gyro/aws/wafv2/RateBasedStatementResource.java @@ -28,6 +28,7 @@ import gyro.core.validation.CollectionMax; import gyro.core.validation.Min; import gyro.core.validation.Required; +import gyro.core.validation.ValidNumbers; import gyro.core.validation.ValidStrings; import gyro.core.validation.ValidationError; import software.amazon.awssdk.services.wafv2.model.RateBasedStatement; @@ -39,6 +40,7 @@ public class RateBasedStatementResource extends Diffable implements Copyable customKeys; private RateLimitForwardedIpConfigResource forwardedIpConfig; + private Long evaluationWindow; /** * The aggregate key type for the rate based statement. Defaults to ``IP``. @@ -113,6 +115,23 @@ public void setForwardedIpConfig(RateLimitForwardedIpConfigResource forwardedIpC this.forwardedIpConfig = forwardedIpConfig; } + /** + * The evaluation window in sec for the rate based statement. Defaults to ``300``. + */ + @Updatable + @ValidNumbers({ 60, 120, 300, 600 }) + public Long getEvaluationWindow() { + if (evaluationWindow == null) { + evaluationWindow = 300L; + } + + return evaluationWindow; + } + + public void setEvaluationWindow(Long evaluationWindow) { + this.evaluationWindow = evaluationWindow; + } + @Override public String primaryKey() { return String.format( @@ -152,12 +171,15 @@ public void copyFrom(RateBasedStatement rateBasedStatement) { forwardedIpConfig.copyFrom(rateBasedStatement.forwardedIPConfig()); setForwardedIpConfig(forwardedIpConfig); } + + setEvaluationWindow(rateBasedStatement.evaluationWindowSec()); } RateBasedStatement toRateBasedStatement() { RateBasedStatement.Builder builder = RateBasedStatement.builder() .aggregateKeyType(getAggregateKeyType()) - .limit(getLimit()); + .limit(getLimit()) + .evaluationWindowSec(getEvaluationWindow()); if (getScopeDownStatement() != null) { builder = builder.scopeDownStatement(getScopeDownStatement().toStatement());