elasticsearch-api 7.8.1 → 7.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -2
  3. data/lib/elasticsearch/api.rb +2 -1
  4. data/lib/elasticsearch/api/actions/bulk.rb +10 -9
  5. data/lib/elasticsearch/api/actions/cat/aliases.rb +4 -5
  6. data/lib/elasticsearch/api/actions/cat/allocation.rb +4 -5
  7. data/lib/elasticsearch/api/actions/cat/count.rb +3 -3
  8. data/lib/elasticsearch/api/actions/cat/fielddata.rb +4 -6
  9. data/lib/elasticsearch/api/actions/cat/health.rb +3 -4
  10. data/lib/elasticsearch/api/actions/cat/help.rb +2 -2
  11. data/lib/elasticsearch/api/actions/cat/indices.rb +7 -11
  12. data/lib/elasticsearch/api/actions/cat/master.rb +2 -2
  13. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +2 -2
  14. data/lib/elasticsearch/api/actions/cat/nodes.rb +5 -7
  15. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +3 -4
  16. data/lib/elasticsearch/api/actions/cat/plugins.rb +2 -2
  17. data/lib/elasticsearch/api/actions/cat/recovery.rb +5 -8
  18. data/lib/elasticsearch/api/actions/cat/repositories.rb +2 -2
  19. data/lib/elasticsearch/api/actions/cat/segments.rb +4 -5
  20. data/lib/elasticsearch/api/actions/cat/shards.rb +5 -7
  21. data/lib/elasticsearch/api/actions/cat/snapshots.rb +4 -5
  22. data/lib/elasticsearch/api/actions/cat/tasks.rb +3 -4
  23. data/lib/elasticsearch/api/actions/cat/templates.rb +3 -3
  24. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +4 -5
  25. data/lib/elasticsearch/api/actions/clear_scroll.rb +4 -4
  26. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +9 -4
  27. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +2 -2
  28. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +2 -2
  29. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +2 -2
  30. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +3 -3
  31. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +2 -2
  32. data/lib/elasticsearch/api/actions/cluster/health.rb +7 -11
  33. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +2 -2
  34. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +2 -2
  35. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +2 -2
  36. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +2 -2
  37. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +2 -2
  38. data/lib/elasticsearch/api/actions/cluster/reroute.rb +3 -4
  39. data/lib/elasticsearch/api/actions/cluster/state.rb +5 -7
  40. data/lib/elasticsearch/api/actions/cluster/stats.rb +3 -3
  41. data/lib/elasticsearch/api/actions/count.rb +11 -18
  42. data/lib/elasticsearch/api/actions/create.rb +5 -7
  43. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +60 -0
  44. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +60 -0
  45. data/lib/elasticsearch/api/actions/{indices/get_data_streams.rb → dangling_indices/list_dangling_indices.rb} +6 -17
  46. data/lib/elasticsearch/api/actions/dangling_indices/params_registry.rb +60 -0
  47. data/lib/elasticsearch/api/actions/delete.rb +6 -8
  48. data/lib/elasticsearch/api/actions/delete_by_query.rb +8 -12
  49. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +3 -3
  50. data/lib/elasticsearch/api/actions/delete_script.rb +2 -2
  51. data/lib/elasticsearch/api/actions/exists.rb +5 -6
  52. data/lib/elasticsearch/api/actions/exists_source.rb +5 -6
  53. data/lib/elasticsearch/api/actions/explain.rb +14 -10
  54. data/lib/elasticsearch/api/actions/field_caps.rb +15 -10
  55. data/lib/elasticsearch/api/actions/get.rb +5 -6
  56. data/lib/elasticsearch/api/actions/get_script.rb +2 -2
  57. data/lib/elasticsearch/api/actions/get_script_context.rb +2 -2
  58. data/lib/elasticsearch/api/actions/get_script_languages.rb +2 -2
  59. data/lib/elasticsearch/api/actions/get_source.rb +5 -6
  60. data/lib/elasticsearch/api/actions/index.rb +10 -11
  61. data/lib/elasticsearch/api/actions/indices/add_block.rb +68 -0
  62. data/lib/elasticsearch/api/actions/indices/analyze.rb +12 -8
  63. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +4 -6
  64. data/lib/elasticsearch/api/actions/indices/clone.rb +2 -2
  65. data/lib/elasticsearch/api/actions/indices/close.rb +3 -4
  66. data/lib/elasticsearch/api/actions/indices/create.rb +2 -2
  67. data/lib/elasticsearch/api/actions/indices/delete.rb +3 -4
  68. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +3 -3
  69. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +2 -2
  70. data/lib/elasticsearch/api/actions/indices/delete_template.rb +2 -2
  71. data/lib/elasticsearch/api/actions/indices/exists.rb +3 -4
  72. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +4 -5
  73. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +2 -2
  74. data/lib/elasticsearch/api/actions/indices/exists_template.rb +2 -2
  75. data/lib/elasticsearch/api/actions/indices/exists_type.rb +3 -4
  76. data/lib/elasticsearch/api/actions/indices/flush.rb +4 -5
  77. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +9 -5
  78. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +4 -5
  79. data/lib/elasticsearch/api/actions/indices/get.rb +3 -4
  80. data/lib/elasticsearch/api/actions/indices/get_alias.rb +4 -5
  81. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +5 -6
  82. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +3 -3
  83. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +6 -7
  84. data/lib/elasticsearch/api/actions/indices/get_settings.rb +4 -5
  85. data/lib/elasticsearch/api/actions/indices/get_template.rb +3 -3
  86. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +4 -5
  87. data/lib/elasticsearch/api/actions/indices/open.rb +3 -4
  88. data/lib/elasticsearch/api/actions/indices/put_alias.rb +3 -3
  89. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +2 -2
  90. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +8 -7
  91. data/lib/elasticsearch/api/actions/indices/put_settings.rb +4 -5
  92. data/lib/elasticsearch/api/actions/indices/put_template.rb +2 -2
  93. data/lib/elasticsearch/api/actions/indices/recovery.rb +3 -3
  94. data/lib/elasticsearch/api/actions/indices/refresh.rb +4 -5
  95. data/lib/elasticsearch/api/actions/indices/{delete_data_stream.rb → resolve_index.rb} +16 -8
  96. data/lib/elasticsearch/api/actions/indices/rollover.rb +3 -3
  97. data/lib/elasticsearch/api/actions/indices/segments.rb +4 -5
  98. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +5 -7
  99. data/lib/elasticsearch/api/actions/indices/shrink.rb +2 -2
  100. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +2 -2
  101. data/lib/elasticsearch/api/actions/indices/{create_data_stream.rb → simulate_template.rb} +25 -12
  102. data/lib/elasticsearch/api/actions/indices/split.rb +2 -2
  103. data/lib/elasticsearch/api/actions/indices/stats.rb +5 -8
  104. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +2 -2
  105. data/lib/elasticsearch/api/actions/indices/upgrade.rb +4 -5
  106. data/lib/elasticsearch/api/actions/indices/validate_query.rb +17 -14
  107. data/lib/elasticsearch/api/actions/info.rb +2 -2
  108. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +2 -2
  109. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +3 -3
  110. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +2 -2
  111. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +2 -2
  112. data/lib/elasticsearch/api/actions/ingest/simulate.rb +4 -4
  113. data/lib/elasticsearch/api/actions/mget.rb +5 -5
  114. data/lib/elasticsearch/api/actions/msearch.rb +8 -11
  115. data/lib/elasticsearch/api/actions/msearch_template.rb +6 -7
  116. data/lib/elasticsearch/api/actions/mtermvectors.rb +16 -12
  117. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +4 -5
  118. data/lib/elasticsearch/api/actions/nodes/info.rb +4 -5
  119. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +3 -3
  120. data/lib/elasticsearch/api/actions/nodes/stats.rb +6 -9
  121. data/lib/elasticsearch/api/actions/nodes/usage.rb +4 -5
  122. data/lib/elasticsearch/api/actions/ping.rb +2 -2
  123. data/lib/elasticsearch/api/actions/put_script.rb +3 -4
  124. data/lib/elasticsearch/api/actions/rank_eval.rb +6 -8
  125. data/lib/elasticsearch/api/actions/reindex.rb +2 -2
  126. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +3 -3
  127. data/lib/elasticsearch/api/actions/render_search_template.rb +12 -7
  128. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +9 -4
  129. data/lib/elasticsearch/api/actions/scroll.rb +13 -9
  130. data/lib/elasticsearch/api/actions/search.rb +18 -17
  131. data/lib/elasticsearch/api/actions/search_shards.rb +4 -5
  132. data/lib/elasticsearch/api/actions/search_template.rb +6 -8
  133. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +2 -2
  134. data/lib/elasticsearch/api/actions/snapshot/clone.rb +66 -0
  135. data/lib/elasticsearch/api/actions/snapshot/create.rb +2 -2
  136. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +2 -2
  137. data/lib/elasticsearch/api/actions/snapshot/delete.rb +2 -2
  138. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +2 -2
  139. data/lib/elasticsearch/api/actions/snapshot/get.rb +2 -2
  140. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +3 -3
  141. data/lib/elasticsearch/api/actions/snapshot/restore.rb +2 -2
  142. data/lib/elasticsearch/api/actions/snapshot/status.rb +3 -3
  143. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +2 -2
  144. data/lib/elasticsearch/api/actions/tasks/cancel.rb +7 -3
  145. data/lib/elasticsearch/api/actions/tasks/get.rb +6 -2
  146. data/lib/elasticsearch/api/actions/tasks/list.rb +7 -4
  147. data/lib/elasticsearch/api/actions/termvectors.rb +10 -7
  148. data/lib/elasticsearch/api/actions/update.rb +8 -7
  149. data/lib/elasticsearch/api/actions/update_by_query.rb +8 -12
  150. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +3 -3
  151. data/lib/elasticsearch/api/namespace/cat.rb +0 -1
  152. data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
  153. data/lib/elasticsearch/api/version.rb +1 -1
  154. data/spec/elasticsearch/api/actions/count_spec.rb +2 -2
  155. data/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +48 -0
  156. data/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +48 -0
  157. data/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +36 -0
  158. data/spec/elasticsearch/api/actions/explain_document_spec.rb +8 -9
  159. data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
  160. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +7 -8
  161. data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +7 -13
  162. data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +6 -7
  163. data/spec/elasticsearch/api/actions/json_builders_spec.rb +10 -13
  164. data/spec/elasticsearch/api/actions/mget_spec.rb +5 -6
  165. data/spec/elasticsearch/api/actions/msearch_spec.rb +21 -39
  166. data/spec/elasticsearch/api/actions/msearch_template_spec.rb +5 -6
  167. data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +7 -7
  168. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +2 -2
  169. data/spec/elasticsearch/api/actions/scroll_spec.rb +1 -1
  170. data/spec/elasticsearch/api/actions/search_spec.rb +7 -7
  171. data/spec/elasticsearch/api/actions/search_template_spec.rb +5 -6
  172. data/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +67 -0
  173. data/spec/elasticsearch/api/actions/termvectors_spec.rb +5 -7
  174. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +11 -7
  175. data/utils/thor/.rubocop.yml +2 -0
  176. data/utils/thor/generate_source.rb +28 -19
  177. data/utils/thor/generator/endpoint_specifics.rb +10 -3
  178. data/utils/thor/templates/_documentation_top.erb +12 -2
  179. metadata +23 -12
  180. data/spec/README.md +0 -61
  181. data/test/integration/yaml_test_runner.rb +0 -592
  182. data/test/test_helper.rb +0 -118
