"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 Firestore Database.
 *
 * If you wish to use Firestore with App Engine, use the
 * `gcp.appengine.Application`
 * resource instead. If you were previously using the `gcp.appengine.Application` resource exclusively for managing a Firestore database
 * and would like to use the `gcp.firestore.Database` resource instead, please follow the instructions
 * [here](https://cloud.google.com/firestore/docs/app-engine-requirement).
 *
 * To get more information about Database, see:
 *
 * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/firestore/docs/)
 *
 * ## Example Usage
 *
 * ### Firestore Default Database
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "(default)",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 * });
 * ```
 * ### Firestore Database
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "database-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     concurrencyMode: "OPTIMISTIC",
 *     appEngineIntegrationMode: "DISABLED",
 *     pointInTimeRecoveryEnablement: "POINT_IN_TIME_RECOVERY_ENABLED",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * ```
 * ### Firestore Database With Tags
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "database-with-tags-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 *     tags: {
 *         keyname: "valuename",
 *     },
 * });
 * ```
 * ### Firestore Cmek Database
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const project = gcp.organizations.getProject({});
 * const keyRing = new gcp.kms.KeyRing("key_ring", {
 *     name: "kms-key-ring",
 *     location: "us",
 * });
 * const cryptoKey = new gcp.kms.CryptoKey("crypto_key", {
 *     name: "kms-key",
 *     keyRing: keyRing.id,
 *     purpose: "ENCRYPT_DECRYPT",
 * });
 * const firestoreCmekKeyuser = new gcp.kms.CryptoKeyIAMBinding("firestore_cmek_keyuser", {
 *     cryptoKeyId: cryptoKey.id,
 *     role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     members: [project.then(project => `serviceAccount:service-${project.number}@gcp-sa-firestore.iam.gserviceaccount.com`)],
 * });
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "cmek-database-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     concurrencyMode: "OPTIMISTIC",
 *     appEngineIntegrationMode: "DISABLED",
 *     pointInTimeRecoveryEnablement: "POINT_IN_TIME_RECOVERY_ENABLED",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 *     cmekConfig: {
 *         kmsKeyName: cryptoKey.id,
 *     },
 * }, {
 *     dependsOn: [firestoreCmekKeyuser],
 * });
 * ```
 * ### Firestore Default Database In Datastore Mode
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const datastoreModeDatabase = new gcp.firestore.Database("datastore_mode_database", {
 *     project: "my-project-name",
 *     name: "(default)",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 * });
 * ```
 * ### Firestore Database In Datastore Mode
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const datastoreModeDatabase = new gcp.firestore.Database("datastore_mode_database", {
 *     project: "my-project-name",
 *     name: "database-id",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 *     concurrencyMode: "OPTIMISTIC",
 *     appEngineIntegrationMode: "DISABLED",
 *     pointInTimeRecoveryEnablement: "POINT_IN_TIME_RECOVERY_ENABLED",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * ```
 * ### Firestore Cmek Database In Datastore Mode
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const project = gcp.organizations.getProject({});
 * const keyRing = new gcp.kms.KeyRing("key_ring", {
 *     name: "kms-key-ring",
 *     location: "us",
 * });
 * const cryptoKey = new gcp.kms.CryptoKey("crypto_key", {
 *     name: "kms-key",
 *     keyRing: keyRing.id,
 *     purpose: "ENCRYPT_DECRYPT",
 * });
 * const firestoreCmekKeyuser = new gcp.kms.CryptoKeyIAMBinding("firestore_cmek_keyuser", {
 *     cryptoKeyId: cryptoKey.id,
 *     role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     members: [project.then(project => `serviceAccount:service-${project.number}@gcp-sa-firestore.iam.gserviceaccount.com`)],
 * });
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "cmek-database-id",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 *     concurrencyMode: "OPTIMISTIC",
 *     appEngineIntegrationMode: "DISABLED",
 *     pointInTimeRecoveryEnablement: "POINT_IN_TIME_RECOVERY_ENABLED",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 *     cmekConfig: {
 *         kmsKeyName: cryptoKey.id,
 *     },
 * }, {
 *     dependsOn: [firestoreCmekKeyuser],
 * });
 * ```
 * ### Firestore Database Enterprise
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const enterprise_db = new gcp.firestore.Database("enterprise-db", {
 *     project: "my-project-name",
 *     name: "database-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     databaseEdition: "ENTERPRISE",
 *     deletionPolicy: "DELETE",
 * });
 * ```
 *
 * ## Import
 *
 * Database can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/databases/{{name}}`
 *
 * * `{{project}}/{{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, Database can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:firestore/database:Database default projects/{{project}}/databases/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:firestore/database:Database default {{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:firestore/database:Database default {{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["appEngineIntegrationMode"] = state?.appEngineIntegrationMode;
            resourceInputs["cmekConfig"] = state?.cmekConfig;
            resourceInputs["concurrencyMode"] = state?.concurrencyMode;
            resourceInputs["createTime"] = state?.createTime;
            resourceInputs["databaseEdition"] = state?.databaseEdition;
            resourceInputs["deleteProtectionState"] = state?.deleteProtectionState;
            resourceInputs["deletionPolicy"] = state?.deletionPolicy;
            resourceInputs["earliestVersionTime"] = state?.earliestVersionTime;
            resourceInputs["etag"] = state?.etag;
            resourceInputs["keyPrefix"] = state?.keyPrefix;
            resourceInputs["locationId"] = state?.locationId;
            resourceInputs["name"] = state?.name;
            resourceInputs["pointInTimeRecoveryEnablement"] = state?.pointInTimeRecoveryEnablement;
            resourceInputs["project"] = state?.project;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["type"] = state?.type;
            resourceInputs["uid"] = state?.uid;
            resourceInputs["updateTime"] = state?.updateTime;
            resourceInputs["versionRetentionPeriod"] = state?.versionRetentionPeriod;
        }
        else {
            const args = argsOrState;
            if (args?.locationId === undefined && !opts.urn) {
                throw new Error("Missing required property 'locationId'");
            }
            if (args?.type === undefined && !opts.urn) {
                throw new Error("Missing required property 'type'");
            }
            resourceInputs["appEngineIntegrationMode"] = args?.appEngineIntegrationMode;
            resourceInputs["cmekConfig"] = args?.cmekConfig;
            resourceInputs["concurrencyMode"] = args?.concurrencyMode;
            resourceInputs["databaseEdition"] = args?.databaseEdition;
            resourceInputs["deleteProtectionState"] = args?.deleteProtectionState;
            resourceInputs["deletionPolicy"] = args?.deletionPolicy;
            resourceInputs["locationId"] = args?.locationId;
            resourceInputs["name"] = args?.name;
            resourceInputs["pointInTimeRecoveryEnablement"] = args?.pointInTimeRecoveryEnablement;
            resourceInputs["project"] = args?.project;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["type"] = args?.type;
            resourceInputs["createTime"] = undefined /*out*/;
            resourceInputs["earliestVersionTime"] = undefined /*out*/;
            resourceInputs["etag"] = undefined /*out*/;
            resourceInputs["keyPrefix"] = undefined /*out*/;
            resourceInputs["uid"] = undefined /*out*/;
            resourceInputs["updateTime"] = undefined /*out*/;
            resourceInputs["versionRetentionPeriod"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Database.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Database = Database;
/** @internal */
Database.__pulumiType = 'gcp:firestore/database:Database';
//# sourceMappingURL=database.js.map