"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.NamespaceCustomerManagedKey = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages a Customer Managed Key for a EventHub Namespace.
 *
 * !> **Note:** In 2.x versions of the Azure Provider during deletion this resource will **delete and recreate the parent EventHub Namespace which may involve data loss** as it's not possible to remove the Customer Managed Key from the EventHub Namespace once it's been added. Version 3.0 of the Azure Provider will change this so that the Delete operation is a noop, requiring the parent EventHub Namespace is deleted/recreated to remove the Customer Managed Key.
 *
 * ## Example Usage
 *
 * ### With System Assigned Identity
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleCluster = new azure.eventhub.Cluster("example", {
 *     name: "example-cluster",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     skuName: "Dedicated_1",
 * });
 * const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("example", {
 *     name: "example-namespace",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "Standard",
 *     dedicatedClusterId: exampleCluster.id,
 *     identity: {
 *         type: "SystemAssigned",
 *     },
 * });
 * const current = azure.core.getClientConfig({});
 * const exampleKeyVault = new azure.keyvault.KeyVault("example", {
 *     name: "examplekv",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     tenantId: current.then(current => current.tenantId),
 *     skuName: "standard",
 *     purgeProtectionEnabled: true,
 * });
 * const exampleAccessPolicy = new azure.keyvault.AccessPolicy("example", {
 *     keyVaultId: exampleKeyVault.id,
 *     tenantId: exampleEventHubNamespace.identity.apply(identity => identity?.tenantId),
 *     objectId: exampleEventHubNamespace.identity.apply(identity => identity?.principalId),
 *     keyPermissions: [
 *         "Get",
 *         "UnwrapKey",
 *         "WrapKey",
 *     ],
 * });
 * const example2 = new azure.keyvault.AccessPolicy("example2", {
 *     keyVaultId: exampleKeyVault.id,
 *     tenantId: current.then(current => current.tenantId),
 *     objectId: current.then(current => current.objectId),
 *     keyPermissions: [
 *         "Create",
 *         "Delete",
 *         "Get",
 *         "List",
 *         "Purge",
 *         "Recover",
 *         "GetRotationPolicy",
 *     ],
 * });
 * const exampleKey = new azure.keyvault.Key("example", {
 *     name: "examplekvkey",
 *     keyVaultId: exampleKeyVault.id,
 *     keyType: "RSA",
 *     keySize: 2048,
 *     keyOpts: [
 *         "decrypt",
 *         "encrypt",
 *         "sign",
 *         "unwrapKey",
 *         "verify",
 *         "wrapKey",
 *     ],
 * }, {
 *     dependsOn: [
 *         exampleAccessPolicy,
 *         example2,
 *     ],
 * });
 * const exampleNamespaceCustomerManagedKey = new azure.eventhub.NamespaceCustomerManagedKey("example", {
 *     eventhubNamespaceId: exampleEventHubNamespace.id,
 *     keyVaultKeyIds: [exampleKey.id],
 * });
 * ```
 *
 * ### With User Assigned Identity
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleCluster = new azure.eventhub.Cluster("example", {
 *     name: "example-cluster",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     skuName: "Dedicated_1",
 * });
 * const exampleUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("example", {
 *     location: example.location,
 *     name: "example",
 *     resourceGroupName: example.name,
 * });
 * const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("example", {
 *     name: "example-namespace",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "Standard",
 *     dedicatedClusterId: exampleCluster.id,
 *     identity: {
 *         type: "UserAssigned",
 *         identityIds: [exampleUserAssignedIdentity.id],
 *     },
 * });
 * const current = azure.core.getClientConfig({});
 * const exampleKeyVault = new azure.keyvault.KeyVault("example", {
 *     name: "examplekv",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     tenantId: current.then(current => current.tenantId),
 *     skuName: "standard",
 *     purgeProtectionEnabled: true,
 * });
 * const exampleAccessPolicy = new azure.keyvault.AccessPolicy("example", {
 *     keyVaultId: exampleKeyVault.id,
 *     tenantId: test.tenantId,
 *     objectId: test.principalId,
 *     keyPermissions: [
 *         "Get",
 *         "UnwrapKey",
 *         "WrapKey",
 *     ],
 * });
 * const example2 = new azure.keyvault.AccessPolicy("example2", {
 *     keyVaultId: exampleKeyVault.id,
 *     tenantId: current.then(current => current.tenantId),
 *     objectId: current.then(current => current.objectId),
 *     keyPermissions: [
 *         "Create",
 *         "Delete",
 *         "Get",
 *         "List",
 *         "Purge",
 *         "Recover",
 *         "GetRotationPolicy",
 *     ],
 * });
 * const exampleKey = new azure.keyvault.Key("example", {
 *     name: "examplekvkey",
 *     keyVaultId: exampleKeyVault.id,
 *     keyType: "RSA",
 *     keySize: 2048,
 *     keyOpts: [
 *         "decrypt",
 *         "encrypt",
 *         "sign",
 *         "unwrapKey",
 *         "verify",
 *         "wrapKey",
 *     ],
 * }, {
 *     dependsOn: [
 *         exampleAccessPolicy,
 *         example2,
 *     ],
 * });
 * const exampleNamespaceCustomerManagedKey = new azure.eventhub.NamespaceCustomerManagedKey("example", {
 *     eventhubNamespaceId: exampleEventHubNamespace.id,
 *     keyVaultKeyIds: [exampleKey.id],
 *     userAssignedIdentityId: exampleUserAssignedIdentity.id,
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.EventHub` - 2024-01-01
 *
 * ## Import
 *
 * Customer Managed Keys for a EventHub Namespace can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:eventhub/namespaceCustomerManagedKey:NamespaceCustomerManagedKey example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventHub/namespaces/namespace1
 * ```
 */
class NamespaceCustomerManagedKey extends pulumi.CustomResource {
    /**
     * Get an existing NamespaceCustomerManagedKey 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 NamespaceCustomerManagedKey(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:eventhub/namespaceCustomerManagedKey:NamespaceCustomerManagedKey';
    /**
     * Returns true if the given object is an instance of NamespaceCustomerManagedKey.  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'] === NamespaceCustomerManagedKey.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["eventhubNamespaceId"] = state?.eventhubNamespaceId;
            resourceInputs["infrastructureEncryptionEnabled"] = state?.infrastructureEncryptionEnabled;
            resourceInputs["keyVaultKeyIds"] = state?.keyVaultKeyIds;
            resourceInputs["userAssignedIdentityId"] = state?.userAssignedIdentityId;
        }
        else {
            const args = argsOrState;
            if (args?.eventhubNamespaceId === undefined && !opts.urn) {
                throw new Error("Missing required property 'eventhubNamespaceId'");
            }
            if (args?.keyVaultKeyIds === undefined && !opts.urn) {
                throw new Error("Missing required property 'keyVaultKeyIds'");
            }
            resourceInputs["eventhubNamespaceId"] = args?.eventhubNamespaceId;
            resourceInputs["infrastructureEncryptionEnabled"] = args?.infrastructureEncryptionEnabled;
            resourceInputs["keyVaultKeyIds"] = args?.keyVaultKeyIds;
            resourceInputs["userAssignedIdentityId"] = args?.userAssignedIdentityId;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(NamespaceCustomerManagedKey.__pulumiType, name, resourceInputs, opts);
    }
}
exports.NamespaceCustomerManagedKey = NamespaceCustomerManagedKey;
//# sourceMappingURL=namespaceCustomerManagedKey.js.map