software.amazon.awssdk.services.appmesh.model.HealthCheckPolicy Maven / Gradle / Ivy
Show all versions of appmesh 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.appmesh.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;
/**
*
* An object that represents the health check policy for a virtual node's listener.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HealthCheckPolicy implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField HEALTHY_THRESHOLD_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(HealthCheckPolicy::healthyThreshold)).setter(setter(Builder::healthyThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("healthyThreshold").build()).build();
private static final SdkField INTERVAL_MILLIS_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(HealthCheckPolicy::intervalMillis)).setter(setter(Builder::intervalMillis))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("intervalMillis").build()).build();
private static final SdkField PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(HealthCheckPolicy::path)).setter(setter(Builder::path))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("path").build()).build();
private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(HealthCheckPolicy::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("port").build()).build();
private static final SdkField PROTOCOL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(HealthCheckPolicy::protocolAsString)).setter(setter(Builder::protocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("protocol").build()).build();
private static final SdkField TIMEOUT_MILLIS_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(HealthCheckPolicy::timeoutMillis)).setter(setter(Builder::timeoutMillis))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("timeoutMillis").build()).build();
private static final SdkField UNHEALTHY_THRESHOLD_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(HealthCheckPolicy::unhealthyThreshold)).setter(setter(Builder::unhealthyThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("unhealthyThreshold").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(HEALTHY_THRESHOLD_FIELD,
INTERVAL_MILLIS_FIELD, PATH_FIELD, PORT_FIELD, PROTOCOL_FIELD, TIMEOUT_MILLIS_FIELD, UNHEALTHY_THRESHOLD_FIELD));
private static final long serialVersionUID = 1L;
private final Integer healthyThreshold;
private final Long intervalMillis;
private final String path;
private final Integer port;
private final String protocol;
private final Long timeoutMillis;
private final Integer unhealthyThreshold;
private HealthCheckPolicy(BuilderImpl builder) {
this.healthyThreshold = builder.healthyThreshold;
this.intervalMillis = builder.intervalMillis;
this.path = builder.path;
this.port = builder.port;
this.protocol = builder.protocol;
this.timeoutMillis = builder.timeoutMillis;
this.unhealthyThreshold = builder.unhealthyThreshold;
}
/**
*
* The number of consecutive successful health checks that must occur before declaring listener healthy.
*
*
* @return The number of consecutive successful health checks that must occur before declaring listener healthy.
*/
public Integer healthyThreshold() {
return healthyThreshold;
}
/**
*
* The time period in milliseconds between each health check execution.
*
*
* @return The time period in milliseconds between each health check execution.
*/
public Long intervalMillis() {
return intervalMillis;
}
/**
*
* The destination path for the health check request. This value is only used if the specified protocol is HTTP or
* HTTP/2. For any other protocol, this value is ignored.
*
*
* @return The destination path for the health check request. This value is only used if the specified protocol is
* HTTP or HTTP/2. For any other protocol, this value is ignored.
*/
public String path() {
return path;
}
/**
*
* The destination port for the health check request. This port must match the port defined in the
* PortMapping for the listener.
*
*
* @return The destination port for the health check request. This port must match the port defined in the
* PortMapping for the listener.
*/
public Integer port() {
return port;
}
/**
*
* The protocol for the health check request. If you specify grpc
, then your service must conform to
* the GRPC Health Checking Protocol.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #protocol} will
* return {@link PortProtocol#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #protocolAsString}.
*
*
* @return The protocol for the health check request. If you specify grpc
, then your service must
* conform to the GRPC Health
* Checking Protocol.
* @see PortProtocol
*/
public PortProtocol protocol() {
return PortProtocol.fromValue(protocol);
}
/**
*
* The protocol for the health check request. If you specify grpc
, then your service must conform to
* the GRPC Health Checking Protocol.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #protocol} will
* return {@link PortProtocol#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #protocolAsString}.
*
*
* @return The protocol for the health check request. If you specify grpc
, then your service must
* conform to the GRPC Health
* Checking Protocol.
* @see PortProtocol
*/
public String protocolAsString() {
return protocol;
}
/**
*
* The amount of time to wait when receiving a response from the health check, in milliseconds.
*
*
* @return The amount of time to wait when receiving a response from the health check, in milliseconds.
*/
public Long timeoutMillis() {
return timeoutMillis;
}
/**
*
* The number of consecutive failed health checks that must occur before declaring a virtual node unhealthy.
*
*
* @return The number of consecutive failed health checks that must occur before declaring a virtual node unhealthy.
*/
public Integer unhealthyThreshold() {
return unhealthyThreshold;
}
@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(healthyThreshold());
hashCode = 31 * hashCode + Objects.hashCode(intervalMillis());
hashCode = 31 * hashCode + Objects.hashCode(path());
hashCode = 31 * hashCode + Objects.hashCode(port());
hashCode = 31 * hashCode + Objects.hashCode(protocolAsString());
hashCode = 31 * hashCode + Objects.hashCode(timeoutMillis());
hashCode = 31 * hashCode + Objects.hashCode(unhealthyThreshold());
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 HealthCheckPolicy)) {
return false;
}
HealthCheckPolicy other = (HealthCheckPolicy) obj;
return Objects.equals(healthyThreshold(), other.healthyThreshold())
&& Objects.equals(intervalMillis(), other.intervalMillis()) && Objects.equals(path(), other.path())
&& Objects.equals(port(), other.port()) && Objects.equals(protocolAsString(), other.protocolAsString())
&& Objects.equals(timeoutMillis(), other.timeoutMillis())
&& Objects.equals(unhealthyThreshold(), other.unhealthyThreshold());
}
/**
* 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("HealthCheckPolicy").add("HealthyThreshold", healthyThreshold())
.add("IntervalMillis", intervalMillis()).add("Path", path()).add("Port", port())
.add("Protocol", protocolAsString()).add("TimeoutMillis", timeoutMillis())
.add("UnhealthyThreshold", unhealthyThreshold()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "healthyThreshold":
return Optional.ofNullable(clazz.cast(healthyThreshold()));
case "intervalMillis":
return Optional.ofNullable(clazz.cast(intervalMillis()));
case "path":
return Optional.ofNullable(clazz.cast(path()));
case "port":
return Optional.ofNullable(clazz.cast(port()));
case "protocol":
return Optional.ofNullable(clazz.cast(protocolAsString()));
case "timeoutMillis":
return Optional.ofNullable(clazz.cast(timeoutMillis()));
case "unhealthyThreshold":
return Optional.ofNullable(clazz.cast(unhealthyThreshold()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function