Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.vertex.kotlin.AiIndex.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.vertex.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexDeployedIndex
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexIndexStat
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexMetadata
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexDeployedIndex.Companion.toKotlin as aiIndexDeployedIndexToKotlin
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexIndexStat.Companion.toKotlin as aiIndexIndexStatToKotlin
import com.pulumi.gcp.vertex.kotlin.outputs.AiIndexMetadata.Companion.toKotlin as aiIndexMetadataToKotlin
/**
* Builder for [AiIndex].
*/
@PulumiTagMarker
public class AiIndexResourceBuilder internal constructor() {
public var name: String? = null
public var args: AiIndexArgs = AiIndexArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend AiIndexArgsBuilder.() -> Unit) {
val builder = AiIndexArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): AiIndex {
val builtJavaResource = com.pulumi.gcp.vertex.AiIndex(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return AiIndex(builtJavaResource)
}
}
/**
* 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",
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* bucket = gcp.storage.Bucket("bucket",
* name="vertex-ai-index-test",
* location="us-central1",
* uniform_bucket_level_access=True)
* # The sample data comes from the following link:
* # https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* data = 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"]}]}
* """)
* index = gcp.vertex.AiIndex("index",
* labels={
* "foo": "bar",
* },
* region="us-central1",
* display_name="test-index",
* description="index for test",
* metadata={
* "contents_delta_uri": bucket.name.apply(lambda name: f"gs://{name}/contents"),
* "config": {
* "dimensions": 2,
* "approximate_neighbors_count": 150,
* "shard_size": "SHARD_SIZE_SMALL",
* "distance_measure_type": "DOT_PRODUCT_DISTANCE",
* "algorithm_config": {
* "tree_ah_config": {
* "leaf_node_embedding_count": 500,
* "leaf_nodes_to_search_percent": 7,
* },
* },
* },
* },
* index_update_method="BATCH_UPDATE")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var bucket = new Gcp.Storage.Bucket("bucket", new()
* {
* 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
* var data = new Gcp.Storage.BucketObject("data", new()
* {
* 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""]}]}
* ",
* });
* var index = new Gcp.Vertex.AiIndex("index", new()
* {
* Labels =
* {
* { "foo", "bar" },
* },
* Region = "us-central1",
* DisplayName = "test-index",
* Description = "index for test",
* Metadata = new Gcp.Vertex.Inputs.AiIndexMetadataArgs
* {
* ContentsDeltaUri = bucket.Name.Apply(name => $"gs://{name}/contents"),
* Config = new Gcp.Vertex.Inputs.AiIndexMetadataConfigArgs
* {
* Dimensions = 2,
* ApproximateNeighborsCount = 150,
* ShardSize = "SHARD_SIZE_SMALL",
* DistanceMeasureType = "DOT_PRODUCT_DISTANCE",
* AlgorithmConfig = new Gcp.Vertex.Inputs.AiIndexMetadataConfigAlgorithmConfigArgs
* {
* TreeAhConfig = new Gcp.Vertex.Inputs.AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs
* {
* LeafNodeEmbeddingCount = 500,
* LeafNodesToSearchPercent = 7,
* },
* },
* },
* },
* IndexUpdateMethod = "BATCH_UPDATE",
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vertex"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
* Name: pulumi.String("vertex-ai-index-test"),
* Location: pulumi.String("us-central1"),
* UniformBucketLevelAccess: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* _, err = storage.NewBucketObject(ctx, "data", &storage.BucketObjectArgs{
* Name: pulumi.String("contents/data.json"),
* Bucket: bucket.Name,
* Content: pulumi.String("{\"id\": \"42\", \"embedding\": [0.5, 1.0], \"restricts\": [{\"namespace\": \"class\", \"allow\": [\"cat\", \"pet\"]},{\"namespace\": \"category\", \"allow\": [\"feline\"]}]}\n{\"id\": \"43\", \"embedding\": [0.6, 1.0], \"restricts\": [{\"namespace\": \"class\", \"allow\": [\"dog\", \"pet\"]},{\"namespace\": \"category\", \"allow\": [\"canine\"]}]}\n"),
* })
* if err != nil {
* return err
* }
* _, err = vertex.NewAiIndex(ctx, "index", &vertex.AiIndexArgs{
* Labels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* Region: pulumi.String("us-central1"),
* DisplayName: pulumi.String("test-index"),
* Description: pulumi.String("index for test"),
* Metadata: &vertex.AiIndexMetadataArgs{
* ContentsDeltaUri: bucket.Name.ApplyT(func(name string) (string, error) {
* return fmt.Sprintf("gs://%v/contents", name), nil
* }).(pulumi.StringOutput),
* Config: &vertex.AiIndexMetadataConfigArgs{
* Dimensions: pulumi.Int(2),
* ApproximateNeighborsCount: pulumi.Int(150),
* ShardSize: pulumi.String("SHARD_SIZE_SMALL"),
* DistanceMeasureType: pulumi.String("DOT_PRODUCT_DISTANCE"),
* AlgorithmConfig: &vertex.AiIndexMetadataConfigAlgorithmConfigArgs{
* TreeAhConfig: &vertex.AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs{
* LeafNodeEmbeddingCount: pulumi.Int(500),
* LeafNodesToSearchPercent: pulumi.Int(7),
* },
* },
* },
* },
* IndexUpdateMethod: pulumi.String("BATCH_UPDATE"),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.storage.Bucket;
* import com.pulumi.gcp.storage.BucketArgs;
* import com.pulumi.gcp.storage.BucketObject;
* import com.pulumi.gcp.storage.BucketObjectArgs;
* import com.pulumi.gcp.vertex.AiIndex;
* import com.pulumi.gcp.vertex.AiIndexArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var bucket = new Bucket("bucket", BucketArgs.builder()
* .name("vertex-ai-index-test")
* .location("us-central1")
* .uniformBucketLevelAccess(true)
* .build());
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* var data = new BucketObject("data", BucketObjectArgs.builder()
* .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"]}]}
* """)
* .build());
* var index = new AiIndex("index", AiIndexArgs.builder()
* .labels(Map.of("foo", "bar"))
* .region("us-central1")
* .displayName("test-index")
* .description("index for test")
* .metadata(AiIndexMetadataArgs.builder()
* .contentsDeltaUri(bucket.name().applyValue(name -> String.format("gs://%s/contents", name)))
* .config(AiIndexMetadataConfigArgs.builder()
* .dimensions(2)
* .approximateNeighborsCount(150)
* .shardSize("SHARD_SIZE_SMALL")
* .distanceMeasureType("DOT_PRODUCT_DISTANCE")
* .algorithmConfig(AiIndexMetadataConfigAlgorithmConfigArgs.builder()
* .treeAhConfig(AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs.builder()
* .leafNodeEmbeddingCount(500)
* .leafNodesToSearchPercent(7)
* .build())
* .build())
* .build())
* .build())
* .indexUpdateMethod("BATCH_UPDATE")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* bucket:
* type: gcp:storage:Bucket
* properties:
* 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
* data:
* type: gcp:storage:BucketObject
* properties:
* 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"]}]}
* index:
* type: gcp:vertex:AiIndex
* properties:
* labels:
* foo: bar
* region: us-central1
* displayName: test-index
* description: index for test
* metadata:
* contentsDeltaUri: 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",
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* bucket = gcp.storage.Bucket("bucket",
* name="vertex-ai-index-test",
* location="us-central1",
* uniform_bucket_level_access=True)
* # The sample data comes from the following link:
* # https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* data = 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"]}]}
* """)
* index = gcp.vertex.AiIndex("index",
* labels={
* "foo": "bar",
* },
* region="us-central1",
* display_name="test-index",
* description="index for test",
* metadata={
* "contents_delta_uri": bucket.name.apply(lambda name: f"gs://{name}/contents"),
* "config": {
* "dimensions": 2,
* "shard_size": "SHARD_SIZE_LARGE",
* "distance_measure_type": "COSINE_DISTANCE",
* "feature_norm_type": "UNIT_L2_NORM",
* "algorithm_config": {
* "brute_force_config": {},
* },
* },
* },
* index_update_method="STREAM_UPDATE")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var bucket = new Gcp.Storage.Bucket("bucket", new()
* {
* 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
* var data = new Gcp.Storage.BucketObject("data", new()
* {
* 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""]}]}
* ",
* });
* var index = new Gcp.Vertex.AiIndex("index", new()
* {
* Labels =
* {
* { "foo", "bar" },
* },
* Region = "us-central1",
* DisplayName = "test-index",
* Description = "index for test",
* Metadata = new Gcp.Vertex.Inputs.AiIndexMetadataArgs
* {
* ContentsDeltaUri = bucket.Name.Apply(name => $"gs://{name}/contents"),
* Config = new Gcp.Vertex.Inputs.AiIndexMetadataConfigArgs
* {
* Dimensions = 2,
* ShardSize = "SHARD_SIZE_LARGE",
* DistanceMeasureType = "COSINE_DISTANCE",
* FeatureNormType = "UNIT_L2_NORM",
* AlgorithmConfig = new Gcp.Vertex.Inputs.AiIndexMetadataConfigAlgorithmConfigArgs
* {
* BruteForceConfig = null,
* },
* },
* },
* IndexUpdateMethod = "STREAM_UPDATE",
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vertex"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
* Name: pulumi.String("vertex-ai-index-test"),
* Location: pulumi.String("us-central1"),
* UniformBucketLevelAccess: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* _, err = storage.NewBucketObject(ctx, "data", &storage.BucketObjectArgs{
* Name: pulumi.String("contents/data.json"),
* Bucket: bucket.Name,
* Content: pulumi.String("{\"id\": \"42\", \"embedding\": [0.5, 1.0], \"restricts\": [{\"namespace\": \"class\", \"allow\": [\"cat\", \"pet\"]},{\"namespace\": \"category\", \"allow\": [\"feline\"]}]}\n{\"id\": \"43\", \"embedding\": [0.6, 1.0], \"restricts\": [{\"namespace\": \"class\", \"allow\": [\"dog\", \"pet\"]},{\"namespace\": \"category\", \"allow\": [\"canine\"]}]}\n"),
* })
* if err != nil {
* return err
* }
* _, err = vertex.NewAiIndex(ctx, "index", &vertex.AiIndexArgs{
* Labels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* Region: pulumi.String("us-central1"),
* DisplayName: pulumi.String("test-index"),
* Description: pulumi.String("index for test"),
* Metadata: &vertex.AiIndexMetadataArgs{
* ContentsDeltaUri: bucket.Name.ApplyT(func(name string) (string, error) {
* return fmt.Sprintf("gs://%v/contents", name), nil
* }).(pulumi.StringOutput),
* Config: &vertex.AiIndexMetadataConfigArgs{
* Dimensions: pulumi.Int(2),
* ShardSize: pulumi.String("SHARD_SIZE_LARGE"),
* DistanceMeasureType: pulumi.String("COSINE_DISTANCE"),
* FeatureNormType: pulumi.String("UNIT_L2_NORM"),
* AlgorithmConfig: &vertex.AiIndexMetadataConfigAlgorithmConfigArgs{
* BruteForceConfig: nil,
* },
* },
* },
* IndexUpdateMethod: pulumi.String("STREAM_UPDATE"),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.storage.Bucket;
* import com.pulumi.gcp.storage.BucketArgs;
* import com.pulumi.gcp.storage.BucketObject;
* import com.pulumi.gcp.storage.BucketObjectArgs;
* import com.pulumi.gcp.vertex.AiIndex;
* import com.pulumi.gcp.vertex.AiIndexArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigArgs;
* import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigBruteForceConfigArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var bucket = new Bucket("bucket", BucketArgs.builder()
* .name("vertex-ai-index-test")
* .location("us-central1")
* .uniformBucketLevelAccess(true)
* .build());
* // The sample data comes from the following link:
* // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
* var data = new BucketObject("data", BucketObjectArgs.builder()
* .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"]}]}
* """)
* .build());
* var index = new AiIndex("index", AiIndexArgs.builder()
* .labels(Map.of("foo", "bar"))
* .region("us-central1")
* .displayName("test-index")
* .description("index for test")
* .metadata(AiIndexMetadataArgs.builder()
* .contentsDeltaUri(bucket.name().applyValue(name -> String.format("gs://%s/contents", name)))
* .config(AiIndexMetadataConfigArgs.builder()
* .dimensions(2)
* .shardSize("SHARD_SIZE_LARGE")
* .distanceMeasureType("COSINE_DISTANCE")
* .featureNormType("UNIT_L2_NORM")
* .algorithmConfig(AiIndexMetadataConfigAlgorithmConfigArgs.builder()
* .bruteForceConfig()
* .build())
* .build())
* .build())
* .indexUpdateMethod("STREAM_UPDATE")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* bucket:
* type: gcp:storage:Bucket
* properties:
* 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
* data:
* type: gcp:storage:BucketObject
* properties:
* 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"]}]}
* index:
* type: gcp:vertex:AiIndex
* properties:
* labels:
* foo: bar
* region: us-central1
* displayName: test-index
* description: index for test
* metadata:
* contentsDeltaUri: 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}}
* ```
*/
public class AiIndex internal constructor(
override val javaResource: com.pulumi.gcp.vertex.AiIndex,
) : KotlinCustomResource(javaResource, AiIndexMapper) {
/**
* The timestamp of when the Index was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
*/
public val createTime: Output
get() = javaResource.createTime().applyValue({ args0 -> args0 })
/**
* The pointers to DeployedIndexes created from this Index. An Index can be only deleted if all its DeployedIndexes had been undeployed first.
* Structure is documented below.
*/
public val deployedIndexes: Output>
get() = javaResource.deployedIndexes().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> aiIndexDeployedIndexToKotlin(args0) })
})
})
/**
* The description of the Index.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The display name of the Index. The name can be up to 128 characters long and can consist of any UTF-8 characters.
* - - -
*/
public val displayName: Output
get() = javaResource.displayName().applyValue({ args0 -> args0 })
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
*/
public val effectiveLabels: Output>
get() = javaResource.effectiveLabels().applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
})
/**
* Used to perform consistent read-modify-write updates.
*/
public val etag: Output
get() = javaResource.etag().applyValue({ args0 -> args0 })
/**
* Stats of the index resource.
* Structure is documented below.
*/
public val indexStats: Output>
get() = javaResource.indexStats().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
aiIndexIndexStatToKotlin(args0)
})
})
})
/**
* The update method to use with this Index. The value must be the followings. If not set, BATCH_UPDATE will be used by default.
* * BATCH_UPDATE: user can call indexes.patch with files on Cloud Storage of datapoints to update.
* * STREAM_UPDATE: user can call indexes.upsertDatapoints/DeleteDatapoints to update the Index and the updates will be applied in corresponding DeployedIndexes in nearly real-time.
*/
public val indexUpdateMethod: Output?
get() = javaResource.indexUpdateMethod().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The labels with user-defined metadata to organize your Indexes.
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field `effective_labels` for all of the labels present on the resource.
*/
public val labels: Output>?
get() = javaResource.labels().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}).orElse(null)
})
/**
* An additional information about the Index
* Structure is documented below.
*/
public val metadata: Output?
get() = javaResource.metadata().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
aiIndexMetadataToKotlin(args0)
})
}).orElse(null)
})
/**
* Points to a YAML file stored on Google Cloud Storage describing additional information about the Index, that is specific to it. Unset if the Index does not have any additional information.
*/
public val metadataSchemaUri: Output
get() = javaResource.metadataSchemaUri().applyValue({ args0 -> args0 })
/**
* The resource name of the Index.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* The combination of labels configured directly on the resource
* and default labels configured on the provider.
*/
public val pulumiLabels: Output>
get() = javaResource.pulumiLabels().applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
})
/**
* The region of the index. eg us-central1
*/
public val region: Output?
get() = javaResource.region().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The timestamp of when the Index was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
*/
public val updateTime: Output
get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}
public object AiIndexMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.vertex.AiIndex::class == javaResource::class
override fun map(javaResource: Resource): AiIndex = AiIndex(
javaResource as
com.pulumi.gcp.vertex.AiIndex,
)
}
/**
* @see [AiIndex].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [AiIndex].
*/
public suspend fun aiIndex(name: String, block: suspend AiIndexResourceBuilder.() -> Unit): AiIndex {
val builder = AiIndexResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [AiIndex].
* @param name The _unique_ name of the resulting resource.
*/
public fun aiIndex(name: String): AiIndex {
val builder = AiIndexResourceBuilder()
builder.name(name)
return builder.build()
}