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

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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.securityinsights.models.AlertDetailsOverride;
import com.azure.resourcemanager.securityinsights.models.AlertRuleTemplateDataSource;
import com.azure.resourcemanager.securityinsights.models.AlertRuleTemplateWithMitreProperties;
import com.azure.resourcemanager.securityinsights.models.AlertSeverity;
import com.azure.resourcemanager.securityinsights.models.AttackTactic;
import com.azure.resourcemanager.securityinsights.models.EntityMapping;
import com.azure.resourcemanager.securityinsights.models.EventGroupingSettings;
import com.azure.resourcemanager.securityinsights.models.TemplateStatus;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** NRT alert rule template properties. */
@Fluent
public final class NrtAlertRuleTemplateProperties extends AlertRuleTemplateWithMitreProperties {
    /*
     * The query that creates alerts for this rule.
     */
    @JsonProperty(value = "query")
    private String query;

    /*
     * The severity for alerts created by this alert rule.
     */
    @JsonProperty(value = "severity")
    private AlertSeverity severity;

    /*
     * The version of this template - in format <a.b.c>, where all are numbers. For example <1.0.2>.
     */
    @JsonProperty(value = "version")
    private String version;

    /*
     * Dictionary of string key-value pairs of columns to be attached to the alert
     */
    @JsonProperty(value = "customDetails")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> customDetails;

    /*
     * Array of the entity mappings of the alert rule
     */
    @JsonProperty(value = "entityMappings")
    private List<EntityMapping> entityMappings;

    /*
     * The alert details override settings
     */
    @JsonProperty(value = "alertDetailsOverride")
    private AlertDetailsOverride alertDetailsOverride;

    /*
     * The event grouping settings.
     */
    @JsonProperty(value = "eventGroupingSettings")
    private EventGroupingSettings eventGroupingSettings;

    /**
     * Get the query property: The query that creates alerts for this rule.
     *
     * @return the query value.
     */
    public String query() {
        return this.query;
    }

    /**
     * Set the query property: The query that creates alerts for this rule.
     *
     * @param query the query value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withQuery(String query) {
        this.query = query;
        return this;
    }

    /**
     * Get the severity property: The severity for alerts created by this alert rule.
     *
     * @return the severity value.
     */
    public AlertSeverity severity() {
        return this.severity;
    }

    /**
     * Set the severity property: The severity for alerts created by this alert rule.
     *
     * @param severity the severity value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withSeverity(AlertSeverity severity) {
        this.severity = severity;
        return this;
    }

    /**
     * Get the version property: The version of this template - in format &lt;a.b.c&gt;, where all are numbers. For
     * example &lt;1.0.2&gt;.
     *
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: The version of this template - in format &lt;a.b.c&gt;, where all are numbers. For
     * example &lt;1.0.2&gt;.
     *
     * @param version the version value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Get the customDetails property: Dictionary of string key-value pairs of columns to be attached to the alert.
     *
     * @return the customDetails value.
     */
    public Map<String, String> customDetails() {
        return this.customDetails;
    }

    /**
     * Set the customDetails property: Dictionary of string key-value pairs of columns to be attached to the alert.
     *
     * @param customDetails the customDetails value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withCustomDetails(Map<String, String> customDetails) {
        this.customDetails = customDetails;
        return this;
    }

    /**
     * Get the entityMappings property: Array of the entity mappings of the alert rule.
     *
     * @return the entityMappings value.
     */
    public List<EntityMapping> entityMappings() {
        return this.entityMappings;
    }

    /**
     * Set the entityMappings property: Array of the entity mappings of the alert rule.
     *
     * @param entityMappings the entityMappings value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withEntityMappings(List<EntityMapping> entityMappings) {
        this.entityMappings = entityMappings;
        return this;
    }

    /**
     * Get the alertDetailsOverride property: The alert details override settings.
     *
     * @return the alertDetailsOverride value.
     */
    public AlertDetailsOverride alertDetailsOverride() {
        return this.alertDetailsOverride;
    }

    /**
     * Set the alertDetailsOverride property: The alert details override settings.
     *
     * @param alertDetailsOverride the alertDetailsOverride value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withAlertDetailsOverride(AlertDetailsOverride alertDetailsOverride) {
        this.alertDetailsOverride = alertDetailsOverride;
        return this;
    }

    /**
     * Get the eventGroupingSettings property: The event grouping settings.
     *
     * @return the eventGroupingSettings value.
     */
    public EventGroupingSettings eventGroupingSettings() {
        return this.eventGroupingSettings;
    }

    /**
     * Set the eventGroupingSettings property: The event grouping settings.
     *
     * @param eventGroupingSettings the eventGroupingSettings value to set.
     * @return the NrtAlertRuleTemplateProperties object itself.
     */
    public NrtAlertRuleTemplateProperties withEventGroupingSettings(EventGroupingSettings eventGroupingSettings) {
        this.eventGroupingSettings = eventGroupingSettings;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withTactics(List<AttackTactic> tactics) {
        super.withTactics(tactics);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withTechniques(List<String> techniques) {
        super.withTechniques(techniques);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withAlertRulesCreatedByTemplateCount(
        Integer alertRulesCreatedByTemplateCount) {
        super.withAlertRulesCreatedByTemplateCount(alertRulesCreatedByTemplateCount);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withDisplayName(String displayName) {
        super.withDisplayName(displayName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withRequiredDataConnectors(
        List<AlertRuleTemplateDataSource> requiredDataConnectors) {
        super.withRequiredDataConnectors(requiredDataConnectors);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRuleTemplateProperties withStatus(TemplateStatus status) {
        super.withStatus(status);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (entityMappings() != null) {
            entityMappings().forEach(e -> e.validate());
        }
        if (alertDetailsOverride() != null) {
            alertDetailsOverride().validate();
        }
        if (eventGroupingSettings() != null) {
            eventGroupingSettings().validate();
        }
    }
}
