com.pulumi.gcp.firestore.kotlin.Field.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.firestore.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.firestore.kotlin.outputs.FieldIndexConfig
import com.pulumi.gcp.firestore.kotlin.outputs.FieldTtlConfig
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 com.pulumi.gcp.firestore.kotlin.outputs.FieldIndexConfig.Companion.toKotlin as fieldIndexConfigToKotlin
import com.pulumi.gcp.firestore.kotlin.outputs.FieldTtlConfig.Companion.toKotlin as fieldTtlConfigToKotlin
/**
* Builder for [Field].
*/
@PulumiTagMarker
public class FieldResourceBuilder internal constructor() {
public var name: String? = null
public var args: FieldArgs = FieldArgs()
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 FieldArgsBuilder.() -> Unit) {
val builder = FieldArgsBuilder()
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(): Field {
val builtJavaResource = com.pulumi.gcp.firestore.Field(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Field(builtJavaResource)
}
}
/**
* Represents a single field in the database.
* Fields are grouped by their "Collection Group", which represent all collections
* in the database with the same id.
* To get more information about Field, see:
* * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.fields)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
* > **Warning:** This resource creates a Firestore Single Field override on a project that
* already has a Firestore database. If you haven't already created it, you may
* create a `gcp.firestore.Database` resource with `location_id` set to your
* chosen location.
* ## Example Usage
* ### Firestore Field 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_ENABLED",
* deletionPolicy: "DELETE",
* });
* const basic = new gcp.firestore.Field("basic", {
* project: "my-project-name",
* database: database.name,
* collection: "chatrooms__74000",
* field: "basic",
* indexConfig: {
* indexes: [
* {
* order: "ASCENDING",
* queryScope: "COLLECTION_GROUP",
* },
* {
* arrayConfig: "CONTAINS",
* },
* ],
* },
* });
* ```
* ```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_ENABLED",
* deletion_policy="DELETE")
* basic = gcp.firestore.Field("basic",
* project="my-project-name",
* database=database.name,
* collection="chatrooms__74000",
* field="basic",
* index_config=gcp.firestore.FieldIndexConfigArgs(
* indexes=[
* gcp.firestore.FieldIndexConfigIndexArgs(
* order="ASCENDING",
* query_scope="COLLECTION_GROUP",
* ),
* gcp.firestore.FieldIndexConfigIndexArgs(
* array_config="CONTAINS",
* ),
* ],
* ))
* ```
* ```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_ENABLED",
* DeletionPolicy = "DELETE",
* });
* var basic = new Gcp.Firestore.Field("basic", new()
* {
* Project = "my-project-name",
* Database = database.Name,
* Collection = "chatrooms__74000",
* FieldId = "basic",
* IndexConfig = new Gcp.Firestore.Inputs.FieldIndexConfigArgs
* {
* Indexes = new[]
* {
* new Gcp.Firestore.Inputs.FieldIndexConfigIndexArgs
* {
* Order = "ASCENDING",
* QueryScope = "COLLECTION_GROUP",
* },
* new Gcp.Firestore.Inputs.FieldIndexConfigIndexArgs
* {
* ArrayConfig = "CONTAINS",
* },
* },
* },
* });
* });
* ```
* ```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_ENABLED"),
* DeletionPolicy: pulumi.String("DELETE"),
* })
* if err != nil {
* return err
* }
* _, err = firestore.NewField(ctx, "basic", &firestore.FieldArgs{
* Project: pulumi.String("my-project-name"),
* Database: database.Name,
* Collection: pulumi.String("chatrooms__74000"),
* Field: pulumi.String("basic"),
* IndexConfig: &firestore.FieldIndexConfigArgs{
* Indexes: firestore.FieldIndexConfigIndexArray{
* &firestore.FieldIndexConfigIndexArgs{
* Order: pulumi.String("ASCENDING"),
* QueryScope: pulumi.String("COLLECTION_GROUP"),
* },
* &firestore.FieldIndexConfigIndexArgs{
* ArrayConfig: pulumi.String("CONTAINS"),
* },
* },
* },
* })
* 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.Field;
* import com.pulumi.gcp.firestore.FieldArgs;
* import com.pulumi.gcp.firestore.inputs.FieldIndexConfigArgs;
* 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_ENABLED")
* .deletionPolicy("DELETE")
* .build());
* var basic = new Field("basic", FieldArgs.builder()
* .project("my-project-name")
* .database(database.name())
* .collection("chatrooms__74000")
* .field("basic")
* .indexConfig(FieldIndexConfigArgs.builder()
* .indexes(
* FieldIndexConfigIndexArgs.builder()
* .order("ASCENDING")
* .queryScope("COLLECTION_GROUP")
* .build(),
* FieldIndexConfigIndexArgs.builder()
* .arrayConfig("CONTAINS")
* .build())
* .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_ENABLED
* deletionPolicy: DELETE
* basic:
* type: gcp:firestore:Field
* properties:
* project: my-project-name
* database: ${database.name}
* collection: chatrooms__74000
* field: basic
* indexConfig:
* indexes:
* - order: ASCENDING
* queryScope: COLLECTION_GROUP
* - arrayConfig: CONTAINS
* ```
*
* ### Firestore Field Timestamp
*
* ```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_ENABLED",
* deletionPolicy: "DELETE",
* });
* const timestamp = new gcp.firestore.Field("timestamp", {
* project: "my-project-name",
* database: database.name,
* collection: "chatrooms",
* field: "timestamp",
* ttlConfig: {},
* indexConfig: {},
* });
* ```
* ```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_ENABLED",
* deletion_policy="DELETE")
* timestamp = gcp.firestore.Field("timestamp",
* project="my-project-name",
* database=database.name,
* collection="chatrooms",
* field="timestamp",
* ttl_config=gcp.firestore.FieldTtlConfigArgs(),
* index_config=gcp.firestore.FieldIndexConfigArgs())
* ```
* ```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_ENABLED",
* DeletionPolicy = "DELETE",
* });
* var timestamp = new Gcp.Firestore.Field("timestamp", new()
* {
* Project = "my-project-name",
* Database = database.Name,
* Collection = "chatrooms",
* FieldId = "timestamp",
* TtlConfig = null,
* IndexConfig = 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"),
* LocationId: pulumi.String("nam5"),
* Type: pulumi.String("FIRESTORE_NATIVE"),
* DeleteProtectionState: pulumi.String("DELETE_PROTECTION_ENABLED"),
* DeletionPolicy: pulumi.String("DELETE"),
* })
* if err != nil {
* return err
* }
* _, err = firestore.NewField(ctx, "timestamp", &firestore.FieldArgs{
* Project: pulumi.String("my-project-name"),
* Database: database.Name,
* Collection: pulumi.String("chatrooms"),
* Field: pulumi.String("timestamp"),
* TtlConfig: nil,
* IndexConfig: 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.Field;
* import com.pulumi.gcp.firestore.FieldArgs;
* import com.pulumi.gcp.firestore.inputs.FieldTtlConfigArgs;
* import com.pulumi.gcp.firestore.inputs.FieldIndexConfigArgs;
* 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_ENABLED")
* .deletionPolicy("DELETE")
* .build());
* var timestamp = new Field("timestamp", FieldArgs.builder()
* .project("my-project-name")
* .database(database.name())
* .collection("chatrooms")
* .field("timestamp")
* .ttlConfig()
* .indexConfig()
* .build());
* }
* }
* ```
* ```yaml
* resources:
* database:
* type: gcp:firestore:Database
* properties:
* project: my-project-name
* name: database-id
* locationId: nam5
* type: FIRESTORE_NATIVE
* deleteProtectionState: DELETE_PROTECTION_ENABLED
* deletionPolicy: DELETE
* timestamp:
* type: gcp:firestore:Field
* properties:
* project: my-project-name
* database: ${database.name}
* collection: chatrooms
* field: timestamp
* ttlConfig: {}
* indexConfig: {}
* ```
*
* ### Firestore Field Match Override
*
* ```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_ENABLED",
* deletionPolicy: "DELETE",
* });
* const matchOverride = new gcp.firestore.Field("match_override", {
* project: "my-project-name",
* database: database.name,
* collection: "chatrooms__75125",
* field: "field_with_same_configuration_as_ancestor",
* indexConfig: {
* indexes: [
* {
* order: "ASCENDING",
* },
* {
* order: "DESCENDING",
* },
* {
* arrayConfig: "CONTAINS",
* },
* ],
* },
* });
* ```
* ```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_ENABLED",
* deletion_policy="DELETE")
* match_override = gcp.firestore.Field("match_override",
* project="my-project-name",
* database=database.name,
* collection="chatrooms__75125",
* field="field_with_same_configuration_as_ancestor",
* index_config=gcp.firestore.FieldIndexConfigArgs(
* indexes=[
* gcp.firestore.FieldIndexConfigIndexArgs(
* order="ASCENDING",
* ),
* gcp.firestore.FieldIndexConfigIndexArgs(
* order="DESCENDING",
* ),
* gcp.firestore.FieldIndexConfigIndexArgs(
* array_config="CONTAINS",
* ),
* ],
* ))
* ```
* ```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_ENABLED",
* DeletionPolicy = "DELETE",
* });
* var matchOverride = new Gcp.Firestore.Field("match_override", new()
* {
* Project = "my-project-name",
* Database = database.Name,
* Collection = "chatrooms__75125",
* FieldId = "field_with_same_configuration_as_ancestor",
* IndexConfig = new Gcp.Firestore.Inputs.FieldIndexConfigArgs
* {
* Indexes = new[]
* {
* new Gcp.Firestore.Inputs.FieldIndexConfigIndexArgs
* {
* Order = "ASCENDING",
* },
* new Gcp.Firestore.Inputs.FieldIndexConfigIndexArgs
* {
* Order = "DESCENDING",
* },
* new Gcp.Firestore.Inputs.FieldIndexConfigIndexArgs
* {
* ArrayConfig = "CONTAINS",
* },
* },
* },
* });
* });
* ```
* ```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_ENABLED"),
* DeletionPolicy: pulumi.String("DELETE"),
* })
* if err != nil {
* return err
* }
* _, err = firestore.NewField(ctx, "match_override", &firestore.FieldArgs{
* Project: pulumi.String("my-project-name"),
* Database: database.Name,
* Collection: pulumi.String("chatrooms__75125"),
* Field: pulumi.String("field_with_same_configuration_as_ancestor"),
* IndexConfig: &firestore.FieldIndexConfigArgs{
* Indexes: firestore.FieldIndexConfigIndexArray{
* &firestore.FieldIndexConfigIndexArgs{
* Order: pulumi.String("ASCENDING"),
* },
* &firestore.FieldIndexConfigIndexArgs{
* Order: pulumi.String("DESCENDING"),
* },
* &firestore.FieldIndexConfigIndexArgs{
* ArrayConfig: pulumi.String("CONTAINS"),
* },
* },
* },
* })
* 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.Field;
* import com.pulumi.gcp.firestore.FieldArgs;
* import com.pulumi.gcp.firestore.inputs.FieldIndexConfigArgs;
* 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_ENABLED")
* .deletionPolicy("DELETE")
* .build());
* var matchOverride = new Field("matchOverride", FieldArgs.builder()
* .project("my-project-name")
* .database(database.name())
* .collection("chatrooms__75125")
* .field("field_with_same_configuration_as_ancestor")
* .indexConfig(FieldIndexConfigArgs.builder()
* .indexes(
* FieldIndexConfigIndexArgs.builder()
* .order("ASCENDING")
* .build(),
* FieldIndexConfigIndexArgs.builder()
* .order("DESCENDING")
* .build(),
* FieldIndexConfigIndexArgs.builder()
* .arrayConfig("CONTAINS")
* .build())
* .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_ENABLED
* deletionPolicy: DELETE
* matchOverride:
* type: gcp:firestore:Field
* name: match_override
* properties:
* project: my-project-name
* database: ${database.name}
* collection: chatrooms__75125
* field: field_with_same_configuration_as_ancestor
* indexConfig:
* indexes:
* - order: ASCENDING
* - order: DESCENDING
* - arrayConfig: CONTAINS
* ```
*
* ## Import
* Field can be imported using any of these accepted formats:
* * `{{name}}`
* When using the `pulumi import` command, Field can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:firestore/field:Field default {{name}}
* ```
*/
public class Field internal constructor(
override val javaResource: com.pulumi.gcp.firestore.Field,
) : KotlinCustomResource(javaResource, FieldMapper) {
/**
* The id of the collection group to configure.
*/
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 id of the field to configure.
* - - -
*/
public val `field`: Output
get() = javaResource.`field`().applyValue({ args0 -> args0 })
/**
* The single field index configuration for this field.
* Creating an index configuration for this field will override any inherited configuration with the
* indexes specified. Configuring the index configuration with an empty block disables all indexes on
* the field.
* Structure is documented below.
*/
public val indexConfig: Output?
get() = javaResource.indexConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
fieldIndexConfigToKotlin(args0)
})
}).orElse(null)
})
/**
* The name of this field. Format:
* `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
*/
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 TTL configuration for this Field. If set to an empty block (i.e. `ttl_config {}`), a TTL policy is configured based on the field. If unset, a TTL policy is not configured (or will be disabled upon updating the resource).
* Structure is documented below.
*/
public val ttlConfig: Output?
get() = javaResource.ttlConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
fieldTtlConfigToKotlin(args0)
})
}).orElse(null)
})
}
public object FieldMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.firestore.Field::class == javaResource::class
override fun map(javaResource: Resource): Field = Field(
javaResource as
com.pulumi.gcp.firestore.Field,
)
}
/**
* @see [Field].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Field].
*/
public suspend fun `field`(name: String, block: suspend FieldResourceBuilder.() -> Unit): Field {
val builder = FieldResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Field].
* @param name The _unique_ name of the resulting resource.
*/
public fun `field`(name: String): Field {
val builder = FieldResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy