@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
493 lines • 16.4 kB
JavaScript
"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! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Index = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Cloud Firestore indexes enable simple and complex queries against documents in a database.
* Firestore Native, Firestore with MongoDB compatibility and Datastore Mode indexes are all 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",
* },
* ],
* });
* ```
* ### Firestore Index Skip Wait
*
* ```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-skip-wait",
* 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",
* },
* ],
* skipWait: true,
* });
* ```
* ### Firestore Index Text Search
*
* ```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: "text-search-database-id",
* 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,
* fields: [{
* fieldPath: "description",
* searchConfig: {
* textSpec: {
* indexSpecs: [{
* indexType: "TOKENIZED",
* matchType: "MATCH_GLOBALLY",
* }],
* },
* },
* }],
* });
* ```
* ### Firestore Index Suppress Geojson Indexing
*
* ```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: "suppress-geojson-indexing-database-id",
* 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",
* queryScope: "COLLECTION_GROUP",
* density: "SPARSE_ANY",
* fields: [{
* fieldPath: "location",
* searchConfig: {
* geoSpec: {
* geoJsonIndexingDisabled: true,
* },
* },
* }],
* });
* ```
* ### Firestore Index Geo Search
*
* ```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: "geo-search-database-id",
* 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,
* fields: [{
* fieldPath: "location",
* searchConfig: {
* geoSpec: {
* geoJsonIndexingDisabled: false,
* },
* },
* }],
* });
* ```
*
* ## 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 });
}
/** @internal */
static __pulumiType = 'gcp:firestore/index:Index';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["skipWait"] = state?.skipWait;
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["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["density"] = args?.density;
resourceInputs["fields"] = args?.fields;
resourceInputs["multikey"] = args?.multikey;
resourceInputs["project"] = args?.project;
resourceInputs["queryScope"] = args?.queryScope;
resourceInputs["skipWait"] = args?.skipWait;
resourceInputs["unique"] = args?.unique;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Index.__pulumiType, name, resourceInputs, opts);
}
}
exports.Index = Index;
//# sourceMappingURL=index_.js.map