"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.Field = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Represents a single field in the database.
 * Fields are grouped by their "Collection Group", which represent all collections
 * in the database with the same id.
 *
 * To get more information about Field, see:
 *
 * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.fields)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
 *
 * > **Warning:** This resource creates a Firestore Single Field override on a project that
 *  already has a Firestore database. If you haven't already created it, you may
 * create a `gcp.firestore.Database` resource with `locationId` set to your
 * chosen location.
 *
 * ## Example Usage
 *
 * ### Firestore Field 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_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const basic = new gcp.firestore.Field("basic", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "chatrooms__59033",
 *     field: "basic",
 *     indexConfig: {
 *         indexes: [
 *             {
 *                 order: "ASCENDING",
 *                 queryScope: "COLLECTION_GROUP",
 *             },
 *             {
 *                 arrayConfig: "CONTAINS",
 *             },
 *         ],
 *     },
 * });
 * ```
 * ### Firestore Field Timestamp
 *
 * ```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_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const timestamp = new gcp.firestore.Field("timestamp", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "chatrooms",
 *     field: "timestamp",
 *     ttlConfig: {},
 *     indexConfig: {},
 * });
 * ```
 * ### Firestore Field Match Override
 *
 * ```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_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const matchOverride = new gcp.firestore.Field("match_override", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "chatrooms__32081",
 *     field: "field_with_same_configuration_as_ancestor",
 *     indexConfig: {
 *         indexes: [
 *             {
 *                 order: "ASCENDING",
 *             },
 *             {
 *                 order: "DESCENDING",
 *             },
 *             {
 *                 arrayConfig: "CONTAINS",
 *             },
 *         ],
 *     },
 * });
 * ```
 * ### Firestore Field Wildcard
 *
 * ```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_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const wildcard = new gcp.firestore.Field("wildcard", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "chatrooms__10393",
 *     field: "*",
 *     indexConfig: {
 *         indexes: [
 *             {
 *                 order: "ASCENDING",
 *                 queryScope: "COLLECTION_GROUP",
 *             },
 *             {
 *                 arrayConfig: "CONTAINS",
 *             },
 *         ],
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * Field can be imported using any of these accepted formats:
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, Field can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:firestore/field:Field default {{name}}
 * ```
 */
class Field extends pulumi.CustomResource {
    /**
     * Get an existing Field 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 Field(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Field.  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'] === Field.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["collection"] = state?.collection;
            resourceInputs["database"] = state?.database;
            resourceInputs["field"] = state?.field;
            resourceInputs["indexConfig"] = state?.indexConfig;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["ttlConfig"] = state?.ttlConfig;
        }
        else {
            const args = argsOrState;
            if (args?.collection === undefined && !opts.urn) {
                throw new Error("Missing required property 'collection'");
            }
            if (args?.field === undefined && !opts.urn) {
                throw new Error("Missing required property 'field'");
            }
            resourceInputs["collection"] = args?.collection;
            resourceInputs["database"] = args?.database;
            resourceInputs["field"] = args?.field;
            resourceInputs["indexConfig"] = args?.indexConfig;
            resourceInputs["project"] = args?.project;
            resourceInputs["ttlConfig"] = args?.ttlConfig;
            resourceInputs["name"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Field.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Field = Field;
/** @internal */
Field.__pulumiType = 'gcp:firestore/field:Field';
//# sourceMappingURL=field.js.map