software.amazon.awssdk.services.vpclattice.model.TargetSummary Maven / Gradle / Ivy
Show all versions of vpclattice 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.vpclattice.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;
/**
*
* Summary information about a target.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TargetSummary implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(TargetSummary::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(TargetSummary::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("port").build()).build();
private static final SdkField REASON_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("reasonCode").getter(getter(TargetSummary::reasonCode)).setter(setter(Builder::reasonCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("reasonCode").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(TargetSummary::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, PORT_FIELD,
REASON_CODE_FIELD, STATUS_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final Integer port;
private final String reasonCode;
private final String status;
private TargetSummary(BuilderImpl builder) {
this.id = builder.id;
this.port = builder.port;
this.reasonCode = builder.reasonCode;
this.status = builder.status;
}
/**
*
* The ID of the target. If the target group type is INSTANCE
, this is an instance ID. If the target
* group type is IP
, this is an IP address. If the target group type is LAMBDA
, this is
* the ARN of a Lambda function. If the target type is ALB
, this is the ARN of an Application Load
* Balancer.
*
*
* @return The ID of the target. If the target group type is INSTANCE
, this is an instance ID. If the
* target group type is IP
, this is an IP address. If the target group type is
* LAMBDA
, this is the ARN of a Lambda function. If the target type is ALB
, this
* is the ARN of an Application Load Balancer.
*/
public final String id() {
return id;
}
/**
*
* The port on which the target is listening.
*
*
* @return The port on which the target is listening.
*/
public final Integer port() {
return port;
}
/**
*
* The code for why the target status is what it is.
*
*
* @return The code for why the target status is what it is.
*/
public final String reasonCode() {
return reasonCode;
}
/**
*
* The status of the target.
*
*
* -
*
* DRAINING
: The target is being deregistered. No new connections are sent to this target while current
* connections are being drained. The default draining time is 5 minutes.
*
*
* -
*
* UNAVAILABLE
: Health checks are unavailable for the target group.
*
*
* -
*
* HEALTHY
: The target is healthy.
*
*
* -
*
* UNHEALTHY
: The target is unhealthy.
*
*
* -
*
* INITIAL
: Initial health checks on the target are being performed.
*
*
* -
*
* UNUSED
: Target group is not used in a service.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link TargetStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the target.
*
* -
*
* DRAINING
: The target is being deregistered. No new connections are sent to this target while
* current connections are being drained. The default draining time is 5 minutes.
*
*
* -
*
* UNAVAILABLE
: Health checks are unavailable for the target group.
*
*
* -
*
* HEALTHY
: The target is healthy.
*
*
* -
*
* UNHEALTHY
: The target is unhealthy.
*
*
* -
*
* INITIAL
: Initial health checks on the target are being performed.
*
*
* -
*
* UNUSED
: Target group is not used in a service.
*
*
* @see TargetStatus
*/
public final TargetStatus status() {
return TargetStatus.fromValue(status);
}
/**
*
* The status of the target.
*
*
* -
*
* DRAINING
: The target is being deregistered. No new connections are sent to this target while current
* connections are being drained. The default draining time is 5 minutes.
*
*
* -
*
* UNAVAILABLE
: Health checks are unavailable for the target group.
*
*
* -
*
* HEALTHY
: The target is healthy.
*
*
* -
*
* UNHEALTHY
: The target is unhealthy.
*
*
* -
*
* INITIAL
: Initial health checks on the target are being performed.
*
*
* -
*
* UNUSED
: Target group is not used in a service.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link TargetStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the target.
*
* -
*
* DRAINING
: The target is being deregistered. No new connections are sent to this target while
* current connections are being drained. The default draining time is 5 minutes.
*
*
* -
*
* UNAVAILABLE
: Health checks are unavailable for the target group.
*
*
* -
*
* HEALTHY
: The target is healthy.
*
*
* -
*
* UNHEALTHY
: The target is unhealthy.
*
*
* -
*
* INITIAL
: Initial health checks on the target are being performed.
*
*
* -
*
* UNUSED
: Target group is not used in a service.
*
*
* @see TargetStatus
*/
public final String statusAsString() {
return status;
}
@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(reasonCode());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
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 TargetSummary)) {
return false;
}
TargetSummary other = (TargetSummary) obj;
return Objects.equals(id(), other.id()) && Objects.equals(port(), other.port())
&& Objects.equals(reasonCode(), other.reasonCode()) && Objects.equals(statusAsString(), other.statusAsString());
}
/**
* 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("TargetSummary").add("Id", id()).add("Port", port()).add("ReasonCode", reasonCode())
.add("Status", statusAsString()).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 "reasonCode":
return Optional.ofNullable(clazz.cast(reasonCode()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function