@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
405 lines • 16.1 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* A DataObject is a single item of data (with optional vectors) stored in a
* Vector Search Collection. Each DataObject conforms to the parent
* Collection's `dataSchema` and `vectorSchema`.
*
* This resource always issues one `CreateDataObject` request per Terraform
* resource block. It does NOT use the `batchCreate` REST endpoint --
* Terraform's resource lifecycle is inherently per-object, so batching
* across resources is not modeled. When you use `forEach` or `count`,
* Terraform will still issue individual requests, up to `-parallelism`
* in parallel.
*
* For ingesting more than a few hundred items, prefer one of the
* following out-of-band paths instead of Terraform:
*
* * `importDataObjects` (bulk ingest from Cloud Storage) -- highest
* throughput, but only available *before* any Index is created on
* the Collection.
* * `batchCreate` (up to ~1000 items per call) -- available at any
* time, but must be driven from your own client code, not Terraform.
*
* Once an Index exists on the Collection, `importDataObjects` is no
* longer available and DataObjects must be created via `CreateDataObject`
* (as this resource does) or via `batchCreate`.
*
* ## Example Usage
*
* ### Vectorsearch Data Object Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // NOTE: This resource issues one CreateDataObject request per block.
* // It does NOT batch across resources. Terraform will parallelize a
* // 'for_each' up to '-parallelism', but each item is still a separate
* // HTTP call.
* //
* // For bulk ingestion of many items, prefer one of these out-of-band
* // paths instead of Terraform:
* // * 'importDataObjects' (from Cloud Storage) -- highest throughput,
* // but only available *before* any Index is created on the Collection.
* // * 'batchCreate' (up to ~1000 items per call) -- available at any
* // time, but must be driven from client code, not Terraform.
* const parent = new gcp.vectorsearch.Collection("parent", {
* location: "us-central1",
* collectionId: "example-collection",
* displayName: "My Awesome Collection",
* description: "This collection stores important data.",
* dataSchema: `{
* \\"type\\": \\"object\\",
* \\"properties\\": {
* \\"title\\": {
* \\"type\\": \\"string\\"
* },
* \\"plot\\": {
* \\"type\\": \\"string\\"
* }
* }
* }
* `,
* vectorSchemas: [{
* fieldName: "text_embedding",
* denseVector: {
* dimensions: 768,
* vertexEmbeddingConfig: {
* modelId: "text-embedding-005",
* taskType: "RETRIEVAL_DOCUMENT",
* textTemplate: "Title: {title} ---- Plot: {plot}",
* },
* },
* }],
* });
* // Because the parent Collection's 'text_embedding' field is configured
* // with a 'vertex_embedding_config', the server will populate the vector
* // automatically from 'data.title' and 'data.plot' -- no explicit
* // 'vectors' block is required.
* const example_data_object = new gcp.vectorsearch.DataObject("example-data-object", {
* location: "us-central1",
* collectionId: parent.collectionId,
* dataObjectId: "example-data-object",
* data: JSON.stringify({
* title: "The Matrix",
* plot: "A computer hacker learns about the true nature of reality.",
* }),
* });
* ```
* ### Vectorsearch Data Object With Vectors
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // NOTE: This resource issues one CreateDataObject request per block.
* // It does NOT batch across resources. Terraform will parallelize a
* // 'for_each' up to '-parallelism', but each item is still a separate
* // HTTP call.
* //
* // For bulk ingestion of many items, prefer one of these out-of-band
* // paths instead of Terraform:
* // * 'importDataObjects' (from Cloud Storage) -- highest throughput,
* // but only available *before* any Index is created on the Collection.
* // * 'batchCreate' (up to ~1000 items per call) -- available at any
* // time, but must be driven from client code, not Terraform.
* const parent = new gcp.vectorsearch.Collection("parent", {
* location: "us-central1",
* collectionId: "example-vectors-collection",
* displayName: "My BYO-Embedding Collection",
* description: "Collection whose vectors are supplied by the client.",
* dataSchema: `{
* \\"type\\": \\"object\\",
* \\"properties\\": {
* \\"title\\": {
* \\"type\\": \\"string\\"
* },
* \\"category\\": {
* \\"type\\": \\"string\\"
* }
* }
* }
* `,
* vectorSchemas: [
* {
* fieldName: "dense_embedding",
* denseVector: {
* dimensions: 4,
* },
* },
* {
* fieldName: "sparse_embedding",
* sparseVector: {},
* },
* ],
* });
* const example_vectors_data_object = new gcp.vectorsearch.DataObject("example-vectors-data-object", {
* location: "us-central1",
* collectionId: parent.collectionId,
* dataObjectId: "example-vectors-data-object",
* data: JSON.stringify({
* title: "The Matrix",
* category: "movie",
* }),
* vectors: [
* {
* fieldName: "dense_embedding",
* dense: {
* values: [
* 0.11,
* 0.22,
* 0.33,
* 0.44,
* ],
* },
* },
* {
* fieldName: "sparse_embedding",
* sparse: {
* values: [
* 0.9,
* 0.5,
* 0.1,
* ],
* indices: [
* 3,
* 17,
* 42,
* ],
* },
* },
* ],
* });
* ```
*
* ## Import
*
* DataObject can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/dataObjects/{{data_object_id}}`
* * `{{project}}/{{location}}/{{collection_id}}/{{data_object_id}}`
* * `{{location}}/{{collection_id}}/{{data_object_id}}`
*
* When using the `pulumi import` command, DataObject can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:vectorsearch/dataObject:DataObject default projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/dataObjects/{{data_object_id}}
* $ pulumi import gcp:vectorsearch/dataObject:DataObject default {{project}}/{{location}}/{{collection_id}}/{{data_object_id}}
* $ pulumi import gcp:vectorsearch/dataObject:DataObject default {{location}}/{{collection_id}}/{{data_object_id}}
* ```
*/
export declare class DataObject extends pulumi.CustomResource {
/**
* Get an existing DataObject 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?: DataObjectState, opts?: pulumi.CustomResourceOptions): DataObject;
/**
* Returns true if the given object is an instance of DataObject. 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 DataObject;
/**
* The ID of the parent Collection.
*/
readonly collectionId: pulumi.Output<string>;
/**
* [Output only] Create time stamp
*/
readonly createTime: pulumi.Output<string>;
/**
* The JSON data of the DataObject. Must be a JSON object whose field
* names match the fields defined in the parent Collection's
* `dataSchema`.
*/
readonly data: pulumi.Output<string | undefined>;
/**
* ID of the DataObject to create.
* The id must be 1-63 characters long, and comply with
* [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
* Specifically, it must be 1-63 characters long and match the regular
* expression `a-z?`.
*/
readonly dataObjectId: pulumi.Output<string>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
readonly deletionPolicy: pulumi.Output<string>;
/**
* The etag of the DataObject, used for optimistic concurrency
* control on updates and deletes.
*/
readonly etag: pulumi.Output<string>;
/**
* Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
*/
readonly location: pulumi.Output<string>;
/**
* Identifier. name of resource
*/
readonly name: pulumi.Output<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* [Output only] Update time stamp
*/
readonly updateTime: pulumi.Output<string>;
/**
* The vectors of the DataObject, keyed by the vector field name as
* defined in the parent Collection's `vectorSchema`.
* If a vector field is configured with a `vertexEmbeddingConfig` on
* the Collection, the server will populate the vector automatically
* from the corresponding text in `data` and the field should be
* omitted here.
* Structure is documented below.
*/
readonly vectors: pulumi.Output<outputs.vectorsearch.DataObjectVector[]>;
/**
* Create a DataObject 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: DataObjectArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering DataObject resources.
*/
export interface DataObjectState {
/**
* The ID of the parent Collection.
*/
collectionId?: pulumi.Input<string | undefined>;
/**
* [Output only] Create time stamp
*/
createTime?: pulumi.Input<string | undefined>;
/**
* The JSON data of the DataObject. Must be a JSON object whose field
* names match the fields defined in the parent Collection's
* `dataSchema`.
*/
data?: pulumi.Input<string | undefined>;
/**
* ID of the DataObject to create.
* The id must be 1-63 characters long, and comply with
* [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
* Specifically, it must be 1-63 characters long and match the regular
* expression `a-z?`.
*/
dataObjectId?: pulumi.Input<string | undefined>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* The etag of the DataObject, used for optimistic concurrency
* control on updates and deletes.
*/
etag?: pulumi.Input<string | undefined>;
/**
* Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
*/
location?: pulumi.Input<string | undefined>;
/**
* Identifier. name of resource
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* [Output only] Update time stamp
*/
updateTime?: pulumi.Input<string | undefined>;
/**
* The vectors of the DataObject, keyed by the vector field name as
* defined in the parent Collection's `vectorSchema`.
* If a vector field is configured with a `vertexEmbeddingConfig` on
* the Collection, the server will populate the vector automatically
* from the corresponding text in `data` and the field should be
* omitted here.
* Structure is documented below.
*/
vectors?: pulumi.Input<pulumi.Input<inputs.vectorsearch.DataObjectVector>[] | undefined>;
}
/**
* The set of arguments for constructing a DataObject resource.
*/
export interface DataObjectArgs {
/**
* The ID of the parent Collection.
*/
collectionId: pulumi.Input<string>;
/**
* The JSON data of the DataObject. Must be a JSON object whose field
* names match the fields defined in the parent Collection's
* `dataSchema`.
*/
data?: pulumi.Input<string | undefined>;
/**
* ID of the DataObject to create.
* The id must be 1-63 characters long, and comply with
* [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
* Specifically, it must be 1-63 characters long and match the regular
* expression `a-z?`.
*/
dataObjectId: pulumi.Input<string>;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* The etag of the DataObject, used for optimistic concurrency
* control on updates and deletes.
*/
etag?: pulumi.Input<string | undefined>;
/**
* Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
*/
location: pulumi.Input<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* The vectors of the DataObject, keyed by the vector field name as
* defined in the parent Collection's `vectorSchema`.
* If a vector field is configured with a `vertexEmbeddingConfig` on
* the Collection, the server will populate the vector automatically
* from the corresponding text in `data` and the field should be
* omitted here.
* Structure is documented below.
*/
vectors?: pulumi.Input<pulumi.Input<inputs.vectorsearch.DataObjectVector>[] | undefined>;
}
//# sourceMappingURL=dataObject.d.ts.map