elasticsearch-api 6.8.0 → 7.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (379) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +26 -5
  3. data/LICENSE +202 -0
  4. data/README.md +24 -21
  5. data/Rakefile +43 -45
  6. data/elasticsearch-api.gemspec +56 -55
  7. data/lib/elasticsearch/api/actions/abort_benchmark.rb +19 -3
  8. data/lib/elasticsearch/api/actions/benchmark.rb +21 -5
  9. data/lib/elasticsearch/api/actions/bulk.rb +54 -69
  10. data/lib/elasticsearch/api/actions/cat/aliases.rb +45 -45
  11. data/lib/elasticsearch/api/actions/cat/allocation.rb +45 -41
  12. data/lib/elasticsearch/api/actions/cat/count.rb +38 -39
  13. data/lib/elasticsearch/api/actions/cat/fielddata.rb +42 -29
  14. data/lib/elasticsearch/api/actions/cat/health.rb +37 -29
  15. data/lib/elasticsearch/api/actions/cat/help.rb +31 -9
  16. data/lib/elasticsearch/api/actions/cat/indices.rb +51 -51
  17. data/lib/elasticsearch/api/actions/cat/master.rb +36 -26
  18. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +36 -14
  19. data/lib/elasticsearch/api/actions/cat/nodes.rb +43 -39
  20. data/lib/elasticsearch/api/actions/cat/params_registry.rb +20 -4
  21. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +38 -26
  22. data/lib/elasticsearch/api/actions/cat/plugins.rb +36 -14
  23. data/lib/elasticsearch/api/actions/cat/recovery.rb +47 -47
  24. data/lib/elasticsearch/api/actions/cat/repositories.rb +36 -22
  25. data/lib/elasticsearch/api/actions/cat/segments.rb +42 -19
  26. data/lib/elasticsearch/api/actions/cat/shards.rb +45 -50
  27. data/lib/elasticsearch/api/actions/cat/snapshots.rb +44 -25
  28. data/lib/elasticsearch/api/actions/cat/tasks.rb +40 -16
  29. data/lib/elasticsearch/api/actions/cat/templates.rb +43 -16
  30. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +46 -35
  31. data/lib/elasticsearch/api/actions/clear_scroll.rb +40 -17
  32. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +38 -11
  33. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +62 -0
  34. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +51 -0
  35. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +63 -0
  36. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +64 -0
  37. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +33 -15
  38. data/lib/elasticsearch/api/actions/cluster/health.rb +46 -27
  39. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +20 -4
  40. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +32 -14
  41. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +55 -0
  42. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +66 -0
  43. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +35 -15
  44. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +27 -12
  45. data/lib/elasticsearch/api/actions/cluster/reroute.rb +38 -33
  46. data/lib/elasticsearch/api/actions/cluster/state.rb +53 -44
  47. data/lib/elasticsearch/api/actions/cluster/stats.rb +38 -19
  48. data/lib/elasticsearch/api/actions/count.rb +60 -36
  49. data/lib/elasticsearch/api/actions/create.rb +37 -25
  50. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +60 -0
  51. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +60 -0
  52. data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +43 -0
  53. data/lib/elasticsearch/api/actions/dangling_indices/params_registry.rb +60 -0
  54. data/lib/elasticsearch/api/actions/delete.rb +62 -47
  55. data/lib/elasticsearch/api/actions/delete_by_query.rb +82 -57
  56. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +36 -11
  57. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +47 -0
  58. data/lib/elasticsearch/api/actions/delete_script.rb +37 -12
  59. data/lib/elasticsearch/api/actions/exists.rb +61 -34
  60. data/lib/elasticsearch/api/actions/exists_source.rb +60 -24
  61. data/lib/elasticsearch/api/actions/explain.rb +68 -44
  62. data/lib/elasticsearch/api/actions/field_caps.rb +49 -19
  63. data/lib/elasticsearch/api/actions/get.rb +60 -40
  64. data/lib/elasticsearch/api/actions/get_script.rb +37 -13
  65. data/lib/elasticsearch/api/actions/get_script_context.rb +45 -0
  66. data/lib/elasticsearch/api/actions/get_script_languages.rb +45 -0
  67. data/lib/elasticsearch/api/actions/get_source.rb +57 -38
  68. data/lib/elasticsearch/api/actions/index.rb +67 -74
  69. data/lib/elasticsearch/api/actions/indices/add_block.rb +68 -0
  70. data/lib/elasticsearch/api/actions/indices/analyze.rb +41 -34
  71. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +44 -41
  72. data/lib/elasticsearch/api/actions/indices/clone.rb +65 -0
  73. data/lib/elasticsearch/api/actions/indices/close.rb +41 -21
  74. data/lib/elasticsearch/api/actions/indices/create.rb +39 -69
  75. data/lib/elasticsearch/api/actions/indices/delete.rb +41 -34
  76. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +41 -19
  77. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +62 -0
  78. data/lib/elasticsearch/api/actions/indices/delete_template.rb +36 -20
  79. data/lib/elasticsearch/api/actions/indices/exists.rb +43 -21
  80. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +46 -18
  81. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +65 -0
  82. data/lib/elasticsearch/api/actions/indices/exists_template.rb +37 -14
  83. data/lib/elasticsearch/api/actions/indices/exists_type.rb +42 -17
  84. data/lib/elasticsearch/api/actions/indices/flush.rb +41 -19
  85. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +45 -11
  86. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +42 -40
  87. data/lib/elasticsearch/api/actions/indices/freeze.rb +24 -7
  88. data/lib/elasticsearch/api/actions/indices/get.rb +42 -18
  89. data/lib/elasticsearch/api/actions/indices/get_alias.rb +47 -22
  90. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +59 -37
  91. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +66 -0
  92. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +57 -32
  93. data/lib/elasticsearch/api/actions/indices/get_settings.rb +50 -36
  94. data/lib/elasticsearch/api/actions/indices/get_template.rb +40 -22
  95. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +62 -0
  96. data/lib/elasticsearch/api/actions/indices/open.rb +40 -20
  97. data/lib/elasticsearch/api/actions/indices/params_registry.rb +20 -4
  98. data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -26
  99. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +66 -0
  100. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +58 -40
  101. data/lib/elasticsearch/api/actions/indices/put_settings.rb +46 -36
  102. data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -24
  103. data/lib/elasticsearch/api/actions/indices/recovery.rb +38 -22
  104. data/lib/elasticsearch/api/actions/indices/refresh.rb +39 -25
  105. data/lib/elasticsearch/api/actions/indices/resolve_index.rb +60 -0
  106. data/lib/elasticsearch/api/actions/indices/rollover.rb +47 -18
  107. data/lib/elasticsearch/api/actions/indices/segments.rb +40 -16
  108. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +41 -13
  109. data/lib/elasticsearch/api/actions/indices/shrink.rb +40 -17
  110. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +65 -0
  111. data/lib/elasticsearch/api/actions/indices/simulate_template.rb +67 -0
  112. data/lib/elasticsearch/api/actions/indices/split.rb +40 -18
  113. data/lib/elasticsearch/api/actions/indices/stats.rb +68 -104
  114. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +24 -7
  115. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +33 -31
  116. data/lib/elasticsearch/api/actions/indices/upgrade.rb +42 -14
  117. data/lib/elasticsearch/api/actions/indices/validate_query.rb +64 -57
  118. data/lib/elasticsearch/api/actions/info.rb +29 -13
  119. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +36 -11
  120. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +37 -9
  121. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +20 -4
  122. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +27 -13
  123. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +37 -13
  124. data/lib/elasticsearch/api/actions/ingest/simulate.rb +39 -10
  125. data/lib/elasticsearch/api/actions/mget.rb +55 -43
  126. data/lib/elasticsearch/api/actions/msearch.rb +67 -50
  127. data/lib/elasticsearch/api/actions/msearch_template.rb +62 -29
  128. data/lib/elasticsearch/api/actions/mtermvectors.rb +59 -32
  129. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +46 -22
  130. data/lib/elasticsearch/api/actions/nodes/info.rb +43 -40
  131. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +20 -4
  132. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +37 -21
  133. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +22 -5
  134. data/lib/elasticsearch/api/actions/nodes/stats.rb +53 -33
  135. data/lib/elasticsearch/api/actions/nodes/usage.rb +46 -12
  136. data/lib/elasticsearch/api/actions/params_registry.rb +20 -4
  137. data/lib/elasticsearch/api/actions/ping.rb +30 -18
  138. data/lib/elasticsearch/api/actions/put_script.rb +44 -31
  139. data/lib/elasticsearch/api/actions/rank_eval.rb +49 -16
  140. data/lib/elasticsearch/api/actions/reindex.rb +45 -48
  141. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +36 -11
  142. data/lib/elasticsearch/api/actions/remote/info.rb +18 -2
  143. data/lib/elasticsearch/api/actions/render_search_template.rb +41 -15
  144. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +38 -14
  145. data/lib/elasticsearch/api/actions/scroll.rb +51 -51
  146. data/lib/elasticsearch/api/actions/search.rb +96 -121
  147. data/lib/elasticsearch/api/actions/search_shards.rb +43 -15
  148. data/lib/elasticsearch/api/actions/search_template.rb +64 -37
  149. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +58 -0
  150. data/lib/elasticsearch/api/actions/snapshot/clone.rb +66 -0
  151. data/lib/elasticsearch/api/actions/snapshot/create.rb +39 -26
  152. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +37 -23
  153. data/lib/elasticsearch/api/actions/snapshot/delete.rb +38 -21
  154. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +35 -17
  155. data/lib/elasticsearch/api/actions/snapshot/get.rb +40 -29
  156. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +38 -20
  157. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +20 -4
  158. data/lib/elasticsearch/api/actions/snapshot/restore.rb +39 -31
  159. data/lib/elasticsearch/api/actions/snapshot/status.rb +41 -21
  160. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +36 -12
  161. data/lib/elasticsearch/api/actions/tasks/cancel.rb +39 -12
  162. data/lib/elasticsearch/api/actions/tasks/get.rb +34 -12
  163. data/lib/elasticsearch/api/actions/tasks/list.rb +35 -16
  164. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +20 -4
  165. data/lib/elasticsearch/api/actions/termvectors.rb +71 -65
  166. data/lib/elasticsearch/api/actions/update.rb +68 -72
  167. data/lib/elasticsearch/api/actions/update_by_query.rb +84 -62
  168. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +36 -11
  169. data/lib/elasticsearch/api/namespace/cat.rb +17 -1
  170. data/lib/elasticsearch/api/namespace/cluster.rb +17 -0
  171. data/lib/elasticsearch/api/namespace/common.rb +17 -0
  172. data/lib/elasticsearch/api/namespace/dangling_indices.rb +35 -0
  173. data/lib/elasticsearch/api/namespace/indices.rb +17 -0
  174. data/lib/elasticsearch/api/namespace/ingest.rb +17 -0
  175. data/lib/elasticsearch/api/namespace/nodes.rb +17 -0
  176. data/lib/elasticsearch/api/namespace/remote.rb +17 -0
  177. data/lib/elasticsearch/api/namespace/snapshot.rb +17 -0
  178. data/lib/elasticsearch/api/namespace/tasks.rb +17 -0
  179. data/lib/elasticsearch/api/utils.rb +17 -0
  180. data/lib/elasticsearch/api/version.rb +18 -1
  181. data/lib/elasticsearch/api.rb +22 -2
  182. data/lib/elasticsearch-api.rb +17 -0
  183. data/spec/elasticsearch/api/actions/abort_benchmark_spec.rb +17 -0
  184. data/spec/elasticsearch/api/actions/benchmark_spec.rb +17 -0
  185. data/spec/elasticsearch/api/actions/bulk_spec.rb +17 -0
  186. data/spec/elasticsearch/api/actions/cat/aliases_spec.rb +18 -1
  187. data/spec/elasticsearch/api/actions/cat/allocation_spec.rb +18 -1
  188. data/spec/elasticsearch/api/actions/cat/count_spec.rb +18 -1
  189. data/spec/elasticsearch/api/actions/cat/fielddata_spec.rb +19 -2
  190. data/spec/elasticsearch/api/actions/cat/health_spec.rb +18 -1
  191. data/spec/elasticsearch/api/actions/cat/help_spec.rb +18 -1
  192. data/spec/elasticsearch/api/actions/cat/indices_spec.rb +18 -1
  193. data/spec/elasticsearch/api/actions/cat/master_spec.rb +18 -1
  194. data/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb +18 -1
  195. data/spec/elasticsearch/api/actions/cat/nodes_spec.rb +18 -1
  196. data/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb +18 -1
  197. data/spec/elasticsearch/api/actions/cat/plugins_spec.rb +18 -1
  198. data/spec/elasticsearch/api/actions/cat/recovery_spec.rb +18 -1
  199. data/spec/elasticsearch/api/actions/cat/repositories_spec.rb +18 -1
  200. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +36 -5
  201. data/spec/elasticsearch/api/actions/cat/shards_spec.rb +18 -1
  202. data/spec/elasticsearch/api/actions/cat/snapshot_spec.rb +18 -1
  203. data/spec/elasticsearch/api/actions/cat/tasks_spec.rb +18 -1
  204. data/spec/elasticsearch/api/actions/cat/templates_spec.rb +18 -1
  205. data/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb +18 -1
  206. data/spec/elasticsearch/api/actions/clear_scroll_spec.rb +21 -2
  207. data/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb +18 -1
  208. data/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb +18 -1
  209. data/spec/elasticsearch/api/actions/cluster/health_spec.rb +20 -3
  210. data/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb +18 -1
  211. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +19 -2
  212. data/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb +18 -1
  213. data/spec/elasticsearch/api/actions/cluster/reroute_spec.rb +19 -2
  214. data/spec/elasticsearch/api/actions/cluster/state_spec.rb +19 -2
  215. data/spec/elasticsearch/api/actions/cluster/stats_spec.rb +18 -18
  216. data/spec/elasticsearch/api/actions/count_spec.rb +30 -10
  217. data/spec/elasticsearch/api/actions/create_document_spec.rb +25 -4
  218. data/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +48 -0
  219. data/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +48 -0
  220. data/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +36 -0
  221. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +33 -8
  222. data/spec/elasticsearch/api/actions/delete_document_spec.rb +21 -8
  223. data/spec/elasticsearch/api/actions/delete_script_spec.rb +19 -15
  224. data/spec/elasticsearch/api/actions/exists_document_spec.rb +20 -2
  225. data/spec/elasticsearch/api/actions/explain_document_spec.rb +26 -15
  226. data/spec/elasticsearch/api/actions/field_caps_spec.rb +19 -1
  227. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +24 -4
  228. data/spec/elasticsearch/api/actions/get_document_spec.rb +20 -2
  229. data/spec/elasticsearch/api/actions/get_script_spec.rb +25 -14
  230. data/spec/elasticsearch/api/actions/hashie_spec.rb +17 -0
  231. data/spec/elasticsearch/api/actions/index_document_spec.rb +25 -22
  232. data/spec/elasticsearch/api/actions/indices/add_block_spec.rb +63 -0
  233. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +24 -12
  234. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +8 -8
  235. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +122 -0
  236. data/spec/elasticsearch/api/actions/indices/close_spec.rb +18 -1
  237. data/spec/elasticsearch/api/actions/indices/create_spec.rb +18 -1
  238. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +20 -3
  239. data/spec/elasticsearch/api/actions/indices/delete_spec.rb +18 -1
  240. data/spec/elasticsearch/api/actions/indices/delete_template_spec.rb +18 -1
  241. data/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb +18 -1
  242. data/spec/elasticsearch/api/actions/indices/exists_spec.rb +18 -1
  243. data/spec/elasticsearch/api/actions/indices/exists_template_spec.rb +18 -1
  244. data/spec/elasticsearch/api/actions/indices/exists_type_spec.rb +18 -1
  245. data/spec/elasticsearch/api/actions/indices/flush_spec.rb +18 -1
  246. data/spec/elasticsearch/api/actions/indices/flush_synced_spec.rb +18 -1
  247. data/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb +18 -1
  248. data/spec/elasticsearch/api/actions/indices/freeze_spec.rb +85 -0
  249. data/spec/elasticsearch/api/actions/indices/get_alias_spec.rb +18 -1
  250. data/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb +18 -1
  251. data/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb +18 -1
  252. data/spec/elasticsearch/api/actions/indices/get_settings_spec.rb +18 -1
  253. data/spec/elasticsearch/api/actions/indices/get_spec.rb +18 -12
  254. data/spec/elasticsearch/api/actions/indices/open_spec.rb +18 -1
  255. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +21 -4
  256. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +21 -4
  257. data/spec/elasticsearch/api/actions/indices/put_settings_spec.rb +33 -1
  258. data/spec/elasticsearch/api/actions/indices/put_template_spec.rb +18 -1
  259. data/spec/elasticsearch/api/actions/indices/recovery_spec.rb +18 -1
  260. data/spec/elasticsearch/api/actions/indices/refresh_spec.rb +18 -1
  261. data/spec/elasticsearch/api/actions/indices/rollover_spec.rb +18 -1
  262. data/spec/elasticsearch/api/actions/indices/segments_spec.rb +18 -1
  263. data/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb +18 -1
  264. data/spec/elasticsearch/api/actions/indices/shrink_spec.rb +18 -1
  265. data/spec/elasticsearch/api/actions/indices/split_spec.rb +18 -1
  266. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +124 -0
  267. data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +85 -0
  268. data/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb +18 -1
  269. data/spec/elasticsearch/api/actions/indices/upgrade_spec.rb +18 -1
  270. data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +24 -13
  271. data/spec/elasticsearch/api/actions/info_spec.rb +19 -1
  272. data/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb +18 -1
  273. data/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb +18 -1
  274. data/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb +18 -1
  275. data/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +23 -7
  276. data/spec/elasticsearch/api/actions/json_builders_spec.rb +27 -11
  277. data/spec/elasticsearch/api/actions/mget_spec.rb +22 -5
  278. data/spec/elasticsearch/api/actions/msearch_spec.rb +38 -39
  279. data/spec/elasticsearch/api/actions/msearch_template_spec.rb +22 -6
  280. data/spec/elasticsearch/api/actions/mtermvectors_spec.rb +24 -6
  281. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +21 -4
  282. data/spec/elasticsearch/api/actions/nodes/info_spec.rb +18 -1
  283. data/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb +24 -10
  284. data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +17 -0
  285. data/spec/elasticsearch/api/actions/nodes/stats_spec.rb +18 -1
  286. data/spec/elasticsearch/api/actions/ping_spec.rb +20 -2
  287. data/spec/elasticsearch/api/actions/put_script_spec.rb +39 -15
  288. data/spec/elasticsearch/api/actions/reindex_spec.rb +20 -2
  289. data/spec/elasticsearch/api/actions/remote/info_spec.rb +17 -0
  290. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +44 -9
  291. data/spec/elasticsearch/api/actions/scroll_spec.rb +52 -0
  292. data/spec/elasticsearch/api/actions/search_shards_spec.rb +20 -2
  293. data/spec/elasticsearch/api/actions/search_spec.rb +24 -6
  294. data/spec/elasticsearch/api/actions/search_template_spec.rb +22 -5
  295. data/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +67 -0
  296. data/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb +18 -1
  297. data/spec/elasticsearch/api/actions/snapshot/create_spec.rb +18 -1
  298. data/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb +18 -1
  299. data/spec/elasticsearch/api/actions/snapshot/delete_spec.rb +18 -1
  300. data/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb +18 -1
  301. data/spec/elasticsearch/api/actions/snapshot/get_spec.rb +18 -1
  302. data/spec/elasticsearch/api/actions/snapshot/restore_spec.rb +18 -1
  303. data/spec/elasticsearch/api/actions/snapshot/status_spec.rb +18 -1
  304. data/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb +18 -1
  305. data/spec/elasticsearch/api/actions/tasks/cancel_spec.rb +18 -1
  306. data/spec/elasticsearch/api/actions/tasks/get_spec.rb +18 -1
  307. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +18 -12
  308. data/spec/elasticsearch/api/actions/termvectors_spec.rb +22 -12
  309. data/spec/elasticsearch/api/actions/update_by_query_spec.rb +20 -2
  310. data/spec/elasticsearch/api/actions/update_document_spec.rb +22 -14
  311. data/spec/elasticsearch/api/api_spec.rb +17 -0
  312. data/spec/elasticsearch/api/client_spec.rb +17 -0
  313. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +138 -0
  314. data/spec/elasticsearch/api/utils_spec.rb +18 -1
  315. data/spec/rest_yaml_tests_helper.rb +107 -0
  316. data/spec/spec_helper.rb +33 -34
  317. data/utils/Gemfile +18 -0
  318. data/utils/README.md +41 -0
  319. data/utils/Thorfile +4 -1
  320. data/utils/thor/.rubocop.yml +2 -0
  321. data/utils/thor/generate_source.rb +248 -81
  322. data/utils/thor/generator/endpoint_specifics.rb +181 -0
  323. data/utils/thor/generator/files_helper.rb +60 -0
  324. data/utils/thor/lister.rb +20 -4
  325. data/utils/thor/templates/_documentation_top.erb +39 -0
  326. data/utils/thor/templates/_method_setup.erb +35 -0
  327. data/utils/thor/templates/_params_registry.erb +12 -0
  328. data/utils/thor/templates/_perform_request.erb +38 -0
  329. data/utils/thor/templates/method.erb +73 -0
  330. data/utils/thor/templates/{ruby/test.erb → test.erb} +4 -0
  331. data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +17 -1
  332. metadata +123 -124
  333. data/LICENSE.txt +0 -13
  334. data/lib/elasticsearch/api/actions/count_percolate.rb +0 -82
  335. data/lib/elasticsearch/api/actions/delete_template.rb +0 -21
  336. data/lib/elasticsearch/api/actions/field_stats.rb +0 -36
  337. data/lib/elasticsearch/api/actions/get_template.rb +0 -27
  338. data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +0 -26
  339. data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +0 -32
  340. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +0 -37
  341. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +0 -62
  342. data/lib/elasticsearch/api/actions/indices/optimize.rb +0 -77
  343. data/lib/elasticsearch/api/actions/indices/put_warmer.rb +0 -65
  344. data/lib/elasticsearch/api/actions/indices/seal.rb +0 -24
  345. data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +0 -44
  346. data/lib/elasticsearch/api/actions/indices/status.rb +0 -63
  347. data/lib/elasticsearch/api/actions/list_benchmarks.rb +0 -27
  348. data/lib/elasticsearch/api/actions/mlt.rb +0 -130
  349. data/lib/elasticsearch/api/actions/mpercolate.rb +0 -62
  350. data/lib/elasticsearch/api/actions/percolate.rb +0 -73
  351. data/lib/elasticsearch/api/actions/put_template.rb +0 -25
  352. data/lib/elasticsearch/api/actions/search_exists.rb +0 -63
  353. data/lib/elasticsearch/api/actions/suggest.rb +0 -49
  354. data/spec/elasticsearch/api/actions/count_percolate_spec.rb +0 -17
  355. data/spec/elasticsearch/api/actions/delete_template_spec.rb +0 -17
  356. data/spec/elasticsearch/api/actions/field_stats_spec.rb +0 -17
  357. data/spec/elasticsearch/api/actions/get_template_spec.rb +0 -52
  358. data/spec/elasticsearch/api/actions/indices/delete_mapping_spec.rb +0 -77
  359. data/spec/elasticsearch/api/actions/indices/delete_warmer_spec.rb +0 -86
  360. data/spec/elasticsearch/api/actions/indices/get_aliases_spec.rb +0 -55
  361. data/spec/elasticsearch/api/actions/indices/get_template_spec.rb +0 -59
  362. data/spec/elasticsearch/api/actions/indices/get_warmer_spec.rb +0 -48
  363. data/spec/elasticsearch/api/actions/indices/optimize_spec.rb +0 -63
  364. data/spec/elasticsearch/api/actions/indices/put_warmer_spec.rb +0 -101
  365. data/spec/elasticsearch/api/actions/indices/seal_spec.rb +0 -18
  366. data/spec/elasticsearch/api/actions/indices/snapshot_index_spec.rb +0 -89
  367. data/spec/elasticsearch/api/actions/indices/status_spec.rb +0 -92
  368. data/spec/elasticsearch/api/actions/list_benchmarks_spec.rb +0 -17
  369. data/spec/elasticsearch/api/actions/mlt_spec.rb +0 -130
  370. data/spec/elasticsearch/api/actions/mpercolate_spec.rb +0 -49
  371. data/spec/elasticsearch/api/actions/percolate_spec.rb +0 -67
  372. data/spec/elasticsearch/api/actions/put_template_spec.rb +0 -17
  373. data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -17
  374. data/spec/elasticsearch/api/actions/search_exists_spec.rb +0 -63
  375. data/spec/elasticsearch/api/actions/suggest_spec.rb +0 -77
  376. data/test/integration/yaml_test_runner.rb +0 -546
  377. data/test/test_helper.rb +0 -42
  378. data/utils/thor/generate_api.rb +0 -189
  379. data/utils/thor/templates/ruby/method.erb +0 -60
