"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.ScheduledQueryRulesAlert = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages an AlertingAction Scheduled Query Rules resource within Azure Monitor.
 *
 * > **Note:** This resource is using an older AzureRM API version which is known to cause problems e.g. with custom webhook properties not included in triggered alerts. This resource is superseded by the azure.monitoring.ScheduledQueryRulesAlertV2 resource using newer API versions.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * import * as std from "@pulumi/std";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "monitoring-resources",
 *     location: "West Europe",
 * });
 * const exampleInsights = new azure.appinsights.Insights("example", {
 *     name: "appinsights",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     applicationType: "web",
 * });
 * const example2 = new azure.appinsights.Insights("example2", {
 *     name: "appinsights2",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     applicationType: "web",
 * });
 * // Example: Alerting Action with result count trigger
 * const exampleScheduledQueryRulesAlert = new azure.monitoring.ScheduledQueryRulesAlert("example", {
 *     name: "example",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     action: {
 *         actionGroups: [],
 *         emailSubject: "Email Header",
 *         customWebhookPayload: "{}",
 *     },
 *     dataSourceId: exampleInsights.id,
 *     description: "Alert when total results cross threshold",
 *     enabled: true,
 *     query: `requests
 *   | where tolong(resultCode) >= 500
 *   | summarize count() by bin(timestamp, 5m)
 * `,
 *     severity: 1,
 *     frequency: 5,
 *     timeWindow: 30,
 *     trigger: {
 *         operator: "GreaterThan",
 *         threshold: 3,
 *     },
 *     tags: {
 *         foo: "bar",
 *     },
 * });
 * // Example: Alerting Action Cross-Resource
 * const example2ScheduledQueryRulesAlert = new azure.monitoring.ScheduledQueryRulesAlert("example2", {
 *     name: "example",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     authorizedResourceIds: [example2.id],
 *     action: {
 *         actionGroups: [],
 *         emailSubject: "Email Header",
 *         customWebhookPayload: "{}",
 *     },
 *     dataSourceId: exampleInsights.id,
 *     description: "Query may access data within multiple resources",
 *     enabled: true,
 *     query: std.format({
 *         input: `let a=requests
 *   | where toint(resultCode) >= 500
 *   | extend fail=1; let b=app('%s').requests
 *   | where toint(resultCode) >= 500 | extend fail=1; a
 *   | join b on fail
 * `,
 *         args: [example2.id],
 *     }).then(invoke => invoke.result),
 *     severity: 1,
 *     frequency: 5,
 *     timeWindow: 30,
 *     trigger: {
 *         operator: "GreaterThan",
 *         threshold: 3,
 *     },
 *     tags: {
 *         foo: "bar",
 *     },
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Insights` - 2018-04-16
 *
 * ## Import
 *
 * Scheduled Query Rule Alerts can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:monitoring/scheduledQueryRulesAlert:ScheduledQueryRulesAlert example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Insights/scheduledQueryRules/myrulename
 * ```
 */
class ScheduledQueryRulesAlert extends pulumi.CustomResource {
    /**
     * Get an existing ScheduledQueryRulesAlert 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 ScheduledQueryRulesAlert(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:monitoring/scheduledQueryRulesAlert:ScheduledQueryRulesAlert';
    /**
     * Returns true if the given object is an instance of ScheduledQueryRulesAlert.  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'] === ScheduledQueryRulesAlert.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["action"] = state?.action;
            resourceInputs["authorizedResourceIds"] = state?.authorizedResourceIds;
            resourceInputs["autoMitigationEnabled"] = state?.autoMitigationEnabled;
            resourceInputs["dataSourceId"] = state?.dataSourceId;
            resourceInputs["description"] = state?.description;
            resourceInputs["enabled"] = state?.enabled;
            resourceInputs["frequency"] = state?.frequency;
            resourceInputs["location"] = state?.location;
            resourceInputs["name"] = state?.name;
            resourceInputs["query"] = state?.query;
            resourceInputs["queryType"] = state?.queryType;
            resourceInputs["resourceGroupName"] = state?.resourceGroupName;
            resourceInputs["severity"] = state?.severity;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["throttling"] = state?.throttling;
            resourceInputs["timeWindow"] = state?.timeWindow;
            resourceInputs["trigger"] = state?.trigger;
        }
        else {
            const args = argsOrState;
            if (args?.action === undefined && !opts.urn) {
                throw new Error("Missing required property 'action'");
            }
            if (args?.dataSourceId === undefined && !opts.urn) {
                throw new Error("Missing required property 'dataSourceId'");
            }
            if (args?.frequency === undefined && !opts.urn) {
                throw new Error("Missing required property 'frequency'");
            }
            if (args?.query === undefined && !opts.urn) {
                throw new Error("Missing required property 'query'");
            }
            if (args?.resourceGroupName === undefined && !opts.urn) {
                throw new Error("Missing required property 'resourceGroupName'");
            }
            if (args?.timeWindow === undefined && !opts.urn) {
                throw new Error("Missing required property 'timeWindow'");
            }
            if (args?.trigger === undefined && !opts.urn) {
                throw new Error("Missing required property 'trigger'");
            }
            resourceInputs["action"] = args?.action;
            resourceInputs["authorizedResourceIds"] = args?.authorizedResourceIds;
            resourceInputs["autoMitigationEnabled"] = args?.autoMitigationEnabled;
            resourceInputs["dataSourceId"] = args?.dataSourceId;
            resourceInputs["description"] = args?.description;
            resourceInputs["enabled"] = args?.enabled;
            resourceInputs["frequency"] = args?.frequency;
            resourceInputs["location"] = args?.location;
            resourceInputs["name"] = args?.name;
            resourceInputs["query"] = args?.query;
            resourceInputs["queryType"] = args?.queryType;
            resourceInputs["resourceGroupName"] = args?.resourceGroupName;
            resourceInputs["severity"] = args?.severity;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["throttling"] = args?.throttling;
            resourceInputs["timeWindow"] = args?.timeWindow;
            resourceInputs["trigger"] = args?.trigger;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(ScheduledQueryRulesAlert.__pulumiType, name, resourceInputs, opts);
    }
}
exports.ScheduledQueryRulesAlert = ScheduledQueryRulesAlert;
//# sourceMappingURL=scheduledQueryRulesAlert.js.map