
software.amazon.awssdk.services.autoscaling.model.StepAdjustment 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.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.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 information used to create a step adjustment for a step scaling policy.
*
*
* For the following examples, suppose that you have an alarm with a breach threshold of 50:
*
*
* -
*
* To trigger the adjustment when the metric is greater than or equal to 50 and less than 60, specify a lower bound of 0
* and an upper bound of 10.
*
*
* -
*
* To trigger the adjustment when the metric is greater than 40 and less than or equal to 50, specify a lower bound of
* -10 and an upper bound of 0.
*
*
*
*
* There are a few rules for the step adjustments for your step policy:
*
*
* -
*
* The ranges of your step adjustments can't overlap or have a gap.
*
*
* -
*
* At most, one step adjustment can have a null lower bound. If one step adjustment has a negative lower bound, then
* there must be a step adjustment with a null lower bound.
*
*
* -
*
* At most, one step adjustment can have a null upper bound. If one step adjustment has a positive upper bound, then
* there must be a step adjustment with a null upper bound.
*
*
* -
*
* The upper and lower bound can't be null in the same step adjustment.
*
*
*
*
* For more information, see Step
* adjustments in the Amazon EC2 Auto Scaling User Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StepAdjustment implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField METRIC_INTERVAL_LOWER_BOUND_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("MetricIntervalLowerBound").getter(getter(StepAdjustment::metricIntervalLowerBound))
.setter(setter(Builder::metricIntervalLowerBound))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricIntervalLowerBound").build())
.build();
private static final SdkField METRIC_INTERVAL_UPPER_BOUND_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("MetricIntervalUpperBound").getter(getter(StepAdjustment::metricIntervalUpperBound))
.setter(setter(Builder::metricIntervalUpperBound))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricIntervalUpperBound").build())
.build();
private static final SdkField SCALING_ADJUSTMENT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ScalingAdjustment").getter(getter(StepAdjustment::scalingAdjustment))
.setter(setter(Builder::scalingAdjustment))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScalingAdjustment").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
METRIC_INTERVAL_LOWER_BOUND_FIELD, METRIC_INTERVAL_UPPER_BOUND_FIELD, SCALING_ADJUSTMENT_FIELD));
private static final long serialVersionUID = 1L;
private final Double metricIntervalLowerBound;
private final Double metricIntervalUpperBound;
private final Integer scalingAdjustment;
private StepAdjustment(BuilderImpl builder) {
this.metricIntervalLowerBound = builder.metricIntervalLowerBound;
this.metricIntervalUpperBound = builder.metricIntervalUpperBound;
this.scalingAdjustment = builder.scalingAdjustment;
}
/**
*
* The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is
* above the breach threshold, the lower bound is inclusive (the metric must be greater than or equal to the
* threshold plus the lower bound). Otherwise, it is exclusive (the metric must be greater than the threshold plus
* the lower bound). A null value indicates negative infinity.
*
*
* @return The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric
* value is above the breach threshold, the lower bound is inclusive (the metric must be greater than or
* equal to the threshold plus the lower bound). Otherwise, it is exclusive (the metric must be greater than
* the threshold plus the lower bound). A null value indicates negative infinity.
*/
public final Double metricIntervalLowerBound() {
return metricIntervalLowerBound;
}
/**
*
* The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is
* above the breach threshold, the upper bound is exclusive (the metric must be less than the threshold plus the
* upper bound). Otherwise, it is inclusive (the metric must be less than or equal to the threshold plus the upper
* bound). A null value indicates positive infinity.
*
*
* The upper bound must be greater than the lower bound.
*
*
* @return The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric
* value is above the breach threshold, the upper bound is exclusive (the metric must be less than the
* threshold plus the upper bound). Otherwise, it is inclusive (the metric must be less than or equal to the
* threshold plus the upper bound). A null value indicates positive infinity.
*
* The upper bound must be greater than the lower bound.
*/
public final Double metricIntervalUpperBound() {
return metricIntervalUpperBound;
}
/**
*
* The amount by which to scale, based on the specified adjustment type. A positive value adds to the current
* capacity while a negative number removes from the current capacity. For exact capacity, you must specify a
* non-negative value.
*
*
* @return The amount by which to scale, based on the specified adjustment type. A positive value adds to the
* current capacity while a negative number removes from the current capacity. For exact capacity, you must
* specify a non-negative value.
*/
public final Integer scalingAdjustment() {
return scalingAdjustment;
}
@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(metricIntervalLowerBound());
hashCode = 31 * hashCode + Objects.hashCode(metricIntervalUpperBound());
hashCode = 31 * hashCode + Objects.hashCode(scalingAdjustment());
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 StepAdjustment)) {
return false;
}
StepAdjustment other = (StepAdjustment) obj;
return Objects.equals(metricIntervalLowerBound(), other.metricIntervalLowerBound())
&& Objects.equals(metricIntervalUpperBound(), other.metricIntervalUpperBound())
&& Objects.equals(scalingAdjustment(), other.scalingAdjustment());
}
/**
* 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("StepAdjustment").add("MetricIntervalLowerBound", metricIntervalLowerBound())
.add("MetricIntervalUpperBound", metricIntervalUpperBound()).add("ScalingAdjustment", scalingAdjustment())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "MetricIntervalLowerBound":
return Optional.ofNullable(clazz.cast(metricIntervalLowerBound()));
case "MetricIntervalUpperBound":
return Optional.ofNullable(clazz.cast(metricIntervalUpperBound()));
case "ScalingAdjustment":
return Optional.ofNullable(clazz.cast(scalingAdjustment()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function