software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetDescription 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.elasticloadbalancingv2.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.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;
/**
*
* Information about a target.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TargetDescription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(TargetDescription::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("Port")
.getter(getter(TargetDescription::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Port").build()).build();
private static final SdkField AVAILABILITY_ZONE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AvailabilityZone").getter(getter(TargetDescription::availabilityZone))
.setter(setter(Builder::availabilityZone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AvailabilityZone").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, PORT_FIELD,
AVAILABILITY_ZONE_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final Integer port;
private final String availabilityZone;
private TargetDescription(BuilderImpl builder) {
this.id = builder.id;
this.port = builder.port;
this.availabilityZone = builder.availabilityZone;
}
/**
*
* The ID of the target. If the target type of the target group is instance
, specify an instance ID. If
* the target type is ip
, specify an IP address. If the target type is lambda
, specify the
* ARN of the Lambda function. If the target type is alb
, specify the ARN of the Application Load
* Balancer target.
*
*
* @return The ID of the target. If the target type of the target group is instance
, specify an
* instance ID. If the target type is ip
, specify an IP address. If the target type is
* lambda
, specify the ARN of the Lambda function. If the target type is alb
,
* specify the ARN of the Application Load Balancer target.
*/
public final String id() {
return id;
}
/**
*
* The port on which the target is listening. If the target group protocol is GENEVE, the supported port is 6081. If
* the target type is alb
, the targeted Application Load Balancer must have at least one listener whose
* port matches the target group port. Not used if the target is a Lambda function.
*
*
* @return The port on which the target is listening. If the target group protocol is GENEVE, the supported port is
* 6081. If the target type is alb
, the targeted Application Load Balancer must have at least
* one listener whose port matches the target group port. Not used if the target is a Lambda function.
*/
public final Integer port() {
return port;
}
/**
*
* An Availability Zone or all
. This determines whether the target receives traffic from the load
* balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.
*
*
* For Application Load Balancer target groups, the specified Availability Zone value is only applicable when
* cross-zone load balancing is off. Otherwise the parameter is ignored and treated as all
.
*
*
* This parameter is not supported if the target type of the target group is instance
or
* alb
.
*
*
* If the target type is ip
and the IP address is in a subnet of the VPC for the target group, the
* Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC,
* this parameter is required.
*
*
* For Application Load Balancer target groups with cross-zone load balancing off, if the target type is
* ip
and the IP address is outside of the VPC for the target group, this should be an Availability
* Zone inside the VPC for the target group.
*
*
* If the target type is lambda
, this parameter is optional and the only supported value is
* all
.
*
*
* @return An Availability Zone or all
. This determines whether the target receives traffic from the
* load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the
* load balancer.
*
* For Application Load Balancer target groups, the specified Availability Zone value is only applicable
* when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as all
* .
*
*
* This parameter is not supported if the target type of the target group is instance
or
* alb
.
*
*
* If the target type is ip
and the IP address is in a subnet of the VPC for the target group,
* the Availability Zone is automatically detected and this parameter is optional. If the IP address is
* outside the VPC, this parameter is required.
*
*
* For Application Load Balancer target groups with cross-zone load balancing off, if the target type is
* ip
and the IP address is outside of the VPC for the target group, this should be an
* Availability Zone inside the VPC for the target group.
*
*
* If the target type is lambda
, this parameter is optional and the only supported value is
* all
.
*/
public final String availabilityZone() {
return availabilityZone;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(port());
hashCode = 31 * hashCode + Objects.hashCode(availabilityZone());
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 TargetDescription)) {
return false;
}
TargetDescription other = (TargetDescription) obj;
return Objects.equals(id(), other.id()) && Objects.equals(port(), other.port())
&& Objects.equals(availabilityZone(), other.availabilityZone());
}
/**
* 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("TargetDescription").add("Id", id()).add("Port", port())
.add("AvailabilityZone", availabilityZone()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Port":
return Optional.ofNullable(clazz.cast(port()));
case "AvailabilityZone":
return Optional.ofNullable(clazz.cast(availabilityZone()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* For Application Load Balancer target groups, the specified Availability Zone value is only applicable
* when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as
* all
.
*
*
* This parameter is not supported if the target type of the target group is instance
or
* alb
.
*
*
* If the target type is ip
and the IP address is in a subnet of the VPC for the target
* group, the Availability Zone is automatically detected and this parameter is optional. If the IP
* address is outside the VPC, this parameter is required.
*
*
* For Application Load Balancer target groups with cross-zone load balancing off, if the target type is
* ip
and the IP address is outside of the VPC for the target group, this should be an
* Availability Zone inside the VPC for the target group.
*
*
* If the target type is lambda
, this parameter is optional and the only supported value is
* all
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder availabilityZone(String availabilityZone);
}
static final class BuilderImpl implements Builder {
private String id;
private Integer port;
private String availabilityZone;
private BuilderImpl() {
}
private BuilderImpl(TargetDescription model) {
id(model.id);
port(model.port);
availabilityZone(model.availabilityZone);
}
public final String getId() {
return id;
}
public final void setId(String id) {
this.id = id;
}
@Override
public final Builder id(String id) {
this.id = id;
return this;
}
public final Integer getPort() {
return port;
}
public final void setPort(Integer port) {
this.port = port;
}
@Override
public final Builder port(Integer port) {
this.port = port;
return this;
}
public final String getAvailabilityZone() {
return availabilityZone;
}
public final void setAvailabilityZone(String availabilityZone) {
this.availabilityZone = availabilityZone;
}
@Override
public final Builder availabilityZone(String availabilityZone) {
this.availabilityZone = availabilityZone;
return this;
}
@Override
public TargetDescription build() {
return new TargetDescription(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}