software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetGroup Maven / Gradle / Ivy
Show all versions of elasticloadbalancingv2 Show documentation
/*
* Copyright 2014-2019 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.elasticloadbalancingv2.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a target group.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TargetGroup implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TARGET_GROUP_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::targetGroupArn)).setter(setter(Builder::targetGroupArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetGroupArn").build()).build();
private static final SdkField TARGET_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::targetGroupName)).setter(setter(Builder::targetGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetGroupName").build()).build();
private static final SdkField PROTOCOL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::protocolAsString)).setter(setter(Builder::protocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Protocol").build()).build();
private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(TargetGroup::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Port").build()).build();
private static final SdkField VPC_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::vpcId)).setter(setter(Builder::vpcId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VpcId").build()).build();
private static final SdkField HEALTH_CHECK_PROTOCOL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::healthCheckProtocolAsString)).setter(setter(Builder::healthCheckProtocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckProtocol").build())
.build();
private static final SdkField HEALTH_CHECK_PORT_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::healthCheckPort)).setter(setter(Builder::healthCheckPort))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckPort").build()).build();
private static final SdkField HEALTH_CHECK_ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(TargetGroup::healthCheckEnabled)).setter(setter(Builder::healthCheckEnabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckEnabled").build())
.build();
private static final SdkField HEALTH_CHECK_INTERVAL_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.getter(getter(TargetGroup::healthCheckIntervalSeconds))
.setter(setter(Builder::healthCheckIntervalSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckIntervalSeconds").build())
.build();
private static final SdkField HEALTH_CHECK_TIMEOUT_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER).getter(getter(TargetGroup::healthCheckTimeoutSeconds))
.setter(setter(Builder::healthCheckTimeoutSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckTimeoutSeconds").build())
.build();
private static final SdkField HEALTHY_THRESHOLD_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(TargetGroup::healthyThresholdCount)).setter(setter(Builder::healthyThresholdCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthyThresholdCount").build())
.build();
private static final SdkField UNHEALTHY_THRESHOLD_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(TargetGroup::unhealthyThresholdCount)).setter(setter(Builder::unhealthyThresholdCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UnhealthyThresholdCount").build())
.build();
private static final SdkField HEALTH_CHECK_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::healthCheckPath)).setter(setter(Builder::healthCheckPath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckPath").build()).build();
private static final SdkField MATCHER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(TargetGroup::matcher)).setter(setter(Builder::matcher)).constructor(Matcher::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Matcher").build()).build();
private static final SdkField> LOAD_BALANCER_ARNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(TargetGroup::loadBalancerArns))
.setter(setter(Builder::loadBalancerArns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LoadBalancerArns").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TARGET_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(TargetGroup::targetTypeAsString)).setter(setter(Builder::targetType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TARGET_GROUP_ARN_FIELD,
TARGET_GROUP_NAME_FIELD, PROTOCOL_FIELD, PORT_FIELD, VPC_ID_FIELD, HEALTH_CHECK_PROTOCOL_FIELD,
HEALTH_CHECK_PORT_FIELD, HEALTH_CHECK_ENABLED_FIELD, HEALTH_CHECK_INTERVAL_SECONDS_FIELD,
HEALTH_CHECK_TIMEOUT_SECONDS_FIELD, HEALTHY_THRESHOLD_COUNT_FIELD, UNHEALTHY_THRESHOLD_COUNT_FIELD,
HEALTH_CHECK_PATH_FIELD, MATCHER_FIELD, LOAD_BALANCER_ARNS_FIELD, TARGET_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String targetGroupArn;
private final String targetGroupName;
private final String protocol;
private final Integer port;
private final String vpcId;
private final String healthCheckProtocol;
private final String healthCheckPort;
private final Boolean healthCheckEnabled;
private final Integer healthCheckIntervalSeconds;
private final Integer healthCheckTimeoutSeconds;
private final Integer healthyThresholdCount;
private final Integer unhealthyThresholdCount;
private final String healthCheckPath;
private final Matcher matcher;
private final List loadBalancerArns;
private final String targetType;
private TargetGroup(BuilderImpl builder) {
this.targetGroupArn = builder.targetGroupArn;
this.targetGroupName = builder.targetGroupName;
this.protocol = builder.protocol;
this.port = builder.port;
this.vpcId = builder.vpcId;
this.healthCheckProtocol = builder.healthCheckProtocol;
this.healthCheckPort = builder.healthCheckPort;
this.healthCheckEnabled = builder.healthCheckEnabled;
this.healthCheckIntervalSeconds = builder.healthCheckIntervalSeconds;
this.healthCheckTimeoutSeconds = builder.healthCheckTimeoutSeconds;
this.healthyThresholdCount = builder.healthyThresholdCount;
this.unhealthyThresholdCount = builder.unhealthyThresholdCount;
this.healthCheckPath = builder.healthCheckPath;
this.matcher = builder.matcher;
this.loadBalancerArns = builder.loadBalancerArns;
this.targetType = builder.targetType;
}
/**
*
* The Amazon Resource Name (ARN) of the target group.
*
*
* @return The Amazon Resource Name (ARN) of the target group.
*/
public String targetGroupArn() {
return targetGroupArn;
}
/**
*
* The name of the target group.
*
*
* @return The name of the target group.
*/
public String targetGroupName() {
return targetGroupName;
}
/**
*
* The protocol to use for routing traffic to the targets.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #protocol} will
* return {@link ProtocolEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #protocolAsString}.
*
*
* @return The protocol to use for routing traffic to the targets.
* @see ProtocolEnum
*/
public ProtocolEnum protocol() {
return ProtocolEnum.fromValue(protocol);
}
/**
*
* The protocol to use for routing traffic to the targets.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #protocol} will
* return {@link ProtocolEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #protocolAsString}.
*
*
* @return The protocol to use for routing traffic to the targets.
* @see ProtocolEnum
*/
public String protocolAsString() {
return protocol;
}
/**
*
* The port on which the targets are listening.
*
*
* @return The port on which the targets are listening.
*/
public Integer port() {
return port;
}
/**
*
* The ID of the VPC for the targets.
*
*
* @return The ID of the VPC for the targets.
*/
public String vpcId() {
return vpcId;
}
/**
*
* The protocol to use to connect with the target.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #healthCheckProtocol} will return {@link ProtocolEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by
* the service is available from {@link #healthCheckProtocolAsString}.
*
*
* @return The protocol to use to connect with the target.
* @see ProtocolEnum
*/
public ProtocolEnum healthCheckProtocol() {
return ProtocolEnum.fromValue(healthCheckProtocol);
}
/**
*
* The protocol to use to connect with the target.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #healthCheckProtocol} will return {@link ProtocolEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by
* the service is available from {@link #healthCheckProtocolAsString}.
*
*
* @return The protocol to use to connect with the target.
* @see ProtocolEnum
*/
public String healthCheckProtocolAsString() {
return healthCheckProtocol;
}
/**
*
* The port to use to connect with the target.
*
*
* @return The port to use to connect with the target.
*/
public String healthCheckPort() {
return healthCheckPort;
}
/**
*
* Indicates whether health checks are enabled.
*
*
* @return Indicates whether health checks are enabled.
*/
public Boolean healthCheckEnabled() {
return healthCheckEnabled;
}
/**
*
* The approximate amount of time, in seconds, between health checks of an individual target.
*
*
* @return The approximate amount of time, in seconds, between health checks of an individual target.
*/
public Integer healthCheckIntervalSeconds() {
return healthCheckIntervalSeconds;
}
/**
*
* The amount of time, in seconds, during which no response means a failed health check.
*
*
* @return The amount of time, in seconds, during which no response means a failed health check.
*/
public Integer healthCheckTimeoutSeconds() {
return healthCheckTimeoutSeconds;
}
/**
*
* The number of consecutive health checks successes required before considering an unhealthy target healthy.
*
*
* @return The number of consecutive health checks successes required before considering an unhealthy target
* healthy.
*/
public Integer healthyThresholdCount() {
return healthyThresholdCount;
}
/**
*
* The number of consecutive health check failures required before considering the target unhealthy.
*
*
* @return The number of consecutive health check failures required before considering the target unhealthy.
*/
public Integer unhealthyThresholdCount() {
return unhealthyThresholdCount;
}
/**
*
* The destination for the health check request.
*
*
* @return The destination for the health check request.
*/
public String healthCheckPath() {
return healthCheckPath;
}
/**
*
* The HTTP codes to use when checking for a successful response from a target.
*
*
* @return The HTTP codes to use when checking for a successful response from a target.
*/
public Matcher matcher() {
return matcher;
}
/**
*
* The Amazon Resource Names (ARN) of the load balancers that route traffic to this target group.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The Amazon Resource Names (ARN) of the load balancers that route traffic to this target group.
*/
public List loadBalancerArns() {
return loadBalancerArns;
}
/**
*
* The type of target that you must specify when registering targets with this target group. The possible values are
* instance
(targets are specified by instance ID) or ip
(targets are specified by IP
* address).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #targetType} will
* return {@link TargetTypeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #targetTypeAsString}.
*
*
* @return The type of target that you must specify when registering targets with this target group. The possible
* values are instance
(targets are specified by instance ID) or ip
(targets are
* specified by IP address).
* @see TargetTypeEnum
*/
public TargetTypeEnum targetType() {
return TargetTypeEnum.fromValue(targetType);
}
/**
*
* The type of target that you must specify when registering targets with this target group. The possible values are
* instance
(targets are specified by instance ID) or ip
(targets are specified by IP
* address).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #targetType} will
* return {@link TargetTypeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #targetTypeAsString}.
*
*
* @return The type of target that you must specify when registering targets with this target group. The possible
* values are instance
(targets are specified by instance ID) or ip
(targets are
* specified by IP address).
* @see TargetTypeEnum
*/
public String targetTypeAsString() {
return targetType;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(targetGroupArn());
hashCode = 31 * hashCode + Objects.hashCode(targetGroupName());
hashCode = 31 * hashCode + Objects.hashCode(protocolAsString());
hashCode = 31 * hashCode + Objects.hashCode(port());
hashCode = 31 * hashCode + Objects.hashCode(vpcId());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckProtocolAsString());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckPort());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckEnabled());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckIntervalSeconds());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckTimeoutSeconds());
hashCode = 31 * hashCode + Objects.hashCode(healthyThresholdCount());
hashCode = 31 * hashCode + Objects.hashCode(unhealthyThresholdCount());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckPath());
hashCode = 31 * hashCode + Objects.hashCode(matcher());
hashCode = 31 * hashCode + Objects.hashCode(loadBalancerArns());
hashCode = 31 * hashCode + Objects.hashCode(targetTypeAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TargetGroup)) {
return false;
}
TargetGroup other = (TargetGroup) obj;
return Objects.equals(targetGroupArn(), other.targetGroupArn())
&& Objects.equals(targetGroupName(), other.targetGroupName())
&& Objects.equals(protocolAsString(), other.protocolAsString()) && Objects.equals(port(), other.port())
&& Objects.equals(vpcId(), other.vpcId())
&& Objects.equals(healthCheckProtocolAsString(), other.healthCheckProtocolAsString())
&& Objects.equals(healthCheckPort(), other.healthCheckPort())
&& Objects.equals(healthCheckEnabled(), other.healthCheckEnabled())
&& Objects.equals(healthCheckIntervalSeconds(), other.healthCheckIntervalSeconds())
&& Objects.equals(healthCheckTimeoutSeconds(), other.healthCheckTimeoutSeconds())
&& Objects.equals(healthyThresholdCount(), other.healthyThresholdCount())
&& Objects.equals(unhealthyThresholdCount(), other.unhealthyThresholdCount())
&& Objects.equals(healthCheckPath(), other.healthCheckPath()) && Objects.equals(matcher(), other.matcher())
&& Objects.equals(loadBalancerArns(), other.loadBalancerArns())
&& Objects.equals(targetTypeAsString(), other.targetTypeAsString());
}
/**
* 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 String toString() {
return ToString.builder("TargetGroup").add("TargetGroupArn", targetGroupArn()).add("TargetGroupName", targetGroupName())
.add("Protocol", protocolAsString()).add("Port", port()).add("VpcId", vpcId())
.add("HealthCheckProtocol", healthCheckProtocolAsString()).add("HealthCheckPort", healthCheckPort())
.add("HealthCheckEnabled", healthCheckEnabled()).add("HealthCheckIntervalSeconds", healthCheckIntervalSeconds())
.add("HealthCheckTimeoutSeconds", healthCheckTimeoutSeconds())
.add("HealthyThresholdCount", healthyThresholdCount()).add("UnhealthyThresholdCount", unhealthyThresholdCount())
.add("HealthCheckPath", healthCheckPath()).add("Matcher", matcher()).add("LoadBalancerArns", loadBalancerArns())
.add("TargetType", targetTypeAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TargetGroupArn":
return Optional.ofNullable(clazz.cast(targetGroupArn()));
case "TargetGroupName":
return Optional.ofNullable(clazz.cast(targetGroupName()));
case "Protocol":
return Optional.ofNullable(clazz.cast(protocolAsString()));
case "Port":
return Optional.ofNullable(clazz.cast(port()));
case "VpcId":
return Optional.ofNullable(clazz.cast(vpcId()));
case "HealthCheckProtocol":
return Optional.ofNullable(clazz.cast(healthCheckProtocolAsString()));
case "HealthCheckPort":
return Optional.ofNullable(clazz.cast(healthCheckPort()));
case "HealthCheckEnabled":
return Optional.ofNullable(clazz.cast(healthCheckEnabled()));
case "HealthCheckIntervalSeconds":
return Optional.ofNullable(clazz.cast(healthCheckIntervalSeconds()));
case "HealthCheckTimeoutSeconds":
return Optional.ofNullable(clazz.cast(healthCheckTimeoutSeconds()));
case "HealthyThresholdCount":
return Optional.ofNullable(clazz.cast(healthyThresholdCount()));
case "UnhealthyThresholdCount":
return Optional.ofNullable(clazz.cast(unhealthyThresholdCount()));
case "HealthCheckPath":
return Optional.ofNullable(clazz.cast(healthCheckPath()));
case "Matcher":
return Optional.ofNullable(clazz.cast(matcher()));
case "LoadBalancerArns":
return Optional.ofNullable(clazz.cast(loadBalancerArns()));
case "TargetType":
return Optional.ofNullable(clazz.cast(targetTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function