@@ -18,14 +18,13 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#msearch_template' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- url,
26
- params,
27
- body,
28
- headers
23
+ 'POST',
24
+ url,
25
+ params,
26
+ body,
27
+ headers
29
28
  ]
30
29
  end
31
30
 
@@ -18,16 +18,16 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#mtermvectors' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- 'my-index/my-type/_mtermvectors',
26
- {},
27
- body,
28
- {}
23
+ method,
24
+ 'my-index/my-type/_mtermvectors',
25
+ {},
26
+ body,
27
+ {}
29
28
  ]
30
29
  end
30
+ let(:method) { 'POST' }
31
31
 
32
32
  let(:body) do
33
33
  { ids: [1, 2, 3] }
@@ -38,7 +38,7 @@ describe 'client#mtermvectors' do
38
38
  end
39
39
 
40
40
  context 'when a list of ids is passed instead of a body' do
41
-
41
+ let(:method) { 'GET' }
42
42
  it 'performs the request' do
43
43
  expect(client_double.mtermvectors(index: 'my-index', type: 'my-type', ids: [1, 2, 3])).to eq({})
44
44
  end
@@ -21,7 +21,7 @@ describe 'client#render_search_template' do
21
21
  context 'when no id is specified' do
22
22
  let(:expected_args) do
23
23
  [
24
- 'GET',
24
+ 'POST',
25
25
  '_render/template',
26
26
  {},
27
27
  { foo: 'bar' },
@@ -37,7 +37,7 @@ describe 'client#render_search_template' do
37
37
  context 'when id is specified' do
38
38
  let(:expected_args) do
39
39
  [
40
- 'GET',
40
+ 'POST',
41
41
  '_render/template/foo',
42
42
  {},
43
43
  { foo: 'bar' },
@@ -37,7 +37,7 @@ describe 'client#scroll' do
37
37
  context 'with scroll_id in the body' do
38
38
  let(:expected_args) do
39
39
  [
40
- 'GET',
40
+ 'POST',
41
41
  '_search/scroll',
42
42
  {},
43
43
  { scroll_id: 'cXVlcn...' },
@@ -18,16 +18,16 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#search' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- url,
26
- params,
27
- body,
28
- {}
23
+ method,
24
+ url,
25
+ params,
26
+ body,
27
+ {}
29
28
  ]
30
29
  end
30
+ let(:method) { 'GET' }
31
31
 
32
32
  let(:body) do
33
33
  nil
@@ -46,10 +46,10 @@ describe 'client#search' do
46
46
  end
47
47
 
48
48
  context 'when a request definition is specified' do
49
-
50
49
  let(:body) do
51
50
  { query: { match: {} } }
52
51
  end
52
+ let(:method) { 'POST' }
53
53
 
54
54
  let(:url) do
55
55
  '_search'
@@ -18,14 +18,13 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#search_template' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- 'foo/_search/template',
26
- { },
27
- { foo: 'bar' },
28
- {}
23
+ 'POST',
24
+ 'foo/_search/template',
25
+ { },
26
+ { foo: 'bar' },
27
+ {}
29
28
  ]
30
29
  end
31
30
 
@@ -0,0 +1,67 @@
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#clone' do
21
+ let(:expected_args) do
22
+ [
23
+ 'PUT',
24
+ '_snapshot/foo/bar/_clone/snapshot',
25
+ {},
26
+ {},
27
+ {}
28
+ ]
29
+ end
30
+
31
+ let(:client) do
32
+ Class.new { include Elasticsearch::API }.new
33
+ end
34
+
35
+ it 'requires the :body argument' do
36
+ expect {
37
+ client.snapshot.clone(snapshot: 'bar')
38
+ }.to raise_exception(ArgumentError)
39
+ end
40
+
41
+ it 'requires the :repository argument' do
42
+ expect {
43
+ client.snapshot.clone(snapshot: 'foo', body: {})
44
+ }.to raise_exception(ArgumentError)
45
+ end
46
+
47
+ it 'requires the :snapshot argument' do
48
+ expect {
49
+ client.snapshot.clone(repository: 'foo', body: {})
50
+ }.to raise_exception(ArgumentError)
51
+ end
52
+
53
+ it 'requires the :target_snapshot argument' do
54
+ expect {
55
+ client.snapshot.clone(repository: 'foo', body: {}, snapshot: 'bar')
56
+ }.to raise_exception(ArgumentError)
57
+ end
58
+
59
+ it 'performs the request' do
60
+ expect(client_double.snapshot.clone(
61
+ repository: 'foo',
62
+ snapshot: 'bar',
63
+ body: {},
64
+ target_snapshot: 'snapshot'
65
+ )).to eq({})
66
+ end
67
+ end
@@ -18,14 +18,13 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#termvectors' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- url,
26
- params,
27
- body,
28
- {}
23
+ 'POST',
24
+ url,
25
+ params,
26
+ body,
27
+ {}
29
28
  ]
