Class: Pinecone::Collection

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pinecone/collection.rb

Instance Method Summary collapse

Constructor Details

#initializeCollection

Returns a new instance of Collection.



6
7
8
9
10
11
12
13
14
# File 'lib/pinecone/collection.rb', line 6

def initialize
  self.class.base_uri "https://api.pinecone.io"

  @headers = {
    "Content-Type" => "application/json",
    "Accept" => "application/json",
    "Api-Key" => Pinecone.configuration.api_key
  }
end

Instance Method Details

#create(body) ⇒ Object



24
25
26
27
# File 'lib/pinecone/collection.rb', line 24

def create(body)
  payload = options.merge(body: body.to_json)
  self.class.post("/collections", payload)
end

#delete(collection_name) ⇒ Object



29
30
31
# File 'lib/pinecone/collection.rb', line 29

def delete(collection_name)
  self.class.delete("/collections/#{collection_name}", options)
end

#describe(collection_name) ⇒ Object



20
21
22
# File 'lib/pinecone/collection.rb', line 20

def describe(collection_name)
  self.class.get("/collections/#{collection_name}", options)
end

#listObject



16
17
18
# File 'lib/pinecone/collection.rb', line 16

def list
  self.class.get("/collections", options)
end

#optionsObject



33
34
35
36
37
# File 'lib/pinecone/collection.rb', line 33

def options
  {
    headers: @headers
  }
end