All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.ai.metricsadvisor.implementation.models.AnomalyFeedback Maven / Gradle / Ivy

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.metricsadvisor.implementation.models;

import com.azure.ai.metricsadvisor.models.FeedbackType;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.UUID;

/**
 * The AnomalyFeedback model.
 */
@Fluent
public final class AnomalyFeedback extends MetricFeedback {
    /*
     * the start timestamp of feedback time range
     */
    private OffsetDateTime startTime;

    /*
     * the end timestamp of feedback time range, when equals to startTime means only one timestamp
     */
    private OffsetDateTime endTime;

    /*
     * The value property.
     */
    private AnomalyFeedbackValue value;

    /*
     * the corresponding anomaly detection configuration of this feedback
     */
    private UUID anomalyDetectionConfigurationId;

    /*
     * The anomalyDetectionConfigurationSnapshot property.
     */
    private AnomalyDetectionConfiguration anomalyDetectionConfigurationSnapshot;

    /**
     * Creates an instance of AnomalyFeedback class.
     */
    public AnomalyFeedback() {
    }

    /**
     * Get the startTime property: the start timestamp of feedback time range.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime getStartTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: the start timestamp of feedback time range.
     * 
     * @param startTime the startTime value to set.
     * @return the AnomalyFeedback object itself.
     */
    public AnomalyFeedback setStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: the end timestamp of feedback time range, when equals to startTime means only one
     * timestamp.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime getEndTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: the end timestamp of feedback time range, when equals to startTime means only one
     * timestamp.
     * 
     * @param endTime the endTime value to set.
     * @return the AnomalyFeedback object itself.
     */
    public AnomalyFeedback setEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Get the value property: The value property.
     * 
     * @return the value value.
     */
    public AnomalyFeedbackValue getValue() {
        return this.value;
    }

    /**
     * Set the value property: The value property.
     * 
     * @param value the value value to set.
     * @return the AnomalyFeedback object itself.
     */
    public AnomalyFeedback setValue(AnomalyFeedbackValue value) {
        this.value = value;
        return this;
    }

    /**
     * Get the anomalyDetectionConfigurationId property: the corresponding anomaly detection configuration of this
     * feedback.
     * 
     * @return the anomalyDetectionConfigurationId value.
     */
    public UUID getAnomalyDetectionConfigurationId() {
        return this.anomalyDetectionConfigurationId;
    }

    /**
     * Set the anomalyDetectionConfigurationId property: the corresponding anomaly detection configuration of this
     * feedback.
     * 
     * @param anomalyDetectionConfigurationId the anomalyDetectionConfigurationId value to set.
     * @return the AnomalyFeedback object itself.
     */
    public AnomalyFeedback setAnomalyDetectionConfigurationId(UUID anomalyDetectionConfigurationId) {
        this.anomalyDetectionConfigurationId = anomalyDetectionConfigurationId;
        return this;
    }

    /**
     * Get the anomalyDetectionConfigurationSnapshot property: The anomalyDetectionConfigurationSnapshot property.
     * 
     * @return the anomalyDetectionConfigurationSnapshot value.
     */
    public AnomalyDetectionConfiguration getAnomalyDetectionConfigurationSnapshot() {
        return this.anomalyDetectionConfigurationSnapshot;
    }

    /**
     * Set the anomalyDetectionConfigurationSnapshot property: The anomalyDetectionConfigurationSnapshot property.
     * 
     * @param anomalyDetectionConfigurationSnapshot the anomalyDetectionConfigurationSnapshot value to set.
     * @return the AnomalyFeedback object itself.
     */
    public AnomalyFeedback
        setAnomalyDetectionConfigurationSnapshot(AnomalyDetectionConfiguration anomalyDetectionConfigurationSnapshot) {
        this.anomalyDetectionConfigurationSnapshot = anomalyDetectionConfigurationSnapshot;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public AnomalyFeedback setMetricId(UUID metricId) {
        super.setMetricId(metricId);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public AnomalyFeedback setDimensionFilter(FeedbackDimensionFilter dimensionFilter) {
        super.setDimensionFilter(dimensionFilter);
        return this;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("feedbackType",
            FeedbackType.ANOMALY == null ? null : FeedbackType.ANOMALY.toString());
        jsonWriter.writeStringField("metricId", Objects.toString(getMetricId(), null));
        jsonWriter.writeJsonField("dimensionFilter", getDimensionFilter());
        jsonWriter.writeStringField("startTime",
            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
        jsonWriter.writeStringField("endTime",
            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
        jsonWriter.writeJsonField("value", this.value);
        jsonWriter.writeStringField("anomalyDetectionConfigurationId",
            Objects.toString(this.anomalyDetectionConfigurationId, null));
        jsonWriter.writeJsonField("anomalyDetectionConfigurationSnapshot", this.anomalyDetectionConfigurationSnapshot);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of AnomalyFeedback from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of AnomalyFeedback if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties or the
     * polymorphic discriminator.
     * @throws IOException If an error occurs while reading the AnomalyFeedback.
     */
    public static AnomalyFeedback fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            AnomalyFeedback deserializedAnomalyFeedback = new AnomalyFeedback();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("feedbackType".equals(fieldName)) {
                    String feedbackType = reader.getString();
                    if (!"Anomaly".equals(feedbackType)) {
                        throw new IllegalStateException(
                            "'feedbackType' was expected to be non-null and equal to 'Anomaly'. The found 'feedbackType' was '"
                                + feedbackType + "'.");
                    }
                } else if ("metricId".equals(fieldName)) {
                    deserializedAnomalyFeedback
                        .setMetricId(reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())));
                } else if ("dimensionFilter".equals(fieldName)) {
                    deserializedAnomalyFeedback.setDimensionFilter(FeedbackDimensionFilter.fromJson(reader));
                } else if ("feedbackId".equals(fieldName)) {
                    deserializedAnomalyFeedback
                        .setFeedbackId(reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())));
                } else if ("createdTime".equals(fieldName)) {
                    deserializedAnomalyFeedback.setCreatedTime(
                        reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())));
                } else if ("userPrincipal".equals(fieldName)) {
                    deserializedAnomalyFeedback.setUserPrincipal(reader.getString());
                } else if ("startTime".equals(fieldName)) {
                    deserializedAnomalyFeedback.startTime
                        = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedAnomalyFeedback.endTime
                        = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()));
                } else if ("value".equals(fieldName)) {
                    deserializedAnomalyFeedback.value = AnomalyFeedbackValue.fromJson(reader);
                } else if ("anomalyDetectionConfigurationId".equals(fieldName)) {
                    deserializedAnomalyFeedback.anomalyDetectionConfigurationId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else if ("anomalyDetectionConfigurationSnapshot".equals(fieldName)) {
                    deserializedAnomalyFeedback.anomalyDetectionConfigurationSnapshot
                        = AnomalyDetectionConfiguration.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAnomalyFeedback;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy