
software.amazon.awssdk.services.securityhub.model.AwsWafv2RulesActionDetails Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.securityhub.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The action that WAF should take on a web request when it matches a rule's statement. Settings at the web ACL level
* can override the rule action setting.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AwsWafv2RulesActionDetails implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ALLOW_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Allow")
.getter(getter(AwsWafv2RulesActionDetails::allow)).setter(setter(Builder::allow))
.constructor(AwsWafv2ActionAllowDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Allow").build()).build();
private static final SdkField BLOCK_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Block")
.getter(getter(AwsWafv2RulesActionDetails::block)).setter(setter(Builder::block))
.constructor(AwsWafv2ActionBlockDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Block").build()).build();
private static final SdkField CAPTCHA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Captcha")
.getter(getter(AwsWafv2RulesActionDetails::captcha)).setter(setter(Builder::captcha))
.constructor(AwsWafv2RulesActionCaptchaDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Captcha").build()).build();
private static final SdkField COUNT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Count")
.getter(getter(AwsWafv2RulesActionDetails::count)).setter(setter(Builder::count))
.constructor(AwsWafv2RulesActionCountDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Count").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ALLOW_FIELD, BLOCK_FIELD,
CAPTCHA_FIELD, COUNT_FIELD));
private static final long serialVersionUID = 1L;
private final AwsWafv2ActionAllowDetails allow;
private final AwsWafv2ActionBlockDetails block;
private final AwsWafv2RulesActionCaptchaDetails captcha;
private final AwsWafv2RulesActionCountDetails count;
private AwsWafv2RulesActionDetails(BuilderImpl builder) {
this.allow = builder.allow;
this.block = builder.block;
this.captcha = builder.captcha;
this.count = builder.count;
}
/**
*
* Instructs WAF to allow the web request.
*
*
* @return Instructs WAF to allow the web request.
*/
public final AwsWafv2ActionAllowDetails allow() {
return allow;
}
/**
*
* Instructs WAF to block the web request.
*
*
* @return Instructs WAF to block the web request.
*/
public final AwsWafv2ActionBlockDetails block() {
return block;
}
/**
*
* Instructs WAF to run a CAPTCHA check against the web request.
*
*
* @return Instructs WAF to run a CAPTCHA check against the web request.
*/
public final AwsWafv2RulesActionCaptchaDetails captcha() {
return captcha;
}
/**
*
* Instructs WAF to count the web request and then continue evaluating the request using the remaining rules in the
* web ACL.
*
*
* @return Instructs WAF to count the web request and then continue evaluating the request using the remaining rules
* in the web ACL.
*/
public final AwsWafv2RulesActionCountDetails count() {
return count;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(allow());
hashCode = 31 * hashCode + Objects.hashCode(block());
hashCode = 31 * hashCode + Objects.hashCode(captcha());
hashCode = 31 * hashCode + Objects.hashCode(count());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AwsWafv2RulesActionDetails)) {
return false;
}
AwsWafv2RulesActionDetails other = (AwsWafv2RulesActionDetails) obj;
return Objects.equals(allow(), other.allow()) && Objects.equals(block(), other.block())
&& Objects.equals(captcha(), other.captcha()) && Objects.equals(count(), other.count());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("AwsWafv2RulesActionDetails").add("Allow", allow()).add("Block", block())
.add("Captcha", captcha()).add("Count", count()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Allow":
return Optional.ofNullable(clazz.cast(allow()));
case "Block":
return Optional.ofNullable(clazz.cast(block()));
case "Captcha":
return Optional.ofNullable(clazz.cast(captcha()));
case "Count":
return Optional.ofNullable(clazz.cast(count()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy