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

software.amazon.awssdk.services.ecs.model.SubmitTaskStateChangeRequest 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.ecs.model;

import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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 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.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;

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

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

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

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

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

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

    private static final SdkField PULL_STARTED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("pullStartedAt").getter(getter(SubmitTaskStateChangeRequest::pullStartedAt))
            .setter(setter(Builder::pullStartedAt))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pullStartedAt").build()).build();

    private static final SdkField PULL_STOPPED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("pullStoppedAt").getter(getter(SubmitTaskStateChangeRequest::pullStoppedAt))
            .setter(setter(Builder::pullStoppedAt))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pullStoppedAt").build()).build();

    private static final SdkField EXECUTION_STOPPED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("executionStoppedAt").getter(getter(SubmitTaskStateChangeRequest::executionStoppedAt))
            .setter(setter(Builder::executionStoppedAt))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("executionStoppedAt").build())
            .build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CLUSTER_FIELD, TASK_FIELD,
            STATUS_FIELD, REASON_FIELD, CONTAINERS_FIELD, ATTACHMENTS_FIELD, PULL_STARTED_AT_FIELD, PULL_STOPPED_AT_FIELD,
            EXECUTION_STOPPED_AT_FIELD));

    private final String cluster;

    private final String task;

    private final String status;

    private final String reason;

    private final List containers;

    private final List attachments;

    private final Instant pullStartedAt;

    private final Instant pullStoppedAt;

    private final Instant executionStoppedAt;

    private SubmitTaskStateChangeRequest(BuilderImpl builder) {
        super(builder);
        this.cluster = builder.cluster;
        this.task = builder.task;
        this.status = builder.status;
        this.reason = builder.reason;
        this.containers = builder.containers;
        this.attachments = builder.attachments;
        this.pullStartedAt = builder.pullStartedAt;
        this.pullStoppedAt = builder.pullStoppedAt;
        this.executionStoppedAt = builder.executionStoppedAt;
    }

    /**
     * 

* The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task. *

* * @return The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task. */ public String cluster() { return cluster; } /** *

* The task ID or full ARN of the task in the state change request. *

* * @return The task ID or full ARN of the task in the state change request. */ public String task() { return task; } /** *

* The status of the state change request. *

* * @return The status of the state change request. */ public String status() { return status; } /** *

* The reason for the state change request. *

* * @return The reason for the state change request. */ public String reason() { return reason; } /** * Returns true if the Containers 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 hasContainers() { return containers != null && !(containers instanceof SdkAutoConstructList); } /** *

* Any containers associated with the state change request. *

*

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

*

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

* * @return Any containers associated with the state change request. */ public List containers() { return containers; } /** * Returns true if the Attachments 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 hasAttachments() { return attachments != null && !(attachments instanceof SdkAutoConstructList); } /** *

* Any attachments associated with the state change request. *

*

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

*

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

* * @return Any attachments associated with the state change request. */ public List attachments() { return attachments; } /** *

* The Unix timestamp for when the container image pull began. *

* * @return The Unix timestamp for when the container image pull began. */ public Instant pullStartedAt() { return pullStartedAt; } /** *

* The Unix timestamp for when the container image pull completed. *

* * @return The Unix timestamp for when the container image pull completed. */ public Instant pullStoppedAt() { return pullStoppedAt; } /** *

* The Unix timestamp for when the task execution stopped. *

* * @return The Unix timestamp for when the task execution stopped. */ public Instant executionStoppedAt() { return executionStoppedAt; } @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(cluster()); hashCode = 31 * hashCode + Objects.hashCode(task()); hashCode = 31 * hashCode + Objects.hashCode(status()); hashCode = 31 * hashCode + Objects.hashCode(reason()); hashCode = 31 * hashCode + Objects.hashCode(hasContainers() ? containers() : null); hashCode = 31 * hashCode + Objects.hashCode(hasAttachments() ? attachments() : null); hashCode = 31 * hashCode + Objects.hashCode(pullStartedAt()); hashCode = 31 * hashCode + Objects.hashCode(pullStoppedAt()); hashCode = 31 * hashCode + Objects.hashCode(executionStoppedAt()); 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 SubmitTaskStateChangeRequest)) { return false; } SubmitTaskStateChangeRequest other = (SubmitTaskStateChangeRequest) obj; return Objects.equals(cluster(), other.cluster()) && Objects.equals(task(), other.task()) && Objects.equals(status(), other.status()) && Objects.equals(reason(), other.reason()) && hasContainers() == other.hasContainers() && Objects.equals(containers(), other.containers()) && hasAttachments() == other.hasAttachments() && Objects.equals(attachments(), other.attachments()) && Objects.equals(pullStartedAt(), other.pullStartedAt()) && Objects.equals(pullStoppedAt(), other.pullStoppedAt()) && Objects.equals(executionStoppedAt(), other.executionStoppedAt()); } /** * 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("SubmitTaskStateChangeRequest").add("Cluster", cluster()).add("Task", task()) .add("Status", status()).add("Reason", reason()).add("Containers", hasContainers() ? containers() : null) .add("Attachments", hasAttachments() ? attachments() : null).add("PullStartedAt", pullStartedAt()) .add("PullStoppedAt", pullStoppedAt()).add("ExecutionStoppedAt", executionStoppedAt()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "cluster": return Optional.ofNullable(clazz.cast(cluster())); case "task": return Optional.ofNullable(clazz.cast(task())); case "status": return Optional.ofNullable(clazz.cast(status())); case "reason": return Optional.ofNullable(clazz.cast(reason())); case "containers": return Optional.ofNullable(clazz.cast(containers())); case "attachments": return Optional.ofNullable(clazz.cast(attachments())); case "pullStartedAt": return Optional.ofNullable(clazz.cast(pullStartedAt())); case "pullStoppedAt": return Optional.ofNullable(clazz.cast(pullStoppedAt())); case "executionStoppedAt": return Optional.ofNullable(clazz.cast(executionStoppedAt())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((SubmitTaskStateChangeRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends EcsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task. *

* * @param cluster * The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder cluster(String cluster); /** *

* The task ID or full ARN of the task in the state change request. *

* * @param task * The task ID or full ARN of the task in the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder task(String task); /** *

* The status of the state change request. *

* * @param status * The status of the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder status(String status); /** *

* The reason for the state change request. *

* * @param reason * The reason for the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder reason(String reason); /** *

* Any containers associated with the state change request. *

* * @param containers * Any containers associated with the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containers(Collection containers); /** *

* Any containers associated with the state change request. *

* * @param containers * Any containers associated with the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containers(ContainerStateChange... containers); /** *

* Any containers associated with the state change request. *

* 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 #containers(List)}. * * @param containers * 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 #containers(List) */ Builder containers(Consumer... containers); /** *

* Any attachments associated with the state change request. *

* * @param attachments * Any attachments associated with the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attachments(Collection attachments); /** *

* Any attachments associated with the state change request. *

* * @param attachments * Any attachments associated with the state change request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attachments(AttachmentStateChange... attachments); /** *

* Any attachments associated with the state change request. *

* 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 #attachments(List)}. * * @param attachments * 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 #attachments(List) */ Builder attachments(Consumer... attachments); /** *

* The Unix timestamp for when the container image pull began. *

* * @param pullStartedAt * The Unix timestamp for when the container image pull began. * @return Returns a reference to this object so that method calls can be chained together. */ Builder pullStartedAt(Instant pullStartedAt); /** *

* The Unix timestamp for when the container image pull completed. *

* * @param pullStoppedAt * The Unix timestamp for when the container image pull completed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder pullStoppedAt(Instant pullStoppedAt); /** *

* The Unix timestamp for when the task execution stopped. *

* * @param executionStoppedAt * The Unix timestamp for when the task execution stopped. * @return Returns a reference to this object so that method calls can be chained together. */ Builder executionStoppedAt(Instant executionStoppedAt); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends EcsRequest.BuilderImpl implements Builder { private String cluster; private String task; private String status; private String reason; private List containers = DefaultSdkAutoConstructList.getInstance(); private List attachments = DefaultSdkAutoConstructList.getInstance(); private Instant pullStartedAt; private Instant pullStoppedAt; private Instant executionStoppedAt; private BuilderImpl() { } private BuilderImpl(SubmitTaskStateChangeRequest model) { super(model); cluster(model.cluster); task(model.task); status(model.status); reason(model.reason); containers(model.containers); attachments(model.attachments); pullStartedAt(model.pullStartedAt); pullStoppedAt(model.pullStoppedAt); executionStoppedAt(model.executionStoppedAt); } public final String getCluster() { return cluster; } @Override public final Builder cluster(String cluster) { this.cluster = cluster; return this; } public final void setCluster(String cluster) { this.cluster = cluster; } public final String getTask() { return task; } @Override public final Builder task(String task) { this.task = task; return this; } public final void setTask(String task) { this.task = task; } public final String getStatus() { return status; } @Override public final Builder status(String status) { this.status = status; return this; } public final void setStatus(String status) { this.status = status; } public final String getReason() { return reason; } @Override public final Builder reason(String reason) { this.reason = reason; return this; } public final void setReason(String reason) { this.reason = reason; } public final Collection getContainers() { if (containers instanceof SdkAutoConstructList) { return null; } return containers != null ? containers.stream().map(ContainerStateChange::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder containers(Collection containers) { this.containers = ContainerStateChangesCopier.copy(containers); return this; } @Override @SafeVarargs public final Builder containers(ContainerStateChange... containers) { containers(Arrays.asList(containers)); return this; } @Override @SafeVarargs public final Builder containers(Consumer... containers) { containers(Stream.of(containers).map(c -> ContainerStateChange.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setContainers(Collection containers) { this.containers = ContainerStateChangesCopier.copyFromBuilder(containers); } public final Collection getAttachments() { if (attachments instanceof SdkAutoConstructList) { return null; } return attachments != null ? attachments.stream().map(AttachmentStateChange::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder attachments(Collection attachments) { this.attachments = AttachmentStateChangesCopier.copy(attachments); return this; } @Override @SafeVarargs public final Builder attachments(AttachmentStateChange... attachments) { attachments(Arrays.asList(attachments)); return this; } @Override @SafeVarargs public final Builder attachments(Consumer... attachments) { attachments(Stream.of(attachments).map(c -> AttachmentStateChange.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setAttachments(Collection attachments) { this.attachments = AttachmentStateChangesCopier.copyFromBuilder(attachments); } public final Instant getPullStartedAt() { return pullStartedAt; } @Override public final Builder pullStartedAt(Instant pullStartedAt) { this.pullStartedAt = pullStartedAt; return this; } public final void setPullStartedAt(Instant pullStartedAt) { this.pullStartedAt = pullStartedAt; } public final Instant getPullStoppedAt() { return pullStoppedAt; } @Override public final Builder pullStoppedAt(Instant pullStoppedAt) { this.pullStoppedAt = pullStoppedAt; return this; } public final void setPullStoppedAt(Instant pullStoppedAt) { this.pullStoppedAt = pullStoppedAt; } public final Instant getExecutionStoppedAt() { return executionStoppedAt; } @Override public final Builder executionStoppedAt(Instant executionStoppedAt) { this.executionStoppedAt = executionStoppedAt; return this; } public final void setExecutionStoppedAt(Instant executionStoppedAt) { this.executionStoppedAt = executionStoppedAt; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public SubmitTaskStateChangeRequest build() { return new SubmitTaskStateChangeRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy