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.



8
9
10
11
12
13
14
15
# File 'lib/pinecone/index.rb', line 8

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



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

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

#create(body) ⇒ Object



25
26
27
28
# File 'lib/pinecone/index.rb', line 25

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

#delete(index_name) ⇒ Object



30
31
32
# File 'lib/pinecone/index.rb', line 30

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

#describe(index_name) ⇒ Object



21
22
23
# File 'lib/pinecone/index.rb', line 21

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

#listObject



17
18
19
# File 'lib/pinecone/index.rb', line 17

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

#optionsObject



39
40
41
42
43
# File 'lib/pinecone/index.rb', line 39

def options
  {
    headers: @headers
  }
end