30
29
  end
31
30
 
@@ -56,7 +55,6 @@ describe 'client#termvectors' do
56
55
  end
57
56
 
58
57
  context 'when the older api name \'termvector\' is used' do
59
-
60
58
  let(:url) do
61
59
  'foo/bar/123/_termvector'
62
60
  end
@@ -8,11 +8,16 @@ require 'rest_yaml_tests_helper'
8
8
  describe 'Rest API YAML tests' do
9
9
  # Traverse YAML files and create TestFile object:
10
10
  REST_API_YAML_FILES.each do |file|
11
- test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, REST_API_YAML_SKIP_FEATURES)
11
+ begin
12
+ test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, ADMIN_CLIENT, REST_API_YAML_SKIP_FEATURES)
13
+ rescue SkipTestsException => _e
14
+ # If the test file has a `skip` at the top level that applies to this
15
+ # version of Elasticsearch, continue with the next text.
16
+ next
17
+ end
12
18
 
13
19
  context "#{file.gsub("#{YAML_FILES_DIRECTORY}/", '')}" do
14
20
  test_file.tests.each do |test|
15
-
16
21
  context "#{test.description}" do
17
22
  if test.skip_test?(ADMIN_CLIENT)
18
23
  skip 'Test contains feature(s) not yet supported or version is not satisfied'
@@ -23,13 +28,13 @@ describe 'Rest API YAML tests' do
23
28
 
24
29
  # Runs once before each test in a test file
