"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.OrgGroupPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
 * Provides a Datadog Org Group Policy resource. This can be used to create and manage policies attached to an org group.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as datadog from "@pulumi/datadog";
 *
 * const prod = new datadog.OrgGroup("prod", {name: "Production Environments"});
 * // Disables widget copy-paste for every member org of the prod group.
 * // enforcement_tier = "OVERRIDE_ALLOWED" means member orgs can still override the value;
 * // use "GROUP_MANAGED" to make the value immutable for members.
 * const example = new datadog.OrgGroupPolicy("example", {
 *     orgGroupId: prod.id,
 *     policyName: "is_widget_copy_paste_enabled",
 *     content: JSON.stringify({
 *         org_config: false,
 *     }),
 *     enforcementTier: "OVERRIDE_ALLOWED",
 * });
 * ```
 *
 * ## Behavior notes
 *
 * ### Side effects on member orgs
 *
 * Creating or updating a policy with a non-`GROUP_MANAGED` tier (`OVERRIDE_ALLOWED` or `DELEGATE`) triggers propagation across every member org in the group. For each member, the server compares the org's current config value to the policy value:
 *
 * - **Match:** No action.
 * - **Mismatch:** The server auto-creates a `datadog.OrgGroupPolicyOverride` for that org, recording its existing value so the org is exempted from the new policy.
 *
 * Auto-created overrides show up in the `datadog.getOrgGroupPolicyOverrides` data source and can be adopted into Terraform via import. See the override resource documentation for the full lifecycle.
 *
 * ### Transitioning to GROUP_MANAGED
 *
 * Changing `enforcementTier` to `"GROUP_MANAGED"` automatically deletes every override associated with this policy server-side. Any `datadog.OrgGroupPolicyOverride` resources pointing at this policy must be removed from configuration in the same commit. Otherwise, Terraform's next apply will try to recreate the server-deleted overrides and fail with a `FailedPrecondition` error.
 *
 * ## Import
 *
 * ```sh
 * $ pulumi import datadog:index/orgGroupPolicy:OrgGroupPolicy example <policy_uuid>
 * ```
 */
class OrgGroupPolicy extends pulumi.CustomResource {
    /**
     * Get an existing OrgGroupPolicy 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 OrgGroupPolicy(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'datadog:index/orgGroupPolicy:OrgGroupPolicy';
    /**
     * Returns true if the given object is an instance of OrgGroupPolicy.  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'] === OrgGroupPolicy.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["content"] = state?.content;
            resourceInputs["enforcementTier"] = state?.enforcementTier;
            resourceInputs["orgGroupId"] = state?.orgGroupId;
            resourceInputs["policyName"] = state?.policyName;
            resourceInputs["policyType"] = state?.policyType;
        }
        else {
            const args = argsOrState;
            if (args?.content === undefined && !opts.urn) {
                throw new Error("Missing required property 'content'");
            }
            if (args?.orgGroupId === undefined && !opts.urn) {
                throw new Error("Missing required property 'orgGroupId'");
            }
            if (args?.policyName === undefined && !opts.urn) {
                throw new Error("Missing required property 'policyName'");
            }
            resourceInputs["content"] = args?.content;
            resourceInputs["enforcementTier"] = args?.enforcementTier;
            resourceInputs["orgGroupId"] = args?.orgGroupId;
            resourceInputs["policyName"] = args?.policyName;
            resourceInputs["policyType"] = args?.policyType;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(OrgGroupPolicy.__pulumiType, name, resourceInputs, opts);
    }
}
exports.OrgGroupPolicy = OrgGroupPolicy;
//# sourceMappingURL=orgGroupPolicy.js.map