
software.amazon.awssdk.services.cloudwatch.model.MetricDataResult Maven / Gradle / Ivy
/*
* Copyright 2013-2018 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.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
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 time stamps of those data points and other
* identifying information.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class MetricDataResult implements ToCopyableBuilder {
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;
}
/**
*
* The time stamps for the data points, formatted in Unix timestamp format. The number of time stamps 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.
*
*
* @return The time stamps for the data points, formatted in Unix timestamp format. The number of time stamps always
* matches the number of values and the value for Timestamps[x] is Values[x].
*/
public List timestamps() {
return timestamps;
}
/**
*
* The data points for the metric corresponding to Timestamps
. The number of values always matches the
* number of time stamps and the time stamp for Values[x] is Timestamps[x].
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The data points for the metric corresponding to Timestamps
. The number of values always
* matches the number of time stamps and the time stamp 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;
}
/**
*
* 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.
*
*
* @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) {
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());
}
@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();
}
}
public interface Builder extends 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 time stamps for the data points, formatted in Unix timestamp format. The number of time stamps always
* matches the number of values and the value for Timestamps[x] is Values[x].
*
*
* @param timestamps
* The time stamps for the data points, formatted in Unix timestamp format. The number of time stamps
* 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 time stamps for the data points, formatted in Unix timestamp format. The number of time stamps always
* matches the number of values and the value for Timestamps[x] is Values[x].
*
*
* @param timestamps
* The time stamps for the data points, formatted in Unix timestamp format. The number of time stamps
* 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 time stamps and the time stamp 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 time stamps and the time stamp 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 time stamps and the time stamp 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 time stamps and the time stamp 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 that creates an instance of the {@link List.Builder} avoiding the need to
* create one manually via {@link List#builder()}.
*
* When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its
* result is passed to {@link #messages(List)}.
*
* @param messages
* a consumer that will call methods on {@link List.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #messages(List)
*/
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;
}
@Override
public final Builder id(String id) {
this.id = id;
return this;
}
public final void setId(String id) {
this.id = id;
}
public final String getLabel() {
return label;
}
@Override
public final Builder label(String label) {
this.label = label;
return this;
}
public final void setLabel(String label) {
this.label = label;
}
public final Collection getTimestamps() {
return 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 void setTimestamps(Collection timestamps) {
this.timestamps = TimestampsCopier.copy(timestamps);
}
public final Collection getValues() {
return 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 void setValues(Collection values) {
this.values = DatapointValuesCopier.copy(values);
}
public final String getStatusCode() {
return statusCode;
}
@Override
public final Builder statusCode(String statusCode) {
this.statusCode = statusCode;
return this;
}
@Override
public final Builder statusCode(StatusCode statusCode) {
this.statusCode(statusCode.toString());
return this;
}
public final void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public final Collection getMessages() {
return messages != null ? messages.stream().map(MessageData::toBuilder).collect(Collectors.toList()) : null;
}
@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;
}
public final void setMessages(Collection messages) {
this.messages = MetricDataResultMessagesCopier.copyFromBuilder(messages);
}
@Override
public MetricDataResult build() {
return new MetricDataResult(this);
}
}
}