software.amazon.awssdk.services.batch.model.EcsTaskDetails 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.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.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;
/**
*
* The details of a task definition that describes the container and volume definitions of an Amazon ECS task.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EcsTaskDetails implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> CONTAINERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("containers")
.getter(getter(EcsTaskDetails::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(TaskContainerDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CONTAINER_INSTANCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("containerInstanceArn").getter(getter(EcsTaskDetails::containerInstanceArn))
.setter(setter(Builder::containerInstanceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("containerInstanceArn").build())
.build();
private static final SdkField TASK_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("taskArn").getter(getter(EcsTaskDetails::taskArn)).setter(setter(Builder::taskArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskArn").build()).build();
private static final SdkField EPHEMERAL_STORAGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ephemeralStorage")
.getter(getter(EcsTaskDetails::ephemeralStorage)).setter(setter(Builder::ephemeralStorage))
.constructor(EphemeralStorage::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ephemeralStorage").build()).build();
private static final SdkField EXECUTION_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("executionRoleArn").getter(getter(EcsTaskDetails::executionRoleArn))
.setter(setter(Builder::executionRoleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("executionRoleArn").build()).build();
private static final SdkField PLATFORM_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("platformVersion").getter(getter(EcsTaskDetails::platformVersion))
.setter(setter(Builder::platformVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("platformVersion").build()).build();
private static final SdkField IPC_MODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ipcMode").getter(getter(EcsTaskDetails::ipcMode)).setter(setter(Builder::ipcMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ipcMode").build()).build();
private static final SdkField TASK_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("taskRoleArn").getter(getter(EcsTaskDetails::taskRoleArn)).setter(setter(Builder::taskRoleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskRoleArn").build()).build();
private static final SdkField PID_MODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("pidMode").getter(getter(EcsTaskDetails::pidMode)).setter(setter(Builder::pidMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pidMode").build()).build();
private static final SdkField NETWORK_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("networkConfiguration")
.getter(getter(EcsTaskDetails::networkConfiguration)).setter(setter(Builder::networkConfiguration))
.constructor(NetworkConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("networkConfiguration").build())
.build();
private static final SdkField RUNTIME_PLATFORM_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("runtimePlatform")
.getter(getter(EcsTaskDetails::runtimePlatform)).setter(setter(Builder::runtimePlatform))
.constructor(RuntimePlatform::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("runtimePlatform").build()).build();
private static final SdkField> VOLUMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("volumes")
.getter(getter(EcsTaskDetails::volumes))
.setter(setter(Builder::volumes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("volumes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Volume::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONTAINERS_FIELD,
CONTAINER_INSTANCE_ARN_FIELD, TASK_ARN_FIELD, EPHEMERAL_STORAGE_FIELD, EXECUTION_ROLE_ARN_FIELD,
PLATFORM_VERSION_FIELD, IPC_MODE_FIELD, TASK_ROLE_ARN_FIELD, PID_MODE_FIELD, NETWORK_CONFIGURATION_FIELD,
RUNTIME_PLATFORM_FIELD, VOLUMES_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("containers", CONTAINERS_FIELD);
put("containerInstanceArn", CONTAINER_INSTANCE_ARN_FIELD);
put("taskArn", TASK_ARN_FIELD);
put("ephemeralStorage", EPHEMERAL_STORAGE_FIELD);
put("executionRoleArn", EXECUTION_ROLE_ARN_FIELD);
put("platformVersion", PLATFORM_VERSION_FIELD);
put("ipcMode", IPC_MODE_FIELD);
put("taskRoleArn", TASK_ROLE_ARN_FIELD);
put("pidMode", PID_MODE_FIELD);
put("networkConfiguration", NETWORK_CONFIGURATION_FIELD);
put("runtimePlatform", RUNTIME_PLATFORM_FIELD);
put("volumes", VOLUMES_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final List containers;
private final String containerInstanceArn;
private final String taskArn;
private final EphemeralStorage ephemeralStorage;
private final String executionRoleArn;
private final String platformVersion;
private final String ipcMode;
private final String taskRoleArn;
private final String pidMode;
private final NetworkConfiguration networkConfiguration;
private final RuntimePlatform runtimePlatform;
private final List volumes;
private EcsTaskDetails(BuilderImpl builder) {
this.containers = builder.containers;
this.containerInstanceArn = builder.containerInstanceArn;
this.taskArn = builder.taskArn;
this.ephemeralStorage = builder.ephemeralStorage;
this.executionRoleArn = builder.executionRoleArn;
this.platformVersion = builder.platformVersion;
this.ipcMode = builder.ipcMode;
this.taskRoleArn = builder.taskRoleArn;
this.pidMode = builder.pidMode;
this.networkConfiguration = builder.networkConfiguration;
this.runtimePlatform = builder.runtimePlatform;
this.volumes = builder.volumes;
}
/**
* For responses, this returns true if the service returned a value for the Containers 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 hasContainers() {
return containers != null && !(containers instanceof SdkAutoConstructList);
}
/**
*
* A list of containers that are included in the taskProperties
list.
*
*
* 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 #hasContainers} method.
*
*
* @return A list of containers that are included in the taskProperties
list.
*/
public final List containers() {
return containers;
}
/**
*
* The Amazon Resource Name (ARN) of the container instance that hosts the task.
*
*
* @return The Amazon Resource Name (ARN) of the container instance that hosts the task.
*/
public final String containerInstanceArn() {
return containerInstanceArn;
}
/**
*
* The ARN of the Amazon ECS task.
*
*
* @return The ARN of the Amazon ECS task.
*/
public final String taskArn() {
return taskArn;
}
/**
*
* The amount of ephemeral storage allocated for the task.
*
*
* @return The amount of ephemeral storage allocated for the task.
*/
public final EphemeralStorage ephemeralStorage() {
return ephemeralStorage;
}
/**
*
* The Amazon Resource Name (ARN) of the execution role that Batch can assume. For more information, see Batch execution IAM role in
* the Batch User Guide.
*
*
* @return The Amazon Resource Name (ARN) of the execution role that Batch can assume. For more information, see Batch execution IAM
* role in the Batch User Guide.
*/
public final String executionRoleArn() {
return executionRoleArn;
}
/**
*
* The Fargate platform version where the jobs are running.
*
*
* @return The Fargate platform version where the jobs are running.
*/
public final String platformVersion() {
return platformVersion;
}
/**
*
* The IPC resource namespace to use for the containers in the task.
*
*
* @return The IPC resource namespace to use for the containers in the task.
*/
public final String ipcMode() {
return ipcMode;
}
/**
*
* The Amazon Resource Name (ARN) of the IAM role that the container can assume for Amazon Web Services permissions.
* For more information, see IAM roles for tasks in
* the Amazon Elastic Container Service Developer Guide.
*
*
*
* This is object is comparable to ContainerProperties:jobRoleArn.
*
*
*
* @return The Amazon Resource Name (ARN) of the IAM role that the container can assume for Amazon Web Services
* permissions. For more information, see IAM roles for
* tasks in the Amazon Elastic Container Service Developer Guide.
*
* This is object is comparable to ContainerProperties:jobRoleArn.
*
*/
public final String taskRoleArn() {
return taskRoleArn;
}
/**
*
* The process namespace to use for the containers in the task.
*
*
* @return The process namespace to use for the containers in the task.
*/
public final String pidMode() {
return pidMode;
}
/**
*
* The network configuration for jobs that are running on Fargate resources. Jobs that are running on Amazon EC2
* resources must not specify this parameter.
*
*
* @return The network configuration for jobs that are running on Fargate resources. Jobs that are running on Amazon
* EC2 resources must not specify this parameter.
*/
public final NetworkConfiguration networkConfiguration() {
return networkConfiguration;
}
/**
*
* An object that represents the compute environment architecture for Batch jobs on Fargate.
*
*
* @return An object that represents the compute environment architecture for Batch jobs on Fargate.
*/
public final RuntimePlatform runtimePlatform() {
return runtimePlatform;
}
/**
* For responses, this returns true if the service returned a value for the Volumes 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 hasVolumes() {
return volumes != null && !(volumes instanceof SdkAutoConstructList);
}
/**
*
* A list of data volumes used in a job.
*
*
* 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 #hasVolumes} method.
*
*
* @return A list of data volumes used in a job.
*/
public final List volumes() {
return volumes;
}
@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(hasContainers() ? containers() : null);
hashCode = 31 * hashCode + Objects.hashCode(containerInstanceArn());
hashCode = 31 * hashCode + Objects.hashCode(taskArn());
hashCode = 31 * hashCode + Objects.hashCode(ephemeralStorage());
hashCode = 31 * hashCode + Objects.hashCode(executionRoleArn());
hashCode = 31 * hashCode + Objects.hashCode(platformVersion());
hashCode = 31 * hashCode + Objects.hashCode(ipcMode());
hashCode = 31 * hashCode + Objects.hashCode(taskRoleArn());
hashCode = 31 * hashCode + Objects.hashCode(pidMode());
hashCode = 31 * hashCode + Objects.hashCode(networkConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(runtimePlatform());
hashCode = 31 * hashCode + Objects.hashCode(hasVolumes() ? volumes() : 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 EcsTaskDetails)) {
return false;
}
EcsTaskDetails other = (EcsTaskDetails) obj;
return hasContainers() == other.hasContainers() && Objects.equals(containers(), other.containers())
&& Objects.equals(containerInstanceArn(), other.containerInstanceArn())
&& Objects.equals(taskArn(), other.taskArn()) && Objects.equals(ephemeralStorage(), other.ephemeralStorage())
&& Objects.equals(executionRoleArn(), other.executionRoleArn())
&& Objects.equals(platformVersion(), other.platformVersion()) && Objects.equals(ipcMode(), other.ipcMode())
&& Objects.equals(taskRoleArn(), other.taskRoleArn()) && Objects.equals(pidMode(), other.pidMode())
&& Objects.equals(networkConfiguration(), other.networkConfiguration())
&& Objects.equals(runtimePlatform(), other.runtimePlatform()) && hasVolumes() == other.hasVolumes()
&& Objects.equals(volumes(), other.volumes());
}
/**
* 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("EcsTaskDetails").add("Containers", hasContainers() ? containers() : null)
.add("ContainerInstanceArn", containerInstanceArn()).add("TaskArn", taskArn())
.add("EphemeralStorage", ephemeralStorage()).add("ExecutionRoleArn", executionRoleArn())
.add("PlatformVersion", platformVersion()).add("IpcMode", ipcMode()).add("TaskRoleArn", taskRoleArn())
.add("PidMode", pidMode()).add("NetworkConfiguration", networkConfiguration())
.add("RuntimePlatform", runtimePlatform()).add("Volumes", hasVolumes() ? volumes() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "containers":
return Optional.ofNullable(clazz.cast(containers()));
case "containerInstanceArn":
return Optional.ofNullable(clazz.cast(containerInstanceArn()));
case "taskArn":
return Optional.ofNullable(clazz.cast(taskArn()));
case "ephemeralStorage":
return Optional.ofNullable(clazz.cast(ephemeralStorage()));
case "executionRoleArn":
return Optional.ofNullable(clazz.cast(executionRoleArn()));
case "platformVersion":
return Optional.ofNullable(clazz.cast(platformVersion()));
case "ipcMode":
return Optional.ofNullable(clazz.cast(ipcMode()));
case "taskRoleArn":
return Optional.ofNullable(clazz.cast(taskRoleArn()));
case "pidMode":
return Optional.ofNullable(clazz.cast(pidMode()));
case "networkConfiguration":
return Optional.ofNullable(clazz.cast(networkConfiguration()));
case "runtimePlatform":
return Optional.ofNullable(clazz.cast(runtimePlatform()));
case "volumes":
return Optional.ofNullable(clazz.cast(volumes()));
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