Class: Pinecone::Index

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

Instance Method Summary collapse

Constructor Details

#initializeIndex

Returns a new instance of Index.



6
7
8
9
10
11
12
13
# File 'lib/pinecone/index.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

#configure(index_name, body) ⇒ Object



32
33
34
35
# File 'lib/pinecone/index.rb', line 32

def configure(index_name, body)
  payload = options.merge(body: body.to_json)
  self.class.patch("/indexes/#{index_name}", payload)
end

#create(body) ⇒ Object



23
24
25
26
# File 'lib/pinecone/index.rb', line 23

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

#delete(index_name) ⇒ Object



28
29
30
# File 'lib/pinecone/index.rb', line 28

def delete(index_name)
  self.class.delete("/indexes/#{index_name}", options)
end

#describe(index_name) ⇒ Object



19
20
21
# File 'lib/pinecone/index.rb', line 19

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

#listObject



15
16
17
# File 'lib/pinecone/index.rb', line 15

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

#optionsObject



37
38
39
40
41
# File 'lib/pinecone/index.rb', line 37

def options
  {
    headers: @headers
  }
end