software.amazon.awssdk.services.cloudwatchlogs.model.AnomalyDetector Maven / Gradle / Ivy
Show all versions of cloudwatchlogs 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.cloudwatchlogs.model;
import java.io.Serializable;
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.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.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;
/**
*
* Contains information about one anomaly detector in the account.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AnomalyDetector implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ANOMALY_DETECTOR_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("anomalyDetectorArn").getter(getter(AnomalyDetector::anomalyDetectorArn))
.setter(setter(Builder::anomalyDetectorArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("anomalyDetectorArn").build())
.build();
private static final SdkField DETECTOR_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("detectorName").getter(getter(AnomalyDetector::detectorName)).setter(setter(Builder::detectorName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("detectorName").build()).build();
private static final SdkField> LOG_GROUP_ARN_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("logGroupArnList")
.getter(getter(AnomalyDetector::logGroupArnList))
.setter(setter(Builder::logGroupArnList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("logGroupArnList").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField EVALUATION_FREQUENCY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("evaluationFrequency").getter(getter(AnomalyDetector::evaluationFrequencyAsString))
.setter(setter(Builder::evaluationFrequency))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("evaluationFrequency").build())
.build();
private static final SdkField FILTER_PATTERN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("filterPattern").getter(getter(AnomalyDetector::filterPattern)).setter(setter(Builder::filterPattern))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("filterPattern").build()).build();
private static final SdkField ANOMALY_DETECTOR_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("anomalyDetectorStatus").getter(getter(AnomalyDetector::anomalyDetectorStatusAsString))
.setter(setter(Builder::anomalyDetectorStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("anomalyDetectorStatus").build())
.build();
private static final SdkField KMS_KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("kmsKeyId").getter(getter(AnomalyDetector::kmsKeyId)).setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("kmsKeyId").build()).build();
private static final SdkField CREATION_TIME_STAMP_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("creationTimeStamp").getter(getter(AnomalyDetector::creationTimeStamp))
.setter(setter(Builder::creationTimeStamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationTimeStamp").build()).build();
private static final SdkField LAST_MODIFIED_TIME_STAMP_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("lastModifiedTimeStamp").getter(getter(AnomalyDetector::lastModifiedTimeStamp))
.setter(setter(Builder::lastModifiedTimeStamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastModifiedTimeStamp").build())
.build();
private static final SdkField ANOMALY_VISIBILITY_TIME_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("anomalyVisibilityTime").getter(getter(AnomalyDetector::anomalyVisibilityTime))
.setter(setter(Builder::anomalyVisibilityTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("anomalyVisibilityTime").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ANOMALY_DETECTOR_ARN_FIELD,
DETECTOR_NAME_FIELD, LOG_GROUP_ARN_LIST_FIELD, EVALUATION_FREQUENCY_FIELD, FILTER_PATTERN_FIELD,
ANOMALY_DETECTOR_STATUS_FIELD, KMS_KEY_ID_FIELD, CREATION_TIME_STAMP_FIELD, LAST_MODIFIED_TIME_STAMP_FIELD,
ANOMALY_VISIBILITY_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String anomalyDetectorArn;
private final String detectorName;
private final List logGroupArnList;
private final String evaluationFrequency;
private final String filterPattern;
private final String anomalyDetectorStatus;
private final String kmsKeyId;
private final Long creationTimeStamp;
private final Long lastModifiedTimeStamp;
private final Long anomalyVisibilityTime;
private AnomalyDetector(BuilderImpl builder) {
this.anomalyDetectorArn = builder.anomalyDetectorArn;
this.detectorName = builder.detectorName;
this.logGroupArnList = builder.logGroupArnList;
this.evaluationFrequency = builder.evaluationFrequency;
this.filterPattern = builder.filterPattern;
this.anomalyDetectorStatus = builder.anomalyDetectorStatus;
this.kmsKeyId = builder.kmsKeyId;
this.creationTimeStamp = builder.creationTimeStamp;
this.lastModifiedTimeStamp = builder.lastModifiedTimeStamp;
this.anomalyVisibilityTime = builder.anomalyVisibilityTime;
}
/**
*
* The ARN of the anomaly detector.
*
*
* @return The ARN of the anomaly detector.
*/
public final String anomalyDetectorArn() {
return anomalyDetectorArn;
}
/**
*
* The name of the anomaly detector.
*
*
* @return The name of the anomaly detector.
*/
public final String detectorName() {
return detectorName;
}
/**
* For responses, this returns true if the service returned a value for the LogGroupArnList 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 hasLogGroupArnList() {
return logGroupArnList != null && !(logGroupArnList instanceof SdkAutoConstructList);
}
/**
*
* A list of the ARNs of the log groups that this anomaly detector watches.
*
*
* 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 #hasLogGroupArnList} method.
*
*
* @return A list of the ARNs of the log groups that this anomaly detector watches.
*/
public final List logGroupArnList() {
return logGroupArnList;
}
/**
*
* Specifies how often the anomaly detector runs and look for anomalies.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #evaluationFrequency} will return {@link EvaluationFrequency#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #evaluationFrequencyAsString}.
*
*
* @return Specifies how often the anomaly detector runs and look for anomalies.
* @see EvaluationFrequency
*/
public final EvaluationFrequency evaluationFrequency() {
return EvaluationFrequency.fromValue(evaluationFrequency);
}
/**
*
* Specifies how often the anomaly detector runs and look for anomalies.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #evaluationFrequency} will return {@link EvaluationFrequency#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #evaluationFrequencyAsString}.
*
*
* @return Specifies how often the anomaly detector runs and look for anomalies.
* @see EvaluationFrequency
*/
public final String evaluationFrequencyAsString() {
return evaluationFrequency;
}
/**
* Returns the value of the FilterPattern property for this object.
*
* @return The value of the FilterPattern property for this object.
*/
public final String filterPattern() {
return filterPattern;
}
/**
*
* Specifies the current status of the anomaly detector. To pause an anomaly detector, use the enabled
* parameter in the UpdateLogAnomalyDetector operation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #anomalyDetectorStatus} will return {@link AnomalyDetectorStatus#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #anomalyDetectorStatusAsString}.
*
*
* @return Specifies the current status of the anomaly detector. To pause an anomaly detector, use the
* enabled
parameter in the UpdateLogAnomalyDetector operation.
* @see AnomalyDetectorStatus
*/
public final AnomalyDetectorStatus anomalyDetectorStatus() {
return AnomalyDetectorStatus.fromValue(anomalyDetectorStatus);
}
/**
*
* Specifies the current status of the anomaly detector. To pause an anomaly detector, use the enabled
* parameter in the UpdateLogAnomalyDetector operation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #anomalyDetectorStatus} will return {@link AnomalyDetectorStatus#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #anomalyDetectorStatusAsString}.
*
*
* @return Specifies the current status of the anomaly detector. To pause an anomaly detector, use the
* enabled
parameter in the UpdateLogAnomalyDetector operation.
* @see AnomalyDetectorStatus
*/
public final String anomalyDetectorStatusAsString() {
return anomalyDetectorStatus;
}
/**
*
* The ID of the KMS key assigned to this anomaly detector, if any.
*
*
* @return The ID of the KMS key assigned to this anomaly detector, if any.
*/
public final String kmsKeyId() {
return kmsKeyId;
}
/**
*
* The date and time when this anomaly detector was created.
*
*
* @return The date and time when this anomaly detector was created.
*/
public final Long creationTimeStamp() {
return creationTimeStamp;
}
/**
*
* The date and time when this anomaly detector was most recently modified.
*
*
* @return The date and time when this anomaly detector was most recently modified.
*/
public final Long lastModifiedTimeStamp() {
return lastModifiedTimeStamp;
}
/**
*
* The number of days used as the life cycle of anomalies. After this time, anomalies are automatically baselined
* and the anomaly detector model will treat new occurrences of similar event as normal.
*
*
* @return The number of days used as the life cycle of anomalies. After this time, anomalies are automatically
* baselined and the anomaly detector model will treat new occurrences of similar event as normal.
*/
public final Long anomalyVisibilityTime() {
return anomalyVisibilityTime;
}
@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(anomalyDetectorArn());
hashCode = 31 * hashCode + Objects.hashCode(detectorName());
hashCode = 31 * hashCode + Objects.hashCode(hasLogGroupArnList() ? logGroupArnList() : null);
hashCode = 31 * hashCode + Objects.hashCode(evaluationFrequencyAsString());
hashCode = 31 * hashCode + Objects.hashCode(filterPattern());
hashCode = 31 * hashCode + Objects.hashCode(anomalyDetectorStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(creationTimeStamp());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedTimeStamp());
hashCode = 31 * hashCode + Objects.hashCode(anomalyVisibilityTime());
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 AnomalyDetector)) {
return false;
}
AnomalyDetector other = (AnomalyDetector) obj;
return Objects.equals(anomalyDetectorArn(), other.anomalyDetectorArn())
&& Objects.equals(detectorName(), other.detectorName()) && hasLogGroupArnList() == other.hasLogGroupArnList()
&& Objects.equals(logGroupArnList(), other.logGroupArnList())
&& Objects.equals(evaluationFrequencyAsString(), other.evaluationFrequencyAsString())
&& Objects.equals(filterPattern(), other.filterPattern())
&& Objects.equals(anomalyDetectorStatusAsString(), other.anomalyDetectorStatusAsString())
&& Objects.equals(kmsKeyId(), other.kmsKeyId()) && Objects.equals(creationTimeStamp(), other.creationTimeStamp())
&& Objects.equals(lastModifiedTimeStamp(), other.lastModifiedTimeStamp())
&& Objects.equals(anomalyVisibilityTime(), other.anomalyVisibilityTime());
}
/**
* 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("AnomalyDetector").add("AnomalyDetectorArn", anomalyDetectorArn())
.add("DetectorName", detectorName()).add("LogGroupArnList", hasLogGroupArnList() ? logGroupArnList() : null)
.add("EvaluationFrequency", evaluationFrequencyAsString()).add("FilterPattern", filterPattern())
.add("AnomalyDetectorStatus", anomalyDetectorStatusAsString()).add("KmsKeyId", kmsKeyId())
.add("CreationTimeStamp", creationTimeStamp()).add("LastModifiedTimeStamp", lastModifiedTimeStamp())
.add("AnomalyVisibilityTime", anomalyVisibilityTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "anomalyDetectorArn":
return Optional.ofNullable(clazz.cast(anomalyDetectorArn()));
case "detectorName":
return Optional.ofNullable(clazz.cast(detectorName()));
case "logGroupArnList":
return Optional.ofNullable(clazz.cast(logGroupArnList()));
case "evaluationFrequency":
return Optional.ofNullable(clazz.cast(evaluationFrequencyAsString()));
case "filterPattern":
return Optional.ofNullable(clazz.cast(filterPattern()));
case "anomalyDetectorStatus":
return Optional.ofNullable(clazz.cast(anomalyDetectorStatusAsString()));
case "kmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "creationTimeStamp":
return Optional.ofNullable(clazz.cast(creationTimeStamp()));
case "lastModifiedTimeStamp":
return Optional.ofNullable(clazz.cast(lastModifiedTimeStamp()));
case "anomalyVisibilityTime":
return Optional.ofNullable(clazz.cast(anomalyVisibilityTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function