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

com.azure.resourcemanager.monitor.models.ConditionFailingPeriods Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Monitor SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

There is a newer version: 2.46.0
Show 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.resourcemanager.monitor.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The minimum number of violations required within the selected lookback time window required to raise an alert.
 * Relevant only for rules of the kind LogAlert.
 */
@Fluent
public final class ConditionFailingPeriods implements JsonSerializable {
    /*
     * The number of aggregated lookback points. The lookback time window is calculated based on the aggregation
     * granularity (windowSize) and the selected number of aggregated points. Default value is 1
     */
    private Long numberOfEvaluationPeriods;

    /*
     * The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default
     * value is 1
     */
    private Long minFailingPeriodsToAlert;

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

    /**
     * Get the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is
     * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points.
     * Default value is 1.
     * 
     * @return the numberOfEvaluationPeriods value.
     */
    public Long numberOfEvaluationPeriods() {
        return this.numberOfEvaluationPeriods;
    }

    /**
     * Set the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is
     * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points.
     * Default value is 1.
     * 
     * @param numberOfEvaluationPeriods the numberOfEvaluationPeriods value to set.
     * @return the ConditionFailingPeriods object itself.
     */
    public ConditionFailingPeriods withNumberOfEvaluationPeriods(Long numberOfEvaluationPeriods) {
        this.numberOfEvaluationPeriods = numberOfEvaluationPeriods;
        return this;
    }

    /**
     * Get the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or
     * equal to numberOfEvaluationPeriods. Default value is 1.
     * 
     * @return the minFailingPeriodsToAlert value.
     */
    public Long minFailingPeriodsToAlert() {
        return this.minFailingPeriodsToAlert;
    }

    /**
     * Set the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or
     * equal to numberOfEvaluationPeriods. Default value is 1.
     * 
     * @param minFailingPeriodsToAlert the minFailingPeriodsToAlert value to set.
     * @return the ConditionFailingPeriods object itself.
     */
    public ConditionFailingPeriods withMinFailingPeriodsToAlert(Long minFailingPeriodsToAlert) {
        this.minFailingPeriodsToAlert = minFailingPeriodsToAlert;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeNumberField("numberOfEvaluationPeriods", this.numberOfEvaluationPeriods);
        jsonWriter.writeNumberField("minFailingPeriodsToAlert", this.minFailingPeriodsToAlert);
        return jsonWriter.writeEndObject();
    }

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

                if ("numberOfEvaluationPeriods".equals(fieldName)) {
                    deserializedConditionFailingPeriods.numberOfEvaluationPeriods
                        = reader.getNullable(JsonReader::getLong);
                } else if ("minFailingPeriodsToAlert".equals(fieldName)) {
                    deserializedConditionFailingPeriods.minFailingPeriodsToAlert
                        = reader.getNullable(JsonReader::getLong);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedConditionFailingPeriods;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy