@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
223 lines • 9.02 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.Document = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* In Cloud Firestore, the unit of storage is the document. A document is a lightweight record
* that contains fields, which map to values. Each document is identified by a name.
*
* To get more information about Document, see:
*
* * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.documents)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/firestore/docs/manage-data/add-data)
*
* > **Warning:** This resource creates a Firestore Document 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 `type` set to
* `"FIRESTORE_NATIVE"` and `locationId` set to your chosen location.
* If you wish to use App Engine, you may instead create a
* `gcp.appengine.Application` resource with `databaseType` set to
* `"CLOUD_FIRESTORE"`. Your Firestore location will be the same as
* the App Engine location specified.
*
* ## Example Usage
*
* ### Firestore Document Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as time from "@pulumiverse/time";
*
* const project = new gcp.organizations.Project("project", {
* projectId: "project-id",
* name: "project-id",
* orgId: "123456789",
* deletionPolicy: "DELETE",
* });
* const wait60Seconds = new time.Sleep("wait_60_seconds", {createDuration: "60s"}, {
* dependsOn: [project],
* });
* const firestore = new gcp.projects.Service("firestore", {
* project: project.projectId,
* service: "firestore.googleapis.com",
* }, {
* dependsOn: [wait60Seconds],
* });
* const database = new gcp.firestore.Database("database", {
* project: project.projectId,
* name: "(default)",
* locationId: "nam5",
* type: "FIRESTORE_NATIVE",
* }, {
* dependsOn: [firestore],
* });
* const mydoc = new gcp.firestore.Document("mydoc", {
* project: project.projectId,
* database: database.name,
* collection: "somenewcollection",
* documentId: "my-doc-id",
* fields: "{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}",
* });
* ```
* ### Firestore Document Nested Document
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as time from "@pulumiverse/time";
*
* const project = new gcp.organizations.Project("project", {
* projectId: "project-id",
* name: "project-id",
* orgId: "123456789",
* deletionPolicy: "DELETE",
* });
* const wait60Seconds = new time.Sleep("wait_60_seconds", {createDuration: "60s"}, {
* dependsOn: [project],
* });
* const firestore = new gcp.projects.Service("firestore", {
* project: project.projectId,
* service: "firestore.googleapis.com",
* }, {
* dependsOn: [wait60Seconds],
* });
* const database = new gcp.firestore.Database("database", {
* project: project.projectId,
* name: "(default)",
* locationId: "nam5",
* type: "FIRESTORE_NATIVE",
* }, {
* dependsOn: [firestore],
* });
* const mydoc = new gcp.firestore.Document("mydoc", {
* project: project.projectId,
* database: database.name,
* collection: "somenewcollection",
* documentId: "my-doc-id",
* fields: "{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}",
* });
* const subDocument = new gcp.firestore.Document("sub_document", {
* project: project.projectId,
* database: database.name,
* collection: pulumi.interpolate`${mydoc.path}/subdocs`,
* documentId: "bitcoinkey",
* fields: "{\"something\":{\"mapValue\":{\"fields\":{\"ayo\":{\"stringValue\":\"val2\"}}}}}",
* });
* const subSubDocument = new gcp.firestore.Document("sub_sub_document", {
* project: project.projectId,
* database: database.name,
* collection: pulumi.interpolate`${subDocument.path}/subsubdocs`,
* documentId: "asecret",
* fields: "{\"something\":{\"mapValue\":{\"fields\":{\"secret\":{\"stringValue\":\"hithere\"}}}}}",
* });
* ```
*
* ## Import
*
* Document can be imported using any of these accepted formats:
*
* * `{{name}}`
*
* When using the `pulumi import` command, Document can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:firestore/document:Document default {{name}}
* ```
*/
class Document extends pulumi.CustomResource {
/**
* Get an existing Document 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 Document(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:firestore/document:Document';
/**
* Returns true if the given object is an instance of Document. 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'] === Document.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["collection"] = state?.collection;
resourceInputs["createTime"] = state?.createTime;
resourceInputs["database"] = state?.database;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["documentId"] = state?.documentId;
resourceInputs["fields"] = state?.fields;
resourceInputs["name"] = state?.name;
resourceInputs["path"] = state?.path;
resourceInputs["project"] = state?.project;
resourceInputs["updateTime"] = state?.updateTime;
}
else {
const args = argsOrState;
if (args?.collection === undefined && !opts.urn) {
throw new Error("Missing required property 'collection'");
}
if (args?.documentId === undefined && !opts.urn) {
throw new Error("Missing required property 'documentId'");
}
if (args?.fields === undefined && !opts.urn) {
throw new Error("Missing required property 'fields'");
}
resourceInputs["collection"] = args?.collection;
resourceInputs["database"] = args?.database;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["documentId"] = args?.documentId;
resourceInputs["fields"] = args?.fields;
resourceInputs["project"] = args?.project;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["path"] = undefined /*out*/;
resourceInputs["updateTime"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Document.__pulumiType, name, resourceInputs, opts);
}
}
exports.Document = Document;
//# sourceMappingURL=document.js.map