All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon CloudWatch module holds the client classes that are used for communicating with Amazon CloudWatch Service

There is a newer version: 2.29.39
Show newest version
/*
 * 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; } /** * For responses, this returns true if the service returned a value for the Dimensions 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 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. *

*

* 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 #hasDimensions} method. *

* * @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 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 getter(Function g) { return obj -> g.apply((DescribeAlarmsForMetricRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the metric. *

* * @param metricName * The name of the metric. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricName(String metricName); /** *

* The namespace of the metric. *

* * @param namespace * The namespace of the metric. * @return Returns a reference to this object so that method calls can be chained together. */ Builder namespace(String namespace); /** *

* The statistic for the metric, other than percentiles. For percentile statistics, use * ExtendedStatistics. *

* * @param statistic * The statistic for the metric, other than percentiles. For percentile statistics, use * ExtendedStatistics. * @see Statistic * @return Returns a reference to this object so that method calls can be chained together. * @see Statistic */ Builder statistic(String statistic); /** *

* The statistic for the metric, other than percentiles. For percentile statistics, use * ExtendedStatistics. *

* * @param statistic * The statistic for the metric, other than percentiles. For percentile statistics, use * ExtendedStatistics. * @see Statistic * @return Returns a reference to this object so that method calls can be chained together. * @see Statistic */ Builder statistic(Statistic statistic); /** *

* The percentile statistic for the metric. Specify a value between p0.0 and p100. *

* * @param extendedStatistic * The percentile statistic for the metric. Specify a value between p0.0 and p100. * @return Returns a reference to this object so that method calls can be chained together. */ Builder extendedStatistic(String extendedStatistic); /** *

* The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them * in order for the call to succeed. *

* * @param dimensions * The dimensions associated with the metric. If the metric has any associated dimensions, you must * specify them in order for the call to succeed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(Collection dimensions); /** *

* The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them * in order for the call to succeed. *

* * @param dimensions * The dimensions associated with the metric. If the metric has any associated dimensions, you must * specify them in order for the call to succeed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(Dimension... dimensions); /** *

* The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them * in order for the call to succeed. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.cloudwatch.model.Dimension.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.cloudwatch.model.Dimension#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.cloudwatch.model.Dimension.Builder#build()} is called immediately and * its result is passed to {@link #dimensions(List)}. * * @param dimensions * a consumer that will call methods on * {@link software.amazon.awssdk.services.cloudwatch.model.Dimension.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #dimensions(java.util.Collection) */ Builder dimensions(Consumer... dimensions); /** *

* The period, in seconds, over which the statistic is applied. *

* * @param period * The period, in seconds, over which the statistic is applied. * @return Returns a reference to this object so that method calls can be chained together. */ Builder period(Integer period); /** *

* The unit for the metric. *

* * @param unit * The unit for the metric. * @see StandardUnit * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ Builder unit(String unit); /** *

* The unit for the metric. *

* * @param unit * The unit for the metric. * @see StandardUnit * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ Builder unit(StandardUnit unit); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CloudWatchRequest.BuilderImpl implements Builder { private String metricName; private String namespace; private String statistic; private String extendedStatistic; private List dimensions = DefaultSdkAutoConstructList.getInstance(); private Integer period; private String unit; private BuilderImpl() { } private BuilderImpl(DescribeAlarmsForMetricRequest model) { super(model); metricName(model.metricName); namespace(model.namespace); statistic(model.statistic); extendedStatistic(model.extendedStatistic); dimensions(model.dimensions); period(model.period); unit(model.unit); } public final String getMetricName() { return metricName; } public final void setMetricName(String metricName) { this.metricName = metricName; } @Override public final Builder metricName(String metricName) { this.metricName = metricName; return this; } public final String getNamespace() { return namespace; } public final void setNamespace(String namespace) { this.namespace = namespace; } @Override public final Builder namespace(String namespace) { this.namespace = namespace; return this; } public final String getStatistic() { return statistic; } public final void setStatistic(String statistic) { this.statistic = statistic; } @Override public final Builder statistic(String statistic) { this.statistic = statistic; return this; } @Override public final Builder statistic(Statistic statistic) { this.statistic(statistic == null ? null : statistic.toString()); return this; } public final String getExtendedStatistic() { return extendedStatistic; } public final void setExtendedStatistic(String extendedStatistic) { this.extendedStatistic = extendedStatistic; } @Override public final Builder extendedStatistic(String extendedStatistic) { this.extendedStatistic = extendedStatistic; return this; } public final List getDimensions() { List result = DimensionsCopier.copyToBuilder(this.dimensions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setDimensions(Collection dimensions) { this.dimensions = DimensionsCopier.copyFromBuilder(dimensions); } @Override public final Builder dimensions(Collection dimensions) { this.dimensions = DimensionsCopier.copy(dimensions); return this; } @Override @SafeVarargs public final Builder dimensions(Dimension... dimensions) { dimensions(Arrays.asList(dimensions)); return this; } @Override @SafeVarargs public final Builder dimensions(Consumer... dimensions) { dimensions(Stream.of(dimensions).map(c -> Dimension.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final Integer getPeriod() { return period; } public final void setPeriod(Integer period) { this.period = period; } @Override public final Builder period(Integer period) { this.period = period; return this; } public final String getUnit() { return unit; } public final void setUnit(String unit) { this.unit = unit; } @Override public final Builder unit(String unit) { this.unit = unit; return this; } @Override public final Builder unit(StandardUnit unit) { this.unit(unit == null ? null : unit.toString()); 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 DescribeAlarmsForMetricRequest build() { return new DescribeAlarmsForMetricRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy