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

software.amazon.awssdk.services.cloudwatch.model.MetricStat 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.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* This structure defines the metric to be returned, along with the statistics, period, and units. *

*/ @Generated("software.amazon.awssdk:codegen") public final class MetricStat implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField METRIC_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("Metric") .getter(getter(MetricStat::metric)).setter(setter(Builder::metric)).constructor(Metric::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metric").build()).build(); private static final SdkField PERIOD_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("Period").getter(getter(MetricStat::period)).setter(setter(Builder::period)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Period").build()).build(); private static final SdkField STAT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Stat") .getter(getter(MetricStat::stat)).setter(setter(Builder::stat)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Stat").build()).build(); private static final SdkField UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Unit") .getter(getter(MetricStat::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_FIELD, PERIOD_FIELD, STAT_FIELD, UNIT_FIELD)); private static final long serialVersionUID = 1L; private final Metric metric; private final Integer period; private final String stat; private final String unit; private MetricStat(BuilderImpl builder) { this.metric = builder.metric; this.period = builder.period; this.stat = builder.stat; this.unit = builder.unit; } /** *

* The metric to return, including the metric name, namespace, and dimensions. *

* * @return The metric to return, including the metric name, namespace, and dimensions. */ public final Metric metric() { return metric; } /** *

* 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 statistic to return. It can include any CloudWatch statistic or extended statistic. *

    * * @return The statistic to return. It can include any CloudWatch statistic or extended statistic. */ public final String stat() { return stat; } /** *

    * When you are using a Put operation, this defines what unit you want to use when storing the metric. *

    *

    * In a Get operation, if you omit Unit then 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 When you are using a Put operation, this defines what unit you want to use when storing the * metric.

    *

    * In a Get operation, if you omit Unit then 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); } /** *

    * When you are using a Put operation, this defines what unit you want to use when storing the metric. *

    *

    * In a Get operation, if you omit Unit then 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 When you are using a Put operation, this defines what unit you want to use when storing the * metric.

    *

    * In a Get operation, if you omit Unit then 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 + Objects.hashCode(metric()); hashCode = 31 * hashCode + Objects.hashCode(period()); hashCode = 31 * hashCode + Objects.hashCode(stat()); hashCode = 31 * hashCode + Objects.hashCode(unitAsString()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof MetricStat)) { return false; } MetricStat other = (MetricStat) obj; return Objects.equals(metric(), other.metric()) && Objects.equals(period(), other.period()) && Objects.equals(stat(), other.stat()) && 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("MetricStat").add("Metric", metric()).add("Period", period()).add("Stat", stat()) .add("Unit", unitAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Metric": return Optional.ofNullable(clazz.cast(metric())); case "Period": return Optional.ofNullable(clazz.cast(period())); case "Stat": return Optional.ofNullable(clazz.cast(stat())); 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((MetricStat) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

    * The metric to return, including the metric name, namespace, and dimensions. *

    * * @param metric * The metric to return, including the metric name, namespace, and dimensions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metric(Metric metric); /** *

    * The metric to return, including the metric name, namespace, and dimensions. *

    * This is a convenience that creates an instance of the {@link Metric.Builder} avoiding the need to create one * manually via {@link Metric#builder()}. * * When the {@link Consumer} completes, {@link Metric.Builder#build()} is called immediately and its result is * passed to {@link #metric(Metric)}. * * @param metric * a consumer that will call methods on {@link Metric.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #metric(Metric) */ default Builder metric(Consumer metric) { return metric(Metric.builder().applyMutation(metric).build()); } /** *

    * 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 statistic to return. It can include any CloudWatch statistic or extended statistic. *

      * * @param stat * The statistic to return. It can include any CloudWatch statistic or extended statistic. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stat(String stat); /** *

      * When you are using a Put operation, this defines what unit you want to use when storing the * metric. *

      *

      * In a Get operation, if you omit Unit then 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 * When you are using a Put operation, this defines what unit you want to use when storing * the metric.

      *

      * In a Get operation, if you omit Unit then 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); /** *

      * When you are using a Put operation, this defines what unit you want to use when storing the * metric. *

      *

      * In a Get operation, if you omit Unit then 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 * When you are using a Put operation, this defines what unit you want to use when storing * the metric.

      *

      * In a Get operation, if you omit Unit then 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); } static final class BuilderImpl implements Builder { private Metric metric; private Integer period; private String stat; private String unit; private BuilderImpl() { } private BuilderImpl(MetricStat model) { metric(model.metric); period(model.period); stat(model.stat); unit(model.unit); } public final Metric.Builder getMetric() { return metric != null ? metric.toBuilder() : null; } @Override public final Builder metric(Metric metric) { this.metric = metric; return this; } public final void setMetric(Metric.BuilderImpl metric) { this.metric = metric != null ? metric.build() : null; } public final Integer getPeriod() { return period; } @Override public final Builder period(Integer period) { this.period = period; return this; } public final void setPeriod(Integer period) { this.period = period; } public final String getStat() { return stat; } @Override public final Builder stat(String stat) { this.stat = stat; return this; } public final void setStat(String stat) { this.stat = stat; } public final String getUnit() { return 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; } public final void setUnit(String unit) { this.unit = unit; } @Override public MetricStat build() { return new MetricStat(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy