elasticsearch-api 7.8.1 → 7.9.0.pre

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.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/lib/elasticsearch/api.rb +2 -1
  3. data/lib/elasticsearch/api/actions/bulk.rb +7 -5
  4. data/lib/elasticsearch/api/actions/cat/aliases.rb +4 -3
  5. data/lib/elasticsearch/api/actions/cat/allocation.rb +4 -3
  6. data/lib/elasticsearch/api/actions/cat/count.rb +3 -3
  7. data/lib/elasticsearch/api/actions/cat/fielddata.rb +4 -3
  8. data/lib/elasticsearch/api/actions/cat/health.rb +3 -2
  9. data/lib/elasticsearch/api/actions/cat/help.rb +2 -2
  10. data/lib/elasticsearch/api/actions/cat/indices.rb +7 -3
  11. data/lib/elasticsearch/api/actions/cat/master.rb +2 -2
  12. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +2 -2
  13. data/lib/elasticsearch/api/actions/cat/nodes.rb +4 -2
  14. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +3 -2
  15. data/lib/elasticsearch/api/actions/cat/plugins.rb +2 -2
  16. data/lib/elasticsearch/api/actions/cat/recovery.rb +5 -3
  17. data/lib/elasticsearch/api/actions/cat/repositories.rb +2 -2
  18. data/lib/elasticsearch/api/actions/cat/segments.rb +4 -3
  19. data/lib/elasticsearch/api/actions/cat/shards.rb +5 -3
  20. data/lib/elasticsearch/api/actions/cat/snapshots.rb +4 -3
  21. data/lib/elasticsearch/api/actions/cat/tasks.rb +3 -2
  22. data/lib/elasticsearch/api/actions/cat/templates.rb +3 -3
  23. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +4 -3
  24. data/lib/elasticsearch/api/actions/clear_scroll.rb +3 -3
  25. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +9 -4
  26. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +2 -6
  27. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +2 -2
  28. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +2 -6
  29. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +3 -7
  30. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +2 -2
  31. data/lib/elasticsearch/api/actions/cluster/health.rb +7 -3
  32. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +2 -2
  33. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +2 -2
  34. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +2 -6
  35. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +2 -2
  36. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +2 -2
  37. data/lib/elasticsearch/api/actions/cluster/reroute.rb +3 -2
  38. data/lib/elasticsearch/api/actions/cluster/state.rb +5 -3
  39. data/lib/elasticsearch/api/actions/cluster/stats.rb +3 -3
  40. data/lib/elasticsearch/api/actions/count.rb +11 -14
  41. data/lib/elasticsearch/api/actions/create.rb +4 -2
  42. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +60 -0
  43. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +60 -0
  44. data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +43 -0
  45. data/lib/elasticsearch/api/actions/dangling_indices/params_registry.rb +60 -0
  46. data/lib/elasticsearch/api/actions/delete.rb +5 -3
  47. data/lib/elasticsearch/api/actions/delete_by_query.rb +7 -3
  48. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +2 -2
  49. data/lib/elasticsearch/api/actions/delete_script.rb +2 -2
  50. data/lib/elasticsearch/api/actions/exists.rb +4 -3
  51. data/lib/elasticsearch/api/actions/exists_source.rb +4 -3
  52. data/lib/elasticsearch/api/actions/explain.rb +13 -7
  53. data/lib/elasticsearch/api/actions/field_caps.rb +15 -8
  54. data/lib/elasticsearch/api/actions/get.rb +4 -3
  55. data/lib/elasticsearch/api/actions/get_script.rb +2 -2
  56. data/lib/elasticsearch/api/actions/get_script_context.rb +2 -6
  57. data/lib/elasticsearch/api/actions/get_script_languages.rb +2 -6
  58. data/lib/elasticsearch/api/actions/get_source.rb +4 -3
  59. data/lib/elasticsearch/api/actions/index.rb +6 -3
  60. data/lib/elasticsearch/api/actions/indices/add_block.rb +70 -0
  61. data/lib/elasticsearch/api/actions/indices/analyze.rb +12 -7
  62. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +4 -3
  63. data/lib/elasticsearch/api/actions/indices/clone.rb +2 -2
  64. data/lib/elasticsearch/api/actions/indices/close.rb +3 -2
  65. data/lib/elasticsearch/api/actions/indices/create.rb +2 -2
  66. data/lib/elasticsearch/api/actions/indices/create_data_stream.rb +3 -8
  67. data/lib/elasticsearch/api/actions/indices/data_streams_stats.rb +62 -0
  68. data/lib/elasticsearch/api/actions/indices/delete.rb +3 -2
  69. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +3 -3
  70. data/lib/elasticsearch/api/actions/indices/delete_data_stream.rb +3 -7
  71. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +2 -6
  72. data/lib/elasticsearch/api/actions/indices/delete_template.rb +2 -2
  73. data/lib/elasticsearch/api/actions/indices/exists.rb +3 -2
  74. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +4 -3
  75. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +2 -6
  76. data/lib/elasticsearch/api/actions/indices/exists_template.rb +2 -2
  77. data/lib/elasticsearch/api/actions/indices/exists_type.rb +3 -2
  78. data/lib/elasticsearch/api/actions/indices/flush.rb +4 -3
  79. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +4 -3
  80. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +4 -3
  81. data/lib/elasticsearch/api/actions/indices/get.rb +3 -2
  82. data/lib/elasticsearch/api/actions/indices/get_alias.rb +4 -3
  83. data/lib/elasticsearch/api/actions/indices/{get_data_streams.rb → get_data_stream.rb} +7 -11
  84. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +4 -3
  85. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +3 -7
  86. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +5 -4
  87. data/lib/elasticsearch/api/actions/indices/get_settings.rb +4 -3
  88. data/lib/elasticsearch/api/actions/indices/get_template.rb +3 -3
  89. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +4 -3
  90. data/lib/elasticsearch/api/actions/indices/open.rb +3 -2
  91. data/lib/elasticsearch/api/actions/indices/put_alias.rb +3 -3
  92. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +2 -6
  93. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +7 -4
  94. data/lib/elasticsearch/api/actions/indices/put_settings.rb +4 -3
  95. data/lib/elasticsearch/api/actions/indices/put_template.rb +2 -2
  96. data/lib/elasticsearch/api/actions/indices/recovery.rb +3 -3
  97. data/lib/elasticsearch/api/actions/indices/refresh.rb +4 -3
  98. data/lib/elasticsearch/api/actions/indices/resolve_index.rb +58 -0
  99. data/lib/elasticsearch/api/actions/indices/rollover.rb +3 -3
  100. data/lib/elasticsearch/api/actions/indices/segments.rb +4 -3
  101. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +5 -3
  102. data/lib/elasticsearch/api/actions/indices/shrink.rb +2 -2
  103. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +2 -6
  104. data/lib/elasticsearch/api/actions/indices/simulate_template.rb +63 -0
  105. data/lib/elasticsearch/api/actions/indices/split.rb +2 -2
  106. data/lib/elasticsearch/api/actions/indices/stats.rb +5 -2
  107. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +2 -2
  108. data/lib/elasticsearch/api/actions/indices/upgrade.rb +4 -3
  109. data/lib/elasticsearch/api/actions/indices/validate_query.rb +16 -9
  110. data/lib/elasticsearch/api/actions/info.rb +2 -2
  111. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +2 -2
  112. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +3 -3
  113. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +2 -2
  114. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +2 -2
  115. data/lib/elasticsearch/api/actions/ingest/simulate.rb +4 -4
  116. data/lib/elasticsearch/api/actions/mget.rb +4 -4
  117. data/lib/elasticsearch/api/actions/msearch.rb +6 -5
  118. data/lib/elasticsearch/api/actions/msearch_template.rb +6 -5
  119. data/lib/elasticsearch/api/actions/mtermvectors.rb +16 -10
  120. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +4 -3
  121. data/lib/elasticsearch/api/actions/nodes/info.rb +4 -3
  122. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +3 -3
  123. data/lib/elasticsearch/api/actions/nodes/stats.rb +7 -4
  124. data/lib/elasticsearch/api/actions/nodes/usage.rb +4 -3
  125. data/lib/elasticsearch/api/actions/ping.rb +2 -2
  126. data/lib/elasticsearch/api/actions/put_script.rb +3 -3
  127. data/lib/elasticsearch/api/actions/rank_eval.rb +6 -8
  128. data/lib/elasticsearch/api/actions/reindex.rb +2 -2
  129. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +2 -2
  130. data/lib/elasticsearch/api/actions/render_search_template.rb +12 -7
  131. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +9 -8
  132. data/lib/elasticsearch/api/actions/scroll.rb +12 -7
  133. data/lib/elasticsearch/api/actions/search.rb +18 -9
  134. data/lib/elasticsearch/api/actions/search_shards.rb +4 -3
  135. data/lib/elasticsearch/api/actions/search_template.rb +6 -4
  136. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +2 -2
  137. data/lib/elasticsearch/api/actions/snapshot/create.rb +2 -2
  138. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +2 -2
  139. data/lib/elasticsearch/api/actions/snapshot/delete.rb +2 -2
  140. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +2 -2
  141. data/lib/elasticsearch/api/actions/snapshot/get.rb +2 -2
  142. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +3 -3
  143. data/lib/elasticsearch/api/actions/snapshot/restore.rb +2 -2
  144. data/lib/elasticsearch/api/actions/snapshot/status.rb +3 -3
  145. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +2 -2
  146. data/lib/elasticsearch/api/actions/tasks/cancel.rb +3 -3
  147. data/lib/elasticsearch/api/actions/tasks/get.rb +2 -2
  148. data/lib/elasticsearch/api/actions/tasks/list.rb +3 -2
  149. data/lib/elasticsearch/api/actions/termvectors.rb +9 -4
  150. data/lib/elasticsearch/api/actions/update.rb +4 -3
  151. data/lib/elasticsearch/api/actions/update_by_query.rb +7 -3
  152. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +2 -2
  153. data/lib/elasticsearch/api/namespace/cat.rb +0 -1
  154. data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
  155. data/lib/elasticsearch/api/version.rb +1 -1
  156. data/spec/elasticsearch/api/actions/count_spec.rb +2 -2
  157. data/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +48 -0
  158. data/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +48 -0
  159. data/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +36 -0
  160. data/spec/elasticsearch/api/actions/explain_document_spec.rb +8 -9
  161. data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
  162. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +7 -8
  163. data/spec/elasticsearch/api/actions/indices/data_streams_stats_spec.rb +72 -0
  164. data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +7 -13
  165. data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +6 -7
  166. data/spec/elasticsearch/api/actions/json_builders_spec.rb +10 -13
  167. data/spec/elasticsearch/api/actions/mget_spec.rb +5 -6
  168. data/spec/elasticsearch/api/actions/msearch_spec.rb +5 -6
  169. data/spec/elasticsearch/api/actions/msearch_template_spec.rb +5 -6
  170. data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +7 -7
  171. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +2 -2
  172. data/spec/elasticsearch/api/actions/scroll_spec.rb +1 -1
  173. data/spec/elasticsearch/api/actions/search_spec.rb +7 -7
  174. data/spec/elasticsearch/api/actions/search_template_spec.rb +5 -6
  175. data/spec/elasticsearch/api/actions/termvectors_spec.rb +5 -7
  176. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +0 -1
  177. data/utils/thor/.rubocop.yml +2 -0
  178. data/utils/thor/generate_source.rb +23 -42
  179. data/utils/thor/generator/endpoint_specifics.rb +8 -1
  180. data/utils/thor/templates/_documentation_top.erb +11 -2
  181. metadata +25 -11
  182. data/spec/README.md +0 -61
  183. data/test/integration/yaml_test_runner.rb +0 -592
  184. data/test/test_helper.rb +0 -118
@@ -18,16 +18,16 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client.cluster#validate_query' 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(:url) do
33
33
  '_validate/query'
@@ -46,7 +46,6 @@ describe 'client.cluster#validate_query' do
46
46
  end
47
47
 
48
48
  context 'when an index is specified' do
49
-
50
49
  let(:url) do
51
50
  'foo/_validate/query'
52
51
  end
@@ -57,7 +56,6 @@ describe 'client.cluster#validate_query' do
57
56
  end
58
57
 
59
58
  context 'when a type and index are specified' do
60
-
61
59
  let(:url) do
62
60
  'foo/bar/_validate/query'
63
61
  end
@@ -68,7 +66,6 @@ describe 'client.cluster#validate_query' do
68
66
  end
69
67
 
70
68
  context 'when multiple indicies are specified as a list' do
71
-
72
69
  let(:url) do
73
70
  'foo,bar/_validate/query'
74
71
  end
@@ -79,7 +76,6 @@ describe 'client.cluster#validate_query' do
79
76
  end
80
77
 
81
78
  context 'when multiple indicies are specified as a string' do
82
-
83
79
  let(:url) do
84
80
  'foo,bar/_validate/query'
85
81
  end
@@ -90,7 +86,6 @@ describe 'client.cluster#validate_query' do
90
86
  end
