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

com.pulumi.gcp.datastore.kotlin.DataStoreIndex.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.datastore.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.datastore.kotlin.outputs.DataStoreIndexProperty
import com.pulumi.gcp.datastore.kotlin.outputs.DataStoreIndexProperty.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 [DataStoreIndex].
 */
@PulumiTagMarker
public class DataStoreIndexResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: DataStoreIndexArgs = DataStoreIndexArgs()

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

/**
 * Describes a composite index for Cloud Datastore.
 * To get more information about Index, see:
 * * [API documentation](https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects.indexes)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/datastore/docs/concepts/indexes)
 * > **Warning:** This resource creates a Datastore Index on a project that has already
 * enabled a Datastore-compatible database. If you haven't already enabled
 * one, you can create a `gcp.appengine.Application` resource with
 * `database_type` set to `"CLOUD_DATASTORE_COMPATIBILITY"` to do so. Your
 * Datastore location will be the same as the App Engine location specified.
 * ## Example Usage
 * ### Datastore Index
 * 
 * ```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: "(default)",
 *     locationId: "nam5",
 *     type: "DATASTORE_MODE",
 *     deleteProtectionState: "DELETE_PROTECTION_DISABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const _default = new gcp.datastore.DataStoreIndex("default", {
 *     kind: "foo",
 *     properties: [
 *         {
 *             name: "property_a",
 *             direction: "ASCENDING",
 *         },
 *         {
 *             name: "property_b",
 *             direction: "ASCENDING",
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="(default)",
 *     location_id="nam5",
 *     type="DATASTORE_MODE",
 *     delete_protection_state="DELETE_PROTECTION_DISABLED",
 *     deletion_policy="DELETE")
 * default = gcp.datastore.DataStoreIndex("default",
 *     kind="foo",
 *     properties=[
 *         gcp.datastore.DataStoreIndexPropertyArgs(
 *             name="property_a",
 *             direction="ASCENDING",
 *         ),
 *         gcp.datastore.DataStoreIndexPropertyArgs(
 *             name="property_b",
 *             direction="ASCENDING",
 *         ),
 *     ])
 * ```
 * ```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 = "(default)",
 *         LocationId = "nam5",
 *         Type = "DATASTORE_MODE",
 *         DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var @default = new Gcp.Datastore.DataStoreIndex("default", new()
 *     {
 *         Kind = "foo",
 *         Properties = new[]
 *         {
 *             new Gcp.Datastore.Inputs.DataStoreIndexPropertyArgs
 *             {
 *                 Name = "property_a",
 *                 Direction = "ASCENDING",
 *             },
 *             new Gcp.Datastore.Inputs.DataStoreIndexPropertyArgs
 *             {
 *                 Name = "property_b",
 *                 Direction = "ASCENDING",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/datastore"
 * 	"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 {
 * 		_, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("(default)"),
 * 			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 = datastore.NewDataStoreIndex(ctx, "default", &datastore.DataStoreIndexArgs{
 * 			Kind: pulumi.String("foo"),
 * 			Properties: datastore.DataStoreIndexPropertyArray{
 * 				&datastore.DataStoreIndexPropertyArgs{
 * 					Name:      pulumi.String("property_a"),
 * 					Direction: pulumi.String("ASCENDING"),
 * 				},
 * 				&datastore.DataStoreIndexPropertyArgs{
 * 					Name:      pulumi.String("property_b"),
 * 					Direction: pulumi.String("ASCENDING"),
 * 				},
 * 			},
 * 		})
 * 		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.datastore.DataStoreIndex;
 * import com.pulumi.gcp.datastore.DataStoreIndexArgs;
 * import com.pulumi.gcp.datastore.inputs.DataStoreIndexPropertyArgs;
 * 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("(default)")
 *             .locationId("nam5")
 *             .type("DATASTORE_MODE")
 *             .deleteProtectionState("DELETE_PROTECTION_DISABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var default_ = new DataStoreIndex("default", DataStoreIndexArgs.builder()
 *             .kind("foo")
 *             .properties(
 *                 DataStoreIndexPropertyArgs.builder()
 *                     .name("property_a")
 *                     .direction("ASCENDING")
 *                     .build(),
 *                 DataStoreIndexPropertyArgs.builder()
 *                     .name("property_b")
 *                     .direction("ASCENDING")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: (default)
 *       locationId: nam5
 *       type: DATASTORE_MODE
 *       deleteProtectionState: DELETE_PROTECTION_DISABLED
 *       deletionPolicy: DELETE
 *   default:
 *     type: gcp:datastore:DataStoreIndex
 *     properties:
 *       kind: foo
 *       properties:
 *         - name: property_a
 *           direction: ASCENDING
 *         - name: property_b
 *           direction: ASCENDING
 * ```
 * 
 * ## Import
 * Index can be imported using any of these accepted formats:
 * * `projects/{{project}}/indexes/{{index_id}}`
 * * `{{project}}/{{index_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:datastore/dataStoreIndex:DataStoreIndex default projects/{{project}}/indexes/{{index_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:datastore/dataStoreIndex:DataStoreIndex default {{project}}/{{index_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:datastore/dataStoreIndex:DataStoreIndex default {{index_id}}
 * ```
 */
public class DataStoreIndex internal constructor(
    override val javaResource: com.pulumi.gcp.datastore.DataStoreIndex,
) : KotlinCustomResource(javaResource, DataStoreIndexMapper) {
    /**
     * Policy for including ancestors in the index.
     * Default value is `NONE`.
     * Possible values are: `NONE`, `ALL_ANCESTORS`.
     */
    public val ancestor: Output?
        get() = javaResource.ancestor().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The index id.
     */
    public val indexId: Output
        get() = javaResource.indexId().applyValue({ args0 -> args0 })

    /**
     * The entity kind which the index applies to.
     * - - -
     */
    public val kind: Output
        get() = javaResource.kind().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 })

    /**
     * An ordered list of properties to index on.
     * Structure is documented below.
     */
    public val properties: Output>?
        get() = javaResource.properties().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> toKotlin(args0) })
                })
            }).orElse(null)
        })
}

public object DataStoreIndexMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.datastore.DataStoreIndex::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy