UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

290 lines (289 loc) • 10.6 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Cloud Firestore indexes enable simple and complex queries against documents in a database. * Both Firestore Native and Datastore Mode indexes are supported. * This resource manages composite indexes and not single field indexes. * To manage single field indexes, use the `gcp.firestore.Field` resource instead. * * 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 `locationId` set * to your chosen location. If you wish to use App Engine, you may * instead create a `gcp.appengine.Application` resource. * 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", * }, * ], * }); * ``` * ### 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", * }, * ], * }); * ``` * ### 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: {}, * }, * }, * ], * }); * ``` * ### Firestore Index Name Descending * * ```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: "DESCENDING", * }], * }); * ``` * * ## 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}} * ``` */ export declare class Index extends pulumi.CustomResource { /** * Get an existing Index 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 Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: IndexState, opts?: pulumi.CustomResourceOptions): Index; /** * Returns true if the given object is an instance of Index. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Index; /** * The API scope at which a query is run. Default value: "ANY_API" Possible values: ["ANY_API", "DATASTORE_MODE_API"] */ readonly apiScope: pulumi.Output<string | undefined>; /** * The collection being indexed. */ readonly collection: pulumi.Output<string>; /** * The Firestore database id. Defaults to '"(default)"'. */ readonly database: pulumi.Output<string | undefined>; /** * 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. */ readonly fields: pulumi.Output<outputs.firestore.IndexField[]>; /** * A server defined name for this index. Format: * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}` */ readonly name: pulumi.Output<string>; readonly project: pulumi.Output<string>; /** * The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP", * "COLLECTION_RECURSIVE"] */ readonly queryScope: pulumi.Output<string | undefined>; /** * Create a Index resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: IndexArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Index resources. */ export interface IndexState { /** * The API scope at which a query is run. Default value: "ANY_API" Possible values: ["ANY_API", "DATASTORE_MODE_API"] */ apiScope?: pulumi.Input<string>; /** * The collection being indexed. */ collection?: pulumi.Input<string>; /** * The Firestore database id. Defaults to '"(default)"'. */ database?: pulumi.Input<string>; /** * 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. */ fields?: pulumi.Input<pulumi.Input<inputs.firestore.IndexField>[]>; /** * A server defined name for this index. Format: * `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}` */ name?: pulumi.Input<string>; project?: pulumi.Input<string>; /** * The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP", * "COLLECTION_RECURSIVE"] */ queryScope?: pulumi.Input<string>; } /** * The set of arguments for constructing a Index resource. */ export interface IndexArgs { /** * The API scope at which a query is run. Default value: "ANY_API" Possible values: ["ANY_API", "DATASTORE_MODE_API"] */ apiScope?: pulumi.Input<string>; /** * The collection being indexed. */ collection: pulumi.Input<string>; /** * The Firestore database id. Defaults to '"(default)"'. */ database?: pulumi.Input<string>; /** * 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. */ fields: pulumi.Input<pulumi.Input<inputs.firestore.IndexField>[]>; project?: pulumi.Input<string>; /** * The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP", * "COLLECTION_RECURSIVE"] */ queryScope?: pulumi.Input<string>; }