software.amazon.awssdk.services.elasticbeanstalk.model.DescribeEnvironmentHealthResponse Maven / Gradle / Ivy
Show all versions of elasticbeanstalk 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.elasticbeanstalk.model;
import java.beans.Transient;
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 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;
/**
*
* Health details for an AWS Elastic Beanstalk environment.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DescribeEnvironmentHealthResponse extends ElasticBeanstalkResponse implements
ToCopyableBuilder {
private static final SdkField ENVIRONMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EnvironmentName").getter(getter(DescribeEnvironmentHealthResponse::environmentName))
.setter(setter(Builder::environmentName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnvironmentName").build()).build();
private static final SdkField HEALTH_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("HealthStatus").getter(getter(DescribeEnvironmentHealthResponse::healthStatus))
.setter(setter(Builder::healthStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthStatus").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(DescribeEnvironmentHealthResponse::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField COLOR_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Color")
.getter(getter(DescribeEnvironmentHealthResponse::color)).setter(setter(Builder::color))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Color").build()).build();
private static final SdkField> CAUSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Causes")
.getter(getter(DescribeEnvironmentHealthResponse::causes))
.setter(setter(Builder::causes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Causes").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 APPLICATION_METRICS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ApplicationMetrics")
.getter(getter(DescribeEnvironmentHealthResponse::applicationMetrics)).setter(setter(Builder::applicationMetrics))
.constructor(ApplicationMetrics::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApplicationMetrics").build())
.build();
private static final SdkField INSTANCES_HEALTH_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("InstancesHealth")
.getter(getter(DescribeEnvironmentHealthResponse::instancesHealth)).setter(setter(Builder::instancesHealth))
.constructor(InstanceHealthSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstancesHealth").build()).build();
private static final SdkField REFRESHED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("RefreshedAt").getter(getter(DescribeEnvironmentHealthResponse::refreshedAt))
.setter(setter(Builder::refreshedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RefreshedAt").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENVIRONMENT_NAME_FIELD,
HEALTH_STATUS_FIELD, STATUS_FIELD, COLOR_FIELD, CAUSES_FIELD, APPLICATION_METRICS_FIELD, INSTANCES_HEALTH_FIELD,
REFRESHED_AT_FIELD));
private final String environmentName;
private final String healthStatus;
private final String status;
private final String color;
private final List causes;
private final ApplicationMetrics applicationMetrics;
private final InstanceHealthSummary instancesHealth;
private final Instant refreshedAt;
private DescribeEnvironmentHealthResponse(BuilderImpl builder) {
super(builder);
this.environmentName = builder.environmentName;
this.healthStatus = builder.healthStatus;
this.status = builder.status;
this.color = builder.color;
this.causes = builder.causes;
this.applicationMetrics = builder.applicationMetrics;
this.instancesHealth = builder.instancesHealth;
this.refreshedAt = builder.refreshedAt;
}
/**
*
* The environment's name.
*
*
* @return The environment's name.
*/
public final String environmentName() {
return environmentName;
}
/**
*
* The health
* status of the environment. For example, Ok
.
*
*
* @return The health
* status of the environment. For example, Ok
.
*/
public final String healthStatus() {
return healthStatus;
}
/**
*
* The environment's operational status. Ready
, Launching
, Updating
,
* Terminating
, or Terminated
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link EnvironmentHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The environment's operational status. Ready
, Launching
, Updating
,
* Terminating
, or Terminated
.
* @see EnvironmentHealth
*/
public final EnvironmentHealth status() {
return EnvironmentHealth.fromValue(status);
}
/**
*
* The environment's operational status. Ready
, Launching
, Updating
,
* Terminating
, or Terminated
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link EnvironmentHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The environment's operational status. Ready
, Launching
, Updating
,
* Terminating
, or Terminated
.
* @see EnvironmentHealth
*/
public final String statusAsString() {
return status;
}
/**
*
* The health color
* of the environment.
*
*
* @return The health
* color of the environment.
*/
public final String color() {
return color;
}
/**
* For responses, this returns true if the service returned a value for the Causes 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 hasCauses() {
return causes != null && !(causes instanceof SdkAutoConstructList);
}
/**
*
* Descriptions of the data that contributed to the environment's current health status.
*
*
* 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 #hasCauses} method.
*
*
* @return Descriptions of the data that contributed to the environment's current health status.
*/
public final List causes() {
return causes;
}
/**
*
* Application request metrics for the environment.
*
*
* @return Application request metrics for the environment.
*/
public final ApplicationMetrics applicationMetrics() {
return applicationMetrics;
}
/**
*
* Summary health information for the instances in the environment.
*
*
* @return Summary health information for the instances in the environment.
*/
public final InstanceHealthSummary instancesHealth() {
return instancesHealth;
}
/**
*
* The date and time that the health information was retrieved.
*
*
* @return The date and time that the health information was retrieved.
*/
public final Instant refreshedAt() {
return refreshedAt;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(environmentName());
hashCode = 31 * hashCode + Objects.hashCode(healthStatus());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(color());
hashCode = 31 * hashCode + Objects.hashCode(hasCauses() ? causes() : null);
hashCode = 31 * hashCode + Objects.hashCode(applicationMetrics());
hashCode = 31 * hashCode + Objects.hashCode(instancesHealth());
hashCode = 31 * hashCode + Objects.hashCode(refreshedAt());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DescribeEnvironmentHealthResponse)) {
return false;
}
DescribeEnvironmentHealthResponse other = (DescribeEnvironmentHealthResponse) obj;
return Objects.equals(environmentName(), other.environmentName()) && Objects.equals(healthStatus(), other.healthStatus())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(color(), other.color())
&& hasCauses() == other.hasCauses() && Objects.equals(causes(), other.causes())
&& Objects.equals(applicationMetrics(), other.applicationMetrics())
&& Objects.equals(instancesHealth(), other.instancesHealth())
&& Objects.equals(refreshedAt(), other.refreshedAt());
}
/**
* 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("DescribeEnvironmentHealthResponse").add("EnvironmentName", environmentName())
.add("HealthStatus", healthStatus()).add("Status", statusAsString()).add("Color", color())
.add("Causes", hasCauses() ? causes() : null).add("ApplicationMetrics", applicationMetrics())
.add("InstancesHealth", instancesHealth()).add("RefreshedAt", refreshedAt()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EnvironmentName":
return Optional.ofNullable(clazz.cast(environmentName()));
case "HealthStatus":
return Optional.ofNullable(clazz.cast(healthStatus()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "Color":
return Optional.ofNullable(clazz.cast(color()));
case "Causes":
return Optional.ofNullable(clazz.cast(causes()));
case "ApplicationMetrics":
return Optional.ofNullable(clazz.cast(applicationMetrics()));
case "InstancesHealth":
return Optional.ofNullable(clazz.cast(instancesHealth()));
case "RefreshedAt":
return Optional.ofNullable(clazz.cast(refreshedAt()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function