elasticsearch-api 7.13.3 → 7.17.11
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/Gemfile +5 -5
- data/README.md +18 -39
- data/Rakefile +2 -16
- data/elasticsearch-api.gemspec +14 -8
- 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 +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 -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 +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/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 +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 +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 +2 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +6 -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 +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 +3 -3
- data/lib/elasticsearch/api/actions/msearch_template.rb +3 -3
- 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/{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 +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 +8 -8
- 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 +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 +17 -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 -7
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +1 -1
- data/lib/elasticsearch/api/{actions/remote/info.rb → namespace/security.rb} +12 -13
- 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/indices/clear_cache_spec.rb +16 -3
- 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/{remote/info_spec.rb → nodes/get_repositories_metering_info_spec.rb} +17 -8
- data/spec/elasticsearch/api/actions/open_point_in_time_spec.rb +2 -12
- data/spec/elasticsearch/api/actions/search_mvt_spec.rb +52 -0
- data/spec/elasticsearch/api/actions/snapshot/{get_features_spec.rb → repository_analize_spec.rb} +15 -5
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +18 -6
- data/spec/elasticsearch/api/utils_spec.rb +9 -21
- data/spec/rest_yaml_tests_helper.rb +64 -10
- data/spec/spec_helper.rb +13 -2
- data/utils/README.md +6 -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/generator/files_helper.rb +1 -1
- 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 +38 -41
- 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/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +0 -76
@@ -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
|
data/spec/elasticsearch/api/actions/snapshot/{get_features_spec.rb → repository_analize_spec.rb}
RENAMED
@@ -17,22 +17,32 @@
|
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
describe 'client.snapshot#
|
20
|
+
describe 'client.snapshot#repository_analyze' do
|
21
21
|
let(:expected_args) do
|
22
22
|
[
|
23
|
-
'
|
24
|
-
|
23
|
+
'POST',
|
24
|
+
url,
|
25
25
|
{},
|
26
26
|
nil,
|
27
27
|
{}
|
28
28
|
]
|
29
29
|
end
|
30
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
|
+
|
31
39
|
let(:client) do
|
32
40
|
Class.new { include Elasticsearch::API }.new
|
33
41
|
end
|
34
42
|
|
35
|
-
it '
|
36
|
-
expect
|
43
|
+
it 'requires the :repository argument' do
|
44
|
+
expect {
|
45
|
+
client.snapshot.repository_analyze
|
46
|
+
}.to raise_exception(ArgumentError)
|
37
47
|
end
|
38
48
|
end
|
@@ -1,7 +1,20 @@
|
|
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
|
|
@@ -9,7 +22,7 @@ describe 'Rest API YAML tests' do
|
|
9
22
|
if REST_API_YAML_FILES.empty?
|
10
23
|
logger = Logger.new($stdout)
|
11
24
|
logger.error 'No test files found!'
|
12
|
-
logger.info 'Use rake rake
|
25
|
+
logger.info 'Use rake rake elasticsearch:download_artifacts in the root directory of the project to download the test artifacts.'
|
13
26
|
exit 1
|
14
27
|
end
|
15
28
|
|
@@ -37,13 +50,12 @@ describe 'Rest API YAML tests' do
|
|
37
50
|
|
38
51
|
# Runs once before each test in a test file
|
39
52
|
before(:all) do
|
40
|
-
Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
|
41
53
|
test_file.setup
|
42
54
|
end
|
43
55
|
|
44
56
|
after(:all) do
|
45
57
|
test_file.teardown
|
46
|
-
Elasticsearch::RestAPIYAMLTests::
|
58
|
+
Elasticsearch::RestAPIYAMLTests::WipeCluster.run(ADMIN_CLIENT)
|
47
59
|
end
|
48
60
|
|
49
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,17 @@
|
|
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'
|
27
|
+
|
28
|
+
def testing_compatibility?
|
29
|
+
[1, true, 'true'].include?(ENV['ELASTIC_CLIENT_APIVERSIONING'])
|
30
|
+
end
|
24
31
|
|
25
32
|
if (hosts = ELASTICSEARCH_URL)
|
26
33
|
split_hosts = hosts.split(',').map do |host|
|
@@ -33,21 +40,69 @@ else
|
|
33
40
|
TEST_HOST, TEST_PORT = 'localhost', '9200'
|
34
41
|
end
|
35
42
|
|
43
|
+
test_suite = ENV['TEST_SUITE'] || 'free'
|
44
|
+
password = ENV['ELASTIC_PASSWORD'] || 'changeme'
|
45
|
+
user = ENV['ELASTIC_USER'] || 'elastic'
|
46
|
+
|
36
47
|
if defined?(TEST_HOST) && defined?(TEST_PORT)
|
37
|
-
URL = "http://#{TEST_HOST}:#{TEST_PORT}"
|
48
|
+
URL = "http://#{TEST_HOST}:#{TEST_PORT}".freeze
|
49
|
+
|
50
|
+
if STACK_VERSION.match?(/^8\./)
|
51
|
+
if ENV['TEST_SUITE'] == 'platinum'
|
52
|
+
raw_certificate = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.crt'))
|
53
|
+
certificate = OpenSSL::X509::Certificate.new(raw_certificate)
|
54
|
+
raw_key = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.key'))
|
55
|
+
key = OpenSSL::PKey::RSA.new(raw_key)
|
56
|
+
ca_file = File.expand_path(File.join(PROJECT_PATH, '/.ci/certs/ca.crt'))
|
57
|
+
host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
|
58
|
+
transport_options = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } }
|
59
|
+
else
|
60
|
+
host = "http://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
|
61
|
+
transport_options = {}
|
62
|
+
end
|
38
63
|
|
39
|
-
|
64
|
+
ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options)
|
40
65
|
|
41
|
-
|
42
|
-
|
66
|
+
DEFAULT_CLIENT = if ENV['QUIET'] == 'true'
|
67
|
+
Elasticsearch::Client.new(host: host, transport_options: transport_options)
|
68
|
+
else
|
69
|
+
Elasticsearch::Client.new(
|
70
|
+
host: host,
|
71
|
+
tracer: Logger.new($stdout),
|
72
|
+
transport_options: transport_options
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
if ENV['QUIET'] == 'true'
|
77
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(
|
78
|
+
host: URL,
|
79
|
+
transport_options: TRANSPORT_OPTIONS,
|
80
|
+
user: user,
|
81
|
+
password: password
|
82
|
+
)
|
83
|
+
else
|
84
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(
|
85
|
+
host: URL,
|
86
|
+
transport_options: TRANSPORT_OPTIONS,
|
87
|
+
user: user,
|
88
|
+
password: password,
|
89
|
+
tracer: Logger.new($stdout)
|
90
|
+
)
|
91
|
+
end
|
43
92
|
else
|
44
|
-
|
45
|
-
|
46
|
-
|
93
|
+
ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
|
94
|
+
|
95
|
+
if ENV['QUIET'] == 'true'
|
96
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
|
97
|
+
else
|
98
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
|
99
|
+
transport_options: TRANSPORT_OPTIONS,
|
100
|
+
tracer: Logger.new($stdout))
|
101
|
+
end
|
47
102
|
end
|
48
103
|
end
|
49
104
|
|
50
|
-
YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec
|
105
|
+
YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../tmp/rest-api-spec/#{STACK_VERSION.match?(/^8\./) ? 'compatTest' : 'test'}/free"
|
51
106
|
|
52
107
|
SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
|
53
108
|
test_target = ENV['SINGLE_TEST']
|
@@ -61,9 +116,8 @@ SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
|
|
61
116
|
end
|
62
117
|
end
|
63
118
|
|
64
|
-
|
65
119
|
# Skipped tests
|
66
|
-
file = File.expand_path(__dir__
|
120
|
+
file = File.expand_path("#{__dir__}/skipped_tests.yml")
|
67
121
|
skipped_tests = YAML.load_file(file)
|
68
122
|
|
69
123
|
# The directory of rest api YAML files.
|
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'
|
@@ -21,6 +25,10 @@ else
|
|
21
25
|
require 'pry-byebug'
|
22
26
|
end
|
23
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'
|
24
32
|
require 'elasticsearch'
|
25
33
|
require 'elasticsearch-api'
|
26
34
|
require 'elasticsearch-transport'
|
@@ -42,7 +50,6 @@ DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
|
|
42
50
|
|
43
51
|
module HelperModule
|
44
52
|
def self.included(context)
|
45
|
-
|
46
53
|
context.let(:client_double) do
|
47
54
|
Class.new { include Elasticsearch::API }.new.tap do |client|
|
48
55
|
expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double)
|
@@ -64,8 +71,12 @@ end
|
|
64
71
|
RSpec.configure do |config|
|
65
72
|
config.include(HelperModule)
|
66
73
|
config.formatter = 'documentation'
|
67
|
-
config.color = true
|
68
74
|
config.add_formatter('RspecJunitFormatter', 'tmp/elasticsearch-api-junit.xml')
|
75
|
+
config.add_formatter(
|
76
|
+
'RSpec::Core::Formatters::HtmlFormatter',
|
77
|
+
"tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}-#{ENV['STACK_VERSION']}.html"
|
78
|
+
)
|
79
|
+
config.color_mode = :on
|
69
80
|
end
|
70
81
|
|
71
82
|
class NotFound < StandardError; end
|
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
@@ -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
|
@@ -22,7 +22,7 @@ module Elasticsearch
|
|
22
22
|
module API
|
23
23
|
module FilesHelper
|
24
24
|
PROJECT_PATH = File.join(File.dirname(__FILE__), '..')
|
25
|
-
SRC_PATH = File.join(PROJECT_PATH, '..', '..', '..', 'tmp/
|
25
|
+
SRC_PATH = File.join(PROJECT_PATH, '..', '..', '..', 'tmp/rest-api-spec/api/')
|
26
26
|
OSS_OUTPUT_DIR = '../../elasticsearch-api/lib/elasticsearch/api/actions'.freeze
|
27
27
|
XPACK_OUTPUT_DIR = '../../elasticsearch-xpack/lib/elasticsearch/xpack/api/actions'.freeze
|
28
28
|
|
@@ -1,3 +1,22 @@
|
|
1
|
+
<%#
|
2
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
3
|
+
# license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright
|
5
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
6
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
7
|
+
# not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
%>
|
19
|
+
|
1
20
|
<%- if @spec['documentation']['description'] -%>
|
2
21
|
<%= ' '*(@namespace_depth+3) %># <%= @spec['documentation']['description'].gsub("\n", "\n#{' '*(@namespace_depth+3)}# ") -%>
|
3
22
|
<%- else %>
|
@@ -1,3 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
3
|
+
# license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright
|
5
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
6
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
7
|
+
# not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
%>
|
1
19
|
<%- if @endpoint_name == 'indices.stats' %>
|
2
20
|
method = HTTP_GET
|
3
21
|
parts = Utils.__extract_parts arguments, ParamsRegistry.get(:stats_parts)
|
@@ -1,3 +1,22 @@
|
|
1
|
+
<%#
|
2
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
3
|
+
# license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright
|
5
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
6
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
7
|
+
# not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
%>
|
19
|
+
|
1
20
|
<%- unless @params.empty? -%>
|
2
21
|
<%= ' '*(@namespace_depth+3) %># Register this action with its valid params when the module is loaded.
|
3
22
|
<%= ' '*(@namespace_depth+3) %>#
|
@@ -1,3 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
3
|
+
# license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright
|
5
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
6
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
7
|
+
# not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
%>
|
1
19
|
<%-
|
2
20
|
case @endpoint_name
|
3
21
|
when 'mtermvectors'
|
@@ -16,7 +34,7 @@ when 'mtermvectors'
|
|
16
34
|
<%- end -%>
|
17
35
|
<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%>
|
18
36
|
<%= self.send("#{@method_name}_body_helper".to_s) %>
|
19
|
-
headers
|
37
|
+
headers = <%= __utils %>.ndjson_headers(headers)
|
20
38
|
<%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, headers).body
|
21
39
|
<%- elsif @method_name == 'ping' -%>
|
22
40
|
<%= ping_perform_request %>
|
@@ -1,6 +1,19 @@
|
|
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
|
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.
|
4
17
|
|
5
18
|
require 'test_helper'
|
6
19
|
|
@@ -15,10 +15,6 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
19
|
-
|
20
|
-
require 'rubygems' if RUBY_1_8
|
21
|
-
|
22
18
|
require 'simplecov' and SimpleCov.start { add_filter "/test|test_/" } if ENV["COVERAGE"]
|
23
19
|
|
24
20
|
require 'test/unit'
|