@@ -1,3 +1,20 @@
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
+
1
18
  require 'spec_helper'
2
19
 
3
20
  describe 'client#update_by_query' do
@@ -6,8 +23,9 @@ describe 'client#update_by_query' do
6
23
  [
7
24
  'POST',
8
25
  'foo/_update_by_query',
9
- { },
10
- nil
26
+ {},
27
+ nil,
28
+ {}
11
29
  ]
12
30
  end
13
31
 
@@ -1,3 +1,20 @@
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
+
1
18
  require 'spec_helper'
2
19
 
3
20
  describe 'client#update' do
@@ -7,7 +24,8 @@ describe 'client#update' do
7
24
  'POST',
8
25
  url,
9
26
  params,
10
- body
27
+ body,
28
+ {}
11
29
  ]
12
30
  end
13
31
 
@@ -33,12 +51,6 @@ describe 'client#update' do
33
51
  }.to raise_exception(ArgumentError)
34
52
  end
35
53
 
36
- it 'requires the :type argument' do
37
- expect {
38
- client.update(index: 'foo', id: '1')
39
- }.to raise_exception(ArgumentError)
40
- end
41
-
42
54
  it 'requires the :id argument' do
43
55
  expect {
44
56
  client.update(index: 'foo', type: 'bar')
@@ -55,16 +67,12 @@ describe 'client#update' do
55
67
  'foo/bar/1/_update'
56
68
  end
57
69
 
58
- let(:params) do
59
- { version: 100 }
60
- end
61
-
62
70
  let(:body) do
63
71
  {}
64
72
  end
65
73
 
66
74
  it 'performs the request' do
67
- expect(client_double.update(index: 'foo', type: 'bar', id: '1', version: 100, body: {}))
75
+ expect(client_double.update(index: 'foo', type: 'bar', id: '1', body: {}))
68
76
  end
69
77
  end
70
78
 
@@ -100,14 +108,14 @@ describe 'client#update' do
100
108
 
101
109
  it 'raises it to the user' do
102
110
  expect {
103
- client.update(index: 'foo', type: 'bar', id: 'XXX')
111
+ client.update(index: 'foo', type: 'bar', id: 'XXX', body: {})
104
112
  }.to raise_exception(NotFound)
105
113
  end
106
114
 
107
115
  context 'when the :ignore parameter is specified' do
108
116
 
109
117
  it 'does not raise the error to the user' do
110
- expect(client.update(index: 'foo', type: 'bar', id: 'XXX', ignore: 404)).to eq(false)
118
+ expect(client.update(index: 'foo', type: 'bar', id: 'XXX', body: {}, ignore: 404)).to eq(false)
111
119
  end
112
120
  end
113
121
  end
@@ -1,3 +1,20 @@
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
+
1
18
  require 'spec_helper'
2
19
 
3
20
  describe Elasticsearch::API do
@@ -1,3 +1,20 @@
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
+
1
18
  require 'spec_helper'
2
19
 
3
20
  describe 'API Client' do
@@ -0,0 +1,138 @@
1
+ # Licensed to Elasticsearch B.V under one or more agreements.
2
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ # See the LICENSE file in the project root for more information
4
+ #
5
+ require 'spec_helper'
6
+ require 'rest_yaml_tests_helper'
7
+
8
+ describe 'Rest API YAML tests' do
9
+ # Traverse YAML files and create TestFile object:
10
+ REST_API_YAML_FILES.each do |file|
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
18
+
19
+ context "#{file.gsub("#{YAML_FILES_DIRECTORY}/", '')}" do
20
+ test_file.tests.each do |test|
21
+ context "#{test.description}" do
22
+ if test.skip_test?(ADMIN_CLIENT)
23
+ skip 'Test contains feature(s) not yet supported or version is not satisfied'
24
+ else
25
+ let(:client) do
26
+ DEFAULT_CLIENT
27
+ end
28
+
29
+ # Runs once before each test in a test file
30
+ before(:all) do
31
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
32
+ test_file.setup
33
+ end
34
+
35
+ after(:all) do
36
+ test_file.teardown
37
+ Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
38
+ end
39
+
40
+ test.task_groups.each do |task_group|
41
+ before do
42
+ task_group.run(client)
43
+ end
44
+
45
+ # 'catch' is in the task group definition
46
+ if task_group.catch_exception?
47
+ it 'sends the request and throws the expected error' do
48
+ expect(task_group.exception).to match_error(task_group.expected_exception_message)
49
+ end
50
+
51
+ # 'match' on error description is in the task group definition
52
+ if task_group.has_match_clauses?
53
+ task_group.match_clauses.each do |match|
54
+ it 'contains the expected error in the request response' do
55
+ expect(task_group.exception.message).to match(Regexp.new(Regexp.escape(match['match'].values.first.to_s)))
56
+ end
57
+ end
58
+ end
59
+ else
60
+ # 'match' is in the task group definition
61
+ if task_group.has_match_clauses?
62
+ task_group.match_clauses.each do |match|
63
+ it "has the expected value (#{match['match'].values.join(',')}) in the response field (#{match['match'].keys.join(',')})" do
64
+ expect(task_group.response).to match_response(match['match'], test)
65
+ end
66
+ end
67
+ end
68
+
69
+ # 'length' is in the task group definition
70
+ if task_group.has_length_match_clauses?
71
+ task_group.length_match_clauses.each do |match|
72
+ it "the '#{match['length'].keys.join(',')}' field have the expected length" do
73
+ expect(task_group.response).to match_response_field_length(match['length'], test)
74
+ end
75
+ end
76
+ end
77
+
78
+ # 'is_true' is in the task group definition
79
+ if task_group.has_true_clauses?
80
+ task_group.true_clauses.each do |match|
81
+ it "sends the request and the '#{match['is_true']}' field is set to true" do
82
+ expect(task_group.response).to match_true_field(match['is_true'], test)
83
+ end
84
+ end
85
+ end
86
+
87
+ # 'is_false' is in the task group definition
88
+ if task_group.has_false_clauses?
89
+ task_group.false_clauses.each do |match|
90
+ it "sends the request and the '#{match['is_false']}' field is set to true" do
91
+ expect(task_group.response).to match_false_field(match['is_false'], test)
92
+ end
93
+ end
94
+ end
95
+
96
+ # 'gte' is in the task group definition
97
+ if task_group.has_gte_clauses?
98
+ task_group.gte_clauses.each do |match|
99
+ it "sends the request and the '#{match['gte']}' field is greater than or equal to the expected value" do
100
+ expect(task_group.response).to match_gte_field(match['gte'], test)
101
+ end
102
+ end
103
+ end
104
+
105
+ # 'gt' is in the task group definition
106
+ if task_group.has_gt_clauses?
107
+ task_group.gt_clauses.each do |match|
108
+ it "sends the request and the '#{match['gt']}' field is greater than the expected value" do
109
+ expect(task_group.response).to match_gt_field(match['gt'], test)
110
+ end
111
+ end
112
+ end
113
+
114
+ # 'lte' is in the task group definition
115
+ if task_group.has_lte_clauses?
116
+ task_group.lte_clauses.each do |match|
117
+ it "sends the request and the '#{match['lte']}' field is less than or equal to the expected value" do
118
+ expect(task_group.response).to match_lte_field(match['lte'], test)
119
+ end
120
+ end
121
+ end
122
+
123
+ # 'lt' is in the task group definition
124
+ if task_group.has_lt_clauses?
125
+ task_group.lt_clauses.each do |match|
126
+ it "sends the request and the '#{match['lt']}' field is less than the expected value" do
127
+ expect(task_group.response).to match_lt_field(match['lt'], test)
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -1,3 +1,20 @@
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
+
1
18
  require 'spec_helper'
2
19
 
3
20
  describe Elasticsearch::API::Utils do
@@ -27,7 +44,7 @@ describe Elasticsearch::API::Utils do
27
44
  expect(utils.__escape('foo bar')).to eq('foo+bar')
28
45
  end
29
46
 
30
- it 'uses the escape_utils gem when available', unless: JRUBY do
47
+ it 'uses the escape_utils gem when available', unless: defined?(JRUBY_VERSION) do
31
48
  require 'escape_utils'
32
49
  expect(CGI).not_to receive(:escape)
33
50
  expect(EscapeUtils).to receive(:escape_url).and_call_original
@@ -0,0 +1,107 @@
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 "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/test_file"
19
+ require "#{File.expand_path(File.dirname('..'), '..')}/api-spec-testing/rspec_matchers"
20
+ include Elasticsearch::RestAPIYAMLTests
21
+
22
+ TRANSPORT_OPTIONS = {}
23
+ PROJECT_PATH = File.join(File.dirname(__FILE__), '..', '..')
24
+
25
+ if hosts = ELASTICSEARCH_URL
26
+ split_hosts = hosts.split(',').map do |host|
27
+ /(http\:\/\/)?\S+/.match(host)
28
+ end
29
+ uri = URI.parse(split_hosts.first[0])
30
+ TEST_HOST = uri.host
31
+ TEST_PORT = uri.port
32
+ else
33
+ TEST_HOST, TEST_PORT = 'localhost', '9200'
34
+ end
35
+
36
+ if defined?(TEST_HOST) && defined?(TEST_PORT)
37
+ URL = "http://#{TEST_HOST}:#{TEST_PORT}"
38
+
39
+ ADMIN_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
40
+
41
+ if ENV['QUIET'] == 'true'
42
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL, transport_options: TRANSPORT_OPTIONS)
43
+ else
44
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: URL,
45
+ transport_options: TRANSPORT_OPTIONS,
46
+ tracer: Logger.new($stdout))
47
+ end
48
+ end
49
+
50
+
51
+ YAML_FILES_DIRECTORY = "#{File.expand_path(File.dirname('..'), '..')}" +
52
+ "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test"
53
+
54
+ SINGLE_TEST = if ENV['SINGLE_TEST'] && !ENV['SINGLE_TEST'].empty?
55
+ ["#{File.expand_path(File.dirname('..'), '..')}" +
56
+ "/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/#{ENV['SINGLE_TEST']}"]
57
+ end
58
+
59
+ skipped_tests = []
60
+
61
+ # Response from Elasticsearch is just a String, so it's not possible to compare using headers.
62
+ skipped_tests << { file: 'cat.aliases/20_headers.yml',
63
+ description: 'Simple alias with yaml body through Accept header' }
64
+
65
+ # Check version skip logic
66
+ skipped_tests << { file: 'create/15_without_id.yml',
67
+ description: 'Create without ID' }
68
+
69
+ # No error is raised
70
+ skipped_tests << { file: 'create/15_without_id_with_types.yml',
71
+ description: 'Create without ID' }
72
+
73
+ # Error message doesn't match
74
+ skipped_tests << { file: 'tasks.get/10_basic.yml',
75
+ description: 'get task test' }
76
+
77
+ # No error is raised
78
+ skipped_tests << { file: 'cat.allocation/10_basic.yml',
79
+ description: '*' }
80
+
81
+ # Figure out how to match response when there is an error
82
+ skipped_tests << { file: 'delete/70_mix_typeless_typeful.yml',
83
+ description: '*' }
84
+
85
+ # Figure out how to match response when there is an error
86
+ skipped_tests << { file: 'cat.templates/10_basic.yml',
87
+ description: '*' }
88
+
89
+ # node_selector is not supported yet
90
+ skipped_tests << { file: 'cat.aliases/10_basic.yml',
91
+ description: '*' }
92
+
93
+ # Responses are there but not equal (eg.: yellow status)
94
+ skipped_tests << { file: 'cluster.health/10_basic.yml',
95
+ description: 'cluster health with closed index (pre 7.2.0)' }
96
+
97
+ # Regular expression not catching exact match:
98
+ skipped_tests << { file: 'cat.indices/10_basic.yml',
99
+ description: 'Test cat indices output for closed index (pre 7.2.0)' }
100
+
101
+ SKIPPED_TESTS = skipped_tests
102
+
103
+ # The directory of rest api YAML files.
104
+ REST_API_YAML_FILES = SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
105
+
106
+ # The features to skip
107
+ REST_API_YAML_SKIP_FEATURES = ['warnings'].freeze
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,44 @@
1
- require 'pry-nav'
2
- require 'elasticsearch-transport'
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
+ if defined?(JRUBY_VERSION)
19
+ require 'pry-nav'
20
+ else
21
+ require 'pry-byebug'
22
+ end
23
+ require 'ansi'
24
+ require 'elasticsearch'
3
25
  require 'elasticsearch-api'
