software.amazon.awssdk.services.lookoutmetrics.model.Alert Maven / Gradle / Ivy
Show all versions of lookoutmetrics 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.lookoutmetrics.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* A configuration for Amazon SNS-integrated notifications.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Alert implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("Action")
.getter(getter(Alert::action)).setter(setter(Builder::action)).constructor(Action::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build();
private static final SdkField ALERT_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlertDescription").getter(getter(Alert::alertDescription)).setter(setter(Builder::alertDescription))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertDescription").build()).build();
private static final SdkField ALERT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlertArn").getter(getter(Alert::alertArn)).setter(setter(Builder::alertArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertArn").build()).build();
private static final SdkField ANOMALY_DETECTOR_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AnomalyDetectorArn").getter(getter(Alert::anomalyDetectorArn))
.setter(setter(Builder::anomalyDetectorArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnomalyDetectorArn").build())
.build();
private static final SdkField ALERT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlertName").getter(getter(Alert::alertName)).setter(setter(Builder::alertName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertName").build()).build();
private static final SdkField ALERT_SENSITIVITY_THRESHOLD_FIELD = SdkField
. builder(MarshallingType.INTEGER).memberName("AlertSensitivityThreshold")
.getter(getter(Alert::alertSensitivityThreshold)).setter(setter(Builder::alertSensitivityThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertSensitivityThreshold").build())
.build();
private static final SdkField ALERT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlertType").getter(getter(Alert::alertTypeAsString)).setter(setter(Builder::alertType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertType").build()).build();
private static final SdkField ALERT_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlertStatus").getter(getter(Alert::alertStatusAsString)).setter(setter(Builder::alertStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertStatus").build()).build();
private static final SdkField LAST_MODIFICATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastModificationTime").getter(getter(Alert::lastModificationTime))
.setter(setter(Builder::lastModificationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModificationTime").build())
.build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreationTime").getter(getter(Alert::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationTime").build()).build();
private static final SdkField ALERT_FILTERS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("AlertFilters").getter(getter(Alert::alertFilters)).setter(setter(Builder::alertFilters))
.constructor(AlertFilters::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlertFilters").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_FIELD,
ALERT_DESCRIPTION_FIELD, ALERT_ARN_FIELD, ANOMALY_DETECTOR_ARN_FIELD, ALERT_NAME_FIELD,
ALERT_SENSITIVITY_THRESHOLD_FIELD, ALERT_TYPE_FIELD, ALERT_STATUS_FIELD, LAST_MODIFICATION_TIME_FIELD,
CREATION_TIME_FIELD, ALERT_FILTERS_FIELD));
private static final long serialVersionUID = 1L;
private final Action action;
private final String alertDescription;
private final String alertArn;
private final String anomalyDetectorArn;
private final String alertName;
private final Integer alertSensitivityThreshold;
private final String alertType;
private final String alertStatus;
private final Instant lastModificationTime;
private final Instant creationTime;
private final AlertFilters alertFilters;
private Alert(BuilderImpl builder) {
this.action = builder.action;
this.alertDescription = builder.alertDescription;
this.alertArn = builder.alertArn;
this.anomalyDetectorArn = builder.anomalyDetectorArn;
this.alertName = builder.alertName;
this.alertSensitivityThreshold = builder.alertSensitivityThreshold;
this.alertType = builder.alertType;
this.alertStatus = builder.alertStatus;
this.lastModificationTime = builder.lastModificationTime;
this.creationTime = builder.creationTime;
this.alertFilters = builder.alertFilters;
}
/**
*
* Action that will be triggered when there is an alert.
*
*
* @return Action that will be triggered when there is an alert.
*/
public final Action action() {
return action;
}
/**
*
* A description of the alert.
*
*
* @return A description of the alert.
*/
public final String alertDescription() {
return alertDescription;
}
/**
*
* The ARN of the alert.
*
*
* @return The ARN of the alert.
*/
public final String alertArn() {
return alertArn;
}
/**
*
* The ARN of the detector to which the alert is attached.
*
*
* @return The ARN of the detector to which the alert is attached.
*/
public final String anomalyDetectorArn() {
return anomalyDetectorArn;
}
/**
*
* The name of the alert.
*
*
* @return The name of the alert.
*/
public final String alertName() {
return alertName;
}
/**
*
* The minimum severity for an anomaly to trigger the alert.
*
*
* @return The minimum severity for an anomaly to trigger the alert.
*/
public final Integer alertSensitivityThreshold() {
return alertSensitivityThreshold;
}
/**
*
* The type of the alert.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alertType} will
* return {@link AlertType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alertTypeAsString}.
*
*
* @return The type of the alert.
* @see AlertType
*/
public final AlertType alertType() {
return AlertType.fromValue(alertType);
}
/**
*
* The type of the alert.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alertType} will
* return {@link AlertType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alertTypeAsString}.
*
*
* @return The type of the alert.
* @see AlertType
*/
public final String alertTypeAsString() {
return alertType;
}
/**
*
* The status of the alert.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alertStatus} will
* return {@link AlertStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alertStatusAsString}.
*
*
* @return The status of the alert.
* @see AlertStatus
*/
public final AlertStatus alertStatus() {
return AlertStatus.fromValue(alertStatus);
}
/**
*
* The status of the alert.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #alertStatus} will
* return {@link AlertStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #alertStatusAsString}.
*
*
* @return The status of the alert.
* @see AlertStatus
*/
public final String alertStatusAsString() {
return alertStatus;
}
/**
*
* The time at which the alert was last modified.
*
*
* @return The time at which the alert was last modified.
*/
public final Instant lastModificationTime() {
return lastModificationTime;
}
/**
*
* The time at which the alert was created.
*
*
* @return The time at which the alert was created.
*/
public final Instant creationTime() {
return creationTime;
}
/**
*
* The configuration of the alert filters, containing MetricList and DimensionFilter.
*
*
* @return The configuration of the alert filters, containing MetricList and DimensionFilter.
*/
public final AlertFilters alertFilters() {
return alertFilters;
}
@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(action());
hashCode = 31 * hashCode + Objects.hashCode(alertDescription());
hashCode = 31 * hashCode + Objects.hashCode(alertArn());
hashCode = 31 * hashCode + Objects.hashCode(anomalyDetectorArn());
hashCode = 31 * hashCode + Objects.hashCode(alertName());
hashCode = 31 * hashCode + Objects.hashCode(alertSensitivityThreshold());
hashCode = 31 * hashCode + Objects.hashCode(alertTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(alertStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(lastModificationTime());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(alertFilters());
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 Alert)) {
return false;
}
Alert other = (Alert) obj;
return Objects.equals(action(), other.action()) && Objects.equals(alertDescription(), other.alertDescription())
&& Objects.equals(alertArn(), other.alertArn())
&& Objects.equals(anomalyDetectorArn(), other.anomalyDetectorArn())
&& Objects.equals(alertName(), other.alertName())
&& Objects.equals(alertSensitivityThreshold(), other.alertSensitivityThreshold())
&& Objects.equals(alertTypeAsString(), other.alertTypeAsString())
&& Objects.equals(alertStatusAsString(), other.alertStatusAsString())
&& Objects.equals(lastModificationTime(), other.lastModificationTime())
&& Objects.equals(creationTime(), other.creationTime()) && Objects.equals(alertFilters(), other.alertFilters());
}
/**
* 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("Alert").add("Action", action()).add("AlertDescription", alertDescription())
.add("AlertArn", alertArn()).add("AnomalyDetectorArn", anomalyDetectorArn()).add("AlertName", alertName())
.add("AlertSensitivityThreshold", alertSensitivityThreshold()).add("AlertType", alertTypeAsString())
.add("AlertStatus", alertStatusAsString()).add("LastModificationTime", lastModificationTime())
.add("CreationTime", creationTime()).add("AlertFilters", alertFilters()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Action":
return Optional.ofNullable(clazz.cast(action()));
case "AlertDescription":
return Optional.ofNullable(clazz.cast(alertDescription()));
case "AlertArn":
return Optional.ofNullable(clazz.cast(alertArn()));
case "AnomalyDetectorArn":
return Optional.ofNullable(clazz.cast(anomalyDetectorArn()));
case "AlertName":
return Optional.ofNullable(clazz.cast(alertName()));
case "AlertSensitivityThreshold":
return Optional.ofNullable(clazz.cast(alertSensitivityThreshold()));
case "AlertType":
return Optional.ofNullable(clazz.cast(alertTypeAsString()));
case "AlertStatus":
return Optional.ofNullable(clazz.cast(alertStatusAsString()));
case "LastModificationTime":
return Optional.ofNullable(clazz.cast(lastModificationTime()));
case "CreationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "AlertFilters":
return Optional.ofNullable(clazz.cast(alertFilters()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function