
software.amazon.awssdk.services.networkfirewall.model.RuleGroup 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.networkfirewall.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 object that defines the rules in a rule group. This, along with RuleGroupResponse, define the rule group.
* You can retrieve all objects for a rule group by calling DescribeRuleGroup.
*
*
* Network Firewall uses a rule group to inspect and control network traffic. You define stateless rule groups to
* inspect individual packets and you define stateful rule groups to inspect packets in the context of their traffic
* flow.
*
*
* To use a rule group, you include it by reference in an Network Firewall firewall policy, then you use the policy in a
* firewall. You can reference a rule group from more than one firewall policy, and you can use a firewall policy in
* more than one firewall.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RuleGroup implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField RULE_VARIABLES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RuleVariables")
.getter(getter(RuleGroup::ruleVariables)).setter(setter(Builder::ruleVariables)).constructor(RuleVariables::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleVariables").build()).build();
private static final SdkField REFERENCE_SETS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ReferenceSets")
.getter(getter(RuleGroup::referenceSets)).setter(setter(Builder::referenceSets)).constructor(ReferenceSets::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReferenceSets").build()).build();
private static final SdkField RULES_SOURCE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("RulesSource").getter(getter(RuleGroup::rulesSource)).setter(setter(Builder::rulesSource))
.constructor(RulesSource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RulesSource").build()).build();
private static final SdkField STATEFUL_RULE_OPTIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("StatefulRuleOptions")
.getter(getter(RuleGroup::statefulRuleOptions)).setter(setter(Builder::statefulRuleOptions))
.constructor(StatefulRuleOptions::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatefulRuleOptions").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RULE_VARIABLES_FIELD,
REFERENCE_SETS_FIELD, RULES_SOURCE_FIELD, STATEFUL_RULE_OPTIONS_FIELD));
private static final long serialVersionUID = 1L;
private final RuleVariables ruleVariables;
private final ReferenceSets referenceSets;
private final RulesSource rulesSource;
private final StatefulRuleOptions statefulRuleOptions;
private RuleGroup(BuilderImpl builder) {
this.ruleVariables = builder.ruleVariables;
this.referenceSets = builder.referenceSets;
this.rulesSource = builder.rulesSource;
this.statefulRuleOptions = builder.statefulRuleOptions;
}
/**
*
* Settings that are available for use in the rules in the rule group. You can only use these for stateful rule
* groups.
*
*
* @return Settings that are available for use in the rules in the rule group. You can only use these for stateful
* rule groups.
*/
public final RuleVariables ruleVariables() {
return ruleVariables;
}
/**
*
* The list of a rule group's reference sets.
*
*
* @return The list of a rule group's reference sets.
*/
public final ReferenceSets referenceSets() {
return referenceSets;
}
/**
*
* The stateful rules or stateless rules for the rule group.
*
*
* @return The stateful rules or stateless rules for the rule group.
*/
public final RulesSource rulesSource() {
return rulesSource;
}
/**
*
* Additional options governing how Network Firewall handles stateful rules. The policies where you use your
* stateful rule group must have stateful rule options settings that are compatible with these settings. Some
* limitations apply; for more information, see Strict evaluation order in the Network Firewall Developer Guide.
*
*
* @return Additional options governing how Network Firewall handles stateful rules. The policies where you use your
* stateful rule group must have stateful rule options settings that are compatible with these settings.
* Some limitations apply; for more information, see Strict evaluation order in the Network Firewall Developer Guide.
*/
public final StatefulRuleOptions statefulRuleOptions() {
return statefulRuleOptions;
}
@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(ruleVariables());
hashCode = 31 * hashCode + Objects.hashCode(referenceSets());
hashCode = 31 * hashCode + Objects.hashCode(rulesSource());
hashCode = 31 * hashCode + Objects.hashCode(statefulRuleOptions());
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 RuleGroup)) {
return false;
}
RuleGroup other = (RuleGroup) obj;
return Objects.equals(ruleVariables(), other.ruleVariables()) && Objects.equals(referenceSets(), other.referenceSets())
&& Objects.equals(rulesSource(), other.rulesSource())
&& Objects.equals(statefulRuleOptions(), other.statefulRuleOptions());
}
/**
* 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("RuleGroup").add("RuleVariables", ruleVariables()).add("ReferenceSets", referenceSets())
.add("RulesSource", rulesSource()).add("StatefulRuleOptions", statefulRuleOptions()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RuleVariables":
return Optional.ofNullable(clazz.cast(ruleVariables()));
case "ReferenceSets":
return Optional.ofNullable(clazz.cast(referenceSets()));
case "RulesSource":
return Optional.ofNullable(clazz.cast(rulesSource()));
case "StatefulRuleOptions":
return Optional.ofNullable(clazz.cast(statefulRuleOptions()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function