@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
268 lines • 11.6 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.Index = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* An Index defines an approximate nearest-neighbor search structure over a
* field of a Vector Search Collection.
*
* ## Example Usage
*
* ### Vectorsearch Index Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // NOTE: For most workloads we recommend creating the Collection and the Index
* // in *separate* Terraform configurations (i.e. create and apply the Collection
* // first, ingest data via importDataObjects, and only then create the Index in a
* // second configuration). Once an Index exists on a Collection you can no longer
* // run importDataObjects for bulk ingestion of data objects on that Collection --
* // you are limited to creating data objects one at a time or in small online
* // batches. Defining both resources in the same Terraform file (as shown below)
* // is convenient for a quick start, but locks you into the online / batched
* // create path for any subsequent data ingestion.
* const parent = new gcp.vectorsearch.Collection("parent", {
* location: "us-central1",
* collectionId: "example-collection",
* displayName: "My Awesome Collection",
* description: "This collection stores important data.",
* dataSchema: `{
* \\"type\\": \\"object\\",
* \\"properties\\": {
* \\"title\\": {
* \\"type\\": \\"string\\"
* },
* \\"plot\\": {
* \\"type\\": \\"string\\"
* }
* }
* }
* `,
* vectorSchemas: [{
* fieldName: "text_embedding",
* denseVector: {
* dimensions: 768,
* vertexEmbeddingConfig: {
* modelId: "textembedding-gecko@003",
* taskType: "RETRIEVAL_DOCUMENT",
* textTemplate: "Title: {title} ---- Plot: {plot}",
* },
* },
* }],
* });
* const example_index = new gcp.vectorsearch.Index("example-index", {
* location: "us-central1",
* collectionId: parent.collectionId,
* indexId: "example-index",
* displayName: "My Awesome Index",
* description: "ScaNN index over text_embedding.",
* indexField: "text_embedding",
* distanceMetric: "DOT_PRODUCT",
* denseScann: {
* featureNormType: "UNIT_L2_NORM",
* },
* });
* ```
* ### Vectorsearch Index Dedicated
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // NOTE: For most workloads we recommend creating the Collection and the Index
* // in *separate* Terraform configurations (i.e. create and apply the Collection
* // first, ingest data via importDataObjects, and only then create the Index in a
* // second configuration). Once an Index exists on a Collection you can no longer
* // run importDataObjects for bulk ingestion of data objects on that Collection --
* // you are limited to creating data objects one at a time or in small online
* // batches. Defining both resources in the same Terraform file (as shown below)
* // is convenient for a quick start, but locks you into the online / batched
* // create path for any subsequent data ingestion.
* const parent = new gcp.vectorsearch.Collection("parent", {
* location: "us-central1",
* collectionId: "example-dedicated-collection",
* displayName: "My Awesome Collection",
* description: "Parent collection for a dedicated-infrastructure index.",
* dataSchema: `{
* \\"type\\": \\"object\\",
* \\"properties\\": {
* \\"title\\": {
* \\"type\\": \\"string\\"
* },
* \\"category\\": {
* \\"type\\": \\"string\\"
* }
* }
* }
* `,
* vectorSchemas: [{
* fieldName: "text_embedding",
* denseVector: {
* dimensions: 768,
* vertexEmbeddingConfig: {
* modelId: "textembedding-gecko@003",
* taskType: "RETRIEVAL_DOCUMENT",
* textTemplate: "Title: {title}",
* },
* },
* }],
* });
* const example_dedicated_index = new gcp.vectorsearch.Index("example-dedicated-index", {
* location: "us-central1",
* collectionId: parent.collectionId,
* indexId: "example-dedicated-index",
* displayName: "My Dedicated Index",
* description: "Index served on dedicated infrastructure with autoscaling.",
* indexField: "text_embedding",
* distanceMetric: "COSINE_DISTANCE",
* filterFields: ["category"],
* storeFields: ["title"],
* denseScann: {
* featureNormType: "UNIT_L2_NORM",
* },
* dedicatedInfrastructure: {
* mode: "PERFORMANCE_OPTIMIZED",
* autoscalingSpec: {
* minReplicaCount: 2,
* maxReplicaCount: 5,
* },
* },
* });
* ```
*
* ## Import
*
* Index can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/indexes/{{index_id}}`
* * `{{project}}/{{location}}/{{collection_id}}/{{index_id}}`
* * `{{location}}/{{collection_id}}/{{index_id}}`
*
* When using the `pulumi import` command, Index can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:vectorsearch/index:Index default projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/indexes/{{index_id}}
* $ pulumi import gcp:vectorsearch/index:Index default {{project}}/{{location}}/{{collection_id}}/{{index_id}}
* $ pulumi import gcp:vectorsearch/index:Index default {{location}}/{{collection_id}}/{{index_id}}
* ```
*/
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:vectorsearch/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["collectionId"] = state?.collectionId;
resourceInputs["createTime"] = state?.createTime;
resourceInputs["dedicatedInfrastructure"] = state?.dedicatedInfrastructure;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["denseScann"] = state?.denseScann;
resourceInputs["description"] = state?.description;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["distanceMetric"] = state?.distanceMetric;
resourceInputs["effectiveLabels"] = state?.effectiveLabels;
resourceInputs["filterFields"] = state?.filterFields;
resourceInputs["indexField"] = state?.indexField;
resourceInputs["indexId"] = state?.indexId;
resourceInputs["labels"] = state?.labels;
resourceInputs["location"] = state?.location;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["pulumiLabels"] = state?.pulumiLabels;
resourceInputs["storeFields"] = state?.storeFields;
resourceInputs["updateTime"] = state?.updateTime;
}
else {
const args = argsOrState;
if (args?.collectionId === undefined && !opts.urn) {
throw new Error("Missing required property 'collectionId'");
}
if (args?.indexField === undefined && !opts.urn) {
throw new Error("Missing required property 'indexField'");
}
if (args?.indexId === undefined && !opts.urn) {
throw new Error("Missing required property 'indexId'");
}
if (args?.location === undefined && !opts.urn) {
throw new Error("Missing required property 'location'");
}
resourceInputs["collectionId"] = args?.collectionId;
resourceInputs["dedicatedInfrastructure"] = args?.dedicatedInfrastructure;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["denseScann"] = args?.denseScann;
resourceInputs["description"] = args?.description;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["distanceMetric"] = args?.distanceMetric;
resourceInputs["filterFields"] = args?.filterFields;
resourceInputs["indexField"] = args?.indexField;
resourceInputs["indexId"] = args?.indexId;
resourceInputs["labels"] = args?.labels;
resourceInputs["location"] = args?.location;
resourceInputs["project"] = args?.project;
resourceInputs["storeFields"] = args?.storeFields;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["pulumiLabels"] = undefined /*out*/;
resourceInputs["updateTime"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Index.__pulumiType, name, resourceInputs, opts);
}
}
exports.Index = Index;
//# sourceMappingURL=index_.js.map