"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.OrgGroupPolicyOverride = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
 * Provides a Datadog Org Group Policy Override resource. An override exempts a specific organization from a policy applied at the org group level.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as datadog from "@pulumi/datadog";
 *
 * const prod = new datadog.OrgGroup("prod", {name: "Production Environments"});
 * const exemptOrg = new datadog.OrgGroupMembership("exempt_org", {
 *     orgGroupId: prod.id,
 *     orgUuid: "ff4a8255-6931-58d1-add0-a6b3602d5421",
 * });
 * const widgetCopyPaste = new datadog.OrgGroupPolicy("widget_copy_paste", {
 *     orgGroupId: prod.id,
 *     policyName: "is_widget_copy_paste_enabled",
 *     content: JSON.stringify({
 *         org_config: false,
 *     }),
 *     enforcementTier: "OVERRIDE_ALLOWED",
 * });
 * // Exempts the given organization from the widget_copy_paste policy.
 * // The org keeps its current value for is_widget_copy_paste_enabled regardless
 * // of the policy. The resource must target a policy whose tier is not GROUP_MANAGED.
 * const example = new datadog.OrgGroupPolicyOverride("example", {
 *     orgGroupId: prod.id,
 *     policyId: widgetCopyPaste.id,
 *     orgUuid: "ff4a8255-6931-58d1-add0-a6b3602d5421",
 *     orgSite: "us1",
 * }, {
 *     dependsOn: [exemptOrg],
 * });
 * ```
 *
 * ## Behavior notes
 *
 * ### Server-side auto-creation
 *
 * Overrides are also created automatically by the server when an org's existing config differs from a policy's value. Two triggers:
 *
 * 1. **Membership change:** When an org is moved into an org group, the server compares that org's current config to each non-`GROUP_MANAGED` policy in the group. Any mismatch produces an auto-created override that records the org's existing value.
 * 2. **Policy create/update** with a non-`GROUP_MANAGED` tier: The server performs the same comparison across every member org at policy apply time, creating overrides for orgs whose config doesn't match the new policy value.
 *
 * Auto-created and user-declared overrides are indistinguishable at the API level. They can be adopted into Terraform via `pulumi import` or by iterating the `datadog.getOrgGroupPolicyOverrides` data source with `forEach` + `import` blocks.
 *
 * ### Delete behavior
 *
 * Removing an override does **not** just remove the exemption marker. The target org's config value is also reset to match the parent policy's current value. The server treats override deletion as "re-apply the policy to this org" and propagates the policy value accordingly.
 *
 * If you want to stop managing an override without changing the org's value, use `terraform state rm` instead of removing the resource block.
 *
 * ### GROUP_MANAGED tier cascade
 *
 * When the parent `datadog.OrgGroupPolicy` transitions to `enforcementTier = "GROUP_MANAGED"`, the server automatically deletes every override for that policy. Creating an override against an already-`GROUP_MANAGED`-tier policy also fails with a `FailedPrecondition` error.
 *
 * If you plan to flip a policy to `GROUP_MANAGED`, remove the `datadog.OrgGroupPolicyOverride` resource blocks for that policy in the same commit. Otherwise, Terraform's next apply will try to re-create the server-deleted overrides and fail.
 *
 * ## Import
 *
 * ```sh
 * $ pulumi import datadog:index/orgGroupPolicyOverride:OrgGroupPolicyOverride example <override_uuid>
 * ```
 */
class OrgGroupPolicyOverride extends pulumi.CustomResource {
    /**
     * Get an existing OrgGroupPolicyOverride 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 OrgGroupPolicyOverride(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'datadog:index/orgGroupPolicyOverride:OrgGroupPolicyOverride';
    /**
     * Returns true if the given object is an instance of OrgGroupPolicyOverride.  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'] === OrgGroupPolicyOverride.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["content"] = state?.content;
            resourceInputs["orgGroupId"] = state?.orgGroupId;
            resourceInputs["orgSite"] = state?.orgSite;
            resourceInputs["orgUuid"] = state?.orgUuid;
            resourceInputs["policyId"] = state?.policyId;
        }
        else {
            const args = argsOrState;
            if (args?.orgGroupId === undefined && !opts.urn) {
                throw new Error("Missing required property 'orgGroupId'");
            }
            if (args?.orgSite === undefined && !opts.urn) {
                throw new Error("Missing required property 'orgSite'");
            }
            if (args?.orgUuid === undefined && !opts.urn) {
                throw new Error("Missing required property 'orgUuid'");
            }
            if (args?.policyId === undefined && !opts.urn) {
                throw new Error("Missing required property 'policyId'");
            }
            resourceInputs["orgGroupId"] = args?.orgGroupId;
            resourceInputs["orgSite"] = args?.orgSite;
            resourceInputs["orgUuid"] = args?.orgUuid;
            resourceInputs["policyId"] = args?.policyId;
            resourceInputs["content"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(OrgGroupPolicyOverride.__pulumiType, name, resourceInputs, opts);
    }
}
exports.OrgGroupPolicyOverride = OrgGroupPolicyOverride;
//# sourceMappingURL=orgGroupPolicyOverride.js.map