milvus 0.10.1 β 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +55 -0
- data/docker-compose.yml +77 -0
- data/lib/milvus/client.rb +8 -0
- data/lib/milvus/roles.rb +32 -0
- data/lib/milvus/users.rb +96 -0
- data/lib/milvus/version.rb +1 -1
- data/lib/milvus.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c38f7235b815b1f48dd2d61e445b99ca675f974d1dddeba02796bf02e353fdd1
|
4
|
+
data.tar.gz: 4af6a551675f63cb17ee6f2c80a8ca000ea98ff028eeefa71f9593061ac04969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37d2666740b3e9df096e5f8b024a72fff37b60c53810f8dcbd5f0b14c4a008060d5cad78109664b74d7e2e76d21c8559cbb6c079b046032acd09491c5a3c3109
|
7
|
+
data.tar.gz: 7c10d887561876c02e6f869807b01c339b2412137e3cefb584ce5451da815eafec06f5c4ea83bbd231862b9742aad08d711566a2660193016b9eb809eca7798b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,11 @@ Available for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.i
|
|
22
22
|
## API Docs
|
23
23
|
https://docs.zilliz.com/reference/restful/data-plane-v2
|
24
24
|
|
25
|
+
## TODOs
|
26
|
+
- [X] Support for [User endpoints](https://docs.zilliz.com/reference/restful/user-operations-v2)
|
27
|
+
- [X] Support for [Role endpoints](https://docs.zilliz.com/reference/restful/role-operations-v2)
|
28
|
+
- [ ] Support for [Alias endpoints](https://docs.zilliz.com/reference/restful/alias-operations-v2)
|
29
|
+
|
25
30
|
## Installation
|
26
31
|
|
27
32
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -267,12 +272,62 @@ client.partitions.drop(
|
|
267
272
|
)
|
268
273
|
```
|
269
274
|
|
275
|
+
### Roles
|
276
|
+
```ruby
|
277
|
+
# List roles available on the server
|
278
|
+
client.roles.list
|
279
|
+
```
|
280
|
+
```ruby
|
281
|
+
# Describe the role
|
282
|
+
client.roles.describe(role_name: 'public')
|
283
|
+
```
|
284
|
+
|
285
|
+
### Users
|
286
|
+
```ruby
|
287
|
+
# Create new user
|
288
|
+
client.users.create(user_name: 'user_name', password: 'password')
|
289
|
+
```
|
290
|
+
```ruby
|
291
|
+
# List of roles assigned to the user
|
292
|
+
client.users.describe(user_name: 'user_name')
|
293
|
+
```
|
294
|
+
```ruby
|
295
|
+
# List all users in the specified database.
|
296
|
+
client.users.list
|
297
|
+
```
|
298
|
+
```ruby
|
299
|
+
# Drop existing user
|
300
|
+
client.users.drop(user_name: 'user_name')
|
301
|
+
```
|
302
|
+
```ruby
|
303
|
+
# Update password for the user
|
304
|
+
client.users.update_password(user_name: 'user_name', password: 'old_password', new_password: 'new_password')
|
305
|
+
```
|
306
|
+
```ruby
|
307
|
+
# Grant role to the user
|
308
|
+
client.users.grant_role(user_name: 'user_name', role_name: 'admin')
|
309
|
+
```
|
310
|
+
```ruby
|
311
|
+
# Revoke role from the user
|
312
|
+
client.users.revoke_role(user_name: 'user_name', role_name: 'admin')
|
313
|
+
```
|
314
|
+
|
270
315
|
## Development
|
271
316
|
|
272
317
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
273
318
|
|
274
319
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
275
320
|
|
321
|
+
## Development with Docker
|
322
|
+
|
323
|
+
Run `docker compose run --rm ruby_app bash` and install required gems (`bundle install`). It will give you a fully working development environment with Milvius services and gem's code.
|
324
|
+
|
325
|
+
For example inside docker container run `bin/console` and inside the ruby console:
|
326
|
+
```ruby
|
327
|
+
client = Milvus::Client.new(url: ENV["MILVUS_URL"])
|
328
|
+
client.collections.list
|
329
|
+
```
|
330
|
+
|
276
331
|
## Contributing
|
277
332
|
|
278
333
|
Bug reports and pull requests are welcome on GitHub at https://github.com/patterns-ai-core/milvus.
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
services:
|
2
|
+
ruby_app:
|
3
|
+
image: ruby:bullseye
|
4
|
+
working_dir: /usr/src/app
|
5
|
+
volumes:
|
6
|
+
- .:/usr/src/app
|
7
|
+
- bundle:/usr/local/bundle
|
8
|
+
depends_on:
|
9
|
+
- standalone
|
10
|
+
environment:
|
11
|
+
MILVUS_URL: "http://standalone:19530"
|
12
|
+
|
13
|
+
etcd:
|
14
|
+
container_name: milvus-etcd
|
15
|
+
image: quay.io/coreos/etcd:v3.5.5
|
16
|
+
environment:
|
17
|
+
- ETCD_AUTO_COMPACTION_MODE=revision
|
18
|
+
- ETCD_AUTO_COMPACTION_RETENTION=1000
|
19
|
+
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
20
|
+
- ETCD_SNAPSHOT_COUNT=50000
|
21
|
+
volumes:
|
22
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
|
23
|
+
command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
|
24
|
+
healthcheck:
|
25
|
+
test: ["CMD", "etcdctl", "endpoint", "health"]
|
26
|
+
interval: 30s
|
27
|
+
timeout: 20s
|
28
|
+
retries: 3
|
29
|
+
|
30
|
+
minio:
|
31
|
+
container_name: milvus-minio
|
32
|
+
image: minio/minio:RELEASE.2023-03-20T20-16-18Z
|
33
|
+
environment:
|
34
|
+
MINIO_ACCESS_KEY: minioadmin
|
35
|
+
MINIO_SECRET_KEY: minioadmin
|
36
|
+
ports:
|
37
|
+
- "9001:9001"
|
38
|
+
- "9000:9000"
|
39
|
+
volumes:
|
40
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
|
41
|
+
command: minio server /minio_data --console-address ":9001"
|
42
|
+
healthcheck:
|
43
|
+
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
44
|
+
interval: 30s
|
45
|
+
timeout: 20s
|
46
|
+
retries: 3
|
47
|
+
|
48
|
+
standalone:
|
49
|
+
container_name: milvus-standalone
|
50
|
+
image: milvusdb/milvus:v2.4.5
|
51
|
+
command: ["milvus", "run", "standalone"]
|
52
|
+
security_opt:
|
53
|
+
- seccomp:unconfined
|
54
|
+
environment:
|
55
|
+
ETCD_ENDPOINTS: etcd:2379
|
56
|
+
MINIO_ADDRESS: minio:9000
|
57
|
+
volumes:
|
58
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
|
59
|
+
healthcheck:
|
60
|
+
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
|
61
|
+
interval: 30s
|
62
|
+
start_period: 90s
|
63
|
+
timeout: 20s
|
64
|
+
retries: 3
|
65
|
+
ports:
|
66
|
+
- "19530:19530"
|
67
|
+
- "9091:9091"
|
68
|
+
depends_on:
|
69
|
+
- "etcd"
|
70
|
+
- "minio"
|
71
|
+
|
72
|
+
networks:
|
73
|
+
default:
|
74
|
+
name: milvus
|
75
|
+
|
76
|
+
volumes:
|
77
|
+
bundle:
|
data/lib/milvus/client.rb
CHANGED
@@ -29,6 +29,14 @@ module Milvus
|
|
29
29
|
@indexes ||= Milvus::Indexes.new(client: self)
|
30
30
|
end
|
31
31
|
|
32
|
+
def roles
|
33
|
+
@roles ||= Milvus::Roles.new(client: self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def users
|
37
|
+
@users ||= Milvus::Users.new(client: self)
|
38
|
+
end
|
39
|
+
|
32
40
|
def connection
|
33
41
|
@connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
|
34
42
|
if api_key
|
data/lib/milvus/roles.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milvus
|
4
|
+
class Roles < Base
|
5
|
+
PATH = "roles"
|
6
|
+
|
7
|
+
# Lists available roles on the server
|
8
|
+
#
|
9
|
+
# @return [Hash] The response from the server.
|
10
|
+
def list
|
11
|
+
response = client.connection.post("#{PATH}/list") do |req|
|
12
|
+
req.body = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
# This operation inserts data into a specific collection.
|
19
|
+
#
|
20
|
+
# @param role_name [String] The name of the collection to insert data into.
|
21
|
+
# @return [Hash] The response from the server.
|
22
|
+
def describe(role_name:)
|
23
|
+
response = client.connection.post("#{PATH}/describe") do |req|
|
24
|
+
req.body = {
|
25
|
+
roleName: role_name
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
response.body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/milvus/users.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milvus
|
4
|
+
class Users < Base
|
5
|
+
PATH = "users"
|
6
|
+
|
7
|
+
# Create a user
|
8
|
+
#
|
9
|
+
# @param user_name [String] Username for the user
|
10
|
+
# @param password [String] Password for the user
|
11
|
+
# @return [Hash] Server response
|
12
|
+
def create(user_name:, password:)
|
13
|
+
response = client.connection.post("#{PATH}/create") do |req|
|
14
|
+
req.body = {
|
15
|
+
userName: user_name,
|
16
|
+
password: password
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
# Describe a user
|
24
|
+
#
|
25
|
+
# @param user_name [String] Username for the user
|
26
|
+
# @return [Hash] Server response
|
27
|
+
def describe(user_name:)
|
28
|
+
response = client.connection.post("#{PATH}/describe") do |req|
|
29
|
+
req.body = {
|
30
|
+
userName: user_name
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
response.body
|
35
|
+
end
|
36
|
+
|
37
|
+
# List users
|
38
|
+
#
|
39
|
+
# @return [Hash] Server response
|
40
|
+
def list
|
41
|
+
response = client.connection.post("#{PATH}/list") do |req|
|
42
|
+
req.body = {}
|
43
|
+
end
|
44
|
+
|
45
|
+
response.body
|
46
|
+
end
|
47
|
+
|
48
|
+
# Drops a user
|
49
|
+
#
|
50
|
+
# @param user_name [String] Username for the user
|
51
|
+
# @return [Hash] Server response
|
52
|
+
def drop(user_name:)
|
53
|
+
response = client.connection.post("#{PATH}/drop") do |req|
|
54
|
+
req.body = {
|
55
|
+
userName: user_name
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
response.body
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_password(user_name:, password:, new_password:)
|
63
|
+
response = client.connection.post("#{PATH}/update_password") do |req|
|
64
|
+
req.body = {
|
65
|
+
userName: user_name,
|
66
|
+
password: password,
|
67
|
+
newPassword: new_password
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
response.body
|
72
|
+
end
|
73
|
+
|
74
|
+
def grant_role(user_name:, role_name:)
|
75
|
+
response = client.connection.post("#{PATH}/grant_role") do |req|
|
76
|
+
req.body = {
|
77
|
+
userName: user_name,
|
78
|
+
roleName: role_name
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
def revoke_role(user_name:, role_name:)
|
86
|
+
response = client.connection.post("#{PATH}/revoke_role") do |req|
|
87
|
+
req.body = {
|
88
|
+
userName: user_name,
|
89
|
+
roleName: role_name
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
response.body
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/milvus/version.rb
CHANGED
data/lib/milvus.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milvus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- LICENSE
|
61
61
|
- README.md
|
62
62
|
- Rakefile
|
63
|
+
- docker-compose.yml
|
63
64
|
- lib/milvus.rb
|
64
65
|
- lib/milvus/base.rb
|
65
66
|
- lib/milvus/client.rb
|
@@ -69,6 +70,8 @@ files:
|
|
69
70
|
- lib/milvus/error.rb
|
70
71
|
- lib/milvus/indexes.rb
|
71
72
|
- lib/milvus/partitions.rb
|
73
|
+
- lib/milvus/roles.rb
|
74
|
+
- lib/milvus/users.rb
|
72
75
|
- lib/milvus/version.rb
|
73
76
|
- sig/milvus.rbs
|
74
77
|
homepage: https://github.com/andreibondarev/milvus
|