// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.security.models.RuleState;
import com.azure.resourcemanager.security.models.SuppressionAlertsScope;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** describes AlertsSuppressionRule properties. */
@Fluent
public final class AlertsSuppressionRuleProperties {
    /*
     * Type of the alert to automatically suppress. For all alert types, use '*'
     */
    @JsonProperty(value = "alertType", required = true)
    private String alertType;

    /*
     * The last time this rule was modified
     */
    @JsonProperty(value = "lastModifiedUtc", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime lastModifiedUtc;

    /*
     * Expiration date of the rule, if value is not provided or provided as null this field will default to the maximum
     * allowed expiration date.
     */
    @JsonProperty(value = "expirationDateUtc")
    private OffsetDateTime expirationDateUtc;

    /*
     * The reason for dismissing the alert
     */
    @JsonProperty(value = "reason", required = true)
    private String reason;

    /*
     * Possible states of the rule
     */
    @JsonProperty(value = "state", required = true)
    private RuleState state;

    /*
     * Any comment regarding the rule
     */
    @JsonProperty(value = "comment")
    private String comment;

    /*
     * The suppression conditions
     */
    @JsonProperty(value = "suppressionAlertsScope")
    private SuppressionAlertsScope suppressionAlertsScope;

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

    /**
     * Get the alertType property: Type of the alert to automatically suppress. For all alert types, use '*'.
     *
     * @return the alertType value.
     */
    public String alertType() {
        return this.alertType;
    }

    /**
     * Set the alertType property: Type of the alert to automatically suppress. For all alert types, use '*'.
     *
     * @param alertType the alertType value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withAlertType(String alertType) {
        this.alertType = alertType;
        return this;
    }

    /**
     * Get the lastModifiedUtc property: The last time this rule was modified.
     *
     * @return the lastModifiedUtc value.
     */
    public OffsetDateTime lastModifiedUtc() {
        return this.lastModifiedUtc;
    }

    /**
     * Get the expirationDateUtc property: Expiration date of the rule, if value is not provided or provided as null
     * this field will default to the maximum allowed expiration date.
     *
     * @return the expirationDateUtc value.
     */
    public OffsetDateTime expirationDateUtc() {
        return this.expirationDateUtc;
    }

    /**
     * Set the expirationDateUtc property: Expiration date of the rule, if value is not provided or provided as null
     * this field will default to the maximum allowed expiration date.
     *
     * @param expirationDateUtc the expirationDateUtc value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withExpirationDateUtc(OffsetDateTime expirationDateUtc) {
        this.expirationDateUtc = expirationDateUtc;
        return this;
    }

    /**
     * Get the reason property: The reason for dismissing the alert.
     *
     * @return the reason value.
     */
    public String reason() {
        return this.reason;
    }

    /**
     * Set the reason property: The reason for dismissing the alert.
     *
     * @param reason the reason value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withReason(String reason) {
        this.reason = reason;
        return this;
    }

    /**
     * Get the state property: Possible states of the rule.
     *
     * @return the state value.
     */
    public RuleState state() {
        return this.state;
    }

    /**
     * Set the state property: Possible states of the rule.
     *
     * @param state the state value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withState(RuleState state) {
        this.state = state;
        return this;
    }

    /**
     * Get the comment property: Any comment regarding the rule.
     *
     * @return the comment value.
     */
    public String comment() {
        return this.comment;
    }

    /**
     * Set the comment property: Any comment regarding the rule.
     *
     * @param comment the comment value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withComment(String comment) {
        this.comment = comment;
        return this;
    }

    /**
     * Get the suppressionAlertsScope property: The suppression conditions.
     *
     * @return the suppressionAlertsScope value.
     */
    public SuppressionAlertsScope suppressionAlertsScope() {
        return this.suppressionAlertsScope;
    }

    /**
     * Set the suppressionAlertsScope property: The suppression conditions.
     *
     * @param suppressionAlertsScope the suppressionAlertsScope value to set.
     * @return the AlertsSuppressionRuleProperties object itself.
     */
    public AlertsSuppressionRuleProperties withSuppressionAlertsScope(SuppressionAlertsScope suppressionAlertsScope) {
        this.suppressionAlertsScope = suppressionAlertsScope;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (alertType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property alertType in model AlertsSuppressionRuleProperties"));
        }
        if (reason() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property reason in model AlertsSuppressionRuleProperties"));
        }
        if (state() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property state in model AlertsSuppressionRuleProperties"));
        }
        if (suppressionAlertsScope() != null) {
            suppressionAlertsScope().validate();
        }
    }

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