"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricDescriptor = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Defines a metric type and its schema. Once a metric descriptor is created, deleting or altering it stops data collection and makes the metric type's existing data unusable.
 *
 * To get more information about MetricDescriptor, see:
 *
 * * [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/monitoring/custom-metrics/)
 *
 * ## Example Usage
 *
 * ### Monitoring Metric Descriptor Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const basic = new gcp.monitoring.MetricDescriptor("basic", {
 *     description: "Daily sales records from all branch stores.",
 *     displayName: "metric-descriptor",
 *     type: "custom.googleapis.com/stores/daily_sales",
 *     metricKind: "GAUGE",
 *     valueType: "DOUBLE",
 *     unit: "{USD}",
 *     labels: [{
 *         key: "store_id",
 *         valueType: "STRING",
 *         description: "The ID of the store.",
 *     }],
 *     launchStage: "BETA",
 *     metadata: {
 *         samplePeriod: "60s",
 *         ingestDelay: "30s",
 *     },
 * });
 * ```
 * ### Monitoring Metric Descriptor Alert
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const withAlert = new gcp.monitoring.MetricDescriptor("with_alert", {
 *     description: "Daily sales records from all branch stores.",
 *     displayName: "metric-descriptor",
 *     type: "custom.googleapis.com/stores/daily_sales",
 *     metricKind: "GAUGE",
 *     valueType: "DOUBLE",
 *     unit: "{USD}",
 * });
 * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", {
 *     displayName: "metric-descriptor",
 *     combiner: "OR",
 *     conditions: [{
 *         displayName: "test condition",
 *         conditionThreshold: {
 *             filter: pulumi.interpolate`metric.type="${withAlert.type}" AND resource.type="gce_instance"`,
 *             duration: "60s",
 *             comparison: "COMPARISON_GT",
 *         },
 *     }],
 * });
 * ```
 *
 * ## Import
 *
 * MetricDescriptor can be imported using any of these accepted formats:
 *
 * * `{{project}}/{{name}}`
 *
 * * `{{project}} {{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, MetricDescriptor can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default {{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default "{{project}} {{name}}"
 * ```
 *
 * ```sh
 * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default {{name}}
 * ```
 */
class MetricDescriptor extends pulumi.CustomResource {
    /**
     * Get an existing MetricDescriptor 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 MetricDescriptor(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of MetricDescriptor.  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'] === MetricDescriptor.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["description"] = state?.description;
            resourceInputs["displayName"] = state?.displayName;
            resourceInputs["labels"] = state?.labels;
            resourceInputs["launchStage"] = state?.launchStage;
            resourceInputs["metadata"] = state?.metadata;
            resourceInputs["metricKind"] = state?.metricKind;
            resourceInputs["monitoredResourceTypes"] = state?.monitoredResourceTypes;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["type"] = state?.type;
            resourceInputs["unit"] = state?.unit;
            resourceInputs["valueType"] = state?.valueType;
        }
        else {
            const args = argsOrState;
            if (args?.metricKind === undefined && !opts.urn) {
                throw new Error("Missing required property 'metricKind'");
            }
            if (args?.type === undefined && !opts.urn) {
                throw new Error("Missing required property 'type'");
            }
            if (args?.valueType === undefined && !opts.urn) {
                throw new Error("Missing required property 'valueType'");
            }
            resourceInputs["description"] = args?.description;
            resourceInputs["displayName"] = args?.displayName;
            resourceInputs["labels"] = args?.labels;
            resourceInputs["launchStage"] = args?.launchStage;
            resourceInputs["metadata"] = args?.metadata;
            resourceInputs["metricKind"] = args?.metricKind;
            resourceInputs["project"] = args?.project;
            resourceInputs["type"] = args?.type;
            resourceInputs["unit"] = args?.unit;
            resourceInputs["valueType"] = args?.valueType;
            resourceInputs["monitoredResourceTypes"] = undefined /*out*/;
            resourceInputs["name"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(MetricDescriptor.__pulumiType, name, resourceInputs, opts);
    }
}
exports.MetricDescriptor = MetricDescriptor;
/** @internal */
MetricDescriptor.__pulumiType = 'gcp:monitoring/metricDescriptor:MetricDescriptor';
//# sourceMappingURL=metricDescriptor.js.map