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

software.amazon.awssdk.services.batch.model.CreateJobQueueRequest Maven / Gradle / Ivy

/*
 * 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.batch.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.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 CreateJobQueueRequest extends BatchRequest implements
        ToCopyableBuilder {
    private static final SdkField JOB_QUEUE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("jobQueueName").getter(getter(CreateJobQueueRequest::jobQueueName)).setter(setter(Builder::jobQueueName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("jobQueueName").build()).build();

    private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("state")
            .getter(getter(CreateJobQueueRequest::stateAsString)).setter(setter(Builder::state))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("state").build()).build();

    private static final SdkField PRIORITY_FIELD = SdkField. builder(MarshallingType.INTEGER)
            .memberName("priority").getter(getter(CreateJobQueueRequest::priority)).setter(setter(Builder::priority))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("priority").build()).build();

    private static final SdkField> COMPUTE_ENVIRONMENT_ORDER_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("computeEnvironmentOrder")
            .getter(getter(CreateJobQueueRequest::computeEnvironmentOrder))
            .setter(setter(Builder::computeEnvironmentOrder))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computeEnvironmentOrder").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(ComputeEnvironmentOrder::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("tags")
            .getter(getter(CreateJobQueueRequest::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(JOB_QUEUE_NAME_FIELD,
            STATE_FIELD, PRIORITY_FIELD, COMPUTE_ENVIRONMENT_ORDER_FIELD, TAGS_FIELD));

    private final String jobQueueName;

    private final String state;

    private final Integer priority;

    private final List computeEnvironmentOrder;

    private final Map tags;

    private CreateJobQueueRequest(BuilderImpl builder) {
        super(builder);
        this.jobQueueName = builder.jobQueueName;
        this.state = builder.state;
        this.priority = builder.priority;
        this.computeEnvironmentOrder = builder.computeEnvironmentOrder;
        this.tags = builder.tags;
    }

    /**
     * 

* The name of the job queue. *

* * @return The name of the job queue. */ public String jobQueueName() { return jobQueueName; } /** *

* The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If the job * queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in the queue can * finish. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return * {@link JQState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #stateAsString}. *

* * @return The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If * the job queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in * the queue can finish. * @see JQState */ public JQState state() { return JQState.fromValue(state); } /** *

* The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If the job * queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in the queue can * finish. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return * {@link JQState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #stateAsString}. *

* * @return The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If * the job queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in * the queue can finish. * @see JQState */ public String stateAsString() { return state; } /** *

* The priority of the job queue. Job queues with a higher priority (or a higher integer value for the * priority parameter) are evaluated first when associated with the same compute environment. Priority * is determined in descending order, for example, a job queue with a priority value of 10 is given * scheduling preference over a job queue with a priority value of 1. *

* * @return The priority of the job queue. Job queues with a higher priority (or a higher integer value for the * priority parameter) are evaluated first when associated with the same compute environment. * Priority is determined in descending order, for example, a job queue with a priority value of * 10 is given scheduling preference over a job queue with a priority value of 1. */ public Integer priority() { return priority; } /** * Returns true if the ComputeEnvironmentOrder property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public boolean hasComputeEnvironmentOrder() { return computeEnvironmentOrder != null && !(computeEnvironmentOrder instanceof SdkAutoConstructList); } /** *

* The set of compute environments mapped to a job queue and their order relative to each other. The job scheduler * uses this parameter to determine which compute environment should execute a given job. Compute environments must * be in the VALID state before you can associate them with a job queue. You can associate up to three * compute environments with a job queue. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasComputeEnvironmentOrder()} to see if a value was sent in this field. *

* * @return The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. Compute * environments must be in the VALID state before you can associate them with a job queue. You * can associate up to three compute environments with a job queue. */ public List computeEnvironmentOrder() { return computeEnvironmentOrder; } /** * Returns true if the Tags property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructMap); } /** *

* The tags that you apply to the job queue to help you categorize and organize your resources. Each tag consists of * a key and an optional value. For more information, see Tagging AWS Resources in AWS General * Reference. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasTags()} to see if a value was sent in this field. *

* * @return The tags that you apply to the job queue to help you categorize and organize your resources. Each tag * consists of a key and an optional value. For more information, see Tagging AWS Resources in AWS * General Reference. */ public 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 int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(jobQueueName()); hashCode = 31 * hashCode + Objects.hashCode(stateAsString()); hashCode = 31 * hashCode + Objects.hashCode(priority()); hashCode = 31 * hashCode + Objects.hashCode(computeEnvironmentOrder()); hashCode = 31 * hashCode + Objects.hashCode(tags()); 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 CreateJobQueueRequest)) { return false; } CreateJobQueueRequest other = (CreateJobQueueRequest) obj; return Objects.equals(jobQueueName(), other.jobQueueName()) && Objects.equals(stateAsString(), other.stateAsString()) && Objects.equals(priority(), other.priority()) && Objects.equals(computeEnvironmentOrder(), other.computeEnvironmentOrder()) && 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 String toString() { return ToString.builder("CreateJobQueueRequest").add("JobQueueName", jobQueueName()).add("State", stateAsString()) .add("Priority", priority()).add("ComputeEnvironmentOrder", computeEnvironmentOrder()).add("Tags", tags()) .build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "jobQueueName": return Optional.ofNullable(clazz.cast(jobQueueName())); case "state": return Optional.ofNullable(clazz.cast(stateAsString())); case "priority": return Optional.ofNullable(clazz.cast(priority())); case "computeEnvironmentOrder": return Optional.ofNullable(clazz.cast(computeEnvironmentOrder())); case "tags": return Optional.ofNullable(clazz.cast(tags())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateJobQueueRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends BatchRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the job queue. *

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

* The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If the * job queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in the * queue can finish. *

* * @param state * The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. * If the job queue state is DISABLED, new jobs cannot be added to the queue, but jobs * already in the queue can finish. * @see JQState * @return Returns a reference to this object so that method calls can be chained together. * @see JQState */ Builder state(String state); /** *

* The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. If the * job queue state is DISABLED, new jobs cannot be added to the queue, but jobs already in the * queue can finish. *

* * @param state * The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs. * If the job queue state is DISABLED, new jobs cannot be added to the queue, but jobs * already in the queue can finish. * @see JQState * @return Returns a reference to this object so that method calls can be chained together. * @see JQState */ Builder state(JQState state); /** *

* The priority of the job queue. Job queues with a higher priority (or a higher integer value for the * priority parameter) are evaluated first when associated with the same compute environment. * Priority is determined in descending order, for example, a job queue with a priority value of 10 * is given scheduling preference over a job queue with a priority value of 1. *

* * @param priority * The priority of the job queue. Job queues with a higher priority (or a higher integer value for the * priority parameter) are evaluated first when associated with the same compute * environment. Priority is determined in descending order, for example, a job queue with a priority * value of 10 is given scheduling preference over a job queue with a priority value of * 1. * @return Returns a reference to this object so that method calls can be chained together. */ Builder priority(Integer priority); /** *

* The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. Compute * environments must be in the VALID state before you can associate them with a job queue. You can * associate up to three compute environments with a job queue. *

* * @param computeEnvironmentOrder * The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. * Compute environments must be in the VALID state before you can associate them with a job * queue. You can associate up to three compute environments with a job queue. * @return Returns a reference to this object so that method calls can be chained together. */ Builder computeEnvironmentOrder(Collection computeEnvironmentOrder); /** *

* The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. Compute * environments must be in the VALID state before you can associate them with a job queue. You can * associate up to three compute environments with a job queue. *

* * @param computeEnvironmentOrder * The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. * Compute environments must be in the VALID state before you can associate them with a job * queue. You can associate up to three compute environments with a job queue. * @return Returns a reference to this object so that method calls can be chained together. */ Builder computeEnvironmentOrder(ComputeEnvironmentOrder... computeEnvironmentOrder); /** *

* The set of compute environments mapped to a job queue and their order relative to each other. The job * scheduler uses this parameter to determine which compute environment should execute a given job. Compute * environments must be in the VALID state before you can associate them with a job queue. You can * associate up to three compute environments with a job queue. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding * the need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called * immediately and its result is passed to {@link #computeEnvironmentOrder(List)}. * * @param computeEnvironmentOrder * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #computeEnvironmentOrder(List) */ Builder computeEnvironmentOrder(Consumer... computeEnvironmentOrder); /** *

* The tags that you apply to the job queue to help you categorize and organize your resources. Each tag * consists of a key and an optional value. For more information, see Tagging AWS Resources in AWS * General Reference. *

* * @param tags * The tags that you apply to the job queue to help you categorize and organize your resources. Each tag * consists of a key and an optional value. For more information, see Tagging AWS Resources in * AWS General Reference. * @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 BatchRequest.BuilderImpl implements Builder { private String jobQueueName; private String state; private Integer priority; private List computeEnvironmentOrder = DefaultSdkAutoConstructList.getInstance(); private Map tags = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateJobQueueRequest model) { super(model); jobQueueName(model.jobQueueName); state(model.state); priority(model.priority); computeEnvironmentOrder(model.computeEnvironmentOrder); tags(model.tags); } public final String getJobQueueName() { return jobQueueName; } @Override public final Builder jobQueueName(String jobQueueName) { this.jobQueueName = jobQueueName; return this; } public final void setJobQueueName(String jobQueueName) { this.jobQueueName = jobQueueName; } public final String getState() { return state; } @Override public final Builder state(String state) { this.state = state; return this; } @Override public final Builder state(JQState state) { this.state(state == null ? null : state.toString()); return this; } public final void setState(String state) { this.state = state; } public final Integer getPriority() { return priority; } @Override public final Builder priority(Integer priority) { this.priority = priority; return this; } public final void setPriority(Integer priority) { this.priority = priority; } public final Collection getComputeEnvironmentOrder() { return computeEnvironmentOrder != null ? computeEnvironmentOrder.stream().map(ComputeEnvironmentOrder::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder computeEnvironmentOrder(Collection computeEnvironmentOrder) { this.computeEnvironmentOrder = ComputeEnvironmentOrdersCopier.copy(computeEnvironmentOrder); return this; } @Override @SafeVarargs public final Builder computeEnvironmentOrder(ComputeEnvironmentOrder... computeEnvironmentOrder) { computeEnvironmentOrder(Arrays.asList(computeEnvironmentOrder)); return this; } @Override @SafeVarargs public final Builder computeEnvironmentOrder(Consumer... computeEnvironmentOrder) { computeEnvironmentOrder(Stream.of(computeEnvironmentOrder) .map(c -> ComputeEnvironmentOrder.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setComputeEnvironmentOrder(Collection computeEnvironmentOrder) { this.computeEnvironmentOrder = ComputeEnvironmentOrdersCopier.copyFromBuilder(computeEnvironmentOrder); } public final Map getTags() { return tags; } @Override public final Builder tags(Map tags) { this.tags = TagrisTagsMapCopier.copy(tags); return this; } public final void setTags(Map tags) { this.tags = TagrisTagsMapCopier.copy(tags); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateJobQueueRequest build() { return new CreateJobQueueRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy