@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
219 lines • 7.7 kB
JavaScript
;
// *** 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.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__9106",
* 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__27169",
* 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__75223",
* 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, Object.assign(Object.assign({}, 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 ? state.collection : undefined;
resourceInputs["database"] = state ? state.database : undefined;
resourceInputs["field"] = state ? state.field : undefined;
resourceInputs["indexConfig"] = state ? state.indexConfig : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["ttlConfig"] = state ? state.ttlConfig : undefined;
}
else {
const args = argsOrState;
if ((!args || args.collection === undefined) && !opts.urn) {
throw new Error("Missing required property 'collection'");
}
if ((!args || args.field === undefined) && !opts.urn) {
throw new Error("Missing required property 'field'");
}
resourceInputs["collection"] = args ? args.collection : undefined;
resourceInputs["database"] = args ? args.database : undefined;
resourceInputs["field"] = args ? args.field : undefined;
resourceInputs["indexConfig"] = args ? args.indexConfig : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["ttlConfig"] = args ? args.ttlConfig : undefined;
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