software.amazon.awssdk.services.networkmanager.model.ServiceInsertionAction Maven / Gradle / Ivy
Show all versions of networkmanager Show documentation
/*
* 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.networkmanager.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* Describes the action that the service insertion will take for any segments associated with it.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ServiceInsertionAction implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action")
.getter(getter(ServiceInsertionAction::actionAsString)).setter(setter(Builder::action))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build();
private static final SdkField MODE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Mode")
.getter(getter(ServiceInsertionAction::modeAsString)).setter(setter(Builder::mode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Mode").build()).build();
private static final SdkField WHEN_SENT_TO_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("WhenSentTo").getter(getter(ServiceInsertionAction::whenSentTo)).setter(setter(Builder::whenSentTo))
.constructor(WhenSentTo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WhenSentTo").build()).build();
private static final SdkField VIA_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("Via")
.getter(getter(ServiceInsertionAction::via)).setter(setter(Builder::via)).constructor(Via::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Via").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_FIELD, MODE_FIELD,
WHEN_SENT_TO_FIELD, VIA_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String action;
private final String mode;
private final WhenSentTo whenSentTo;
private final Via via;
private ServiceInsertionAction(BuilderImpl builder) {
this.action = builder.action;
this.mode = builder.mode;
this.whenSentTo = builder.whenSentTo;
this.via = builder.via;
}
/**
*
* The action the service insertion takes for traffic. send-via
sends east-west traffic between
* attachments. send-to
sends north-south traffic to the security appliance, and then from that to
* either the Internet or to an on-premesis location.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #action} will
* return {@link SegmentActionServiceInsertion#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #actionAsString}.
*
*
* @return The action the service insertion takes for traffic. send-via
sends east-west traffic between
* attachments. send-to
sends north-south traffic to the security appliance, and then from that
* to either the Internet or to an on-premesis location.
* @see SegmentActionServiceInsertion
*/
public final SegmentActionServiceInsertion action() {
return SegmentActionServiceInsertion.fromValue(action);
}
/**
*
* The action the service insertion takes for traffic. send-via
sends east-west traffic between
* attachments. send-to
sends north-south traffic to the security appliance, and then from that to
* either the Internet or to an on-premesis location.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #action} will
* return {@link SegmentActionServiceInsertion#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #actionAsString}.
*
*
* @return The action the service insertion takes for traffic. send-via
sends east-west traffic between
* attachments. send-to
sends north-south traffic to the security appliance, and then from that
* to either the Internet or to an on-premesis location.
* @see SegmentActionServiceInsertion
*/
public final String actionAsString() {
return action;
}
/**
*
* Describes the mode packets take for the send-via
action. This is not used when the action is
* send-to
. dual-hop
packets traverse attachments in both the source to the destination
* core network edges. This mode requires that an inspection attachment must be present in all Regions of the
* service insertion-enabled segments. For single-hop
, packets traverse a single intermediate inserted
* attachment. You can use EdgeOverride
to specify a specific edge to use.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link SendViaMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeAsString}.
*
*
* @return Describes the mode packets take for the send-via
action. This is not used when the action is
* send-to
. dual-hop
packets traverse attachments in both the source to the
* destination core network edges. This mode requires that an inspection attachment must be present in all
* Regions of the service insertion-enabled segments. For single-hop
, packets traverse a single
* intermediate inserted attachment. You can use EdgeOverride
to specify a specific edge to
* use.
* @see SendViaMode
*/
public final SendViaMode mode() {
return SendViaMode.fromValue(mode);
}
/**
*
* Describes the mode packets take for the send-via
action. This is not used when the action is
* send-to
. dual-hop
packets traverse attachments in both the source to the destination
* core network edges. This mode requires that an inspection attachment must be present in all Regions of the
* service insertion-enabled segments. For single-hop
, packets traverse a single intermediate inserted
* attachment. You can use EdgeOverride
to specify a specific edge to use.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link SendViaMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeAsString}.
*
*
* @return Describes the mode packets take for the send-via
action. This is not used when the action is
* send-to
. dual-hop
packets traverse attachments in both the source to the
* destination core network edges. This mode requires that an inspection attachment must be present in all
* Regions of the service insertion-enabled segments. For single-hop
, packets traverse a single
* intermediate inserted attachment. You can use EdgeOverride
to specify a specific edge to
* use.
* @see SendViaMode
*/
public final String modeAsString() {
return mode;
}
/**
*
* The list of destination segments if the service insertion action is send-via
.
*
*
* @return The list of destination segments if the service insertion action is send-via
.
*/
public final WhenSentTo whenSentTo() {
return whenSentTo;
}
/**
*
* The list of network function groups and any edge overrides for the chosen service insertion action. Used for both
* send-to
or send-via
.
*
*
* @return The list of network function groups and any edge overrides for the chosen service insertion action. Used
* for both send-to
or send-via
.
*/
public final Via via() {
return via;
}
@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(actionAsString());
hashCode = 31 * hashCode + Objects.hashCode(modeAsString());
hashCode = 31 * hashCode + Objects.hashCode(whenSentTo());
hashCode = 31 * hashCode + Objects.hashCode(via());
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 ServiceInsertionAction)) {
return false;
}
ServiceInsertionAction other = (ServiceInsertionAction) obj;
return Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(modeAsString(), other.modeAsString())
&& Objects.equals(whenSentTo(), other.whenSentTo()) && Objects.equals(via(), other.via());
}
/**
* 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("ServiceInsertionAction").add("Action", actionAsString()).add("Mode", modeAsString())
.add("WhenSentTo", whenSentTo()).add("Via", via()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Action":
return Optional.ofNullable(clazz.cast(actionAsString()));
case "Mode":
return Optional.ofNullable(clazz.cast(modeAsString()));
case "WhenSentTo":
return Optional.ofNullable(clazz.cast(whenSentTo()));
case "Via":
return Optional.ofNullable(clazz.cast(via()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("Action", ACTION_FIELD);
map.put("Mode", MODE_FIELD);
map.put("WhenSentTo", WHEN_SENT_TO_FIELD);
map.put("Via", VIA_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function