UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

224 lines • 8.05 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** 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", * 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", * }], * }); * ``` * * ## 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, Object.assign(Object.assign({}, 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 ? state.apiScope : undefined; resourceInputs["collection"] = state ? state.collection : undefined; resourceInputs["database"] = state ? state.database : undefined; resourceInputs["fields"] = state ? state.fields : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["queryScope"] = state ? state.queryScope : undefined; } else { const args = argsOrState; if ((!args || args.collection === undefined) && !opts.urn) { throw new Error("Missing required property 'collection'"); } if ((!args || args.fields === undefined) && !opts.urn) { throw new Error("Missing required property 'fields'"); } resourceInputs["apiScope"] = args ? args.apiScope : undefined; resourceInputs["collection"] = args ? args.collection : undefined; resourceInputs["database"] = args ? args.database : undefined; resourceInputs["fields"] = args ? args.fields : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["queryScope"] = args ? args.queryScope : undefined; 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