4
-
5
- require 'jbuilder' if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
26
+ require 'elasticsearch-transport'
27
+ require 'jbuilder'
6
28
  require 'jsonify'
29
+ require 'yaml'
7
30
 
8
- require 'ansi'
9
31
  tracer = ::Logger.new(STDERR)
10
32
  tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" }
11
33
 
12
- RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
13
- JRUBY = defined?(JRUBY_VERSION)
14
-
15
34
  unless defined?(ELASTICSEARCH_URL)
16
- ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || ENV['TEST_ES_SERVER'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
35
+ ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] ||
36
+ ENV['TEST_ES_SERVER'] ||
37
+ "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
17
38
  end
18
39
 
19
- DEFAULT_CLIENT = Elasticsearch::Client.new host: ELASTICSEARCH_URL,
20
- tracer: (ENV['QUIET'] ? nil : tracer)
40
+ DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
41
+ tracer: (tracer unless ENV['QUIET']))
21
42
 
22
43
  module HelperModule
23
44
  def self.included(context)
@@ -44,29 +65,7 @@ RSpec.configure do |config|
44
65
  config.include(HelperModule)
45
66
  config.formatter = 'documentation'
46
67
  config.color = true
47
- end
48
-
49
- if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
50
- require 'simplecov'
51
- SimpleCov.start { add_filter "/test|test_/" }
52
- end
53
-
54
- if ENV['CI'] && !RUBY_1_8
55
- require 'simplecov'
56
- require 'simplecov-rcov'
57
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
58
- SimpleCov.start { add_filter "/test|test_" }
59
- end
60
-
61
-
62
- unless ENV["NOTURN"] || RUBY_1_8
63
- require 'turn'
64
-
65
- if ENV['QUIET']
66
- Turn.config.format = :outline
67
- Turn.config.trace = 1
68
- end
68
+ config.add_formatter('RspecJunitFormatter', 'tmp/elasticsearch-api-junit.xml')
69
69
  end
