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

software.amazon.awssdk.services.cloudwatch.model.MetricDataResult 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.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.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;

/**
 * 

* A GetMetricData call returns an array of MetricDataResult structures. Each of these * structures includes the data points for that metric, along with the timestamps of those data points and other * identifying information. *

*/ @Generated("software.amazon.awssdk:codegen") public final class MetricDataResult implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id") .getter(getter(MetricDataResult::id)).setter(setter(Builder::id)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build(); private static final SdkField LABEL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Label") .getter(getter(MetricDataResult::label)).setter(setter(Builder::label)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Label").build()).build(); private static final SdkField> TIMESTAMPS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Timestamps") .getter(getter(MetricDataResult::timestamps)) .setter(setter(Builder::timestamps)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamps").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.INSTANT) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> VALUES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Values") .getter(getter(MetricDataResult::values)) .setter(setter(Builder::values)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Values").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.DOUBLE) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField STATUS_CODE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("StatusCode").getter(getter(MetricDataResult::statusCodeAsString)).setter(setter(Builder::statusCode)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusCode").build()).build(); private static final SdkField> MESSAGES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Messages") .getter(getter(MetricDataResult::messages)) .setter(setter(Builder::messages)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Messages").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MessageData::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, LABEL_FIELD, TIMESTAMPS_FIELD, VALUES_FIELD, STATUS_CODE_FIELD, MESSAGES_FIELD)); private static final long serialVersionUID = 1L; private final String id; private final String label; private final List timestamps; private final List values; private final String statusCode; private final List messages; private MetricDataResult(BuilderImpl builder) { this.id = builder.id; this.label = builder.label; this.timestamps = builder.timestamps; this.values = builder.values; this.statusCode = builder.statusCode; this.messages = builder.messages; } /** *

* The short name you specified to represent this metric. *

* * @return The short name you specified to represent this metric. */ public final String id() { return id; } /** *

* The human-readable label associated with the data. *

* * @return The human-readable label associated with the data. */ public final String label() { return label; } /** * For responses, this returns true if the service returned a value for the Timestamps 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 hasTimestamps() { return timestamps != null && !(timestamps instanceof SdkAutoConstructList); } /** *

* The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps always matches * the number of values and the value for Timestamps[x] is Values[x]. *

*

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

* * @return The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps always * matches the number of values and the value for Timestamps[x] is Values[x]. */ public final List timestamps() { return timestamps; } /** * For responses, this returns true if the service returned a value for the Values 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 hasValues() { return values != null && !(values instanceof SdkAutoConstructList); } /** *

* The data points for the metric corresponding to Timestamps. The number of values always matches the * number of timestamps and the timestamp for Values[x] is Timestamps[x]. *

*

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

* * @return The data points for the metric corresponding to Timestamps. The number of values always * matches the number of timestamps and the timestamp for Values[x] is Timestamps[x]. */ public final List values() { return values; } /** *

* The status of the returned data. Complete indicates that all data points in the requested time range * were returned. PartialData means that an incomplete set of data points were returned. You can use * the NextToken value that was returned and repeat your request to get more data points. * NextToken is not returned if you are performing a math expression. InternalError * indicates that an error occurred. Retry your request using NextToken, if present. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #statusCode} will * return {@link StatusCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusCodeAsString}. *

* * @return The status of the returned data. Complete indicates that all data points in the requested * time range were returned. PartialData means that an incomplete set of data points were * returned. You can use the NextToken value that was returned and repeat your request to get * more data points. NextToken is not returned if you are performing a math expression. * InternalError indicates that an error occurred. Retry your request using * NextToken, if present. * @see StatusCode */ public final StatusCode statusCode() { return StatusCode.fromValue(statusCode); } /** *

* The status of the returned data. Complete indicates that all data points in the requested time range * were returned. PartialData means that an incomplete set of data points were returned. You can use * the NextToken value that was returned and repeat your request to get more data points. * NextToken is not returned if you are performing a math expression. InternalError * indicates that an error occurred. Retry your request using NextToken, if present. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #statusCode} will * return {@link StatusCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusCodeAsString}. *

* * @return The status of the returned data. Complete indicates that all data points in the requested * time range were returned. PartialData means that an incomplete set of data points were * returned. You can use the NextToken value that was returned and repeat your request to get * more data points. NextToken is not returned if you are performing a math expression. * InternalError indicates that an error occurred. Retry your request using * NextToken, if present. * @see StatusCode */ public final String statusCodeAsString() { return statusCode; } /** * For responses, this returns true if the service returned a value for the Messages 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 hasMessages() { return messages != null && !(messages instanceof SdkAutoConstructList); } /** *

* A list of messages with additional information about the data returned. *

*

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

* * @return A list of messages with additional information about the data returned. */ public final List messages() { return messages; } @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(label()); hashCode = 31 * hashCode + Objects.hashCode(hasTimestamps() ? timestamps() : null); hashCode = 31 * hashCode + Objects.hashCode(hasValues() ? values() : null); hashCode = 31 * hashCode + Objects.hashCode(statusCodeAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasMessages() ? messages() : null); 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 MetricDataResult)) { return false; } MetricDataResult other = (MetricDataResult) obj; return Objects.equals(id(), other.id()) && Objects.equals(label(), other.label()) && hasTimestamps() == other.hasTimestamps() && Objects.equals(timestamps(), other.timestamps()) && hasValues() == other.hasValues() && Objects.equals(values(), other.values()) && Objects.equals(statusCodeAsString(), other.statusCodeAsString()) && hasMessages() == other.hasMessages() && Objects.equals(messages(), other.messages()); } /** * 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("MetricDataResult").add("Id", id()).add("Label", label()) .add("Timestamps", hasTimestamps() ? timestamps() : null).add("Values", hasValues() ? values() : null) .add("StatusCode", statusCodeAsString()).add("Messages", hasMessages() ? messages() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Id": return Optional.ofNullable(clazz.cast(id())); case "Label": return Optional.ofNullable(clazz.cast(label())); case "Timestamps": return Optional.ofNullable(clazz.cast(timestamps())); case "Values": return Optional.ofNullable(clazz.cast(values())); case "StatusCode": return Optional.ofNullable(clazz.cast(statusCodeAsString())); case "Messages": return Optional.ofNullable(clazz.cast(messages())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((MetricDataResult) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The short name you specified to represent this metric. *

* * @param id * The short name you specified to represent this metric. * @return Returns a reference to this object so that method calls can be chained together. */ Builder id(String id); /** *

* The human-readable label associated with the data. *

* * @param label * The human-readable label associated with the data. * @return Returns a reference to this object so that method calls can be chained together. */ Builder label(String label); /** *

* The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps always * matches the number of values and the value for Timestamps[x] is Values[x]. *

* * @param timestamps * The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps * always matches the number of values and the value for Timestamps[x] is Values[x]. * @return Returns a reference to this object so that method calls can be chained together. */ Builder timestamps(Collection timestamps); /** *

* The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps always * matches the number of values and the value for Timestamps[x] is Values[x]. *

* * @param timestamps * The timestamps for the data points, formatted in Unix timestamp format. The number of timestamps * always matches the number of values and the value for Timestamps[x] is Values[x]. * @return Returns a reference to this object so that method calls can be chained together. */ Builder timestamps(Instant... timestamps); /** *

* The data points for the metric corresponding to Timestamps. The number of values always matches * the number of timestamps and the timestamp for Values[x] is Timestamps[x]. *

* * @param values * The data points for the metric corresponding to Timestamps. The number of values always * matches the number of timestamps and the timestamp for Values[x] is Timestamps[x]. * @return Returns a reference to this object so that method calls can be chained together. */ Builder values(Collection values); /** *

* The data points for the metric corresponding to Timestamps. The number of values always matches * the number of timestamps and the timestamp for Values[x] is Timestamps[x]. *

* * @param values * The data points for the metric corresponding to Timestamps. The number of values always * matches the number of timestamps and the timestamp for Values[x] is Timestamps[x]. * @return Returns a reference to this object so that method calls can be chained together. */ Builder values(Double... values); /** *

* The status of the returned data. Complete indicates that all data points in the requested time * range were returned. PartialData means that an incomplete set of data points were returned. You * can use the NextToken value that was returned and repeat your request to get more data points. * NextToken is not returned if you are performing a math expression. InternalError * indicates that an error occurred. Retry your request using NextToken, if present. *

* * @param statusCode * The status of the returned data. Complete indicates that all data points in the requested * time range were returned. PartialData means that an incomplete set of data points were * returned. You can use the NextToken value that was returned and repeat your request to * get more data points. NextToken is not returned if you are performing a math expression. * InternalError indicates that an error occurred. Retry your request using * NextToken, if present. * @see StatusCode * @return Returns a reference to this object so that method calls can be chained together. * @see StatusCode */ Builder statusCode(String statusCode); /** *

* The status of the returned data. Complete indicates that all data points in the requested time * range were returned. PartialData means that an incomplete set of data points were returned. You * can use the NextToken value that was returned and repeat your request to get more data points. * NextToken is not returned if you are performing a math expression. InternalError * indicates that an error occurred. Retry your request using NextToken, if present. *

* * @param statusCode * The status of the returned data. Complete indicates that all data points in the requested * time range were returned. PartialData means that an incomplete set of data points were * returned. You can use the NextToken value that was returned and repeat your request to * get more data points. NextToken is not returned if you are performing a math expression. * InternalError indicates that an error occurred. Retry your request using * NextToken, if present. * @see StatusCode * @return Returns a reference to this object so that method calls can be chained together. * @see StatusCode */ Builder statusCode(StatusCode statusCode); /** *

* A list of messages with additional information about the data returned. *

* * @param messages * A list of messages with additional information about the data returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder messages(Collection messages); /** *

* A list of messages with additional information about the data returned. *

* * @param messages * A list of messages with additional information about the data returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder messages(MessageData... messages); /** *

* A list of messages with additional information about the data returned. *

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

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.cloudwatch.model.MessageData.Builder#build()} is called immediately * and its result is passed to {@link #messages(List)}. * * @param messages * a consumer that will call methods on * {@link software.amazon.awssdk.services.cloudwatch.model.MessageData.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #messages(java.util.Collection) */ Builder messages(Consumer... messages); } static final class BuilderImpl implements Builder { private String id; private String label; private List timestamps = DefaultSdkAutoConstructList.getInstance(); private List values = DefaultSdkAutoConstructList.getInstance(); private String statusCode; private List messages = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(MetricDataResult model) { id(model.id); label(model.label); timestamps(model.timestamps); values(model.values); statusCode(model.statusCode); messages(model.messages); } 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 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 Collection getTimestamps() { if (timestamps instanceof SdkAutoConstructList) { return null; } return timestamps; } public final void setTimestamps(Collection timestamps) { this.timestamps = TimestampsCopier.copy(timestamps); } @Override public final Builder timestamps(Collection timestamps) { this.timestamps = TimestampsCopier.copy(timestamps); return this; } @Override @SafeVarargs public final Builder timestamps(Instant... timestamps) { timestamps(Arrays.asList(timestamps)); return this; } public final Collection getValues() { if (values instanceof SdkAutoConstructList) { return null; } return values; } public final void setValues(Collection values) { this.values = DatapointValuesCopier.copy(values); } @Override public final Builder values(Collection values) { this.values = DatapointValuesCopier.copy(values); return this; } @Override @SafeVarargs public final Builder values(Double... values) { values(Arrays.asList(values)); return this; } public final String getStatusCode() { return statusCode; } public final void setStatusCode(String statusCode) { this.statusCode = statusCode; } @Override public final Builder statusCode(String statusCode) { this.statusCode = statusCode; return this; } @Override public final Builder statusCode(StatusCode statusCode) { this.statusCode(statusCode == null ? null : statusCode.toString()); return this; } public final List getMessages() { List result = MetricDataResultMessagesCopier.copyToBuilder(this.messages); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setMessages(Collection messages) { this.messages = MetricDataResultMessagesCopier.copyFromBuilder(messages); } @Override public final Builder messages(Collection messages) { this.messages = MetricDataResultMessagesCopier.copy(messages); return this; } @Override @SafeVarargs public final Builder messages(MessageData... messages) { messages(Arrays.asList(messages)); return this; } @Override @SafeVarargs public final Builder messages(Consumer... messages) { messages(Stream.of(messages).map(c -> MessageData.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public MetricDataResult build() { return new MetricDataResult(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy