software.amazon.awssdk.services.devopsguru.model.ProactiveAnomalySummary Maven / Gradle / Ivy
Show all versions of devopsguru 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.devopsguru.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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.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;
/**
*
* Details about a proactive anomaly. This object is returned by DescribeAnomaly.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ProactiveAnomalySummary implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(ProactiveAnomalySummary::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField SEVERITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Severity").getter(getter(ProactiveAnomalySummary::severityAsString)).setter(setter(Builder::severity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Severity").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(ProactiveAnomalySummary::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField UPDATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("UpdateTime").getter(getter(ProactiveAnomalySummary::updateTime)).setter(setter(Builder::updateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdateTime").build()).build();
private static final SdkField ANOMALY_TIME_RANGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("AnomalyTimeRange")
.getter(getter(ProactiveAnomalySummary::anomalyTimeRange)).setter(setter(Builder::anomalyTimeRange))
.constructor(AnomalyTimeRange::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnomalyTimeRange").build()).build();
private static final SdkField ANOMALY_REPORTED_TIME_RANGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("AnomalyReportedTimeRange")
.getter(getter(ProactiveAnomalySummary::anomalyReportedTimeRange)).setter(setter(Builder::anomalyReportedTimeRange))
.constructor(AnomalyReportedTimeRange::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnomalyReportedTimeRange").build())
.build();
private static final SdkField PREDICTION_TIME_RANGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("PredictionTimeRange")
.getter(getter(ProactiveAnomalySummary::predictionTimeRange)).setter(setter(Builder::predictionTimeRange))
.constructor(PredictionTimeRange::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PredictionTimeRange").build())
.build();
private static final SdkField SOURCE_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SourceDetails")
.getter(getter(ProactiveAnomalySummary::sourceDetails)).setter(setter(Builder::sourceDetails))
.constructor(AnomalySourceDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceDetails").build()).build();
private static final SdkField ASSOCIATED_INSIGHT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AssociatedInsightId").getter(getter(ProactiveAnomalySummary::associatedInsightId))
.setter(setter(Builder::associatedInsightId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociatedInsightId").build())
.build();
private static final SdkField RESOURCE_COLLECTION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResourceCollection")
.getter(getter(ProactiveAnomalySummary::resourceCollection)).setter(setter(Builder::resourceCollection))
.constructor(ResourceCollection::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceCollection").build())
.build();
private static final SdkField LIMIT_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Limit")
.getter(getter(ProactiveAnomalySummary::limit)).setter(setter(Builder::limit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Limit").build()).build();
private static final SdkField SOURCE_METADATA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SourceMetadata")
.getter(getter(ProactiveAnomalySummary::sourceMetadata)).setter(setter(Builder::sourceMetadata))
.constructor(AnomalySourceMetadata::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceMetadata").build()).build();
private static final SdkField> ANOMALY_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AnomalyResources")
.getter(getter(ProactiveAnomalySummary::anomalyResources))
.setter(setter(Builder::anomalyResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnomalyResources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AnomalyResource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(ProactiveAnomalySummary::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, SEVERITY_FIELD,
STATUS_FIELD, UPDATE_TIME_FIELD, ANOMALY_TIME_RANGE_FIELD, ANOMALY_REPORTED_TIME_RANGE_FIELD,
PREDICTION_TIME_RANGE_FIELD, SOURCE_DETAILS_FIELD, ASSOCIATED_INSIGHT_ID_FIELD, RESOURCE_COLLECTION_FIELD,
LIMIT_FIELD, SOURCE_METADATA_FIELD, ANOMALY_RESOURCES_FIELD, DESCRIPTION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("Id", ID_FIELD);
put("Severity", SEVERITY_FIELD);
put("Status", STATUS_FIELD);
put("UpdateTime", UPDATE_TIME_FIELD);
put("AnomalyTimeRange", ANOMALY_TIME_RANGE_FIELD);
put("AnomalyReportedTimeRange", ANOMALY_REPORTED_TIME_RANGE_FIELD);
put("PredictionTimeRange", PREDICTION_TIME_RANGE_FIELD);
put("SourceDetails", SOURCE_DETAILS_FIELD);
put("AssociatedInsightId", ASSOCIATED_INSIGHT_ID_FIELD);
put("ResourceCollection", RESOURCE_COLLECTION_FIELD);
put("Limit", LIMIT_FIELD);
put("SourceMetadata", SOURCE_METADATA_FIELD);
put("AnomalyResources", ANOMALY_RESOURCES_FIELD);
put("Description", DESCRIPTION_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String id;
private final String severity;
private final String status;
private final Instant updateTime;
private final AnomalyTimeRange anomalyTimeRange;
private final AnomalyReportedTimeRange anomalyReportedTimeRange;
private final PredictionTimeRange predictionTimeRange;
private final AnomalySourceDetails sourceDetails;
private final String associatedInsightId;
private final ResourceCollection resourceCollection;
private final Double limit;
private final AnomalySourceMetadata sourceMetadata;
private final List anomalyResources;
private final String description;
private ProactiveAnomalySummary(BuilderImpl builder) {
this.id = builder.id;
this.severity = builder.severity;
this.status = builder.status;
this.updateTime = builder.updateTime;
this.anomalyTimeRange = builder.anomalyTimeRange;
this.anomalyReportedTimeRange = builder.anomalyReportedTimeRange;
this.predictionTimeRange = builder.predictionTimeRange;
this.sourceDetails = builder.sourceDetails;
this.associatedInsightId = builder.associatedInsightId;
this.resourceCollection = builder.resourceCollection;
this.limit = builder.limit;
this.sourceMetadata = builder.sourceMetadata;
this.anomalyResources = builder.anomalyResources;
this.description = builder.description;
}
/**
*
* The ID of the anomaly.
*
*
* @return The ID of the anomaly.
*/
public final String id() {
return id;
}
/**
*
* The severity of the anomaly. The severity of anomalies that generate an insight determine that insight's
* severity. For more information, see Understanding insight severities in the Amazon DevOps Guru User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link AnomalySeverity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the anomaly. The severity of anomalies that generate an insight determine that insight's
* severity. For more information, see Understanding insight severities in the Amazon DevOps Guru User Guide.
* @see AnomalySeverity
*/
public final AnomalySeverity severity() {
return AnomalySeverity.fromValue(severity);
}
/**
*
* The severity of the anomaly. The severity of anomalies that generate an insight determine that insight's
* severity. For more information, see Understanding insight severities in the Amazon DevOps Guru User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link AnomalySeverity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the anomaly. The severity of anomalies that generate an insight determine that insight's
* severity. For more information, see Understanding insight severities in the Amazon DevOps Guru User Guide.
* @see AnomalySeverity
*/
public final String severityAsString() {
return severity;
}
/**
*
* The status of the anomaly.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AnomalyStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the anomaly.
* @see AnomalyStatus
*/
public final AnomalyStatus status() {
return AnomalyStatus.fromValue(status);
}
/**
*
* The status of the anomaly.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AnomalyStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the anomaly.
* @see AnomalyStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The time of the anomaly's most recent update.
*
*
* @return The time of the anomaly's most recent update.
*/
public final Instant updateTime() {
return updateTime;
}
/**
* Returns the value of the AnomalyTimeRange property for this object.
*
* @return The value of the AnomalyTimeRange property for this object.
*/
public final AnomalyTimeRange anomalyTimeRange() {
return anomalyTimeRange;
}
/**
*
* An AnomalyReportedTimeRange
object that specifies the time range between when the anomaly is opened
* and the time when it is closed.
*
*
* @return An AnomalyReportedTimeRange
object that specifies the time range between when the anomaly is
* opened and the time when it is closed.
*/
public final AnomalyReportedTimeRange anomalyReportedTimeRange() {
return anomalyReportedTimeRange;
}
/**
* Returns the value of the PredictionTimeRange property for this object.
*
* @return The value of the PredictionTimeRange property for this object.
*/
public final PredictionTimeRange predictionTimeRange() {
return predictionTimeRange;
}
/**
*
* Details about the source of the analyzed operational data that triggered the anomaly. The one supported source is
* Amazon CloudWatch metrics.
*
*
* @return Details about the source of the analyzed operational data that triggered the anomaly. The one supported
* source is Amazon CloudWatch metrics.
*/
public final AnomalySourceDetails sourceDetails() {
return sourceDetails;
}
/**
*
* The ID of the insight that contains this anomaly. An insight is composed of related anomalies.
*
*
* @return The ID of the insight that contains this anomaly. An insight is composed of related anomalies.
*/
public final String associatedInsightId() {
return associatedInsightId;
}
/**
* Returns the value of the ResourceCollection property for this object.
*
* @return The value of the ResourceCollection property for this object.
*/
public final ResourceCollection resourceCollection() {
return resourceCollection;
}
/**
*
* A threshold that was exceeded by behavior in analyzed resources. Exceeding this threshold is related to the
* anomalous behavior that generated this anomaly.
*
*
* @return A threshold that was exceeded by behavior in analyzed resources. Exceeding this threshold is related to
* the anomalous behavior that generated this anomaly.
*/
public final Double limit() {
return limit;
}
/**
*
* The metadata of the source which detects proactive anomalies.
*
*
* @return The metadata of the source which detects proactive anomalies.
*/
public final AnomalySourceMetadata sourceMetadata() {
return sourceMetadata;
}
/**
* For responses, this returns true if the service returned a value for the AnomalyResources 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 hasAnomalyResources() {
return anomalyResources != null && !(anomalyResources instanceof SdkAutoConstructList);
}
/**
*
* Information about a resource in which DevOps Guru detected anomalous behavior.
*
*
* 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 #hasAnomalyResources} method.
*
*
* @return Information about a resource in which DevOps Guru detected anomalous behavior.
*/
public final List anomalyResources() {
return anomalyResources;
}
/**
*
* A description of the proactive anomaly.
*
*
* @return A description of the proactive anomaly.
*/
public final String description() {
return description;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(severityAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(updateTime());
hashCode = 31 * hashCode + Objects.hashCode(anomalyTimeRange());
hashCode = 31 * hashCode + Objects.hashCode(anomalyReportedTimeRange());
hashCode = 31 * hashCode + Objects.hashCode(predictionTimeRange());
hashCode = 31 * hashCode + Objects.hashCode(sourceDetails());
hashCode = 31 * hashCode + Objects.hashCode(associatedInsightId());
hashCode = 31 * hashCode + Objects.hashCode(resourceCollection());
hashCode = 31 * hashCode + Objects.hashCode(limit());
hashCode = 31 * hashCode + Objects.hashCode(sourceMetadata());
hashCode = 31 * hashCode + Objects.hashCode(hasAnomalyResources() ? anomalyResources() : null);
hashCode = 31 * hashCode + Objects.hashCode(description());
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 ProactiveAnomalySummary)) {
return false;
}
ProactiveAnomalySummary other = (ProactiveAnomalySummary) obj;
return Objects.equals(id(), other.id()) && Objects.equals(severityAsString(), other.severityAsString())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(updateTime(), other.updateTime())
&& Objects.equals(anomalyTimeRange(), other.anomalyTimeRange())
&& Objects.equals(anomalyReportedTimeRange(), other.anomalyReportedTimeRange())
&& Objects.equals(predictionTimeRange(), other.predictionTimeRange())
&& Objects.equals(sourceDetails(), other.sourceDetails())
&& Objects.equals(associatedInsightId(), other.associatedInsightId())
&& Objects.equals(resourceCollection(), other.resourceCollection()) && Objects.equals(limit(), other.limit())
&& Objects.equals(sourceMetadata(), other.sourceMetadata())
&& hasAnomalyResources() == other.hasAnomalyResources()
&& Objects.equals(anomalyResources(), other.anomalyResources())
&& Objects.equals(description(), other.description());
}
/**
* 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("ProactiveAnomalySummary").add("Id", id()).add("Severity", severityAsString())
.add("Status", statusAsString()).add("UpdateTime", updateTime()).add("AnomalyTimeRange", anomalyTimeRange())
.add("AnomalyReportedTimeRange", anomalyReportedTimeRange()).add("PredictionTimeRange", predictionTimeRange())
.add("SourceDetails", sourceDetails()).add("AssociatedInsightId", associatedInsightId())
.add("ResourceCollection", resourceCollection()).add("Limit", limit()).add("SourceMetadata", sourceMetadata())
.add("AnomalyResources", hasAnomalyResources() ? anomalyResources() : null).add("Description", description())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Severity":
return Optional.ofNullable(clazz.cast(severityAsString()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "UpdateTime":
return Optional.ofNullable(clazz.cast(updateTime()));
case "AnomalyTimeRange":
return Optional.ofNullable(clazz.cast(anomalyTimeRange()));
case "AnomalyReportedTimeRange":
return Optional.ofNullable(clazz.cast(anomalyReportedTimeRange()));
case "PredictionTimeRange":
return Optional.ofNullable(clazz.cast(predictionTimeRange()));
case "SourceDetails":
return Optional.ofNullable(clazz.cast(sourceDetails()));
case "AssociatedInsightId":
return Optional.ofNullable(clazz.cast(associatedInsightId()));
case "ResourceCollection":
return Optional.ofNullable(clazz.cast(resourceCollection()));
case "Limit":
return Optional.ofNullable(clazz.cast(limit()));
case "SourceMetadata":
return Optional.ofNullable(clazz.cast(sourceMetadata()));
case "AnomalyResources":
return Optional.ofNullable(clazz.cast(anomalyResources()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
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