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

com.azure.resourcemanager.security.models.NotificationsSourceAlert 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.security.models;

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;

/**
 * Alert notification source.
 */
@Fluent
public final class NotificationsSourceAlert extends NotificationsSource {
    /*
     * The source type that will trigger the notification
     */
    private SourceType sourceType = SourceType.ALERT;

    /*
     * Defines the minimal alert severity which will be sent as email notifications
     */
    private MinimalSeverity minimalSeverity;

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

    /**
     * Get the sourceType property: The source type that will trigger the notification.
     * 
     * @return the sourceType value.
     */
    @Override
    public SourceType sourceType() {
        return this.sourceType;
    }

    /**
     * Get the minimalSeverity property: Defines the minimal alert severity which will be sent as email notifications.
     * 
     * @return the minimalSeverity value.
     */
    public MinimalSeverity minimalSeverity() {
        return this.minimalSeverity;
    }

    /**
     * Set the minimalSeverity property: Defines the minimal alert severity which will be sent as email notifications.
     * 
     * @param minimalSeverity the minimalSeverity value to set.
     * @return the NotificationsSourceAlert object itself.
     */
    public NotificationsSourceAlert withMinimalSeverity(MinimalSeverity minimalSeverity) {
        this.minimalSeverity = minimalSeverity;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("sourceType", this.sourceType == null ? null : this.sourceType.toString());
        jsonWriter.writeStringField("minimalSeverity",
            this.minimalSeverity == null ? null : this.minimalSeverity.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("sourceType".equals(fieldName)) {
                    deserializedNotificationsSourceAlert.sourceType = SourceType.fromString(reader.getString());
                } else if ("minimalSeverity".equals(fieldName)) {
                    deserializedNotificationsSourceAlert.minimalSeverity
                        = MinimalSeverity.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedNotificationsSourceAlert;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy