All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.pcs.model.CreateQueueRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for PCS module holds the client classes that are used for communicating with PCS.

There is a newer version: 2.28.4
Show newest version
/*
 * 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.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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.awscore.AwsRequestOverrideConfiguration;
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.DefaultValueTrait;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateQueueRequest extends PcsRequest implements
        ToCopyableBuilder {
    private static final SdkField CLUSTER_IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("clusterIdentifier").getter(getter(CreateQueueRequest::clusterIdentifier))
            .setter(setter(Builder::clusterIdentifier))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clusterIdentifier").build()).build();

    private static final SdkField QUEUE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("queueName").getter(getter(CreateQueueRequest::queueName)).setter(setter(Builder::queueName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queueName").build()).build();

    private static final SdkField> COMPUTE_NODE_GROUP_CONFIGURATIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("computeNodeGroupConfigurations")
            .getter(getter(CreateQueueRequest::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 CLIENT_TOKEN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("clientToken")
            .getter(getter(CreateQueueRequest::clientToken))
            .setter(setter(Builder::clientToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clientToken").build(),
                    DefaultValueTrait.idempotencyToken()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("tags")
            .getter(getter(CreateQueueRequest::tags))
            .setter(setter(Builder::tags))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CLUSTER_IDENTIFIER_FIELD,
            QUEUE_NAME_FIELD, COMPUTE_NODE_GROUP_CONFIGURATIONS_FIELD, CLIENT_TOKEN_FIELD, TAGS_FIELD));

    private final String clusterIdentifier;

    private final String queueName;

    private final List computeNodeGroupConfigurations;

    private final String clientToken;

    private final Map tags;

    private CreateQueueRequest(BuilderImpl builder) {
        super(builder);
        this.clusterIdentifier = builder.clusterIdentifier;
        this.queueName = builder.queueName;
        this.computeNodeGroupConfigurations = builder.computeNodeGroupConfigurations;
        this.clientToken = builder.clientToken;
        this.tags = builder.tags;
    }

    /**
     * 

* The name or ID of the cluster for which to create a queue. *

* * @return The name or ID of the cluster for which to create a queue. */ public final String clusterIdentifier() { return clusterIdentifier; } /** *

* A name to identify the queue. *

* * @return A name to identify the queue. */ public final String queueName() { return queueName; } /** * 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 to associate 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 to associate with the queue. Queues assign jobs to * associated compute node groups. */ public final List computeNodeGroupConfigurations() { return computeNodeGroupConfigurations; } /** *

* A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency * ensures that an API request completes only once. With an idempotent request, if the original request completes * successfully, the subsequent retries with the same client token return the result from the original successful * request and they have no additional effect. If you don't specify a client token, the CLI and SDK automatically * generate 1 for you. *

* * @return A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. * Idempotency ensures that an API request completes only once. With an idempotent request, if the original * request completes successfully, the subsequent retries with the same client token return the result from * the original successful request and they have no additional effect. If you don't specify a client token, * the CLI and SDK automatically generate 1 for you. */ public final String clientToken() { return clientToken; } /** * For responses, this returns true if the service returned a value for the Tags 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 hasTags() { return tags != null && !(tags instanceof SdkAutoConstructMap); } /** *

* 1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is optional and * can be an empty string. *

*

* 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 #hasTags} method. *

* * @return 1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is * optional and can be an empty string. */ public final Map tags() { return tags; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(clusterIdentifier()); hashCode = 31 * hashCode + Objects.hashCode(queueName()); hashCode = 31 * hashCode + Objects.hashCode(hasComputeNodeGroupConfigurations() ? computeNodeGroupConfigurations() : null); hashCode = 31 * hashCode + Objects.hashCode(clientToken()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); 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 CreateQueueRequest)) { return false; } CreateQueueRequest other = (CreateQueueRequest) obj; return Objects.equals(clusterIdentifier(), other.clusterIdentifier()) && Objects.equals(queueName(), other.queueName()) && hasComputeNodeGroupConfigurations() == other.hasComputeNodeGroupConfigurations() && Objects.equals(computeNodeGroupConfigurations(), other.computeNodeGroupConfigurations()) && Objects.equals(clientToken(), other.clientToken()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()); } /** * 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("CreateQueueRequest") .add("ClusterIdentifier", clusterIdentifier()) .add("QueueName", queueName()) .add("ComputeNodeGroupConfigurations", hasComputeNodeGroupConfigurations() ? computeNodeGroupConfigurations() : null) .add("ClientToken", clientToken()).add("Tags", hasTags() ? tags() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "clusterIdentifier": return Optional.ofNullable(clazz.cast(clusterIdentifier())); case "queueName": return Optional.ofNullable(clazz.cast(queueName())); case "computeNodeGroupConfigurations": return Optional.ofNullable(clazz.cast(computeNodeGroupConfigurations())); case "clientToken": return Optional.ofNullable(clazz.cast(clientToken())); case "tags": return Optional.ofNullable(clazz.cast(tags())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateQueueRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends PcsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name or ID of the cluster for which to create a queue. *

* * @param clusterIdentifier * The name or ID of the cluster for which to create a queue. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clusterIdentifier(String clusterIdentifier); /** *

* A name to identify the queue. *

* * @param queueName * A name to identify the queue. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queueName(String queueName); /** *

* The list of compute node group configurations to associate with the queue. Queues assign jobs to associated * compute node groups. *

* * @param computeNodeGroupConfigurations * The list of compute node group configurations to associate with the queue. Queues assign jobs to * associated compute node groups. * @return Returns a reference to this object so that method calls can be chained together. */ Builder computeNodeGroupConfigurations(Collection computeNodeGroupConfigurations); /** *

* The list of compute node group configurations to associate with the queue. Queues assign jobs to associated * compute node groups. *

* * @param computeNodeGroupConfigurations * The list of compute node group configurations to associate with the queue. Queues assign jobs to * associated compute node groups. * @return Returns a reference to this object so that method calls can be chained together. */ Builder computeNodeGroupConfigurations(ComputeNodeGroupConfiguration... computeNodeGroupConfigurations); /** *

* The list of compute node group configurations to associate with the queue. Queues assign jobs to associated * compute node groups. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.pcs.model.ComputeNodeGroupConfiguration.Builder} avoiding the need to * create one manually via * {@link software.amazon.awssdk.services.pcs.model.ComputeNodeGroupConfiguration#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.pcs.model.ComputeNodeGroupConfiguration.Builder#build()} is called * immediately and its result is passed to {@link * #computeNodeGroupConfigurations(List)}. * * @param computeNodeGroupConfigurations * a consumer that will call methods on * {@link software.amazon.awssdk.services.pcs.model.ComputeNodeGroupConfiguration.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #computeNodeGroupConfigurations(java.util.Collection) */ Builder computeNodeGroupConfigurations(Consumer... computeNodeGroupConfigurations); /** *

* A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency * ensures that an API request completes only once. With an idempotent request, if the original request * completes successfully, the subsequent retries with the same client token return the result from the original * successful request and they have no additional effect. If you don't specify a client token, the CLI and SDK * automatically generate 1 for you. *

* * @param clientToken * A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. * Idempotency ensures that an API request completes only once. With an idempotent request, if the * original request completes successfully, the subsequent retries with the same client token return the * result from the original successful request and they have no additional effect. If you don't specify a * client token, the CLI and SDK automatically generate 1 for you. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientToken(String clientToken); /** *

* 1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is optional * and can be an empty string. *

* * @param tags * 1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is * optional and can be an empty string. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Map tags); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends PcsRequest.BuilderImpl implements Builder { private String clusterIdentifier; private String queueName; private List computeNodeGroupConfigurations = DefaultSdkAutoConstructList.getInstance(); private String clientToken; private Map tags = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateQueueRequest model) { super(model); clusterIdentifier(model.clusterIdentifier); queueName(model.queueName); computeNodeGroupConfigurations(model.computeNodeGroupConfigurations); clientToken(model.clientToken); tags(model.tags); } public final String getClusterIdentifier() { return clusterIdentifier; } public final void setClusterIdentifier(String clusterIdentifier) { this.clusterIdentifier = clusterIdentifier; } @Override public final Builder clusterIdentifier(String clusterIdentifier) { this.clusterIdentifier = clusterIdentifier; return this; } public final String getQueueName() { return queueName; } public final void setQueueName(String queueName) { this.queueName = queueName; } @Override public final Builder queueName(String queueName) { this.queueName = queueName; return this; } public final List getComputeNodeGroupConfigurations() { List result = ComputeNodeGroupConfigurationListCopier .copyToBuilder(this.computeNodeGroupConfigurations); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setComputeNodeGroupConfigurations( Collection computeNodeGroupConfigurations) { this.computeNodeGroupConfigurations = ComputeNodeGroupConfigurationListCopier .copyFromBuilder(computeNodeGroupConfigurations); } @Override public final Builder computeNodeGroupConfigurations( Collection computeNodeGroupConfigurations) { this.computeNodeGroupConfigurations = ComputeNodeGroupConfigurationListCopier.copy(computeNodeGroupConfigurations); return this; } @Override @SafeVarargs public final Builder computeNodeGroupConfigurations(ComputeNodeGroupConfiguration... computeNodeGroupConfigurations) { computeNodeGroupConfigurations(Arrays.asList(computeNodeGroupConfigurations)); return this; } @Override @SafeVarargs public final Builder computeNodeGroupConfigurations( Consumer... computeNodeGroupConfigurations) { computeNodeGroupConfigurations(Stream.of(computeNodeGroupConfigurations) .map(c -> ComputeNodeGroupConfiguration.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final String getClientToken() { return clientToken; } public final void setClientToken(String clientToken) { this.clientToken = clientToken; } @Override public final Builder clientToken(String clientToken) { this.clientToken = clientToken; return this; } public final Map getTags() { if (tags instanceof SdkAutoConstructMap) { return null; } return tags; } public final void setTags(Map tags) { this.tags = RequestTagMapCopier.copy(tags); } @Override public final Builder tags(Map tags) { this.tags = RequestTagMapCopier.copy(tags); return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateQueueRequest build() { return new CreateQueueRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy