software.amazon.awssdk.services.cloudwatch.model.AlarmHistoryItem 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.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
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;
/**
*
* Represents the history of a specific alarm.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AlarmHistoryItem implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ALARM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlarmName").getter(getter(AlarmHistoryItem::alarmName)).setter(setter(Builder::alarmName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmName").build()).build();
private static final SdkField ALARM_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlarmType").getter(getter(AlarmHistoryItem::alarmTypeAsString)).setter(setter(Builder::alarmType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmType").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("Timestamp").getter(getter(AlarmHistoryItem::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamp").build()).build();
private static final SdkField HISTORY_ITEM_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("HistoryItemType").getter(getter(AlarmHistoryItem::historyItemTypeAsString))
.setter(setter(Builder::historyItemType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HistoryItemType").build()).build();
private static final SdkField HISTORY_SUMMARY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("HistorySummary").getter(getter(AlarmHistoryItem::historySummary))
.setter(setter(Builder::historySummary))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HistorySummary").build()).build();
private static final SdkField HISTORY_DATA_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("HistoryData").getter(getter(AlarmHistoryItem::historyData)).setter(setter(Builder::historyData))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HistoryData").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ALARM_NAME_FIELD,
ALARM_TYPE_FIELD, TIMESTAMP_FIELD, HISTORY_ITEM_TYPE_FIELD, HISTORY_SUMMARY_FIELD, HISTORY_DATA_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("AlarmName", ALARM_NAME_FIELD);
put("AlarmType", ALARM_TYPE_FIELD);
put("Timestamp", TIMESTAMP_FIELD);
put("HistoryItemType", HISTORY_ITEM_TYPE_FIELD);
put("HistorySummary", HISTORY_SUMMARY_FIELD);
put("HistoryData", HISTORY_DATA_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String alarmName;
private final String alarmType;
private final Instant timestamp;
private final String historyItemType;
private final String historySummary;
private final String historyData;
private AlarmHistoryItem(BuilderImpl builder) {
this.alarmName = builder.alarmName;
this.alarmType = builder.alarmType;
this.timestamp = builder.timestamp;
this.historyItemType = builder.historyItemType;
this.historySummary = builder.historySummary;
this.historyData = builder.historyData;
}
/**
*
* The descriptive name for the alarm.
*
*
* @return The descriptive name for the alarm.
*/
public final String alarmName() {
return alarmName;
}
/**
*
* The type of alarm, either metric alarm or composite alarm.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alarmType} will
* return {@link AlarmType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alarmTypeAsString}.
*
*
* @return The type of alarm, either metric alarm or composite alarm.
* @see AlarmType
*/
public final AlarmType alarmType() {
return AlarmType.fromValue(alarmType);
}
/**
*
* The type of alarm, either metric alarm or composite alarm.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alarmType} will
* return {@link AlarmType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alarmTypeAsString}.
*
*
* @return The type of alarm, either metric alarm or composite alarm.
* @see AlarmType
*/
public final String alarmTypeAsString() {
return alarmType;
}
/**
*
* The time stamp for the alarm history item.
*
*
* @return The time stamp for the alarm history item.
*/
public final Instant timestamp() {
return timestamp;
}
/**
*
* The type of alarm history item.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #historyItemType}
* will return {@link HistoryItemType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #historyItemTypeAsString}.
*
*
* @return The type of alarm history item.
* @see HistoryItemType
*/
public final HistoryItemType historyItemType() {
return HistoryItemType.fromValue(historyItemType);
}
/**
*
* The type of alarm history item.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #historyItemType}
* will return {@link HistoryItemType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #historyItemTypeAsString}.
*
*
* @return The type of alarm history item.
* @see HistoryItemType
*/
public final String historyItemTypeAsString() {
return historyItemType;
}
/**
*
* A summary of the alarm history, in text format.
*
*
* @return A summary of the alarm history, in text format.
*/
public final String historySummary() {
return historySummary;
}
/**
*
* Data about the alarm, in JSON format.
*
*
* @return Data about the alarm, in JSON format.
*/
public final String historyData() {
return historyData;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(alarmName());
hashCode = 31 * hashCode + Objects.hashCode(alarmTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
hashCode = 31 * hashCode + Objects.hashCode(historyItemTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(historySummary());
hashCode = 31 * hashCode + Objects.hashCode(historyData());
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 AlarmHistoryItem)) {
return false;
}
AlarmHistoryItem other = (AlarmHistoryItem) obj;
return Objects.equals(alarmName(), other.alarmName()) && Objects.equals(alarmTypeAsString(), other.alarmTypeAsString())
&& Objects.equals(timestamp(), other.timestamp())
&& Objects.equals(historyItemTypeAsString(), other.historyItemTypeAsString())
&& Objects.equals(historySummary(), other.historySummary()) && Objects.equals(historyData(), other.historyData());
}
/**
* 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("AlarmHistoryItem").add("AlarmName", alarmName()).add("AlarmType", alarmTypeAsString())
.add("Timestamp", timestamp()).add("HistoryItemType", historyItemTypeAsString())
.add("HistorySummary", historySummary()).add("HistoryData", historyData()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AlarmName":
return Optional.ofNullable(clazz.cast(alarmName()));
case "AlarmType":
return Optional.ofNullable(clazz.cast(alarmTypeAsString()));
case "Timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
case "HistoryItemType":
return Optional.ofNullable(clazz.cast(historyItemTypeAsString()));
case "HistorySummary":
return Optional.ofNullable(clazz.cast(historySummary()));
case "HistoryData":
return Optional.ofNullable(clazz.cast(historyData()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function