Class: Supabase::Storage::VectorBucketScope

Inherits:
Object
  • Object
show all
Defined in:
lib/supabase/storage/vectors.rb

Overview

A bucket-scoped facade. Mirrors storage3’s ‘SyncVectorBucketScope`.

Instance Method Summary collapse

Constructor Details

#initialize(vectors_client, bucket_name) ⇒ VectorBucketScope

Returns a new instance of VectorBucketScope.



68
69
70
71
# File 'lib/supabase/storage/vectors.rb', line 68

def initialize(vectors_client, bucket_name)
  @client      = vectors_client
  @bucket_name = bucket_name
end

Instance Method Details

#create_index(index_name, dimension, distance_metric, data_type, metadata: nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/supabase/storage/vectors.rb', line 73

def create_index(index_name, dimension, distance_metric, data_type, metadata: nil)
  json = (
    "indexName"             => index_name,
    "dimension"             => dimension,
    "distanceMetric"        => distance_metric,
    "dataType"              => data_type,
    "metadataConfiguration" => 
  )
  @client.send_action(path: "CreateIndex", json: json)
  nil
end

#delete_index(index_name) ⇒ Object



98
99
100
101
# File 'lib/supabase/storage/vectors.rb', line 98

def delete_index(index_name)
  @client.send_action(path: "DeleteIndex", json: ("indexName" => index_name))
  nil
end

#get_index(index_name) ⇒ Object



85
86
87
88
89
90
# File 'lib/supabase/storage/vectors.rb', line 85

def get_index(index_name)
  body = @client.send_action(path: "GetIndex", json: ("indexName" => index_name))
  Types::GetVectorIndexResponse.from_hash(body)
rescue Errors::StorageApiError
  nil
end

#index(index_name) ⇒ Object



103
104
105
# File 'lib/supabase/storage/vectors.rb', line 103

def index(index_name)
  VectorIndexScope.new(@client, @bucket_name, index_name)
end

#list_indexes(next_token: nil, max_results: nil, prefix: nil) ⇒ Object



92
93
94
95
96
# File 'lib/supabase/storage/vectors.rb', line 92

def list_indexes(next_token: nil, max_results: nil, prefix: nil)
  json = ("next_token" => next_token, "max_results" => max_results, "prefix" => prefix)
  body = @client.send_action(path: "ListIndexes", json: json)
  Types::ListVectorIndexesResponse.from_hash(body)
end