software.amazon.awssdk.services.pcs.model.Queue 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;
/**
*
* A queue resource.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Queue implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(Queue::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(Queue::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(Queue::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField CLUSTER_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("clusterId").getter(getter(Queue::clusterId)).setter(setter(Builder::clusterId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clusterId").build()).build();
private static final SdkField CREATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("createdAt")
.getter(getter(Queue::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(Queue::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 STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(Queue::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField> COMPUTE_NODE_GROUP_CONFIGURATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("computeNodeGroupConfigurations")
.getter(getter(Queue::computeNodeGroupConfigurations))
.setter(setter(Builder::computeNodeGroupConfigurations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computeNodeGroupConfigurations")
.build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ComputeNodeGroupConfiguration::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(Queue::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, CLUSTER_ID_FIELD, CREATED_AT_FIELD, MODIFIED_AT_FIELD, STATUS_FIELD,
COMPUTE_NODE_GROUP_CONFIGURATIONS_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("clusterId", CLUSTER_ID_FIELD);
put("createdAt", CREATED_AT_FIELD);
put("modifiedAt", MODIFIED_AT_FIELD);
put("status", STATUS_FIELD);
put("computeNodeGroupConfigurations", COMPUTE_NODE_GROUP_CONFIGURATIONS_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 clusterId;
private final Instant createdAt;
private final Instant modifiedAt;
private final String status;
private final List computeNodeGroupConfigurations;
private final List errorInfo;
private Queue(BuilderImpl builder) {
this.name = builder.name;
this.id = builder.id;
this.arn = builder.arn;
this.clusterId = builder.clusterId;
this.createdAt = builder.createdAt;
this.modifiedAt = builder.modifiedAt;
this.status = builder.status;
this.computeNodeGroupConfigurations = builder.computeNodeGroupConfigurations;
this.errorInfo = builder.errorInfo;
}
/**
*
* The name that identifies the queue.
*
*
* @return The name that identifies the queue.
*/
public final String name() {
return name;
}
/**
*
* The generated unique ID of the queue.
*
*
* @return The generated unique ID of the queue.
*/
public final String id() {
return id;
}
/**
*
* The unique Amazon Resource Name (ARN) of the queue.
*
*
* @return The unique Amazon Resource Name (ARN) of the queue.
*/
public final String arn() {
return arn;
}
/**
*
* The ID of the cluster of the queue.
*
*
* @return The ID of the cluster of the queue.
*/
public final String clusterId() {
return clusterId;
}
/**
*
* 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;
}
/**
*
* The provisioning status of the queue.
*
*
*
* The provisioning status doesn't indicate the overall health of the queue.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link QueueStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The provisioning status of the queue.
*
* The provisioning status doesn't indicate the overall health of the queue.
*
* @see QueueStatus
*/
public final QueueStatus status() {
return QueueStatus.fromValue(status);
}
/**
*
* The provisioning status of the queue.
*
*
*
* The provisioning status doesn't indicate the overall health of the queue.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link QueueStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The provisioning status of the queue.
*
* The provisioning status doesn't indicate the overall health of the queue.
*
* @see QueueStatus
*/
public final String statusAsString() {
return status;
}
/**
* For responses, this returns true if the service returned a value for the ComputeNodeGroupConfigurations 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 hasComputeNodeGroupConfigurations() {
return computeNodeGroupConfigurations != null && !(computeNodeGroupConfigurations instanceof SdkAutoConstructList);
}
/**
*
* The list of compute node group configurations associated with the queue. Queues assign jobs to associated compute
* node groups.
*
*
* 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 #hasComputeNodeGroupConfigurations} method.
*
*
* @return The list of compute node group configurations associated with the queue. Queues assign jobs to associated
* compute node groups.
*/
public final List computeNodeGroupConfigurations() {
return computeNodeGroupConfigurations;
}
/**
* 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 queue 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 queue 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(clusterId());
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(modifiedAt());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode
+ Objects.hashCode(hasComputeNodeGroupConfigurations() ? computeNodeGroupConfigurations() : 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 Queue)) {
return false;
}
Queue other = (Queue) obj;
return Objects.equals(name(), other.name()) && Objects.equals(id(), other.id()) && Objects.equals(arn(), other.arn())
&& Objects.equals(clusterId(), other.clusterId()) && Objects.equals(createdAt(), other.createdAt())
&& Objects.equals(modifiedAt(), other.modifiedAt()) && Objects.equals(statusAsString(), other.statusAsString())
&& hasComputeNodeGroupConfigurations() == other.hasComputeNodeGroupConfigurations()
&& Objects.equals(computeNodeGroupConfigurations(), other.computeNodeGroupConfigurations())
&& 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("Queue")
.add("Name", name())
.add("Id", id())
.add("Arn", arn())
.add("ClusterId", clusterId())
.add("CreatedAt", createdAt())
.add("ModifiedAt", modifiedAt())
.add("Status", statusAsString())
.add("ComputeNodeGroupConfigurations",
hasComputeNodeGroupConfigurations() ? computeNodeGroupConfigurations() : 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 "clusterId":
return Optional.ofNullable(clazz.cast(clusterId()));
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "modifiedAt":
return Optional.ofNullable(clazz.cast(modifiedAt()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "computeNodeGroupConfigurations":
return Optional.ofNullable(clazz.cast(computeNodeGroupConfigurations()));
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