25
30
  before(:all) do
26
- Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
27
- test_file.setup(ADMIN_CLIENT)
31
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
32
+ test_file.setup
28
33
  end
29
34
 
30
35
  after(:all) do
31
- test_file.teardown(ADMIN_CLIENT)
32
- Elasticsearch::RestAPIYAMLTests::TestFile.clear_data(ADMIN_CLIENT)
36
+ test_file.teardown
37
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
33
38
  end
34
39
 
35
40
  test.task_groups.each do |task_group|
@@ -52,7 +57,6 @@ describe 'Rest API YAML tests' do
52
57
  end
53
58
  end
54
59
  else
55
-
56
60
  # 'match' is in the task group definition
57
61
  if task_group.has_match_clauses?
58
62
  task_group.match_clauses.each do |match|
@@ -0,0 +1,2 @@
1
+ Layout/EndAlignment:
2
+ AutoCorrect: true
@@ -50,6 +50,7 @@ module Elasticsearch
50
50
  method_option :verbose, type: :boolean, default: false, desc: 'Output more information'
51
51
  method_option :tests, type: :boolean, default: false, desc: 'Generate test files'
52
52
  method_option :api, type: :array, default: %w[oss xpack], desc: 'APIs to generate (oss, x-pack)'
53
+
53
54
  def generate
54
55
  self.class.source_root File.expand_path(__dir__)
55
56
  @xpack = options[:api].include? 'xpack'
@@ -113,12 +114,13 @@ module Elasticsearch
113
114
  names = @endpoint_name.split('.')
114
115
  if @current_api == :xpack
115
116
  names = (names.first == 'xpack' ? names : ['xpack', names].flatten)
116
- # Return an array with 'ml' renamed to 'machine_learning' and 'ilm' to
117
- # 'index_lifecycle_management'
117
+ # Return an array to expand 'ccr', 'ilm', 'ml' and 'slm'
118
118
  names.map do |name|
119
119
  name
120
120
  .gsub(/^ml$/, 'machine_learning')
121
121
  .gsub(/^ilm$/, 'index_lifecycle_management')
122
+ .gsub(/^ccr/, 'cross_cluster_replication')
123
+ .gsub(/^slm/, 'snapshot_lifecycle_management')
122
124
  end
123
125
  else
124
126
  names
@@ -146,19 +148,24 @@ module Elasticsearch
146
148
  end
147
149
 
148
150
  def __http_method
149
- case @endpoint_name
150
- when 'index'
151
- '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST'
152
- when 'count'
153
- <<~SRC
154
- if arguments[:body]
155
- Elasticsearch::API::HTTP_POST
156
- else
157
- Elasticsearch::API::HTTP_GET
158
- end
159
- SRC
151
+ return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
152
+
153
+ default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first
154
+ if @spec['body'] && default_method == 'GET'
155
+ # When default method is GET and body is required, we should always use POST
156
+ if @spec['body']['required']
157
+ 'Elasticsearch::API::HTTP_POST'
158
+ else
159
+ <<~SRC
160
+ if arguments[:body]
161
+ Elasticsearch::API::HTTP_POST
162
+ else
163
+ Elasticsearch::API::HTTP_GET
164
+ end
165
+ SRC
166
+ end
160
167
  else
161
- "Elasticsearch::API::HTTP_#{@spec['url']['paths'].map { |a| a['methods'] }.flatten.first}"
168
+ "Elasticsearch::API::HTTP_#{default_method}"
162
169
  end
163
170
  end
164
171
 
@@ -222,10 +229,12 @@ module Elasticsearch
222
229
  info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings'
223
230
  tipo = info['type'] ? info['type'].capitalize : 'String'
224
231
  description = info['description'] ? info['description'].strip : '[TODO]'
225
- options = info['options'] ? "\n # (options: #{info['options'].join(', '.strip)})" : nil
226
- required = info['required'] ? ' (*Required*)' : ''
227
- deprecated = info['deprecated'] ? ' *Deprecated*' : ''
228
- "# @option arguments [#{tipo}] :#{name} #{description} #{required} #{deprecated} #{options}\n"
232
+ options = info['options'] ? "(options: #{info['options'].join(', ').strip})" : nil
233
+ required = info['required'] ? '(*Required*)' : ''
234
+ deprecated = info['deprecated'] ? '*Deprecated*' : ''
235
+ optionals = [required, deprecated, options].join(' ').strip
236
+
237
+ "# @option arguments [#{tipo}] :#{name} #{description} #{optionals}\n"
229
238
  end
230
239
 