91
87
 
92
88
  context 'when parameters are specified' do
93
-
94
89
  let(:params) do
95
90
  { explain: true, q: 'foo' }
96
91
  end
@@ -105,10 +100,10 @@ describe 'client.cluster#validate_query' do
105
100
  end
106
101
 
107
102
  context 'when a body is specified' do
108
-
109
103
  let(:body) do
110
104
  { filtered: {} }
111
105
  end
106
+ let(:method) { 'POST' }
112
107
 
113
108
  it 'performs the request' do
114
109
  expect(client_double.indices.validate_query(body: { filtered: {} })).to eq({})
@@ -116,7 +111,6 @@ describe 'client.cluster#validate_query' do
116
111
  end
117
112
 
118
113
  context 'when the path needs to be URL-escaped' do
119
-
120
114
  let(:url) do
121
115
  'foo%5Ebar/_validate/query'
122
116
  end
@@ -18,16 +18,16 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client.ingest#simulate' do
21
-
22
21
  let(:expected_args) do
23
22
  [
24
- 'GET',
25
- url,
26
- {},
27
- {},
28
- {}
23
+ method,
24
+ url,
25
+ {},
26
+ {},
27
+ {}
29
28
  ]
30
29
  end
30
+ let(:method) { 'POST' }
31
31
 
