software.amazon.awssdk.services.autoscaling.model.InstanceRefresh Maven / Gradle / Ivy
Show all versions of autoscaling 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.autoscaling.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* Describes an instance refresh for an Auto Scaling group.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class InstanceRefresh implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField INSTANCE_REFRESH_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceRefreshId").getter(getter(InstanceRefresh::instanceRefreshId))
.setter(setter(Builder::instanceRefreshId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceRefreshId").build()).build();
private static final SdkField AUTO_SCALING_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AutoScalingGroupName").getter(getter(InstanceRefresh::autoScalingGroupName))
.setter(setter(Builder::autoScalingGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingGroupName").build())
.build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(InstanceRefresh::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatusReason").getter(getter(InstanceRefresh::statusReason)).setter(setter(Builder::statusReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusReason").build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartTime").getter(getter(InstanceRefresh::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndTime").getter(getter(InstanceRefresh::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final SdkField PERCENTAGE_COMPLETE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("PercentageComplete").getter(getter(InstanceRefresh::percentageComplete))
.setter(setter(Builder::percentageComplete))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PercentageComplete").build())
.build();
private static final SdkField INSTANCES_TO_UPDATE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("InstancesToUpdate").getter(getter(InstanceRefresh::instancesToUpdate))
.setter(setter(Builder::instancesToUpdate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstancesToUpdate").build()).build();
private static final SdkField PROGRESS_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ProgressDetails")
.getter(getter(InstanceRefresh::progressDetails)).setter(setter(Builder::progressDetails))
.constructor(InstanceRefreshProgressDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProgressDetails").build()).build();
private static final SdkField PREFERENCES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Preferences")
.getter(getter(InstanceRefresh::preferences)).setter(setter(Builder::preferences))
.constructor(RefreshPreferences::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Preferences").build()).build();
private static final SdkField DESIRED_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("DesiredConfiguration")
.getter(getter(InstanceRefresh::desiredConfiguration)).setter(setter(Builder::desiredConfiguration))
.constructor(DesiredConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DesiredConfiguration").build())
.build();
private static final SdkField ROLLBACK_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RollbackDetails")
.getter(getter(InstanceRefresh::rollbackDetails)).setter(setter(Builder::rollbackDetails))
.constructor(RollbackDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RollbackDetails").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INSTANCE_REFRESH_ID_FIELD,
AUTO_SCALING_GROUP_NAME_FIELD, STATUS_FIELD, STATUS_REASON_FIELD, START_TIME_FIELD, END_TIME_FIELD,
PERCENTAGE_COMPLETE_FIELD, INSTANCES_TO_UPDATE_FIELD, PROGRESS_DETAILS_FIELD, PREFERENCES_FIELD,
DESIRED_CONFIGURATION_FIELD, ROLLBACK_DETAILS_FIELD));
private static final long serialVersionUID = 1L;
private final String instanceRefreshId;
private final String autoScalingGroupName;
private final String status;
private final String statusReason;
private final Instant startTime;
private final Instant endTime;
private final Integer percentageComplete;
private final Integer instancesToUpdate;
private final InstanceRefreshProgressDetails progressDetails;
private final RefreshPreferences preferences;
private final DesiredConfiguration desiredConfiguration;
private final RollbackDetails rollbackDetails;
private InstanceRefresh(BuilderImpl builder) {
this.instanceRefreshId = builder.instanceRefreshId;
this.autoScalingGroupName = builder.autoScalingGroupName;
this.status = builder.status;
this.statusReason = builder.statusReason;
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.percentageComplete = builder.percentageComplete;
this.instancesToUpdate = builder.instancesToUpdate;
this.progressDetails = builder.progressDetails;
this.preferences = builder.preferences;
this.desiredConfiguration = builder.desiredConfiguration;
this.rollbackDetails = builder.rollbackDetails;
}
/**
*
* The instance refresh ID.
*
*
* @return The instance refresh ID.
*/
public final String instanceRefreshId() {
return instanceRefreshId;
}
/**
*
* The name of the Auto Scaling group.
*
*
* @return The name of the Auto Scaling group.
*/
public final String autoScalingGroupName() {
return autoScalingGroupName;
}
/**
*
* The current status for the instance refresh operation:
*
*
* -
*
* Pending
- The request was created, but the instance refresh has not started.
*
*
* -
*
* InProgress
- An instance refresh is in progress.
*
*
* -
*
* Successful
- An instance refresh completed successfully.
*
*
* -
*
* Failed
- An instance refresh failed to complete. You can troubleshoot using the status reason and
* the scaling activities.
*
*
* -
*
* Cancelling
- An ongoing instance refresh is being cancelled.
*
*
* -
*
* Cancelled
- The instance refresh is cancelled.
*
*
* -
*
* RollbackInProgress
- An instance refresh is being rolled back.
*
*
* -
*
* RollbackFailed
- The rollback failed to complete. You can troubleshoot using the status reason and
* the scaling activities.
*
*
* -
*
* RollbackSuccessful
- The rollback completed successfully.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link InstanceRefreshStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The current status for the instance refresh operation:
*
* -
*
* Pending
- The request was created, but the instance refresh has not started.
*
*
* -
*
* InProgress
- An instance refresh is in progress.
*
*
* -
*
* Successful
- An instance refresh completed successfully.
*
*
* -
*
* Failed
- An instance refresh failed to complete. You can troubleshoot using the status
* reason and the scaling activities.
*
*
* -
*
* Cancelling
- An ongoing instance refresh is being cancelled.
*
*
* -
*
* Cancelled
- The instance refresh is cancelled.
*
*
* -
*
* RollbackInProgress
- An instance refresh is being rolled back.
*
*
* -
*
* RollbackFailed
- The rollback failed to complete. You can troubleshoot using the status
* reason and the scaling activities.
*
*
* -
*
* RollbackSuccessful
- The rollback completed successfully.
*
*
* @see InstanceRefreshStatus
*/
public final InstanceRefreshStatus status() {
return InstanceRefreshStatus.fromValue(status);
}
/**
*
* The current status for the instance refresh operation:
*
*
* -
*
* Pending
- The request was created, but the instance refresh has not started.
*
*
* -
*
* InProgress
- An instance refresh is in progress.
*
*
* -
*
* Successful
- An instance refresh completed successfully.
*
*
* -
*
* Failed
- An instance refresh failed to complete. You can troubleshoot using the status reason and
* the scaling activities.
*
*
* -
*
* Cancelling
- An ongoing instance refresh is being cancelled.
*
*
* -
*
* Cancelled
- The instance refresh is cancelled.
*
*
* -
*
* RollbackInProgress
- An instance refresh is being rolled back.
*
*
* -
*
* RollbackFailed
- The rollback failed to complete. You can troubleshoot using the status reason and
* the scaling activities.
*
*
* -
*
* RollbackSuccessful
- The rollback completed successfully.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link InstanceRefreshStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The current status for the instance refresh operation:
*
* -
*
* Pending
- The request was created, but the instance refresh has not started.
*
*
* -
*
* InProgress
- An instance refresh is in progress.
*
*
* -
*
* Successful
- An instance refresh completed successfully.
*
*
* -
*
* Failed
- An instance refresh failed to complete. You can troubleshoot using the status
* reason and the scaling activities.
*
*
* -
*
* Cancelling
- An ongoing instance refresh is being cancelled.
*
*
* -
*
* Cancelled
- The instance refresh is cancelled.
*
*
* -
*
* RollbackInProgress
- An instance refresh is being rolled back.
*
*
* -
*
* RollbackFailed
- The rollback failed to complete. You can troubleshoot using the status
* reason and the scaling activities.
*
*
* -
*
* RollbackSuccessful
- The rollback completed successfully.
*
*
* @see InstanceRefreshStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The explanation for the specific status assigned to this operation.
*
*
* @return The explanation for the specific status assigned to this operation.
*/
public final String statusReason() {
return statusReason;
}
/**
*
* The date and time at which the instance refresh began.
*
*
* @return The date and time at which the instance refresh began.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The date and time at which the instance refresh ended.
*
*
* @return The date and time at which the instance refresh ended.
*/
public final Instant endTime() {
return endTime;
}
/**
*
* The percentage of the instance refresh that is complete. For each instance replacement, Amazon EC2 Auto Scaling
* tracks the instance's health status and warm-up time. When the instance's health status changes to healthy and
* the specified warm-up time passes, the instance is considered updated and is added to the percentage complete.
*
*
*
* PercentageComplete
does not include instances that are replaced during a rollback. This value
* gradually goes back down to zero during a rollback.
*
*
*
* @return The percentage of the instance refresh that is complete. For each instance replacement, Amazon EC2 Auto
* Scaling tracks the instance's health status and warm-up time. When the instance's health status changes
* to healthy and the specified warm-up time passes, the instance is considered updated and is added to the
* percentage complete.
*
* PercentageComplete
does not include instances that are replaced during a rollback. This
* value gradually goes back down to zero during a rollback.
*
*/
public final Integer percentageComplete() {
return percentageComplete;
}
/**
*
* The number of instances remaining to update before the instance refresh is complete.
*
*
*
* If you roll back the instance refresh, InstancesToUpdate
shows you the number of instances that were
* not yet updated by the instance refresh. Therefore, these instances don't need to be replaced as part of the
* rollback.
*
*
*
* @return The number of instances remaining to update before the instance refresh is complete.
*
* If you roll back the instance refresh, InstancesToUpdate
shows you the number of instances
* that were not yet updated by the instance refresh. Therefore, these instances don't need to be replaced
* as part of the rollback.
*
*/
public final Integer instancesToUpdate() {
return instancesToUpdate;
}
/**
*
* Additional progress details for an Auto Scaling group that has a warm pool.
*
*
* @return Additional progress details for an Auto Scaling group that has a warm pool.
*/
public final InstanceRefreshProgressDetails progressDetails() {
return progressDetails;
}
/**
*
* The preferences for an instance refresh.
*
*
* @return The preferences for an instance refresh.
*/
public final RefreshPreferences preferences() {
return preferences;
}
/**
*
* Describes the desired configuration for the instance refresh.
*
*
* @return Describes the desired configuration for the instance refresh.
*/
public final DesiredConfiguration desiredConfiguration() {
return desiredConfiguration;
}
/**
*
* The rollback details.
*
*
* @return The rollback details.
*/
public final RollbackDetails rollbackDetails() {
return rollbackDetails;
}
@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(instanceRefreshId());
hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroupName());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusReason());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
hashCode = 31 * hashCode + Objects.hashCode(percentageComplete());
hashCode = 31 * hashCode + Objects.hashCode(instancesToUpdate());
hashCode = 31 * hashCode + Objects.hashCode(progressDetails());
hashCode = 31 * hashCode + Objects.hashCode(preferences());
hashCode = 31 * hashCode + Objects.hashCode(desiredConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(rollbackDetails());
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 InstanceRefresh)) {
return false;
}
InstanceRefresh other = (InstanceRefresh) obj;
return Objects.equals(instanceRefreshId(), other.instanceRefreshId())
&& Objects.equals(autoScalingGroupName(), other.autoScalingGroupName())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(statusReason(), other.statusReason()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(endTime(), other.endTime()) && Objects.equals(percentageComplete(), other.percentageComplete())
&& Objects.equals(instancesToUpdate(), other.instancesToUpdate())
&& Objects.equals(progressDetails(), other.progressDetails())
&& Objects.equals(preferences(), other.preferences())
&& Objects.equals(desiredConfiguration(), other.desiredConfiguration())
&& Objects.equals(rollbackDetails(), other.rollbackDetails());
}
/**
* 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("InstanceRefresh").add("InstanceRefreshId", instanceRefreshId())
.add("AutoScalingGroupName", autoScalingGroupName()).add("Status", statusAsString())
.add("StatusReason", statusReason()).add("StartTime", startTime()).add("EndTime", endTime())
.add("PercentageComplete", percentageComplete()).add("InstancesToUpdate", instancesToUpdate())
.add("ProgressDetails", progressDetails()).add("Preferences", preferences())
.add("DesiredConfiguration", desiredConfiguration()).add("RollbackDetails", rollbackDetails()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InstanceRefreshId":
return Optional.ofNullable(clazz.cast(instanceRefreshId()));
case "AutoScalingGroupName":
return Optional.ofNullable(clazz.cast(autoScalingGroupName()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "StatusReason":
return Optional.ofNullable(clazz.cast(statusReason()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "PercentageComplete":
return Optional.ofNullable(clazz.cast(percentageComplete()));
case "InstancesToUpdate":
return Optional.ofNullable(clazz.cast(instancesToUpdate()));
case "ProgressDetails":
return Optional.ofNullable(clazz.cast(progressDetails()));
case "Preferences":
return Optional.ofNullable(clazz.cast(preferences()));
case "DesiredConfiguration":
return Optional.ofNullable(clazz.cast(desiredConfiguration()));
case "RollbackDetails":
return Optional.ofNullable(clazz.cast(rollbackDetails()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function