231
240
  def stability_doc_helper(stability)
@@ -286,7 +295,7 @@ module Elasticsearch
286
295
  end
287
296
 
288
297
  def run_rubocop(api)
289
- system("rubocop --format autogenconf -x #{FilesHelper::output_dir(api)}")
298
+ system("rubocop -c ./thor/.rubocop.yml --format autogenconf -x #{FilesHelper::output_dir(api)}")
290
299
  end
291
300
  end
292
301
  end
@@ -78,7 +78,7 @@ module Elasticsearch
78
78
  def module_name_helper(name)
79
79
  return name.upcase if %w[sql ssl].include? name
80
80
 
81
- name.split("_").map(&:capitalize).join
81
+ name.split('_').map(&:capitalize).join
82
82
  end
83
83
 
84
84
  def termvectors_path
@@ -136,11 +136,11 @@ module Elasticsearch
136
136
  end.
137
137
  map { |item| Elasticsearch::API.serializer.dump(item) }
138
138
  payload << "" unless payload.empty?
139
- payload = payload.join("\n")
139
+ payload = payload.join("\\n")
140
140
  when body.is_a?(Array)
141
141
  payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
142
142
  payload << "" unless payload.empty?
143
- payload = payload.join("\n")
143
+ payload = payload.join("\\n")
144
144
  else
145
145
  payload = body
146
146
  end
@@ -169,6 +169,13 @@ module Elasticsearch
169
169
  end
170
170
  SRC
171
171
  end
172
+
173
+ def bulk_doc_helper(info)
174
+ <<~SRC
175
+ # @option arguments [String|Array] :body #{info}. Array of Strings, Header/Data pairs,
176
+ # or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation.
177
+ SRC
178
+ end
172
179
  end
173
180
  end
174
181
  end
@@ -12,10 +12,20 @@
12
12
  <%- end -%><%# Body -%>
13
13
  <%# URL parameters -%>
14
14
  <%- @params.each do |name, info| -%>
15
- <%= docs_helper(name, info) -%>
15
+ <%= docs_helper(name, info) unless (!@parts.empty? && @parts.keys.include?(name)) -%>
16
16
  <%- end -%>
17
17
  # @option arguments [Hash] :headers Custom HTTP headers
18
- <%= ' '*(@namespace_depth+3) + '# @option arguments [Hash] :body ' + (@spec['body']['description'] ? @spec['body']['description'].strip : 'TODO: Description') + (@spec['body']['required'] ? ' (*Required*)' : '') + "\n" if @spec['body'] -%>
18
+ <%- if @spec['body'] -%>
19
+ <%- if @method_name == 'bulk' -%>
20
+ <%= bulk_doc_helper(@spec['body']['description']) -%>
21
+ <%- else -%>
22
+ <%= ' '*(@namespace_depth+1) +
23
+ '# @option arguments [Hash] :body ' + (@spec['body']['description'] ?
24
+ @spec['body']['description'].strip : 'TODO: Description') +
25
+ (@spec['body']['required'] ? ' (*Required*)' : '') + "\n"
26
+ -%>
27
+ <%- end -%>
28
+ <%- end -%>
19
29
  <% if @deprecation_note -%>
20
30
  #
21
31
  # *Deprecation notice*:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.8.1
4
+ version: 7.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -340,7 +340,7 @@ dependencies:
340
340
  version: '0'
341
341
  description: 'Ruby API for Elasticsearch. See the `elasticsearch` gem for full integration.
342
342
 
343
- '
343
+ '
344
344
  email:
345
345
  - karel.minarik@elasticsearch.org
346
346
  executables: []
@@ -400,6 +400,10 @@ files:
400
400
  - lib/elasticsearch/api/actions/cluster/stats.rb
401
401
  - lib/elasticsearch/api/actions/count.rb
402
402
  - lib/elasticsearch/api/actions/create.rb
403
+ - lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb
404
+ - lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb
405
+ - lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb
406
+ - lib/elasticsearch/api/actions/dangling_indices/params_registry.rb
403
407
  - lib/elasticsearch/api/actions/delete.rb
404
408
  - lib/elasticsearch/api/actions/delete_by_query.rb
405
409
  - lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb
@@ -415,15 +419,14 @@ files:
415
419
  - lib/elasticsearch/api/actions/get_script_languages.rb
416
420
  - lib/elasticsearch/api/actions/get_source.rb
417
421
  - lib/elasticsearch/api/actions/index.rb
422
+ - lib/elasticsearch/api/actions/indices/add_block.rb
418
423
  - lib/elasticsearch/api/actions/indices/analyze.rb
