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

package com.azure.resourcemanager.servicefabric.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Describes the notification channel for cluster events. */
@Fluent
public final class Notification {
    /*
     * Indicates if the notification is enabled.
     */
    @JsonProperty(value = "isEnabled", required = true)
    private boolean isEnabled;

    /*
     * The category of notification.
     */
    @JsonProperty(value = "notificationCategory", required = true)
    private NotificationCategory notificationCategory;

    /*
     * The level of notification.
     */
    @JsonProperty(value = "notificationLevel", required = true)
    private NotificationLevel notificationLevel;

    /*
     * List of targets that subscribe to the notification.
     */
    @JsonProperty(value = "notificationTargets", required = true)
    private List<NotificationTarget> notificationTargets;

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

    /**
     * Get the isEnabled property: Indicates if the notification is enabled.
     *
     * @return the isEnabled value.
     */
    public boolean isEnabled() {
        return this.isEnabled;
    }

    /**
     * Set the isEnabled property: Indicates if the notification is enabled.
     *
     * @param isEnabled the isEnabled value to set.
     * @return the Notification object itself.
     */
    public Notification withIsEnabled(boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    /**
     * Get the notificationCategory property: The category of notification.
     *
     * @return the notificationCategory value.
     */
    public NotificationCategory notificationCategory() {
        return this.notificationCategory;
    }

    /**
     * Set the notificationCategory property: The category of notification.
     *
     * @param notificationCategory the notificationCategory value to set.
     * @return the Notification object itself.
     */
    public Notification withNotificationCategory(NotificationCategory notificationCategory) {
        this.notificationCategory = notificationCategory;
        return this;
    }

    /**
     * Get the notificationLevel property: The level of notification.
     *
     * @return the notificationLevel value.
     */
    public NotificationLevel notificationLevel() {
        return this.notificationLevel;
    }

    /**
     * Set the notificationLevel property: The level of notification.
     *
     * @param notificationLevel the notificationLevel value to set.
     * @return the Notification object itself.
     */
    public Notification withNotificationLevel(NotificationLevel notificationLevel) {
        this.notificationLevel = notificationLevel;
        return this;
    }

    /**
     * Get the notificationTargets property: List of targets that subscribe to the notification.
     *
     * @return the notificationTargets value.
     */
    public List<NotificationTarget> notificationTargets() {
        return this.notificationTargets;
    }

    /**
     * Set the notificationTargets property: List of targets that subscribe to the notification.
     *
     * @param notificationTargets the notificationTargets value to set.
     * @return the Notification object itself.
     */
    public Notification withNotificationTargets(List<NotificationTarget> notificationTargets) {
        this.notificationTargets = notificationTargets;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (notificationCategory() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property notificationCategory in model Notification"));
        }
        if (notificationLevel() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property notificationLevel in model Notification"));
        }
        if (notificationTargets() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property notificationTargets in model Notification"));
        } else {
            notificationTargets().forEach(e -> e.validate());
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(Notification.class);
}
