
software.amazon.awssdk.services.batch.model.ComputeEnvironmentDetail 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.batch.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.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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An object representing an AWS Batch compute environment.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ComputeEnvironmentDetail implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField COMPUTE_ENVIRONMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::computeEnvironmentName)).setter(setter(Builder::computeEnvironmentName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computeEnvironmentName").build())
.build();
private static final SdkField COMPUTE_ENVIRONMENT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::computeEnvironmentArn)).setter(setter(Builder::computeEnvironmentArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computeEnvironmentArn").build())
.build();
private static final SdkField ECS_CLUSTER_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::ecsClusterArn)).setter(setter(Builder::ecsClusterArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ecsClusterArn").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("type").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("state").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::statusReason)).setter(setter(Builder::statusReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statusReason").build()).build();
private static final SdkField COMPUTE_RESOURCES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(ComputeEnvironmentDetail::computeResources))
.setter(setter(Builder::computeResources)).constructor(ComputeResource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computeResources").build()).build();
private static final SdkField SERVICE_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ComputeEnvironmentDetail::serviceRole)).setter(setter(Builder::serviceRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("serviceRole").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
COMPUTE_ENVIRONMENT_NAME_FIELD, COMPUTE_ENVIRONMENT_ARN_FIELD, ECS_CLUSTER_ARN_FIELD, TYPE_FIELD, STATE_FIELD,
STATUS_FIELD, STATUS_REASON_FIELD, COMPUTE_RESOURCES_FIELD, SERVICE_ROLE_FIELD));
private static final long serialVersionUID = 1L;
private final String computeEnvironmentName;
private final String computeEnvironmentArn;
private final String ecsClusterArn;
private final String type;
private final String state;
private final String status;
private final String statusReason;
private final ComputeResource computeResources;
private final String serviceRole;
private ComputeEnvironmentDetail(BuilderImpl builder) {
this.computeEnvironmentName = builder.computeEnvironmentName;
this.computeEnvironmentArn = builder.computeEnvironmentArn;
this.ecsClusterArn = builder.ecsClusterArn;
this.type = builder.type;
this.state = builder.state;
this.status = builder.status;
this.statusReason = builder.statusReason;
this.computeResources = builder.computeResources;
this.serviceRole = builder.serviceRole;
}
/**
*
* The name of the compute environment.
*
*
* @return The name of the compute environment.
*/
public String computeEnvironmentName() {
return computeEnvironmentName;
}
/**
*
* The Amazon Resource Name (ARN) of the compute environment.
*
*
* @return The Amazon Resource Name (ARN) of the compute environment.
*/
public String computeEnvironmentArn() {
return computeEnvironmentArn;
}
/**
*
* The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster used by the compute environment.
*
*
* @return The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster used by the compute environment.
*/
public String ecsClusterArn() {
return ecsClusterArn;
}
/**
*
* The type of the compute environment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link CEType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the compute environment.
* @see CEType
*/
public CEType type() {
return CEType.fromValue(type);
}
/**
*
* The type of the compute environment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link CEType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the compute environment.
* @see CEType
*/
public String typeAsString() {
return type;
}
/**
*
* The state of the compute environment. The valid values are ENABLED
or DISABLED
.
*
*
* If the state is ENABLED
, then the AWS Batch scheduler can attempt to place jobs from an associated
* job queue on the compute resources within the environment. If the compute environment is managed, then it can
* scale its instances out or in automatically, based on the job queue demand.
*
*
* If the state is DISABLED
, then the AWS Batch scheduler does not attempt to place jobs within the
* environment. Jobs in a STARTING
or RUNNING
state continue to progress normally. Managed
* compute environments in the DISABLED
state do not scale out. However, they scale in to
* minvCpus
value after instances become idle.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CEState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the compute environment. The valid values are ENABLED
or DISABLED
* .
*
* If the state is ENABLED
, then the AWS Batch scheduler can attempt to place jobs from an
* associated job queue on the compute resources within the environment. If the compute environment is
* managed, then it can scale its instances out or in automatically, based on the job queue demand.
*
*
* If the state is DISABLED
, then the AWS Batch scheduler does not attempt to place jobs within
* the environment. Jobs in a STARTING
or RUNNING
state continue to progress
* normally. Managed compute environments in the DISABLED
state do not scale out. However, they
* scale in to minvCpus
value after instances become idle.
* @see CEState
*/
public CEState state() {
return CEState.fromValue(state);
}
/**
*
* The state of the compute environment. The valid values are ENABLED
or DISABLED
.
*
*
* If the state is ENABLED
, then the AWS Batch scheduler can attempt to place jobs from an associated
* job queue on the compute resources within the environment. If the compute environment is managed, then it can
* scale its instances out or in automatically, based on the job queue demand.
*
*
* If the state is DISABLED
, then the AWS Batch scheduler does not attempt to place jobs within the
* environment. Jobs in a STARTING
or RUNNING
state continue to progress normally. Managed
* compute environments in the DISABLED
state do not scale out. However, they scale in to
* minvCpus
value after instances become idle.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CEState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the compute environment. The valid values are ENABLED
or DISABLED
* .
*
* If the state is ENABLED
, then the AWS Batch scheduler can attempt to place jobs from an
* associated job queue on the compute resources within the environment. If the compute environment is
* managed, then it can scale its instances out or in automatically, based on the job queue demand.
*
*
* If the state is DISABLED
, then the AWS Batch scheduler does not attempt to place jobs within
* the environment. Jobs in a STARTING
or RUNNING
state continue to progress
* normally. Managed compute environments in the DISABLED
state do not scale out. However, they
* scale in to minvCpus
value after instances become idle.
* @see CEState
*/
public String stateAsString() {
return state;
}
/**
*
* The current status of the compute environment (for example, CREATING
or VALID
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link CEStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The current status of the compute environment (for example, CREATING
or VALID
).
* @see CEStatus
*/
public CEStatus status() {
return CEStatus.fromValue(status);
}
/**
*
* The current status of the compute environment (for example, CREATING
or VALID
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link CEStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The current status of the compute environment (for example, CREATING
or VALID
).
* @see CEStatus
*/
public String statusAsString() {
return status;
}
/**
*
* A short, human-readable string to provide additional details about the current status of the compute environment.
*
*
* @return A short, human-readable string to provide additional details about the current status of the compute
* environment.
*/
public String statusReason() {
return statusReason;
}
/**
*
* The compute resources defined for the compute environment.
*
*
* @return The compute resources defined for the compute environment.
*/
public ComputeResource computeResources() {
return computeResources;
}
/**
*
* The service role associated with the compute environment that allows AWS Batch to make calls to AWS API
* operations on your behalf.
*
*
* @return The service role associated with the compute environment that allows AWS Batch to make calls to AWS API
* operations on your behalf.
*/
public String serviceRole() {
return serviceRole;
}
@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(computeEnvironmentName());
hashCode = 31 * hashCode + Objects.hashCode(computeEnvironmentArn());
hashCode = 31 * hashCode + Objects.hashCode(ecsClusterArn());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusReason());
hashCode = 31 * hashCode + Objects.hashCode(computeResources());
hashCode = 31 * hashCode + Objects.hashCode(serviceRole());
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 ComputeEnvironmentDetail)) {
return false;
}
ComputeEnvironmentDetail other = (ComputeEnvironmentDetail) obj;
return Objects.equals(computeEnvironmentName(), other.computeEnvironmentName())
&& Objects.equals(computeEnvironmentArn(), other.computeEnvironmentArn())
&& Objects.equals(ecsClusterArn(), other.ecsClusterArn()) && Objects.equals(typeAsString(), other.typeAsString())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(statusReason(), other.statusReason())
&& Objects.equals(computeResources(), other.computeResources())
&& Objects.equals(serviceRole(), other.serviceRole());
}
/**
* 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("ComputeEnvironmentDetail").add("ComputeEnvironmentName", computeEnvironmentName())
.add("ComputeEnvironmentArn", computeEnvironmentArn()).add("EcsClusterArn", ecsClusterArn())
.add("Type", typeAsString()).add("State", stateAsString()).add("Status", statusAsString())
.add("StatusReason", statusReason()).add("ComputeResources", computeResources())
.add("ServiceRole", serviceRole()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "computeEnvironmentName":
return Optional.ofNullable(clazz.cast(computeEnvironmentName()));
case "computeEnvironmentArn":
return Optional.ofNullable(clazz.cast(computeEnvironmentArn()));
case "ecsClusterArn":
return Optional.ofNullable(clazz.cast(ecsClusterArn()));
case "type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "state":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "statusReason":
return Optional.ofNullable(clazz.cast(statusReason()));
case "computeResources":
return Optional.ofNullable(clazz.cast(computeResources()));
case "serviceRole":
return Optional.ofNullable(clazz.cast(serviceRole()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function