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

package com.azure.resourcemanager.alertsmanagement.models;

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

/** Alert processing rule properties defining scopes, conditions and scheduling logic for alert processing rule. */
@Fluent
public final class AlertProcessingRuleProperties {
    /*
     * Scopes on which alert processing rule will apply.
     */
    @JsonProperty(value = "scopes", required = true)
    private List<String> scopes;

    /*
     * Conditions on which alerts will be filtered.
     */
    @JsonProperty(value = "conditions")
    private List<Condition> conditions;

    /*
     * Scheduling for alert processing rule.
     */
    @JsonProperty(value = "schedule")
    private Schedule schedule;

    /*
     * Actions to be applied.
     */
    @JsonProperty(value = "actions", required = true)
    private List<Action> actions;

    /*
     * Description of alert processing rule.
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * Indicates if the given alert processing rule is enabled or disabled.
     */
    @JsonProperty(value = "enabled")
    private Boolean enabled;

    /**
     * Get the scopes property: Scopes on which alert processing rule will apply.
     *
     * @return the scopes value.
     */
    public List<String> scopes() {
        return this.scopes;
    }

    /**
     * Set the scopes property: Scopes on which alert processing rule will apply.
     *
     * @param scopes the scopes value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withScopes(List<String> scopes) {
        this.scopes = scopes;
        return this;
    }

    /**
     * Get the conditions property: Conditions on which alerts will be filtered.
     *
     * @return the conditions value.
     */
    public List<Condition> conditions() {
        return this.conditions;
    }

    /**
     * Set the conditions property: Conditions on which alerts will be filtered.
     *
     * @param conditions the conditions value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withConditions(List<Condition> conditions) {
        this.conditions = conditions;
        return this;
    }

    /**
     * Get the schedule property: Scheduling for alert processing rule.
     *
     * @return the schedule value.
     */
    public Schedule schedule() {
        return this.schedule;
    }

    /**
     * Set the schedule property: Scheduling for alert processing rule.
     *
     * @param schedule the schedule value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withSchedule(Schedule schedule) {
        this.schedule = schedule;
        return this;
    }

    /**
     * Get the actions property: Actions to be applied.
     *
     * @return the actions value.
     */
    public List<Action> actions() {
        return this.actions;
    }

    /**
     * Set the actions property: Actions to be applied.
     *
     * @param actions the actions value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withActions(List<Action> actions) {
        this.actions = actions;
        return this;
    }

    /**
     * Get the description property: Description of alert processing rule.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Description of alert processing rule.
     *
     * @param description the description value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the enabled property: Indicates if the given alert processing rule is enabled or disabled.
     *
     * @return the enabled value.
     */
    public Boolean enabled() {
        return this.enabled;
    }

    /**
     * Set the enabled property: Indicates if the given alert processing rule is enabled or disabled.
     *
     * @param enabled the enabled value to set.
     * @return the AlertProcessingRuleProperties object itself.
     */
    public AlertProcessingRuleProperties withEnabled(Boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (scopes() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property scopes in model AlertProcessingRuleProperties"));
        }
        if (conditions() != null) {
            conditions().forEach(e -> e.validate());
        }
        if (schedule() != null) {
            schedule().validate();
        }
        if (actions() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property actions in model AlertProcessingRuleProperties"));
        } else {
            actions().forEach(e -> e.validate());
        }
    }

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