"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.Database = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages a MS SQL Database.
 *
 * !> **Note:** To mitigate the possibility of accidental data loss it is highly recommended that you use the `preventDestroy` lifecycle argument in your configuration file for this resource. For more information on the `preventDestroy` lifecycle argument please see the terraform documentation.
 *
 * ## Example Usage
 *
 * ```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 exampleServer = new azure.mssql.Server("example", {
 *     name: "example-sqlserver",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     version: "12.0",
 *     administratorLogin: "4dm1n157r470r",
 *     administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
 * });
 * const exampleDatabase = new azure.mssql.Database("example", {
 *     name: "example-db",
 *     serverId: exampleServer.id,
 *     collation: "SQL_Latin1_General_CP1_CI_AS",
 *     licenseType: "LicenseIncluded",
 *     maxSizeGb: 2,
 *     skuName: "S0",
 *     enclaveType: "VBS",
 *     tags: {
 *         foo: "bar",
 *     },
 * });
 * ```
 *
 * ### Transparent Data Encryption(TDE) With A Customer Managed Key(CMK) During Create
 * ```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 exampleUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("example", {
 *     name: "example-admin",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "examplesa",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 * });
 * const exampleServer = new azure.mssql.Server("example", {
 *     name: "example-sqlserver",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     version: "12.0",
 *     administratorLogin: "4dm1n157r470r",
 *     administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
 * });
 * // Create a key vault with access policies which allow for the current user to get, list, create, delete, update, recover, purge and getRotationPolicy for the key vault key and also add a key vault access policy for the Microsoft Sql Server instance User Managed Identity to get, wrap, and unwrap key(s)
 * const exampleKeyVault = new azure.keyvault.KeyVault("example", {
 *     name: "mssqltdeexample",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     enabledForDiskEncryption: true,
 *     tenantId: exampleUserAssignedIdentity.tenantId,
 *     softDeleteRetentionDays: 7,
 *     purgeProtectionEnabled: true,
 *     skuName: "standard",
 *     accessPolicies: [
 *         {
 *             tenantId: current.tenantId,
 *             objectId: current.objectId,
 *             keyPermissions: [
 *                 "Get",
 *                 "List",
 *                 "Create",
 *                 "Delete",
 *                 "Update",
 *                 "Recover",
 *                 "Purge",
 *                 "GetRotationPolicy",
 *             ],
 *         },
 *         {
 *             tenantId: exampleUserAssignedIdentity.tenantId,
 *             objectId: exampleUserAssignedIdentity.principalId,
 *             keyPermissions: [
 *                 "Get",
 *                 "WrapKey",
 *                 "UnwrapKey",
 *             ],
 *         },
 *     ],
 * });
 * const exampleKey = new azure.keyvault.Key("example", {
 *     name: "example-key",
 *     keyVaultId: exampleKeyVault.id,
 *     keyType: "RSA",
 *     keySize: 2048,
 *     keyOpts: [
 *         "unwrapKey",
 *         "wrapKey",
 *     ],
 * }, {
 *     dependsOn: [exampleKeyVault],
 * });
 * const exampleDatabase = new azure.mssql.Database("example", {
 *     name: "example-db",
 *     serverId: exampleServer.id,
 *     collation: "SQL_Latin1_General_CP1_CI_AS",
 *     licenseType: "LicenseIncluded",
 *     maxSizeGb: 4,
 *     readScale: true,
 *     skuName: "S0",
 *     zoneRedundant: true,
 *     enclaveType: "VBS",
 *     tags: {
 *         foo: "bar",
 *     },
 *     identity: {
 *         type: "UserAssigned",
 *         identityIds: [exampleUserAssignedIdentity.id],
 *     },
 *     transparentDataEncryptionKeyVaultKeyId: exampleKey.id,
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Sql` - 2023-08-01-preview
 *
 * ## Import
 *
 * SQL Database can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:mssql/database:Database example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/example1
 * ```
 */
class Database extends pulumi.CustomResource {
    /**
     * Get an existing Database 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 Database(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:mssql/database:Database';
    /**
     * Returns true if the given object is an instance of Database.  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'] === Database.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["autoPauseDelayInMinutes"] = state?.autoPauseDelayInMinutes;
            resourceInputs["collation"] = state?.collation;
            resourceInputs["createMode"] = state?.createMode;
            resourceInputs["creationSourceDatabaseId"] = state?.creationSourceDatabaseId;
            resourceInputs["elasticPoolId"] = state?.elasticPoolId;
            resourceInputs["enclaveType"] = state?.enclaveType;
            resourceInputs["geoBackupEnabled"] = state?.geoBackupEnabled;
            resourceInputs["identity"] = state?.identity;
            resourceInputs["import"] = state?.import;
            resourceInputs["ledgerEnabled"] = state?.ledgerEnabled;
            resourceInputs["licenseType"] = state?.licenseType;
            resourceInputs["longTermRetentionPolicy"] = state?.longTermRetentionPolicy;
            resourceInputs["maintenanceConfigurationName"] = state?.maintenanceConfigurationName;
            resourceInputs["maxSizeGb"] = state?.maxSizeGb;
            resourceInputs["minCapacity"] = state?.minCapacity;
            resourceInputs["name"] = state?.name;
            resourceInputs["readReplicaCount"] = state?.readReplicaCount;
            resourceInputs["readScale"] = state?.readScale;
            resourceInputs["recoverDatabaseId"] = state?.recoverDatabaseId;
            resourceInputs["recoveryPointId"] = state?.recoveryPointId;
            resourceInputs["restoreDroppedDatabaseId"] = state?.restoreDroppedDatabaseId;
            resourceInputs["restoreLongTermRetentionBackupId"] = state?.restoreLongTermRetentionBackupId;
            resourceInputs["restorePointInTime"] = state?.restorePointInTime;
            resourceInputs["sampleName"] = state?.sampleName;
            resourceInputs["secondaryType"] = state?.secondaryType;
            resourceInputs["serverId"] = state?.serverId;
            resourceInputs["shortTermRetentionPolicy"] = state?.shortTermRetentionPolicy;
            resourceInputs["skuName"] = state?.skuName;
            resourceInputs["storageAccountType"] = state?.storageAccountType;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["threatDetectionPolicy"] = state?.threatDetectionPolicy;
            resourceInputs["transparentDataEncryptionEnabled"] = state?.transparentDataEncryptionEnabled;
            resourceInputs["transparentDataEncryptionKeyAutomaticRotationEnabled"] = state?.transparentDataEncryptionKeyAutomaticRotationEnabled;
            resourceInputs["transparentDataEncryptionKeyVaultKeyId"] = state?.transparentDataEncryptionKeyVaultKeyId;
            resourceInputs["zoneRedundant"] = state?.zoneRedundant;
        }
        else {
            const args = argsOrState;
            if (args?.serverId === undefined && !opts.urn) {
                throw new Error("Missing required property 'serverId'");
            }
            resourceInputs["autoPauseDelayInMinutes"] = args?.autoPauseDelayInMinutes;
            resourceInputs["collation"] = args?.collation;
            resourceInputs["createMode"] = args?.createMode;
            resourceInputs["creationSourceDatabaseId"] = args?.creationSourceDatabaseId;
            resourceInputs["elasticPoolId"] = args?.elasticPoolId;
            resourceInputs["enclaveType"] = args?.enclaveType;
            resourceInputs["geoBackupEnabled"] = args?.geoBackupEnabled;
            resourceInputs["identity"] = args?.identity;
            resourceInputs["import"] = args?.import;
            resourceInputs["ledgerEnabled"] = args?.ledgerEnabled;
            resourceInputs["licenseType"] = args?.licenseType;
            resourceInputs["longTermRetentionPolicy"] = args?.longTermRetentionPolicy;
            resourceInputs["maintenanceConfigurationName"] = args?.maintenanceConfigurationName;
            resourceInputs["maxSizeGb"] = args?.maxSizeGb;
            resourceInputs["minCapacity"] = args?.minCapacity;
            resourceInputs["name"] = args?.name;
            resourceInputs["readReplicaCount"] = args?.readReplicaCount;
            resourceInputs["readScale"] = args?.readScale;
            resourceInputs["recoverDatabaseId"] = args?.recoverDatabaseId;
            resourceInputs["recoveryPointId"] = args?.recoveryPointId;
            resourceInputs["restoreDroppedDatabaseId"] = args?.restoreDroppedDatabaseId;
            resourceInputs["restoreLongTermRetentionBackupId"] = args?.restoreLongTermRetentionBackupId;
            resourceInputs["restorePointInTime"] = args?.restorePointInTime;
            resourceInputs["sampleName"] = args?.sampleName;
            resourceInputs["secondaryType"] = args?.secondaryType;
            resourceInputs["serverId"] = args?.serverId;
            resourceInputs["shortTermRetentionPolicy"] = args?.shortTermRetentionPolicy;
            resourceInputs["skuName"] = args?.skuName;
            resourceInputs["storageAccountType"] = args?.storageAccountType;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["threatDetectionPolicy"] = args?.threatDetectionPolicy;
            resourceInputs["transparentDataEncryptionEnabled"] = args?.transparentDataEncryptionEnabled;
            resourceInputs["transparentDataEncryptionKeyAutomaticRotationEnabled"] = args?.transparentDataEncryptionKeyAutomaticRotationEnabled;
            resourceInputs["transparentDataEncryptionKeyVaultKeyId"] = args?.transparentDataEncryptionKeyVaultKeyId;
            resourceInputs["zoneRedundant"] = args?.zoneRedundant;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const aliasOpts = { aliases: [{ type: "azure:sql/database:Database" }] };
        opts = pulumi.mergeOptions(opts, aliasOpts);
        super(Database.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Database = Database;
//# sourceMappingURL=database.js.map