70
70
 
71
71
  class NotFound < StandardError; end
72
-
data/utils/Gemfile CHANGED
@@ -1,3 +1,20 @@
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
+
1
18
  source 'https://rubygems.org'
2
19
 
3
20
  gem 'activesupport'
@@ -7,3 +24,4 @@ gem 'multi_json'
7
24
  gem 'thor'
8
25
  gem 'json'
9
26
  gem 'pry'
27
+ gem 'rubocop'
data/utils/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Utils
2
+
3
+ ## The Generator
4
+
5
+ This directory hosts The Generator, a tool that generates the classes for each API endpoint from the [Elasticsearch REST API JSON Specification](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec).
6
+
7
+ ### Generate
8
+
9
+ To generate the code, you need to run (from this folder):
10
+ ```bash
11
+ $ thor api:code:generate
12
+ ```
13
+
14
+ - The oss Ruby code will be generated in `elasticsearch-api/lib/elasticsearch/api/actions`.
15
+ - The xpack Ruby code will be generated in `elasticsearch-xpack/lib/elasticsearch/xpack/api/actions`.
16
+ - The generator runs Rubocop to autolint and clean up the generated files.
17
+
18
+ Alternatively, you can pass in `oss` or `xpack` as parameters to generate only one of the 2 sets of endpoints:
19
+
20
+ ```bash
21
+ $ thor api:code:generate --api=xpack
22
+ $ thor api:code:generate --api=oss
23
+ ```
24
+
25
+ ### Development
26
+
27
+ The main entry point is `generate_source.rb`, which contains a class that implements a Thor task: `generate`:
28
+
29
+ ```
30
+ $ thor api:code:generate
31
+ ```
32
+
33
+ It uses [Thor::Actions](https://github.com/erikhuda/thor/wiki/Actions)' `template` method and `templates/method.erb` to generate the final code. The `generator` directory contains some helpers used to generate the code. The ERB template is split into partials and you can find all ERB files in the `templates` directory.
34
+
35
+ There's also a lister task:
36
+
37
+ ```
38
+ $ thor api:list
39
+ ```
40
+
41
+ It's implemented in `lister.rb` and it lists all the REST API endpoints from the JSON specification.
data/utils/Thorfile CHANGED
@@ -1,3 +1,6 @@
1
- require File.expand_path('./thor/generate_api')
1
+ # Licensed to Elasticsearch B.V under one or more agreements.
2
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ # See the LICENSE file in the project root for more information
4
+
2
5
  require File.expand_path('./thor/generate_source')
3
6
  require File.expand_path('./thor/lister')
@@ -0,0 +1,2 @@
1
+ Layout/EndAlignment:
2
+ AutoCorrect: true