elasticsearch-api 7.11.2 → 7.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/README.md +22 -45
- data/Rakefile +46 -62
- data/elasticsearch-api.gemspec +6 -7
- data/lib/elasticsearch/api/actions/bulk.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/aliases.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/allocation.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/count.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/health.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/help.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/indices.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/master.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/nodes.rb +4 -2
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/plugins.rb +3 -1
- data/lib/elasticsearch/api/actions/cat/recovery.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/repositories.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/segments.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/shards.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/snapshots.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/templates.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +1 -1
- data/lib/elasticsearch/api/actions/clear_scroll.rb +1 -1
- data/lib/elasticsearch/api/actions/{abort_benchmark.rb → close_point_in_time.rb} +13 -12
- data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +3 -3
- data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +2 -1
- data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/health.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/remote_info.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/state.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/stats.rb +1 -1
- data/lib/elasticsearch/api/actions/count.rb +7 -2
- data/lib/elasticsearch/api/actions/create.rb +1 -1
- data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +1 -1
- data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +1 -1
- data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +1 -1
- data/lib/elasticsearch/api/actions/delete.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_by_query.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_script.rb +1 -1
- data/lib/elasticsearch/api/actions/exists.rb +2 -1
- data/lib/elasticsearch/api/actions/exists_source.rb +2 -1
- data/lib/elasticsearch/api/actions/explain.rb +6 -6
- data/lib/elasticsearch/api/actions/{nodes/shutdown.rb → features/get_features.rb} +16 -21
- data/lib/elasticsearch/api/actions/features/params_registry.rb +60 -0
- data/lib/elasticsearch/api/actions/features/reset_features.rb +47 -0
- data/lib/elasticsearch/api/actions/field_caps.rb +6 -6
- data/lib/elasticsearch/api/actions/get.rb +1 -1
- data/lib/elasticsearch/api/actions/get_script.rb +1 -1
- data/lib/elasticsearch/api/actions/get_script_context.rb +1 -5
- data/lib/elasticsearch/api/actions/get_script_languages.rb +1 -5
- data/lib/elasticsearch/api/actions/get_source.rb +1 -1
- data/lib/elasticsearch/api/actions/index.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/add_block.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/analyze.rb +6 -6
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/clone.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/close.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/create.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +6 -2
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/disk_usage.rb +68 -0
- data/lib/elasticsearch/api/actions/indices/exists.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +7 -2
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/field_usage_stats.rb +66 -0
- data/lib/elasticsearch/api/actions/indices/flush.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/flush_synced.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/forcemerge.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_index_template.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/open.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_index_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/recovery.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/refresh.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/resolve_index.rb +1 -5
- data/lib/elasticsearch/api/actions/indices/rollover.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/segments.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/shard_stores.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/shrink.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/simulate_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/split.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/stats.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/upgrade.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +8 -8
- data/lib/elasticsearch/api/actions/info.rb +1 -1
- data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +1 -1
- data/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb +43 -0
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +3 -1
- data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +1 -1
- data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +3 -1
- data/lib/elasticsearch/api/actions/ingest/simulate.rb +1 -1
- data/lib/elasticsearch/api/actions/mget.rb +1 -1
- data/lib/elasticsearch/api/actions/msearch.rb +2 -2
- data/lib/elasticsearch/api/actions/msearch_template.rb +2 -2
- data/lib/elasticsearch/api/actions/mtermvectors.rb +8 -8
- data/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb +56 -0
- data/lib/elasticsearch/api/actions/nodes/get_repositories_metering_info.rb +52 -0
- data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +4 -2
- data/lib/elasticsearch/api/actions/nodes/info.rb +2 -2
- data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/nodes/stats.rb +5 -3
- data/lib/elasticsearch/api/actions/nodes/usage.rb +1 -1
- data/lib/elasticsearch/api/actions/open_point_in_time.rb +62 -0
- data/lib/elasticsearch/api/actions/ping.rb +3 -3
- data/lib/elasticsearch/api/actions/put_script.rb +1 -1
- data/lib/elasticsearch/api/actions/rank_eval.rb +1 -5
- data/lib/elasticsearch/api/actions/reindex.rb +1 -1
- data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +1 -1
- data/lib/elasticsearch/api/actions/render_search_template.rb +6 -6
- data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +2 -2
- data/lib/elasticsearch/api/actions/scroll.rb +6 -6
- data/lib/elasticsearch/api/actions/search.rb +11 -9
- data/lib/elasticsearch/api/actions/search_mvt.rb +85 -0
- data/lib/elasticsearch/api/actions/search_shards.rb +1 -1
- data/lib/elasticsearch/api/actions/search_template.rb +2 -2
- data/lib/elasticsearch/api/actions/shutdown/delete_node.rb +48 -0
- data/lib/elasticsearch/api/actions/shutdown/get_node.rb +50 -0
- data/lib/elasticsearch/api/actions/shutdown/params_registry.rb +60 -0
- data/lib/elasticsearch/api/actions/shutdown/put_node.rb +50 -0
- data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/clone.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/create.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/get.rb +5 -1
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb +76 -0
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/status.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/tasks/cancel.rb +1 -1
- data/lib/elasticsearch/api/actions/tasks/get.rb +1 -1
- data/lib/elasticsearch/api/actions/tasks/list.rb +1 -1
- data/lib/elasticsearch/api/actions/termvectors.rb +11 -10
- data/lib/elasticsearch/api/actions/update.rb +1 -1
- data/lib/elasticsearch/api/actions/update_by_query.rb +1 -1
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +1 -1
- data/lib/elasticsearch/api/{actions/remote/info.rb → namespace/features.rb} +12 -13
- data/lib/elasticsearch/api/namespace/security.rb +36 -0
- data/lib/elasticsearch/api/namespace/shutdown.rb +37 -0
- data/lib/elasticsearch/api/version.rb +1 -1
- data/lib/elasticsearch/api.rb +3 -1
- data/spec/elasticsearch/api/actions/{benchmark_spec.rb → close_point_in_time_spec.rb} +6 -6
- data/spec/elasticsearch/api/actions/count_spec.rb +2 -5
- data/spec/elasticsearch/api/actions/{remote/info_spec.rb → features/get_features_spec.rb} +7 -8
- data/spec/elasticsearch/api/actions/features/reset_features_spec.rb +34 -0
- data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +16 -3
- data/spec/elasticsearch/api/actions/indices/disk_usage_spec.rb +48 -0
- data/spec/elasticsearch/api/actions/indices/field_usage_stats_spec.rb +46 -0
- data/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb +34 -0
- data/spec/elasticsearch/api/actions/nodes/clear_repositories_metering_archive_spec.rb +51 -0
- data/spec/elasticsearch/api/actions/nodes/get_repositories_metering_info_spec.rb +44 -0
- data/spec/elasticsearch/api/actions/{abort_benchmark_spec.rb → open_point_in_time_spec.rb} +5 -5
- data/spec/elasticsearch/api/actions/search_mvt_spec.rb +52 -0
- data/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb +44 -0
- data/spec/elasticsearch/api/actions/shutdown/get_node_spec.rb +46 -0
- data/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb +50 -0
- data/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb +48 -0
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +23 -3
- data/spec/rest_yaml_tests_helper.rb +17 -53
- data/spec/skipped_tests.yml +29 -0
- data/spec/spec_helper.rb +4 -1
- data/utils/Gemfile +4 -3
- data/utils/README.md +6 -1
- data/utils/thor/.rubocop.yml +2 -0
- data/utils/thor/generate_source.rb +18 -13
- data/utils/thor/generator/endpoint_specifics.rb +7 -1
- data/utils/thor/generator/files_helper.rb +38 -20
- data/utils/thor/templates/_documentation_top.erb +19 -0
- data/utils/thor/templates/_method_setup.erb +18 -0
- data/utils/thor/templates/_params_registry.erb +19 -0
- data/utils/thor/templates/_perform_request.erb +19 -1
- data/utils/thor/templates/test.erb +16 -3
- data/utils/thor/templates/test_helper.rb +0 -4
- metadata +58 -48
- data/lib/elasticsearch/api/actions/benchmark.rb +0 -81
- data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +0 -47
- data/lib/elasticsearch/api/actions/indices/freeze.rb +0 -56
- data/lib/elasticsearch/api/actions/indices/unfreeze.rb +0 -56
- data/spec/elasticsearch/api/actions/indices/freeze_spec.rb +0 -85
- data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +0 -85
- data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +0 -76
@@ -0,0 +1,51 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
|
21
|
+
describe 'client.nodes#clear_metering_archive' do
|
22
|
+
let(:expected_args) do
|
23
|
+
[
|
24
|
+
'DELETE',
|
25
|
+
'_nodes/foo/_repositories_metering/bar',
|
26
|
+
{},
|
27
|
+
nil,
|
28
|
+
{}
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'performs the request' do
|
33
|
+
expect(client_double.nodes.clear_repositories_metering_archive(node_id: 'foo', max_archive_version: 'bar')).to eq({})
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:client) do
|
37
|
+
Class.new { include Elasticsearch::API }.new
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'raises an error if no node_id is provided' do
|
41
|
+
expect do
|
42
|
+
client.nodes.clear_repositories_metering_archive(max_archive_version: 'bar')
|
43
|
+
end.to raise_exception(ArgumentError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an error if no max_archive_version is provided' do
|
47
|
+
expect do
|
48
|
+
client.nodes.clear_repositories_metering_archive(node_id: 'foo')
|
49
|
+
end.to raise_exception(ArgumentError)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client.nodes#get_metering_info' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'GET',
|
24
|
+
'_nodes/foo/_repositories_metering',
|
25
|
+
{},
|
26
|
+
nil,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'performs the request' do
|
32
|
+
expect(client_double.nodes.get_repositories_metering_info(node_id: 'foo', max_archive_version: 'bar')).to eq({})
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:client) do
|
36
|
+
Class.new { include Elasticsearch::API }.new
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an error if no node_id is provided' do
|
40
|
+
expect do
|
41
|
+
client.nodes.get_repositories_metering_info
|
42
|
+
end.to raise_exception(ArgumentError)
|
43
|
+
end
|
44
|
+
end
|
@@ -17,18 +17,18 @@
|
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
describe 'client#
|
21
|
-
|
20
|
+
describe 'client#open_point_in_time' do
|
22
21
|
let(:expected_args) do
|
23
22
|
[
|
24
23
|
'POST',
|
25
|
-
'
|
24
|
+
'foo/_pit',
|
26
25
|
{},
|
27
|
-
nil
|
26
|
+
nil,
|
27
|
+
{}
|
28
28
|
]
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'performs the request' do
|
32
|
-
expect(client_double.
|
32
|
+
expect(client_double.open_point_in_time(index: 'foo')).to eq({})
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client#search_mvt' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'POST',
|
24
|
+
url,
|
25
|
+
params,
|
26
|
+
body,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with right parameters' do
|
32
|
+
let(:url) { 'foo/_mvt/field/10/57.2127/6.2348' }
|
33
|
+
let(:params) { {} }
|
34
|
+
let(:body) { nil }
|
35
|
+
|
36
|
+
it 'performs the request' do
|
37
|
+
expect(client_double.search_mvt(index: 'foo', field: 'field', zoom: 10, x: 57.2127, y: 6.2348)).to eq({})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when a param is missing' do
|
42
|
+
let(:client) do
|
43
|
+
Class.new { include Elasticsearch::API }.new
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an ArgumentError' do
|
47
|
+
expect{
|
48
|
+
client.search_mvt
|
49
|
+
}.to raise_exception(ArgumentError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client.shutdown#delete_node' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'DELETE',
|
24
|
+
'_nodes/id/shutdown',
|
25
|
+
{},
|
26
|
+
nil,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'performs the request' do
|
32
|
+
expect(client_double.shutdown.delete_node(node_id: 'id')).to eq({})
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:client) do
|
36
|
+
Class.new { include Elasticsearch::API }.new
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an error if no node_id is provided' do
|
40
|
+
expect {
|
41
|
+
client.shutdown.delete_node
|
42
|
+
}.to raise_exception(ArgumentError)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client.shutdown#get_node' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'GET',
|
24
|
+
url,
|
25
|
+
{},
|
26
|
+
nil,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when id is provided' do
|
32
|
+
let(:url) { '_nodes/id/shutdown' }
|
33
|
+
|
34
|
+
it 'performs the request' do
|
35
|
+
expect(client_double.shutdown.get_node(node_id: 'id')).to eq({})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when no id is provided' do
|
40
|
+
let(:url) { '_nodes/shutdown' }
|
41
|
+
|
42
|
+
it 'performs the request' do
|
43
|
+
expect(client_double.shutdown.get_node).to eq({})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client.shutdown#put_node' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'PUT',
|
24
|
+
'_nodes/id/shutdown',
|
25
|
+
{},
|
26
|
+
{},
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'performs the request' do
|
32
|
+
expect(client_double.shutdown.put_node(body: {}, node_id: 'id')).to eq({})
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:client) do
|
36
|
+
Class.new { include Elasticsearch::API }.new
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an error if no node_id is provided' do
|
40
|
+
expect {
|
41
|
+
client.shutdown.put_node(body: {})
|
42
|
+
}.to raise_exception(ArgumentError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'raises an error if no body is provided' do
|
46
|
+
expect {
|
47
|
+
client.shutdown.put_node(node_id: 'id')
|
48
|
+
}.to raise_exception(ArgumentError)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client.snapshot#repository_analyze' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'POST',
|
24
|
+
url,
|
25
|
+
{},
|
26
|
+
nil,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:url) do
|
32
|
+
'_snapshot/foo/_analyze'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'performs the request' do
|
36
|
+
expect(client_double.snapshot.repository_analyze(repository: 'foo')).to eq({})
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:client) do
|
40
|
+
Class.new { include Elasticsearch::API }.new
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'requires the :repository argument' do
|
44
|
+
expect {
|
45
|
+
client.snapshot.repository_analyze
|
46
|
+
}.to raise_exception(ArgumentError)
|
47
|
+
end
|
48
|
+
end
|
@@ -1,11 +1,31 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
4
8
|
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
5
18
|
require 'spec_helper'
|
6
19
|
require 'rest_yaml_tests_helper'
|
7
20
|
|
8
21
|
describe 'Rest API YAML tests' do
|
22
|
+
if REST_API_YAML_FILES.empty?
|
23
|
+
logger = Logger.new($stdout)
|
24
|
+
logger.error 'No test files found!'
|
25
|
+
logger.info 'Use rake rake elasticsearch:download_artifacts in the root directory of the project to download the test artifacts.'
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
9
29
|
# Traverse YAML files and create TestFile object:
|
10
30
|
REST_API_YAML_FILES.each do |file|
|
11
31
|
begin
|
@@ -18,9 +18,10 @@
|
|
18
18
|
require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/test_file"
|
19
19
|
require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/rspec_matchers"
|
20
20
|
include Elasticsearch::RestAPIYAMLTests
|
21
|
+
require 'elasticsearch/xpack'
|
21
22
|
|
22
23
|
TRANSPORT_OPTIONS = {}
|
23
|
-
PROJECT_PATH = File.join(File.dirname(__FILE__), '..'
|
24
|
+
PROJECT_PATH = File.join(File.dirname(__FILE__), '..')
|
24
25
|
|
25
26
|
if (hosts = ELASTICSEARCH_URL)
|
26
27
|
split_hosts = hosts.split(',').map do |host|
|
@@ -47,71 +48,34 @@ if defined?(TEST_HOST) && defined?(TEST_PORT)
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
YAML_FILES_DIRECTORY = "#{File.expand_path(File.dirname('..'), '..')}" +
|
52
|
-
'/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test'
|
51
|
+
YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/test/free"
|
53
52
|
|
54
53
|
SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
|
55
54
|
test_target = ENV['SINGLE_TEST']
|
56
|
-
path = File.expand_path(File.dirname('..'), '..')
|
57
55
|
|
58
56
|
if test_target.match?(/\.yml$/)
|
59
|
-
["#{
|
57
|
+
["#{PROJECT_PATH}/../tmp/rest-api-spec/test/free/#{test_target}"]
|
60
58
|
else
|
61
59
|
Dir.glob(
|
62
|
-
["#{
|
60
|
+
["#{PROJECT_PATH}/../tmp/rest-api-spec/test/free/#{test_target}/*.yml"]
|
63
61
|
)
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
skipped_tests << { file: 'cat.aliases/20_headers.yml',
|
71
|
-
description: 'Simple alias with yaml body through Accept header' }
|
72
|
-
|
73
|
-
# Check version skip logic
|
74
|
-
skipped_tests << { file: 'create/15_without_id.yml',
|
75
|
-
description: 'Create without ID' }
|
76
|
-
|
77
|
-
# No error is raised
|
78
|
-
skipped_tests << { file: 'create/15_without_id_with_types.yml',
|
79
|
-
description: 'Create without ID' }
|
80
|
-
|
81
|
-
# Error message doesn't match
|
82
|
-
skipped_tests << { file: 'tasks.get/10_basic.yml',
|
83
|
-
description: 'get task test' }
|
84
|
-
|
85
|
-
# No error is raised
|
86
|
-
skipped_tests << { file: 'cat.allocation/10_basic.yml',
|
87
|
-
description: '*' }
|
88
|
-
|
89
|
-
# Figure out how to match response when there is an error
|
90
|
-
skipped_tests << { file: 'delete/70_mix_typeless_typeful.yml',
|
91
|
-
description: '*' }
|
92
|
-
|
93
|
-
# Figure out how to match response when there is an error
|
94
|
-
skipped_tests << { file: 'cat.templates/10_basic.yml',
|
95
|
-
description: '*' }
|
96
|
-
|
97
|
-
# Responses are there but not equal (eg.: yellow status)
|
98
|
-
skipped_tests << { file: 'cluster.health/10_basic.yml',
|
99
|
-
description: 'cluster health with closed index (pre 7.2.0)' }
|
100
|
-
|
101
|
-
# Regular expression not catching exact match:
|
102
|
-
skipped_tests << { file: 'cat.indices/10_basic.yml',
|
103
|
-
description: 'Test cat indices output for closed index (pre 7.2.0)' }
|
104
|
-
|
105
|
-
# TODO
|
106
|
-
skipped_tests << {
|
107
|
-
file: 'nodes.info/10_basic.yml',
|
108
|
-
description: 'node_info role test'
|
109
|
-
}
|
110
|
-
|
111
|
-
SKIPPED_TESTS = skipped_tests
|
65
|
+
# Skipped tests
|
66
|
+
file = File.expand_path("#{__dir__}/skipped_tests.yml")
|
67
|
+
skipped_tests = YAML.load_file(file)
|
112
68
|
|
113
69
|
# The directory of rest api YAML files.
|
114
|
-
REST_API_YAML_FILES =
|
70
|
+
REST_API_YAML_FILES = if ENV['RUN_SKIPPED_TESTS'] # only run the skipped tests if true
|
71
|
+
SKIPPED_TESTS = []
|
72
|
+
skipped_tests.map { |test| "#{YAML_FILES_DIRECTORY}/#{test[:file]}" }
|
73
|
+
else
|
74
|
+
# If not, define the skipped tests constant and try the single test or all
|
75
|
+
# the tests
|
76
|
+
SKIPPED_TESTS = skipped_tests
|
77
|
+
SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
|
78
|
+
end
|
115
79
|
|
116
80
|
# The features to skip
|
117
81
|
REST_API_YAML_SKIP_FEATURES = ['warnings', 'node_selector'].freeze
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Response from Elasticsearch is just a String, so it's not possible to compare using headers.
|
2
|
+
-
|
3
|
+
:file: 'cat.aliases/20_headers.yml'
|
4
|
+
:description: 'Simple alias with yaml body through Accept header'
|
5
|
+
|
6
|
+
# Check version skip logic
|
7
|
+
-
|
8
|
+
:file: 'create/15_without_id.yml'
|
9
|
+
:description: 'Create without ID'
|
10
|
+
|
11
|
+
# No error is raised
|
12
|
+
-
|
13
|
+
:file: 'create/15_without_id_with_types.yml'
|
14
|
+
:description: 'Create without ID'
|
15
|
+
|
16
|
+
# Error message doesn't match
|
17
|
+
-
|
18
|
+
:file: 'tasks.get/10_basic.yml'
|
19
|
+
:description: 'get task test'
|
20
|
+
|
21
|
+
# Figure out how to match response when there is an error
|
22
|
+
-
|
23
|
+
:file: 'delete/70_mix_typeless_typeful.yml'
|
24
|
+
:description: '*'
|
25
|
+
|
26
|
+
# Figure out how to match response when there is an error
|
27
|
+
-
|
28
|
+
:file: 'cat.templates/10_basic.yml'
|
29
|
+
:description: '*'
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,10 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
|
+
if ENV['COVERAGE'] && ENV['CI'].nil?
|
18
|
+
require 'simplecov'
|
19
|
+
SimpleCov.start { add_filter %r{^/test|spec/} }
|
20
|
+
end
|
17
21
|
|
18
22
|
if defined?(JRUBY_VERSION)
|
19
23
|
require 'pry-nav'
|
@@ -42,7 +46,6 @@ DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
|
|
42
46
|
|
43
47
|
module HelperModule
|
44
48
|
def self.included(context)
|
45
|
-
|
46
49
|
context.let(:client_double) do
|
47
50
|
Class.new { include Elasticsearch::API }.new.tap do |client|
|
48
51
|
expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double)
|
data/utils/Gemfile
CHANGED
@@ -18,10 +18,11 @@
|
|
18
18
|
source 'https://rubygems.org'
|
19
19
|
|
20
20
|
gem 'activesupport'
|
21
|
-
gem '
|
21
|
+
gem 'byebug'
|
22
22
|
gem 'coderay'
|
23
|
-
gem 'multi_json'
|
24
|
-
gem 'thor'
|
25
23
|
gem 'json'
|
24
|
+
gem 'multi_json'
|
26
25
|
gem 'pry'
|
26
|
+
gem 'rest-client'
|
27
27
|
gem 'rubocop'
|
28
|
+
gem 'thor'
|
data/utils/README.md
CHANGED
@@ -6,7 +6,12 @@ This directory hosts The Generator, a tool that generates the classes for each A
|
|
6
6
|
|
7
7
|
### Generate
|
8
8
|
|
9
|
-
To generate the code, you need to run
|
9
|
+
To generate the code, you need to have the Elasticsearch REST API spec files in `tmp/rest-api-spec` in the root of the project. You can run a rake task from the root of the project to download the specs corresponding to the current running cluster:
|
10
|
+
```bash
|
11
|
+
$ rake elasticsearch:download_artifacts
|
12
|
+
```
|
13
|
+
|
14
|
+
Once the JSON files have been downloaded, you need to run (from this folder):
|
10
15
|
```bash
|
11
16
|
$ thor api:code:generate
|
12
17
|
```
|
data/utils/thor/.rubocop.yml
CHANGED
@@ -66,11 +66,10 @@ module Elasticsearch
|
|
66
66
|
|
67
67
|
def __generate_source(api)
|
68
68
|
@current_api = api
|
69
|
-
@input = FilesHelper.input_dir(api)
|
70
69
|
@output = FilesHelper.output_dir(api)
|
71
70
|
|
72
71
|
FilesHelper.files(api).each do |filepath|
|
73
|
-
@path = Pathname(
|
72
|
+
@path = Pathname(filepath)
|
74
73
|
@json = MultiJson.load(File.read(@path))
|
75
74
|
@spec = @json.values.first
|
76
75
|
say_status 'json', @path, :yellow
|
@@ -149,6 +148,7 @@ module Elasticsearch
|
|
149
148
|
|
150
149
|
def __http_method
|
151
150
|
return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
|
151
|
+
return post_and_get if @endpoint_name == 'count'
|
152
152
|
|
153
153
|
default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first
|
154
154
|
if @spec['body'] && default_method == 'GET'
|
@@ -156,19 +156,23 @@ module Elasticsearch
|
|
156
156
|
if @spec['body']['required']
|
157
157
|
'Elasticsearch::API::HTTP_POST'
|
158
158
|
else
|
159
|
-
|
160
|
-
if arguments[:body]
|
161
|
-
Elasticsearch::API::HTTP_POST
|
162
|
-
else
|
163
|
-
Elasticsearch::API::HTTP_GET
|
164
|
-
end
|
165
|
-
SRC
|
159
|
+
post_and_get
|
166
160
|
end
|
167
161
|
else
|
168
162
|
"Elasticsearch::API::HTTP_#{default_method}"
|
169
163
|
end
|
170
164
|
end
|
171
165
|
|
166
|
+
def post_and_get
|
167
|
+
<<~SRC
|
168
|
+
if arguments[:body]
|
169
|
+
Elasticsearch::API::HTTP_POST
|
170
|
+
else
|
171
|
+
Elasticsearch::API::HTTP_GET
|
172
|
+
end
|
173
|
+
SRC
|
174
|
+
end
|
175
|
+
|
172
176
|
def __http_path
|
173
177
|
return "\"#{__parse_path(@paths.first)}\"" if @paths.size == 1
|
174
178
|
return termvectors_path if @method_name == 'termvectors'
|
@@ -195,9 +199,9 @@ module Elasticsearch
|
|
195
199
|
|
196
200
|
def __parse_path(path)
|
197
201
|
path.gsub(/^\//, '')
|
198
|
-
|
199
|
-
|
200
|
-
|
202
|
+
.gsub(/\/$/, '')
|
203
|
+
.gsub('{', "\#{#{__utils}.__listify(_")
|
204
|
+
.gsub('}', ')}')
|
201
205
|
end
|
202
206
|
|
203
207
|
def __path_variables
|
@@ -227,6 +231,7 @@ module Elasticsearch
|
|
227
231
|
|
228
232
|
def docs_helper(name, info)
|
229
233
|
info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings'
|
234
|
+
info['type'] = 'Integer' if info['type'] == 'int' # Rename 'int' to 'Integer'
|
230
235
|
tipo = info['type'] ? info['type'].capitalize : 'String'
|
231
236
|
description = info['description'] ? info['description'].strip : '[TODO]'
|
232
237
|
options = info['options'] ? "(options: #{info['options'].join(', ').strip})" : nil
|
@@ -291,7 +296,7 @@ module Elasticsearch
|
|
291
296
|
end
|
292
297
|
|
293
298
|
def __utils
|
294
|
-
|
299
|
+
@current_api == :xpack ? 'Elasticsearch::API::Utils' : 'Utils'
|
295
300
|
end
|
296
301
|
|
297
302
|
def run_rubocop(api)
|