"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.Database = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A Cloud Spanner Database which is hosted on a Spanner instance.
 *
 * To get more information about Database, see:
 *
 * * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/spanner/)
 *
 * > **Warning:** On newer versions of the provider, you must explicitly set `deletion_protection=false`
 * (and run `pulumi up` to write the field to state) in order to destroy an instance.
 * It is recommended to not set this field (or set it to true) until you're ready to destroy.
 * On older versions, it is strongly recommended to set `lifecycle { preventDestroy = true }`
 * on databases in order to prevent accidental data loss.
 *
 * ## Example Usage
 *
 * ### Spanner Database Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const main = new gcp.spanner.Instance("main", {
 *     config: "regional-europe-west1",
 *     displayName: "main-instance",
 *     numNodes: 1,
 * });
 * const database = new gcp.spanner.Database("database", {
 *     instance: main.name,
 *     name: "my-database",
 *     versionRetentionPeriod: "3d",
 *     defaultTimeZone: "UTC",
 *     ddls: [
 *         "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
 *         "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
 *     ],
 *     deletionProtection: false,
 * });
 * ```
 *
 * ## Import
 *
 * Database can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/instances/{{instance}}/databases/{{name}}`
 *
 * * `instances/{{instance}}/databases/{{name}}`
 *
 * * `{{project}}/{{instance}}/{{name}}`
 *
 * * `{{instance}}/{{name}}`
 *
 * When using the `pulumi import` command, Database can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:spanner/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:spanner/database:Database default instances/{{instance}}/databases/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:spanner/database:Database default {{project}}/{{instance}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:spanner/database:Database default {{instance}}/{{name}}
 * ```
 */
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 });
    }
    /**
     * 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["databaseDialect"] = state?.databaseDialect;
            resourceInputs["ddls"] = state?.ddls;
            resourceInputs["defaultTimeZone"] = state?.defaultTimeZone;
            resourceInputs["deletionProtection"] = state?.deletionProtection;
            resourceInputs["enableDropProtection"] = state?.enableDropProtection;
            resourceInputs["encryptionConfig"] = state?.encryptionConfig;
            resourceInputs["instance"] = state?.instance;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["state"] = state?.state;
            resourceInputs["versionRetentionPeriod"] = state?.versionRetentionPeriod;
        }
        else {
            const args = argsOrState;
            if (args?.instance === undefined && !opts.urn) {
                throw new Error("Missing required property 'instance'");
            }
            resourceInputs["databaseDialect"] = args?.databaseDialect;
            resourceInputs["ddls"] = args?.ddls;
            resourceInputs["defaultTimeZone"] = args?.defaultTimeZone;
            resourceInputs["deletionProtection"] = args?.deletionProtection;
            resourceInputs["enableDropProtection"] = args?.enableDropProtection;
            resourceInputs["encryptionConfig"] = args?.encryptionConfig;
            resourceInputs["instance"] = args?.instance;
            resourceInputs["name"] = args?.name;
            resourceInputs["project"] = args?.project;
            resourceInputs["versionRetentionPeriod"] = args?.versionRetentionPeriod;
            resourceInputs["state"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Database.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Database = Database;
/** @internal */
Database.__pulumiType = 'gcp:spanner/database:Database';
//# sourceMappingURL=database.js.map