software.amazon.awssdk.services.guardduty.model.EcsTaskDetails Maven / Gradle / Ivy
Show all versions of guardduty 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.guardduty.model;
import java.io.Serializable;
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.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;
/**
*
* Contains information about the task in an ECS cluster.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EcsTaskDetails implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(EcsTaskDetails::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField DEFINITION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DefinitionArn").getter(getter(EcsTaskDetails::definitionArn)).setter(setter(Builder::definitionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("definitionArn").build()).build();
private static final SdkField VERSION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Version")
.getter(getter(EcsTaskDetails::version)).setter(setter(Builder::version))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("version").build()).build();
private static final SdkField TASK_CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("TaskCreatedAt").getter(getter(EcsTaskDetails::taskCreatedAt)).setter(setter(Builder::taskCreatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build()).build();
private static final SdkField STARTED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartedAt").getter(getter(EcsTaskDetails::startedAt)).setter(setter(Builder::startedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startedAt").build()).build();
private static final SdkField STARTED_BY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StartedBy").getter(getter(EcsTaskDetails::startedBy)).setter(setter(Builder::startedBy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startedBy").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(EcsTaskDetails::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).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 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(Container::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField GROUP_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Group")
.getter(getter(EcsTaskDetails::group)).setter(setter(Builder::group))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("group").build()).build();
private static final SdkField LAUNCH_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LaunchType").getter(getter(EcsTaskDetails::launchType)).setter(setter(Builder::launchType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("launchType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD,
DEFINITION_ARN_FIELD, VERSION_FIELD, TASK_CREATED_AT_FIELD, STARTED_AT_FIELD, STARTED_BY_FIELD, TAGS_FIELD,
VOLUMES_FIELD, CONTAINERS_FIELD, GROUP_FIELD, LAUNCH_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String arn;
private final String definitionArn;
private final String version;
private final Instant taskCreatedAt;
private final Instant startedAt;
private final String startedBy;
private final List tags;
private final List volumes;
private final List containers;
private final String group;
private final String launchType;
private EcsTaskDetails(BuilderImpl builder) {
this.arn = builder.arn;
this.definitionArn = builder.definitionArn;
this.version = builder.version;
this.taskCreatedAt = builder.taskCreatedAt;
this.startedAt = builder.startedAt;
this.startedBy = builder.startedBy;
this.tags = builder.tags;
this.volumes = builder.volumes;
this.containers = builder.containers;
this.group = builder.group;
this.launchType = builder.launchType;
}
/**
*
* The Amazon Resource Name (ARN) of the task.
*
*
* @return The Amazon Resource Name (ARN) of the task.
*/
public final String arn() {
return arn;
}
/**
*
* The ARN of the task definition that creates the task.
*
*
* @return The ARN of the task definition that creates the task.
*/
public final String definitionArn() {
return definitionArn;
}
/**
*
* The version counter for the task.
*
*
* @return The version counter for the task.
*/
public final String version() {
return version;
}
/**
*
* The Unix timestamp for the time when the task was created.
*
*
* @return The Unix timestamp for the time when the task was created.
*/
public final Instant taskCreatedAt() {
return taskCreatedAt;
}
/**
*
* The Unix timestamp for the time when the task started.
*
*
* @return The Unix timestamp for the time when the task started.
*/
public final Instant startedAt() {
return startedAt;
}
/**
*
* Contains the tag specified when a task is started.
*
*
* @return Contains the tag specified when a task is started.
*/
public final String startedBy() {
return startedBy;
}
/**
* 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 SdkAutoConstructList);
}
/**
*
* The tags of the 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 #hasTags} method.
*
*
* @return The tags of the ECS Task.
*/
public final List tags() {
return tags;
}
/**
* 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);
}
/**
*
* The list of data volume definitions for the 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 #hasVolumes} method.
*
*
* @return The list of data volume definitions for the task.
*/
public final List volumes() {
return 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);
}
/**
*
* The containers that's associated with the 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 #hasContainers} method.
*
*
* @return The containers that's associated with the task.
*/
public final List containers() {
return containers;
}
/**
*
* The name of the task group that's associated with the task.
*
*
* @return The name of the task group that's associated with the task.
*/
public final String group() {
return group;
}
/**
*
* A capacity on which the task is running. For example, Fargate
and EC2
.
*
*
* @return A capacity on which the task is running. For example, Fargate
and EC2
.
*/
public final String launchType() {
return launchType;
}
@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 + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(definitionArn());
hashCode = 31 * hashCode + Objects.hashCode(version());
hashCode = 31 * hashCode + Objects.hashCode(taskCreatedAt());
hashCode = 31 * hashCode + Objects.hashCode(startedAt());
hashCode = 31 * hashCode + Objects.hashCode(startedBy());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasVolumes() ? volumes() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasContainers() ? containers() : null);
hashCode = 31 * hashCode + Objects.hashCode(group());
hashCode = 31 * hashCode + Objects.hashCode(launchType());
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 Objects.equals(arn(), other.arn()) && Objects.equals(definitionArn(), other.definitionArn())
&& Objects.equals(version(), other.version()) && Objects.equals(taskCreatedAt(), other.taskCreatedAt())
&& Objects.equals(startedAt(), other.startedAt()) && Objects.equals(startedBy(), other.startedBy())
&& hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()) && hasVolumes() == other.hasVolumes()
&& Objects.equals(volumes(), other.volumes()) && hasContainers() == other.hasContainers()
&& Objects.equals(containers(), other.containers()) && Objects.equals(group(), other.group())
&& Objects.equals(launchType(), other.launchType());
}
/**
* 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("Arn", arn()).add("DefinitionArn", definitionArn())
.add("Version", version()).add("TaskCreatedAt", taskCreatedAt()).add("StartedAt", startedAt())
.add("StartedBy", startedBy()).add("Tags", hasTags() ? tags() : null)
.add("Volumes", hasVolumes() ? volumes() : null).add("Containers", hasContainers() ? containers() : null)
.add("Group", group()).add("LaunchType", launchType()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "DefinitionArn":
return Optional.ofNullable(clazz.cast(definitionArn()));
case "Version":
return Optional.ofNullable(clazz.cast(version()));
case "TaskCreatedAt":
return Optional.ofNullable(clazz.cast(taskCreatedAt()));
case "StartedAt":
return Optional.ofNullable(clazz.cast(startedAt()));
case "StartedBy":
return Optional.ofNullable(clazz.cast(startedBy()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "Volumes":
return Optional.ofNullable(clazz.cast(volumes()));
case "Containers":
return Optional.ofNullable(clazz.cast(containers()));
case "Group":
return Optional.ofNullable(clazz.cast(group()));
case "LaunchType":
return Optional.ofNullable(clazz.cast(launchType()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function