
software.amazon.awssdk.services.codedeploy.model.ECSTaskSet 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.codedeploy.model;
import java.io.Serializable;
import java.util.Arrays;
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 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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a set of Amazon ECS tasks in an CodeDeploy deployment. An Amazon ECS task set includes details such
* as the desired number of tasks, how many tasks are running, and whether the task set serves production traffic. An
* CodeDeploy application that uses the Amazon ECS compute platform deploys a containerized application in an Amazon ECS
* service as a task set.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ECSTaskSet implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField IDENTIFER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("identifer").getter(getter(ECSTaskSet::identifer)).setter(setter(Builder::identifer))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("identifer").build()).build();
private static final SdkField DESIRED_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("desiredCount").getter(getter(ECSTaskSet::desiredCount)).setter(setter(Builder::desiredCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("desiredCount").build()).build();
private static final SdkField PENDING_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("pendingCount").getter(getter(ECSTaskSet::pendingCount)).setter(setter(Builder::pendingCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pendingCount").build()).build();
private static final SdkField RUNNING_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("runningCount").getter(getter(ECSTaskSet::runningCount)).setter(setter(Builder::runningCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("runningCount").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(ECSTaskSet::status)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField TRAFFIC_WEIGHT_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("trafficWeight").getter(getter(ECSTaskSet::trafficWeight)).setter(setter(Builder::trafficWeight))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("trafficWeight").build()).build();
private static final SdkField TARGET_GROUP_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("targetGroup")
.getter(getter(ECSTaskSet::targetGroup)).setter(setter(Builder::targetGroup)).constructor(TargetGroupInfo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targetGroup").build()).build();
private static final SdkField TASK_SET_LABEL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("taskSetLabel").getter(getter(ECSTaskSet::taskSetLabelAsString)).setter(setter(Builder::taskSetLabel))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskSetLabel").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IDENTIFER_FIELD,
DESIRED_COUNT_FIELD, PENDING_COUNT_FIELD, RUNNING_COUNT_FIELD, STATUS_FIELD, TRAFFIC_WEIGHT_FIELD,
TARGET_GROUP_FIELD, TASK_SET_LABEL_FIELD));
private static final long serialVersionUID = 1L;
private final String identifer;
private final Long desiredCount;
private final Long pendingCount;
private final Long runningCount;
private final String status;
private final Double trafficWeight;
private final TargetGroupInfo targetGroup;
private final String taskSetLabel;
private ECSTaskSet(BuilderImpl builder) {
this.identifer = builder.identifer;
this.desiredCount = builder.desiredCount;
this.pendingCount = builder.pendingCount;
this.runningCount = builder.runningCount;
this.status = builder.status;
this.trafficWeight = builder.trafficWeight;
this.targetGroup = builder.targetGroup;
this.taskSetLabel = builder.taskSetLabel;
}
/**
*
* A unique ID of an ECSTaskSet
.
*
*
* @return A unique ID of an ECSTaskSet
.
*/
public final String identifer() {
return identifer;
}
/**
*
* The number of tasks in a task set. During a deployment that uses the Amazon ECS compute type, CodeDeploy
* instructs Amazon ECS to create a new task set and uses this value to determine how many tasks to create. After
* the updated task set is created, CodeDeploy shifts traffic to the new task set.
*
*
* @return The number of tasks in a task set. During a deployment that uses the Amazon ECS compute type, CodeDeploy
* instructs Amazon ECS to create a new task set and uses this value to determine how many tasks to create.
* After the updated task set is created, CodeDeploy shifts traffic to the new task set.
*/
public final Long desiredCount() {
return desiredCount;
}
/**
*
* The number of tasks in the task set that are in the PENDING
status during an Amazon ECS deployment.
* A task in the PENDING
state is preparing to enter the RUNNING
state. A task set enters
* the PENDING
status when it launches for the first time, or when it is restarted after being in the
* STOPPED
state.
*
*
* @return The number of tasks in the task set that are in the PENDING
status during an Amazon ECS
* deployment. A task in the PENDING
state is preparing to enter the RUNNING
* state. A task set enters the PENDING
status when it launches for the first time, or when it
* is restarted after being in the STOPPED
state.
*/
public final Long pendingCount() {
return pendingCount;
}
/**
*
* The number of tasks in the task set that are in the RUNNING
status during an Amazon ECS deployment.
* A task in the RUNNING
state is running and ready for use.
*
*
* @return The number of tasks in the task set that are in the RUNNING
status during an Amazon ECS
* deployment. A task in the RUNNING
state is running and ready for use.
*/
public final Long runningCount() {
return runningCount;
}
/**
*
* The status of the task set. There are three valid task set statuses:
*
*
* -
*
* PRIMARY
: Indicates the task set is serving production traffic.
*
*
* -
*
* ACTIVE
: Indicates the task set is not serving production traffic.
*
*
* -
*
* DRAINING
: Indicates the tasks in the task set are being stopped and their corresponding targets are
* being deregistered from their target group.
*
*
*
*
* @return The status of the task set. There are three valid task set statuses:
*
* -
*
* PRIMARY
: Indicates the task set is serving production traffic.
*
*
* -
*
* ACTIVE
: Indicates the task set is not serving production traffic.
*
*
* -
*
* DRAINING
: Indicates the tasks in the task set are being stopped and their corresponding
* targets are being deregistered from their target group.
*
*
*/
public final String status() {
return status;
}
/**
*
* The percentage of traffic served by this task set.
*
*
* @return The percentage of traffic served by this task set.
*/
public final Double trafficWeight() {
return trafficWeight;
}
/**
*
* The target group associated with the task set. The target group is used by CodeDeploy to manage traffic to a task
* set.
*
*
* @return The target group associated with the task set. The target group is used by CodeDeploy to manage traffic
* to a task set.
*/
public final TargetGroupInfo targetGroup() {
return targetGroup;
}
/**
*
* A label that identifies whether the ECS task set is an original target (BLUE
) or a replacement
* target (GREEN
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #taskSetLabel} will
* return {@link TargetLabel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #taskSetLabelAsString}.
*
*
* @return A label that identifies whether the ECS task set is an original target (BLUE
) or a
* replacement target (GREEN
).
* @see TargetLabel
*/
public final TargetLabel taskSetLabel() {
return TargetLabel.fromValue(taskSetLabel);
}
/**
*
* A label that identifies whether the ECS task set is an original target (BLUE
) or a replacement
* target (GREEN
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #taskSetLabel} will
* return {@link TargetLabel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #taskSetLabelAsString}.
*
*
* @return A label that identifies whether the ECS task set is an original target (BLUE
) or a
* replacement target (GREEN
).
* @see TargetLabel
*/
public final String taskSetLabelAsString() {
return taskSetLabel;
}
@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(identifer());
hashCode = 31 * hashCode + Objects.hashCode(desiredCount());
hashCode = 31 * hashCode + Objects.hashCode(pendingCount());
hashCode = 31 * hashCode + Objects.hashCode(runningCount());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(trafficWeight());
hashCode = 31 * hashCode + Objects.hashCode(targetGroup());
hashCode = 31 * hashCode + Objects.hashCode(taskSetLabelAsString());
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 ECSTaskSet)) {
return false;
}
ECSTaskSet other = (ECSTaskSet) obj;
return Objects.equals(identifer(), other.identifer()) && Objects.equals(desiredCount(), other.desiredCount())
&& Objects.equals(pendingCount(), other.pendingCount()) && Objects.equals(runningCount(), other.runningCount())
&& Objects.equals(status(), other.status()) && Objects.equals(trafficWeight(), other.trafficWeight())
&& Objects.equals(targetGroup(), other.targetGroup())
&& Objects.equals(taskSetLabelAsString(), other.taskSetLabelAsString());
}
/**
* 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("ECSTaskSet").add("Identifer", identifer()).add("DesiredCount", desiredCount())
.add("PendingCount", pendingCount()).add("RunningCount", runningCount()).add("Status", status())
.add("TrafficWeight", trafficWeight()).add("TargetGroup", targetGroup())
.add("TaskSetLabel", taskSetLabelAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "identifer":
return Optional.ofNullable(clazz.cast(identifer()));
case "desiredCount":
return Optional.ofNullable(clazz.cast(desiredCount()));
case "pendingCount":
return Optional.ofNullable(clazz.cast(pendingCount()));
case "runningCount":
return Optional.ofNullable(clazz.cast(runningCount()));
case "status":
return Optional.ofNullable(clazz.cast(status()));
case "trafficWeight":
return Optional.ofNullable(clazz.cast(trafficWeight()));
case "targetGroup":
return Optional.ofNullable(clazz.cast(targetGroup()));
case "taskSetLabel":
return Optional.ofNullable(clazz.cast(taskSetLabelAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function