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

software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest 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.time.Instant;
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 GetMetricStatisticsRequest extends CloudWatchRequest implements
        ToCopyableBuilder {
    private static final SdkField NAMESPACE_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("Namespace").getter(getter(GetMetricStatisticsRequest::namespace)).setter(setter(Builder::namespace))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Namespace").build()).build();

    private static final SdkField METRIC_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("MetricName").getter(getter(GetMetricStatisticsRequest::metricName)).setter(setter(Builder::metricName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricName").build()).build();

    private static final SdkField> DIMENSIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Dimensions")
            .getter(getter(GetMetricStatisticsRequest::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 START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("StartTime").getter(getter(GetMetricStatisticsRequest::startTime)).setter(setter(Builder::startTime))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();

    private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("EndTime").getter(getter(GetMetricStatisticsRequest::endTime)).setter(setter(Builder::endTime))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();

    private static final SdkField PERIOD_FIELD = SdkField. builder(MarshallingType.INTEGER)
            .memberName("Period").getter(getter(GetMetricStatisticsRequest::period)).setter(setter(Builder::period))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Period").build()).build();

    private static final SdkField> STATISTICS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Statistics")
            .getter(getter(GetMetricStatisticsRequest::statisticsAsStrings))
            .setter(setter(Builder::statisticsWithStrings))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Statistics").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> EXTENDED_STATISTICS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("ExtendedStatistics")
            .getter(getter(GetMetricStatisticsRequest::extendedStatistics))
            .setter(setter(Builder::extendedStatistics))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExtendedStatistics").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 UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Unit")
            .getter(getter(GetMetricStatisticsRequest::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(NAMESPACE_FIELD,
            METRIC_NAME_FIELD, DIMENSIONS_FIELD, START_TIME_FIELD, END_TIME_FIELD, PERIOD_FIELD, STATISTICS_FIELD,
            EXTENDED_STATISTICS_FIELD, UNIT_FIELD));

    private final String namespace;

    private final String metricName;

    private final List dimensions;

    private final Instant startTime;

    private final Instant endTime;

    private final Integer period;

    private final List statistics;

    private final List extendedStatistics;

    private final String unit;

    private GetMetricStatisticsRequest(BuilderImpl builder) {
        super(builder);
        this.namespace = builder.namespace;
        this.metricName = builder.metricName;
        this.dimensions = builder.dimensions;
        this.startTime = builder.startTime;
        this.endTime = builder.endTime;
        this.period = builder.period;
        this.statistics = builder.statistics;
        this.extendedStatistics = builder.extendedStatistics;
        this.unit = builder.unit;
    }

    /**
     * 

* The namespace of the metric, with or without spaces. *

* * @return The namespace of the metric, with or without spaces. */ public final String namespace() { return namespace; } /** *

* The name of the metric, with or without spaces. *

* * @return The name of the metric, with or without spaces. */ public final String metricName() { return metricName; } /** * 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. If the metric contains multiple dimensions, you must include a value for each dimension. * CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination of * dimensions was not published, you can't retrieve statistics for it. You must specify the same dimensions that * were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about specifying * dimensions, see Publishing * Metrics in the Amazon CloudWatch 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 #hasDimensions} method. *

* * @return The dimensions. If the metric contains multiple dimensions, you must include a value for each dimension. * CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination * of dimensions was not published, you can't retrieve statistics for it. You must specify the same * dimensions that were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about * specifying dimensions, see Publishing * Metrics in the Amazon CloudWatch User Guide. */ public final List dimensions() { return dimensions; } /** *

* The time stamp that determines the first data point to return. Start times are evaluated relative to the time * that CloudWatch receives the request. *

*

* The value specified is inclusive; results include data points with the specified time stamp. In a raw HTTP query, * the time stamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z). *

*

* CloudWatch rounds the specified time stamp as follows: *

*
    *
  • *

    * Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded down * to 12:32:00. *

    *
  • *
  • *

    * Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, 12:32:34 * is rounded down to 12:30:00. *

    *
  • *
  • *

    * Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, 12:32:34 is * rounded down to 12:00:00. *

    *
  • *
*

* If you set Period to 5, 10, or 30, the start time of your request is rounded down to the nearest * time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query at * (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and you * receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of data, using * a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15. *

* * @return The time stamp that determines the first data point to return. Start times are evaluated relative to the * time that CloudWatch receives the request.

*

* The value specified is inclusive; results include data points with the specified time stamp. In a raw * HTTP query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z). *

*

* CloudWatch rounds the specified time stamp as follows: *

*
    *
  • *

    * Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is * rounded down to 12:32:00. *

    *
  • *
  • *

    * Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, * 12:32:34 is rounded down to 12:30:00. *

    *
  • *
  • *

    * Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, * 12:32:34 is rounded down to 12:00:00. *

    *
  • *
*

* If you set Period to 5, 10, or 30, the start time of your request is rounded down to the * nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you * make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is * rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the * previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between 15:02:15 * and 15:07:15. */ public final Instant startTime() { return startTime; } /** *

* The time stamp that determines the last data point to return. *

*

* The value specified is exclusive; results include data points up to the specified time stamp. In a raw HTTP * query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-10T23:00:00Z). *

* * @return The time stamp that determines the last data point to return.

*

* The value specified is exclusive; results include data points up to the specified time stamp. In a raw * HTTP query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-10T23:00:00Z). */ public final Instant endTime() { return endTime; } /** *

* The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can be as * short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at * intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. High-resolution * metrics are those metrics stored by a PutMetricData call that includes a * StorageResolution of 1 second. *

*

* If the StartTime parameter specifies a time stamp that is greater than 3 hours ago, you must specify * the period as follows or no data points in that time range is returned: *

*
    *
  • *

    * Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute). *

    *
  • *
  • *

    * Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes). *

    *
  • *
  • *

    * Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour). *

    *
  • *
* * @return The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period * can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that * are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple * of 60. High-resolution metrics are those metrics stored by a PutMetricData call that * includes a StorageResolution of 1 second.

*

* If the StartTime parameter specifies a time stamp that is greater than 3 hours ago, you must * specify the period as follows or no data points in that time range is returned: *

*
    *
  • *

    * Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute). *

    *
  • *
  • *

    * Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes). *

    *
  • *
  • *

    * Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour). *

    *
  • */ public final Integer period() { return period; } /** *

    * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

    *

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

    * * @return The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify either * Statistics or ExtendedStatistics, but not both. */ public final List statistics() { return StatisticsCopier.copyStringToEnum(statistics); } /** * For responses, this returns true if the service returned a value for the Statistics 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 hasStatistics() { return statistics != null && !(statistics instanceof SdkAutoConstructList); } /** *

    * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

    *

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

    * * @return The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify either * Statistics or ExtendedStatistics, but not both. */ public final List statisticsAsStrings() { return statistics; } /** * For responses, this returns true if the service returned a value for the ExtendedStatistics 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 hasExtendedStatistics() { return extendedStatistics != null && !(extendedStatistics instanceof SdkAutoConstructList); } /** *

    * The percentile statistics. Specify values between p0.0 and p100. When calling GetMetricStatistics, * you must specify either Statistics or ExtendedStatistics, but not both. Percentile * statistics are not available for metrics when any of the metric values are negative numbers. *

    *

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

    * * @return The percentile statistics. Specify values between p0.0 and p100. When calling * GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. Percentile statistics are not available for metrics when * any of the metric values are negative numbers. */ public final List extendedStatistics() { return extendedStatistics; } /** *

    * The unit for a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to CloudWatch. If you * specify a unit, the operation returns only data that was collected with that unit specified. If you specify a * unit that does not match the data collected, the results of the operation are null. CloudWatch does not perform * unit conversions. *

    *

    * 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 a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to * CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit * specified. If you specify a unit that does not match the data collected, the results of the operation are * null. CloudWatch does not perform unit conversions. * @see StandardUnit */ public final StandardUnit unit() { return StandardUnit.fromValue(unit); } /** *

    * The unit for a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to CloudWatch. If you * specify a unit, the operation returns only data that was collected with that unit specified. If you specify a * unit that does not match the data collected, the results of the operation are null. CloudWatch does not perform * unit conversions. *

    *

    * 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 a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to * CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit * specified. If you specify a unit that does not match the data collected, the results of the operation are * null. CloudWatch does not perform unit conversions. * @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(namespace()); hashCode = 31 * hashCode + Objects.hashCode(metricName()); hashCode = 31 * hashCode + Objects.hashCode(hasDimensions() ? dimensions() : null); hashCode = 31 * hashCode + Objects.hashCode(startTime()); hashCode = 31 * hashCode + Objects.hashCode(endTime()); hashCode = 31 * hashCode + Objects.hashCode(period()); hashCode = 31 * hashCode + Objects.hashCode(hasStatistics() ? statisticsAsStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(hasExtendedStatistics() ? extendedStatistics() : null); 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 GetMetricStatisticsRequest)) { return false; } GetMetricStatisticsRequest other = (GetMetricStatisticsRequest) obj; return Objects.equals(namespace(), other.namespace()) && Objects.equals(metricName(), other.metricName()) && hasDimensions() == other.hasDimensions() && Objects.equals(dimensions(), other.dimensions()) && Objects.equals(startTime(), other.startTime()) && Objects.equals(endTime(), other.endTime()) && Objects.equals(period(), other.period()) && hasStatistics() == other.hasStatistics() && Objects.equals(statisticsAsStrings(), other.statisticsAsStrings()) && hasExtendedStatistics() == other.hasExtendedStatistics() && Objects.equals(extendedStatistics(), other.extendedStatistics()) && 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("GetMetricStatisticsRequest").add("Namespace", namespace()).add("MetricName", metricName()) .add("Dimensions", hasDimensions() ? dimensions() : null).add("StartTime", startTime()).add("EndTime", endTime()) .add("Period", period()).add("Statistics", hasStatistics() ? statisticsAsStrings() : null) .add("ExtendedStatistics", hasExtendedStatistics() ? extendedStatistics() : null).add("Unit", unitAsString()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Namespace": return Optional.ofNullable(clazz.cast(namespace())); case "MetricName": return Optional.ofNullable(clazz.cast(metricName())); case "Dimensions": return Optional.ofNullable(clazz.cast(dimensions())); case "StartTime": return Optional.ofNullable(clazz.cast(startTime())); case "EndTime": return Optional.ofNullable(clazz.cast(endTime())); case "Period": return Optional.ofNullable(clazz.cast(period())); case "Statistics": return Optional.ofNullable(clazz.cast(statisticsAsStrings())); case "ExtendedStatistics": return Optional.ofNullable(clazz.cast(extendedStatistics())); 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((GetMetricStatisticsRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchRequest.Builder, SdkPojo, CopyableBuilder { /** *

    * The namespace of the metric, with or without spaces. *

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

    * The name of the metric, with or without spaces. *

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

    * The dimensions. If the metric contains multiple dimensions, you must include a value for each dimension. * CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination of * dimensions was not published, you can't retrieve statistics for it. You must specify the same dimensions that * were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about specifying * dimensions, see Publishing * Metrics in the Amazon CloudWatch User Guide. *

    * * @param dimensions * The dimensions. If the metric contains multiple dimensions, you must include a value for each * dimension. CloudWatch treats each unique combination of dimensions as a separate metric. If a specific * combination of dimensions was not published, you can't retrieve statistics for it. You must specify * the same dimensions that were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about * specifying dimensions, see Publishing Metrics in the Amazon CloudWatch User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(Collection dimensions); /** *

    * The dimensions. If the metric contains multiple dimensions, you must include a value for each dimension. * CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination of * dimensions was not published, you can't retrieve statistics for it. You must specify the same dimensions that * were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about specifying * dimensions, see Publishing * Metrics in the Amazon CloudWatch User Guide. *

    * * @param dimensions * The dimensions. If the metric contains multiple dimensions, you must include a value for each * dimension. CloudWatch treats each unique combination of dimensions as a separate metric. If a specific * combination of dimensions was not published, you can't retrieve statistics for it. You must specify * the same dimensions that were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about * specifying dimensions, see Publishing Metrics in the Amazon CloudWatch User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(Dimension... dimensions); /** *

    * The dimensions. If the metric contains multiple dimensions, you must include a value for each dimension. * CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination of * dimensions was not published, you can't retrieve statistics for it. You must specify the same dimensions that * were used when the metrics were created. For an example, see Dimension Combinations in the Amazon CloudWatch User Guide. For more information about specifying * dimensions, see Publishing * Metrics in the Amazon CloudWatch User Guide. *

    * 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 time stamp that determines the first data point to return. Start times are evaluated relative to the time * that CloudWatch receives the request. *

    *

    * The value specified is inclusive; results include data points with the specified time stamp. In a raw HTTP * query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z). *

    *

    * CloudWatch rounds the specified time stamp as follows: *

    *
      *
    • *

      * Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is rounded * down to 12:32:00. *

      *
    • *
    • *

      * Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For example, * 12:32:34 is rounded down to 12:30:00. *

      *
    • *
    • *

      * Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, 12:32:34 * is rounded down to 12:00:00. *

      *
    • *
    *

    * If you set Period to 5, 10, or 30, the start time of your request is rounded down to the nearest * time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you make a query * at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request is rounded down and * you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of * data, using a period of 5 seconds, you receive data timestamped between 15:02:15 and 15:07:15. *

    * * @param startTime * The time stamp that determines the first data point to return. Start times are evaluated relative to * the time that CloudWatch receives the request.

    *

    * The value specified is inclusive; results include data points with the specified time stamp. In a raw * HTTP query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z). *

    *

    * CloudWatch rounds the specified time stamp as follows: *

    *
      *
    • *

      * Start time less than 15 days ago - Round down to the nearest whole minute. For example, 12:32:34 is * rounded down to 12:32:00. *

      *
    • *
    • *

      * Start time between 15 and 63 days ago - Round down to the nearest 5-minute clock interval. For * example, 12:32:34 is rounded down to 12:30:00. *

      *
    • *
    • *

      * Start time greater than 63 days ago - Round down to the nearest 1-hour clock interval. For example, * 12:32:34 is rounded down to 12:00:00. *

      *
    • *
    *

    * If you set Period to 5, 10, or 30, the start time of your request is rounded down to the * nearest time that corresponds to even 5-, 10-, or 30-second divisions of a minute. For example, if you * make a query at (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of your request * is rounded down and you receive data from 01:05:10 to 01:05:20. If you make a query at 15:07:17 for * the previous 5 minutes of data, using a period of 5 seconds, you receive data timestamped between * 15:02:15 and 15:07:15. * @return Returns a reference to this object so that method calls can be chained together. */ Builder startTime(Instant startTime); /** *

    * The time stamp that determines the last data point to return. *

    *

    * The value specified is exclusive; results include data points up to the specified time stamp. In a raw HTTP * query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-10T23:00:00Z). *

    * * @param endTime * The time stamp that determines the last data point to return.

    *

    * The value specified is exclusive; results include data points up to the specified time stamp. In a raw * HTTP query, the time stamp must be in ISO 8601 UTC format (for example, 2016-10-10T23:00:00Z). * @return Returns a reference to this object so that method calls can be chained together. */ Builder endTime(Instant endTime); /** *

    * The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can * be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are * collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. * High-resolution metrics are those metrics stored by a PutMetricData call that includes a * StorageResolution of 1 second. *

    *

    * If the StartTime parameter specifies a time stamp that is greater than 3 hours ago, you must * specify the period as follows or no data points in that time range is returned: *

    *
      *
    • *

      * Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute). *

      *
    • *
    • *

      * Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes). *

      *
    • *
    • *

      * Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour). *

      *
    • *
    * * @param period * The granularity, in seconds, of the returned data points. For metrics with regular resolution, a * period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution * metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, * or any multiple of 60. High-resolution metrics are those metrics stored by a * PutMetricData call that includes a StorageResolution of 1 second.

    *

    * If the StartTime parameter specifies a time stamp that is greater than 3 hours ago, you * must specify the period as follows or no data points in that time range is returned: *

    *
      *
    • *

      * Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute). *

      *
    • *
    • *

      * Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes). *

      *
    • *
    • *

      * Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour). *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder period(Integer period); /** *

      * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

      * * @param statistics * The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify * either Statistics or ExtendedStatistics, but not both. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statisticsWithStrings(Collection statistics); /** *

      * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

      * * @param statistics * The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify * either Statistics or ExtendedStatistics, but not both. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statisticsWithStrings(String... statistics); /** *

      * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

      * * @param statistics * The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify * either Statistics or ExtendedStatistics, but not both. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statistics(Collection statistics); /** *

      * The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. * When calling GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. *

      * * @param statistics * The metric statistics, other than percentile. For percentile statistics, use * ExtendedStatistics. When calling GetMetricStatistics, you must specify * either Statistics or ExtendedStatistics, but not both. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statistics(Statistic... statistics); /** *

      * The percentile statistics. Specify values between p0.0 and p100. When calling * GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. Percentile statistics are not available for metrics when any * of the metric values are negative numbers. *

      * * @param extendedStatistics * The percentile statistics. Specify values between p0.0 and p100. When calling * GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. Percentile statistics are not available for metrics * when any of the metric values are negative numbers. * @return Returns a reference to this object so that method calls can be chained together. */ Builder extendedStatistics(Collection extendedStatistics); /** *

      * The percentile statistics. Specify values between p0.0 and p100. When calling * GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. Percentile statistics are not available for metrics when any * of the metric values are negative numbers. *

      * * @param extendedStatistics * The percentile statistics. Specify values between p0.0 and p100. When calling * GetMetricStatistics, you must specify either Statistics or * ExtendedStatistics, but not both. Percentile statistics are not available for metrics * when any of the metric values are negative numbers. * @return Returns a reference to this object so that method calls can be chained together. */ Builder extendedStatistics(String... extendedStatistics); /** *

      * The unit for a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to CloudWatch. If * you specify a unit, the operation returns only data that was collected with that unit specified. If you * specify a unit that does not match the data collected, the results of the operation are null. CloudWatch does * not perform unit conversions. *

      * * @param unit * The unit for a given metric. If you omit Unit, all data that was collected with any unit * is returned, along with the corresponding units that were specified when the data was reported to * CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit * specified. If you specify a unit that does not match the data collected, the results of the operation * are null. CloudWatch does not perform unit conversions. * @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 a given metric. If you omit Unit, all data that was collected with any unit is * returned, along with the corresponding units that were specified when the data was reported to CloudWatch. If * you specify a unit, the operation returns only data that was collected with that unit specified. If you * specify a unit that does not match the data collected, the results of the operation are null. CloudWatch does * not perform unit conversions. *

      * * @param unit * The unit for a given metric. If you omit Unit, all data that was collected with any unit * is returned, along with the corresponding units that were specified when the data was reported to * CloudWatch. If you specify a unit, the operation returns only data that was collected with that unit * specified. If you specify a unit that does not match the data collected, the results of the operation * are null. CloudWatch does not perform unit conversions. * @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 namespace; private String metricName; private List dimensions = DefaultSdkAutoConstructList.getInstance(); private Instant startTime; private Instant endTime; private Integer period; private List statistics = DefaultSdkAutoConstructList.getInstance(); private List extendedStatistics = DefaultSdkAutoConstructList.getInstance(); private String unit; private BuilderImpl() { } private BuilderImpl(GetMetricStatisticsRequest model) { super(model); namespace(model.namespace); metricName(model.metricName); dimensions(model.dimensions); startTime(model.startTime); endTime(model.endTime); period(model.period); statisticsWithStrings(model.statistics); extendedStatistics(model.extendedStatistics); unit(model.unit); } 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 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 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 Instant getStartTime() { return startTime; } public final void setStartTime(Instant startTime) { this.startTime = startTime; } @Override public final Builder startTime(Instant startTime) { this.startTime = startTime; return this; } public final Instant getEndTime() { return endTime; } public final void setEndTime(Instant endTime) { this.endTime = endTime; } @Override public final Builder endTime(Instant endTime) { this.endTime = endTime; 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 Collection getStatistics() { if (statistics instanceof SdkAutoConstructList) { return null; } return statistics; } public final void setStatistics(Collection statistics) { this.statistics = StatisticsCopier.copy(statistics); } @Override public final Builder statisticsWithStrings(Collection statistics) { this.statistics = StatisticsCopier.copy(statistics); return this; } @Override @SafeVarargs public final Builder statisticsWithStrings(String... statistics) { statisticsWithStrings(Arrays.asList(statistics)); return this; } @Override public final Builder statistics(Collection statistics) { this.statistics = StatisticsCopier.copyEnumToString(statistics); return this; } @Override @SafeVarargs public final Builder statistics(Statistic... statistics) { statistics(Arrays.asList(statistics)); return this; } public final Collection getExtendedStatistics() { if (extendedStatistics instanceof SdkAutoConstructList) { return null; } return extendedStatistics; } public final void setExtendedStatistics(Collection extendedStatistics) { this.extendedStatistics = ExtendedStatisticsCopier.copy(extendedStatistics); } @Override public final Builder extendedStatistics(Collection extendedStatistics) { this.extendedStatistics = ExtendedStatisticsCopier.copy(extendedStatistics); return this; } @Override @SafeVarargs public final Builder extendedStatistics(String... extendedStatistics) { extendedStatistics(Arrays.asList(extendedStatistics)); 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 GetMetricStatisticsRequest build() { return new GetMetricStatisticsRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy