software.amazon.awssdk.services.globalaccelerator.model.EndpointGroup Maven / Gradle / Ivy
Show all versions of globalaccelerator 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.globalaccelerator.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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A complex type for the endpoint group. An AWS Region can have only one endpoint group for a specific listener.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EndpointGroup implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ENDPOINT_GROUP_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointGroup::endpointGroupArn)).setter(setter(Builder::endpointGroupArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndpointGroupArn").build()).build();
private static final SdkField ENDPOINT_GROUP_REGION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointGroup::endpointGroupRegion)).setter(setter(Builder::endpointGroupRegion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndpointGroupRegion").build())
.build();
private static final SdkField> ENDPOINT_DESCRIPTIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(EndpointGroup::endpointDescriptions))
.setter(setter(Builder::endpointDescriptions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndpointDescriptions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(EndpointDescription::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TRAFFIC_DIAL_PERCENTAGE_FIELD = SdkField. builder(MarshallingType.FLOAT)
.getter(getter(EndpointGroup::trafficDialPercentage)).setter(setter(Builder::trafficDialPercentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TrafficDialPercentage").build())
.build();
private static final SdkField HEALTH_CHECK_PORT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EndpointGroup::healthCheckPort)).setter(setter(Builder::healthCheckPort))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckPort").build()).build();
private static final SdkField HEALTH_CHECK_PROTOCOL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointGroup::healthCheckProtocolAsString)).setter(setter(Builder::healthCheckProtocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckProtocol").build())
.build();
private static final SdkField HEALTH_CHECK_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointGroup::healthCheckPath)).setter(setter(Builder::healthCheckPath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckPath").build()).build();
private static final SdkField HEALTH_CHECK_INTERVAL_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.getter(getter(EndpointGroup::healthCheckIntervalSeconds))
.setter(setter(Builder::healthCheckIntervalSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthCheckIntervalSeconds").build())
.build();
private static final SdkField THRESHOLD_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EndpointGroup::thresholdCount)).setter(setter(Builder::thresholdCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ThresholdCount").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENDPOINT_GROUP_ARN_FIELD,
ENDPOINT_GROUP_REGION_FIELD, ENDPOINT_DESCRIPTIONS_FIELD, TRAFFIC_DIAL_PERCENTAGE_FIELD, HEALTH_CHECK_PORT_FIELD,
HEALTH_CHECK_PROTOCOL_FIELD, HEALTH_CHECK_PATH_FIELD, HEALTH_CHECK_INTERVAL_SECONDS_FIELD, THRESHOLD_COUNT_FIELD));
private static final long serialVersionUID = 1L;
private final String endpointGroupArn;
private final String endpointGroupRegion;
private final List endpointDescriptions;
private final Float trafficDialPercentage;
private final Integer healthCheckPort;
private final String healthCheckProtocol;
private final String healthCheckPath;
private final Integer healthCheckIntervalSeconds;
private final Integer thresholdCount;
private EndpointGroup(BuilderImpl builder) {
this.endpointGroupArn = builder.endpointGroupArn;
this.endpointGroupRegion = builder.endpointGroupRegion;
this.endpointDescriptions = builder.endpointDescriptions;
this.trafficDialPercentage = builder.trafficDialPercentage;
this.healthCheckPort = builder.healthCheckPort;
this.healthCheckProtocol = builder.healthCheckProtocol;
this.healthCheckPath = builder.healthCheckPath;
this.healthCheckIntervalSeconds = builder.healthCheckIntervalSeconds;
this.thresholdCount = builder.thresholdCount;
}
/**
*
* The Amazon Resource Name (ARN) of the endpoint group.
*
*
* @return The Amazon Resource Name (ARN) of the endpoint group.
*/
public String endpointGroupArn() {
return endpointGroupArn;
}
/**
*
* The AWS Region that this endpoint group belongs.
*
*
* @return The AWS Region that this endpoint group belongs.
*/
public String endpointGroupRegion() {
return endpointGroupRegion;
}
/**
* Returns true if the EndpointDescriptions property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasEndpointDescriptions() {
return endpointDescriptions != null && !(endpointDescriptions instanceof SdkAutoConstructList);
}
/**
*
* The list of endpoint objects.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasEndpointDescriptions()} to see if a value was sent in this field.
*
*
* @return The list of endpoint objects.
*/
public List endpointDescriptions() {
return endpointDescriptions;
}
/**
*
* The percentage of traffic to send to an AWS Region. Additional traffic is distributed to other endpoint groups
* for this listener.
*
*
* Use this action to increase (dial up) or decrease (dial down) traffic to a specific Region. The percentage is
* applied to the traffic that would otherwise have been routed to the Region based on optimal routing.
*
*
* The default value is 100.
*
*
* @return The percentage of traffic to send to an AWS Region. Additional traffic is distributed to other endpoint
* groups for this listener.
*
* Use this action to increase (dial up) or decrease (dial down) traffic to a specific Region. The
* percentage is applied to the traffic that would otherwise have been routed to the Region based on optimal
* routing.
*
*
* The default value is 100.
*/
public Float trafficDialPercentage() {
return trafficDialPercentage;
}
/**
*
* The port that Global Accelerator uses to perform health checks on endpoints that are part of this endpoint group.
*
*
* The default port is the port for the listener that this endpoint group is associated with. If the listener port
* is a list, Global Accelerator uses the first specified port in the list of ports.
*
*
* @return The port that Global Accelerator uses to perform health checks on endpoints that are part of this
* endpoint group.
*
* The default port is the port for the listener that this endpoint group is associated with. If the
* listener port is a list, Global Accelerator uses the first specified port in the list of ports.
*/
public Integer healthCheckPort() {
return healthCheckPort;
}
/**
*
* The protocol that Global Accelerator uses to perform health checks on endpoints that are part of this endpoint
* group. The default value is TCP.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #healthCheckProtocol} will return {@link HealthCheckProtocol#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #healthCheckProtocolAsString}.
*
*
* @return The protocol that Global Accelerator uses to perform health checks on endpoints that are part of this
* endpoint group. The default value is TCP.
* @see HealthCheckProtocol
*/
public HealthCheckProtocol healthCheckProtocol() {
return HealthCheckProtocol.fromValue(healthCheckProtocol);
}
/**
*
* The protocol that Global Accelerator uses to perform health checks on endpoints that are part of this endpoint
* group. The default value is TCP.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #healthCheckProtocol} will return {@link HealthCheckProtocol#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #healthCheckProtocolAsString}.
*
*
* @return The protocol that Global Accelerator uses to perform health checks on endpoints that are part of this
* endpoint group. The default value is TCP.
* @see HealthCheckProtocol
*/
public String healthCheckProtocolAsString() {
return healthCheckProtocol;
}
/**
*
* If the protocol is HTTP/S, then this value provides the ping path that Global Accelerator uses for the
* destination on the endpoints for health checks. The default is slash (/).
*
*
* @return If the protocol is HTTP/S, then this value provides the ping path that Global Accelerator uses for the
* destination on the endpoints for health checks. The default is slash (/).
*/
public String healthCheckPath() {
return healthCheckPath;
}
/**
*
* The time—10 seconds or 30 seconds—between health checks for each endpoint. The default value is 30.
*
*
* @return The time—10 seconds or 30 seconds—between health checks for each endpoint. The default value is 30.
*/
public Integer healthCheckIntervalSeconds() {
return healthCheckIntervalSeconds;
}
/**
*
* The number of consecutive health checks required to set the state of a healthy endpoint to unhealthy, or to set
* an unhealthy endpoint to healthy. The default value is 3.
*
*
* @return The number of consecutive health checks required to set the state of a healthy endpoint to unhealthy, or
* to set an unhealthy endpoint to healthy. The default value is 3.
*/
public Integer thresholdCount() {
return thresholdCount;
}
@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(endpointGroupArn());
hashCode = 31 * hashCode + Objects.hashCode(endpointGroupRegion());
hashCode = 31 * hashCode + Objects.hashCode(endpointDescriptions());
hashCode = 31 * hashCode + Objects.hashCode(trafficDialPercentage());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckPort());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckProtocolAsString());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckPath());
hashCode = 31 * hashCode + Objects.hashCode(healthCheckIntervalSeconds());
hashCode = 31 * hashCode + Objects.hashCode(thresholdCount());
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 EndpointGroup)) {
return false;
}
EndpointGroup other = (EndpointGroup) obj;
return Objects.equals(endpointGroupArn(), other.endpointGroupArn())
&& Objects.equals(endpointGroupRegion(), other.endpointGroupRegion())
&& Objects.equals(endpointDescriptions(), other.endpointDescriptions())
&& Objects.equals(trafficDialPercentage(), other.trafficDialPercentage())
&& Objects.equals(healthCheckPort(), other.healthCheckPort())
&& Objects.equals(healthCheckProtocolAsString(), other.healthCheckProtocolAsString())
&& Objects.equals(healthCheckPath(), other.healthCheckPath())
&& Objects.equals(healthCheckIntervalSeconds(), other.healthCheckIntervalSeconds())
&& Objects.equals(thresholdCount(), other.thresholdCount());
}
/**
* 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("EndpointGroup").add("EndpointGroupArn", endpointGroupArn())
.add("EndpointGroupRegion", endpointGroupRegion()).add("EndpointDescriptions", endpointDescriptions())
.add("TrafficDialPercentage", trafficDialPercentage()).add("HealthCheckPort", healthCheckPort())
.add("HealthCheckProtocol", healthCheckProtocolAsString()).add("HealthCheckPath", healthCheckPath())
.add("HealthCheckIntervalSeconds", healthCheckIntervalSeconds()).add("ThresholdCount", thresholdCount()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EndpointGroupArn":
return Optional.ofNullable(clazz.cast(endpointGroupArn()));
case "EndpointGroupRegion":
return Optional.ofNullable(clazz.cast(endpointGroupRegion()));
case "EndpointDescriptions":
return Optional.ofNullable(clazz.cast(endpointDescriptions()));
case "TrafficDialPercentage":
return Optional.ofNullable(clazz.cast(trafficDialPercentage()));
case "HealthCheckPort":
return Optional.ofNullable(clazz.cast(healthCheckPort()));
case "HealthCheckProtocol":
return Optional.ofNullable(clazz.cast(healthCheckProtocolAsString()));
case "HealthCheckPath":
return Optional.ofNullable(clazz.cast(healthCheckPath()));
case "HealthCheckIntervalSeconds":
return Optional.ofNullable(clazz.cast(healthCheckIntervalSeconds()));
case "ThresholdCount":
return Optional.ofNullable(clazz.cast(thresholdCount()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function