/* * Copyright 2018-2023 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 com.amazonaws.services.cloudwatch.model; import java.io.Serializable; import javax.annotation.Generated; /** *
* This structure is used in both GetMetricData
and PutMetricAlarm
. The supported use of this
* structure is different for those two operations.
*
* When used in GetMetricData
, it indicates the metric data to return, and whether this call is just
* retrieving a batch set of data for one metric, or is performing a Metrics Insights query or a math expression. A
* single GetMetricData
call can include up to 500 MetricDataQuery
structures.
*
* When used in PutMetricAlarm
, it enables you to create an alarm based on a metric math expression. Each
* MetricDataQuery
in the array specifies either a metric to retrieve, or a math expression to be performed
* on retrieved metrics. A single PutMetricAlarm
call can include up to 20 MetricDataQuery
* structures in the array. The 20 structures can include as many as 10 structures that contain a
* MetricStat
parameter to retrieve a metric, and as many as 10 structures that contain the
* Expression
parameter to perform a math expression. Of those Expression
structures, one must
* have true
as the value for ReturnData
. The result of this expression is the value the alarm
* watches.
*
* Any expression used in a PutMetricAlarm
operation must return a single time series. For more
* information, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Some of the parameters of this structure also have different uses whether you are using this structure in a
* GetMetricData
operation or a PutMetricAlarm
operation. These differences are explained in
* the following parameter list.
*
* A short name used to tie this object to the results in the response. This name must be unique within a single
* call to GetMetricData
. If you are performing math expressions on this set of data, this name
* represents that data and can serve as a variable in the mathematical expression. The valid characters are
* letters, numbers, and underscore. The first character must be a lowercase letter.
*
* The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is * retrieving a metric and not performing a math expression on returned data. *
*
* Within one MetricDataQuery object, you must specify either Expression
or MetricStat
but
* not both.
*
* This field can contain either a Metrics Insights query, or a metric math expression to be performed on the * returned data. For more information about Metrics Insights queries, see Metrics Insights query components and syntax in the Amazon CloudWatch User Guide. *
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics, and can
* also use the Id
of other expressions to use the result of those expressions. For more information
* about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or MetricStat
* but not both.
*
* A human-readable label for this metric or expression. This is especially useful if this is an expression, so that * you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the * label is shown. If Label is omitted, CloudWatch generates a default. *
** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using Dynamic * Labels. *
*/ private String label; /** *
* When used in GetMetricData
, this option indicates whether to return the timestamps and raw data
* values of this metric. If you are performing this call just to do math expressions and do not also need the raw
* data returned, you can specify false
. If you omit this, the default of true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use as the
* alarm. For all other metrics and expressions in the same PutMetricAlarm
operation, specify
* ReturnData
as False.
*
* 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
operation that includes a
* StorageResolution of 1 second
.
*
* The ID of the account where the metrics are located. *
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify which
* account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains the
* metric that the alarm is watching.
*
* A short name used to tie this object to the results in the response. This name must be unique within a single
* call to GetMetricData
. If you are performing math expressions on this set of data, this name
* represents that data and can serve as a variable in the mathematical expression. The valid characters are
* letters, numbers, and underscore. The first character must be a lowercase letter.
*
GetMetricData
. If you are performing math expressions on this set of data,
* this name represents that data and can serve as a variable in the mathematical expression. The valid
* characters are letters, numbers, and underscore. The first character must be a lowercase letter.
*/
public void setId(String id) {
this.id = id;
}
/**
*
* A short name used to tie this object to the results in the response. This name must be unique within a single
* call to GetMetricData
. If you are performing math expressions on this set of data, this name
* represents that data and can serve as a variable in the mathematical expression. The valid characters are
* letters, numbers, and underscore. The first character must be a lowercase letter.
*
GetMetricData
. If you are performing math expressions on this set of data,
* this name represents that data and can serve as a variable in the mathematical expression. The valid
* characters are letters, numbers, and underscore. The first character must be a lowercase letter.
*/
public String getId() {
return this.id;
}
/**
*
* A short name used to tie this object to the results in the response. This name must be unique within a single
* call to GetMetricData
. If you are performing math expressions on this set of data, this name
* represents that data and can serve as a variable in the mathematical expression. The valid characters are
* letters, numbers, and underscore. The first character must be a lowercase letter.
*
GetMetricData
. If you are performing math expressions on this set of data,
* this name represents that data and can serve as a variable in the mathematical expression. The valid
* characters are letters, numbers, and underscore. The first character must be a lowercase letter.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withId(String id) {
setId(id);
return this;
}
/**
* * The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is * retrieving a metric and not performing a math expression on returned data. *
*
* Within one MetricDataQuery object, you must specify either Expression
or MetricStat
but
* not both.
*
* Within one MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
*/
public void setMetricStat(MetricStat metricStat) {
this.metricStat = metricStat;
}
/**
*
* The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is * retrieving a metric and not performing a math expression on returned data. *
*
* Within one MetricDataQuery object, you must specify either Expression
or MetricStat
but
* not both.
*
* Within one MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
*/
public MetricStat getMetricStat() {
return this.metricStat;
}
/**
*
* The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is * retrieving a metric and not performing a math expression on returned data. *
*
* Within one MetricDataQuery object, you must specify either Expression
or MetricStat
but
* not both.
*
* Within one MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withMetricStat(MetricStat metricStat) {
setMetricStat(metricStat);
return this;
}
/**
*
* This field can contain either a Metrics Insights query, or a metric math expression to be performed on the * returned data. For more information about Metrics Insights queries, see Metrics Insights query components and syntax in the Amazon CloudWatch User Guide. *
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics, and can
* also use the Id
of other expressions to use the result of those expressions. For more information
* about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or MetricStat
* but not both.
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics,
* and can also use the Id
of other expressions to use the result of those expressions. For more
* information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
*/
public void setExpression(String expression) {
this.expression = expression;
}
/**
*
* This field can contain either a Metrics Insights query, or a metric math expression to be performed on the * returned data. For more information about Metrics Insights queries, see Metrics Insights query components and syntax in the Amazon CloudWatch User Guide. *
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics, and can
* also use the Id
of other expressions to use the result of those expressions. For more information
* about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or MetricStat
* but not both.
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics,
* and can also use the Id
of other expressions to use the result of those expressions. For
* more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
*/
public String getExpression() {
return this.expression;
}
/**
*
* This field can contain either a Metrics Insights query, or a metric math expression to be performed on the * returned data. For more information about Metrics Insights queries, see Metrics Insights query components and syntax in the Amazon CloudWatch User Guide. *
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics, and can
* also use the Id
of other expressions to use the result of those expressions. For more information
* about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or MetricStat
* but not both.
*
* A math expression can use the Id
of the other metrics or queries to refer to those metrics,
* and can also use the Id
of other expressions to use the result of those expressions. For more
* information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
*
* Within each MetricDataQuery object, you must specify either Expression
or
* MetricStat
but not both.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withExpression(String expression) {
setExpression(expression);
return this;
}
/**
*
* A human-readable label for this metric or expression. This is especially useful if this is an expression, so that * you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the * label is shown. If Label is omitted, CloudWatch generates a default. *
** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using Dynamic * Labels. *
* * @param label * A human-readable label for this metric or expression. This is especially useful if this is an expression, * so that you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard * widget, the label is shown. If Label is omitted, CloudWatch generates a default. ** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using * Dynamic Labels. */ public void setLabel(String label) { this.label = label; } /** *
* A human-readable label for this metric or expression. This is especially useful if this is an expression, so that * you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the * label is shown. If Label is omitted, CloudWatch generates a default. *
** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using Dynamic * Labels. *
* * @return A human-readable label for this metric or expression. This is especially useful if this is an expression, * so that you know what the value represents. If the metric or expression is shown in a CloudWatch * dashboard widget, the label is shown. If Label is omitted, CloudWatch generates a default. ** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see * Using * Dynamic Labels. */ public String getLabel() { return this.label; } /** *
* A human-readable label for this metric or expression. This is especially useful if this is an expression, so that * you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the * label is shown. If Label is omitted, CloudWatch generates a default. *
** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using Dynamic * Labels. *
* * @param label * A human-readable label for this metric or expression. This is especially useful if this is an expression, * so that you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard * widget, the label is shown. If Label is omitted, CloudWatch generates a default. ** You can put dynamic expressions into a label, so that it is more descriptive. For more information, see Using * Dynamic Labels. * @return Returns a reference to this object so that method calls can be chained together. */ public MetricDataQuery withLabel(String label) { setLabel(label); return this; } /** *
* When used in GetMetricData
, this option indicates whether to return the timestamps and raw data
* values of this metric. If you are performing this call just to do math expressions and do not also need the raw
* data returned, you can specify false
. If you omit this, the default of true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use as the
* alarm. For all other metrics and expressions in the same PutMetricAlarm
operation, specify
* ReturnData
as False.
*
GetMetricData
, this option indicates whether to return the timestamps and raw
* data values of this metric. If you are performing this call just to do math expressions and do not also
* need the raw data returned, you can specify false
. If you omit this, the default of
* true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use
* as the alarm. For all other metrics and expressions in the same PutMetricAlarm
operation,
* specify ReturnData
as False.
*/
public void setReturnData(Boolean returnData) {
this.returnData = returnData;
}
/**
*
* When used in GetMetricData
, this option indicates whether to return the timestamps and raw data
* values of this metric. If you are performing this call just to do math expressions and do not also need the raw
* data returned, you can specify false
. If you omit this, the default of true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use as the
* alarm. For all other metrics and expressions in the same PutMetricAlarm
operation, specify
* ReturnData
as False.
*
GetMetricData
, this option indicates whether to return the timestamps and raw
* data values of this metric. If you are performing this call just to do math expressions and do not also
* need the raw data returned, you can specify false
. If you omit this, the default of
* true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use
* as the alarm. For all other metrics and expressions in the same PutMetricAlarm
operation,
* specify ReturnData
as False.
*/
public Boolean getReturnData() {
return this.returnData;
}
/**
*
* When used in GetMetricData
, this option indicates whether to return the timestamps and raw data
* values of this metric. If you are performing this call just to do math expressions and do not also need the raw
* data returned, you can specify false
. If you omit this, the default of true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use as the
* alarm. For all other metrics and expressions in the same PutMetricAlarm
operation, specify
* ReturnData
as False.
*
GetMetricData
, this option indicates whether to return the timestamps and raw
* data values of this metric. If you are performing this call just to do math expressions and do not also
* need the raw data returned, you can specify false
. If you omit this, the default of
* true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use
* as the alarm. For all other metrics and expressions in the same PutMetricAlarm
operation,
* specify ReturnData
as False.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withReturnData(Boolean returnData) {
setReturnData(returnData);
return this;
}
/**
*
* When used in GetMetricData
, this option indicates whether to return the timestamps and raw data
* values of this metric. If you are performing this call just to do math expressions and do not also need the raw
* data returned, you can specify false
. If you omit this, the default of true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use as the
* alarm. For all other metrics and expressions in the same PutMetricAlarm
operation, specify
* ReturnData
as False.
*
GetMetricData
, this option indicates whether to return the timestamps and raw
* data values of this metric. If you are performing this call just to do math expressions and do not also
* need the raw data returned, you can specify false
. If you omit this, the default of
* true
is used.
*
* When used in PutMetricAlarm
, specify true
for the one expression result to use
* as the alarm. For all other metrics and expressions in the same PutMetricAlarm
operation,
* specify ReturnData
as False.
*/
public Boolean isReturnData() {
return this.returnData;
}
/**
*
* 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
operation that includes a
* StorageResolution of 1 second
.
*
PutMetricData
operation that
* includes a StorageResolution of 1 second
.
*/
public void setPeriod(Integer period) {
this.period = 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
operation that includes a
* StorageResolution of 1 second
.
*
PutMetricData
operation that
* includes a StorageResolution of 1 second
.
*/
public Integer getPeriod() {
return this.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
operation that includes a
* StorageResolution of 1 second
.
*
PutMetricData
operation that
* includes a StorageResolution of 1 second
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withPeriod(Integer period) {
setPeriod(period);
return this;
}
/**
* * The ID of the account where the metrics are located. *
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify which
* account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains the
* metric that the alarm is watching.
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify
* which account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains
* the metric that the alarm is watching.
*/
public void setAccountId(String accountId) {
this.accountId = accountId;
}
/**
*
* The ID of the account where the metrics are located. *
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify which
* account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains the
* metric that the alarm is watching.
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify
* which account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains
* the metric that the alarm is watching.
*/
public String getAccountId() {
return this.accountId;
}
/**
*
* The ID of the account where the metrics are located. *
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify which
* account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains the
* metric that the alarm is watching.
*
* If you are performing a GetMetricData
operation in a monitoring account, use this to specify
* which account to retrieve this metric from.
*
* If you are performing a PutMetricAlarm
operation, use this to specify which account contains
* the metric that the alarm is watching.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public MetricDataQuery withAccountId(String accountId) {
setAccountId(accountId);
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getId() != null)
sb.append("Id: ").append(getId()).append(",");
if (getMetricStat() != null)
sb.append("MetricStat: ").append(getMetricStat()).append(",");
if (getExpression() != null)
sb.append("Expression: ").append(getExpression()).append(",");
if (getLabel() != null)
sb.append("Label: ").append(getLabel()).append(",");
if (getReturnData() != null)
sb.append("ReturnData: ").append(getReturnData()).append(",");
if (getPeriod() != null)
sb.append("Period: ").append(getPeriod()).append(",");
if (getAccountId() != null)
sb.append("AccountId: ").append(getAccountId());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof MetricDataQuery == false)
return false;
MetricDataQuery other = (MetricDataQuery) obj;
if (other.getId() == null ^ this.getId() == null)
return false;
if (other.getId() != null && other.getId().equals(this.getId()) == false)
return false;
if (other.getMetricStat() == null ^ this.getMetricStat() == null)
return false;
if (other.getMetricStat() != null && other.getMetricStat().equals(this.getMetricStat()) == false)
return false;
if (other.getExpression() == null ^ this.getExpression() == null)
return false;
if (other.getExpression() != null && other.getExpression().equals(this.getExpression()) == false)
return false;
if (other.getLabel() == null ^ this.getLabel() == null)
return false;
if (other.getLabel() != null && other.getLabel().equals(this.getLabel()) == false)
return false;
if (other.getReturnData() == null ^ this.getReturnData() == null)
return false;
if (other.getReturnData() != null && other.getReturnData().equals(this.getReturnData()) == false)
return false;
if (other.getPeriod() == null ^ this.getPeriod() == null)
return false;
if (other.getPeriod() != null && other.getPeriod().equals(this.getPeriod()) == false)
return false;
if (other.getAccountId() == null ^ this.getAccountId() == null)
return false;
if (other.getAccountId() != null && other.getAccountId().equals(this.getAccountId()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode());
hashCode = prime * hashCode + ((getMetricStat() == null) ? 0 : getMetricStat().hashCode());
hashCode = prime * hashCode + ((getExpression() == null) ? 0 : getExpression().hashCode());
hashCode = prime * hashCode + ((getLabel() == null) ? 0 : getLabel().hashCode());
hashCode = prime * hashCode + ((getReturnData() == null) ? 0 : getReturnData().hashCode());
hashCode = prime * hashCode + ((getPeriod() == null) ? 0 : getPeriod().hashCode());
hashCode = prime * hashCode + ((getAccountId() == null) ? 0 : getAccountId().hashCode());
return hashCode;
}
@Override
public MetricDataQuery clone() {
try {
return (MetricDataQuery) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}