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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.securityinsights.fluent.models.AlertRuleInner;
import com.azure.resourcemanager.securityinsights.fluent.models.NrtAlertRuleProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/** Represents NRT alert rule. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind")
@JsonTypeName("NRT")
@Fluent
public final class NrtAlertRule extends AlertRuleInner {
    /*
     * NRT alert rule properties
     */
    @JsonProperty(value = "properties")
    private NrtAlertRuleProperties innerProperties;

    /**
     * Get the innerProperties property: NRT alert rule properties.
     *
     * @return the innerProperties value.
     */
    private NrtAlertRuleProperties innerProperties() {
        return this.innerProperties;
    }

    /** {@inheritDoc} */
    @Override
    public NrtAlertRule withEtag(String etag) {
        super.withEtag(etag);
        return this;
    }

    /**
     * Get the alertRuleTemplateName property: The Name of the alert rule template used to create this rule.
     *
     * @return the alertRuleTemplateName value.
     */
    public String alertRuleTemplateName() {
        return this.innerProperties() == null ? null : this.innerProperties().alertRuleTemplateName();
    }

    /**
     * Set the alertRuleTemplateName property: The Name of the alert rule template used to create this rule.
     *
     * @param alertRuleTemplateName the alertRuleTemplateName value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withAlertRuleTemplateName(String alertRuleTemplateName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withAlertRuleTemplateName(alertRuleTemplateName);
        return this;
    }

    /**
     * Get the templateVersion property: The version of the alert rule template used to create this rule - in format
     * &lt;a.b.c&gt;, where all are numbers, for example 0 &lt;1.0.2&gt;.
     *
     * @return the templateVersion value.
     */
    public String templateVersion() {
        return this.innerProperties() == null ? null : this.innerProperties().templateVersion();
    }

    /**
     * Set the templateVersion property: The version of the alert rule template used to create this rule - in format
     * &lt;a.b.c&gt;, where all are numbers, for example 0 &lt;1.0.2&gt;.
     *
     * @param templateVersion the templateVersion value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withTemplateVersion(String templateVersion) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withTemplateVersion(templateVersion);
        return this;
    }

    /**
     * Get the description property: The description of the alert rule.
     *
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: The description of the alert rule.
     *
     * @param description the description value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

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

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

    /**
     * Get the tactics property: The tactics of the alert rule.
     *
     * @return the tactics value.
     */
    public List<AttackTactic> tactics() {
        return this.innerProperties() == null ? null : this.innerProperties().tactics();
    }

    /**
     * Set the tactics property: The tactics of the alert rule.
     *
     * @param tactics the tactics value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withTactics(List<AttackTactic> tactics) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withTactics(tactics);
        return this;
    }

    /**
     * Get the techniques property: The techniques of the alert rule.
     *
     * @return the techniques value.
     */
    public List<String> techniques() {
        return this.innerProperties() == null ? null : this.innerProperties().techniques();
    }

    /**
     * Set the techniques property: The techniques of the alert rule.
     *
     * @param techniques the techniques value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withTechniques(List<String> techniques) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withTechniques(techniques);
        return this;
    }

    /**
     * Get the displayName property: The display name for alerts created by this alert rule.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.innerProperties() == null ? null : this.innerProperties().displayName();
    }

    /**
     * Set the displayName property: The display name for alerts created by this alert rule.
     *
     * @param displayName the displayName value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

    /**
     * Get the enabled property: Determines whether this alert rule is enabled or disabled.
     *
     * @return the enabled value.
     */
    public Boolean enabled() {
        return this.innerProperties() == null ? null : this.innerProperties().enabled();
    }

    /**
     * Set the enabled property: Determines whether this alert rule is enabled or disabled.
     *
     * @param enabled the enabled value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withEnabled(Boolean enabled) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withEnabled(enabled);
        return this;
    }

    /**
     * Get the lastModifiedUtc property: The last time that this alert rule has been modified.
     *
     * @return the lastModifiedUtc value.
     */
    public OffsetDateTime lastModifiedUtc() {
        return this.innerProperties() == null ? null : this.innerProperties().lastModifiedUtc();
    }

    /**
     * Get the suppressionDuration property: The suppression (in ISO 8601 duration format) to wait since last time this
     * alert rule been triggered.
     *
     * @return the suppressionDuration value.
     */
    public Duration suppressionDuration() {
        return this.innerProperties() == null ? null : this.innerProperties().suppressionDuration();
    }

    /**
     * Set the suppressionDuration property: The suppression (in ISO 8601 duration format) to wait since last time this
     * alert rule been triggered.
     *
     * @param suppressionDuration the suppressionDuration value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withSuppressionDuration(Duration suppressionDuration) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withSuppressionDuration(suppressionDuration);
        return this;
    }

    /**
     * Get the suppressionEnabled property: Determines whether the suppression for this alert rule is enabled or
     * disabled.
     *
     * @return the suppressionEnabled value.
     */
    public Boolean suppressionEnabled() {
        return this.innerProperties() == null ? null : this.innerProperties().suppressionEnabled();
    }

    /**
     * Set the suppressionEnabled property: Determines whether the suppression for this alert rule is enabled or
     * disabled.
     *
     * @param suppressionEnabled the suppressionEnabled value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withSuppressionEnabled(Boolean suppressionEnabled) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withSuppressionEnabled(suppressionEnabled);
        return this;
    }

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

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

    /**
     * Get the incidentConfiguration property: The settings of the incidents that created from alerts triggered by this
     * analytics rule.
     *
     * @return the incidentConfiguration value.
     */
    public IncidentConfiguration incidentConfiguration() {
        return this.innerProperties() == null ? null : this.innerProperties().incidentConfiguration();
    }

    /**
     * Set the incidentConfiguration property: The settings of the incidents that created from alerts triggered by this
     * analytics rule.
     *
     * @param incidentConfiguration the incidentConfiguration value to set.
     * @return the NrtAlertRule object itself.
     */
    public NrtAlertRule withIncidentConfiguration(IncidentConfiguration incidentConfiguration) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withIncidentConfiguration(incidentConfiguration);
        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.innerProperties() == null ? null : this.innerProperties().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 NrtAlertRule object itself.
     */
    public NrtAlertRule withCustomDetails(Map<String, String> customDetails) {
        if (this.innerProperties() == null) {
            this.innerProperties = new NrtAlertRuleProperties();
        }
        this.innerProperties().withCustomDetails(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.innerProperties() == null ? null : this.innerProperties().entityMappings();
    }

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

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

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

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

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
