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

software.amazon.awssdk.services.ecs.model.TaskOverride Maven / Gradle / Ivy

Go to download

The AWS Java SDK for the Amazon EC2 Container Service holds the client classes that are used for communicating with the Amazon EC2 Container Service

There is a newer version: 2.29.39
Show newest version
/*
 * 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.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;

/**
 * 

* The overrides that are associated with a task. *

*/ @Generated("software.amazon.awssdk:codegen") public final class TaskOverride implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> CONTAINER_OVERRIDES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("containerOverrides") .getter(getter(TaskOverride::containerOverrides)) .setter(setter(Builder::containerOverrides)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("containerOverrides").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(ContainerOverride::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField CPU_FIELD = SdkField. builder(MarshallingType.STRING).memberName("cpu") .getter(getter(TaskOverride::cpu)).setter(setter(Builder::cpu)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("cpu").build()).build(); private static final SdkField> INFERENCE_ACCELERATOR_OVERRIDES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("inferenceAcceleratorOverrides") .getter(getter(TaskOverride::inferenceAcceleratorOverrides)) .setter(setter(Builder::inferenceAcceleratorOverrides)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("inferenceAcceleratorOverrides") .build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(InferenceAcceleratorOverride::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField EXECUTION_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("executionRoleArn").getter(getter(TaskOverride::executionRoleArn)) .setter(setter(Builder::executionRoleArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("executionRoleArn").build()).build(); private static final SdkField MEMORY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("memory") .getter(getter(TaskOverride::memory)).setter(setter(Builder::memory)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("memory").build()).build(); private static final SdkField TASK_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("taskRoleArn").getter(getter(TaskOverride::taskRoleArn)).setter(setter(Builder::taskRoleArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskRoleArn").build()).build(); private static final SdkField EPHEMERAL_STORAGE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("ephemeralStorage") .getter(getter(TaskOverride::ephemeralStorage)).setter(setter(Builder::ephemeralStorage)) .constructor(EphemeralStorage::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ephemeralStorage").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONTAINER_OVERRIDES_FIELD, CPU_FIELD, INFERENCE_ACCELERATOR_OVERRIDES_FIELD, EXECUTION_ROLE_ARN_FIELD, MEMORY_FIELD, TASK_ROLE_ARN_FIELD, EPHEMERAL_STORAGE_FIELD)); private static final long serialVersionUID = 1L; private final List containerOverrides; private final String cpu; private final List inferenceAcceleratorOverrides; private final String executionRoleArn; private final String memory; private final String taskRoleArn; private final EphemeralStorage ephemeralStorage; private TaskOverride(BuilderImpl builder) { this.containerOverrides = builder.containerOverrides; this.cpu = builder.cpu; this.inferenceAcceleratorOverrides = builder.inferenceAcceleratorOverrides; this.executionRoleArn = builder.executionRoleArn; this.memory = builder.memory; this.taskRoleArn = builder.taskRoleArn; this.ephemeralStorage = builder.ephemeralStorage; } /** * For responses, this returns true if the service returned a value for the ContainerOverrides 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 hasContainerOverrides() { return containerOverrides != null && !(containerOverrides instanceof SdkAutoConstructList); } /** *

* One or more container overrides that are sent to a 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 #hasContainerOverrides} method. *

* * @return One or more container overrides that are sent to a task. */ public final List containerOverrides() { return containerOverrides; } /** *

* The CPU override for the task. *

* * @return The CPU override for the task. */ public final String cpu() { return cpu; } /** * For responses, this returns true if the service returned a value for the InferenceAcceleratorOverrides 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 hasInferenceAcceleratorOverrides() { return inferenceAcceleratorOverrides != null && !(inferenceAcceleratorOverrides instanceof SdkAutoConstructList); } /** *

* The Elastic Inference accelerator override 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 #hasInferenceAcceleratorOverrides} method. *

* * @return The Elastic Inference accelerator override for the task. */ public final List inferenceAcceleratorOverrides() { return inferenceAcceleratorOverrides; } /** *

* The Amazon Resource Name (ARN) of the task execution role override for the task. For more information, see Amazon ECS task * execution IAM role in the Amazon Elastic Container Service Developer Guide. *

* * @return The Amazon Resource Name (ARN) of the task execution role override for the task. For more information, * see Amazon * ECS task execution IAM role in the Amazon Elastic Container Service Developer Guide. */ public final String executionRoleArn() { return executionRoleArn; } /** *

* The memory override for the task. *

* * @return The memory override for the task. */ public final String memory() { return memory; } /** *

* The Amazon Resource Name (ARN) of the role that containers in this task can assume. All containers in this task * are granted the permissions that are specified in this role. For more information, see IAM Role for Tasks in * the Amazon Elastic Container Service Developer Guide. *

* * @return The Amazon Resource Name (ARN) of the role that containers in this task can assume. All containers in * this task are granted the permissions that are specified in this role. For more information, see IAM Role for * Tasks in the Amazon Elastic Container Service Developer Guide. */ public final String taskRoleArn() { return taskRoleArn; } /** *

* The ephemeral storage setting override for the task. *

* *

* This parameter is only supported for tasks hosted on Fargate that use the following platform versions: *

*
    *
  • *

    * Linux platform version 1.4.0 or later. *

    *
  • *
  • *

    * Windows platform version 1.0.0 or later. *

    *
  • *
*
* * @return The ephemeral storage setting override for the task.

*

* This parameter is only supported for tasks hosted on Fargate that use the following platform versions: *

*
    *
  • *

    * Linux platform version 1.4.0 or later. *

    *
  • *
  • *

    * Windows platform version 1.0.0 or later. *

    *
  • *
*/ public final EphemeralStorage ephemeralStorage() { return ephemeralStorage; } @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(hasContainerOverrides() ? containerOverrides() : null); hashCode = 31 * hashCode + Objects.hashCode(cpu()); hashCode = 31 * hashCode + Objects.hashCode(hasInferenceAcceleratorOverrides() ? inferenceAcceleratorOverrides() : null); hashCode = 31 * hashCode + Objects.hashCode(executionRoleArn()); hashCode = 31 * hashCode + Objects.hashCode(memory()); hashCode = 31 * hashCode + Objects.hashCode(taskRoleArn()); hashCode = 31 * hashCode + Objects.hashCode(ephemeralStorage()); 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 TaskOverride)) { return false; } TaskOverride other = (TaskOverride) obj; return hasContainerOverrides() == other.hasContainerOverrides() && Objects.equals(containerOverrides(), other.containerOverrides()) && Objects.equals(cpu(), other.cpu()) && hasInferenceAcceleratorOverrides() == other.hasInferenceAcceleratorOverrides() && Objects.equals(inferenceAcceleratorOverrides(), other.inferenceAcceleratorOverrides()) && Objects.equals(executionRoleArn(), other.executionRoleArn()) && Objects.equals(memory(), other.memory()) && Objects.equals(taskRoleArn(), other.taskRoleArn()) && Objects.equals(ephemeralStorage(), other.ephemeralStorage()); } /** * 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("TaskOverride") .add("ContainerOverrides", hasContainerOverrides() ? containerOverrides() : null) .add("Cpu", cpu()) .add("InferenceAcceleratorOverrides", hasInferenceAcceleratorOverrides() ? inferenceAcceleratorOverrides() : null) .add("ExecutionRoleArn", executionRoleArn()).add("Memory", memory()).add("TaskRoleArn", taskRoleArn()) .add("EphemeralStorage", ephemeralStorage()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "containerOverrides": return Optional.ofNullable(clazz.cast(containerOverrides())); case "cpu": return Optional.ofNullable(clazz.cast(cpu())); case "inferenceAcceleratorOverrides": return Optional.ofNullable(clazz.cast(inferenceAcceleratorOverrides())); case "executionRoleArn": return Optional.ofNullable(clazz.cast(executionRoleArn())); case "memory": return Optional.ofNullable(clazz.cast(memory())); case "taskRoleArn": return Optional.ofNullable(clazz.cast(taskRoleArn())); case "ephemeralStorage": return Optional.ofNullable(clazz.cast(ephemeralStorage())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((TaskOverride) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* One or more container overrides that are sent to a task. *

* * @param containerOverrides * One or more container overrides that are sent to a task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containerOverrides(Collection containerOverrides); /** *

* One or more container overrides that are sent to a task. *

* * @param containerOverrides * One or more container overrides that are sent to a task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder containerOverrides(ContainerOverride... containerOverrides); /** *

* One or more container overrides that are sent to a task. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.ecs.model.ContainerOverride.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.ecs.model.ContainerOverride#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.ecs.model.ContainerOverride.Builder#build()} is called immediately and * its result is passed to {@link #containerOverrides(List)}. * * @param containerOverrides * a consumer that will call methods on * {@link software.amazon.awssdk.services.ecs.model.ContainerOverride.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #containerOverrides(java.util.Collection) */ Builder containerOverrides(Consumer... containerOverrides); /** *

* The CPU override for the task. *

* * @param cpu * The CPU override for the task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder cpu(String cpu); /** *

* The Elastic Inference accelerator override for the task. *

* * @param inferenceAcceleratorOverrides * The Elastic Inference accelerator override for the task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder inferenceAcceleratorOverrides(Collection inferenceAcceleratorOverrides); /** *

* The Elastic Inference accelerator override for the task. *

* * @param inferenceAcceleratorOverrides * The Elastic Inference accelerator override for the task. * @return Returns a reference to this object so that method calls can be chained together. */ Builder inferenceAcceleratorOverrides(InferenceAcceleratorOverride... inferenceAcceleratorOverrides); /** *

* The Elastic Inference accelerator override for the task. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.ecs.model.InferenceAcceleratorOverride.Builder} avoiding the need to * create one manually via * {@link software.amazon.awssdk.services.ecs.model.InferenceAcceleratorOverride#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.ecs.model.InferenceAcceleratorOverride.Builder#build()} is called * immediately and its result is passed to {@link * #inferenceAcceleratorOverrides(List)}. * * @param inferenceAcceleratorOverrides * a consumer that will call methods on * {@link software.amazon.awssdk.services.ecs.model.InferenceAcceleratorOverride.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #inferenceAcceleratorOverrides(java.util.Collection) */ Builder inferenceAcceleratorOverrides(Consumer... inferenceAcceleratorOverrides); /** *

* The Amazon Resource Name (ARN) of the task execution role override for the task. For more information, see Amazon ECS * task execution IAM role in the Amazon Elastic Container Service Developer Guide. *

* * @param executionRoleArn * The Amazon Resource Name (ARN) of the task execution role override for the task. For more information, * see Amazon * ECS task execution IAM role in the Amazon Elastic Container Service Developer Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder executionRoleArn(String executionRoleArn); /** *

* The memory override for the task. *

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

* The Amazon Resource Name (ARN) of the role that containers in this task can assume. All containers in this * task are granted the permissions that are specified in this role. For more information, see IAM Role for Tasks * in the Amazon Elastic Container Service Developer Guide. *

* * @param taskRoleArn * The Amazon Resource Name (ARN) of the role that containers in this task can assume. All containers in * this task are granted the permissions that are specified in this role. For more information, see IAM Role for * Tasks in the Amazon Elastic Container Service Developer Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder taskRoleArn(String taskRoleArn); /** *

* The ephemeral storage setting override for the task. *

* *

* This parameter is only supported for tasks hosted on Fargate that use the following platform versions: *

*
    *
  • *

    * Linux platform version 1.4.0 or later. *

    *
  • *
  • *

    * Windows platform version 1.0.0 or later. *

    *
  • *
*
* * @param ephemeralStorage * The ephemeral storage setting override for the task.

*

* This parameter is only supported for tasks hosted on Fargate that use the following platform versions: *

*
    *
  • *

    * Linux platform version 1.4.0 or later. *

    *
  • *
  • *

    * Windows platform version 1.0.0 or later. *

    *
  • *
* @return Returns a reference to this object so that method calls can be chained together. */ Builder ephemeralStorage(EphemeralStorage ephemeralStorage); /** *

* The ephemeral storage setting override for the task. *

* *

* This parameter is only supported for tasks hosted on Fargate that use the following platform versions: *

*
    *
  • *

    * Linux platform version 1.4.0 or later. *

    *
  • *
  • *

    * Windows platform version 1.0.0 or later. *

    *
  • *
*
This is a convenience method that creates an instance of the {@link EphemeralStorage.Builder} * avoiding the need to create one manually via {@link EphemeralStorage#builder()}. * *

* When the {@link Consumer} completes, {@link EphemeralStorage.Builder#build()} is called immediately and its * result is passed to {@link #ephemeralStorage(EphemeralStorage)}. * * @param ephemeralStorage * a consumer that will call methods on {@link EphemeralStorage.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #ephemeralStorage(EphemeralStorage) */ default Builder ephemeralStorage(Consumer ephemeralStorage) { return ephemeralStorage(EphemeralStorage.builder().applyMutation(ephemeralStorage).build()); } } static final class BuilderImpl implements Builder { private List containerOverrides = DefaultSdkAutoConstructList.getInstance(); private String cpu; private List inferenceAcceleratorOverrides = DefaultSdkAutoConstructList.getInstance(); private String executionRoleArn; private String memory; private String taskRoleArn; private EphemeralStorage ephemeralStorage; private BuilderImpl() { } private BuilderImpl(TaskOverride model) { containerOverrides(model.containerOverrides); cpu(model.cpu); inferenceAcceleratorOverrides(model.inferenceAcceleratorOverrides); executionRoleArn(model.executionRoleArn); memory(model.memory); taskRoleArn(model.taskRoleArn); ephemeralStorage(model.ephemeralStorage); } public final List getContainerOverrides() { List result = ContainerOverridesCopier.copyToBuilder(this.containerOverrides); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setContainerOverrides(Collection containerOverrides) { this.containerOverrides = ContainerOverridesCopier.copyFromBuilder(containerOverrides); } @Override public final Builder containerOverrides(Collection containerOverrides) { this.containerOverrides = ContainerOverridesCopier.copy(containerOverrides); return this; } @Override @SafeVarargs public final Builder containerOverrides(ContainerOverride... containerOverrides) { containerOverrides(Arrays.asList(containerOverrides)); return this; } @Override @SafeVarargs public final Builder containerOverrides(Consumer... containerOverrides) { containerOverrides(Stream.of(containerOverrides).map(c -> ContainerOverride.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final String getCpu() { return cpu; } public final void setCpu(String cpu) { this.cpu = cpu; } @Override public final Builder cpu(String cpu) { this.cpu = cpu; return this; } public final List getInferenceAcceleratorOverrides() { List result = InferenceAcceleratorOverridesCopier .copyToBuilder(this.inferenceAcceleratorOverrides); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setInferenceAcceleratorOverrides( Collection inferenceAcceleratorOverrides) { this.inferenceAcceleratorOverrides = InferenceAcceleratorOverridesCopier .copyFromBuilder(inferenceAcceleratorOverrides); } @Override public final Builder inferenceAcceleratorOverrides(Collection inferenceAcceleratorOverrides) { this.inferenceAcceleratorOverrides = InferenceAcceleratorOverridesCopier.copy(inferenceAcceleratorOverrides); return this; } @Override @SafeVarargs public final Builder inferenceAcceleratorOverrides(InferenceAcceleratorOverride... inferenceAcceleratorOverrides) { inferenceAcceleratorOverrides(Arrays.asList(inferenceAcceleratorOverrides)); return this; } @Override @SafeVarargs public final Builder inferenceAcceleratorOverrides( Consumer... inferenceAcceleratorOverrides) { inferenceAcceleratorOverrides(Stream.of(inferenceAcceleratorOverrides) .map(c -> InferenceAcceleratorOverride.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final String getExecutionRoleArn() { return executionRoleArn; } public final void setExecutionRoleArn(String executionRoleArn) { this.executionRoleArn = executionRoleArn; } @Override public final Builder executionRoleArn(String executionRoleArn) { this.executionRoleArn = executionRoleArn; return this; } public final String getMemory() { return memory; } public final void setMemory(String memory) { this.memory = memory; } @Override public final Builder memory(String memory) { this.memory = memory; return this; } public final String getTaskRoleArn() { return taskRoleArn; } public final void setTaskRoleArn(String taskRoleArn) { this.taskRoleArn = taskRoleArn; } @Override public final Builder taskRoleArn(String taskRoleArn) { this.taskRoleArn = taskRoleArn; return this; } public final EphemeralStorage.Builder getEphemeralStorage() { return ephemeralStorage != null ? ephemeralStorage.toBuilder() : null; } public final void setEphemeralStorage(EphemeralStorage.BuilderImpl ephemeralStorage) { this.ephemeralStorage = ephemeralStorage != null ? ephemeralStorage.build() : null; } @Override public final Builder ephemeralStorage(EphemeralStorage ephemeralStorage) { this.ephemeralStorage = ephemeralStorage; return this; } @Override public TaskOverride build() { return new TaskOverride(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy