software.amazon.awssdk.services.cloudwatch.model.MetricDataResult Maven / Gradle / Ivy
Show all versions of cloudwatch Show documentation
/*
* 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)
.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)
.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)
.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)
.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)
.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)
.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 String id() {
return id;
}
/**
*
* The human-readable label associated with the data.
*
*
* @return The human-readable label associated with the data.
*/
public String label() {
return label;
}
/**
* Returns true if the Timestamps property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public 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.
*
*
* You can use {@link #hasTimestamps()} to see if a value was sent in this field.
*
*
* @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 List timestamps() {
return timestamps;
}
/**
* Returns true if the Values property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public 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.
*
*
* You can use {@link #hasValues()} to see if a value was sent in this field.
*
*
* @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 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 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 String statusCodeAsString() {
return statusCode;
}
/**
* Returns true if the Messages property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public 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.
*
*
* You can use {@link #hasMessages()} to see if a value was sent in this field.
*
*
* @return A list of messages with additional information about the data returned.
*/
public List messages() {
return messages;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(label());
hashCode = 31 * hashCode + Objects.hashCode(timestamps());
hashCode = 31 * hashCode + Objects.hashCode(values());
hashCode = 31 * hashCode + Objects.hashCode(statusCodeAsString());
hashCode = 31 * hashCode + Objects.hashCode(messages());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public 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())
&& Objects.equals(timestamps(), other.timestamps()) && Objects.equals(values(), other.values())
&& Objects.equals(statusCodeAsString(), other.statusCodeAsString())
&& 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 String toString() {
return ToString.builder("MetricDataResult").add("Id", id()).add("Label", label()).add("Timestamps", timestamps())
.add("Values", values()).add("StatusCode", statusCodeAsString()).add("Messages", messages()).build();
}
public 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 List> sdkFields() {
return SDK_FIELDS;
}
private static Function