"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.Policy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Allows management of Organization Policies for a Google Cloud Organization.
 *
 * > **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://docs.cloud.google.com/resource-manager/reference/rest/v1/organizations/setOrgPolicy)
 * * How-to Guides
 *     * [Introduction to the Organization Policy Service](https://docs.cloud.google.com/resource-manager/docs/organization-policy/overview)
 *
 * ## Example Usage
 *
 * To set policy with a [boolean constraint](https://docs.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.organizations.Policy("serial_port_policy", {
 *     orgId: "123456789",
 *     constraint: "compute.disableSerialPortAccess",
 *     booleanPolicy: {
 *         enforced: true,
 *     },
 * });
 * ```
 *
 * To set a policy with a [list constraint](https://docs.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.organizations.Policy("services_policy", {
 *     orgId: "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.organizations.Policy("services_policy", {
 *     orgId: "123456789",
 *     constraint: "serviceuser.services",
 *     listPolicy: {
 *         suggestedValue: "compute.googleapis.com",
 *         deny: {
 *             values: ["cloudresourcemanager.googleapis.com"],
 *         },
 *     },
 * });
 * ```
 *
 * To restore the default organization policy, use the following instead:
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const servicesPolicy = new gcp.organizations.Policy("services_policy", {
 *     orgId: "123456789",
 *     constraint: "serviceuser.services",
 *     restorePolicy: {
 *         "default": true,
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * Organization Policies can be imported using the `org_id` and the `constraint`, e.g.
 *
 * * `{{org_id}}/constraints/{{constraint}}`
 *
 * When using the `pulumi import` command, Organization Policies can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:organizations/policy:Policy default {{org_id}}/constraints/{{constraint}}
 * ```
 *
 * It is all right if the constraint contains a slash, as in the example above.
 */
class Policy extends pulumi.CustomResource {
    /**
     * Get an existing Policy 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 Policy(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Policy.  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'] === Policy.__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["listPolicy"] = state?.listPolicy;
            resourceInputs["orgId"] = state?.orgId;
            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?.orgId === undefined && !opts.urn) {
                throw new Error("Missing required property 'orgId'");
            }
            resourceInputs["booleanPolicy"] = args?.booleanPolicy;
            resourceInputs["constraint"] = args?.constraint;
            resourceInputs["listPolicy"] = args?.listPolicy;
            resourceInputs["orgId"] = args?.orgId;
            resourceInputs["restorePolicy"] = args?.restorePolicy;
            resourceInputs["version"] = args?.version;
            resourceInputs["etag"] = undefined /*out*/;
            resourceInputs["updateTime"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Policy.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Policy = Policy;
/** @internal */
Policy.__pulumiType = 'gcp:organizations/policy:Policy';
//# sourceMappingURL=policy.js.map