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

software.amazon.awssdk.services.autoscaling.model.MetricDataQuery Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.30.1
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.autoscaling.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;

/**
 * 

* The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is * performing a math expression on the values of returned metric statistics to create a new time series. A time series * is a series of data points, each of which is associated with a timestamp. *

*

* For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User * Guide. *

*/ @Generated("software.amazon.awssdk:codegen") public final class MetricDataQuery implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id") .getter(getter(MetricDataQuery::id)).setter(setter(Builder::id)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build(); private static final SdkField EXPRESSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Expression").getter(getter(MetricDataQuery::expression)).setter(setter(Builder::expression)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Expression").build()).build(); private static final SdkField METRIC_STAT_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("MetricStat").getter(getter(MetricDataQuery::metricStat)).setter(setter(Builder::metricStat)) .constructor(MetricStat::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricStat").build()).build(); private static final SdkField LABEL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Label") .getter(getter(MetricDataQuery::label)).setter(setter(Builder::label)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Label").build()).build(); private static final SdkField RETURN_DATA_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("ReturnData").getter(getter(MetricDataQuery::returnData)).setter(setter(Builder::returnData)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReturnData").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, EXPRESSION_FIELD, METRIC_STAT_FIELD, LABEL_FIELD, RETURN_DATA_FIELD)); private static final long serialVersionUID = 1L; private final String id; private final String expression; private final MetricStat metricStat; private final String label; private final Boolean returnData; private MetricDataQuery(BuilderImpl builder) { this.id = builder.id; this.expression = builder.expression; this.metricStat = builder.metricStat; this.label = builder.label; this.returnData = builder.returnData; } /** *

* A short name that identifies the object's results in the response. This name must be unique among all * MetricDataQuery objects specified for a single scaling policy. 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 underscores. The first character must be a lowercase * letter. *

* * @return A short name that identifies the object's results in the response. This name must be unique among all * MetricDataQuery objects specified for a single scaling policy. 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 underscores. The first character * must be a lowercase letter. */ public final String id() { return id; } /** *

* The math expression to perform on the returned data, if this object is performing a math expression. This * expression can use the Id of the other metrics to refer to those metrics, and can also use the * Id of other expressions to use the result of those expressions. *

*

* Conditional: Within each MetricDataQuery object, you must specify either Expression or * MetricStat, but not both. *

* * @return The math expression to perform on the returned data, if this object is performing a math expression. This * expression can use the Id of the other metrics to refer to those metrics, and can also use * the Id of other expressions to use the result of those expressions.

*

* Conditional: Within each MetricDataQuery object, you must specify either * Expression or MetricStat, but not both. */ public final String expression() { return expression; } /** *

* Information about the metric data to return. *

*

* Conditional: Within each MetricDataQuery object, you must specify either Expression or * MetricStat, but not both. *

* * @return Information about the metric data to return.

*

* Conditional: Within each MetricDataQuery object, you must specify either * Expression or MetricStat, but not both. */ public final MetricStat metricStat() { return metricStat; } /** *

* A human-readable label for this metric or expression. This is especially useful if this is a math expression, so * that you know what the value represents. *

* * @return A human-readable label for this metric or expression. This is especially useful if this is a math * expression, so that you know what the value represents. */ public final String label() { return label; } /** *

* Indicates whether to return the timestamps and raw data values of this metric. *

*

* If you use any math expressions, specify true for this value for only the final math expression that * the metric specification is based on. You must specify false for ReturnData for all the * other metrics and expressions used in the metric specification. *

*

* If you are only retrieving metrics and not performing any math expressions, do not specify anything for * ReturnData. This sets it to its default (true). *

* * @return Indicates whether to return the timestamps and raw data values of this metric.

*

* If you use any math expressions, specify true for this value for only the final math * expression that the metric specification is based on. You must specify false for * ReturnData for all the other metrics and expressions used in the metric specification. *

*

* If you are only retrieving metrics and not performing any math expressions, do not specify anything for * ReturnData. This sets it to its default (true). */ public final Boolean returnData() { return returnData; } @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(id()); hashCode = 31 * hashCode + Objects.hashCode(expression()); hashCode = 31 * hashCode + Objects.hashCode(metricStat()); hashCode = 31 * hashCode + Objects.hashCode(label()); hashCode = 31 * hashCode + Objects.hashCode(returnData()); 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 MetricDataQuery)) { return false; } MetricDataQuery other = (MetricDataQuery) obj; return Objects.equals(id(), other.id()) && Objects.equals(expression(), other.expression()) && Objects.equals(metricStat(), other.metricStat()) && Objects.equals(label(), other.label()) && Objects.equals(returnData(), other.returnData()); } /** * 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("MetricDataQuery").add("Id", id()).add("Expression", expression()) .add("MetricStat", metricStat()).add("Label", label()).add("ReturnData", returnData()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Id": return Optional.ofNullable(clazz.cast(id())); case "Expression": return Optional.ofNullable(clazz.cast(expression())); case "MetricStat": return Optional.ofNullable(clazz.cast(metricStat())); case "Label": return Optional.ofNullable(clazz.cast(label())); case "ReturnData": return Optional.ofNullable(clazz.cast(returnData())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((MetricDataQuery) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* A short name that identifies the object's results in the response. This name must be unique among all * MetricDataQuery objects specified for a single scaling policy. 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 underscores. The first character must * be a lowercase letter. *

* * @param id * A short name that identifies the object's results in the response. This name must be unique among all * MetricDataQuery objects specified for a single scaling policy. 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 underscores. The first * character must be a lowercase letter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder id(String id); /** *

* The math expression to perform on the returned data, if this object is performing a math expression. This * expression can use the Id of the other metrics to refer to those metrics, and can also use the * Id of other expressions to use the result of those expressions. *

*

* Conditional: Within each MetricDataQuery object, you must specify either Expression * or MetricStat, but not both. *

* * @param expression * The math expression to perform on the returned data, if this object is performing a math expression. * This expression can use the Id of the other metrics to refer to those metrics, and can * also use the Id of other expressions to use the result of those expressions.

*

* Conditional: 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. */ Builder expression(String expression); /** *

* Information about the metric data to return. *

*

* Conditional: Within each MetricDataQuery object, you must specify either Expression * or MetricStat, but not both. *

* * @param metricStat * Information about the metric data to return.

*

* Conditional: 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. */ Builder metricStat(MetricStat metricStat); /** *

* Information about the metric data to return. *

*

* Conditional: Within each MetricDataQuery object, you must specify either Expression * or MetricStat, but not both. *

* This is a convenience method that creates an instance of the {@link MetricStat.Builder} avoiding the need to * create one manually via {@link MetricStat#builder()}. * *

* When the {@link Consumer} completes, {@link MetricStat.Builder#build()} is called immediately and its result * is passed to {@link #metricStat(MetricStat)}. * * @param metricStat * a consumer that will call methods on {@link MetricStat.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #metricStat(MetricStat) */ default Builder metricStat(Consumer metricStat) { return metricStat(MetricStat.builder().applyMutation(metricStat).build()); } /** *

* A human-readable label for this metric or expression. This is especially useful if this is a math expression, * so that you know what the value represents. *

* * @param label * A human-readable label for this metric or expression. This is especially useful if this is a math * expression, so that you know what the value represents. * @return Returns a reference to this object so that method calls can be chained together. */ Builder label(String label); /** *

* Indicates whether to return the timestamps and raw data values of this metric. *

*

* If you use any math expressions, specify true for this value for only the final math expression * that the metric specification is based on. You must specify false for ReturnData * for all the other metrics and expressions used in the metric specification. *

*

* If you are only retrieving metrics and not performing any math expressions, do not specify anything for * ReturnData. This sets it to its default (true). *

* * @param returnData * Indicates whether to return the timestamps and raw data values of this metric.

*

* If you use any math expressions, specify true for this value for only the final math * expression that the metric specification is based on. You must specify false for * ReturnData for all the other metrics and expressions used in the metric specification. *

*

* If you are only retrieving metrics and not performing any math expressions, do not specify anything * for ReturnData. This sets it to its default (true). * @return Returns a reference to this object so that method calls can be chained together. */ Builder returnData(Boolean returnData); } static final class BuilderImpl implements Builder { private String id; private String expression; private MetricStat metricStat; private String label; private Boolean returnData; private BuilderImpl() { } private BuilderImpl(MetricDataQuery model) { id(model.id); expression(model.expression); metricStat(model.metricStat); label(model.label); returnData(model.returnData); } public final String getId() { return id; } public final void setId(String id) { this.id = id; } @Override public final Builder id(String id) { this.id = id; return this; } public final String getExpression() { return expression; } public final void setExpression(String expression) { this.expression = expression; } @Override public final Builder expression(String expression) { this.expression = expression; return this; } public final MetricStat.Builder getMetricStat() { return metricStat != null ? metricStat.toBuilder() : null; } public final void setMetricStat(MetricStat.BuilderImpl metricStat) { this.metricStat = metricStat != null ? metricStat.build() : null; } @Override public final Builder metricStat(MetricStat metricStat) { this.metricStat = metricStat; return this; } public final String getLabel() { return label; } public final void setLabel(String label) { this.label = label; } @Override public final Builder label(String label) { this.label = label; return this; } public final Boolean getReturnData() { return returnData; } public final void setReturnData(Boolean returnData) { this.returnData = returnData; } @Override public final Builder returnData(Boolean returnData) { this.returnData = returnData; return this; } @Override public MetricDataQuery build() { return new MetricDataQuery(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy