From 48063232a091a0aea8230967173499ac707e33d3 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 16 Oct 2024 01:28:20 -0400 Subject: [PATCH] rebase external changes for rerank against release-candidate/2024 branch, refactor code to use generated inference module, correct a few issues with Documents argument shape and rerank test --- codegen/apis | 2 +- internal/gen/control/control_plane.oas.go | 1857 ----------------- .../gen/db_control/db_control_2024-10.oas.go | 37 + .../grpc}/db_data_2024-10.pb.go | 11 +- .../grpc}/db_data_2024-10_grpc.pb.go | 2 +- .../gen/inference/inference_2024-10.oas.go | 70 +- pinecone/client.go | 37 +- pinecone/client_test.go | 18 +- pinecone/index_connection.go | 52 +- pinecone/index_connection_test.go | 70 +- 10 files changed, 160 insertions(+), 1996 deletions(-) delete mode 100644 internal/gen/control/control_plane.oas.go rename internal/gen/{data => db_data/grpc}/db_data_2024-10.pb.go (99%) rename internal/gen/{data => db_data/grpc}/db_data_2024-10_grpc.pb.go (99%) diff --git a/codegen/apis b/codegen/apis index 3b7369b..9d3a41f 160000 --- a/codegen/apis +++ b/codegen/apis @@ -1 +1 @@ -Subproject commit 3b7369b89469ddc6ef4c08d3f8df905302966624 +Subproject commit 9d3a41f6ae657d9b0b818065dcdc3adf76bdb7fe diff --git a/internal/gen/control/control_plane.oas.go b/internal/gen/control/control_plane.oas.go deleted file mode 100644 index 5088e89..0000000 --- a/internal/gen/control/control_plane.oas.go +++ /dev/null @@ -1,1857 +0,0 @@ -// Package db_control provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package db_control - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "strings" - - "github.com/oapi-codegen/runtime" -) - -const ( - ApiKeyAuthScopes = "ApiKeyAuth.Scopes" -) - -// Defines values for CollectionModelStatus. -const ( - CollectionModelStatusInitializing CollectionModelStatus = "Initializing" - CollectionModelStatusReady CollectionModelStatus = "Ready" - CollectionModelStatusTerminating CollectionModelStatus = "Terminating" -) - -// Defines values for CreateIndexRequestMetric. -const ( - CreateIndexRequestMetricCosine CreateIndexRequestMetric = "cosine" - CreateIndexRequestMetricDotproduct CreateIndexRequestMetric = "dotproduct" - CreateIndexRequestMetricEuclidean CreateIndexRequestMetric = "euclidean" -) - -// Defines values for DeletionProtection. -const ( - Disabled DeletionProtection = "disabled" - Enabled DeletionProtection = "enabled" -) - -// Defines values for ErrorResponseErrorCode. -const ( - ABORTED ErrorResponseErrorCode = "ABORTED" - ALREADYEXISTS ErrorResponseErrorCode = "ALREADY_EXISTS" - DATALOSS ErrorResponseErrorCode = "DATA_LOSS" - DEADLINEEXCEEDED ErrorResponseErrorCode = "DEADLINE_EXCEEDED" - FAILEDPRECONDITION ErrorResponseErrorCode = "FAILED_PRECONDITION" - FORBIDDEN ErrorResponseErrorCode = "FORBIDDEN" - INTERNAL ErrorResponseErrorCode = "INTERNAL" - INVALIDARGUMENT ErrorResponseErrorCode = "INVALID_ARGUMENT" - NOTFOUND ErrorResponseErrorCode = "NOT_FOUND" - OK ErrorResponseErrorCode = "OK" - OUTOFRANGE ErrorResponseErrorCode = "OUT_OF_RANGE" - PERMISSIONDENIED ErrorResponseErrorCode = "PERMISSION_DENIED" - QUOTAEXCEEDED ErrorResponseErrorCode = "QUOTA_EXCEEDED" - RESOURCEEXHAUSTED ErrorResponseErrorCode = "RESOURCE_EXHAUSTED" - UNAUTHENTICATED ErrorResponseErrorCode = "UNAUTHENTICATED" - UNAVAILABLE ErrorResponseErrorCode = "UNAVAILABLE" - UNIMPLEMENTED ErrorResponseErrorCode = "UNIMPLEMENTED" - UNKNOWN ErrorResponseErrorCode = "UNKNOWN" - UNPROCESSABLEENTITY ErrorResponseErrorCode = "UNPROCESSABLE_ENTITY" -) - -// Defines values for IndexModelMetric. -const ( - IndexModelMetricCosine IndexModelMetric = "cosine" - IndexModelMetricDotproduct IndexModelMetric = "dotproduct" - IndexModelMetricEuclidean IndexModelMetric = "euclidean" -) - -// Defines values for IndexModelStatusState. -const ( - IndexModelStatusStateInitializationFailed IndexModelStatusState = "InitializationFailed" - IndexModelStatusStateInitializing IndexModelStatusState = "Initializing" - IndexModelStatusStateReady IndexModelStatusState = "Ready" - IndexModelStatusStateScalingDown IndexModelStatusState = "ScalingDown" - IndexModelStatusStateScalingDownPodSize IndexModelStatusState = "ScalingDownPodSize" - IndexModelStatusStateScalingUp IndexModelStatusState = "ScalingUp" - IndexModelStatusStateScalingUpPodSize IndexModelStatusState = "ScalingUpPodSize" - IndexModelStatusStateTerminating IndexModelStatusState = "Terminating" -) - -// Defines values for ServerlessSpecCloud. -const ( - Aws ServerlessSpecCloud = "aws" - Azure ServerlessSpecCloud = "azure" - Gcp ServerlessSpecCloud = "gcp" -) - -// CollectionList The list of collections that exist in the project. -type CollectionList struct { - Collections *[]CollectionModel `json:"collections,omitempty"` -} - -// CollectionModel The CollectionModel describes the configuration and status of a Pinecone collection. -type CollectionModel struct { - // Dimension The dimension of the vectors stored in each record held in the collection. - Dimension *int32 `json:"dimension,omitempty"` - - // Environment The environment where the collection is hosted. - Environment string `json:"environment"` - - // Name The name of the collection. - Name string `json:"name"` - - // Size The size of the collection in bytes. - Size *int64 `json:"size,omitempty"` - - // Status The status of the collection. - Status CollectionModelStatus `json:"status"` - - // VectorCount The number of records stored in the collection. - VectorCount *int32 `json:"vector_count,omitempty"` -} - -// CollectionModelStatus The status of the collection. -type CollectionModelStatus string - -// ConfigureIndexRequest Configuration used to scale an index. -type ConfigureIndexRequest struct { - // DeletionProtection Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index. - DeletionProtection *DeletionProtection `json:"deletion_protection,omitempty"` - Spec *struct { - Pod struct { - // PodType The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. - PodType *string `json:"pod_type,omitempty"` - - // Replicas The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. - Replicas *int32 `json:"replicas,omitempty"` - } `json:"pod"` - } `json:"spec,omitempty"` -} - -// CreateCollectionRequest The configuration needed to create a Pinecone collection. -type CreateCollectionRequest struct { - // Name The name of the collection to be created. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'. - Name string `json:"name"` - - // Source The name of the index to be used as the source for the collection. - Source string `json:"source"` -} - -// CreateIndexRequest The configuration needed to create a Pinecone index. -type CreateIndexRequest struct { - // DeletionProtection Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index. - DeletionProtection *DeletionProtection `json:"deletion_protection,omitempty"` - - // Dimension The dimensions of the vectors to be inserted in the index. - Dimension int32 `json:"dimension"` - - // Metric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. - Metric *CreateIndexRequestMetric `json:"metric,omitempty"` - - // Name The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'. - Name string `json:"name"` - - // Spec The spec object defines how the index should be deployed. - // - // For serverless indexes, you define only the [cloud and region](http://docs.pinecone.io/guides/indexes/understanding-indexes#cloud-regions) where the index should be hosted. For pod-based indexes, you define the [environment](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-environments) where the index should be hosted, the [pod type and size](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-types) to use, and other index characteristics. - Spec IndexSpec `json:"spec"` -} - -// CreateIndexRequestMetric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. -type CreateIndexRequestMetric string - -// DeletionProtection Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index. -type DeletionProtection string - -// ErrorResponse The response shape used for all error responses. -type ErrorResponse struct { - // Error Detailed information about the error that occurred. - Error struct { - Code ErrorResponseErrorCode `json:"code"` - - // Details Additional information about the error. This field is not guaranteed to be present. - Details *map[string]interface{} `json:"details,omitempty"` - Message string `json:"message"` - } `json:"error"` - - // Status The HTTP status code of the error. - Status int `json:"status"` -} - -// ErrorResponseErrorCode defines model for ErrorResponse.Error.Code. -type ErrorResponseErrorCode string - -// IndexList The list of indexes that exist in the project. -type IndexList struct { - Indexes *[]IndexModel `json:"indexes,omitempty"` -} - -// IndexModel The IndexModel describes the configuration and status of a Pinecone index. -type IndexModel struct { - // DeletionProtection Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index. - DeletionProtection *DeletionProtection `json:"deletion_protection,omitempty"` - - // Dimension The dimensions of the vectors to be inserted in the index. - Dimension int32 `json:"dimension"` - - // Host The URL address where the index is hosted. - Host string `json:"host"` - - // Metric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. - Metric IndexModelMetric `json:"metric"` - - // Name The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'. - Name string `json:"name"` - Spec struct { - // Pod Configuration needed to deploy a pod-based index. - Pod *PodSpec `json:"pod,omitempty"` - - // Serverless Configuration needed to deploy a serverless index. - Serverless *ServerlessSpec `json:"serverless,omitempty"` - } `json:"spec"` - Status struct { - Ready bool `json:"ready"` - State IndexModelStatusState `json:"state"` - } `json:"status"` -} - -// IndexModelMetric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. -type IndexModelMetric string - -// IndexModelStatusState defines model for IndexModel.Status.State. -type IndexModelStatusState string - -// IndexSpec The spec object defines how the index should be deployed. -// -// For serverless indexes, you define only the [cloud and region](http://docs.pinecone.io/guides/indexes/understanding-indexes#cloud-regions) where the index should be hosted. For pod-based indexes, you define the [environment](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-environments) where the index should be hosted, the [pod type and size](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-types) to use, and other index characteristics. -type IndexSpec struct { - // Pod Configuration needed to deploy a pod-based index. - Pod *PodSpec `json:"pod,omitempty"` - - // Serverless Configuration needed to deploy a serverless index. - Serverless *ServerlessSpec `json:"serverless,omitempty"` - union json.RawMessage -} - -// IndexSpec0 defines model for . -type IndexSpec0 = interface{} - -// IndexSpec1 defines model for . -type IndexSpec1 = interface{} - -// PodSpec Configuration needed to deploy a pod-based index. -type PodSpec struct { - // Environment The environment where the index is hosted. - Environment string `json:"environment"` - - // MetadataConfig Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. These configurations are only valid for use with pod-based indexes. - MetadataConfig *struct { - // Indexed By default, all metadata is indexed; to change this behavior, use this property to specify an array of metadata fields that should be indexed. - Indexed *[]string `json:"indexed,omitempty"` - } `json:"metadata_config,omitempty"` - - // PodType The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. - PodType string `json:"pod_type"` - - // Pods The number of pods to be used in the index. This should be equal to `shards` x `replicas`.' - Pods int `json:"pods"` - - // Replicas The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. - Replicas int32 `json:"replicas"` - - // Shards The number of shards. Shards split your data across multiple pods so you can fit more data into an index. - Shards int32 `json:"shards"` - - // SourceCollection The name of the collection to be used as the source for the index. - SourceCollection *string `json:"source_collection,omitempty"` -} - -// ServerlessSpec Configuration needed to deploy a serverless index. -type ServerlessSpec struct { - // Cloud The public cloud where you would like your index hosted. - Cloud ServerlessSpecCloud `json:"cloud"` - - // Region The region where you would like your index to be created. - Region string `json:"region"` -} - -// ServerlessSpecCloud The public cloud where you would like your index hosted. -type ServerlessSpecCloud string - -// CreateCollectionJSONRequestBody defines body for CreateCollection for application/json ContentType. -type CreateCollectionJSONRequestBody = CreateCollectionRequest - -// CreateIndexJSONRequestBody defines body for CreateIndex for application/json ContentType. -type CreateIndexJSONRequestBody = CreateIndexRequest - -// ConfigureIndexJSONRequestBody defines body for ConfigureIndex for application/json ContentType. -type ConfigureIndexJSONRequestBody = ConfigureIndexRequest - -// AsIndexSpec0 returns the union data inside the IndexSpec as a IndexSpec0 -func (t IndexSpec) AsIndexSpec0() (IndexSpec0, error) { - var body IndexSpec0 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIndexSpec0 overwrites any union data inside the IndexSpec as the provided IndexSpec0 -func (t *IndexSpec) FromIndexSpec0(v IndexSpec0) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIndexSpec0 performs a merge with any union data inside the IndexSpec, using the provided IndexSpec0 -func (t *IndexSpec) MergeIndexSpec0(v IndexSpec0) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsIndexSpec1 returns the union data inside the IndexSpec as a IndexSpec1 -func (t IndexSpec) AsIndexSpec1() (IndexSpec1, error) { - var body IndexSpec1 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIndexSpec1 overwrites any union data inside the IndexSpec as the provided IndexSpec1 -func (t *IndexSpec) FromIndexSpec1(v IndexSpec1) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIndexSpec1 performs a merge with any union data inside the IndexSpec, using the provided IndexSpec1 -func (t *IndexSpec) MergeIndexSpec1(v IndexSpec1) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t IndexSpec) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - if err != nil { - return nil, err - } - object := make(map[string]json.RawMessage) - if t.union != nil { - err = json.Unmarshal(b, &object) - if err != nil { - return nil, err - } - } - - if t.Pod != nil { - object["pod"], err = json.Marshal(t.Pod) - if err != nil { - return nil, fmt.Errorf("error marshaling 'pod': %w", err) - } - } - - if t.Serverless != nil { - object["serverless"], err = json.Marshal(t.Serverless) - if err != nil { - return nil, fmt.Errorf("error marshaling 'serverless': %w", err) - } - } - b, err = json.Marshal(object) - return b, err -} - -func (t *IndexSpec) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - if err != nil { - return err - } - object := make(map[string]json.RawMessage) - err = json.Unmarshal(b, &object) - if err != nil { - return err - } - - if raw, found := object["pod"]; found { - err = json.Unmarshal(raw, &t.Pod) - if err != nil { - return fmt.Errorf("error reading 'pod': %w", err) - } - } - - if raw, found := object["serverless"]; found { - err = json.Unmarshal(raw, &t.Serverless) - if err != nil { - return fmt.Errorf("error reading 'serverless': %w", err) - } - } - - return err -} - -// RequestEditorFn is the function signature for the RequestEditor callback function -type RequestEditorFn func(ctx context.Context, req *http.Request) error - -// Doer performs HTTP requests. -// -// The standard http.Client implements this interface. -type HttpRequestDoer interface { - Do(req *http.Request) (*http.Response, error) -} - -// Client which conforms to the OpenAPI3 specification for this service. -type Client struct { - // The endpoint of the server conforming to this interface, with scheme, - // https://api.deepmap.com for example. This can contain a path relative - // to the server, such as https://api.deepmap.com/dev-test, and all the - // paths in the swagger spec will be appended to the server. - Server string - - // Doer for performing requests, typically a *http.Client with any - // customized settings, such as certificate chains. - Client HttpRequestDoer - - // A list of callbacks for modifying requests which are generated before sending over - // the network. - RequestEditors []RequestEditorFn -} - -// ClientOption allows setting custom parameters during construction -type ClientOption func(*Client) error - -// Creates a new Client, with reasonable defaults -func NewClient(server string, opts ...ClientOption) (*Client, error) { - // create a client with sane default values - client := Client{ - Server: server, - } - // mutate client and add all optional params - for _, o := range opts { - if err := o(&client); err != nil { - return nil, err - } - } - // ensure the server URL always has a trailing slash - if !strings.HasSuffix(client.Server, "/") { - client.Server += "/" - } - // create httpClient, if not already present - if client.Client == nil { - client.Client = &http.Client{} - } - return &client, nil -} - -// WithHTTPClient allows overriding the default Doer, which is -// automatically created using http.Client. This is useful for tests. -func WithHTTPClient(doer HttpRequestDoer) ClientOption { - return func(c *Client) error { - c.Client = doer - return nil - } -} - -// WithRequestEditorFn allows setting up a callback function, which will be -// called right before sending the request. This can be used to mutate the request. -func WithRequestEditorFn(fn RequestEditorFn) ClientOption { - return func(c *Client) error { - c.RequestEditors = append(c.RequestEditors, fn) - return nil - } -} - -// The interface specification for the client above. -type ClientInterface interface { - // ListCollections request - ListCollections(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateCollectionWithBody request with any body - CreateCollectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateCollection(ctx context.Context, body CreateCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteCollection request - DeleteCollection(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DescribeCollection request - DescribeCollection(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListIndexes request - ListIndexes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateIndexWithBody request with any body - CreateIndexWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateIndex(ctx context.Context, body CreateIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteIndex request - DeleteIndex(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DescribeIndex request - DescribeIndex(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ConfigureIndexWithBody request with any body - ConfigureIndexWithBody(ctx context.Context, indexName string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - ConfigureIndex(ctx context.Context, indexName string, body ConfigureIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) ListCollections(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListCollectionsRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateCollectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateCollectionRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateCollection(ctx context.Context, body CreateCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateCollectionRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteCollection(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteCollectionRequest(c.Server, collectionName) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DescribeCollection(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDescribeCollectionRequest(c.Server, collectionName) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ListIndexes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListIndexesRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateIndexWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateIndexRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateIndex(ctx context.Context, body CreateIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateIndexRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DeleteIndex(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteIndexRequest(c.Server, indexName) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) DescribeIndex(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDescribeIndexRequest(c.Server, indexName) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ConfigureIndexWithBody(ctx context.Context, indexName string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewConfigureIndexRequestWithBody(c.Server, indexName, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ConfigureIndex(ctx context.Context, indexName string, body ConfigureIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewConfigureIndexRequest(c.Server, indexName, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -// NewListCollectionsRequest generates requests for ListCollections -func NewListCollectionsRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewCreateCollectionRequest calls the generic CreateCollection builder with application/json body -func NewCreateCollectionRequest(server string, body CreateCollectionJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateCollectionRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateCollectionRequestWithBody generates requests for CreateCollection with any type of body -func NewCreateCollectionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewDeleteCollectionRequest generates requests for DeleteCollection -func NewDeleteCollectionRequest(server string, collectionName string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_name", runtime.ParamLocationPath, collectionName) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewDescribeCollectionRequest generates requests for DescribeCollection -func NewDescribeCollectionRequest(server string, collectionName string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_name", runtime.ParamLocationPath, collectionName) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/collections/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewListIndexesRequest generates requests for ListIndexes -func NewListIndexesRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/indexes") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewCreateIndexRequest calls the generic CreateIndex builder with application/json body -func NewCreateIndexRequest(server string, body CreateIndexJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateIndexRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateIndexRequestWithBody generates requests for CreateIndex with any type of body -func NewCreateIndexRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/indexes") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewDeleteIndexRequest generates requests for DeleteIndex -func NewDeleteIndexRequest(server string, indexName string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "index_name", runtime.ParamLocationPath, indexName) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/indexes/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewDescribeIndexRequest generates requests for DescribeIndex -func NewDescribeIndexRequest(server string, indexName string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "index_name", runtime.ParamLocationPath, indexName) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/indexes/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewConfigureIndexRequest calls the generic ConfigureIndex builder with application/json body -func NewConfigureIndexRequest(server string, indexName string, body ConfigureIndexJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewConfigureIndexRequestWithBody(server, indexName, "application/json", bodyReader) -} - -// NewConfigureIndexRequestWithBody generates requests for ConfigureIndex with any type of body -func NewConfigureIndexRequestWithBody(server string, indexName string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "index_name", runtime.ParamLocationPath, indexName) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/indexes/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PATCH", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err - } - } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err - } - } - return nil -} - -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} - -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) - if err != nil { - return nil, err - } - return &ClientWithResponses{client}, nil -} - -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil - } -} - -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // ListCollectionsWithResponse request - ListCollectionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListCollectionsResponse, error) - - // CreateCollectionWithBodyWithResponse request with any body - CreateCollectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCollectionResponse, error) - - CreateCollectionWithResponse(ctx context.Context, body CreateCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCollectionResponse, error) - - // DeleteCollectionWithResponse request - DeleteCollectionWithResponse(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*DeleteCollectionResponse, error) - - // DescribeCollectionWithResponse request - DescribeCollectionWithResponse(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*DescribeCollectionResponse, error) - - // ListIndexesWithResponse request - ListIndexesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListIndexesResponse, error) - - // CreateIndexWithBodyWithResponse request with any body - CreateIndexWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateIndexResponse, error) - - CreateIndexWithResponse(ctx context.Context, body CreateIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateIndexResponse, error) - - // DeleteIndexWithResponse request - DeleteIndexWithResponse(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*DeleteIndexResponse, error) - - // DescribeIndexWithResponse request - DescribeIndexWithResponse(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*DescribeIndexResponse, error) - - // ConfigureIndexWithBodyWithResponse request with any body - ConfigureIndexWithBodyWithResponse(ctx context.Context, indexName string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConfigureIndexResponse, error) - - ConfigureIndexWithResponse(ctx context.Context, indexName string, body ConfigureIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*ConfigureIndexResponse, error) -} - -type ListCollectionsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CollectionList - JSON401 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r ListCollectionsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListCollectionsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *CollectionModel - JSON400 *ErrorResponse - JSON401 *ErrorResponse - JSON403 *ErrorResponse - JSON409 *ErrorResponse - JSON422 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r CreateCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON401 *ErrorResponse - JSON404 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r DeleteCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DescribeCollectionResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CollectionModel - JSON401 *ErrorResponse - JSON404 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r DescribeCollectionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DescribeCollectionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListIndexesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *IndexList - JSON401 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r ListIndexesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListIndexesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateIndexResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *IndexModel - JSON400 *ErrorResponse - JSON401 *ErrorResponse - JSON403 *ErrorResponse - JSON404 *ErrorResponse - JSON409 *ErrorResponse - JSON422 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r CreateIndexResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateIndexResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeleteIndexResponse struct { - Body []byte - HTTPResponse *http.Response - JSON401 *ErrorResponse - JSON404 *ErrorResponse - JSON412 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r DeleteIndexResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteIndexResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DescribeIndexResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *IndexModel - JSON401 *ErrorResponse - JSON404 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r DescribeIndexResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DescribeIndexResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ConfigureIndexResponse struct { - Body []byte - HTTPResponse *http.Response - JSON202 *IndexModel - JSON400 *ErrorResponse - JSON401 *ErrorResponse - JSON403 *ErrorResponse - JSON404 *ErrorResponse - JSON422 *ErrorResponse - JSON500 *ErrorResponse -} - -// Status returns HTTPResponse.Status -func (r ConfigureIndexResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ConfigureIndexResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -// ListCollectionsWithResponse request returning *ListCollectionsResponse -func (c *ClientWithResponses) ListCollectionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListCollectionsResponse, error) { - rsp, err := c.ListCollections(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseListCollectionsResponse(rsp) -} - -// CreateCollectionWithBodyWithResponse request with arbitrary body returning *CreateCollectionResponse -func (c *ClientWithResponses) CreateCollectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCollectionResponse, error) { - rsp, err := c.CreateCollectionWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateCollectionResponse(rsp) -} - -func (c *ClientWithResponses) CreateCollectionWithResponse(ctx context.Context, body CreateCollectionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCollectionResponse, error) { - rsp, err := c.CreateCollection(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateCollectionResponse(rsp) -} - -// DeleteCollectionWithResponse request returning *DeleteCollectionResponse -func (c *ClientWithResponses) DeleteCollectionWithResponse(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*DeleteCollectionResponse, error) { - rsp, err := c.DeleteCollection(ctx, collectionName, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteCollectionResponse(rsp) -} - -// DescribeCollectionWithResponse request returning *DescribeCollectionResponse -func (c *ClientWithResponses) DescribeCollectionWithResponse(ctx context.Context, collectionName string, reqEditors ...RequestEditorFn) (*DescribeCollectionResponse, error) { - rsp, err := c.DescribeCollection(ctx, collectionName, reqEditors...) - if err != nil { - return nil, err - } - return ParseDescribeCollectionResponse(rsp) -} - -// ListIndexesWithResponse request returning *ListIndexesResponse -func (c *ClientWithResponses) ListIndexesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListIndexesResponse, error) { - rsp, err := c.ListIndexes(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseListIndexesResponse(rsp) -} - -// CreateIndexWithBodyWithResponse request with arbitrary body returning *CreateIndexResponse -func (c *ClientWithResponses) CreateIndexWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateIndexResponse, error) { - rsp, err := c.CreateIndexWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateIndexResponse(rsp) -} - -func (c *ClientWithResponses) CreateIndexWithResponse(ctx context.Context, body CreateIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateIndexResponse, error) { - rsp, err := c.CreateIndex(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateIndexResponse(rsp) -} - -// DeleteIndexWithResponse request returning *DeleteIndexResponse -func (c *ClientWithResponses) DeleteIndexWithResponse(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*DeleteIndexResponse, error) { - rsp, err := c.DeleteIndex(ctx, indexName, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteIndexResponse(rsp) -} - -// DescribeIndexWithResponse request returning *DescribeIndexResponse -func (c *ClientWithResponses) DescribeIndexWithResponse(ctx context.Context, indexName string, reqEditors ...RequestEditorFn) (*DescribeIndexResponse, error) { - rsp, err := c.DescribeIndex(ctx, indexName, reqEditors...) - if err != nil { - return nil, err - } - return ParseDescribeIndexResponse(rsp) -} - -// ConfigureIndexWithBodyWithResponse request with arbitrary body returning *ConfigureIndexResponse -func (c *ClientWithResponses) ConfigureIndexWithBodyWithResponse(ctx context.Context, indexName string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConfigureIndexResponse, error) { - rsp, err := c.ConfigureIndexWithBody(ctx, indexName, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseConfigureIndexResponse(rsp) -} - -func (c *ClientWithResponses) ConfigureIndexWithResponse(ctx context.Context, indexName string, body ConfigureIndexJSONRequestBody, reqEditors ...RequestEditorFn) (*ConfigureIndexResponse, error) { - rsp, err := c.ConfigureIndex(ctx, indexName, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseConfigureIndexResponse(rsp) -} - -// ParseListCollectionsResponse parses an HTTP response from a ListCollectionsWithResponse call -func ParseListCollectionsResponse(rsp *http.Response) (*ListCollectionsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListCollectionsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CollectionList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseCreateCollectionResponse parses an HTTP response from a CreateCollectionWithResponse call -func ParseCreateCollectionResponse(rsp *http.Response) (*CreateCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest CollectionModel - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON403 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteCollectionResponse parses an HTTP response from a DeleteCollectionWithResponse call -func ParseDeleteCollectionResponse(rsp *http.Response) (*DeleteCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDescribeCollectionResponse parses an HTTP response from a DescribeCollectionWithResponse call -func ParseDescribeCollectionResponse(rsp *http.Response) (*DescribeCollectionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DescribeCollectionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CollectionModel - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseListIndexesResponse parses an HTTP response from a ListIndexesWithResponse call -func ParseListIndexesResponse(rsp *http.Response) (*ListIndexesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListIndexesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest IndexList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseCreateIndexResponse parses an HTTP response from a CreateIndexWithResponse call -func ParseCreateIndexResponse(rsp *http.Response) (*CreateIndexResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateIndexResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest IndexModel - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON403 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON409 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDeleteIndexResponse parses an HTTP response from a DeleteIndexWithResponse call -func ParseDeleteIndexResponse(rsp *http.Response) (*DeleteIndexResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteIndexResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON412 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseDescribeIndexResponse parses an HTTP response from a DescribeIndexWithResponse call -func ParseDescribeIndexResponse(rsp *http.Response) (*DescribeIndexResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DescribeIndexResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest IndexModel - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} - -// ParseConfigureIndexResponse parses an HTTP response from a ConfigureIndexWithResponse call -func ParseConfigureIndexResponse(rsp *http.Response) (*ConfigureIndexResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ConfigureIndexResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: - var dest IndexModel - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON202 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON401 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON403 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON422 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON500 = &dest - - } - - return response, nil -} diff --git a/internal/gen/db_control/db_control_2024-10.oas.go b/internal/gen/db_control/db_control_2024-10.oas.go index 5088e89..9415ad2 100644 --- a/internal/gen/db_control/db_control_2024-10.oas.go +++ b/internal/gen/db_control/db_control_2024-10.oas.go @@ -53,6 +53,7 @@ const ( NOTFOUND ErrorResponseErrorCode = "NOT_FOUND" OK ErrorResponseErrorCode = "OK" OUTOFRANGE ErrorResponseErrorCode = "OUT_OF_RANGE" + PAYMENTREQUIRED ErrorResponseErrorCode = "PAYMENT_REQUIRED" PERMISSIONDENIED ErrorResponseErrorCode = "PERMISSION_DENIED" QUOTAEXCEEDED ErrorResponseErrorCode = "QUOTA_EXCEEDED" RESOURCEEXHAUSTED ErrorResponseErrorCode = "RESOURCE_EXHAUSTED" @@ -131,6 +132,9 @@ type ConfigureIndexRequest struct { Replicas *int32 `json:"replicas,omitempty"` } `json:"pod"` } `json:"spec,omitempty"` + + // Tags Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less. + Tags *IndexTags `json:"tags,omitempty"` } // CreateCollectionRequest The configuration needed to create a Pinecone collection. @@ -160,6 +164,9 @@ type CreateIndexRequest struct { // // For serverless indexes, you define only the [cloud and region](http://docs.pinecone.io/guides/indexes/understanding-indexes#cloud-regions) where the index should be hosted. For pod-based indexes, you define the [environment](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-environments) where the index should be hosted, the [pod type and size](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-types) to use, and other index characteristics. Spec IndexSpec `json:"spec"` + + // Tags Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less. + Tags *IndexTags `json:"tags,omitempty"` } // CreateIndexRequestMetric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. @@ -218,6 +225,9 @@ type IndexModel struct { Ready bool `json:"ready"` State IndexModelStatusState `json:"state"` } `json:"status"` + + // Tags Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less. + Tags *IndexTags `json:"tags,omitempty"` } // IndexModelMetric The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. @@ -244,6 +254,9 @@ type IndexSpec0 = interface{} // IndexSpec1 defines model for . type IndexSpec1 = interface{} +// IndexTags Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less. +type IndexTags map[string]*string + // PodSpec Configuration needed to deploy a pod-based index. type PodSpec struct { // Environment The environment where the index is hosted. @@ -1077,6 +1090,7 @@ type CreateCollectionResponse struct { JSON201 *CollectionModel JSON400 *ErrorResponse JSON401 *ErrorResponse + JSON402 *ErrorResponse JSON403 *ErrorResponse JSON409 *ErrorResponse JSON422 *ErrorResponse @@ -1178,6 +1192,7 @@ type CreateIndexResponse struct { JSON201 *IndexModel JSON400 *ErrorResponse JSON401 *ErrorResponse + JSON402 *ErrorResponse JSON403 *ErrorResponse JSON404 *ErrorResponse JSON409 *ErrorResponse @@ -1257,6 +1272,7 @@ type ConfigureIndexResponse struct { JSON202 *IndexModel JSON400 *ErrorResponse JSON401 *ErrorResponse + JSON402 *ErrorResponse JSON403 *ErrorResponse JSON404 *ErrorResponse JSON422 *ErrorResponse @@ -1459,6 +1475,13 @@ func ParseCreateCollectionResponse(rsp *http.Response) (*CreateCollectionRespons } response.JSON401 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -1654,6 +1677,13 @@ func ParseCreateIndexResponse(rsp *http.Response) (*CreateIndexResponse, error) } response.JSON401 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -1823,6 +1853,13 @@ func ParseConfigureIndexResponse(rsp *http.Response) (*ConfigureIndexResponse, e } response.JSON401 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { diff --git a/internal/gen/data/db_data_2024-10.pb.go b/internal/gen/db_data/grpc/db_data_2024-10.pb.go similarity index 99% rename from internal/gen/data/db_data_2024-10.pb.go rename to internal/gen/db_data/grpc/db_data_2024-10.pb.go index 04960b8..b7bdd83 100644 --- a/internal/gen/data/db_data_2024-10.pb.go +++ b/internal/gen/db_data/grpc/db_data_2024-10.pb.go @@ -4,7 +4,7 @@ // protoc v5.27.1 // source: db_data_2024-10.proto -package data +package grpc import ( _ "google.golang.org/genproto/googleapis/api/annotations" @@ -1870,12 +1870,13 @@ var file_db_data_2024_10_proto_rawDesc = []byte{ 0x02, 0x33, 0x3a, 0x01, 0x2a, 0x5a, 0x17, 0x12, 0x15, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x22, 0x15, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, - 0x73, 0x74, 0x61, 0x74, 0x73, 0x42, 0x4b, 0x0a, 0x11, 0x69, 0x6f, 0x2e, 0x70, 0x69, 0x6e, 0x65, - 0x63, 0x6f, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x42, 0x53, 0x0a, 0x11, 0x69, 0x6f, 0x2e, 0x70, 0x69, 0x6e, 0x65, + 0x63, 0x6f, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x6e, 0x65, 0x63, 0x6f, 0x6e, 0x65, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x70, 0x69, 0x6e, 0x65, 0x63, 0x6f, 0x6e, 0x65, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x64, 0x61, - 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x64, 0x62, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/internal/gen/data/db_data_2024-10_grpc.pb.go b/internal/gen/db_data/grpc/db_data_2024-10_grpc.pb.go similarity index 99% rename from internal/gen/data/db_data_2024-10_grpc.pb.go rename to internal/gen/db_data/grpc/db_data_2024-10_grpc.pb.go index 88de85e..c296696 100644 --- a/internal/gen/data/db_data_2024-10_grpc.pb.go +++ b/internal/gen/db_data/grpc/db_data_2024-10_grpc.pb.go @@ -4,7 +4,7 @@ // - protoc v5.27.1 // source: db_data_2024-10.proto -package data +package grpc import ( context "context" diff --git a/internal/gen/inference/inference_2024-10.oas.go b/internal/gen/inference/inference_2024-10.oas.go index 580b724..13b2a59 100644 --- a/internal/gen/inference/inference_2024-10.oas.go +++ b/internal/gen/inference/inference_2024-10.oas.go @@ -45,12 +45,12 @@ type Document map[string]string // EmbedRequest defines model for EmbedRequest. type EmbedRequest struct { - // Inputs List of inputs to generate embeddings for that varies by model + // Inputs List of inputs to generate embeddings for. Inputs []struct { Text *string `json:"text,omitempty"` } `json:"inputs"` - // Model Model name to use for embedding generation. + // Model The [model](https://docs.pinecone.io/guides/inference/understanding-inference#models) to use for embedding generation. Model string `json:"model"` // Parameters Model-specific parameters. @@ -58,7 +58,7 @@ type EmbedRequest struct { // InputType Common property used to distinguish between types of data. InputType *string `json:"input_type,omitempty"` - // Truncate How to handle inputs longer than those supported by the model. If NONE, when the input exceeds the maximum input token length an error will be returned. + // Truncate How to handle inputs longer than those supported by the model. If `"END"`, truncate the input sequence at the token limit. If `"NONE"`, return an error when the input exceeds the token limit. Truncate *string `json:"truncate,omitempty"` } `json:"parameters,omitempty"` } @@ -71,15 +71,15 @@ type Embedding struct { // EmbeddingsList Embeddings generated for the input type EmbeddingsList struct { - // Data The embeddings generated for the inputs + // Data The embeddings generated for the inputs. Data []Embedding `json:"data"` // Model The model used to generate the embeddings Model string `json:"model"` - // Usage Usage statistics for model inference including any instruction prefixes + // Usage Usage statistics for the model inference. Usage struct { - // TotalTokens Total number tokens consumed across all inputs + // TotalTokens Total number of tokens consumed across all inputs. TotalTokens *int `json:"total_tokens,omitempty"` } `json:"usage"` } @@ -102,33 +102,47 @@ type ErrorResponse struct { // ErrorResponseErrorCode defines model for ErrorResponse.Error.Code. type ErrorResponseErrorCode string -// RankResult Reranking score of single input -type RankResult struct { +// RankedDocument A ranked document with a relevance score and an index position. +type RankedDocument struct { // Document Document for reranking Document *Document `json:"document,omitempty"` - // Index The index of the document in the input list + // Index The index of the document Index int `json:"index"` // Score The relevance score of the document normalized between 0 and 1. Score float32 `json:"score"` } +// RerankResult The result of a reranking request. +type RerankResult struct { + // Data The reranked documents. + Data []RankedDocument `json:"data"` + + // Model The model used to rerank documents. + Model string `json:"model"` + + // Usage Usage statistics for the model inference. + Usage struct { + RerankUnits *int `json:"rerank_units,omitempty"` + } `json:"usage"` +} + // RerankJSONBody defines parameters for Rerank. type RerankJSONBody struct { // Documents The documents to rerank. Documents []Document `json:"documents"` - // Model Model to use for reranking. + // Model The [model](https://docs.pinecone.io/guides/inference/understanding-inference#models) to use for reranking. Model string `json:"model"` - // Parameters Additional model specific parameters for the reranker. + // Parameters Additional model-specific parameters for the reranker. Parameters *map[string]string `json:"parameters,omitempty"` // Query The query to rerank documents against. Query string `json:"query"` - // RankFields The fields to rank the documents by. If not provided the default is text. + // RankFields The fields to rank the documents by. If not provided, the default is `"text"`. RankFields *[]string `json:"rank_fields,omitempty"` // ReturnDocuments Whether to return the documents in the response. @@ -438,21 +452,10 @@ func (r EmbedResponse) StatusCode() int { type RerankResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *struct { - // Data The reranked documents - Data []RankResult `json:"data"` - - // Model The model used for reranking - Model string `json:"model"` - - // Usage Usage statistics for the inference - Usage struct { - RerankUnits *int `json:"rerank_units,omitempty"` - } `json:"usage"` - } - JSON400 *ErrorResponse - JSON401 *ErrorResponse - JSON500 *ErrorResponse + JSON200 *RerankResult + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON500 *ErrorResponse } // Status returns HTTPResponse.Status @@ -567,18 +570,7 @@ func ParseRerankResponse(rsp *http.Response) (*RerankResponse, error) { switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - // Data The reranked documents - Data []RankResult `json:"data"` - - // Model The model used for reranking - Model string `json:"model"` - - // Usage Usage statistics for the inference - Usage struct { - RerankUnits *int `json:"rerank_units,omitempty"` - } `json:"usage"` - } + var dest RerankResult if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } diff --git a/pinecone/client.go b/pinecone/client.go index fc5d646..2899eb7 100644 --- a/pinecone/client.go +++ b/pinecone/client.go @@ -1325,15 +1325,7 @@ func (i *InferenceService) Embed(ctx context.Context, in *EmbedRequest) (*infere return decodeEmbeddingsList(res.Body) } -// Document represents a single document to be reranked. -// -// Fields: -// - ID: (Required) The unique identifier of the document. -// - Text: (Required) The text content of the document. -type Document struct { - Id string - Text string -} +type Document map[string]string // RerankRequest holds the parameters for reranking a list of documents based on a query. // @@ -1344,23 +1336,25 @@ type Document struct { // - TopN: (Required) The number of top documents to return after reranking. // - Documents: (Required) A list of Document objects to be reranked. type RerankRequest struct { + Documents []Document Model string Query string - ReturnDocuments bool - TopN int - Documents []Document + Parameters *map[string]string + RankFields *[]string + ReturnDocuments *bool + TopN *int } -type RankResult struct { +type RerankResult struct { Document *Document `json:"document,omitempty"` Index IntegrationTests `json:"index"` Score float32 `json:"score"` } type RerankResponse struct { - Data []RankResult `json:"data,omitempty"` - Model string `json:"model,omitempty"` - Usage RerankUsage `json:"usage"` + Data []RerankResult `json:"data,omitempty"` + Model string `json:"model,omitempty"` + Usage RerankUsage `json:"usage"` } // Rerank processes the reranking of documents based on the provided query and model. @@ -1404,20 +1398,15 @@ type RerankResponse struct { // fmt.Printf("Successfully reranked documents: %+v", res) // } func (i *InferenceService) Rerank(ctx context.Context, in *RerankRequest) (*RerankResponse, error) { - - if len(in.Documents) <= 2 { - return nil, fmt.Errorf("documents must contain at least more than two value") - } - // Convert documents to the expected type convertedDocuments := make([]inference.Document, len(in.Documents)) for i, doc := range in.Documents { - convertedDocuments[i] = inference.Document{"Id": doc.Id, "Text": doc.Text} + convertedDocuments[i] = inference.Document(doc) } req := inference.RerankJSONRequestBody{ Model: in.Model, Query: in.Query, - ReturnDocuments: &in.ReturnDocuments, - TopN: &in.TopN, + ReturnDocuments: in.ReturnDocuments, + TopN: in.TopN, Documents: convertedDocuments, } res, err := i.client.Rerank(ctx, req) diff --git a/pinecone/client_test.go b/pinecone/client_test.go index 6b15a33..bf473ee 100644 --- a/pinecone/client_test.go +++ b/pinecone/client_test.go @@ -316,21 +316,23 @@ func (ts *IntegrationTests) TestGenerateEmbeddingsInvalidInputs() { func (ts *IntegrationTests) TestRerankDocument() { ctx := context.Background() rerankModel := "bge-reranker-v2-m3" + topN := 4 ranking, err := ts.client.Inference.Rerank(ctx, &RerankRequest{ Model: rerankModel, - Query: "The tech company Apple is known for its innovative products like the iPhone.", - ReturnDocuments: true, - TopN: 4, + Query: "i love cats", + ReturnDocuments: nil, + TopN: &topN, + RankFields: &[]string{"text"}, Documents: []Document{ - {Id: "vec1", Text: "Apple is a popular fruit known for its sweetness and crisp texture."}, - {Id: "vec2", Text: "Many people enjoy eating apples as a healthy snack."}, - {Id: "vec3", Text: "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, - {Id: "vec4", Text: "An apple a day keeps the doctor away, as the saying goes."}, + {"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."}, + {"id": "vec2", "text": "Many people enjoy eating apples as a healthy snack."}, + {"id": "vec3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, + {"id": "vec4", "text": "An apple a day keeps the doctor away, as the saying goes."}, }}) require.NoError(ts.T(), err) require.NotNil(ts.T(), ranking, "Expected reranking result to be non-nil") - require.Equal(ts.T(), 4, len(*ranking.Data), "Expected 4 rankings") + require.Equal(ts.T(), 4, len(ranking.Data), "Expected 4 rankings") } // Unit tests: diff --git a/pinecone/index_connection.go b/pinecone/index_connection.go index 3fc5202..23b3f1f 100644 --- a/pinecone/index_connection.go +++ b/pinecone/index_connection.go @@ -8,7 +8,7 @@ import ( "net/url" "strings" - "github.com/pinecone-io/go-pinecone/internal/gen/data" + db_data "github.com/pinecone-io/go-pinecone/internal/gen/db_data/grpc" "github.com/pinecone-io/go-pinecone/internal/useragent" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -26,7 +26,7 @@ import ( type IndexConnection struct { Namespace string additionalMetadata map[string]string - dataClient *data.VectorServiceClient + dataClient *db_data.VectorServiceClient grpcConn *grpc.ClientConn } @@ -65,7 +65,7 @@ func newIndexConnection(in newIndexParameters, dialOpts ...grpc.DialOption) (*In return nil, err } - dataClient := data.NewVectorServiceClient(conn) + dataClient := db_data.NewVectorServiceClient(conn) idx := IndexConnection{ Namespace: in.namespace, @@ -185,12 +185,12 @@ func (idx *IndexConnection) Close() error { // log.Fatalf("Successfully upserted %d vector(s)!\n", count) // } func (idx *IndexConnection) UpsertVectors(ctx context.Context, in []*Vector) (uint32, error) { - vectors := make([]*data.Vector, len(in)) + vectors := make([]*db_data.Vector, len(in)) for i, v := range in { vectors[i] = vecToGrpc(v) } - req := &data.UpsertRequest{ + req := &db_data.UpsertRequest{ Vectors: vectors, Namespace: idx.Namespace, } @@ -263,7 +263,7 @@ type FetchVectorsResponse struct { // fmt.Println("No vectors found") // } func (idx *IndexConnection) FetchVectors(ctx context.Context, ids []string) (*FetchVectorsResponse, error) { - req := &data.FetchRequest{ + req := &db_data.FetchRequest{ Ids: ids, Namespace: idx.Namespace, } @@ -371,7 +371,7 @@ type ListVectorsResponse struct { // fmt.Printf("Found %d vector(s)\n", len(res.VectorIds)) // } func (idx *IndexConnection) ListVectors(ctx context.Context, in *ListVectorsRequest) (*ListVectorsResponse, error) { - req := &data.ListRequest{ + req := &db_data.ListRequest{ Prefix: in.Prefix, Limit: in.Limit, PaginationToken: in.PaginationToken, @@ -501,7 +501,7 @@ type QueryVectorsResponse struct { // } // } func (idx *IndexConnection) QueryByVectorValues(ctx context.Context, in *QueryByVectorValuesRequest) (*QueryVectorsResponse, error) { - req := &data.QueryRequest{ + req := &db_data.QueryRequest{ Namespace: idx.Namespace, TopK: in.TopK, Filter: in.MetadataFilter, @@ -591,7 +591,7 @@ type QueryByVectorIdRequest struct { // } // } func (idx *IndexConnection) QueryByVectorId(ctx context.Context, in *QueryByVectorIdRequest) (*QueryVectorsResponse, error) { - req := &data.QueryRequest{ + req := &db_data.QueryRequest{ Id: in.VectorId, Namespace: idx.Namespace, TopK: in.TopK, @@ -652,7 +652,7 @@ func (idx *IndexConnection) QueryByVectorId(ctx context.Context, in *QueryByVect // log.Fatalf("Failed to delete vector with ID: %s. Error: %s\n", vectorId, err) // } func (idx *IndexConnection) DeleteVectorsById(ctx context.Context, ids []string) error { - req := data.DeleteRequest{ + req := db_data.DeleteRequest{ Ids: ids, Namespace: idx.Namespace, } @@ -716,7 +716,7 @@ func (idx *IndexConnection) DeleteVectorsById(ctx context.Context, ids []string) // log.Fatalf("Failed to delete vector(s) with filter: %+v. Error: %s\n", filter, err) // } func (idx *IndexConnection) DeleteVectorsByFilter(ctx context.Context, metadataFilter *MetadataFilter) error { - req := data.DeleteRequest{ + req := db_data.DeleteRequest{ Filter: metadataFilter, Namespace: idx.Namespace, } @@ -768,7 +768,7 @@ func (idx *IndexConnection) DeleteVectorsByFilter(ctx context.Context, metadataF // log.Fatalf("Failed to delete vectors in namespace: \"%s\". Error: %s", idxConnection.Namespace, err) // } func (idx *IndexConnection) DeleteAllVectorsInNamespace(ctx context.Context) error { - req := data.DeleteRequest{ + req := db_data.DeleteRequest{ Namespace: idx.Namespace, DeleteAll: true, } @@ -842,7 +842,7 @@ func (idx *IndexConnection) UpdateVector(ctx context.Context, in *UpdateVectorRe return fmt.Errorf("a vector ID plus at least one of Values, SparseValues, or Metadata must be provided to update a vector") } - req := &data.UpdateRequest{ + req := &db_data.UpdateRequest{ Id: in.Id, Values: in.Values, SparseValues: sparseValToGrpc(in.SparseValues), @@ -973,7 +973,7 @@ func (idx *IndexConnection) DescribeIndexStats(ctx context.Context) (*DescribeIn // } // } func (idx *IndexConnection) DescribeIndexStatsFiltered(ctx context.Context, metadataFilter *MetadataFilter) (*DescribeIndexStatsResponse, error) { - req := &data.DescribeIndexStatsRequest{ + req := &db_data.DescribeIndexStatsRequest{ Filter: metadataFilter, } res, err := (*idx.dataClient).DescribeIndexStats(idx.akCtx(ctx), req) @@ -996,7 +996,7 @@ func (idx *IndexConnection) DescribeIndexStatsFiltered(ctx context.Context, meta }, nil } -func (idx *IndexConnection) query(ctx context.Context, req *data.QueryRequest) (*QueryVectorsResponse, error) { +func (idx *IndexConnection) query(ctx context.Context, req *db_data.QueryRequest) (*QueryVectorsResponse, error) { res, err := (*idx.dataClient).Query(idx.akCtx(ctx), req) if err != nil { return nil, err @@ -1014,7 +1014,7 @@ func (idx *IndexConnection) query(ctx context.Context, req *data.QueryRequest) ( }, nil } -func (idx *IndexConnection) delete(ctx context.Context, req *data.DeleteRequest) error { +func (idx *IndexConnection) delete(ctx context.Context, req *db_data.DeleteRequest) error { _, err := (*idx.dataClient).Delete(idx.akCtx(ctx), req) return err } @@ -1029,7 +1029,7 @@ func (idx *IndexConnection) akCtx(ctx context.Context) context.Context { return metadata.AppendToOutgoingContext(ctx, newMetadata...) } -func toVector(vector *data.Vector) *Vector { +func toVector(vector *db_data.Vector) *Vector { if vector == nil { return nil } @@ -1041,11 +1041,11 @@ func toVector(vector *data.Vector) *Vector { } } -func toScoredVector(sv *data.ScoredVector) *ScoredVector { +func toScoredVector(sv *db_data.ScoredVector) *ScoredVector { if sv == nil { return nil } - v := toVector(&data.Vector{ + v := toVector(&db_data.Vector{ Id: sv.Id, Values: sv.Values, SparseValues: sv.SparseValues, @@ -1057,7 +1057,7 @@ func toScoredVector(sv *data.ScoredVector) *ScoredVector { } } -func toSparseValues(sv *data.SparseValues) *SparseValues { +func toSparseValues(sv *db_data.SparseValues) *SparseValues { if sv == nil { return nil } @@ -1067,7 +1067,7 @@ func toSparseValues(sv *data.SparseValues) *SparseValues { } } -func toUsage(u *data.Usage) *Usage { +func toUsage(u *db_data.Usage) *Usage { if u == nil { return nil } @@ -1076,18 +1076,18 @@ func toUsage(u *data.Usage) *Usage { } } -func toPaginationToken(p *data.Pagination) *string { +func toPaginationToken(p *db_data.Pagination) *string { if p == nil { return nil } return &p.Next } -func vecToGrpc(v *Vector) *data.Vector { +func vecToGrpc(v *Vector) *db_data.Vector { if v == nil { return nil } - return &data.Vector{ + return &db_data.Vector{ Id: v.Id, Values: v.Values, Metadata: v.Metadata, @@ -1095,11 +1095,11 @@ func vecToGrpc(v *Vector) *data.Vector { } } -func sparseValToGrpc(sv *SparseValues) *data.SparseValues { +func sparseValToGrpc(sv *SparseValues) *db_data.SparseValues { if sv == nil { return nil } - return &data.SparseValues{ + return &db_data.SparseValues{ Indices: sv.Indices, Values: sv.Values, } diff --git a/pinecone/index_connection_test.go b/pinecone/index_connection_test.go index adc98ff..0d4fbb2 100644 --- a/pinecone/index_connection_test.go +++ b/pinecone/index_connection_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/pinecone-io/go-pinecone/internal/gen/data" + db_data_grpc "github.com/pinecone-io/go-pinecone/internal/gen/db_data/grpc" "github.com/pinecone-io/go-pinecone/internal/utils" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -518,7 +518,7 @@ func TestMarshalDescribeIndexStatsResponseUnit(t *testing.T) { func TestToVectorUnit(t *testing.T) { tests := []struct { name string - vector *data.Vector + vector *db_data_grpc.Vector expected *Vector }{ { @@ -528,7 +528,7 @@ func TestToVectorUnit(t *testing.T) { }, { name: "Pass dense vector", - vector: &data.Vector{ + vector: &db_data_grpc.Vector{ Id: "dense-1", Values: []float32{0.01, 0.02, 0.03}, }, @@ -539,10 +539,10 @@ func TestToVectorUnit(t *testing.T) { }, { name: "Pass sparse vector", - vector: &data.Vector{ + vector: &db_data_grpc.Vector{ Id: "sparse-1", Values: nil, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -558,10 +558,10 @@ func TestToVectorUnit(t *testing.T) { }, { name: "Pass hybrid vector", - vector: &data.Vector{ + vector: &db_data_grpc.Vector{ Id: "hybrid-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -578,10 +578,10 @@ func TestToVectorUnit(t *testing.T) { }, { name: "Pass hybrid vector with metadata", - vector: &data.Vector{ + vector: &db_data_grpc.Vector{ Id: "hybrid-metadata-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -616,7 +616,7 @@ func TestToVectorUnit(t *testing.T) { func TestToSparseValuesUnit(t *testing.T) { tests := []struct { name string - sparseValues *data.SparseValues + sparseValues *db_data_grpc.SparseValues expected *SparseValues }{ { @@ -626,7 +626,7 @@ func TestToSparseValuesUnit(t *testing.T) { }, { name: "Pass sparse values", - sparseValues: &data.SparseValues{ + sparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -647,7 +647,7 @@ func TestToSparseValuesUnit(t *testing.T) { func TestToScoredVectorUnit(t *testing.T) { tests := []struct { name string - scoredVector *data.ScoredVector + scoredVector *db_data_grpc.ScoredVector expected *ScoredVector }{ { @@ -657,7 +657,7 @@ func TestToScoredVectorUnit(t *testing.T) { }, { name: "Pass scored dense vector", - scoredVector: &data.ScoredVector{ + scoredVector: &db_data_grpc.ScoredVector{ Id: "dense-1", Values: []float32{0.01, 0.01, 0.01}, Score: 0.1, @@ -672,9 +672,9 @@ func TestToScoredVectorUnit(t *testing.T) { }, { name: "Pass scored sparse vector", - scoredVector: &data.ScoredVector{ + scoredVector: &db_data_grpc.ScoredVector{ Id: "sparse-1", - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -693,10 +693,10 @@ func TestToScoredVectorUnit(t *testing.T) { }, { name: "Pass scored hybrid vector", - scoredVector: &data.ScoredVector{ + scoredVector: &db_data_grpc.ScoredVector{ Id: "hybrid-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -716,10 +716,10 @@ func TestToScoredVectorUnit(t *testing.T) { }, { name: "Pass scored hybrid vector with metadata", - scoredVector: &data.ScoredVector{ + scoredVector: &db_data_grpc.ScoredVector{ Id: "hybrid-metadata-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -760,7 +760,7 @@ func TestVecToGrpcUnit(t *testing.T) { tests := []struct { name string vector *Vector - expected *data.Vector + expected *db_data_grpc.Vector }{ { name: "Pass nil vector, expect nil to be returned", @@ -773,7 +773,7 @@ func TestVecToGrpcUnit(t *testing.T) { Id: "dense-1", Values: []float32{0.01, 0.02, 0.03}, }, - expected: &data.Vector{ + expected: &db_data_grpc.Vector{ Id: "dense-1", Values: []float32{0.01, 0.02, 0.03}, }, @@ -788,9 +788,9 @@ func TestVecToGrpcUnit(t *testing.T) { Values: []float32{0.01, 0.03}, }, }, - expected: &data.Vector{ + expected: &db_data_grpc.Vector{ Id: "sparse-1", - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -806,10 +806,10 @@ func TestVecToGrpcUnit(t *testing.T) { Values: []float32{0.01, 0.03}, }, }, - expected: &data.Vector{ + expected: &db_data_grpc.Vector{ Id: "hybrid-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -830,10 +830,10 @@ func TestVecToGrpcUnit(t *testing.T) { }, }, }, - expected: &data.Vector{ + expected: &db_data_grpc.Vector{ Id: "hybrid-metadata-1", Values: []float32{0.01, 0.02, 0.03}, - SparseValues: &data.SparseValues{ + SparseValues: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -859,7 +859,7 @@ func TestSparseValToGrpcUnit(t *testing.T) { name string sparseValues *SparseValues metadata *structpb.Struct - expected *data.SparseValues + expected *db_data_grpc.SparseValues }{ { name: "Pass nil sparse values, expect nil to be returned", @@ -872,7 +872,7 @@ func TestSparseValToGrpcUnit(t *testing.T) { Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, - expected: &data.SparseValues{ + expected: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -888,7 +888,7 @@ func TestSparseValToGrpcUnit(t *testing.T) { "genre": {Kind: &structpb.Value_StringValue{StringValue: "classical"}}, }, }, - expected: &data.SparseValues{ + expected: &db_data_grpc.SparseValues{ Indices: []uint32{0, 2}, Values: []float32{0.01, 0.03}, }, @@ -971,7 +971,7 @@ func TestToUsageUnit(t *testing.T) { tests := []struct { name string - usage *data.Usage + usage *db_data_grpc.Usage expected *Usage }{ { @@ -981,7 +981,7 @@ func TestToUsageUnit(t *testing.T) { }, { name: "Pass usage", - usage: &data.Usage{ + usage: &db_data_grpc.Usage{ ReadUnits: &u5, }, expected: &Usage{ @@ -1033,17 +1033,17 @@ func TestToPaginationToken(t *testing.T) { tests := []struct { name string - token *data.Pagination + token *db_data_grpc.Pagination expected *string }{ { name: "Pass empty token, expect empty string to be returned", - token: &data.Pagination{}, + token: &db_data_grpc.Pagination{}, expected: &tokenForNilCase, }, { name: "Pass token", - token: &data.Pagination{ + token: &db_data_grpc.Pagination{ Next: "next-token", }, expected: &tokenForPositiveCase,