antbird 0.15.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build-os.yml +6 -27
- data/.gitignore +2 -2
- data/Gemfile.lock +66 -0
- data/README.md +11 -15
- data/antbird.gemspec +3 -4
- data/lib/antbird/client.rb +59 -49
- data/lib/antbird/rest_api/rest_api_opensearch_v3_0.rb +492 -328
- data/lib/antbird/rest_api/rest_api_opensearch_v3_1.rb +495 -330
- data/lib/antbird/rest_api/rest_api_opensearch_v3_2.rb +495 -330
- data/lib/antbird/rest_api/rest_api_opensearch_v3_3.rb +495 -330
- data/lib/antbird/rest_api/rest_api_opensearch_v3_4.rb +1505 -0
- data/lib/antbird/rest_api/rest_api_opensearch_v3_5.rb +1505 -0
- data/lib/antbird/version.rb +1 -1
- metadata +8 -71
- data/.github/workflows/build.yml +0 -45
- data/lib/antbird/rest_api/rest_api_opensearch_v1_0.rb +0 -1221
- data/lib/antbird/rest_api/rest_api_opensearch_v1_1.rb +0 -1221
- data/lib/antbird/rest_api/rest_api_opensearch_v1_2.rb +0 -1221
- data/lib/antbird/rest_api/rest_api_opensearch_v1_3.rb +0 -1221
- data/lib/antbird/rest_api/rest_api_opensearch_v2_0.rb +0 -1204
- data/lib/antbird/rest_api/rest_api_opensearch_v2_1.rb +0 -1204
- data/lib/antbird/rest_api/rest_api_opensearch_v2_10.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_11.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_12.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_13.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_14.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_15.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_16.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_17.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_18.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_19.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_2.rb +0 -1204
- data/lib/antbird/rest_api/rest_api_opensearch_v2_3.rb +0 -1212
- data/lib/antbird/rest_api/rest_api_opensearch_v2_4.rb +0 -1292
- data/lib/antbird/rest_api/rest_api_opensearch_v2_5.rb +0 -1292
- data/lib/antbird/rest_api/rest_api_opensearch_v2_6.rb +0 -1300
- data/lib/antbird/rest_api/rest_api_opensearch_v2_7.rb +0 -1324
- data/lib/antbird/rest_api/rest_api_opensearch_v2_8.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_opensearch_v2_9.rb +0 -1332
- data/lib/antbird/rest_api/rest_api_v6_4.rb +0 -996
- data/lib/antbird/rest_api/rest_api_v6_5.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v6_6.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v6_7.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v6_8.rb +0 -1011
- data/lib/antbird/rest_api/rest_api_v7_0.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v7_1.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v7_10.rb +0 -1189
- data/lib/antbird/rest_api/rest_api_v7_11.rb +0 -1189
- data/lib/antbird/rest_api/rest_api_v7_12.rb +0 -1197
- data/lib/antbird/rest_api/rest_api_v7_13.rb +0 -3045
- data/lib/antbird/rest_api/rest_api_v7_14.rb +0 -3141
- data/lib/antbird/rest_api/rest_api_v7_15.rb +0 -3189
- data/lib/antbird/rest_api/rest_api_v7_2.rb +0 -1020
- data/lib/antbird/rest_api/rest_api_v7_3.rb +0 -1012
- data/lib/antbird/rest_api/rest_api_v7_4.rb +0 -1028
- data/lib/antbird/rest_api/rest_api_v7_5.rb +0 -1028
- data/lib/antbird/rest_api/rest_api_v7_6.rb +0 -1044
- data/lib/antbird/rest_api/rest_api_v7_7.rb +0 -1092
- data/lib/antbird/rest_api/rest_api_v7_8.rb +0 -1157
- data/lib/antbird/rest_api/rest_api_v7_9.rb +0 -1181
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 472e058c1be7a6fdadf9949dc8c73c644ba5c82f3eea3b76fc502623fac4bea8
|
|
4
|
+
data.tar.gz: 35d0eff4b83b58a11f9299fca6210922f3243b3c166d7cc20385492bebf80570
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 569096a452fa059ee7527a8fc48a372fc0c7aa1c6001f467b0ce355240656ac787ae6a4ecdc7065d54d1c3daeecc31bbdc812304e023b5fafe32a0669b770838
|
|
7
|
+
data.tar.gz: d0c653d432e0ea31f1e98cc56b5486f126d1697483efae7a4f66f31e0b73669d2a5387be8d41b19e8a9759374df635791d88e3814c16d149001ac0b380c7de28
|
|
@@ -13,34 +13,12 @@ jobs:
|
|
|
13
13
|
matrix:
|
|
14
14
|
# https://github.com/opensearch-project/OpenSearch/releases
|
|
15
15
|
search_versions:
|
|
16
|
+
- 3.5.0
|
|
17
|
+
- 3.4.0
|
|
16
18
|
- 3.3.2
|
|
17
19
|
- 3.2.0
|
|
18
20
|
- 3.1.0
|
|
19
21
|
- 3.0.0
|
|
20
|
-
- 2.19.4
|
|
21
|
-
- 2.18.0
|
|
22
|
-
- 2.17.1
|
|
23
|
-
- 2.16.0
|
|
24
|
-
- 2.15.0
|
|
25
|
-
- 2.14.0
|
|
26
|
-
- 2.13.0
|
|
27
|
-
- 2.12.0
|
|
28
|
-
- 2.11.1
|
|
29
|
-
- 2.10.0
|
|
30
|
-
- 2.9.0
|
|
31
|
-
- 2.8.0
|
|
32
|
-
- 2.7.0
|
|
33
|
-
- 2.6.0
|
|
34
|
-
- 2.5.0
|
|
35
|
-
- 2.4.1
|
|
36
|
-
- 2.3.0
|
|
37
|
-
- 2.2.1
|
|
38
|
-
- 2.1.0
|
|
39
|
-
- 2.0.1
|
|
40
|
-
- 1.3.20
|
|
41
|
-
- 1.2.4
|
|
42
|
-
- 1.1.0
|
|
43
|
-
- 1.0.0
|
|
44
22
|
services:
|
|
45
23
|
opensearch:
|
|
46
24
|
image: opensearchproject/opensearch:${{matrix.search_versions}}
|
|
@@ -49,7 +27,8 @@ jobs:
|
|
|
49
27
|
env:
|
|
50
28
|
discovery.type: single-node
|
|
51
29
|
plugins.security.disabled: true
|
|
52
|
-
|
|
30
|
+
# a minimum 8 character password and must contain at least one uppercase letter, one lowercase letter, one digit, and one special character that is strong. Password strength can be tested here: https://lowe.github.io/tryzxcvbn
|
|
31
|
+
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "antbird@123Antbird"
|
|
53
32
|
steps:
|
|
54
33
|
- name: Configure sysctl limits
|
|
55
34
|
run: |
|
|
@@ -60,8 +39,8 @@ jobs:
|
|
|
60
39
|
- uses: actions/checkout@v6
|
|
61
40
|
- uses: ruby/setup-ruby@v1
|
|
62
41
|
with:
|
|
63
|
-
ruby-version: "
|
|
42
|
+
ruby-version: "4.0"
|
|
64
43
|
bundler-cache: true
|
|
65
44
|
- name: Wait for OpenSearch
|
|
66
|
-
run: timeout
|
|
45
|
+
run: timeout 120 bash -c "until curl --silent --output /dev/null 'localhost:9200/_cat/health?h=st'; do printf '.'; sleep 5; done; printf '\n'"
|
|
67
46
|
- run: bundle exec rspec
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
antbird (1.0.0)
|
|
5
|
+
faraday (>= 2.0.1)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.8.9)
|
|
11
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
12
|
+
connection_pool (3.0.2)
|
|
13
|
+
diff-lcs (1.6.2)
|
|
14
|
+
faraday (2.14.1)
|
|
15
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
16
|
+
json
|
|
17
|
+
logger
|
|
18
|
+
faraday-net_http (3.4.2)
|
|
19
|
+
net-http (~> 0.5)
|
|
20
|
+
faraday-net_http_persistent (2.3.1)
|
|
21
|
+
faraday (~> 2.5)
|
|
22
|
+
net-http-persistent (>= 4.0.4, < 5)
|
|
23
|
+
faraday-retry (2.4.0)
|
|
24
|
+
faraday (~> 2.0)
|
|
25
|
+
json (2.19.2)
|
|
26
|
+
logger (1.7.0)
|
|
27
|
+
net-http (0.9.1)
|
|
28
|
+
uri (>= 0.11.1)
|
|
29
|
+
net-http-persistent (4.0.8)
|
|
30
|
+
connection_pool (>= 2.2.4, < 4)
|
|
31
|
+
octokit (10.0.0)
|
|
32
|
+
faraday (>= 1, < 3)
|
|
33
|
+
sawyer (~> 0.9)
|
|
34
|
+
public_suffix (7.0.5)
|
|
35
|
+
rake (13.3.1)
|
|
36
|
+
rspec (3.13.2)
|
|
37
|
+
rspec-core (~> 3.13.0)
|
|
38
|
+
rspec-expectations (~> 3.13.0)
|
|
39
|
+
rspec-mocks (~> 3.13.0)
|
|
40
|
+
rspec-core (3.13.6)
|
|
41
|
+
rspec-support (~> 3.13.0)
|
|
42
|
+
rspec-expectations (3.13.5)
|
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
+
rspec-support (~> 3.13.0)
|
|
45
|
+
rspec-mocks (3.13.8)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.13.0)
|
|
48
|
+
rspec-support (3.13.7)
|
|
49
|
+
sawyer (0.9.3)
|
|
50
|
+
addressable (>= 2.3.5)
|
|
51
|
+
faraday (>= 0.17.3, < 3)
|
|
52
|
+
uri (1.1.1)
|
|
53
|
+
|
|
54
|
+
PLATFORMS
|
|
55
|
+
ruby
|
|
56
|
+
|
|
57
|
+
DEPENDENCIES
|
|
58
|
+
antbird!
|
|
59
|
+
faraday-net_http_persistent
|
|
60
|
+
faraday-retry
|
|
61
|
+
octokit
|
|
62
|
+
rake (~> 13.0)
|
|
63
|
+
rspec (~> 3.0)
|
|
64
|
+
|
|
65
|
+
BUNDLED WITH
|
|
66
|
+
4.0.8
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Antbird
|
|
2
2
|
|
|
3
|
-
Nearly auto-generated
|
|
3
|
+
Nearly auto-generated OpenSearch client (supports OpenSearch 3.x)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/fukayatsu/antbird/actions)
|
|
5
|
+
[](https://github.com/fukayatsu/antbird/actions)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ client = Antbird::Client.new
|
|
|
29
29
|
|
|
30
30
|
# OR
|
|
31
31
|
|
|
32
|
-
client = Antbird::Client.new.scoped(index: 'test-index'
|
|
32
|
+
client = Antbird::Client.new.scoped(index: 'test-index')
|
|
33
33
|
|
|
34
34
|
# OR
|
|
35
35
|
|
|
@@ -37,19 +37,17 @@ client = Antbird::Client.new(
|
|
|
37
37
|
url: 'http://localhost:9200',
|
|
38
38
|
scope: {
|
|
39
39
|
index: 'test-index',
|
|
40
|
-
type: 'test-type'
|
|
41
40
|
}
|
|
42
41
|
)
|
|
43
42
|
|
|
44
|
-
# OR
|
|
43
|
+
# OR with AWS OpenSearch Service
|
|
45
44
|
|
|
46
45
|
require 'faraday/net_http_persistent'
|
|
47
46
|
require 'faraday_middleware/aws_sigv4'
|
|
48
47
|
client = Antbird::Client.new(
|
|
49
|
-
url: ENV['
|
|
48
|
+
url: ENV['AMAZON_OPENSEARCH_SERVICE_URL'],
|
|
50
49
|
scope: {
|
|
51
50
|
index: 'test-index',
|
|
52
|
-
type: 'test-type'
|
|
53
51
|
},
|
|
54
52
|
adapter: :net_http_persistent
|
|
55
53
|
) do |f|
|
|
@@ -68,7 +66,7 @@ end
|
|
|
68
66
|
|
|
69
67
|
```ruby
|
|
70
68
|
client = Antbird::Client.new(
|
|
71
|
-
scope: { index: 'test-index'
|
|
69
|
+
scope: { index: 'test-index' }
|
|
72
70
|
)
|
|
73
71
|
|
|
74
72
|
client.indices_exists? # => false
|
|
@@ -76,10 +74,8 @@ client.indices_create(
|
|
|
76
74
|
body: {
|
|
77
75
|
settings: { number_of_shards: 1 },
|
|
78
76
|
mappings: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
field1: { type: :text }
|
|
82
|
-
}
|
|
77
|
+
properties: {
|
|
78
|
+
field1: { type: :text }
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
81
|
}
|
|
@@ -113,9 +109,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
113
109
|
|
|
114
110
|
Bug reports and pull requests are welcome on GitHub at https://github.com/fukayatsu/antbird. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
115
111
|
|
|
116
|
-
### How to support newer version of
|
|
112
|
+
### How to support newer version of OpenSearch
|
|
117
113
|
|
|
118
|
-
1. Add
|
|
114
|
+
1. Add OpenSearch version to `jobs.build.strategy.matrix.search_versions` on `.github/workflows/build-os.yml`
|
|
119
115
|
- Only one line for `x.y.*` version
|
|
120
116
|
1. `script/generate_api_methods`
|
|
121
117
|
- Set `GITHUB_TOKEN=***` env for GitHub API Limit
|
|
@@ -126,4 +122,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
126
122
|
|
|
127
123
|
## Code of Conduct
|
|
128
124
|
|
|
129
|
-
Everyone interacting in the Antbird project
|
|
125
|
+
Everyone interacting in the Antbird project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fukayatsu/antbird/blob/master/CODE_OF_CONDUCT.md).
|
data/antbird.gemspec
CHANGED
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ["fukayatsu"]
|
|
10
10
|
spec.email = ["fukayatsu@gmail.com"]
|
|
11
11
|
|
|
12
|
-
spec.summary = %q{Nearly auto-generated
|
|
13
|
-
spec.description = %q{Antbird is a yet another low level API client for the
|
|
12
|
+
spec.summary = %q{Nearly auto-generated OpenSearch client}
|
|
13
|
+
spec.description = %q{Antbird is a yet another low level API client for the OpenSearch HTTP interface.}
|
|
14
14
|
spec.homepage = "https://github.com/fukayatsu/antbird"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
@@ -20,13 +20,12 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
spec.bindir = "exe"
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
|
-
spec.required_ruby_version = ">=
|
|
23
|
+
spec.required_ruby_version = ">= 3.3.0"
|
|
24
24
|
|
|
25
25
|
spec.add_dependency "faraday", ">= 2.0.1"
|
|
26
26
|
|
|
27
27
|
spec.add_development_dependency "faraday-retry"
|
|
28
28
|
spec.add_development_dependency "faraday-net_http_persistent"
|
|
29
|
-
spec.add_development_dependency "bundler", "> 1.16", "< 3.0"
|
|
30
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
31
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
32
31
|
spec.add_development_dependency "octokit"
|
data/lib/antbird/client.rb
CHANGED
|
@@ -7,7 +7,6 @@ module Antbird
|
|
|
7
7
|
scope: {},
|
|
8
8
|
url: "http://localhost:9200",
|
|
9
9
|
version: nil,
|
|
10
|
-
distribution: nil,
|
|
11
10
|
read_timeout: 5,
|
|
12
11
|
open_timeout: 2,
|
|
13
12
|
adapter: ::Faraday.default_adapter,
|
|
@@ -21,14 +20,11 @@ module Antbird
|
|
|
21
20
|
|
|
22
21
|
@scope = scope.transform_keys(&:to_sym)
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
@version = version
|
|
26
|
-
@distribution = distribution
|
|
27
|
-
end
|
|
23
|
+
@version = version
|
|
28
24
|
|
|
29
25
|
@api_specs = {}
|
|
30
26
|
end
|
|
31
|
-
attr_reader :scope, :url
|
|
27
|
+
attr_reader :scope, :url
|
|
32
28
|
attr_reader :read_timeout, :open_timeout, :adapter
|
|
33
29
|
attr_reader :api_specs, :last_request
|
|
34
30
|
|
|
@@ -37,17 +33,18 @@ module Antbird
|
|
|
37
33
|
scope: new_scope,
|
|
38
34
|
url: url,
|
|
39
35
|
version: version,
|
|
40
|
-
distribution: distribution,
|
|
41
36
|
read_timeout: read_timeout,
|
|
42
|
-
open_timeout: open_timeout
|
|
37
|
+
open_timeout: open_timeout,
|
|
38
|
+
adapter: adapter,
|
|
39
|
+
&@block
|
|
43
40
|
)
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
def request(api_name, api_spec, params)
|
|
47
|
-
validate_params(api_spec, params)
|
|
43
|
+
def request(api_name, api_spec, params, path_params = [:index, :type, :id])
|
|
44
|
+
validate_params(api_spec, params, path_params)
|
|
48
45
|
|
|
49
46
|
body = extract_body(params)
|
|
50
|
-
scopes = extract_scopes(params)
|
|
47
|
+
scopes = extract_scopes(params, path_params)
|
|
51
48
|
forced_method = extract_method(params)
|
|
52
49
|
|
|
53
50
|
# Greedy match
|
|
@@ -148,9 +145,9 @@ module Antbird
|
|
|
148
145
|
params.delete(:method)&.to_sym
|
|
149
146
|
end
|
|
150
147
|
|
|
151
|
-
def extract_scopes(params)
|
|
148
|
+
def extract_scopes(params, path_params = [:index, :type, :id])
|
|
152
149
|
scopes = {}
|
|
153
|
-
|
|
150
|
+
path_params.each do |s|
|
|
154
151
|
scope = params.delete(s)
|
|
155
152
|
next unless scope
|
|
156
153
|
scopes[s] = scope
|
|
@@ -195,32 +192,10 @@ module Antbird
|
|
|
195
192
|
end
|
|
196
193
|
end
|
|
197
194
|
|
|
198
|
-
def elasticsearch?
|
|
199
|
-
!opensearch?
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
def opensearch?
|
|
203
|
-
ensure_version_and_distribution
|
|
204
|
-
|
|
205
|
-
distribution == 'opensearch'
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def elasticsearch_v7_0_compatible?
|
|
209
|
-
return true if opensearch?
|
|
210
|
-
|
|
211
|
-
elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.0.0')
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def elasticsearch_v7_6_compatible?
|
|
215
|
-
return true if opensearch?
|
|
216
|
-
|
|
217
|
-
elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.6.0')
|
|
218
|
-
end
|
|
219
|
-
|
|
220
195
|
def version
|
|
221
196
|
return @version if @version
|
|
222
197
|
|
|
223
|
-
|
|
198
|
+
ensure_version
|
|
224
199
|
@version
|
|
225
200
|
end
|
|
226
201
|
|
|
@@ -246,16 +221,50 @@ module Antbird
|
|
|
246
221
|
end
|
|
247
222
|
end
|
|
248
223
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
# TODO case: invalid parameter format
|
|
224
|
+
SPECIAL_PARAMS = %i[body method read_timeout].freeze
|
|
225
|
+
|
|
226
|
+
def validate_params(api_spec, params, path_params)
|
|
253
227
|
if api_spec.dig('body', 'required') && !params.key?(:body)
|
|
254
228
|
raise ArgumentError, 'Body is missing'
|
|
255
229
|
end
|
|
230
|
+
|
|
231
|
+
return unless api_spec.key?('params')
|
|
232
|
+
|
|
233
|
+
api_params = api_spec['params']
|
|
234
|
+
common = respond_to?(:common_params) ? common_params.fetch('params', {}).keys.map(&:to_sym) : []
|
|
235
|
+
valid_keys = api_params.keys.map(&:to_sym) + path_params + SPECIAL_PARAMS + common
|
|
236
|
+
|
|
237
|
+
unknown = params.keys - valid_keys
|
|
238
|
+
unless unknown.empty?
|
|
239
|
+
raise ArgumentError, "Unknown parameters: #{unknown.join(', ')}"
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
api_params.each do |name, defn|
|
|
243
|
+
if defn['required'] && !params.key?(name.to_sym)
|
|
244
|
+
raise ArgumentError, "Required parameter missing: #{name}"
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
value = params[name.to_sym]
|
|
248
|
+
next if value.nil?
|
|
249
|
+
|
|
250
|
+
validate_param_type(name, value, defn['type'])
|
|
251
|
+
end
|
|
256
252
|
end
|
|
257
253
|
|
|
258
|
-
def
|
|
254
|
+
def validate_param_type(name, value, type)
|
|
255
|
+
case type
|
|
256
|
+
when 'boolean'
|
|
257
|
+
unless value == true || value == false
|
|
258
|
+
raise ArgumentError, "Parameter '#{name}' must be a boolean"
|
|
259
|
+
end
|
|
260
|
+
when 'number', 'integer', 'int'
|
|
261
|
+
unless value.is_a?(Numeric)
|
|
262
|
+
raise ArgumentError, "Parameter '#{name}' must be a number"
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def ensure_version
|
|
259
268
|
return if @version
|
|
260
269
|
|
|
261
270
|
response = connection.get('/')
|
|
@@ -265,26 +274,27 @@ module Antbird
|
|
|
265
274
|
|
|
266
275
|
version_hash = response.body.dig('version')
|
|
267
276
|
@version = version_hash['number']
|
|
268
|
-
@distribution = version_hash['distribution']
|
|
269
277
|
end
|
|
270
278
|
|
|
271
279
|
def class_version
|
|
272
280
|
version.split('.')[0, 2].join('_')
|
|
273
281
|
end
|
|
274
282
|
|
|
283
|
+
SUPPORTED_MAJOR_VERSION = 3
|
|
284
|
+
|
|
275
285
|
def ensure_api_spec_loaded
|
|
276
286
|
return if api_specs_loaded?
|
|
277
287
|
|
|
278
|
-
|
|
288
|
+
ensure_version
|
|
279
289
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
else
|
|
284
|
-
require "antbird/rest_api/rest_api_v#{class_version}"
|
|
285
|
-
extend Antbird::RestApi.const_get "RestApiV#{class_version}"
|
|
290
|
+
major = version.split('.').first.to_i
|
|
291
|
+
unless major == SUPPORTED_MAJOR_VERSION
|
|
292
|
+
raise "Unsupported OpenSearch version: #{version}. Antbird currently supports OpenSearch #{SUPPORTED_MAJOR_VERSION}.x only."
|
|
286
293
|
end
|
|
287
294
|
|
|
295
|
+
require "antbird/rest_api/rest_api_opensearch_v#{class_version}"
|
|
296
|
+
extend Antbird::RestApi.const_get "RestApiOpensearchV#{class_version}"
|
|
297
|
+
|
|
288
298
|
@api_specs_loaded = true
|
|
289
299
|
end
|
|
290
300
|
|