@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
244 lines • 8.59 kB
JavaScript
;
// *** 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.Field = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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__49547",
* 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__48675",
* 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__42702",
* 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 });
}
/** @internal */
static __pulumiType = 'gcp:firestore/field:Field';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["deletionPolicy"] = args?.deletionPolicy;
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;
//# sourceMappingURL=field.js.map