software.amazon.awssdk.services.autoscaling.model.StartInstanceRefreshRequest 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.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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class StartInstanceRefreshRequest extends AutoScalingRequest implements
ToCopyableBuilder {
private static final SdkField AUTO_SCALING_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AutoScalingGroupName").getter(getter(StartInstanceRefreshRequest::autoScalingGroupName))
.setter(setter(Builder::autoScalingGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingGroupName").build())
.build();
private static final SdkField STRATEGY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Strategy").getter(getter(StartInstanceRefreshRequest::strategyAsString))
.setter(setter(Builder::strategy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Strategy").build()).build();
private static final SdkField DESIRED_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("DesiredConfiguration")
.getter(getter(StartInstanceRefreshRequest::desiredConfiguration)).setter(setter(Builder::desiredConfiguration))
.constructor(DesiredConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DesiredConfiguration").build())
.build();
private static final SdkField PREFERENCES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Preferences")
.getter(getter(StartInstanceRefreshRequest::preferences)).setter(setter(Builder::preferences))
.constructor(RefreshPreferences::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Preferences").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AUTO_SCALING_GROUP_NAME_FIELD,
STRATEGY_FIELD, DESIRED_CONFIGURATION_FIELD, PREFERENCES_FIELD));
private final String autoScalingGroupName;
private final String strategy;
private final DesiredConfiguration desiredConfiguration;
private final RefreshPreferences preferences;
private StartInstanceRefreshRequest(BuilderImpl builder) {
super(builder);
this.autoScalingGroupName = builder.autoScalingGroupName;
this.strategy = builder.strategy;
this.desiredConfiguration = builder.desiredConfiguration;
this.preferences = builder.preferences;
}
/**
*
* The name of the Auto Scaling group.
*
*
* @return The name of the Auto Scaling group.
*/
public final String autoScalingGroupName() {
return autoScalingGroupName;
}
/**
*
* The strategy to use for the instance refresh. The only valid value is Rolling
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #strategy} will
* return {@link RefreshStrategy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #strategyAsString}.
*
*
* @return The strategy to use for the instance refresh. The only valid value is Rolling
.
* @see RefreshStrategy
*/
public final RefreshStrategy strategy() {
return RefreshStrategy.fromValue(strategy);
}
/**
*
* The strategy to use for the instance refresh. The only valid value is Rolling
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #strategy} will
* return {@link RefreshStrategy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #strategyAsString}.
*
*
* @return The strategy to use for the instance refresh. The only valid value is Rolling
.
* @see RefreshStrategy
*/
public final String strategyAsString() {
return strategy;
}
/**
*
* The desired configuration. For example, the desired configuration can specify a new launch template or a new
* version of the current launch template.
*
*
* Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to
* reflect the new desired configuration.
*
*
*
* When you specify a new launch template or a new version of the current launch template for your desired
* configuration, consider enabling the SkipMatching
property in preferences. If it's enabled, Amazon
* EC2 Auto Scaling skips replacing instances that already use the specified launch template and instance types.
* This can help you reduce the number of replacements that are required to apply updates.
*
*
*
* @return The desired configuration. For example, the desired configuration can specify a new launch template or a
* new version of the current launch template.
*
* Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling
* group to reflect the new desired configuration.
*
*
*
* When you specify a new launch template or a new version of the current launch template for your desired
* configuration, consider enabling the SkipMatching
property in preferences. If it's enabled,
* Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and
* instance types. This can help you reduce the number of replacements that are required to apply updates.
*
*/
public final DesiredConfiguration desiredConfiguration() {
return desiredConfiguration;
}
/**
*
* Sets your preferences for the instance refresh so that it performs as expected when you start it. Includes the
* instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2
* Auto Scaling to use if instances that are in Standby
state or protected from scale in are found. You
* can also choose to enable additional features, such as the following:
*
*
* -
*
* Auto rollback
*
*
* -
*
* Checkpoints
*
*
* -
*
* CloudWatch alarms
*
*
* -
*
* Skip matching
*
*
*
*
* @return Sets your preferences for the instance refresh so that it performs as expected when you start it.
* Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that
* you want Amazon EC2 Auto Scaling to use if instances that are in Standby
state or protected
* from scale in are found. You can also choose to enable additional features, such as the following:
*
* -
*
* Auto rollback
*
*
* -
*
* Checkpoints
*
*
* -
*
* CloudWatch alarms
*
*
* -
*
* Skip matching
*
*
*/
public final RefreshPreferences preferences() {
return preferences;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroupName());
hashCode = 31 * hashCode + Objects.hashCode(strategyAsString());
hashCode = 31 * hashCode + Objects.hashCode(desiredConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(preferences());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof StartInstanceRefreshRequest)) {
return false;
}
StartInstanceRefreshRequest other = (StartInstanceRefreshRequest) obj;
return Objects.equals(autoScalingGroupName(), other.autoScalingGroupName())
&& Objects.equals(strategyAsString(), other.strategyAsString())
&& Objects.equals(desiredConfiguration(), other.desiredConfiguration())
&& Objects.equals(preferences(), other.preferences());
}
/**
* 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("StartInstanceRefreshRequest").add("AutoScalingGroupName", autoScalingGroupName())
.add("Strategy", strategyAsString()).add("DesiredConfiguration", desiredConfiguration())
.add("Preferences", preferences()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AutoScalingGroupName":
return Optional.ofNullable(clazz.cast(autoScalingGroupName()));
case "Strategy":
return Optional.ofNullable(clazz.cast(strategyAsString()));
case "DesiredConfiguration":
return Optional.ofNullable(clazz.cast(desiredConfiguration()));
case "Preferences":
return Optional.ofNullable(clazz.cast(preferences()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function