"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.OrganizationPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Allows management of Organization Policies for a Google Cloud Folder.
 *
 * > **Warning:** This resource has been superseded by `gcp.orgpolicy.Policy`. `gcp.orgpolicy.Policy` uses Organization Policy API V2 instead of Cloud Resource Manager API V1 and it supports additional features such as tags and conditions.
 *
 * To get more information about Organization Policies, see:
 *
 * * [API documentation](https://cloud.google.com/resource-manager/reference/rest/v1/folders/setOrgPolicy)
 * * How-to Guides
 *     * [Introduction to the Organization Policy Service](https://cloud.google.com/resource-manager/docs/organization-policy/overview)
 *
 * ## Example Usage
 *
 * To set policy with a [boolean constraint](https://cloud.google.com/resource-manager/docs/organization-policy/quickstart-boolean-constraints):
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const serialPortPolicy = new gcp.folder.OrganizationPolicy("serial_port_policy", {
 *     folder: "folders/123456789",
 *     constraint: "compute.disableSerialPortAccess",
 *     booleanPolicy: {
 *         enforced: true,
 *     },
 * });
 * ```
 *
 * To set a policy with a [list constraint](https://cloud.google.com/resource-manager/docs/organization-policy/quickstart-list-constraints):
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const servicesPolicy = new gcp.folder.OrganizationPolicy("services_policy", {
 *     folder: "folders/123456789",
 *     constraint: "serviceuser.services",
 *     listPolicy: {
 *         allow: {
 *             all: true,
 *         },
 *     },
 * });
 * ```
 *
 * Or to deny some services, use the following instead:
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const servicesPolicy = new gcp.folder.OrganizationPolicy("services_policy", {
 *     folder: "folders/123456789",
 *     constraint: "serviceuser.services",
 *     listPolicy: {
 *         suggestedValue: "compute.googleapis.com",
 *         deny: {
 *             values: ["cloudresourcemanager.googleapis.com"],
 *         },
 *     },
 * });
 * ```
 *
 * To restore the default folder organization policy, use the following instead:
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const servicesPolicy = new gcp.folder.OrganizationPolicy("services_policy", {
 *     folder: "folders/123456789",
 *     constraint: "serviceuser.services",
 *     restorePolicy: {
 *         "default": true,
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * Folder organization policies can be imported using any of the follow formats:
 *
 * * `folders/{{folder_id}}/constraints/serviceuser.services`
 *
 * * `{{folder_id}}/serviceuser.services`
 *
 * When using the `pulumi import` command, folder organization policies can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:folder/organizationPolicy:OrganizationPolicy * `google_folder_organization_policy.default folders/* ``{{folder_id}}/constraints/serviceuser.services`
 * ```
 *
 * ```sh
 * $ pulumi import gcp:folder/organizationPolicy:OrganizationPolicy * `* `google_folder_organization_policy.default {{folder_id}}/``serviceuser.services
 * ```
 */
class OrganizationPolicy extends pulumi.CustomResource {
    /**
     * Get an existing OrganizationPolicy 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 OrganizationPolicy(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of OrganizationPolicy.  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'] === OrganizationPolicy.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["booleanPolicy"] = state?.booleanPolicy;
            resourceInputs["constraint"] = state?.constraint;
            resourceInputs["etag"] = state?.etag;
            resourceInputs["folder"] = state?.folder;
            resourceInputs["listPolicy"] = state?.listPolicy;
            resourceInputs["restorePolicy"] = state?.restorePolicy;
            resourceInputs["updateTime"] = state?.updateTime;
            resourceInputs["version"] = state?.version;
        }
        else {
            const args = argsOrState;
            if (args?.constraint === undefined && !opts.urn) {
                throw new Error("Missing required property 'constraint'");
            }
            if (args?.folder === undefined && !opts.urn) {
                throw new Error("Missing required property 'folder'");
            }
            resourceInputs["booleanPolicy"] = args?.booleanPolicy;
            resourceInputs["constraint"] = args?.constraint;
            resourceInputs["folder"] = args?.folder;
            resourceInputs["listPolicy"] = args?.listPolicy;
            resourceInputs["restorePolicy"] = args?.restorePolicy;
            resourceInputs["version"] = args?.version;
            resourceInputs["etag"] = undefined /*out*/;
            resourceInputs["updateTime"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(OrganizationPolicy.__pulumiType, name, resourceInputs, opts);
    }
}
exports.OrganizationPolicy = OrganizationPolicy;
/** @internal */
OrganizationPolicy.__pulumiType = 'gcp:folder/organizationPolicy:OrganizationPolicy';
//# sourceMappingURL=organizationPolicy.js.map