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

com.azure.resourcemanager.databoxedge.fluent.models.AlertProperties Maven / Gradle / Ivy

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

package com.azure.resourcemanager.databoxedge.fluent.models;

import com.azure.core.annotation.Immutable;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.databoxedge.models.AlertErrorDetails;
import com.azure.resourcemanager.databoxedge.models.AlertSeverity;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Map;

/**
 * Properties of alert.
 */
@Immutable
public final class AlertProperties implements JsonSerializable {
    /*
     * Alert title.
     */
    private String title;

    /*
     * Alert type.
     */
    private String alertType;

    /*
     * UTC time when the alert appeared.
     */
    private OffsetDateTime appearedAtDateTime;

    /*
     * Alert recommendation.
     */
    private String recommendation;

    /*
     * Severity of the alert.
     */
    private AlertSeverity severity;

    /*
     * Error details of the alert.
     */
    private AlertErrorDetails errorDetails;

    /*
     * Alert details.
     */
    private Map detailedInformation;

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

    /**
     * Get the title property: Alert title.
     * 
     * @return the title value.
     */
    public String title() {
        return this.title;
    }

    /**
     * Get the alertType property: Alert type.
     * 
     * @return the alertType value.
     */
    public String alertType() {
        return this.alertType;
    }

    /**
     * Get the appearedAtDateTime property: UTC time when the alert appeared.
     * 
     * @return the appearedAtDateTime value.
     */
    public OffsetDateTime appearedAtDateTime() {
        return this.appearedAtDateTime;
    }

    /**
     * Get the recommendation property: Alert recommendation.
     * 
     * @return the recommendation value.
     */
    public String recommendation() {
        return this.recommendation;
    }

    /**
     * Get the severity property: Severity of the alert.
     * 
     * @return the severity value.
     */
    public AlertSeverity severity() {
        return this.severity;
    }

    /**
     * Get the errorDetails property: Error details of the alert.
     * 
     * @return the errorDetails value.
     */
    public AlertErrorDetails errorDetails() {
        return this.errorDetails;
    }

    /**
     * Get the detailedInformation property: Alert details.
     * 
     * @return the detailedInformation value.
     */
    public Map detailedInformation() {
        return this.detailedInformation;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of AlertProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of AlertProperties 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 AlertProperties.
     */
    public static AlertProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            AlertProperties deserializedAlertProperties = new AlertProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("title".equals(fieldName)) {
                    deserializedAlertProperties.title = reader.getString();
                } else if ("alertType".equals(fieldName)) {
                    deserializedAlertProperties.alertType = reader.getString();
                } else if ("appearedAtDateTime".equals(fieldName)) {
                    deserializedAlertProperties.appearedAtDateTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("recommendation".equals(fieldName)) {
                    deserializedAlertProperties.recommendation = reader.getString();
                } else if ("severity".equals(fieldName)) {
                    deserializedAlertProperties.severity = AlertSeverity.fromString(reader.getString());
                } else if ("errorDetails".equals(fieldName)) {
                    deserializedAlertProperties.errorDetails = AlertErrorDetails.fromJson(reader);
                } else if ("detailedInformation".equals(fieldName)) {
                    Map detailedInformation = reader.readMap(reader1 -> reader1.getString());
                    deserializedAlertProperties.detailedInformation = detailedInformation;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAlertProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy