rxer-api 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.md +107 -0
- data/Rakefile +12 -0
- data/lib/rxer/api/client.rb +47 -0
- data/lib/rxer/api/v1/db.rb +22 -0
- data/lib/rxer/api/v1/indexes.rb +26 -0
- data/lib/rxer/api/v1/items.rb +30 -0
- data/lib/rxer/api/v1/namespaces.rb +48 -0
- data/lib/rxer/api/v1/queries.rb +22 -0
- data/lib/rxer/api/v1/schemas.rb +22 -0
- data/lib/rxer/api/v1/sysinfo.rb +46 -0
- data/lib/rxer/api/v1/transactions.rb +38 -0
- data/lib/rxer/api/version.rb +7 -0
- data/lib/rxer/api.rb +12 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee45b57414dc0420e186ecc8420c51b8cb788a5f7f560bd5e0d4062a777157de
|
4
|
+
data.tar.gz: b201d624d1a56ff189b0f6155acfc6427a55340a4cb27b1cf2542929eb16008b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 525a43f4c2266daae2065082b6fea42e39340373e431c8b8b2a19517b22114f0a808d31f37c533e9b8ef1074511eb16c55520d80f7481b82c236e47ae3243069
|
7
|
+
data.tar.gz: 4c994a8f4b351fd2dcf1a322b6ab8879a6b1fc8a781fc523cd869e449fb08d059f5e264b6d543d19409b0f6d3fe1fcad9c9afba31f607f50e0210cf10d1ae5cd
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Metrics/BlockLength:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/StringLiterals:
|
8
|
+
Enabled: true
|
9
|
+
EnforcedStyle: double_quotes
|
10
|
+
|
11
|
+
Style/StringLiteralsInInterpolation:
|
12
|
+
Enabled: true
|
13
|
+
EnforcedStyle: double_quotes
|
14
|
+
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
## [0.4.0] - Index/Query/Schema methods added
|
2
|
+
|
3
|
+
## [0.3.0] - System methods added
|
4
|
+
|
5
|
+
## [0.2.0] - Transactions added
|
6
|
+
|
7
|
+
## [0.1.0] - Initial release
|
8
|
+
- HTTP-client based on Faraday and Excon with Keep-Alive
|
9
|
+
- /db (list_db/create_db/drop_db)
|
10
|
+
- /db/{database}/namespaces (list_namespaces/create_namespace/drop_namespace/truncate_namespace)
|
11
|
+
- /db/{database}/namespaces/{namespace}/items (insert_items/get_items)
|
12
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rxer-api (0.3.0)
|
5
|
+
excon (>= 0.27.4)
|
6
|
+
faraday (>= 2.1.0)
|
7
|
+
faraday-excon (>= 2.1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.4)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
crack (0.4.5)
|
16
|
+
rexml
|
17
|
+
diff-lcs (1.5.0)
|
18
|
+
excon (0.99.0)
|
19
|
+
faraday (2.7.4)
|
20
|
+
faraday-net_http (>= 2.0, < 3.1)
|
21
|
+
ruby2_keywords (>= 0.0.4)
|
22
|
+
faraday-excon (2.1.0)
|
23
|
+
excon (>= 0.27.4)
|
24
|
+
faraday (~> 2.0)
|
25
|
+
faraday-net_http (3.0.2)
|
26
|
+
hashdiff (1.0.1)
|
27
|
+
json (2.6.3)
|
28
|
+
parallel (1.23.0)
|
29
|
+
parser (3.2.2.0)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
public_suffix (5.0.1)
|
32
|
+
rainbow (3.1.1)
|
33
|
+
rake (13.0.6)
|
34
|
+
regexp_parser (2.8.0)
|
35
|
+
rexml (3.2.5)
|
36
|
+
rspec (3.12.0)
|
37
|
+
rspec-core (~> 3.12.0)
|
38
|
+
rspec-expectations (~> 3.12.0)
|
39
|
+
rspec-mocks (~> 3.12.0)
|
40
|
+
rspec-core (3.12.2)
|
41
|
+
rspec-support (~> 3.12.0)
|
42
|
+
rspec-expectations (3.12.3)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.12.0)
|
45
|
+
rspec-mocks (3.12.5)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.12.0)
|
48
|
+
rspec-support (3.12.0)
|
49
|
+
rubocop (1.50.2)
|
50
|
+
json (~> 2.3)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 3.2.0.0)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.8, < 3.0)
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
57
|
+
ruby-progressbar (~> 1.7)
|
58
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
59
|
+
rubocop-ast (1.28.0)
|
60
|
+
parser (>= 3.2.1.0)
|
61
|
+
ruby-progressbar (1.13.0)
|
62
|
+
ruby2_keywords (0.0.5)
|
63
|
+
unicode-display_width (2.4.2)
|
64
|
+
webmock (3.18.1)
|
65
|
+
addressable (>= 2.8.0)
|
66
|
+
crack (>= 0.3.2)
|
67
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
x86_64-linux
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
rake (~> 13.0)
|
74
|
+
rspec (~> 3.0)
|
75
|
+
rubocop (~> 1.21)
|
76
|
+
rxer-api!
|
77
|
+
webmock
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
2.3.18
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 SundayNight
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# Rxer::Api
|
2
|
+
|
3
|
+
It is not in my mind to ask questions that cannot be answered.
|
4
|
+
That is the soul standing upon the crossroad of vacillation.
|
5
|
+
You search for wisdom, but achieve only a stasis of will.
|
6
|
+
|
7
|
+
This is a simple client for REST API of [Reindexer](https://github.com/Restream/reindexer/)
|
8
|
+
|
9
|
+
REST API fully described [here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/Restream/reindexer/master/cpp_src/server/contrib/server.yml)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add these line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
17
|
+
gem 'rxer-api', github: 'etspring/rxer-api'
|
18
|
+
```
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
24
|
+
|
25
|
+
$ gem specific_install https://github.com/etspring/rxer-api.git
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'rxer/api'
|
31
|
+
# Initialize client
|
32
|
+
client = Rxer::Api::Client.new(url: 'http://localhost:9088/')
|
33
|
+
|
34
|
+
# Drop db
|
35
|
+
client.drop_db(db_name: 'my_test_db')
|
36
|
+
|
37
|
+
# Create db
|
38
|
+
client.create_db(db_name: 'my_test_db')
|
39
|
+
|
40
|
+
# Define namespace confiuration
|
41
|
+
ns_config = {
|
42
|
+
"name": "my_test_namespace",
|
43
|
+
"storage": {
|
44
|
+
"enabled": false
|
45
|
+
},
|
46
|
+
"indexes": {
|
47
|
+
"name": "id",
|
48
|
+
"json_paths": [
|
49
|
+
"id"
|
50
|
+
],
|
51
|
+
"field_type": "string",
|
52
|
+
"index_type": "hash"
|
53
|
+
...
|
54
|
+
}
|
55
|
+
}
|
56
|
+
# Create NS with defined config
|
57
|
+
client.create_namespace(db_name: 'my_test_db', namespace: ns_config)
|
58
|
+
|
59
|
+
# Truncate NS
|
60
|
+
client.truncate_namespace(db_name: 'my_test_db', namespace: 'my_test_namespace')
|
61
|
+
|
62
|
+
# Drop NS
|
63
|
+
client.drop_namespace(db_name: 'my_test_db', namespace: 'my_test_namespace')
|
64
|
+
|
65
|
+
# Insert items
|
66
|
+
items = [{id: "100", title: "Remember"}, {id: "101", title: "Cadia"}].map(&:to_json).join("\n")
|
67
|
+
client.create_items(db_name: 'my_test_db', ns_name: 'my_test_namespace', payload: items)
|
68
|
+
|
69
|
+
# Get items
|
70
|
+
q = { filter: "id = 'my_id_1' OR id = 'my_id_2'", format: 'json' }
|
71
|
+
client.get_items(db_name: 'my_test_db', ns_name: 'my_test_namespace', payload: q)
|
72
|
+
|
73
|
+
# Drop items
|
74
|
+
items = [{id: "100", title: "Remember"}, {id: "101", title: "Cadia"}].map { |x| x.slice(:id) }.map(&:to_json)
|
75
|
+
client.drop_items(db_name: 'my_test_db', ns_name: 'my_test_namespace', payload: items)
|
76
|
+
|
77
|
+
|
78
|
+
# Transactions
|
79
|
+
|
80
|
+
# Begin tx
|
81
|
+
tx_id = client.create_tx(db_name: 'my_test_db', ns_name: 'my_test_namespace').body["tx_id"]
|
82
|
+
|
83
|
+
# Create items with tx
|
84
|
+
client.create_items_tx(db_name: 'my_test_db', tx_id: tx_id, payload: items)
|
85
|
+
|
86
|
+
# Upser items with tx
|
87
|
+
client.upsert_items_tx(db_name: 'my_test_db', tx_id: tx_id, payload: items)
|
88
|
+
|
89
|
+
# Drop items with tx
|
90
|
+
items = [{id: "100", title: "Remember"}, {id: "101", title: "Cadia"}].map { |x| x.slice(:id) }.map(&:to_json)
|
91
|
+
client.drop_items_tx(db_name: 'my_test_db', tx_id: tx_id, payload: items)
|
92
|
+
|
93
|
+
# Commit tx
|
94
|
+
client.commit_tx(db_name: 'my_test_db', tx_id: tx_id)
|
95
|
+
|
96
|
+
# Rollback tx
|
97
|
+
client.rollback_tx(db_name: 'my_test_db', tx_id: tx_id)
|
98
|
+
```
|
99
|
+
|
100
|
+
## Contributing
|
101
|
+
|
102
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/etspring/rxer-api.
|
103
|
+
|
104
|
+
## License
|
105
|
+
|
106
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
107
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
# HTTP-client based on Faraday and Excon adapter
|
6
|
+
class Client
|
7
|
+
attr_reader :api_version
|
8
|
+
attr_accessor :conn
|
9
|
+
|
10
|
+
def initialize(url:, version: "v1")
|
11
|
+
@api_version = version
|
12
|
+
@conn = Faraday.new(url: url) do |f|
|
13
|
+
f.adapter :excon, persistent: true
|
14
|
+
f.request :json
|
15
|
+
f.response :json
|
16
|
+
end
|
17
|
+
include_api_version_methods
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Вычислить путь звезды, и развести сады,
|
23
|
+
# И укротить тайфун - всё может магия...
|
24
|
+
def include_api_version_methods
|
25
|
+
Dir.glob("#{__dir__}/#{api_version}/*.rb").sort.each do |endpoint|
|
26
|
+
require endpoint
|
27
|
+
mdl_to_incl = "Rxer::Api::#{api_version.capitalize}::#{endpoint.split("/").last.gsub(".rb", "").capitalize}"
|
28
|
+
self.class.send(:include, Object.const_get(mdl_to_incl))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
%w[post put patch].each do |method_name|
|
33
|
+
define_method(method_name) do |endpoint:, payload: {}|
|
34
|
+
conn.send(method_name, endpoint) do |req|
|
35
|
+
req.body = payload
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
%w[get delete].each do |method_name|
|
41
|
+
define_method(method_name) do |endpoint:, payload: {}|
|
42
|
+
conn.send(method_name, endpoint, payload)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with /db endpoint
|
7
|
+
module Db
|
8
|
+
def list_db
|
9
|
+
get(endpoint: "/api/v1/db")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_db(db_name:)
|
13
|
+
post(endpoint: "/api/v1/db", payload: { name: db_name })
|
14
|
+
end
|
15
|
+
|
16
|
+
def drop_db(db_name:)
|
17
|
+
delete(endpoint: "/api/v1/db/#{db_name}", payload: { name: db_name })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with Indexes
|
7
|
+
module Indexes
|
8
|
+
def list_indexes(db_name:, ns_name:)
|
9
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/idexes")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_index(db_name:, ns_name:, payload:)
|
13
|
+
post(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/indexes", payload: payload)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_index(db_name:, ns_name:, payload:)
|
17
|
+
put(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/indexes", payload: payload)
|
18
|
+
end
|
19
|
+
|
20
|
+
def drop_index(db_name:, ns_name:, index:)
|
21
|
+
delete(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/idexes/#{index}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with /items endpoint
|
7
|
+
module Items
|
8
|
+
def drop_items(db_name:, ns_name:, payload:)
|
9
|
+
delete(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/items", payload: payload)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_items(db_name:, ns_name:, payload:)
|
13
|
+
post(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/items", payload: payload)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_items(db_name:, ns_name:, payload:)
|
17
|
+
put(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/items", payload: payload)
|
18
|
+
end
|
19
|
+
|
20
|
+
def upsert_items(db_name:, ns_name:, payload:)
|
21
|
+
patch(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/items", payload: payload)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_items(db_name:, ns_name:, payload: {})
|
25
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/items", payload: payload)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with /namespace endpoint
|
7
|
+
module Namespaces
|
8
|
+
def list_namespaces(db_name:)
|
9
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_namespace(db_name:, namespace:)
|
13
|
+
raise ArgumentError "namespace param must be a hash" unless namespace.instance_of?(Hash)
|
14
|
+
|
15
|
+
post(endpoint: "/api/v1/db/#{db_name}/namespaces", payload: namespace)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_namespace(db_name:, namespace:)
|
19
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def drop_namespace(db_name:, namespace:)
|
23
|
+
delete(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def truncate_namespace(db_name:, namespace:)
|
27
|
+
delete(endpoint: "/api/v1/db/#{db_name}/#{namespace}/truncate")
|
28
|
+
end
|
29
|
+
|
30
|
+
def rename_namespace(db_name:, namespace:, name:)
|
31
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/rename/#{name}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_namespace_metalist(db_name:, namespace:)
|
35
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/metalist")
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_namespace_meta_by_key(db_name:, namespace:, key:)
|
39
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/metabykey/#{key}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def update_namespace_meta_key(db_name:, namespace:, payload:)
|
43
|
+
put(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/metabykey", payload: payload)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with Queries
|
7
|
+
module Queries
|
8
|
+
def list_db
|
9
|
+
get(endpoint: "/api/v1/db")
|
10
|
+
end
|
11
|
+
|
12
|
+
def query(db_name:, payload:)
|
13
|
+
post(endpoint: "/api/v1/db/#{db_name}/query", payload: { name: db_name })
|
14
|
+
end
|
15
|
+
|
16
|
+
def sqlquery(db_name:, payload:)
|
17
|
+
post(endpoint: "/api/v1/db/#{db_name}/sqlquery", payload: { name: db_name })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with schemas
|
7
|
+
module Schemas
|
8
|
+
def set_schema(db_name:, namespace:, payload:)
|
9
|
+
put(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/schema", payload: payload)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_schema(db_name:, namespace:)
|
13
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#{namespace}/schema")
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_protobuf_schema(db_name:)
|
17
|
+
get(endpoint: "/api/v1/db/#{db_name}/protobuf_schema")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with /db endpoint
|
7
|
+
module Sysinfo
|
8
|
+
def check
|
9
|
+
get(endpoint: "/api/v1/check")
|
10
|
+
end
|
11
|
+
|
12
|
+
def drop_cache
|
13
|
+
post(endpoint: "/api/v1/allocator/drop_cache", payload: {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def allocator_info
|
17
|
+
get(endpoint: "/api/v1/allocator/info")
|
18
|
+
end
|
19
|
+
|
20
|
+
def activity_stats(db_name:)
|
21
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#activitystats/items")
|
22
|
+
end
|
23
|
+
|
24
|
+
def clients_stats(db_name:)
|
25
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#clientsstats/items")
|
26
|
+
end
|
27
|
+
|
28
|
+
def mem_stats(db_name:)
|
29
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#memstats/items")
|
30
|
+
end
|
31
|
+
|
32
|
+
def perf_stats(db_name:)
|
33
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#perfstats/items")
|
34
|
+
end
|
35
|
+
|
36
|
+
def queries_perf_stats(db_name:)
|
37
|
+
get(endpoint: "/api/v1/db/#{db_name}/namespaces/#queriesperfstats/items")
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_profiling(db_name:, payload:)
|
41
|
+
put(endpoint: "/api/v1/db/#{db_name}/namespaces/#config/items", payload: payload)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rxer
|
4
|
+
module Api
|
5
|
+
module V1
|
6
|
+
# Working with Transactions
|
7
|
+
module Transactions
|
8
|
+
def create_tx(db_name:, ns_name:)
|
9
|
+
post(endpoint: "/api/v1/db/#{db_name}/namespaces/#{ns_name}/transactions/begin", payload: {})
|
10
|
+
end
|
11
|
+
|
12
|
+
def commit_tx(db_name:, tx_id:)
|
13
|
+
post(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/commit", payload: {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def rollback_tx(db_name:, tx_id:)
|
17
|
+
post(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/rollback", payload: {})
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_items_tx(db_name:, tx_id:, payload:)
|
21
|
+
post(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/items", payload: payload)
|
22
|
+
end
|
23
|
+
|
24
|
+
def upsert_items_tx(db_name:, tx_id:, payload:)
|
25
|
+
patch(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/items", payload: payload)
|
26
|
+
end
|
27
|
+
|
28
|
+
def update_items_tx(db_name:, tx_id:, payload:)
|
29
|
+
put(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/items", payload: payload)
|
30
|
+
end
|
31
|
+
|
32
|
+
def drop_items_tx(db_name:, tx_id:, payload:)
|
33
|
+
delete(endpoint: "/api/v1/db/#{db_name}/transactions/#{tx_id}/items", payload: payload)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rxer/api.rb
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rxer-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SundayNight
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.27.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.27.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday-excon
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Simple HTTP-client for https://reindexer.io/
|
70
|
+
email:
|
71
|
+
- etspring@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".rspec"
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/rxer/api.rb
|
85
|
+
- lib/rxer/api/client.rb
|
86
|
+
- lib/rxer/api/v1/db.rb
|
87
|
+
- lib/rxer/api/v1/indexes.rb
|
88
|
+
- lib/rxer/api/v1/items.rb
|
89
|
+
- lib/rxer/api/v1/namespaces.rb
|
90
|
+
- lib/rxer/api/v1/queries.rb
|
91
|
+
- lib/rxer/api/v1/schemas.rb
|
92
|
+
- lib/rxer/api/v1/sysinfo.rb
|
93
|
+
- lib/rxer/api/v1/transactions.rb
|
94
|
+
- lib/rxer/api/version.rb
|
95
|
+
homepage: https://github.com/etspring/rxer-api/
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata:
|
99
|
+
homepage_uri: https://github.com/etspring/rxer-api/
|
100
|
+
source_code_uri: https://github.com/etspring/rxer-api.git
|
101
|
+
changelog_uri: https://github.com/etspring/rxer-api/CHANGELOG.md
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.6.0
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubygems_version: 3.0.3
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Simple client for Reindexer REST Api
|
121
|
+
test_files: []
|