419
424
  - lib/elasticsearch/api/actions/indices/clear_cache.rb
420
425
  - lib/elasticsearch/api/actions/indices/clone.rb
421
426
  - lib/elasticsearch/api/actions/indices/close.rb
422
427
  - lib/elasticsearch/api/actions/indices/create.rb
423
- - lib/elasticsearch/api/actions/indices/create_data_stream.rb
424
428
  - lib/elasticsearch/api/actions/indices/delete.rb
425
429
  - lib/elasticsearch/api/actions/indices/delete_alias.rb
426
- - lib/elasticsearch/api/actions/indices/delete_data_stream.rb
427
430
  - lib/elasticsearch/api/actions/indices/delete_index_template.rb
428
431
  - lib/elasticsearch/api/actions/indices/delete_template.rb
429
432
  - lib/elasticsearch/api/actions/indices/exists.rb
@@ -437,7 +440,6 @@ files:
437
440
  - lib/elasticsearch/api/actions/indices/freeze.rb
438
441
  - lib/elasticsearch/api/actions/indices/get.rb
439
442
  - lib/elasticsearch/api/actions/indices/get_alias.rb
440
- - lib/elasticsearch/api/actions/indices/get_data_streams.rb
441
443
  - lib/elasticsearch/api/actions/indices/get_field_mapping.rb
442
444
  - lib/elasticsearch/api/actions/indices/get_index_template.rb
443
445
  - lib/elasticsearch/api/actions/indices/get_mapping.rb
@@ -453,11 +455,13 @@ files:
453
455
  - lib/elasticsearch/api/actions/indices/put_template.rb
454
456
  - lib/elasticsearch/api/actions/indices/recovery.rb
455
457
  - lib/elasticsearch/api/actions/indices/refresh.rb
458
+ - lib/elasticsearch/api/actions/indices/resolve_index.rb
456
459
  - lib/elasticsearch/api/actions/indices/rollover.rb
457
460
  - lib/elasticsearch/api/actions/indices/segments.rb
458
461
  - lib/elasticsearch/api/actions/indices/shard_stores.rb
459
462
  - lib/elasticsearch/api/actions/indices/shrink.rb
460
463
  - lib/elasticsearch/api/actions/indices/simulate_index_template.rb
464
+ - lib/elasticsearch/api/actions/indices/simulate_template.rb
461
465
  - lib/elasticsearch/api/actions/indices/split.rb
462
466
  - lib/elasticsearch/api/actions/indices/stats.rb
463
467
  - lib/elasticsearch/api/actions/indices/unfreeze.rb
@@ -496,6 +500,7 @@ files:
496
500
  - lib/elasticsearch/api/actions/search_shards.rb
497
501
  - lib/elasticsearch/api/actions/search_template.rb
498
502
  - lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb
503
+ - lib/elasticsearch/api/actions/snapshot/clone.rb
499
504
  - lib/elasticsearch/api/actions/snapshot/create.rb
500
505
  - lib/elasticsearch/api/actions/snapshot/create_repository.rb
501
506
  - lib/elasticsearch/api/actions/snapshot/delete.rb
@@ -517,6 +522,7 @@ files:
517
522
  - lib/elasticsearch/api/namespace/cat.rb
518
523
  - lib/elasticsearch/api/namespace/cluster.rb
519
524
  - lib/elasticsearch/api/namespace/common.rb
525
+ - lib/elasticsearch/api/namespace/dangling_indices.rb
520
526
  - lib/elasticsearch/api/namespace/indices.rb
521
527
  - lib/elasticsearch/api/namespace/ingest.rb
522
528
  - lib/elasticsearch/api/namespace/nodes.rb
@@ -525,7 +531,6 @@ files:
525
531
  - lib/elasticsearch/api/namespace/tasks.rb
526
532
  - lib/elasticsearch/api/utils.rb
527
533
  - lib/elasticsearch/api/version.rb
528
- - spec/README.md
529
534
  - spec/elasticsearch/api/actions/abort_benchmark_spec.rb
530
535
  - spec/elasticsearch/api/actions/benchmark_spec.rb
531
536
  - spec/elasticsearch/api/actions/bulk_spec.rb
@@ -561,6 +566,9 @@ files:
561
566
  - spec/elasticsearch/api/actions/cluster/stats_spec.rb
562
567
  - spec/elasticsearch/api/actions/count_spec.rb
563
568
  - spec/elasticsearch/api/actions/create_document_spec.rb
