antbird 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-os.yml +41 -0
- data/.github/workflows/build.yml +7 -5
- data/README.md +3 -3
- data/lib/antbird/client.rb +40 -7
- data/lib/antbird/rest_api/rest_api_opensearch_v1_0.rb +1222 -0
- data/lib/antbird/rest_api/rest_api_opensearch_v1_1.rb +1222 -0
- data/lib/antbird/rest_api/rest_api_opensearch_v1_2.rb +1222 -0
- data/lib/antbird/rest_api/rest_api_v7_14.rb +3 -3
- data/lib/antbird/rest_api/rest_api_v7_15.rb +3190 -0
- data/lib/antbird/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c8c8fecccb123dbea652666e8c3afe9c0bb82b05addd4c16184285fc8d883fa
|
4
|
+
data.tar.gz: 300f03046a12082dc0f7ee92dc0283f1228cdc6dc1975cfa965e56d7baf065db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e54fed3437d547f92bfead50aeab29612694a955d6ed3f762962eaa29a7bec0743027557c8f0d15c82f032f5f5f188e138eb1a58a53afdb893b4e9abfa09b6
|
7
|
+
data.tar.gz: 37595c88f4e1df53b79d3f859c9a551d9ebfd49fd005f6e75136c91b677c84def615f3022bbac99149da8f00ff1991884c9a18a9d43f50e476fbfe2875adec6a
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: build-os
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
env:
|
5
|
+
ENGINE_NAME: opensearch
|
6
|
+
REST_API_SPEC_REPO: opensearch-project/OpenSearch
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
# https://github.com/opensearch-project/OpenSearch/releases
|
15
|
+
search_versions:
|
16
|
+
- 1.2.0
|
17
|
+
- 1.1.0
|
18
|
+
- 1.0.0
|
19
|
+
services:
|
20
|
+
opensearch:
|
21
|
+
image: opensearchproject/opensearch:${{matrix.search_versions}}
|
22
|
+
ports:
|
23
|
+
- 9200:9200
|
24
|
+
env:
|
25
|
+
discovery.type: single-node
|
26
|
+
plugins.security.disabled: true
|
27
|
+
steps:
|
28
|
+
- name: Configure sysctl limits
|
29
|
+
run: |
|
30
|
+
sudo swapoff -a
|
31
|
+
sudo sysctl -w vm.swappiness=1
|
32
|
+
sudo sysctl -w fs.file-max=262144
|
33
|
+
sudo sysctl -w vm.max_map_count=262144
|
34
|
+
- uses: actions/checkout@v2
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: 2.7
|
38
|
+
bundler-cache: true
|
39
|
+
- name: Wait for OpenSearch
|
40
|
+
run: timeout 60 bash -c "until curl --silent --output /dev/null localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
|
41
|
+
- run: bundle exec rspec
|
data/.github/workflows/build.yml
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
name: build
|
2
2
|
|
3
3
|
on: [push]
|
4
|
+
env:
|
5
|
+
ENGINE_NAME: elasticsearch
|
6
|
+
REST_API_SPEC_REPO: elastic/elasticsearch
|
4
7
|
|
5
8
|
jobs:
|
6
9
|
build:
|
@@ -10,15 +13,15 @@ jobs:
|
|
10
13
|
matrix:
|
11
14
|
# 1. Run script/list_versions
|
12
15
|
# 2. Check https://www.elastic.co/jp/support/eol
|
13
|
-
|
14
|
-
- 7.
|
16
|
+
search_versions:
|
17
|
+
- 7.15.2
|
18
|
+
- 7.14.2
|
15
19
|
- 7.13.4
|
16
20
|
- 7.12.1
|
17
21
|
- 7.11.2
|
18
22
|
- 7.10.2
|
19
23
|
- 7.9.3
|
20
24
|
- 7.8.1
|
21
|
-
- 7.7.1
|
22
25
|
- 6.8.18
|
23
26
|
steps:
|
24
27
|
# @see https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch
|
@@ -31,13 +34,12 @@ jobs:
|
|
31
34
|
- name: Runs Elasticsearch
|
32
35
|
uses: elastic/elastic-github-actions/elasticsearch@master
|
33
36
|
with:
|
34
|
-
stack-version: ${{matrix.
|
37
|
+
stack-version: ${{matrix.search_versions}}
|
35
38
|
- uses: actions/checkout@v2
|
36
39
|
- uses: ruby/setup-ruby@v1
|
37
40
|
with:
|
38
41
|
ruby-version: 2.7
|
39
42
|
bundler-cache: true
|
40
|
-
- run: bundle install --jobs 4 --retry 3
|
41
43
|
- name: Wait for elasticsearch
|
42
44
|
run: timeout 60 bash -c "until curl --silent --output /dev/null localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
|
43
45
|
- run: bundle exec rspec
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Antbird
|
2
2
|
|
3
|
-
Nearly auto-generated Elasticsearch client
|
3
|
+
Nearly auto-generated Elasticsearch/OpenSearch client
|
4
4
|
|
5
5
|
[![Build Status](https://github.com/fukayatsu/antbird/workflows/build/badge.svg)](https://github.com/fukayatsu/antbird/actions)
|
6
6
|
|
@@ -113,9 +113,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
113
113
|
|
114
114
|
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
115
|
|
116
|
-
### How to support newer version of Elasticsearch
|
116
|
+
### How to support newer version of Elasticsearch/OpenSearch
|
117
117
|
|
118
|
-
1. Add Elasticsearch version to `jobs.build.strategy.matrix.
|
118
|
+
1. Add Elasticsearch version to `jobs.build.strategy.matrix.search_versions` on `.github/workflows/build.yml` / `.github/workflows/build-os.yml`
|
119
119
|
- Only one line for `x.y.*` version
|
120
120
|
1. `script/generate_api_methods`
|
121
121
|
- Set `GITHUB_TOKEN=***` env for GitHub API Limit
|
data/lib/antbird/client.rb
CHANGED
@@ -8,6 +8,7 @@ module Antbird
|
|
8
8
|
scope: {},
|
9
9
|
url: "http://localhost:9200",
|
10
10
|
version: nil,
|
11
|
+
distribution: nil,
|
11
12
|
read_timeout: 5,
|
12
13
|
open_timeout: 2,
|
13
14
|
adapter: ::Faraday.default_adapter,
|
@@ -19,12 +20,13 @@ module Antbird
|
|
19
20
|
@block = block
|
20
21
|
@url = url
|
21
22
|
|
22
|
-
@scope
|
23
|
-
@version
|
23
|
+
@scope = scope.transform_keys(&:to_sym)
|
24
|
+
@version = version
|
25
|
+
@distribution = distribution
|
24
26
|
|
25
27
|
@api_specs = {}
|
26
28
|
end
|
27
|
-
attr_reader :scope, :url, :version
|
29
|
+
attr_reader :scope, :url, :version, :distribution
|
28
30
|
attr_reader :read_timeout, :open_timeout, :adapter
|
29
31
|
attr_reader :api_specs, :last_request
|
30
32
|
|
@@ -33,6 +35,7 @@ module Antbird
|
|
33
35
|
scope: new_scope,
|
34
36
|
url: url,
|
35
37
|
version: version,
|
38
|
+
distribution: distribution,
|
36
39
|
read_timeout: read_timeout,
|
37
40
|
open_timeout: open_timeout
|
38
41
|
)
|
@@ -190,6 +193,27 @@ module Antbird
|
|
190
193
|
end
|
191
194
|
end
|
192
195
|
|
196
|
+
def elasticsearch?
|
197
|
+
!opensearch?
|
198
|
+
end
|
199
|
+
|
200
|
+
def opensearch?
|
201
|
+
fetch_version
|
202
|
+
distribution == 'opensearch'
|
203
|
+
end
|
204
|
+
|
205
|
+
def elasticsearch_v7_0_compatible?
|
206
|
+
return true if opensearch?
|
207
|
+
|
208
|
+
elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.0.0')
|
209
|
+
end
|
210
|
+
|
211
|
+
def elasticsearch_v7_6_compatible?
|
212
|
+
return true if opensearch?
|
213
|
+
|
214
|
+
elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.6.0')
|
215
|
+
end
|
216
|
+
|
193
217
|
private
|
194
218
|
|
195
219
|
# NOTE: stable sort
|
@@ -222,16 +246,25 @@ module Antbird
|
|
222
246
|
end
|
223
247
|
|
224
248
|
def fetch_version
|
225
|
-
|
249
|
+
return if @version
|
250
|
+
|
251
|
+
version_hash = connection.get('/').body.dig('version')
|
252
|
+
@version ||= version_hash['number']
|
253
|
+
@distribution ||= version_hash['distribution']
|
226
254
|
end
|
227
255
|
|
228
256
|
def ensure_api_spec_loaded
|
229
257
|
return if api_specs_loaded?
|
230
258
|
|
231
|
-
|
259
|
+
fetch_version
|
232
260
|
class_version = @version.split('.')[0, 2].join('_')
|
233
|
-
|
234
|
-
|
261
|
+
if opensearch?
|
262
|
+
require "antbird/rest_api/rest_api_opensearch_v#{class_version}"
|
263
|
+
extend Antbird::RestApi.const_get "RestApiOpensearchV#{class_version}"
|
264
|
+
else
|
265
|
+
require "antbird/rest_api/rest_api_v#{class_version}"
|
266
|
+
extend Antbird::RestApi.const_get "RestApiV#{class_version}"
|
267
|
+
end
|
235
268
|
|
236
269
|
@api_specs_loaded = true
|
237
270
|
end
|