"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScheduledQueryRulesAlertV2 = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages an AlertingAction Scheduled Query Rules Version 2 resource within Azure Monitor
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleInsights = new azure.appinsights.Insights("example", {
 *     name: "example-ai",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     applicationType: "web",
 * });
 * const exampleActionGroup = new azure.monitoring.ActionGroup("example", {
 *     name: "example-mag",
 *     resourceGroupName: example.name,
 *     shortName: "test mag",
 * });
 * const exampleUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("example", {
 *     name: "example-uai",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const exampleAssignment = new azure.authorization.Assignment("example", {
 *     scope: exampleInsights.id,
 *     roleDefinitionName: "Reader",
 *     principalId: exampleUserAssignedIdentity.principalId,
 * });
 * const exampleScheduledQueryRulesAlertV2 = new azure.monitoring.ScheduledQueryRulesAlertV2("example", {
 *     name: "example-msqrv2",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     evaluationFrequency: "PT10M",
 *     windowDuration: "PT10M",
 *     scopes: exampleInsights.id,
 *     severity: 4,
 *     criterias: [{
 *         query: `requests
 *   | summarize CountByCountry=count() by client_CountryOrRegion
 * `,
 *         timeAggregationMethod: "Maximum",
 *         threshold: 17.5,
 *         operator: "LessThan",
 *         resourceIdColumn: "client_CountryOrRegion",
 *         metricMeasureColumn: "CountByCountry",
 *         dimensions: [{
 *             name: "client_CountryOrRegion",
 *             operator: "Exclude",
 *             values: ["123"],
 *         }],
 *         failingPeriods: {
 *             minimumFailingPeriodsToTriggerAlert: 1,
 *             numberOfEvaluationPeriods: 1,
 *         },
 *     }],
 *     autoMitigationEnabled: true,
 *     workspaceAlertsStorageEnabled: false,
 *     description: "example sqr",
 *     displayName: "example-sqr",
 *     enabled: true,
 *     queryTimeRangeOverride: "PT1H",
 *     skipQueryValidation: true,
 *     action: {
 *         actionGroups: [exampleActionGroup.id],
 *         customProperties: {
 *             key: "value",
 *             key2: "value2",
 *         },
 *         emailSubject: "Email Header",
 *     },
 *     identity: {
 *         type: "UserAssigned",
 *         identityIds: [exampleUserAssignedIdentity.id],
 *     },
 *     tags: {
 *         key: "value",
 *         key2: "value2",
 *     },
 * }, {
 *     dependsOn: [exampleAssignment],
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Insights` - 2023-03-15-preview
 *
 * ## Import
 *
 * Monitor Scheduled Query Rule Alert can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:monitoring/scheduledQueryRulesAlertV2:ScheduledQueryRulesAlertV2 example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Insights/scheduledQueryRules/rule1
 * ```
 */
class ScheduledQueryRulesAlertV2 extends pulumi.CustomResource {
    /**
     * Get an existing ScheduledQueryRulesAlertV2 resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new ScheduledQueryRulesAlertV2(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:monitoring/scheduledQueryRulesAlertV2:ScheduledQueryRulesAlertV2';
    /**
     * Returns true if the given object is an instance of ScheduledQueryRulesAlertV2.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === ScheduledQueryRulesAlertV2.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["action"] = state?.action;
            resourceInputs["autoMitigationEnabled"] = state?.autoMitigationEnabled;
            resourceInputs["createdWithApiVersion"] = state?.createdWithApiVersion;
            resourceInputs["criterias"] = state?.criterias;
            resourceInputs["description"] = state?.description;
            resourceInputs["displayName"] = state?.displayName;
            resourceInputs["enabled"] = state?.enabled;
            resourceInputs["evaluationFrequency"] = state?.evaluationFrequency;
            resourceInputs["identity"] = state?.identity;
            resourceInputs["isALegacyLogAnalyticsRule"] = state?.isALegacyLogAnalyticsRule;
            resourceInputs["isWorkspaceAlertsStorageConfigured"] = state?.isWorkspaceAlertsStorageConfigured;
            resourceInputs["location"] = state?.location;
            resourceInputs["muteActionsAfterAlertDuration"] = state?.muteActionsAfterAlertDuration;
            resourceInputs["name"] = state?.name;
            resourceInputs["queryTimeRangeOverride"] = state?.queryTimeRangeOverride;
            resourceInputs["resourceGroupName"] = state?.resourceGroupName;
            resourceInputs["scopes"] = state?.scopes;
            resourceInputs["severity"] = state?.severity;
            resourceInputs["skipQueryValidation"] = state?.skipQueryValidation;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["targetResourceTypes"] = state?.targetResourceTypes;
            resourceInputs["windowDuration"] = state?.windowDuration;
            resourceInputs["workspaceAlertsStorageEnabled"] = state?.workspaceAlertsStorageEnabled;
        }
        else {
            const args = argsOrState;
            if (args?.criterias === undefined && !opts.urn) {
                throw new Error("Missing required property 'criterias'");
            }
            if (args?.evaluationFrequency === undefined && !opts.urn) {
                throw new Error("Missing required property 'evaluationFrequency'");
            }
            if (args?.resourceGroupName === undefined && !opts.urn) {
                throw new Error("Missing required property 'resourceGroupName'");
            }
            if (args?.scopes === undefined && !opts.urn) {
                throw new Error("Missing required property 'scopes'");
            }
            if (args?.severity === undefined && !opts.urn) {
                throw new Error("Missing required property 'severity'");
            }
            if (args?.windowDuration === undefined && !opts.urn) {
                throw new Error("Missing required property 'windowDuration'");
            }
            resourceInputs["action"] = args?.action;
            resourceInputs["autoMitigationEnabled"] = args?.autoMitigationEnabled;
            resourceInputs["criterias"] = args?.criterias;
            resourceInputs["description"] = args?.description;
            resourceInputs["displayName"] = args?.displayName;
            resourceInputs["enabled"] = args?.enabled;
            resourceInputs["evaluationFrequency"] = args?.evaluationFrequency;
            resourceInputs["identity"] = args?.identity;
            resourceInputs["location"] = args?.location;
            resourceInputs["muteActionsAfterAlertDuration"] = args?.muteActionsAfterAlertDuration;
            resourceInputs["name"] = args?.name;
            resourceInputs["queryTimeRangeOverride"] = args?.queryTimeRangeOverride;
            resourceInputs["resourceGroupName"] = args?.resourceGroupName;
            resourceInputs["scopes"] = args?.scopes;
            resourceInputs["severity"] = args?.severity;
            resourceInputs["skipQueryValidation"] = args?.skipQueryValidation;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["targetResourceTypes"] = args?.targetResourceTypes;
            resourceInputs["windowDuration"] = args?.windowDuration;
            resourceInputs["workspaceAlertsStorageEnabled"] = args?.workspaceAlertsStorageEnabled;
            resourceInputs["createdWithApiVersion"] = undefined /*out*/;
            resourceInputs["isALegacyLogAnalyticsRule"] = undefined /*out*/;
            resourceInputs["isWorkspaceAlertsStorageConfigured"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(ScheduledQueryRulesAlertV2.__pulumiType, name, resourceInputs, opts);
    }
}
exports.ScheduledQueryRulesAlertV2 = ScheduledQueryRulesAlertV2;
//# sourceMappingURL=scheduledQueryRulesAlertV2.js.map