Class: Milvus::Client

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

Constant Summary collapse

API_VERSION =
"v2/vectordb"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, api_key: nil, adapter: Faraday.default_adapter, raise_error: false, logger: nil) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/milvus/client.rb', line 11

def initialize(
  url:,
  api_key: nil,
  adapter: Faraday.default_adapter,
  raise_error: false,
  logger: nil
)
  @url = url
  @api_key = api_key
  @adapter = adapter
  @raise_error = raise_error
  @logger = logger || Logger.new($stdout)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



7
8
9
# File 'lib/milvus/client.rb', line 7

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/milvus/client.rb', line 7

def api_key
  @api_key
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/milvus/client.rb', line 7

def logger
  @logger
end

#raise_errorObject (readonly)

Returns the value of attribute raise_error.



7
8
9
# File 'lib/milvus/client.rb', line 7

def raise_error
  @raise_error
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/milvus/client.rb', line 7

def url
  @url
end

Instance Method Details

#aliasesObject



49
50
51
# File 'lib/milvus/client.rb', line 49

def aliases
  @aliases ||= Milvus::Aliases.new(client: self)
end

#collectionsObject



25
26
27
# File 'lib/milvus/client.rb', line 25

def collections
  @schema ||= Milvus::Collections.new(client: self)
end

#connectionObject



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/milvus/client.rb', line 53

def connection
  @connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
    if api_key
      faraday.request :authorization, :Bearer, api_key
    end
    faraday.request :json
    faraday.response :logger, logger, {headers: true, bodies: true, errors: true}
    faraday.response :raise_error if raise_error
    faraday.response :json, content_type: /\bjson$/
    faraday.adapter adapter
  end
end

#entitiesObject



33
34
35
# File 'lib/milvus/client.rb', line 33

def entities
  @entities ||= Milvus::Entities.new(client: self)
end

#indexesObject



37
38
39
# File 'lib/milvus/client.rb', line 37

def indexes
  @indexes ||= Milvus::Indexes.new(client: self)
end

#partitionsObject



29
30
31
# File 'lib/milvus/client.rb', line 29

def partitions
  @partitions ||= Milvus::Partitions.new(client: self)
end

#rolesObject



41
42
43
# File 'lib/milvus/client.rb', line 41

def roles
  @roles ||= Milvus::Roles.new(client: self)
end

#usersObject



45
46
47
# File 'lib/milvus/client.rb', line 45

def users
  @users ||= Milvus::Users.new(client: self)
end