software.amazon.awssdk.services.autoscaling.model.EnableMetricsCollectionRequest 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.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 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.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class EnableMetricsCollectionRequest extends AutoScalingRequest implements
ToCopyableBuilder {
private static final SdkField AUTO_SCALING_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AutoScalingGroupName").getter(getter(EnableMetricsCollectionRequest::autoScalingGroupName))
.setter(setter(Builder::autoScalingGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingGroupName").build())
.build();
private static final SdkField> METRICS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Metrics")
.getter(getter(EnableMetricsCollectionRequest::metrics))
.setter(setter(Builder::metrics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField GRANULARITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Granularity").getter(getter(EnableMetricsCollectionRequest::granularity))
.setter(setter(Builder::granularity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Granularity").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AUTO_SCALING_GROUP_NAME_FIELD,
METRICS_FIELD, GRANULARITY_FIELD));
private final String autoScalingGroupName;
private final List metrics;
private final String granularity;
private EnableMetricsCollectionRequest(BuilderImpl builder) {
super(builder);
this.autoScalingGroupName = builder.autoScalingGroupName;
this.metrics = builder.metrics;
this.granularity = builder.granularity;
}
/**
*
* The name of the Auto Scaling group.
*
*
* @return The name of the Auto Scaling group.
*/
public final String autoScalingGroupName() {
return autoScalingGroupName;
}
/**
* For responses, this returns true if the service returned a value for the Metrics 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 hasMetrics() {
return metrics != null && !(metrics instanceof SdkAutoConstructList);
}
/**
*
* Identifies the metrics to enable.
*
*
* You can specify one or more of the following metrics:
*
*
* -
*
* GroupMinSize
*
*
* -
*
* GroupMaxSize
*
*
* -
*
* GroupDesiredCapacity
*
*
* -
*
* GroupInServiceInstances
*
*
* -
*
* GroupPendingInstances
*
*
* -
*
* GroupStandbyInstances
*
*
* -
*
* GroupTerminatingInstances
*
*
* -
*
* GroupTotalInstances
*
*
* -
*
* GroupInServiceCapacity
*
*
* -
*
* GroupPendingCapacity
*
*
* -
*
* GroupStandbyCapacity
*
*
* -
*
* GroupTerminatingCapacity
*
*
* -
*
* GroupTotalCapacity
*
*
* -
*
* WarmPoolDesiredCapacity
*
*
* -
*
* WarmPoolWarmedCapacity
*
*
* -
*
* WarmPoolPendingCapacity
*
*
* -
*
* WarmPoolTerminatingCapacity
*
*
* -
*
* WarmPoolTotalCapacity
*
*
* -
*
* GroupAndWarmPoolDesiredCapacity
*
*
* -
*
* GroupAndWarmPoolTotalCapacity
*
*
*
*
* If you specify Granularity
and don't specify any metrics, all metrics are enabled.
*
*
* For more information, see Amazon CloudWatch
* metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
*
*
* 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 #hasMetrics} method.
*
*
* @return Identifies the metrics to enable.
*
* You can specify one or more of the following metrics:
*
*
* -
*
* GroupMinSize
*
*
* -
*
* GroupMaxSize
*
*
* -
*
* GroupDesiredCapacity
*
*
* -
*
* GroupInServiceInstances
*
*
* -
*
* GroupPendingInstances
*
*
* -
*
* GroupStandbyInstances
*
*
* -
*
* GroupTerminatingInstances
*
*
* -
*
* GroupTotalInstances
*
*
* -
*
* GroupInServiceCapacity
*
*
* -
*
* GroupPendingCapacity
*
*
* -
*
* GroupStandbyCapacity
*
*
* -
*
* GroupTerminatingCapacity
*
*
* -
*
* GroupTotalCapacity
*
*
* -
*
* WarmPoolDesiredCapacity
*
*
* -
*
* WarmPoolWarmedCapacity
*
*
* -
*
* WarmPoolPendingCapacity
*
*
* -
*
* WarmPoolTerminatingCapacity
*
*
* -
*
* WarmPoolTotalCapacity
*
*
* -
*
* GroupAndWarmPoolDesiredCapacity
*
*
* -
*
* GroupAndWarmPoolTotalCapacity
*
*
*
*
* If you specify Granularity
and don't specify any metrics, all metrics are enabled.
*
*
* For more information, see Amazon
* CloudWatch metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
*/
public final List metrics() {
return metrics;
}
/**
*
* The frequency at which Amazon EC2 Auto Scaling sends aggregated data to CloudWatch. The only valid value is
* 1Minute
.
*
*
* @return The frequency at which Amazon EC2 Auto Scaling sends aggregated data to CloudWatch. The only valid value
* is 1Minute
.
*/
public final String granularity() {
return granularity;
}
@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(hasMetrics() ? metrics() : null);
hashCode = 31 * hashCode + Objects.hashCode(granularity());
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 EnableMetricsCollectionRequest)) {
return false;
}
EnableMetricsCollectionRequest other = (EnableMetricsCollectionRequest) obj;
return Objects.equals(autoScalingGroupName(), other.autoScalingGroupName()) && hasMetrics() == other.hasMetrics()
&& Objects.equals(metrics(), other.metrics()) && Objects.equals(granularity(), other.granularity());
}
/**
* 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("EnableMetricsCollectionRequest").add("AutoScalingGroupName", autoScalingGroupName())
.add("Metrics", hasMetrics() ? metrics() : null).add("Granularity", granularity()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AutoScalingGroupName":
return Optional.ofNullable(clazz.cast(autoScalingGroupName()));
case "Metrics":
return Optional.ofNullable(clazz.cast(metrics()));
case "Granularity":
return Optional.ofNullable(clazz.cast(granularity()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* You can specify one or more of the following metrics:
*
*
* -
*
* GroupMinSize
*
*
* -
*
* GroupMaxSize
*
*
* -
*
* GroupDesiredCapacity
*
*
* -
*
* GroupInServiceInstances
*
*
* -
*
* GroupPendingInstances
*
*
* -
*
* GroupStandbyInstances
*
*
* -
*
* GroupTerminatingInstances
*
*
* -
*
* GroupTotalInstances
*
*
* -
*
* GroupInServiceCapacity
*
*
* -
*
* GroupPendingCapacity
*
*
* -
*
* GroupStandbyCapacity
*
*
* -
*
* GroupTerminatingCapacity
*
*
* -
*
* GroupTotalCapacity
*
*
* -
*
* WarmPoolDesiredCapacity
*
*
* -
*
* WarmPoolWarmedCapacity
*
*
* -
*
* WarmPoolPendingCapacity
*
*
* -
*
* WarmPoolTerminatingCapacity
*
*
* -
*
* WarmPoolTotalCapacity
*
*
* -
*
* GroupAndWarmPoolDesiredCapacity
*
*
* -
*
* GroupAndWarmPoolTotalCapacity
*
*
*
*
* If you specify Granularity
and don't specify any metrics, all metrics are enabled.
*
*
* For more information, see Amazon
* CloudWatch metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder metrics(Collection metrics);
/**
*
* Identifies the metrics to enable.
*
*
* You can specify one or more of the following metrics:
*
*
* -
*
* GroupMinSize
*
*
* -
*
* GroupMaxSize
*
*
* -
*
* GroupDesiredCapacity
*
*
* -
*
* GroupInServiceInstances
*
*
* -
*
* GroupPendingInstances
*
*
* -
*
* GroupStandbyInstances
*
*
* -
*
* GroupTerminatingInstances
*
*
* -
*
* GroupTotalInstances
*
*
* -
*
* GroupInServiceCapacity
*
*
* -
*
* GroupPendingCapacity
*
*
* -
*
* GroupStandbyCapacity
*
*
* -
*
* GroupTerminatingCapacity
*
*
* -
*
* GroupTotalCapacity
*
*
* -
*
* WarmPoolDesiredCapacity
*
*
* -
*
* WarmPoolWarmedCapacity
*
*
* -
*
* WarmPoolPendingCapacity
*
*
* -
*
* WarmPoolTerminatingCapacity
*
*
* -
*
* WarmPoolTotalCapacity
*
*
* -
*
* GroupAndWarmPoolDesiredCapacity
*
*
* -
*
* GroupAndWarmPoolTotalCapacity
*
*
*
*
* If you specify Granularity
and don't specify any metrics, all metrics are enabled.
*
*
* For more information, see Amazon CloudWatch
* metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
*
*
* @param metrics
* Identifies the metrics to enable.
*
* You can specify one or more of the following metrics:
*
*
* -
*
* GroupMinSize
*
*
* -
*
* GroupMaxSize
*
*
* -
*
* GroupDesiredCapacity
*
*
* -
*
* GroupInServiceInstances
*
*
* -
*
* GroupPendingInstances
*
*
* -
*
* GroupStandbyInstances
*
*
* -
*
* GroupTerminatingInstances
*
*
* -
*
* GroupTotalInstances
*
*
* -
*
* GroupInServiceCapacity
*
*
* -
*
* GroupPendingCapacity
*
*
* -
*
* GroupStandbyCapacity
*
*
* -
*
* GroupTerminatingCapacity
*
*
* -
*
* GroupTotalCapacity
*
*
* -
*
* WarmPoolDesiredCapacity
*
*
* -
*
* WarmPoolWarmedCapacity
*
*
* -
*
* WarmPoolPendingCapacity
*
*
* -
*
* WarmPoolTerminatingCapacity
*
*
* -
*
* WarmPoolTotalCapacity
*
*
* -
*
* GroupAndWarmPoolDesiredCapacity
*
*
* -
*
* GroupAndWarmPoolTotalCapacity
*
*
*
*
* If you specify Granularity
and don't specify any metrics, all metrics are enabled.
*
*
* For more information, see Amazon
* CloudWatch metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder metrics(String... metrics);
/**
*
* The frequency at which Amazon EC2 Auto Scaling sends aggregated data to CloudWatch. The only valid value is
* 1Minute
.
*
*
* @param granularity
* The frequency at which Amazon EC2 Auto Scaling sends aggregated data to CloudWatch. The only valid
* value is 1Minute
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder granularity(String granularity);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends AutoScalingRequest.BuilderImpl implements Builder {
private String autoScalingGroupName;
private List metrics = DefaultSdkAutoConstructList.getInstance();
private String granularity;
private BuilderImpl() {
}
private BuilderImpl(EnableMetricsCollectionRequest model) {
super(model);
autoScalingGroupName(model.autoScalingGroupName);
metrics(model.metrics);
granularity(model.granularity);
}
public final String getAutoScalingGroupName() {
return autoScalingGroupName;
}
public final void setAutoScalingGroupName(String autoScalingGroupName) {
this.autoScalingGroupName = autoScalingGroupName;
}
@Override
public final Builder autoScalingGroupName(String autoScalingGroupName) {
this.autoScalingGroupName = autoScalingGroupName;
return this;
}
public final Collection getMetrics() {
if (metrics instanceof SdkAutoConstructList) {
return null;
}
return metrics;
}
public final void setMetrics(Collection metrics) {
this.metrics = MetricsCopier.copy(metrics);
}
@Override
public final Builder metrics(Collection metrics) {
this.metrics = MetricsCopier.copy(metrics);
return this;
}
@Override
@SafeVarargs
public final Builder metrics(String... metrics) {
metrics(Arrays.asList(metrics));
return this;
}
public final String getGranularity() {
return granularity;
}
public final void setGranularity(String granularity) {
this.granularity = granularity;
}
@Override
public final Builder granularity(String granularity) {
this.granularity = granularity;
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public EnableMetricsCollectionRequest build() {
return new EnableMetricsCollectionRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}