Class: Pinecone::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pinecone/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, environment: nil) ⇒ Client

Returns a new instance of Client.



3
4
5
6
# File 'lib/pinecone/client.rb', line 3

def initialize(api_key: nil, environment: nil)
  Pinecone.configuration.api_key = api_key if api_key
  Pinecone.configuration.environment = environment if environment
end

Class Method Details

.delete(path:, prefix: '') ⇒ Object



47
48
49
50
51
52
# File 'lib/pinecone/client.rb', line 47

def self.delete(path:, prefix: '')
  HTTParty.delete(
    uri(path: path, prefix: prefix),
    headers: headers
  )
end

.get(path:, prefix: '') ⇒ Object

# HTTP Helpers



16
17
18
19
20
21
# File 'lib/pinecone/client.rb', line 16

def self.get(path:, prefix: '')
  HTTParty.get(
    uri(path: path, prefix: prefix),
    headers: headers
  )
end

.json_patch(path:, prefix: '', parameters:) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/pinecone/client.rb', line 31

def self.json_patch(path:, prefix: '', parameters:)
  HTTParty.patch(
    uri(path: path, prefix: prefix),
    headers: headers,
    body: parameters&.to_json
  )
end

.json_post(path:, prefix: '', parameters:) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/pinecone/client.rb', line 23

def self.json_post(path:, prefix: '', parameters:)
  HTTParty.post(
    uri(path: path, prefix: prefix),
    headers: headers,
    body: parameters&.to_json
  )
end

.multipart_post(path:, prefix: '', parameters: nil) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/pinecone/client.rb', line 39

def self.multipart_post(path:, prefix: '', parameters: nil)
  HTTParty.post(
    uri(path: path, prefix: prefix),
    headers: headers.merge({ "Content-Type" => "multipart/form-data" }),
    body: parameters
  )
end

.project_nameObject



54
55
56
# File 'lib/pinecone/client.rb', line 54

def self.project_name
  @project_name ||= Pinecone::Client.get(prefix: 'controller', path: '/actions/whoami')['project_name']
end

Instance Method Details

#indexesObject

# Vectors API



10
11
12
# File 'lib/pinecone/client.rb', line 10

def indexes
  Pinecone::Index
end