// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.gcp.firestore;

import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import com.pulumi.gcp.Utilities;
import com.pulumi.gcp.firestore.FieldArgs;
import com.pulumi.gcp.firestore.inputs.FieldState;
import com.pulumi.gcp.firestore.outputs.FieldIndexConfig;
import com.pulumi.gcp.firestore.outputs.FieldTtlConfig;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Represents a single field in the database.
 * Fields are grouped by their &#34;Collection Group&#34;, 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)
 * 
 * &gt; **Warning:** This resource creates a Firestore Single Field override on a project that
 *  already has a Firestore database. If you haven&#39;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
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.firestore.Field;
 * import com.pulumi.gcp.firestore.FieldArgs;
 * import com.pulumi.gcp.firestore.inputs.FieldIndexConfigArgs;
 * import com.pulumi.gcp.firestore.inputs.FieldTtlConfigArgs;
 * 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 basic = new Field(&#34;basic&#34;, FieldArgs.builder()        
 *             .collection(&#34;chatrooms_%{random_suffix}&#34;)
 *             .database(&#34;(default)&#34;)
 *             .field(&#34;basic&#34;)
 *             .indexConfig(FieldIndexConfigArgs.builder()
 *                 .indexes(                
 *                     FieldIndexConfigIndexArgs.builder()
 *                         .order(&#34;ASCENDING&#34;)
 *                         .queryScope(&#34;COLLECTION_GROUP&#34;)
 *                         .build(),
 *                     FieldIndexConfigIndexArgs.builder()
 *                         .arrayConfig(&#34;CONTAINS&#34;)
 *                         .build())
 *                 .build())
 *             .project(&#34;my-project-name&#34;)
 *             .ttlConfig()
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Firestore Field Timestamp
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.firestore.Field;
 * import com.pulumi.gcp.firestore.FieldArgs;
 * import com.pulumi.gcp.firestore.inputs.FieldIndexConfigArgs;
 * import com.pulumi.gcp.firestore.inputs.FieldTtlConfigArgs;
 * 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 timestamp = new Field(&#34;timestamp&#34;, FieldArgs.builder()        
 *             .collection(&#34;chatrooms_%{random_suffix}&#34;)
 *             .field(&#34;timestamp&#34;)
 *             .indexConfig()
 *             .project(&#34;my-project-name&#34;)
 *             .ttlConfig()
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Firestore Field Match Override
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * 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 matchOverride = new Field(&#34;matchOverride&#34;, FieldArgs.builder()        
 *             .collection(&#34;chatrooms_%{random_suffix}&#34;)
 *             .field(&#34;field_with_same_configuration_as_ancestor&#34;)
 *             .indexConfig(FieldIndexConfigArgs.builder()
 *                 .indexes(                
 *                     FieldIndexConfigIndexArgs.builder()
 *                         .order(&#34;ASCENDING&#34;)
 *                         .build(),
 *                     FieldIndexConfigIndexArgs.builder()
 *                         .order(&#34;DESCENDING&#34;)
 *                         .build(),
 *                     FieldIndexConfigIndexArgs.builder()
 *                         .arrayConfig(&#34;CONTAINS&#34;)
 *                         .build())
 *                 .build())
 *             .project(&#34;my-project-name&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * Field can be imported using any of these accepted formats
 * 
 * ```sh
 *  $ pulumi import gcp:firestore/field:Field default {{name}}
 * ```
 * 
 */
@ResourceType(type="gcp:firestore/field:Field")
public class Field extends com.pulumi.resources.CustomResource {
    /**
     * The id of the collection group to configure.
     * 
     */
    @Export(name="collection", type=String.class, parameters={})
    private Output<String> collection;

    /**
     * @return The id of the collection group to configure.
     * 
     */
    public Output<String> collection() {
        return this.collection;
    }
    /**
     * The Firestore database id. Defaults to `&#34;(default)&#34;`.
     * 
     */
    @Export(name="database", type=String.class, parameters={})
    private Output</* @Nullable */ String> database;

    /**
     * @return The Firestore database id. Defaults to `&#34;(default)&#34;`.
     * 
     */
    public Output<Optional<String>> database() {
        return Codegen.optional(this.database);
    }
    /**
     * The id of the field to configure.
     * 
     * ***
     * 
     */
    @Export(name="field", type=String.class, parameters={})
    private Output<String> field;

    /**
     * @return The id of the field to configure.
     * 
     * ***
     * 
     */
    public Output<String> field() {
        return this.field;
    }
    /**
     * 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.
     * 
     */
    @Export(name="indexConfig", type=FieldIndexConfig.class, parameters={})
    private Output</* @Nullable */ FieldIndexConfig> indexConfig;

    /**
     * @return 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 Output<Optional<FieldIndexConfig>> indexConfig() {
        return Codegen.optional(this.indexConfig);
    }
    /**
     * The name of this field. Format:
     * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
     * 
     */
    @Export(name="name", type=String.class, parameters={})
    private Output<String> name;

    /**
     * @return The name of this field. Format:
     * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
     * 
     */
    public Output<String> name() {
        return this.name;
    }
    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    @Export(name="project", type=String.class, parameters={})
    private Output<String> project;

    /**
     * @return The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    public Output<String> project() {
        return this.project;
    }
    /**
     * If set, this field is configured for TTL deletion.
     * Structure is documented below.
     * 
     */
    @Export(name="ttlConfig", type=FieldTtlConfig.class, parameters={})
    private Output</* @Nullable */ FieldTtlConfig> ttlConfig;

    /**
     * @return If set, this field is configured for TTL deletion.
     * Structure is documented below.
     * 
     */
    public Output<Optional<FieldTtlConfig>> ttlConfig() {
        return Codegen.optional(this.ttlConfig);
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public Field(String name) {
        this(name, FieldArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public Field(String name, FieldArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public Field(String name, FieldArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:firestore/field:Field", name, args == null ? FieldArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private Field(String name, Output<String> id, @Nullable FieldState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:firestore/field:Field", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static Field get(String name, Output<String> id, @Nullable FieldState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new Field(name, id, state, options);
    }
}
