"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.Index = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Cloud Firestore indexes enable simple and complex queries against documents in a database.
 *  Both Firestore Native and Datastore Mode indexes are supported.
 *  This resource manages composite indexes and not single field indexes.
 *  To manage single field indexes, use the `gcp.firestore.Field` resource instead.
 *
 * To get more information about Index, see:
 *
 * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.indexes)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
 *
 * > **Warning:** This resource creates a Firestore Index on a project that already has
 * a Firestore database. If you haven't already created it, you may
 * create a `gcp.firestore.Database` resource and `locationId` set
 * to your chosen location. If you wish to use App Engine, you may
 * instead create a `gcp.appengine.Application` resource.
 * Your Firestore location will be the same as the App Engine location specified.
 *
 * ## Example Usage
 *
 * ### Firestore Index Basic
 *
 * ```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",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ### Firestore Index Datastore Mode
 *
 * ```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-dm",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     queryScope: "COLLECTION_RECURSIVE",
 *     apiScope: "DATASTORE_MODE_API",
 *     density: "SPARSE_ALL",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ### Firestore Index Vector
 *
 * ```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-vector",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     fields: [
 *         {
 *             fieldPath: "field_name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "__name__",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             vectorConfig: {
 *                 dimension: 128,
 *                 flat: {},
 *             },
 *         },
 *     ],
 * });
 * ```
 * ### Firestore Index Name Descending
 *
 * ```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",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     fields: [{
 *         fieldPath: "__name__",
 *         order: "DESCENDING",
 *     }],
 * });
 * ```
 * ### Firestore Index Mongodb Compatible Scope
 *
 * ```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-mongodb-compatible",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     databaseEdition: "ENTERPRISE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     apiScope: "MONGODB_COMPATIBLE_API",
 *     queryScope: "COLLECTION_GROUP",
 *     multikey: true,
 *     density: "DENSE",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ### Firestore Index Sparse Any
 *
 * ```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-sparse-any",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     databaseEdition: "ENTERPRISE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     apiScope: "MONGODB_COMPATIBLE_API",
 *     queryScope: "COLLECTION_GROUP",
 *     multikey: true,
 *     density: "SPARSE_ANY",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ### Firestore Index Unique
 *
 * ```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-unique",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     databaseEdition: "ENTERPRISE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     apiScope: "MONGODB_COMPATIBLE_API",
 *     queryScope: "COLLECTION_GROUP",
 *     multikey: true,
 *     density: "DENSE",
 *     unique: true,
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 *
 * ## Import
 *
 * Index can be imported using any of these accepted formats:
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, Index can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:firestore/index:Index default {{name}}
 * ```
 */
class Index extends pulumi.CustomResource {
    /**
     * Get an existing Index 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 Index(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Index.  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'] === Index.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["apiScope"] = state?.apiScope;
            resourceInputs["collection"] = state?.collection;
            resourceInputs["database"] = state?.database;
            resourceInputs["density"] = state?.density;
            resourceInputs["fields"] = state?.fields;
            resourceInputs["multikey"] = state?.multikey;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["queryScope"] = state?.queryScope;
            resourceInputs["unique"] = state?.unique;
        }
        else {
            const args = argsOrState;
            if (args?.collection === undefined && !opts.urn) {
                throw new Error("Missing required property 'collection'");
            }
            if (args?.fields === undefined && !opts.urn) {
                throw new Error("Missing required property 'fields'");
            }
            resourceInputs["apiScope"] = args?.apiScope;
            resourceInputs["collection"] = args?.collection;
            resourceInputs["database"] = args?.database;
            resourceInputs["density"] = args?.density;
            resourceInputs["fields"] = args?.fields;
            resourceInputs["multikey"] = args?.multikey;
            resourceInputs["project"] = args?.project;
            resourceInputs["queryScope"] = args?.queryScope;
            resourceInputs["unique"] = args?.unique;
            resourceInputs["name"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Index.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Index = Index;
/** @internal */
Index.__pulumiType = 'gcp:firestore/index:Index';
//# sourceMappingURL=index_.js.map