All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.firestore.kotlin.Index.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.firestore.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.firestore.kotlin.outputs.IndexField
import com.pulumi.gcp.firestore.kotlin.outputs.IndexField.Companion.toKotlin
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

/**
 * Builder for [Index].
 */
@PulumiTagMarker
public class IndexResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: IndexArgs = IndexArgs()

    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 IndexArgsBuilder.() -> Unit) {
        val builder = IndexArgsBuilder()
        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(): Index {
        val builtJavaResource = com.pulumi.gcp.firestore.Index(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Index(builtJavaResource)
    }
}

/**
 * Cloud Firestore indexes enable simple and complex queries against documents in a database.
 *  This resource manages composite indexes and not single
 * field indexes.
 * To get more information about Index, see:
 * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.indexes)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
 * > **Warning:** This resource creates a Firestore Index on a project that already has
 * a Firestore database. If you haven't already created it, you may
 * create a `gcp.firestore.Database` resource and `location_id` set
 * to your chosen location. If you wish to use App Engine, you may
 * instead create a `gcp.appengine.Application` resource with
 * `database_type` set to `"CLOUD_FIRESTORE"`. Your Firestore location
 * will be the same as the App Engine location specified.
 * ## Example Usage
 * ### Firestore Index 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_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="database-id",
 *     location_id="nam5",
 *     type="FIRESTORE_NATIVE",
 *     delete_protection_state="DELETE_PROTECTION_DISABLED",
 *     deletion_policy="DELETE")
 * my_index = gcp.firestore.Index("my-index",
 *     project="my-project-name",
 *     database=database.name,
 *     collection="atestcollection",
 *     fields=[
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="name",
 *             order="ASCENDING",
 *         ),
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="description",
 *             order="DESCENDING",
 *         ),
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var database = new Gcp.Firestore.Database("database", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "database-id",
 *         LocationId = "nam5",
 *         Type = "FIRESTORE_NATIVE",
 *         DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var my_index = new Gcp.Firestore.Index("my-index", new()
 *     {
 *         Project = "my-project-name",
 *         Database = database.Name,
 *         Collection = "atestcollection",
 *         Fields = new[]
 *         {
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "name",
 *                 Order = "ASCENDING",
 *             },
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "description",
 *                 Order = "DESCENDING",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("database-id"),
 * 			LocationId:            pulumi.String("nam5"),
 * 			Type:                  pulumi.String("FIRESTORE_NATIVE"),
 * 			DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
 * 			DeletionPolicy:        pulumi.String("DELETE"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
 * 			Project:    pulumi.String("my-project-name"),
 * 			Database:   database.Name,
 * 			Collection: pulumi.String("atestcollection"),
 * 			Fields: firestore.IndexFieldArray{
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("name"),
 * 					Order:     pulumi.String("ASCENDING"),
 * 				},
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("description"),
 * 					Order:     pulumi.String("DESCENDING"),
 * 				},
 * 			},
 * 		})
 * 		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.firestore.Database;
 * import com.pulumi.gcp.firestore.DatabaseArgs;
 * import com.pulumi.gcp.firestore.Index;
 * import com.pulumi.gcp.firestore.IndexArgs;
 * import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
 * 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 database = new Database("database", DatabaseArgs.builder()
 *             .project("my-project-name")
 *             .name("database-id")
 *             .locationId("nam5")
 *             .type("FIRESTORE_NATIVE")
 *             .deleteProtectionState("DELETE_PROTECTION_DISABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var my_index = new Index("my-index", IndexArgs.builder()
 *             .project("my-project-name")
 *             .database(database.name())
 *             .collection("atestcollection")
 *             .fields(
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("name")
 *                     .order("ASCENDING")
 *                     .build(),
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("description")
 *                     .order("DESCENDING")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: database-id
 *       locationId: nam5
 *       type: FIRESTORE_NATIVE
 *       deleteProtectionState: DELETE_PROTECTION_DISABLED
 *       deletionPolicy: DELETE
 *   my-index:
 *     type: gcp:firestore:Index
 *     properties:
 *       project: my-project-name
 *       database: ${database.name}
 *       collection: atestcollection
 *       fields:
 *         - fieldPath: name
 *           order: ASCENDING
 *         - fieldPath: description
 *           order: DESCENDING
 * ```
 * 
 * ### Firestore Index Datastore Mode
 * 
 * ```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-dm",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     queryScope: "COLLECTION_RECURSIVE",
 *     apiScope: "DATASTORE_MODE_API",
 *     fields: [
 *         {
 *             fieldPath: "name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             order: "DESCENDING",
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="database-id-dm",
 *     location_id="nam5",
 *     type="DATASTORE_MODE",
 *     delete_protection_state="DELETE_PROTECTION_DISABLED",
 *     deletion_policy="DELETE")
 * my_index = gcp.firestore.Index("my-index",
 *     project="my-project-name",
 *     database=database.name,
 *     collection="atestcollection",
 *     query_scope="COLLECTION_RECURSIVE",
 *     api_scope="DATASTORE_MODE_API",
 *     fields=[
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="name",
 *             order="ASCENDING",
 *         ),
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="description",
 *             order="DESCENDING",
 *         ),
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var database = new Gcp.Firestore.Database("database", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "database-id-dm",
 *         LocationId = "nam5",
 *         Type = "DATASTORE_MODE",
 *         DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var my_index = new Gcp.Firestore.Index("my-index", new()
 *     {
 *         Project = "my-project-name",
 *         Database = database.Name,
 *         Collection = "atestcollection",
 *         QueryScope = "COLLECTION_RECURSIVE",
 *         ApiScope = "DATASTORE_MODE_API",
 *         Fields = new[]
 *         {
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "name",
 *                 Order = "ASCENDING",
 *             },
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "description",
 *                 Order = "DESCENDING",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("database-id-dm"),
 * 			LocationId:            pulumi.String("nam5"),
 * 			Type:                  pulumi.String("DATASTORE_MODE"),
 * 			DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
 * 			DeletionPolicy:        pulumi.String("DELETE"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
 * 			Project:    pulumi.String("my-project-name"),
 * 			Database:   database.Name,
 * 			Collection: pulumi.String("atestcollection"),
 * 			QueryScope: pulumi.String("COLLECTION_RECURSIVE"),
 * 			ApiScope:   pulumi.String("DATASTORE_MODE_API"),
 * 			Fields: firestore.IndexFieldArray{
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("name"),
 * 					Order:     pulumi.String("ASCENDING"),
 * 				},
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("description"),
 * 					Order:     pulumi.String("DESCENDING"),
 * 				},
 * 			},
 * 		})
 * 		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.firestore.Database;
 * import com.pulumi.gcp.firestore.DatabaseArgs;
 * import com.pulumi.gcp.firestore.Index;
 * import com.pulumi.gcp.firestore.IndexArgs;
 * import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
 * 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 database = new Database("database", DatabaseArgs.builder()
 *             .project("my-project-name")
 *             .name("database-id-dm")
 *             .locationId("nam5")
 *             .type("DATASTORE_MODE")
 *             .deleteProtectionState("DELETE_PROTECTION_DISABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var my_index = new Index("my-index", IndexArgs.builder()
 *             .project("my-project-name")
 *             .database(database.name())
 *             .collection("atestcollection")
 *             .queryScope("COLLECTION_RECURSIVE")
 *             .apiScope("DATASTORE_MODE_API")
 *             .fields(
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("name")
 *                     .order("ASCENDING")
 *                     .build(),
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("description")
 *                     .order("DESCENDING")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: database-id-dm
 *       locationId: nam5
 *       type: DATASTORE_MODE
 *       deleteProtectionState: DELETE_PROTECTION_DISABLED
 *       deletionPolicy: DELETE
 *   my-index:
 *     type: gcp:firestore:Index
 *     properties:
 *       project: my-project-name
 *       database: ${database.name}
 *       collection: atestcollection
 *       queryScope: COLLECTION_RECURSIVE
 *       apiScope: DATASTORE_MODE_API
 *       fields:
 *         - fieldPath: name
 *           order: ASCENDING
 *         - fieldPath: description
 *           order: DESCENDING
 * ```
 * 
 * ### Firestore Index Vector
 * 
 * ```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-vector",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const my_index = new gcp.firestore.Index("my-index", {
 *     project: "my-project-name",
 *     database: database.name,
 *     collection: "atestcollection",
 *     fields: [
 *         {
 *             fieldPath: "field_name",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "__name__",
 *             order: "ASCENDING",
 *         },
 *         {
 *             fieldPath: "description",
 *             vectorConfig: {
 *                 dimension: 128,
 *                 flat: {},
 *             },
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="database-id-vector",
 *     location_id="nam5",
 *     type="FIRESTORE_NATIVE",
 *     delete_protection_state="DELETE_PROTECTION_DISABLED",
 *     deletion_policy="DELETE")
 * my_index = gcp.firestore.Index("my-index",
 *     project="my-project-name",
 *     database=database.name,
 *     collection="atestcollection",
 *     fields=[
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="field_name",
 *             order="ASCENDING",
 *         ),
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="__name__",
 *             order="ASCENDING",
 *         ),
 *         gcp.firestore.IndexFieldArgs(
 *             field_path="description",
 *             vector_config=gcp.firestore.IndexFieldVectorConfigArgs(
 *                 dimension=128,
 *                 flat=gcp.firestore.IndexFieldVectorConfigFlatArgs(),
 *             ),
 *         ),
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var database = new Gcp.Firestore.Database("database", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "database-id-vector",
 *         LocationId = "nam5",
 *         Type = "FIRESTORE_NATIVE",
 *         DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var my_index = new Gcp.Firestore.Index("my-index", new()
 *     {
 *         Project = "my-project-name",
 *         Database = database.Name,
 *         Collection = "atestcollection",
 *         Fields = new[]
 *         {
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "field_name",
 *                 Order = "ASCENDING",
 *             },
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "__name__",
 *                 Order = "ASCENDING",
 *             },
 *             new Gcp.Firestore.Inputs.IndexFieldArgs
 *             {
 *                 FieldPath = "description",
 *                 VectorConfig = new Gcp.Firestore.Inputs.IndexFieldVectorConfigArgs
 *                 {
 *                     Dimension = 128,
 *                     Flat = null,
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("database-id-vector"),
 * 			LocationId:            pulumi.String("nam5"),
 * 			Type:                  pulumi.String("FIRESTORE_NATIVE"),
 * 			DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
 * 			DeletionPolicy:        pulumi.String("DELETE"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
 * 			Project:    pulumi.String("my-project-name"),
 * 			Database:   database.Name,
 * 			Collection: pulumi.String("atestcollection"),
 * 			Fields: firestore.IndexFieldArray{
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("field_name"),
 * 					Order:     pulumi.String("ASCENDING"),
 * 				},
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("__name__"),
 * 					Order:     pulumi.String("ASCENDING"),
 * 				},
 * 				&firestore.IndexFieldArgs{
 * 					FieldPath: pulumi.String("description"),
 * 					VectorConfig: &firestore.IndexFieldVectorConfigArgs{
 * 						Dimension: pulumi.Int(128),
 * 						Flat:      nil,
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.firestore.Database;
 * import com.pulumi.gcp.firestore.DatabaseArgs;
 * import com.pulumi.gcp.firestore.Index;
 * import com.pulumi.gcp.firestore.IndexArgs;
 * import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
 * import com.pulumi.gcp.firestore.inputs.IndexFieldVectorConfigArgs;
 * import com.pulumi.gcp.firestore.inputs.IndexFieldVectorConfigFlatArgs;
 * 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 database = new Database("database", DatabaseArgs.builder()
 *             .project("my-project-name")
 *             .name("database-id-vector")
 *             .locationId("nam5")
 *             .type("FIRESTORE_NATIVE")
 *             .deleteProtectionState("DELETE_PROTECTION_DISABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var my_index = new Index("my-index", IndexArgs.builder()
 *             .project("my-project-name")
 *             .database(database.name())
 *             .collection("atestcollection")
 *             .fields(
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("field_name")
 *                     .order("ASCENDING")
 *                     .build(),
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("__name__")
 *                     .order("ASCENDING")
 *                     .build(),
 *                 IndexFieldArgs.builder()
 *                     .fieldPath("description")
 *                     .vectorConfig(IndexFieldVectorConfigArgs.builder()
 *                         .dimension(128)
 *                         .flat()
 *                         .build())
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: database-id-vector
 *       locationId: nam5
 *       type: FIRESTORE_NATIVE
 *       deleteProtectionState: DELETE_PROTECTION_DISABLED
 *       deletionPolicy: DELETE
 *   my-index:
 *     type: gcp:firestore:Index
 *     properties:
 *       project: my-project-name
 *       database: ${database.name}
 *       collection: atestcollection
 *       fields:
 *         - fieldPath: field_name
 *           order: ASCENDING
 *         - fieldPath: __name__
 *           order: ASCENDING
 *         - fieldPath: description
 *           vectorConfig:
 *             dimension: 128
 *             flat: {}
 * ```
 * 
 * ## Import
 * Index can be imported using any of these accepted formats:
 * * `{{name}}`
 * When using the `pulumi import` command, Index can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:firestore/index:Index default {{name}}
 * ```
 */
public class Index internal constructor(
    override val javaResource: com.pulumi.gcp.firestore.Index,
) : KotlinCustomResource(javaResource, IndexMapper) {
    /**
     * The API scope at which a query is run. Default value: "ANY_API" Possible values: ["ANY_API", "DATASTORE_MODE_API"]
     */
    public val apiScope: Output?
        get() = javaResource.apiScope().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The collection being indexed.
     */
    public val collection: Output
        get() = javaResource.collection().applyValue({ args0 -> args0 })

    /**
     * The Firestore database id. Defaults to '"(default)"'.
     */
    public val database: Output?
        get() = javaResource.database().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The fields supported by this index. The last non-stored field entry is
     * always for the field path `__name__`. If, on creation, `__name__` was not
     * specified as the last field, it will be added automatically with the same
     * direction as that of the last field defined. If the final field in a
     * composite index is not directional, the `__name__` will be ordered
     * `"ASCENDING"` (unless explicitly specified otherwise).
     * Structure is documented below.
     */
    public val fields: Output>
        get() = javaResource.fields().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            })
        })

    /**
     * A server defined name for this index. Format:
     * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}`
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP",
     * "COLLECTION_RECURSIVE"]
     */
    public val queryScope: Output?
        get() = javaResource.queryScope().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object IndexMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.firestore.Index::class == javaResource::class

    override fun map(javaResource: Resource): Index = Index(
        javaResource as
            com.pulumi.gcp.firestore.Index,
    )
}

/**
 * @see [Index].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Index].
 */
public suspend fun index(name: String, block: suspend IndexResourceBuilder.() -> Unit): Index {
    val builder = IndexResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Index].
 * @param name The _unique_ name of the resulting resource.
 */
public fun index(name: String): Index {
    val builder = IndexResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy