
software.amazon.awssdk.services.elasticbeanstalk.model.DescribeEnvironmentHealthResponse Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.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.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)
.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)
.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)
.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)
.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)
.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)
.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)
.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)
.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 String environmentName() {
return environmentName;
}
/**
*
* The health
* status of the environment. For example, Ok
.
*
*
* @return The health
* status of the environment. For example, Ok
.
*/
public 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 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 String statusAsString() {
return status;
}
/**
*
* The health color
* of the environment.
*
*
* @return The health
* color of the environment.
*/
public String color() {
return color;
}
/**
*
* 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.
*
*
* @return Descriptions of the data that contributed to the environment's current health status.
*/
public List causes() {
return causes;
}
/**
*
* Application request metrics for the environment.
*
*
* @return Application request metrics for the environment.
*/
public ApplicationMetrics applicationMetrics() {
return applicationMetrics;
}
/**
*
* Summary health information for the instances in the environment.
*
*
* @return Summary health information for the instances in the environment.
*/
public 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 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 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(causes());
hashCode = 31 * hashCode + Objects.hashCode(applicationMetrics());
hashCode = 31 * hashCode + Objects.hashCode(instancesHealth());
hashCode = 31 * hashCode + Objects.hashCode(refreshedAt());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public 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())
&& 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 String toString() {
return ToString.builder("DescribeEnvironmentHealthResponse").add("EnvironmentName", environmentName())
.add("HealthStatus", healthStatus()).add("Status", statusAsString()).add("Color", color())
.add("Causes", causes()).add("ApplicationMetrics", applicationMetrics())
.add("InstancesHealth", instancesHealth()).add("RefreshedAt", refreshedAt()).build();
}
public 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 List> sdkFields() {
return SDK_FIELDS;
}
private static Function