569
+ - spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb
570
+ - spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb
571
+ - spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb
564
572
  - spec/elasticsearch/api/actions/delete_by_query_spec.rb
565
573
  - spec/elasticsearch/api/actions/delete_document_spec.rb
566
574
  - spec/elasticsearch/api/actions/delete_script_spec.rb
@@ -572,6 +580,7 @@ files:
572
580
  - spec/elasticsearch/api/actions/get_script_spec.rb
573
581
  - spec/elasticsearch/api/actions/hashie_spec.rb
574
582
  - spec/elasticsearch/api/actions/index_document_spec.rb
583
+ - spec/elasticsearch/api/actions/indices/add_block_spec.rb
575
584
  - spec/elasticsearch/api/actions/indices/analyze_spec.rb
576
585
  - spec/elasticsearch/api/actions/indices/clear_cache_spec.rb
577
586
  - spec/elasticsearch/api/actions/indices/clone_spec.rb
@@ -634,6 +643,7 @@ files:
634
643
  - spec/elasticsearch/api/actions/search_shards_spec.rb
635
644
  - spec/elasticsearch/api/actions/search_spec.rb
636
645
  - spec/elasticsearch/api/actions/search_template_spec.rb
646
+ - spec/elasticsearch/api/actions/snapshot/clone_spec.rb
637
647
  - spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb
638
648
  - spec/elasticsearch/api/actions/snapshot/create_spec.rb
639
649
  - spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb
@@ -655,11 +665,10 @@ files:
655
665
  - spec/elasticsearch/api/utils_spec.rb
656
666
  - spec/rest_yaml_tests_helper.rb
657
667
  - spec/spec_helper.rb
658
- - test/integration/yaml_test_runner.rb
659
- - test/test_helper.rb
660
668
  - utils/Gemfile
661
669
  - utils/README.md
662
670
  - utils/Thorfile
671
+ - utils/thor/.rubocop.yml
663
672
  - utils/thor/generate_source.rb
664
673
  - utils/thor/generator/endpoint_specifics.rb
665
674
  - utils/thor/generator/files_helper.rb
@@ -700,7 +709,6 @@ signing_key:
700
709
  specification_version: 4
701
710
  summary: Ruby API for Elasticsearch.
702
711
  test_files:
703
- - spec/README.md
704
712
  - spec/elasticsearch/api/actions/abort_benchmark_spec.rb
705
713
  - spec/elasticsearch/api/actions/benchmark_spec.rb
706
714
  - spec/elasticsearch/api/actions/bulk_spec.rb
@@ -736,6 +744,9 @@ test_files:
736
744
  - spec/elasticsearch/api/actions/cluster/stats_spec.rb
737
745
  - spec/elasticsearch/api/actions/count_spec.rb
738
746
  - spec/elasticsearch/api/actions/create_document_spec.rb
747
+ - spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb
748
+ - spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb
749
+ - spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb
739
750
  - spec/elasticsearch/api/actions/delete_by_query_spec.rb
740
751
  - spec/elasticsearch/api/actions/delete_document_spec.rb
741
752
  - spec/elasticsearch/api/actions/delete_script_spec.rb
@@ -747,6 +758,7 @@ test_files:
747
758
  - spec/elasticsearch/api/actions/get_script_spec.rb
748
759
  - spec/elasticsearch/api/actions/hashie_spec.rb
749
760
  - spec/elasticsearch/api/actions/index_document_spec.rb
761
+ - spec/elasticsearch/api/actions/indices/add_block_spec.rb
750
762
  - spec/elasticsearch/api/actions/indices/analyze_spec.rb
751
763
  - spec/elasticsearch/api/actions/indices/clear_cache_spec.rb
752
764
  - spec/elasticsearch/api/actions/indices/clone_spec.rb
@@ -809,6 +821,7 @@ test_files:
809
821
  - spec/elasticsearch/api/actions/search_shards_spec.rb
810
822
  - spec/elasticsearch/api/actions/search_spec.rb
811
823
  - spec/elasticsearch/api/actions/search_template_spec.rb
824
+ - spec/elasticsearch/api/actions/snapshot/clone_spec.rb
812
825
  - spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb
813
826
  - spec/elasticsearch/api/actions/snapshot/create_spec.rb
814
827
  - spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb
@@ -830,5 +843,3 @@ test_files:
830
843
  - spec/elasticsearch/api/utils_spec.rb
831
844
  - spec/rest_yaml_tests_helper.rb
832
845
  - spec/spec_helper.rb
833
- - test/integration/yaml_test_runner.rb
834
- - test/test_helper.rb