elasticsearch-api 7.14.1 → 7.16.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -35
- data/Rakefile +0 -14
- data/elasticsearch-api.gemspec +13 -5
- data/lib/elasticsearch/api/actions/bulk.rb +2 -2
- 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 +1 -1
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/plugins.rb +1 -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/close_point_in_time.rb +1 -1
- 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 +1 -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 -7
- 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 +1 -1
- data/lib/elasticsearch/api/actions/exists_source.rb +1 -1
- data/lib/elasticsearch/api/actions/explain.rb +1 -1
- data/lib/elasticsearch/api/actions/features/get_features.rb +1 -1
- data/lib/elasticsearch/api/actions/features/reset_features.rb +1 -1
- data/lib/elasticsearch/api/actions/field_caps.rb +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +5 -2
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +1 -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 +1 -1
- 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 +1 -1
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +1 -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 +1 -1
- data/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb +56 -0
- data/lib/elasticsearch/api/actions/{snapshot/get_features.rb → nodes/get_repositories_metering_info.rb} +15 -14
- 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 +2 -2
- data/lib/elasticsearch/api/actions/nodes/usage.rb +1 -1
- data/lib/elasticsearch/api/actions/open_point_in_time.rb +5 -7
- data/lib/elasticsearch/api/actions/ping.rb +1 -1
- 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 +1 -1
- data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +1 -1
- data/lib/elasticsearch/api/actions/scroll.rb +1 -1
- data/lib/elasticsearch/api/actions/search.rb +1 -1
- 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 +1 -1
- data/lib/elasticsearch/api/actions/shutdown/delete_node.rb +1 -5
- data/lib/elasticsearch/api/actions/shutdown/get_node.rb +1 -5
- data/lib/elasticsearch/api/actions/shutdown/put_node.rb +1 -5
- 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 +1 -1
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb +1 -1
- 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 +1 -1
- data/lib/elasticsearch/api/actions/update.rb +1 -1
- data/lib/elasticsearch/api/actions/update_by_query.rb +1 -7
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +1 -1
- data/lib/elasticsearch/api/utils.rb +7 -3
- data/lib/elasticsearch/api/version.rb +1 -1
- data/spec/elasticsearch/api/actions/count_spec.rb +2 -5
- data/spec/elasticsearch/api/actions/{abort_benchmark_spec.rb → indices/disk_usage_spec.rb} +19 -5
- data/spec/elasticsearch/api/actions/{benchmark_spec.rb → indices/field_usage_stats_spec.rb} +18 -6
- data/spec/elasticsearch/api/actions/nodes/clear_repositories_metering_archive_spec.rb +51 -0
- data/spec/elasticsearch/api/actions/{snapshot/get_features_spec.rb → nodes/get_repositories_metering_info_spec.rb} +10 -4
- data/spec/elasticsearch/api/actions/open_point_in_time_spec.rb +2 -12
- data/spec/elasticsearch/api/actions/{remote/info_spec.rb → search_mvt_spec.rb} +26 -9
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +1 -2
- data/spec/elasticsearch/api/utils_spec.rb +9 -21
- data/spec/rest_yaml_tests_helper.rb +59 -8
- data/spec/spec_helper.rb +5 -1
- data/utils/thor/.rubocop.yml +2 -0
- data/utils/thor/generate_source.rb +17 -11
- data/utils/thor/generator/endpoint_specifics.rb +3 -1
- data/utils/thor/templates/_perform_request.erb +1 -1
- metadata +53 -26
- data/lib/elasticsearch/api/actions/abort_benchmark.rb +0 -41
- 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/nodes/shutdown.rb +0 -56
- data/lib/elasticsearch/api/actions/remote/info.rb +0 -37
- data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +0 -76
@@ -17,18 +17,30 @@
|
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
describe 'client#
|
21
|
-
|
20
|
+
describe 'client.indices#field_usage_stats' do
|
22
21
|
let(:expected_args) do
|
23
22
|
[
|
24
|
-
'
|
25
|
-
'
|
23
|
+
'GET',
|
24
|
+
'foo/_field_usage_stats',
|
26
25
|
{},
|
27
|
-
|
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.indices.field_usage_stats(index: 'foo')).to eq({})
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when there is no index specified' do
|
36
|
+
let(:client) do
|
37
|
+
Class.new { include Elasticsearch::API }.new
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'raises an exception' do
|
41
|
+
expect {
|
42
|
+
client.indices.field_usage_stats
|
43
|
+
}.to raise_exception(ArgumentError)
|
44
|
+
end
|
33
45
|
end
|
34
46
|
end
|
@@ -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
|
@@ -17,22 +17,28 @@
|
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
describe 'client.
|
20
|
+
describe 'client.nodes#get_metering_info' do
|
21
21
|
let(:expected_args) do
|
22
22
|
[
|
23
23
|
'GET',
|
24
|
-
'
|
24
|
+
'_nodes/foo/_repositories_metering',
|
25
25
|
{},
|
26
26
|
nil,
|
27
27
|
{}
|
28
28
|
]
|
29
29
|
end
|
30
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
|
+
|
31
35
|
let(:client) do
|
32
36
|
Class.new { include Elasticsearch::API }.new
|
33
37
|
end
|
34
38
|
|
35
|
-
it '
|
36
|
-
expect
|
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)
|
37
43
|
end
|
38
44
|
end
|
@@ -21,24 +21,14 @@ describe 'client#open_point_in_time' do
|
|
21
21
|
let(:expected_args) do
|
22
22
|
[
|
23
23
|
'POST',
|
24
|
-
|
24
|
+
'foo/_pit',
|
25
25
|
{},
|
26
26
|
nil,
|
27
27
|
{}
|
28
28
|
]
|
29
29
|
end
|
30
30
|
|
31
|
-
let (:url) { '_pit'}
|
32
|
-
|
33
31
|
it 'performs the request' do
|
34
|
-
expect(client_double.open_point_in_time).to eq({})
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with index' do
|
38
|
-
let (:url) { 'foo/_pit'}
|
39
|
-
|
40
|
-
it 'performs the request' do
|
41
|
-
expect(client_double.open_point_in_time(index: 'foo')).to eq({})
|
42
|
-
end
|
32
|
+
expect(client_double.open_point_in_time(index: 'foo')).to eq({})
|
43
33
|
end
|
44
34
|
end
|
@@ -17,19 +17,36 @@
|
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
describe 'client
|
21
|
-
|
20
|
+
describe 'client#search_mvt' do
|
22
21
|
let(:expected_args) do
|
23
22
|
[
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
'POST',
|
24
|
+
url,
|
25
|
+
params,
|
26
|
+
body,
|
27
|
+
{}
|
29
28
|
]
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
|
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
|
34
51
|
end
|
35
52
|
end
|
@@ -50,13 +50,12 @@ describe 'Rest API YAML tests' do
|
|
50
50
|
|
51
51
|
# Runs once before each test in a test file
|
52
52
|
before(:all) do
|
53
|
-
Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
|
54
53
|
test_file.setup
|
55
54
|
end
|
56
55
|
|
57
56
|
after(:all) do
|
58
57
|
test_file.teardown
|
59
|
-
Elasticsearch::RestAPIYAMLTests::
|
58
|
+
Elasticsearch::RestAPIYAMLTests::WipeCluster.run(ADMIN_CLIENT)
|
60
59
|
end
|
61
60
|
|
62
61
|
test.task_groups.each do |task_group|
|
@@ -30,7 +30,7 @@ describe Elasticsearch::API::Utils do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'encodes special characters' do
|
33
|
-
expect(utils.__escape('foo bar')).to eq('foo
|
33
|
+
expect(utils.__escape('foo bar')).to eq('foo%20bar')
|
34
34
|
expect(utils.__escape('foo/bar')).to eq('foo%2Fbar')
|
35
35
|
expect(utils.__escape('foo^bar')).to eq('foo%5Ebar')
|
36
36
|
end
|
@@ -38,18 +38,6 @@ describe Elasticsearch::API::Utils do
|
|
38
38
|
it 'does not encode asterisks' do
|
39
39
|
expect(utils.__escape('*')).to eq('*')
|
40
40
|
end
|
41
|
-
|
42
|
-
it 'users CGI.escape by default' do
|
43
|
-
expect(CGI).to receive(:escape).and_call_original
|
44
|
-
expect(utils.__escape('foo bar')).to eq('foo+bar')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'uses the escape_utils gem when available', unless: defined?(JRUBY_VERSION) do
|
48
|
-
require 'escape_utils'
|
49
|
-
expect(CGI).not_to receive(:escape)
|
50
|
-
expect(EscapeUtils).to receive(:escape_url).and_call_original
|
51
|
-
expect(utils.__escape('foo bar')).to eq('foo+bar')
|
52
|
-
end
|
53
41
|
end
|
54
42
|
|
55
43
|
describe '#__listify' do
|
@@ -77,7 +65,7 @@ describe Elasticsearch::API::Utils do
|
|
77
65
|
context 'when the escape option is set to false' do
|
78
66
|
|
79
67
|
it 'does not escape the characters' do
|
80
|
-
expect(utils.__listify(['foo', 'bar^bam'], :
|
68
|
+
expect(utils.__listify(['foo', 'bar^bam'], escape: false)).to eq('foo,bar^bam')
|
81
69
|
end
|
82
70
|
end
|
83
71
|
end
|
@@ -107,19 +95,19 @@ describe Elasticsearch::API::Utils do
|
|
107
95
|
|
108
96
|
let(:result) do
|
109
97
|
utils.__bulkify [
|
110
|
-
{ :
|
111
|
-
{ :
|
112
|
-
{ :
|
98
|
+
{ index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } },
|
99
|
+
{ update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } },
|
100
|
+
{ delete: { _index: 'myindexC', _id: '3' } }
|
113
101
|
]
|
114
102
|
end
|
115
103
|
|
116
104
|
let(:expected_string) do
|
117
105
|
<<-PAYLOAD.gsub(/^\s+/, '')
|
118
|
-
{"index":{"_index":"myindexA","
|
106
|
+
{"index":{"_index":"myindexA","_id":"1"}}
|
119
107
|
{"title":"Test"}
|
120
|
-
{"update":{"_index":"myindexB","
|
108
|
+
{"update":{"_index":"myindexB","_id":"2"}}
|
121
109
|
{"doc":{"title":"Update"}}
|
122
|
-
{"delete":{"_index":"myindexC","
|
110
|
+
{"delete":{"_index":"myindexC","_id":"3"}}
|
123
111
|
PAYLOAD
|
124
112
|
end
|
125
113
|
|
@@ -379,7 +367,7 @@ describe Elasticsearch::API::Utils do
|
|
379
367
|
end
|
380
368
|
|
381
369
|
let(:unsupported_params) do
|
382
|
-
[ { :
|
370
|
+
[ { foo: { explanation: 'NOT_SUPPORTED'} }, :moo ]
|
383
371
|
end
|
384
372
|
|
385
373
|
|
@@ -17,10 +17,13 @@
|
|
17
17
|
|
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
|
+
require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/wipe_cluster"
|
20
21
|
include Elasticsearch::RestAPIYAMLTests
|
21
22
|
|
22
23
|
TRANSPORT_OPTIONS = {}
|
23
24
|
PROJECT_PATH = File.join(File.dirname(__FILE__), '..')
|
25
|
+
STACK_VERSION = ENV['STACK_VERSION']
|
26
|
+
require 'elasticsearch/xpack'
|
24
27
|
|
25
28
|
if (hosts = ELASTICSEARCH_URL)
|
26
29
|
split_hosts = hosts.split(',').map do |host|
|
@@ -33,21 +36,69 @@ else
|
|
33
36
|
TEST_HOST, TEST_PORT = 'localhost', '9200'
|
34
37
|
end
|
35
38
|
|
39
|
+
test_suite = ENV['TEST_SUITE'] || 'free'
|
40
|
+
password = ENV['ELASTIC_PASSWORD'] || 'changeme'
|
41
|
+
user = ENV['ELASTIC_USER'] || 'elastic'
|
42
|
+
|
36
43
|
if defined?(TEST_HOST) && defined?(TEST_PORT)
|
37
|
-
URL = "http://#{TEST_HOST}:#{TEST_PORT}"
|
44
|
+
URL = "http://#{TEST_HOST}:#{TEST_PORT}".freeze
|
45
|
+
|
46
|
+
if STACK_VERSION.match?(/^8\./)
|
47
|
+
if ENV['TEST_SUITE'] == 'platinum'
|
48
|
+
raw_certificate = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.crt'))
|
49
|
+
certificate = OpenSSL::X509::Certificate.new(raw_certificate)
|
50
|
+
raw_key = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.key'))
|
51
|
+
key = OpenSSL::PKey::RSA.new(raw_key)
|
52
|
+
ca_file = File.expand_path(File.join(PROJECT_PATH, '/.ci/certs/ca.crt'))
|
53
|
+
host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
|
54
|
+
transport_options = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } }
|
55
|
+
else
|
56
|
+
host = "http://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
|
57
|
+
transport_options = {}
|
58
|
+
end
|
38
59
|
|
39
|
-
|
60
|
+
ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options)
|
40
61
|
|
41
|
-
|
42
|
-
|
62
|
+
DEFAULT_CLIENT = if ENV['QUIET'] == 'true'
|
63
|
+
Elasticsearch::Client.new(host: host, transport_options: transport_options)
|
64
|
+
else
|
65
|
+
Elasticsearch::Client.new(
|
66
|
+
host: host,
|
67
|
+
tracer: Logger.new($stdout),
|
68
|
+
transport_options: transport_options
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
if ENV['QUIET'] == 'true'
|
73
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(
|
74
|
+
host: URL,
|
75
|
+
transport_options: TRANSPORT_OPTIONS,
|
76
|
+
user: user,
|
77
|
+
password: password
|
78
|
+
)
|
79
|
+
else
|
80
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(
|
81
|
+
host: URL,
|
82
|
+
transport_options: TRANSPORT_OPTIONS,
|
83
|
+
user: user,
|
84
|
+
password: password,
|
85
|
+
tracer: Logger.new($stdout)
|
86
|
+
)
|
87
|
+
end
|
43
88
|
else
|
44
|
-
|
45
|
-
|
46
|
-
|
89
|
+
ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
|
90
|
+
|
91
|
+
if ENV['QUIET'] == 'true'
|
92
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
|
93
|
+
else
|
94
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
|
95
|
+
transport_options: TRANSPORT_OPTIONS,
|
96
|
+
tracer: Logger.new($stdout))
|
97
|
+
end
|
47
98
|
end
|
48
99
|
end
|
49
100
|
|
50
|
-
YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec
|
101
|
+
YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/#{STACK_VERSION.match?(/^8\./) ? 'compatTest' : 'test'}/free"
|
51
102
|
|
52
103
|
SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
|
53
104
|
test_target = ENV['SINGLE_TEST']
|
data/spec/spec_helper.rb
CHANGED
@@ -25,6 +25,10 @@ else
|
|
25
25
|
require 'pry-byebug'
|
26
26
|
end
|
27
27
|
require 'ansi'
|
28
|
+
require 'yaml'
|
29
|
+
require 'active_support/isolated_execution_state' unless RUBY_VERSION < '2.7.0'
|
30
|
+
require 'jbuilder'
|
31
|
+
require 'jsonify'
|
28
32
|
require 'elasticsearch'
|
29
33
|
require 'elasticsearch-api'
|
30
34
|
require 'elasticsearch-transport'
|
@@ -67,7 +71,7 @@ end
|
|
67
71
|
RSpec.configure do |config|
|
68
72
|
config.include(HelperModule)
|
69
73
|
config.formatter = 'documentation'
|
70
|
-
config.
|
74
|
+
config.color_mode = :on
|
71
75
|
config.add_formatter('RspecJunitFormatter', 'tmp/elasticsearch-api-junit.xml')
|
72
76
|
end
|
73
77
|
|
data/utils/thor/.rubocop.yml
CHANGED
@@ -148,6 +148,7 @@ module Elasticsearch
|
|
148
148
|
|
149
149
|
def __http_method
|
150
150
|
return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
|
151
|
+
return post_and_get if @endpoint_name == 'count'
|
151
152
|
|
152
153
|
default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first
|
153
154
|
if @spec['body'] && default_method == 'GET'
|
@@ -155,19 +156,23 @@ module Elasticsearch
|
|
155
156
|
if @spec['body']['required']
|
156
157
|
'Elasticsearch::API::HTTP_POST'
|
157
158
|
else
|
158
|
-
|
159
|
-
if arguments[:body]
|
160
|
-
Elasticsearch::API::HTTP_POST
|
161
|
-
else
|
162
|
-
Elasticsearch::API::HTTP_GET
|
163
|
-
end
|
164
|
-
SRC
|
159
|
+
post_and_get
|
165
160
|
end
|
166
161
|
else
|
167
162
|
"Elasticsearch::API::HTTP_#{default_method}"
|
168
163
|
end
|
169
164
|
end
|
170
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
|
+
|
171
176
|
def __http_path
|
172
177
|
return "\"#{__parse_path(@paths.first)}\"" if @paths.size == 1
|
173
178
|
return termvectors_path if @method_name == 'termvectors'
|
@@ -194,9 +199,9 @@ module Elasticsearch
|
|
194
199
|
|
195
200
|
def __parse_path(path)
|
196
201
|
path.gsub(/^\//, '')
|
197
|
-
|
198
|
-
|
199
|
-
|
202
|
+
.gsub(/\/$/, '')
|
203
|
+
.gsub('{', "\#{#{__utils}.__listify(_")
|
204
|
+
.gsub('}', ')}')
|
200
205
|
end
|
201
206
|
|
202
207
|
def __path_variables
|
@@ -226,6 +231,7 @@ module Elasticsearch
|
|
226
231
|
|
227
232
|
def docs_helper(name, info)
|
228
233
|
info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings'
|
234
|
+
info['type'] = 'Integer' if info['type'] == 'int' # Rename 'int' to 'Integer'
|
229
235
|
tipo = info['type'] ? info['type'].capitalize : 'String'
|
230
236
|
description = info['description'] ? info['description'].strip : '[TODO]'
|
231
237
|
options = info['options'] ? "(options: #{info['options'].join(', ').strip})" : nil
|
@@ -290,7 +296,7 @@ module Elasticsearch
|
|
290
296
|
end
|
291
297
|
|
292
298
|
def __utils
|
293
|
-
|
299
|
+
@current_api == :xpack ? 'Elasticsearch::API::Utils' : 'Utils'
|
294
300
|
end
|
295
301
|
|
296
302
|
def run_rubocop(api)
|
@@ -27,6 +27,7 @@ module Elasticsearch
|
|
27
27
|
exists
|
28
28
|
indices.exists
|
29
29
|
indices.exists_alias
|
30
|
+
indices.exists_index_template
|
30
31
|
indices.exists_template
|
31
32
|
indices.exists_type
|
32
33
|
].freeze
|
@@ -37,8 +38,9 @@ module Elasticsearch
|
|
37
38
|
delete
|
38
39
|
get
|
39
40
|
indices.flush_synced
|
40
|
-
indices.delete_template
|
41
41
|
indices.delete
|
42
|
+
indices.delete_index_template
|
43
|
+
indices.delete_template
|
42
44
|
security.get_role
|
43
45
|
security.get_user
|
44
46
|
snapshot.status
|
@@ -34,7 +34,7 @@ when 'mtermvectors'
|
|
34
34
|
<%- end -%>
|
35
35
|
<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%>
|
36
36
|
<%= self.send("#{@method_name}_body_helper".to_s) %>
|
37
|
-
headers
|
37
|
+
headers = <%= __utils %>.ndjson_headers(headers)
|
38
38
|
<%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, headers).body
|
39
39
|
<%- elsif @method_name == 'ping' -%>
|
40
40
|
<%= ping_perform_request %>
|