32
32
  let(:url) do
33
33
  '_ingest/pipeline/_simulate'
@@ -38,7 +38,6 @@ describe 'client.ingest#simulate' do
38
38
  end
39
39
 
40
40
  context 'when a pipeline id is provided' do
41
-
42
41
  let(:url) do
43
42
  '_ingest/pipeline/foo/_simulate'
44
43
  end
@@ -18,16 +18,14 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'JSON builders' do
21
-
22
21
  context 'JBuilder' do
23
-
24
22
  let(:expected_args) do
25
23
  [
26
- 'GET',
27
- '_search',
28
- {},
29
- body,
30
- {}
24
+ 'POST',
25
+ '_search',
26
+ {},
27
+ body,
28
+ {}
31
29
  ]
32
30
  end
33
31
 
@@ -53,14 +51,13 @@ describe 'JSON builders' do
53
51
  end
54
52
 
55
53
  context 'Jsonify' do
56
-
57
54
  let(:expected_args) do
58
55
  [
59
- 'GET',
60
- '_search',
61
- {},
62
- body,
63
- {}
56
+ 'POST',
57
+ '_search',
58
+ {},
59
+ body,
60
+ {}
64
61
  ]
65
62
  end
66
63
 
@@ -18,14 +18,13 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#mget' 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
 
@@ -18,14 +18,13 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#msearch' 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,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
 
@@ -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
@@ -52,7 +52,6 @@ describe 'Rest API YAML tests' do
52
52
  end
53
53
  end
54
54
  else
55
-
56
55
  # 'match' is in the task group definition
57
56
  if task_group.has_match_clauses?
58
57
  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,38 +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
232
+ options = info['options'] ? "\n # (options: #{info['options'].join(', '.strip)})\n" : ''
226
233
  required = info['required'] ? ' (*Required*)' : ''
227
234
  deprecated = info['deprecated'] ? ' *Deprecated*' : ''
228
235
  "# @option arguments [#{tipo}] :#{name} #{description} #{required} #{deprecated} #{options}\n"
229
236
  end
230
237
 
231
- def stability_doc_helper(stability)
232
- return if stability == 'stable'
233
-
234
- if stability == 'experimental'
235
- <<~MSG
236
- # This functionality is Experimental and may be changed or removed
237
- # completely in a future release. Elastic will take a best effort approach
238
- # to fix any issues, but experimental features are not subject to the
239
- # support SLA of official GA features.
240
- MSG
241
- elsif stability == 'beta'
242
- <<~MSG
243
- # This functionality is in Beta and is subject to change. The design and
244
- # code is less mature than official GA features and is being provided
245
- # as-is with no warranties. Beta features are not subject to the support
246
- # SLA of official GA features.
247
- MSG
248
- else
249
- <<~MSG
250
- # This functionality is subject to potential breaking changes within a
251
- # minor version, meaning that your referencing code may break when this
252
- # library is upgraded.
253
- MSG
254
- end
255
- end
256
-
257
238
  def generate_tests
258
239
  copy_file 'templates/test_helper.rb', @output.join('test').join('test_helper.rb')
259
240
 
@@ -286,7 +267,7 @@ module Elasticsearch
286
267
  end
287
268
 
288
269
  def run_rubocop(api)
289
- system("rubocop --format autogenconf -x #{FilesHelper::output_dir(api)}")
270
+ system("rubocop -c ./thor/.rubocop.yml --format autogenconf -x #{FilesHelper::output_dir(api)}")
290
271
  end
291
272
  end
292
273
  end