
software.amazon.awssdk.services.networkfirewall.model.CustomAction 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;
/**
*
* An optional, non-standard action to use for stateless packet handling. You can define this in addition to the
* standard action that you must specify.
*
*
* You define and name the custom actions that you want to be able to use, and then you reference them by name in your
* actions settings.
*
*
* You can use custom actions in the following places:
*
*
* -
*
* In a rule group's StatelessRulesAndCustomActions specification. The custom actions are available for use by
* name inside the StatelessRulesAndCustomActions
where you define them. You can use them for your
* stateless rule actions to specify what to do with a packet that matches the rule's match attributes.
*
*
* -
*
* In a FirewallPolicy specification, in StatelessCustomActions
. The custom actions are available
* for use inside the policy where you define them. You can use them for the policy's default stateless actions settings
* to specify what to do with packets that don't match any of the policy's stateless rules.
*
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CustomAction implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ACTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActionName").getter(getter(CustomAction::actionName)).setter(setter(Builder::actionName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionName").build()).build();
private static final SdkField ACTION_DEFINITION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ActionDefinition")
.getter(getter(CustomAction::actionDefinition)).setter(setter(Builder::actionDefinition))
.constructor(ActionDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionDefinition").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_NAME_FIELD,
ACTION_DEFINITION_FIELD));
private static final long serialVersionUID = 1L;
private final String actionName;
private final ActionDefinition actionDefinition;
private CustomAction(BuilderImpl builder) {
this.actionName = builder.actionName;
this.actionDefinition = builder.actionDefinition;
}
/**
*
* The descriptive name of the custom action. You can't change the name of a custom action after you create it.
*
*
* @return The descriptive name of the custom action. You can't change the name of a custom action after you create
* it.
*/
public final String actionName() {
return actionName;
}
/**
*
* The custom action associated with the action name.
*
*
* @return The custom action associated with the action name.
*/
public final ActionDefinition actionDefinition() {
return actionDefinition;
}
@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(actionName());
hashCode = 31 * hashCode + Objects.hashCode(actionDefinition());
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 CustomAction)) {
return false;
}
CustomAction other = (CustomAction) obj;
return Objects.equals(actionName(), other.actionName()) && Objects.equals(actionDefinition(), other.actionDefinition());
}
/**
* 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("CustomAction").add("ActionName", actionName()).add("ActionDefinition", actionDefinition())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ActionName":
return Optional.ofNullable(clazz.cast(actionName()));
case "ActionDefinition":
return Optional.ofNullable(clazz.cast(actionDefinition()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function