software.amazon.awssdk.services.pcs.model.Cluster Maven / Gradle / Ivy
Show all versions of pcs 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.pcs.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.traits.TimestampFormatTrait;
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;
/**
*
* The cluster resource and configuration.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Cluster implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(Cluster::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(Cluster::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
.getter(getter(Cluster::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(Cluster::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField CREATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("createdAt")
.getter(getter(Cluster::createdAt))
.setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField MODIFIED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("modifiedAt")
.getter(getter(Cluster::modifiedAt))
.setter(setter(Builder::modifiedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("modifiedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField SCHEDULER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("scheduler").getter(getter(Cluster::scheduler)).setter(setter(Builder::scheduler))
.constructor(Scheduler::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("scheduler").build()).build();
private static final SdkField SIZE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("size")
.getter(getter(Cluster::sizeAsString)).setter(setter(Builder::size))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("size").build()).build();
private static final SdkField SLURM_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("slurmConfiguration")
.getter(getter(Cluster::slurmConfiguration)).setter(setter(Builder::slurmConfiguration))
.constructor(ClusterSlurmConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("slurmConfiguration").build())
.build();
private static final SdkField NETWORKING_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("networking").getter(getter(Cluster::networking)).setter(setter(Builder::networking))
.constructor(Networking::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("networking").build()).build();
private static final SdkField> ENDPOINTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("endpoints")
.getter(getter(Cluster::endpoints))
.setter(setter(Builder::endpoints))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("endpoints").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Endpoint::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> ERROR_INFO_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("errorInfo")
.getter(getter(Cluster::errorInfo))
.setter(setter(Builder::errorInfo))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("errorInfo").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ErrorInfo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, ID_FIELD,
ARN_FIELD, STATUS_FIELD, CREATED_AT_FIELD, MODIFIED_AT_FIELD, SCHEDULER_FIELD, SIZE_FIELD, SLURM_CONFIGURATION_FIELD,
NETWORKING_FIELD, ENDPOINTS_FIELD, ERROR_INFO_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("name", NAME_FIELD);
put("id", ID_FIELD);
put("arn", ARN_FIELD);
put("status", STATUS_FIELD);
put("createdAt", CREATED_AT_FIELD);
put("modifiedAt", MODIFIED_AT_FIELD);
put("scheduler", SCHEDULER_FIELD);
put("size", SIZE_FIELD);
put("slurmConfiguration", SLURM_CONFIGURATION_FIELD);
put("networking", NETWORKING_FIELD);
put("endpoints", ENDPOINTS_FIELD);
put("errorInfo", ERROR_INFO_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String name;
private final String id;
private final String arn;
private final String status;
private final Instant createdAt;
private final Instant modifiedAt;
private final Scheduler scheduler;
private final String size;
private final ClusterSlurmConfiguration slurmConfiguration;
private final Networking networking;
private final List endpoints;
private final List errorInfo;
private Cluster(BuilderImpl builder) {
this.name = builder.name;
this.id = builder.id;
this.arn = builder.arn;
this.status = builder.status;
this.createdAt = builder.createdAt;
this.modifiedAt = builder.modifiedAt;
this.scheduler = builder.scheduler;
this.size = builder.size;
this.slurmConfiguration = builder.slurmConfiguration;
this.networking = builder.networking;
this.endpoints = builder.endpoints;
this.errorInfo = builder.errorInfo;
}
/**
*
* The name that identifies the cluster.
*
*
* @return The name that identifies the cluster.
*/
public final String name() {
return name;
}
/**
*
* The generated unique ID of the cluster.
*
*
* @return The generated unique ID of the cluster.
*/
public final String id() {
return id;
}
/**
*
* The unique Amazon Resource Name (ARN) of the cluster.
*
*
* @return The unique Amazon Resource Name (ARN) of the cluster.
*/
public final String arn() {
return arn;
}
/**
*
* The provisioning status of the cluster.
*
*
*
* The provisioning status doesn't indicate the overall health of the cluster.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ClusterStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The provisioning status of the cluster.
*
* The provisioning status doesn't indicate the overall health of the cluster.
*
* @see ClusterStatus
*/
public final ClusterStatus status() {
return ClusterStatus.fromValue(status);
}
/**
*
* The provisioning status of the cluster.
*
*
*
* The provisioning status doesn't indicate the overall health of the cluster.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ClusterStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The provisioning status of the cluster.
*
* The provisioning status doesn't indicate the overall health of the cluster.
*
* @see ClusterStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The date and time the resource was created.
*
*
* @return The date and time the resource was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The date and time the resource was modified.
*
*
* @return The date and time the resource was modified.
*/
public final Instant modifiedAt() {
return modifiedAt;
}
/**
* Returns the value of the Scheduler property for this object.
*
* @return The value of the Scheduler property for this object.
*/
public final Scheduler scheduler() {
return scheduler;
}
/**
*
* The size of the cluster.
*
*
* -
*
* SMALL
: 32 compute nodes and 256 jobs
*
*
* -
*
* MEDIUM
: 512 compute nodes and 8192 jobs
*
*
* -
*
* LARGE
: 2048 compute nodes and 16,384 jobs
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #size} will return
* {@link Size#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #sizeAsString}.
*
*
* @return The size of the cluster.
*
* -
*
* SMALL
: 32 compute nodes and 256 jobs
*
*
* -
*
* MEDIUM
: 512 compute nodes and 8192 jobs
*
*
* -
*
* LARGE
: 2048 compute nodes and 16,384 jobs
*
*
* @see Size
*/
public final Size size() {
return Size.fromValue(size);
}
/**
*
* The size of the cluster.
*
*
* -
*
* SMALL
: 32 compute nodes and 256 jobs
*
*
* -
*
* MEDIUM
: 512 compute nodes and 8192 jobs
*
*
* -
*
* LARGE
: 2048 compute nodes and 16,384 jobs
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #size} will return
* {@link Size#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #sizeAsString}.
*
*
* @return The size of the cluster.
*
* -
*
* SMALL
: 32 compute nodes and 256 jobs
*
*
* -
*
* MEDIUM
: 512 compute nodes and 8192 jobs
*
*
* -
*
* LARGE
: 2048 compute nodes and 16,384 jobs
*
*
* @see Size
*/
public final String sizeAsString() {
return size;
}
/**
*
* Additional options related to the Slurm scheduler.
*
*
* @return Additional options related to the Slurm scheduler.
*/
public final ClusterSlurmConfiguration slurmConfiguration() {
return slurmConfiguration;
}
/**
* Returns the value of the Networking property for this object.
*
* @return The value of the Networking property for this object.
*/
public final Networking networking() {
return networking;
}
/**
* For responses, this returns true if the service returned a value for the Endpoints 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 hasEndpoints() {
return endpoints != null && !(endpoints instanceof SdkAutoConstructList);
}
/**
*
* The list of endpoints available for interaction with the scheduler.
*
*
* 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 #hasEndpoints} method.
*
*
* @return The list of endpoints available for interaction with the scheduler.
*/
public final List endpoints() {
return endpoints;
}
/**
* For responses, this returns true if the service returned a value for the ErrorInfo 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 hasErrorInfo() {
return errorInfo != null && !(errorInfo instanceof SdkAutoConstructList);
}
/**
*
* The list of errors that occurred during cluster provisioning.
*
*
* 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 #hasErrorInfo} method.
*
*
* @return The list of errors that occurred during cluster provisioning.
*/
public final List errorInfo() {
return errorInfo;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(modifiedAt());
hashCode = 31 * hashCode + Objects.hashCode(scheduler());
hashCode = 31 * hashCode + Objects.hashCode(sizeAsString());
hashCode = 31 * hashCode + Objects.hashCode(slurmConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(networking());
hashCode = 31 * hashCode + Objects.hashCode(hasEndpoints() ? endpoints() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasErrorInfo() ? errorInfo() : null);
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 Cluster)) {
return false;
}
Cluster other = (Cluster) obj;
return Objects.equals(name(), other.name()) && Objects.equals(id(), other.id()) && Objects.equals(arn(), other.arn())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(createdAt(), other.createdAt())
&& Objects.equals(modifiedAt(), other.modifiedAt()) && Objects.equals(scheduler(), other.scheduler())
&& Objects.equals(sizeAsString(), other.sizeAsString())
&& Objects.equals(slurmConfiguration(), other.slurmConfiguration())
&& Objects.equals(networking(), other.networking()) && hasEndpoints() == other.hasEndpoints()
&& Objects.equals(endpoints(), other.endpoints()) && hasErrorInfo() == other.hasErrorInfo()
&& Objects.equals(errorInfo(), other.errorInfo());
}
/**
* 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("Cluster").add("Name", name()).add("Id", id()).add("Arn", arn()).add("Status", statusAsString())
.add("CreatedAt", createdAt()).add("ModifiedAt", modifiedAt()).add("Scheduler", scheduler())
.add("Size", sizeAsString()).add("SlurmConfiguration", slurmConfiguration()).add("Networking", networking())
.add("Endpoints", hasEndpoints() ? endpoints() : null).add("ErrorInfo", hasErrorInfo() ? errorInfo() : null)
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "modifiedAt":
return Optional.ofNullable(clazz.cast(modifiedAt()));
case "scheduler":
return Optional.ofNullable(clazz.cast(scheduler()));
case "size":
return Optional.ofNullable(clazz.cast(sizeAsString()));
case "slurmConfiguration":
return Optional.ofNullable(clazz.cast(slurmConfiguration()));
case "networking":
return Optional.ofNullable(clazz.cast(networking()));
case "endpoints":
return Optional.ofNullable(clazz.cast(endpoints()));
case "errorInfo":
return Optional.ofNullable(clazz.cast(errorInfo()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function