software.amazon.awssdk.services.elasticloadbalancingv2.model.LoadBalancer 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.time.Instant;
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;
/**
*
* Information about a load balancer.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LoadBalancer implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField LOAD_BALANCER_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LoadBalancerArn").getter(getter(LoadBalancer::loadBalancerArn)).setter(setter(Builder::loadBalancerArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LoadBalancerArn").build()).build();
private static final SdkField DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DNSName").getter(getter(LoadBalancer::dnsName)).setter(setter(Builder::dnsName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DNSName").build()).build();
private static final SdkField CANONICAL_HOSTED_ZONE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CanonicalHostedZoneId").getter(getter(LoadBalancer::canonicalHostedZoneId))
.setter(setter(Builder::canonicalHostedZoneId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CanonicalHostedZoneId").build())
.build();
private static final SdkField CREATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTime").getter(getter(LoadBalancer::createdTime)).setter(setter(Builder::createdTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTime").build()).build();
private static final SdkField LOAD_BALANCER_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LoadBalancerName").getter(getter(LoadBalancer::loadBalancerName))
.setter(setter(Builder::loadBalancerName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LoadBalancerName").build()).build();
private static final SdkField SCHEME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Scheme")
.getter(getter(LoadBalancer::schemeAsString)).setter(setter(Builder::scheme))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Scheme").build()).build();
private static final SdkField VPC_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("VpcId")
.getter(getter(LoadBalancer::vpcId)).setter(setter(Builder::vpcId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VpcId").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("State").getter(getter(LoadBalancer::state)).setter(setter(Builder::state))
.constructor(LoadBalancerState::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(LoadBalancer::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField> AVAILABILITY_ZONES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AvailabilityZones")
.getter(getter(LoadBalancer::availabilityZones))
.setter(setter(Builder::availabilityZones))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AvailabilityZones").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AvailabilityZone::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> SECURITY_GROUPS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SecurityGroups")
.getter(getter(LoadBalancer::securityGroups))
.setter(setter(Builder::securityGroups))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecurityGroups").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 IP_ADDRESS_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("IpAddressType").getter(getter(LoadBalancer::ipAddressTypeAsString))
.setter(setter(Builder::ipAddressType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IpAddressType").build()).build();
private static final SdkField CUSTOMER_OWNED_IPV4_POOL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CustomerOwnedIpv4Pool").getter(getter(LoadBalancer::customerOwnedIpv4Pool))
.setter(setter(Builder::customerOwnedIpv4Pool))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomerOwnedIpv4Pool").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LOAD_BALANCER_ARN_FIELD,
DNS_NAME_FIELD, CANONICAL_HOSTED_ZONE_ID_FIELD, CREATED_TIME_FIELD, LOAD_BALANCER_NAME_FIELD, SCHEME_FIELD,
VPC_ID_FIELD, STATE_FIELD, TYPE_FIELD, AVAILABILITY_ZONES_FIELD, SECURITY_GROUPS_FIELD, IP_ADDRESS_TYPE_FIELD,
CUSTOMER_OWNED_IPV4_POOL_FIELD));
private static final long serialVersionUID = 1L;
private final String loadBalancerArn;
private final String dnsName;
private final String canonicalHostedZoneId;
private final Instant createdTime;
private final String loadBalancerName;
private final String scheme;
private final String vpcId;
private final LoadBalancerState state;
private final String type;
private final List availabilityZones;
private final List securityGroups;
private final String ipAddressType;
private final String customerOwnedIpv4Pool;
private LoadBalancer(BuilderImpl builder) {
this.loadBalancerArn = builder.loadBalancerArn;
this.dnsName = builder.dnsName;
this.canonicalHostedZoneId = builder.canonicalHostedZoneId;
this.createdTime = builder.createdTime;
this.loadBalancerName = builder.loadBalancerName;
this.scheme = builder.scheme;
this.vpcId = builder.vpcId;
this.state = builder.state;
this.type = builder.type;
this.availabilityZones = builder.availabilityZones;
this.securityGroups = builder.securityGroups;
this.ipAddressType = builder.ipAddressType;
this.customerOwnedIpv4Pool = builder.customerOwnedIpv4Pool;
}
/**
*
* The Amazon Resource Name (ARN) of the load balancer.
*
*
* @return The Amazon Resource Name (ARN) of the load balancer.
*/
public final String loadBalancerArn() {
return loadBalancerArn;
}
/**
*
* The public DNS name of the load balancer.
*
*
* @return The public DNS name of the load balancer.
*/
public final String dnsName() {
return dnsName;
}
/**
*
* The ID of the Amazon Route 53 hosted zone associated with the load balancer.
*
*
* @return The ID of the Amazon Route 53 hosted zone associated with the load balancer.
*/
public final String canonicalHostedZoneId() {
return canonicalHostedZoneId;
}
/**
*
* The date and time the load balancer was created.
*
*
* @return The date and time the load balancer was created.
*/
public final Instant createdTime() {
return createdTime;
}
/**
*
* The name of the load balancer.
*
*
* @return The name of the load balancer.
*/
public final String loadBalancerName() {
return loadBalancerName;
}
/**
*
* The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an Internet-facing load
* balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet-facing load
* balancers can route requests from clients over the internet.
*
*
* The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load balancer
* is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load balancers can route
* requests only from clients with access to the VPC for the load balancer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #scheme} will
* return {@link LoadBalancerSchemeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #schemeAsString}.
*
*
* @return The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an
* Internet-facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore,
* Internet-facing load balancers can route requests from clients over the internet.
*
* The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load
* balancer is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load
* balancers can route requests only from clients with access to the VPC for the load balancer.
* @see LoadBalancerSchemeEnum
*/
public final LoadBalancerSchemeEnum scheme() {
return LoadBalancerSchemeEnum.fromValue(scheme);
}
/**
*
* The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an Internet-facing load
* balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet-facing load
* balancers can route requests from clients over the internet.
*
*
* The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load balancer
* is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load balancers can route
* requests only from clients with access to the VPC for the load balancer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #scheme} will
* return {@link LoadBalancerSchemeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #schemeAsString}.
*
*
* @return The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an
* Internet-facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore,
* Internet-facing load balancers can route requests from clients over the internet.
*
* The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load
* balancer is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load
* balancers can route requests only from clients with access to the VPC for the load balancer.
* @see LoadBalancerSchemeEnum
*/
public final String schemeAsString() {
return scheme;
}
/**
*
* The ID of the VPC for the load balancer.
*
*
* @return The ID of the VPC for the load balancer.
*/
public final String vpcId() {
return vpcId;
}
/**
*
* The state of the load balancer.
*
*
* @return The state of the load balancer.
*/
public final LoadBalancerState state() {
return state;
}
/**
*
* The type of load balancer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link LoadBalancerTypeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of load balancer.
* @see LoadBalancerTypeEnum
*/
public final LoadBalancerTypeEnum type() {
return LoadBalancerTypeEnum.fromValue(type);
}
/**
*
* The type of load balancer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link LoadBalancerTypeEnum#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of load balancer.
* @see LoadBalancerTypeEnum
*/
public final String typeAsString() {
return type;
}
/**
* For responses, this returns true if the service returned a value for the AvailabilityZones property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasAvailabilityZones() {
return availabilityZones != null && !(availabilityZones instanceof SdkAutoConstructList);
}
/**
*
* The subnets for the load balancer.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasAvailabilityZones} method.
*
*
* @return The subnets for the load balancer.
*/
public final List availabilityZones() {
return availabilityZones;
}
/**
* For responses, this returns true if the service returned a value for the SecurityGroups property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasSecurityGroups() {
return securityGroups != null && !(securityGroups instanceof SdkAutoConstructList);
}
/**
*
* The IDs of the security groups for the load balancer.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSecurityGroups} method.
*
*
* @return The IDs of the security groups for the load balancer.
*/
public final List securityGroups() {
return securityGroups;
}
/**
*
* The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4
* (for IPv4 addresses) and dualstack
(for IPv4 and IPv6 addresses).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #ipAddressType}
* will return {@link IpAddressType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #ipAddressTypeAsString}.
*
*
* @return The type of IP addresses used by the subnets for your load balancer. The possible values are
* ipv4
(for IPv4 addresses) and dualstack
(for IPv4 and IPv6 addresses).
* @see IpAddressType
*/
public final IpAddressType ipAddressType() {
return IpAddressType.fromValue(ipAddressType);
}
/**
*
* The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4
* (for IPv4 addresses) and dualstack
(for IPv4 and IPv6 addresses).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #ipAddressType}
* will return {@link IpAddressType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #ipAddressTypeAsString}.
*
*
* @return The type of IP addresses used by the subnets for your load balancer. The possible values are
* ipv4
(for IPv4 addresses) and dualstack
(for IPv4 and IPv6 addresses).
* @see IpAddressType
*/
public final String ipAddressTypeAsString() {
return ipAddressType;
}
/**
*
* [Application Load Balancers on Outposts] The ID of the customer-owned address pool.
*
*
* @return [Application Load Balancers on Outposts] The ID of the customer-owned address pool.
*/
public final String customerOwnedIpv4Pool() {
return customerOwnedIpv4Pool;
}
@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(loadBalancerArn());
hashCode = 31 * hashCode + Objects.hashCode(dnsName());
hashCode = 31 * hashCode + Objects.hashCode(canonicalHostedZoneId());
hashCode = 31 * hashCode + Objects.hashCode(createdTime());
hashCode = 31 * hashCode + Objects.hashCode(loadBalancerName());
hashCode = 31 * hashCode + Objects.hashCode(schemeAsString());
hashCode = 31 * hashCode + Objects.hashCode(vpcId());
hashCode = 31 * hashCode + Objects.hashCode(state());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasAvailabilityZones() ? availabilityZones() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasSecurityGroups() ? securityGroups() : null);
hashCode = 31 * hashCode + Objects.hashCode(ipAddressTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(customerOwnedIpv4Pool());
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 LoadBalancer)) {
return false;
}
LoadBalancer other = (LoadBalancer) obj;
return Objects.equals(loadBalancerArn(), other.loadBalancerArn()) && Objects.equals(dnsName(), other.dnsName())
&& Objects.equals(canonicalHostedZoneId(), other.canonicalHostedZoneId())
&& Objects.equals(createdTime(), other.createdTime())
&& Objects.equals(loadBalancerName(), other.loadBalancerName())
&& Objects.equals(schemeAsString(), other.schemeAsString()) && Objects.equals(vpcId(), other.vpcId())
&& Objects.equals(state(), other.state()) && Objects.equals(typeAsString(), other.typeAsString())
&& hasAvailabilityZones() == other.hasAvailabilityZones()
&& Objects.equals(availabilityZones(), other.availabilityZones())
&& hasSecurityGroups() == other.hasSecurityGroups() && Objects.equals(securityGroups(), other.securityGroups())
&& Objects.equals(ipAddressTypeAsString(), other.ipAddressTypeAsString())
&& Objects.equals(customerOwnedIpv4Pool(), other.customerOwnedIpv4Pool());
}
/**
* 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("LoadBalancer").add("LoadBalancerArn", loadBalancerArn()).add("DNSName", dnsName())
.add("CanonicalHostedZoneId", canonicalHostedZoneId()).add("CreatedTime", createdTime())
.add("LoadBalancerName", loadBalancerName()).add("Scheme", schemeAsString()).add("VpcId", vpcId())
.add("State", state()).add("Type", typeAsString())
.add("AvailabilityZones", hasAvailabilityZones() ? availabilityZones() : null)
.add("SecurityGroups", hasSecurityGroups() ? securityGroups() : null)
.add("IpAddressType", ipAddressTypeAsString()).add("CustomerOwnedIpv4Pool", customerOwnedIpv4Pool()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "LoadBalancerArn":
return Optional.ofNullable(clazz.cast(loadBalancerArn()));
case "DNSName":
return Optional.ofNullable(clazz.cast(dnsName()));
case "CanonicalHostedZoneId":
return Optional.ofNullable(clazz.cast(canonicalHostedZoneId()));
case "CreatedTime":
return Optional.ofNullable(clazz.cast(createdTime()));
case "LoadBalancerName":
return Optional.ofNullable(clazz.cast(loadBalancerName()));
case "Scheme":
return Optional.ofNullable(clazz.cast(schemeAsString()));
case "VpcId":
return Optional.ofNullable(clazz.cast(vpcId()));
case "State":
return Optional.ofNullable(clazz.cast(state()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "AvailabilityZones":
return Optional.ofNullable(clazz.cast(availabilityZones()));
case "SecurityGroups":
return Optional.ofNullable(clazz.cast(securityGroups()));
case "IpAddressType":
return Optional.ofNullable(clazz.cast(ipAddressTypeAsString()));
case "CustomerOwnedIpv4Pool":
return Optional.ofNullable(clazz.cast(customerOwnedIpv4Pool()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function