software.amazon.awssdk.services.batch.model.AttemptDetail Maven / Gradle / Ivy
Show all versions of batch 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.batch.model;
import java.io.Serializable;
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.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;
/**
*
* An object that represents a job attempt.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AttemptDetail implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CONTAINER_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("container")
.getter(getter(AttemptDetail::container)).setter(setter(Builder::container))
.constructor(AttemptContainerDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("container").build()).build();
private static final SdkField STARTED_AT_FIELD = SdkField. builder(MarshallingType.LONG).memberName("startedAt")
.getter(getter(AttemptDetail::startedAt)).setter(setter(Builder::startedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startedAt").build()).build();
private static final SdkField STOPPED_AT_FIELD = SdkField. builder(MarshallingType.LONG).memberName("stoppedAt")
.getter(getter(AttemptDetail::stoppedAt)).setter(setter(Builder::stoppedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stoppedAt").build()).build();
private static final SdkField STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("statusReason").getter(getter(AttemptDetail::statusReason)).setter(setter(Builder::statusReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statusReason").build()).build();
private static final SdkField> TASK_PROPERTIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("taskProperties")
.getter(getter(AttemptDetail::taskProperties))
.setter(setter(Builder::taskProperties))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskProperties").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AttemptEcsTaskDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONTAINER_FIELD,
STARTED_AT_FIELD, STOPPED_AT_FIELD, STATUS_REASON_FIELD, TASK_PROPERTIES_FIELD));
private static final long serialVersionUID = 1L;
private final AttemptContainerDetail container;
private final Long startedAt;
private final Long stoppedAt;
private final String statusReason;
private final List taskProperties;
private AttemptDetail(BuilderImpl builder) {
this.container = builder.container;
this.startedAt = builder.startedAt;
this.stoppedAt = builder.stoppedAt;
this.statusReason = builder.statusReason;
this.taskProperties = builder.taskProperties;
}
/**
*
* The details for the container in this job attempt.
*
*
* @return The details for the container in this job attempt.
*/
public final AttemptContainerDetail container() {
return container;
}
/**
*
* The Unix timestamp (in milliseconds) for when the attempt was started (when the attempt transitioned from the
* STARTING
state to the RUNNING
state).
*
*
* @return The Unix timestamp (in milliseconds) for when the attempt was started (when the attempt transitioned from
* the STARTING
state to the RUNNING
state).
*/
public final Long startedAt() {
return startedAt;
}
/**
*
* The Unix timestamp (in milliseconds) for when the attempt was stopped (when the attempt transitioned from the
* RUNNING
state to a terminal state, such as SUCCEEDED
or FAILED
).
*
*
* @return The Unix timestamp (in milliseconds) for when the attempt was stopped (when the attempt transitioned from
* the RUNNING
state to a terminal state, such as SUCCEEDED
or FAILED
* ).
*/
public final Long stoppedAt() {
return stoppedAt;
}
/**
*
* A short, human-readable string to provide additional details for the current status of the job attempt.
*
*
* @return A short, human-readable string to provide additional details for the current status of the job attempt.
*/
public final String statusReason() {
return statusReason;
}
/**
* For responses, this returns true if the service returned a value for the TaskProperties 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 hasTaskProperties() {
return taskProperties != null && !(taskProperties instanceof SdkAutoConstructList);
}
/**
*
* The properties for a task definition that describes the container and volume definitions of an Amazon ECS task.
*
*
* 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 #hasTaskProperties} method.
*
*
* @return The properties for a task definition that describes the container and volume definitions of an Amazon ECS
* task.
*/
public final List taskProperties() {
return taskProperties;
}
@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(container());
hashCode = 31 * hashCode + Objects.hashCode(startedAt());
hashCode = 31 * hashCode + Objects.hashCode(stoppedAt());
hashCode = 31 * hashCode + Objects.hashCode(statusReason());
hashCode = 31 * hashCode + Objects.hashCode(hasTaskProperties() ? taskProperties() : 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 AttemptDetail)) {
return false;
}
AttemptDetail other = (AttemptDetail) obj;
return Objects.equals(container(), other.container()) && Objects.equals(startedAt(), other.startedAt())
&& Objects.equals(stoppedAt(), other.stoppedAt()) && Objects.equals(statusReason(), other.statusReason())
&& hasTaskProperties() == other.hasTaskProperties() && Objects.equals(taskProperties(), other.taskProperties());
}
/**
* 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("AttemptDetail").add("Container", container()).add("StartedAt", startedAt())
.add("StoppedAt", stoppedAt()).add("StatusReason", statusReason())
.add("TaskProperties", hasTaskProperties() ? taskProperties() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "container":
return Optional.ofNullable(clazz.cast(container()));
case "startedAt":
return Optional.ofNullable(clazz.cast(startedAt()));
case "stoppedAt":
return Optional.ofNullable(clazz.cast(stoppedAt()));
case "statusReason":
return Optional.ofNullable(clazz.cast(statusReason()));
case "taskProperties":
return Optional.ofNullable(clazz.cast(taskProperties()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function