software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest Maven / Gradle / Ivy
Show all versions of cloudwatch 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.cloudwatch.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 java.util.stream.Collectors;
import java.util.stream.Stream;
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 DescribeAlarmsForMetricRequest extends CloudWatchRequest implements
ToCopyableBuilder {
private static final SdkField METRIC_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MetricName").getter(getter(DescribeAlarmsForMetricRequest::metricName))
.setter(setter(Builder::metricName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricName").build()).build();
private static final SdkField NAMESPACE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Namespace").getter(getter(DescribeAlarmsForMetricRequest::namespace)).setter(setter(Builder::namespace))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Namespace").build()).build();
private static final SdkField STATISTIC_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Statistic").getter(getter(DescribeAlarmsForMetricRequest::statisticAsString))
.setter(setter(Builder::statistic))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Statistic").build()).build();
private static final SdkField EXTENDED_STATISTIC_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ExtendedStatistic").getter(getter(DescribeAlarmsForMetricRequest::extendedStatistic))
.setter(setter(Builder::extendedStatistic))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExtendedStatistic").build()).build();
private static final SdkField> DIMENSIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Dimensions")
.getter(getter(DescribeAlarmsForMetricRequest::dimensions))
.setter(setter(Builder::dimensions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Dimensions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Dimension::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField PERIOD_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Period").getter(getter(DescribeAlarmsForMetricRequest::period)).setter(setter(Builder::period))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Period").build()).build();
private static final SdkField UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Unit")
.getter(getter(DescribeAlarmsForMetricRequest::unitAsString)).setter(setter(Builder::unit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Unit").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(METRIC_NAME_FIELD,
NAMESPACE_FIELD, STATISTIC_FIELD, EXTENDED_STATISTIC_FIELD, DIMENSIONS_FIELD, PERIOD_FIELD, UNIT_FIELD));
private final String metricName;
private final String namespace;
private final String statistic;
private final String extendedStatistic;
private final List dimensions;
private final Integer period;
private final String unit;
private DescribeAlarmsForMetricRequest(BuilderImpl builder) {
super(builder);
this.metricName = builder.metricName;
this.namespace = builder.namespace;
this.statistic = builder.statistic;
this.extendedStatistic = builder.extendedStatistic;
this.dimensions = builder.dimensions;
this.period = builder.period;
this.unit = builder.unit;
}
/**
*
* The name of the metric.
*
*
* @return The name of the metric.
*/
public final String metricName() {
return metricName;
}
/**
*
* The namespace of the metric.
*
*
* @return The namespace of the metric.
*/
public final String namespace() {
return namespace;
}
/**
*
* The statistic for the metric, other than percentiles. For percentile statistics, use
* ExtendedStatistics
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #statistic} will
* return {@link Statistic#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statisticAsString}.
*
*
* @return The statistic for the metric, other than percentiles. For percentile statistics, use
* ExtendedStatistics
.
* @see Statistic
*/
public final Statistic statistic() {
return Statistic.fromValue(statistic);
}
/**
*
* The statistic for the metric, other than percentiles. For percentile statistics, use
* ExtendedStatistics
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #statistic} will
* return {@link Statistic#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statisticAsString}.
*
*
* @return The statistic for the metric, other than percentiles. For percentile statistics, use
* ExtendedStatistics
.
* @see Statistic
*/
public final String statisticAsString() {
return statistic;
}
/**
*
* The percentile statistic for the metric. Specify a value between p0.0 and p100.
*
*
* @return The percentile statistic for the metric. Specify a value between p0.0 and p100.
*/
public final String extendedStatistic() {
return extendedStatistic;
}
/**
* Returns true if the Dimensions property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public final boolean hasDimensions() {
return dimensions != null && !(dimensions instanceof SdkAutoConstructList);
}
/**
*
* The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them in
* order for the call to succeed.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasDimensions()} to see if a value was sent in this field.
*
*
* @return The dimensions associated with the metric. If the metric has any associated dimensions, you must specify
* them in order for the call to succeed.
*/
public final List dimensions() {
return dimensions;
}
/**
*
* The period, in seconds, over which the statistic is applied.
*
*
* @return The period, in seconds, over which the statistic is applied.
*/
public final Integer period() {
return period;
}
/**
*
* The unit for the metric.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return
* {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #unitAsString}.
*
*
* @return The unit for the metric.
* @see StandardUnit
*/
public final StandardUnit unit() {
return StandardUnit.fromValue(unit);
}
/**
*
* The unit for the metric.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return
* {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #unitAsString}.
*
*
* @return The unit for the metric.
* @see StandardUnit
*/
public final String unitAsString() {
return unit;
}
@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(metricName());
hashCode = 31 * hashCode + Objects.hashCode(namespace());
hashCode = 31 * hashCode + Objects.hashCode(statisticAsString());
hashCode = 31 * hashCode + Objects.hashCode(extendedStatistic());
hashCode = 31 * hashCode + Objects.hashCode(hasDimensions() ? dimensions() : null);
hashCode = 31 * hashCode + Objects.hashCode(period());
hashCode = 31 * hashCode + Objects.hashCode(unitAsString());
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 DescribeAlarmsForMetricRequest)) {
return false;
}
DescribeAlarmsForMetricRequest other = (DescribeAlarmsForMetricRequest) obj;
return Objects.equals(metricName(), other.metricName()) && Objects.equals(namespace(), other.namespace())
&& Objects.equals(statisticAsString(), other.statisticAsString())
&& Objects.equals(extendedStatistic(), other.extendedStatistic()) && hasDimensions() == other.hasDimensions()
&& Objects.equals(dimensions(), other.dimensions()) && Objects.equals(period(), other.period())
&& Objects.equals(unitAsString(), other.unitAsString());
}
/**
* 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("DescribeAlarmsForMetricRequest").add("MetricName", metricName()).add("Namespace", namespace())
.add("Statistic", statisticAsString()).add("ExtendedStatistic", extendedStatistic())
.add("Dimensions", hasDimensions() ? dimensions() : null).add("Period", period()).add("Unit", unitAsString())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "MetricName":
return Optional.ofNullable(clazz.cast(metricName()));
case "Namespace":
return Optional.ofNullable(clazz.cast(namespace()));
case "Statistic":
return Optional.ofNullable(clazz.cast(statisticAsString()));
case "ExtendedStatistic":
return Optional.ofNullable(clazz.cast(extendedStatistic()));
case "Dimensions":
return Optional.ofNullable(clazz.cast(dimensions()));
case "Period":
return Optional.ofNullable(clazz.cast(period()));
case "Unit":
return Optional.ofNullable(clazz.cast(unitAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function