Class Field


  • public class Field
    extends com.pulumi.resources.CustomResource
    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 <!--Start PulumiCodeChooser --> ```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__34962") .field("basic") .indexConfig(FieldIndexConfigArgs.builder() .indexes( FieldIndexConfigIndexArgs.builder() .order("ASCENDING") .queryScope("COLLECTION_GROUP") .build(), FieldIndexConfigIndexArgs.builder() .arrayConfig("CONTAINS") .build()) .build()) .build()); } } ``` <!--End PulumiCodeChooser --> ### Firestore Field Timestamp <!--Start PulumiCodeChooser --> ```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()); } } ``` <!--End PulumiCodeChooser --> ### Firestore Field Match Override <!--Start PulumiCodeChooser --> ```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__74000") .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()); } } ``` <!--End PulumiCodeChooser --> ## 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}} ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Field​(java.lang.String name)  
      Field​(java.lang.String name, FieldArgs args)  
      Field​(java.lang.String name, FieldArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> collection()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> database()  
      com.pulumi.core.Output<java.lang.String> field()  
      static Field get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, FieldState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<FieldIndexConfig>> indexConfig()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.util.Optional<FieldTtlConfig>> ttlConfig()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Field

        public Field​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Field

        public Field​(java.lang.String name,
                     FieldArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Field

        public Field​(java.lang.String name,
                     FieldArgs args,
                     @Nullable
                     com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • collection

        public com.pulumi.core.Output<java.lang.String> collection()
        Returns:
        The id of the collection group to configure.
      • database

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> database()
        Returns:
        The Firestore database id. Defaults to `"(default)"`.
      • field

        public com.pulumi.core.Output<java.lang.String> field()
        Returns:
        The id of the field to configure. ***
      • indexConfig

        public com.pulumi.core.Output<java.util.Optional<FieldIndexConfig>> indexConfig()
        Returns:
        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.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        The name of this field. Format: `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
      • project

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
      • ttlConfig

        public com.pulumi.core.Output<java.util.Optional<FieldTtlConfig>> ttlConfig()
        Returns:
        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.
      • get

        public static Field get​(java.lang.String name,
                                com.pulumi.core.Output<java.lang.String> id,
                                @Nullable
                                FieldState state,
                                @Nullable
                                com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.