@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
211 lines • 9 kB
JavaScript
"use strict";
// *** 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.AiIndex = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A representation of a collection of database items organized in a way that allows for approximate nearest neighbor (a.k.a ANN) algorithms search.
*
* To get more information about Index, see:
*
* * [API documentation](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.indexes/)
*
* ## Example Usage
*
* ### Vertex Ai Index
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bucket = new gcp.storage.Bucket("bucket", {
* name: "vertex-ai-index-test",
* location: "us-central1",
* uniformBucketLevelAccess: true,
* });
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* const data = new gcp.storage.BucketObject("data", {
* name: "contents/data.json",
* bucket: bucket.name,
* content: `{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
* {"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
* `,
* });
* const index = new gcp.vertex.AiIndex("index", {
* labels: {
* foo: "bar",
* },
* region: "us-central1",
* displayName: "test-index",
* description: "index for test",
* metadata: {
* contentsDeltaUri: pulumi.interpolate`gs://${bucket.name}/contents`,
* config: {
* dimensions: 2,
* approximateNeighborsCount: 150,
* shardSize: "SHARD_SIZE_SMALL",
* distanceMeasureType: "DOT_PRODUCT_DISTANCE",
* algorithmConfig: {
* treeAhConfig: {
* leafNodeEmbeddingCount: 500,
* leafNodesToSearchPercent: 7,
* },
* },
* },
* },
* indexUpdateMethod: "BATCH_UPDATE",
* });
* ```
* ### Vertex Ai Index Streaming
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bucket = new gcp.storage.Bucket("bucket", {
* name: "vertex-ai-index-test",
* location: "us-central1",
* uniformBucketLevelAccess: true,
* });
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* const data = new gcp.storage.BucketObject("data", {
* name: "contents/data.json",
* bucket: bucket.name,
* content: `{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
* {"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
* `,
* });
* const index = new gcp.vertex.AiIndex("index", {
* labels: {
* foo: "bar",
* },
* region: "us-central1",
* displayName: "test-index",
* description: "index for test",
* metadata: {
* contentsDeltaUri: pulumi.interpolate`gs://${bucket.name}/contents`,
* config: {
* dimensions: 2,
* shardSize: "SHARD_SIZE_LARGE",
* distanceMeasureType: "COSINE_DISTANCE",
* featureNormType: "UNIT_L2_NORM",
* algorithmConfig: {
* bruteForceConfig: {},
* },
* },
* },
* indexUpdateMethod: "STREAM_UPDATE",
* });
* ```
*
* ## Import
*
* Index can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{region}}/indexes/{{name}}`
*
* * `{{project}}/{{region}}/{{name}}`
*
* * `{{region}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, Index can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:vertex/aiIndex:AiIndex default projects/{{project}}/locations/{{region}}/indexes/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:vertex/aiIndex:AiIndex default {{project}}/{{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:vertex/aiIndex:AiIndex default {{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:vertex/aiIndex:AiIndex default {{name}}
* ```
*/
class AiIndex extends pulumi.CustomResource {
/**
* Get an existing AiIndex 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 AiIndex(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of AiIndex. 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'] === AiIndex.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["createTime"] = state ? state.createTime : undefined;
resourceInputs["deployedIndexes"] = state ? state.deployedIndexes : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined;
resourceInputs["etag"] = state ? state.etag : undefined;
resourceInputs["indexStats"] = state ? state.indexStats : undefined;
resourceInputs["indexUpdateMethod"] = state ? state.indexUpdateMethod : undefined;
resourceInputs["labels"] = state ? state.labels : undefined;
resourceInputs["metadata"] = state ? state.metadata : undefined;
resourceInputs["metadataSchemaUri"] = state ? state.metadataSchemaUri : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["updateTime"] = state ? state.updateTime : undefined;
}
else {
const args = argsOrState;
if ((!args || args.displayName === undefined) && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["indexUpdateMethod"] = args ? args.indexUpdateMethod : undefined;
resourceInputs["labels"] = args ? args.labels : undefined;
resourceInputs["metadata"] = args ? args.metadata : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["deployedIndexes"] = undefined /*out*/;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["etag"] = undefined /*out*/;
resourceInputs["indexStats"] = undefined /*out*/;
resourceInputs["metadataSchemaUri"] = 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(AiIndex.__pulumiType, name, resourceInputs, opts);
}
}
exports.AiIndex = AiIndex;
/** @internal */
AiIndex.__pulumiType = 'gcp:vertex/aiIndex:AiIndex';
//# sourceMappingURL=aiIndex.js.map