opensearch-ruby 3.4.0 → 4.0.0.pre.beta.2

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 (477) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/opensearch/api/actions/asynchronous_search/delete.rb +36 -0
  4. data/lib/opensearch/api/actions/asynchronous_search/get.rb +36 -0
  5. data/lib/opensearch/api/actions/asynchronous_search/search.rb +43 -0
  6. data/lib/opensearch/api/actions/asynchronous_search/stats.rb +31 -0
  7. data/lib/opensearch/api/actions/bulk.rb +48 -79
  8. data/lib/opensearch/api/actions/bulk_stream.rb +64 -0
  9. data/lib/opensearch/api/actions/cat/aliases.rb +27 -55
  10. data/lib/opensearch/api/actions/cat/all_pit_segments.rb +23 -22
  11. data/lib/opensearch/api/actions/cat/allocation.rb +29 -57
  12. data/lib/opensearch/api/actions/cat/cluster_manager.rb +27 -31
  13. data/lib/opensearch/api/actions/cat/count.rb +23 -51
  14. data/lib/opensearch/api/actions/cat/fielddata.rb +25 -53
  15. data/lib/opensearch/api/actions/cat/health.rb +22 -46
  16. data/lib/opensearch/api/actions/cat/help.rb +13 -43
  17. data/lib/opensearch/api/actions/cat/indices.rb +37 -65
  18. data/lib/opensearch/api/actions/cat/master.rb +27 -50
  19. data/lib/opensearch/api/actions/cat/nodeattrs.rb +26 -49
  20. data/lib/opensearch/api/actions/cat/nodes.rb +30 -56
  21. data/lib/opensearch/api/actions/cat/pending_tasks.rb +28 -52
  22. data/lib/opensearch/api/actions/cat/pit_segments.rb +24 -25
  23. data/lib/opensearch/api/actions/cat/plugins.rb +27 -52
  24. data/lib/opensearch/api/actions/cat/recovery.rb +28 -57
  25. data/lib/opensearch/api/actions/cat/repositories.rb +27 -50
  26. data/lib/opensearch/api/actions/cat/segment_replication.rb +70 -0
  27. data/lib/opensearch/api/actions/cat/segments.rb +28 -51
  28. data/lib/opensearch/api/actions/cat/shards.rb +31 -59
  29. data/lib/opensearch/api/actions/cat/snapshots.rb +31 -56
  30. data/lib/opensearch/api/actions/cat/tasks.rb +29 -52
  31. data/lib/opensearch/api/actions/cat/templates.rb +29 -56
  32. data/lib/opensearch/api/actions/cat/thread_pool.rb +31 -59
  33. data/lib/opensearch/api/actions/clear_scroll.rb +21 -48
  34. data/lib/opensearch/api/actions/cluster/allocation_explain.rb +20 -48
  35. data/lib/opensearch/api/actions/cluster/delete_component_template.rb +24 -47
  36. data/lib/opensearch/api/actions/cluster/delete_decommission_awareness.rb +31 -0
  37. data/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb +18 -41
  38. data/lib/opensearch/api/actions/cluster/delete_weighted_routing.rb +32 -0
  39. data/lib/opensearch/api/actions/cluster/exists_component_template.rb +26 -51
  40. data/lib/opensearch/api/actions/cluster/get_component_template.rb +24 -49
  41. data/lib/opensearch/api/actions/cluster/get_decommission_awareness.rb +36 -0
  42. data/lib/opensearch/api/actions/cluster/get_settings.rb +22 -45
  43. data/lib/opensearch/api/actions/cluster/get_weighted_routing.rb +36 -0
  44. data/lib/opensearch/api/actions/cluster/health.rb +34 -59
  45. data/lib/opensearch/api/actions/cluster/pending_tasks.rb +21 -44
  46. data/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb +19 -42
  47. data/lib/opensearch/api/actions/cluster/put_component_template.rb +27 -50
  48. data/lib/opensearch/api/actions/cluster/put_decommission_awareness.rb +39 -0
  49. data/lib/opensearch/api/actions/cluster/put_settings.rb +22 -45
  50. data/lib/opensearch/api/actions/cluster/put_weighted_routing.rb +37 -0
  51. data/lib/opensearch/api/actions/cluster/remote_info.rb +13 -33
  52. data/lib/opensearch/api/actions/cluster/reroute.rb +26 -49
  53. data/lib/opensearch/api/actions/cluster/state.rb +34 -64
  54. data/lib/opensearch/api/actions/cluster/stats.rb +24 -47
  55. data/lib/opensearch/api/actions/count.rb +51 -81
  56. data/lib/opensearch/api/actions/create.rb +46 -47
  57. data/lib/opensearch/api/actions/create_pit.rb +34 -30
  58. data/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb +26 -48
  59. data/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb +26 -47
  60. data/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb +14 -34
  61. data/lib/opensearch/api/actions/delete.rb +45 -76
  62. data/lib/opensearch/api/actions/delete_all_pits.rb +18 -13
  63. data/lib/opensearch/api/actions/delete_by_query.rb +91 -117
  64. data/lib/opensearch/api/actions/delete_by_query_rethrottle.rb +25 -46
  65. data/lib/opensearch/api/actions/delete_pit.rb +19 -17
  66. data/lib/opensearch/api/actions/delete_script.rb +29 -50
  67. data/lib/opensearch/api/actions/exists.rb +49 -81
  68. data/lib/opensearch/api/actions/exists_source.rb +48 -77
  69. data/lib/opensearch/api/actions/explain.rb +51 -83
  70. data/lib/opensearch/api/actions/field_caps.rb +33 -63
  71. data/lib/opensearch/api/actions/flow_framework/create.rb +45 -0
  72. data/lib/opensearch/api/actions/flow_framework/delete.rb +41 -0
  73. data/lib/opensearch/api/actions/flow_framework/deprovision.rb +41 -0
  74. data/lib/opensearch/api/actions/flow_framework/get.rb +36 -0
  75. data/lib/opensearch/api/actions/flow_framework/get_status.rb +41 -0
  76. data/lib/opensearch/api/actions/flow_framework/get_steps.rb +36 -0
  77. data/lib/opensearch/api/actions/flow_framework/provision.rb +37 -0
  78. data/lib/opensearch/api/actions/flow_framework/search.rb +34 -0
  79. data/lib/opensearch/api/actions/flow_framework/search_state.rb +34 -0
  80. data/lib/opensearch/api/actions/flow_framework/update.rb +50 -0
  81. data/lib/opensearch/api/actions/get.rb +49 -80
  82. data/lib/opensearch/api/actions/get_all_pits.rb +18 -13
  83. data/lib/opensearch/api/actions/get_script.rb +27 -48
  84. data/lib/opensearch/api/actions/get_script_context.rb +18 -40
  85. data/lib/opensearch/api/actions/get_script_languages.rb +18 -40
  86. data/lib/opensearch/api/actions/get_source.rb +48 -75
  87. data/lib/opensearch/api/actions/index.rb +49 -80
  88. data/lib/opensearch/api/actions/indices/add_block.rb +34 -58
  89. data/lib/opensearch/api/actions/indices/analyze.rb +16 -52
  90. data/lib/opensearch/api/actions/indices/clear_cache.rb +30 -56
  91. data/lib/opensearch/api/actions/indices/clone.rb +36 -56
  92. data/lib/opensearch/api/actions/indices/close.rb +29 -52
  93. data/lib/opensearch/api/actions/indices/create.rb +26 -49
  94. data/lib/opensearch/api/actions/indices/create_data_stream.rb +37 -0
  95. data/lib/opensearch/api/actions/indices/data_streams_stats.rb +34 -0
  96. data/lib/opensearch/api/actions/indices/delete.rb +28 -55
  97. data/lib/opensearch/api/actions/indices/delete_alias.rb +29 -53
  98. data/lib/opensearch/api/actions/indices/delete_data_stream.rb +36 -0
  99. data/lib/opensearch/api/actions/indices/delete_index_template.rb +23 -46
  100. data/lib/opensearch/api/actions/indices/delete_template.rb +23 -50
  101. data/lib/opensearch/api/actions/indices/exists.rb +31 -57
  102. data/lib/opensearch/api/actions/indices/exists_alias.rb +28 -61
  103. data/lib/opensearch/api/actions/indices/exists_index_template.rb +27 -52
  104. data/lib/opensearch/api/actions/indices/exists_template.rb +27 -55
  105. data/lib/opensearch/api/actions/indices/flush.rb +26 -53
  106. data/lib/opensearch/api/actions/indices/forcemerge.rb +30 -53
  107. data/lib/opensearch/api/actions/indices/get.rb +30 -53
  108. data/lib/opensearch/api/actions/indices/get_alias.rb +24 -56
  109. data/lib/opensearch/api/actions/indices/get_data_stream.rb +34 -0
  110. data/lib/opensearch/api/actions/indices/get_field_mapping.rb +27 -59
  111. data/lib/opensearch/api/actions/indices/get_index_template.rb +23 -50
  112. data/lib/opensearch/api/actions/indices/get_mapping.rb +27 -59
  113. data/lib/opensearch/api/actions/indices/get_settings.rb +32 -64
  114. data/lib/opensearch/api/actions/indices/get_template.rb +23 -50
  115. data/lib/opensearch/api/actions/indices/get_upgrade.rb +22 -54
  116. data/lib/opensearch/api/actions/indices/open.rb +33 -52
  117. data/lib/opensearch/api/actions/indices/put_alias.rb +27 -54
  118. data/lib/opensearch/api/actions/indices/put_index_template.rb +26 -49
  119. data/lib/opensearch/api/actions/indices/put_mapping.rb +31 -58
  120. data/lib/opensearch/api/actions/indices/put_settings.rb +32 -59
  121. data/lib/opensearch/api/actions/indices/put_template.rb +26 -49
  122. data/lib/opensearch/api/actions/indices/recovery.rb +20 -47
  123. data/lib/opensearch/api/actions/indices/refresh.rb +22 -49
  124. data/lib/opensearch/api/actions/indices/resolve_index.rb +21 -48
  125. data/lib/opensearch/api/actions/indices/rollover.rb +31 -59
  126. data/lib/opensearch/api/actions/indices/segments.rb +22 -49
  127. data/lib/opensearch/api/actions/indices/shard_stores.rb +24 -51
  128. data/lib/opensearch/api/actions/indices/shrink.rb +36 -56
  129. data/lib/opensearch/api/actions/indices/simulate_index_template.rb +23 -50
  130. data/lib/opensearch/api/actions/indices/simulate_template.rb +25 -52
  131. data/lib/opensearch/api/actions/indices/split.rb +36 -56
  132. data/lib/opensearch/api/actions/indices/stats.rb +31 -74
  133. data/lib/opensearch/api/actions/indices/update_aliases.rb +22 -45
  134. data/lib/opensearch/api/actions/indices/upgrade.rb +24 -56
  135. data/lib/opensearch/api/actions/indices/validate_query.rb +36 -73
  136. data/lib/opensearch/api/actions/info.rb +18 -36
  137. data/lib/opensearch/api/actions/ingest/delete_pipeline.rb +22 -45
  138. data/lib/opensearch/api/actions/ingest/get_pipeline.rb +20 -49
  139. data/lib/opensearch/api/actions/ingest/processor_grok.rb +18 -33
  140. data/lib/opensearch/api/actions/ingest/put_pipeline.rb +24 -47
  141. data/lib/opensearch/api/actions/ingest/simulate.rb +21 -48
  142. data/lib/opensearch/api/actions/insights/top_queries.rb +38 -0
  143. data/lib/opensearch/api/actions/ism/add_policy.rb +37 -0
  144. data/lib/opensearch/api/actions/ism/change_policy.rb +37 -0
  145. data/lib/opensearch/api/actions/ism/delete_policy.rb +36 -0
  146. data/lib/opensearch/api/actions/ism/exists_policy.rb +36 -0
  147. data/lib/opensearch/api/actions/ism/explain_policy.rb +35 -0
  148. data/lib/opensearch/api/actions/ism/get_policies.rb +31 -0
  149. data/lib/opensearch/api/actions/ism/get_policy.rb +36 -0
  150. data/lib/opensearch/api/actions/ism/put_policies.rb +43 -0
  151. data/lib/opensearch/api/actions/ism/put_policy.rb +44 -0
  152. data/lib/opensearch/api/actions/ism/refresh_search_analyzers.rb +36 -0
  153. data/lib/opensearch/api/actions/ism/remove_policy.rb +36 -0
  154. data/lib/opensearch/api/actions/ism/retry_index.rb +37 -0
  155. data/lib/opensearch/api/actions/knn/delete_model.rb +36 -0
  156. data/lib/opensearch/api/actions/knn/get_model.rb +36 -0
  157. data/lib/opensearch/api/actions/knn/search_models.rb +119 -0
  158. data/lib/opensearch/api/actions/knn/stats.rb +41 -0
  159. data/lib/opensearch/api/actions/knn/train_model.rb +40 -0
  160. data/lib/opensearch/api/actions/knn/warmup.rb +36 -0
  161. data/lib/opensearch/api/actions/list/help.rb +31 -0
  162. data/lib/opensearch/api/actions/list/indices.rb +71 -0
  163. data/lib/opensearch/api/actions/list/shards.rb +63 -0
  164. data/lib/opensearch/api/actions/mget.rb +40 -70
  165. data/lib/opensearch/api/actions/ml/chunk_model.rb +40 -0
  166. data/lib/opensearch/api/actions/ml/create_connector.rb +32 -0
  167. data/lib/opensearch/api/actions/ml/create_controller.rb +37 -0
  168. data/lib/opensearch/api/actions/ml/create_memory.rb +32 -0
  169. data/lib/opensearch/api/actions/ml/create_message.rb +37 -0
  170. data/lib/opensearch/api/actions/ml/create_model_meta.rb +32 -0
  171. data/lib/opensearch/api/actions/ml/delete_agent.rb +36 -0
  172. data/lib/opensearch/api/actions/ml/delete_connector.rb +36 -0
  173. data/lib/opensearch/api/actions/ml/delete_controller.rb +36 -0
  174. data/lib/opensearch/api/actions/ml/delete_memory.rb +36 -0
  175. data/lib/opensearch/api/actions/ml/delete_model.rb +36 -0
  176. data/lib/opensearch/api/actions/ml/delete_model_group.rb +36 -0
  177. data/lib/opensearch/api/actions/ml/delete_task.rb +36 -0
  178. data/lib/opensearch/api/actions/ml/deploy_model.rb +36 -0
  179. data/lib/opensearch/api/actions/ml/execute_agent.rb +37 -0
  180. data/lib/opensearch/api/actions/ml/execute_algorithm.rb +37 -0
  181. data/lib/opensearch/api/actions/ml/get_agent.rb +36 -0
  182. data/lib/opensearch/api/actions/ml/get_all_memories.rb +38 -0
  183. data/lib/opensearch/api/actions/ml/get_all_messages.rb +43 -0
  184. data/lib/opensearch/api/actions/ml/get_all_tools.rb +31 -0
  185. data/lib/opensearch/api/actions/ml/get_connector.rb +36 -0
  186. data/lib/opensearch/api/actions/ml/get_controller.rb +36 -0
  187. data/lib/opensearch/api/actions/ml/get_memory.rb +36 -0
  188. data/lib/opensearch/api/actions/ml/get_message.rb +36 -0
  189. data/lib/opensearch/api/actions/ml/get_message_traces.rb +43 -0
  190. data/lib/opensearch/api/actions/ml/get_model.rb +36 -0
  191. data/lib/opensearch/api/actions/ml/get_model_group.rb +36 -0
  192. data/lib/opensearch/api/actions/ml/get_profile.rb +32 -0
  193. data/lib/opensearch/api/actions/ml/get_profile_models.rb +35 -0
  194. data/lib/opensearch/api/actions/ml/get_profile_tasks.rb +35 -0
  195. data/lib/opensearch/api/actions/ml/get_stats.rb +36 -0
  196. data/lib/opensearch/api/actions/ml/get_task.rb +36 -0
  197. data/lib/opensearch/api/actions/ml/get_tool.rb +36 -0
  198. data/lib/opensearch/api/actions/ml/load_model.rb +36 -0
  199. data/lib/opensearch/api/actions/ml/predict.rb +40 -0
  200. data/lib/opensearch/api/actions/ml/predict_model.rb +37 -0
  201. data/lib/opensearch/api/actions/ml/register_agents.rb +32 -0
  202. data/lib/opensearch/api/actions/ml/register_model.rb +32 -0
  203. data/lib/opensearch/api/actions/ml/register_model_group.rb +32 -0
  204. data/lib/opensearch/api/actions/ml/register_model_meta.rb +32 -0
  205. data/lib/opensearch/api/actions/ml/search_agents.rb +32 -0
  206. data/lib/opensearch/api/actions/ml/search_connectors.rb +32 -0
  207. data/lib/opensearch/api/actions/ml/search_memory.rb +32 -0
  208. data/lib/opensearch/api/actions/ml/search_message.rb +37 -0
  209. data/lib/opensearch/api/actions/ml/search_model_group.rb +32 -0
  210. data/lib/opensearch/api/actions/ml/search_models.rb +32 -0
  211. data/lib/opensearch/api/actions/ml/search_tasks.rb +32 -0
  212. data/lib/opensearch/api/actions/ml/train.rb +37 -0
  213. data/lib/opensearch/api/actions/ml/train_predict.rb +37 -0
  214. data/lib/opensearch/api/actions/ml/undeploy_model.rb +35 -0
  215. data/lib/opensearch/api/actions/ml/unload_model.rb +35 -0
  216. data/lib/opensearch/api/actions/ml/update_connector.rb +37 -0
  217. data/lib/opensearch/api/actions/ml/update_controller.rb +37 -0
  218. data/lib/opensearch/api/actions/ml/update_memory.rb +37 -0
  219. data/lib/opensearch/api/actions/ml/update_message.rb +37 -0
  220. data/lib/opensearch/api/actions/ml/update_model.rb +37 -0
  221. data/lib/opensearch/api/actions/ml/update_model_group.rb +37 -0
  222. data/lib/opensearch/api/actions/ml/upload_chunk.rb +40 -0
  223. data/lib/opensearch/api/actions/ml/upload_model.rb +32 -0
  224. data/lib/opensearch/api/actions/msearch.rb +40 -91
  225. data/lib/opensearch/api/actions/msearch_template.rb +36 -75
  226. data/lib/opensearch/api/actions/mtermvectors.rb +47 -87
  227. data/lib/opensearch/api/actions/nodes/hot_threads.rb +25 -57
  228. data/lib/opensearch/api/actions/nodes/info.rb +23 -53
  229. data/lib/opensearch/api/actions/nodes/reload_secure_settings.rb +20 -47
  230. data/lib/opensearch/api/actions/nodes/stats.rb +33 -72
  231. data/lib/opensearch/api/actions/nodes/usage.rb +21 -53
  232. data/lib/opensearch/api/actions/notifications/create_config.rb +34 -0
  233. data/lib/opensearch/api/actions/notifications/delete_config.rb +36 -0
  234. data/lib/opensearch/api/actions/notifications/delete_configs.rb +40 -0
  235. data/lib/opensearch/api/actions/notifications/get_config.rb +36 -0
  236. data/lib/opensearch/api/actions/notifications/get_configs.rb +115 -0
  237. data/lib/opensearch/api/actions/notifications/list_channels.rb +31 -0
  238. data/lib/opensearch/api/actions/notifications/list_features.rb +31 -0
  239. data/lib/opensearch/api/actions/notifications/send_test.rb +36 -0
  240. data/lib/opensearch/api/actions/notifications/update_config.rb +38 -0
  241. data/lib/opensearch/api/actions/observability/create_object.rb +32 -0
  242. data/lib/opensearch/api/actions/observability/delete_object.rb +36 -0
  243. data/lib/opensearch/api/actions/observability/delete_objects.rb +38 -0
  244. data/lib/opensearch/api/actions/observability/get_localstats.rb +31 -0
  245. data/lib/opensearch/api/actions/observability/get_object.rb +36 -0
  246. data/lib/opensearch/api/actions/observability/list_objects.rb +31 -0
  247. data/lib/opensearch/api/actions/observability/update_object.rb +37 -0
  248. data/lib/opensearch/api/actions/ping.rb +17 -40
  249. data/lib/opensearch/api/actions/ppl/explain.rb +41 -0
  250. data/lib/opensearch/api/actions/ppl/get_stats.rb +38 -0
  251. data/lib/opensearch/api/actions/ppl/post_stats.rb +41 -0
  252. data/lib/opensearch/api/actions/ppl/query.rb +41 -0
  253. data/lib/opensearch/api/actions/put_script.rb +37 -64
  254. data/lib/opensearch/api/actions/query/datasource_delete.rb +36 -0
  255. data/lib/opensearch/api/actions/query/datasource_retrieve.rb +36 -0
  256. data/lib/opensearch/api/actions/query/datasources_create.rb +32 -0
  257. data/lib/opensearch/api/actions/query/datasources_list.rb +31 -0
  258. data/lib/opensearch/api/actions/query/datasources_update.rb +32 -0
  259. data/lib/opensearch/api/actions/rank_eval.rb +32 -61
  260. data/lib/opensearch/api/actions/reindex.rb +42 -61
  261. data/lib/opensearch/api/actions/reindex_rethrottle.rb +25 -46
  262. data/lib/opensearch/api/actions/remote_store/restore.rb +19 -21
  263. data/lib/opensearch/api/actions/render_search_template.rb +21 -48
  264. data/lib/opensearch/api/actions/replication/autofollow_stats.rb +31 -0
  265. data/lib/opensearch/api/actions/replication/create_replication_rule.rb +34 -0
  266. data/lib/opensearch/api/actions/replication/delete_replication_rule.rb +34 -0
  267. data/lib/opensearch/api/actions/replication/follower_stats.rb +31 -0
  268. data/lib/opensearch/api/actions/replication/leader_stats.rb +31 -0
  269. data/lib/opensearch/api/actions/replication/pause.rb +38 -0
  270. data/lib/opensearch/api/actions/replication/resume.rb +38 -0
  271. data/lib/opensearch/api/actions/replication/start.rb +38 -0
  272. data/lib/opensearch/api/actions/replication/status.rb +36 -0
  273. data/lib/opensearch/api/actions/replication/stop.rb +38 -0
  274. data/lib/opensearch/api/actions/replication/update_settings.rb +38 -0
  275. data/lib/opensearch/api/actions/rollups/delete.rb +36 -0
  276. data/lib/opensearch/api/actions/rollups/explain.rb +36 -0
  277. data/lib/opensearch/api/actions/rollups/get.rb +36 -0
  278. data/lib/opensearch/api/actions/rollups/put.rb +44 -0
  279. data/lib/opensearch/api/actions/rollups/start.rb +36 -0
  280. data/lib/opensearch/api/actions/rollups/stop.rb +36 -0
  281. data/lib/opensearch/api/actions/scripts_painless_execute.rb +19 -46
  282. data/lib/opensearch/api/actions/scroll.rb +27 -63
  283. data/lib/opensearch/api/actions/search.rb +115 -146
  284. data/lib/opensearch/api/actions/search_pipeline/delete.rb +43 -0
  285. data/lib/opensearch/api/actions/search_pipeline/get.rb +39 -0
  286. data/lib/opensearch/api/actions/search_pipeline/put.rb +45 -0
  287. data/lib/opensearch/api/actions/search_shards.rb +34 -59
  288. data/lib/opensearch/api/actions/search_template.rb +50 -80
  289. data/lib/opensearch/api/actions/security/authinfo.rb +38 -0
  290. data/lib/opensearch/api/actions/security/authtoken.rb +31 -0
  291. data/lib/opensearch/api/actions/security/change_password.rb +12 -17
  292. data/lib/opensearch/api/actions/security/config_upgrade_check.rb +31 -0
  293. data/lib/opensearch/api/actions/security/config_upgrade_perform.rb +32 -0
  294. data/lib/opensearch/api/actions/security/create_action_group.rb +15 -19
  295. data/lib/opensearch/api/actions/security/create_allowlist.rb +34 -0
  296. data/lib/opensearch/api/actions/security/create_role.rb +15 -20
  297. data/lib/opensearch/api/actions/security/create_role_mapping.rb +15 -20
  298. data/lib/opensearch/api/actions/security/create_tenant.rb +15 -19
  299. data/lib/opensearch/api/actions/security/create_update_tenancy_config.rb +34 -0
  300. data/lib/opensearch/api/actions/security/create_user.rb +15 -20
  301. data/lib/opensearch/api/actions/security/create_user_legacy.rb +38 -0
  302. data/lib/opensearch/api/actions/security/delete_action_group.rb +14 -19
  303. data/lib/opensearch/api/actions/security/delete_distinguished_name.rb +36 -0
  304. data/lib/opensearch/api/actions/security/delete_role.rb +14 -19
  305. data/lib/opensearch/api/actions/security/delete_role_mapping.rb +13 -18
  306. data/lib/opensearch/api/actions/security/delete_tenant.rb +14 -19
  307. data/lib/opensearch/api/actions/security/delete_user.rb +14 -19
  308. data/lib/opensearch/api/actions/security/delete_user_legacy.rb +36 -0
  309. data/lib/opensearch/api/actions/security/flush_cache.rb +11 -16
  310. data/lib/opensearch/api/actions/security/generate_obo_token.rb +34 -0
  311. data/lib/opensearch/api/actions/security/generate_user_token.rb +36 -0
  312. data/lib/opensearch/api/actions/security/generate_user_token_legacy.rb +36 -0
  313. data/lib/opensearch/api/actions/security/get_account_details.rb +11 -16
  314. data/lib/opensearch/api/actions/security/get_action_group.rb +13 -18
  315. data/lib/opensearch/api/actions/security/get_action_groups.rb +10 -15
  316. data/lib/opensearch/api/actions/security/get_all_certificates.rb +38 -0
  317. data/lib/opensearch/api/actions/security/get_allowlist.rb +31 -0
  318. data/lib/opensearch/api/actions/security/get_audit_configuration.rb +10 -15
  319. data/lib/opensearch/api/actions/security/get_certificates.rb +11 -16
  320. data/lib/opensearch/api/actions/security/get_configuration.rb +11 -16
  321. data/lib/opensearch/api/actions/security/get_dashboards_info.rb +31 -0
  322. data/lib/opensearch/api/actions/security/get_distinguished_name.rb +41 -0
  323. data/lib/opensearch/api/actions/security/get_distinguished_names.rb +16 -19
  324. data/lib/opensearch/api/actions/security/get_node_certificates.rb +43 -0
  325. data/lib/opensearch/api/actions/security/get_permissions_info.rb +31 -0
  326. data/lib/opensearch/api/actions/security/get_role.rb +13 -18
  327. data/lib/opensearch/api/actions/security/get_role_mapping.rb +14 -19
  328. data/lib/opensearch/api/actions/security/get_role_mappings.rb +10 -15
  329. data/lib/opensearch/api/actions/security/get_roles.rb +10 -15
  330. data/lib/opensearch/api/actions/security/get_sslinfo.rb +36 -0
  331. data/lib/opensearch/api/actions/security/get_tenancy_config.rb +31 -0
  332. data/lib/opensearch/api/actions/security/get_tenant.rb +14 -19
  333. data/lib/opensearch/api/actions/security/get_tenants.rb +10 -15
  334. data/lib/opensearch/api/actions/security/get_user.rb +14 -19
  335. data/lib/opensearch/api/actions/security/get_user_legacy.rb +36 -0
  336. data/lib/opensearch/api/actions/security/get_users.rb +10 -15
  337. data/lib/opensearch/api/actions/security/get_users_legacy.rb +31 -0
  338. data/lib/opensearch/api/actions/security/health.rb +16 -16
  339. data/lib/opensearch/api/actions/security/migrate.rb +31 -0
  340. data/lib/opensearch/api/actions/security/patch_action_group.rb +16 -20
  341. data/lib/opensearch/api/actions/security/patch_action_groups.rb +14 -17
  342. data/lib/opensearch/api/actions/security/patch_allowlist.rb +34 -0
  343. data/lib/opensearch/api/actions/security/patch_audit_configuration.rb +13 -18
  344. data/lib/opensearch/api/actions/security/patch_configuration.rb +13 -18
  345. data/lib/opensearch/api/actions/security/patch_distinguished_name.rb +37 -0
  346. data/lib/opensearch/api/actions/security/patch_distinguished_names.rb +13 -18
  347. data/lib/opensearch/api/actions/security/patch_role.rb +16 -21
  348. data/lib/opensearch/api/actions/security/patch_role_mapping.rb +16 -21
  349. data/lib/opensearch/api/actions/security/patch_role_mappings.rb +13 -18
  350. data/lib/opensearch/api/actions/security/patch_roles.rb +12 -17
  351. data/lib/opensearch/api/actions/security/patch_tenant.rb +16 -21
  352. data/lib/opensearch/api/actions/security/patch_tenants.rb +13 -18
  353. data/lib/opensearch/api/actions/security/patch_user.rb +16 -21
  354. data/lib/opensearch/api/actions/security/patch_users.rb +13 -18
  355. data/lib/opensearch/api/actions/security/post_dashboards_info.rb +31 -0
  356. data/lib/opensearch/api/actions/security/reload_http_certificates.rb +11 -16
  357. data/lib/opensearch/api/actions/security/reload_transport_certificates.rb +11 -16
  358. data/lib/opensearch/api/actions/security/tenant_info.rb +31 -0
  359. data/lib/opensearch/api/actions/security/update_audit_configuration.rb +12 -17
  360. data/lib/opensearch/api/actions/security/update_configuration.rb +13 -18
  361. data/lib/opensearch/api/actions/security/update_distinguished_name.rb +37 -0
  362. data/lib/opensearch/api/actions/security/validate.rb +36 -0
  363. data/lib/opensearch/api/actions/security/who_am_i.rb +31 -0
  364. data/lib/opensearch/api/actions/security/who_am_i_protected.rb +31 -0
  365. data/lib/opensearch/api/actions/sm/create_policy.rb +37 -0
  366. data/lib/opensearch/api/actions/sm/delete_policy.rb +36 -0
  367. data/lib/opensearch/api/actions/sm/explain_policy.rb +36 -0
  368. data/lib/opensearch/api/actions/sm/get_policies.rb +44 -0
  369. data/lib/opensearch/api/actions/sm/get_policy.rb +36 -0
  370. data/lib/opensearch/api/actions/sm/start_policy.rb +36 -0
  371. data/lib/opensearch/api/actions/sm/stop_policy.rb +36 -0
  372. data/lib/opensearch/api/actions/sm/update_policy.rb +46 -0
  373. data/lib/opensearch/api/actions/snapshot/cleanup_repository.rb +22 -45
  374. data/lib/opensearch/api/actions/snapshot/clone.rb +33 -58
  375. data/lib/opensearch/api/actions/snapshot/create.rb +29 -53
  376. data/lib/opensearch/api/actions/snapshot/create_repository.rb +25 -48
  377. data/lib/opensearch/api/actions/snapshot/delete.rb +27 -55
  378. data/lib/opensearch/api/actions/snapshot/delete_repository.rb +22 -49
  379. data/lib/opensearch/api/actions/snapshot/get.rb +29 -61
  380. data/lib/opensearch/api/actions/snapshot/get_repository.rb +21 -51
  381. data/lib/opensearch/api/actions/snapshot/restore.rb +29 -53
  382. data/lib/opensearch/api/actions/snapshot/status.rb +23 -57
  383. data/lib/opensearch/api/actions/snapshot/verify_repository.rb +22 -45
  384. data/lib/opensearch/api/actions/sql/close.rb +39 -0
  385. data/lib/opensearch/api/actions/sql/explain.rb +39 -0
  386. data/lib/opensearch/api/actions/sql/get_stats.rb +38 -0
  387. data/lib/opensearch/api/actions/sql/post_stats.rb +39 -0
  388. data/lib/opensearch/api/actions/sql/query.rb +39 -0
  389. data/lib/opensearch/api/actions/sql/settings.rb +37 -0
  390. data/lib/opensearch/api/actions/tasks/cancel.rb +22 -53
  391. data/lib/opensearch/api/actions/tasks/get.rb +21 -46
  392. data/lib/opensearch/api/actions/tasks/list.rb +25 -52
  393. data/lib/opensearch/api/actions/termvectors.rb +48 -92
  394. data/lib/opensearch/api/actions/transforms/delete.rb +36 -0
  395. data/lib/opensearch/api/actions/transforms/explain.rb +36 -0
  396. data/lib/opensearch/api/actions/transforms/get.rb +36 -0
  397. data/lib/opensearch/api/actions/transforms/preview.rb +32 -0
  398. data/lib/opensearch/api/actions/transforms/put.rb +44 -0
  399. data/lib/opensearch/api/actions/transforms/search.rb +44 -0
  400. data/lib/opensearch/api/actions/transforms/start.rb +36 -0
  401. data/lib/opensearch/api/actions/transforms/stop.rb +36 -0
  402. data/lib/opensearch/api/actions/update.rb +52 -83
  403. data/lib/opensearch/api/actions/update_by_query.rb +93 -121
  404. data/lib/opensearch/api/actions/update_by_query_rethrottle.rb +25 -46
  405. data/lib/opensearch/api/actions/wlm/create_query_group.rb +34 -0
  406. data/lib/opensearch/api/actions/wlm/delete_query_group.rb +36 -0
  407. data/lib/opensearch/api/actions/wlm/get_query_group.rb +34 -0
  408. data/lib/opensearch/api/actions/wlm/update_query_group.rb +38 -0
  409. data/lib/opensearch/api/http.rb +94 -0
  410. data/lib/opensearch/api/namespace.rb +23 -0
  411. data/lib/opensearch/api/utils.rb +41 -236
  412. data/lib/opensearch/api.rb +10 -82
  413. data/lib/opensearch/dsl/search.rb +2 -2
  414. data/lib/opensearch/dsl.rb +3 -3
  415. data/lib/opensearch/transport/client.rb +30 -2
  416. data/lib/opensearch/transport/transport/base.rb +3 -8
  417. data/lib/opensearch/transport/transport/http/faraday.rb +3 -1
  418. data/lib/opensearch/version.rb +1 -1
  419. data/lib/opensearch.rb +106 -68
  420. data/opensearch-ruby.gemspec +2 -1
  421. data/spec/spec_helper.rb +3 -18
  422. data/test/transport/unit/transport_base_test.rb +0 -26
  423. data.tar.gz.sig +0 -0
  424. metadata +240 -67
  425. metadata.gz.sig +0 -0
  426. data/lib/opensearch/api/actions/abort_benchmark.rb +0 -49
  427. data/lib/opensearch/api/actions/benchmark.rb +0 -88
  428. data/lib/opensearch/api/actions/cat/params_registry.rb +0 -69
  429. data/lib/opensearch/api/actions/cluster/params_registry.rb +0 -69
  430. data/lib/opensearch/api/actions/dangling_indices/params_registry.rb +0 -69
  431. data/lib/opensearch/api/actions/features/get_features.rb +0 -61
  432. data/lib/opensearch/api/actions/features/params_registry.rb +0 -69
  433. data/lib/opensearch/api/actions/features/reset_features.rb +0 -55
  434. data/lib/opensearch/api/actions/http/connect.rb +0 -28
  435. data/lib/opensearch/api/actions/http/delete.rb +0 -28
  436. data/lib/opensearch/api/actions/http/get.rb +0 -28
  437. data/lib/opensearch/api/actions/http/head.rb +0 -28
  438. data/lib/opensearch/api/actions/http/options.rb +0 -28
  439. data/lib/opensearch/api/actions/http/patch.rb +0 -28
  440. data/lib/opensearch/api/actions/http/post.rb +0 -28
  441. data/lib/opensearch/api/actions/http/put.rb +0 -28
  442. data/lib/opensearch/api/actions/http/request.rb +0 -27
  443. data/lib/opensearch/api/actions/http/trace.rb +0 -28
  444. data/lib/opensearch/api/actions/indices/disk_usage.rb +0 -76
  445. data/lib/opensearch/api/actions/indices/field_usage_stats.rb +0 -74
  446. data/lib/opensearch/api/actions/indices/params_registry.rb +0 -69
  447. data/lib/opensearch/api/actions/ingest/geo_ip_stats.rb +0 -51
  448. data/lib/opensearch/api/actions/ingest/params_registry.rb +0 -69
  449. data/lib/opensearch/api/actions/nodes/params_registry.rb +0 -69
  450. data/lib/opensearch/api/actions/nodes/shutdown.rb +0 -65
  451. data/lib/opensearch/api/actions/params_registry.rb +0 -67
  452. data/lib/opensearch/api/actions/remote/info.rb +0 -45
  453. data/lib/opensearch/api/actions/security/delete_distinguished_names.rb +0 -41
  454. data/lib/opensearch/api/actions/security/update_distinguished_names.rb +0 -42
  455. data/lib/opensearch/api/actions/shutdown/delete_node.rb +0 -60
  456. data/lib/opensearch/api/actions/shutdown/get_node.rb +0 -62
  457. data/lib/opensearch/api/actions/shutdown/params_registry.rb +0 -69
  458. data/lib/opensearch/api/actions/shutdown/put_node.rb +0 -62
  459. data/lib/opensearch/api/actions/snapshot/get_features.rb +0 -61
  460. data/lib/opensearch/api/actions/snapshot/params_registry.rb +0 -69
  461. data/lib/opensearch/api/actions/snapshot/repository_analyze.rb +0 -84
  462. data/lib/opensearch/api/actions/tasks/params_registry.rb +0 -69
  463. data/lib/opensearch/api/namespace/cat.rb +0 -47
  464. data/lib/opensearch/api/namespace/cluster.rb +0 -47
  465. data/lib/opensearch/api/namespace/common.rb +0 -72
  466. data/lib/opensearch/api/namespace/dangling_indices.rb +0 -47
  467. data/lib/opensearch/api/namespace/features.rb +0 -47
  468. data/lib/opensearch/api/namespace/http.rb +0 -30
  469. data/lib/opensearch/api/namespace/indices.rb +0 -47
  470. data/lib/opensearch/api/namespace/ingest.rb +0 -47
  471. data/lib/opensearch/api/namespace/nodes.rb +0 -47
  472. data/lib/opensearch/api/namespace/remote.rb +0 -47
  473. data/lib/opensearch/api/namespace/remote_store.rb +0 -30
  474. data/lib/opensearch/api/namespace/security.rb +0 -30
  475. data/lib/opensearch/api/namespace/shutdown.rb +0 -47
  476. data/lib/opensearch/api/namespace/snapshot.rb +0 -47
  477. data/lib/opensearch/api/namespace/tasks.rb +0 -47
@@ -3,96 +3,56 @@
3
3
  # The OpenSearch Contributors require contributions made to
4
4
  # this file be licensed under the Apache-2.0 license or a
5
5
  # compatible open source license.
6
- #
7
- # Modifications Copyright OpenSearch Contributors. See
8
- # GitHub history for details.
9
- #
10
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
6
+
7
+ # This file is generated from the OpenSearch REST API spec.
8
+ # Do not modify it by hand. Instead, modify the generator or the spec
9
+
10
+ # frozen_string_literal: true
11
+
12
+ require 'cgi'
26
13
 
27
14
  module OpenSearch
28
15
  module API
29
- # Generic utility methods
30
- #
31
16
  module Utils
32
- # URL-escape a string
33
- #
34
- # @example
35
- # __escape('foo/bar') # => 'foo%2Fbar'
36
- # __escape('bar^bam') # => 'bar%5Ebam'
37
- #
38
- # @api private
39
- def __escape(string)
40
- return string if string == '*'
41
-
42
- CGI.escape(string.to_s)
17
+ NON_URL_ARGS = Set.new(%w[body headers]).freeze
18
+ BULK_OPERATIONS = Set.new(%w[index create delete update]).freeze
19
+
20
+ # @return a new hash with all keys converted to strings and url param values escaped
21
+ # @param [Hash] args
22
+ def self.clone_and_normalize_arguments(args)
23
+ args.each_with_object({}) do |(k, v), acc|
24
+ k = k.to_s
25
+ acc[k] = NON_URL_ARGS.include?(k) ? v : normalize_value(v)
26
+ end
43
27
  end
44
28
 
45
- # Create a "list" of values from arguments, ignoring nil values and encoding special characters.
46
- #
47
- # @example Create a list from array
48
- # __listify(['A','B']) # => 'A,B'
49
- #
50
- # @example Create a list from arguments
51
- # __listify('A','B') # => 'A,B'
52
- #
53
- # @example Escape values
54
- # __listify('foo','bar^bam') # => 'foo,bar%5Ebam'
55
- #
56
- # @example Do not escape the values
57
- # __listify('foo','bar^bam', escape: false) # => 'foo,bar^bam'
58
- #
59
- # @api private
60
- def __listify(*list)
61
- options = list.last.is_a?(Hash) ? list.pop : {}
29
+ # @param [Hash] params the query params to validate
30
+ # @param [Set<String>] valid_param_names the list of valid params names for the api method
31
+ def self.validate_query_params!(params, valid_param_names = nil)
32
+ return if OpenSearch::API.settings[:skip_parameter_validation]
33
+ params.each_key do |k|
34
+ next if valid_param_names&.include?(k)
35
+ next if GLOBAL_QUERY_PARAMS.include?(k)
36
+ raise ArgumentError, "URL parameter '#{k}' is not supported"
37
+ end
38
+ end
62
39
 
63
- escape = options[:escape]
64
- Array(list)
65
- .flat_map { |e| e.respond_to?(:split) ? e.split(',') : e }
66
- .flatten
67
- .compact
68
- .map { |e| escape == false ? e : __escape(e) }
69
- .join(',')
40
+ # @return the value escaped for URL unless it is a Hash
41
+ def self.normalize_value(value)
42
+ return value.clone if value.is_a? Hash
43
+ value = value.to_s.strip unless value.is_a? Enumerable
44
+ value = value.split(',') if value.is_a? String
45
+ value.map { |v| CGI.escape(v.to_s) }.join(',')
70
46
  end
71
47
 
72
- # Create a path (URL part) from arguments, ignoring nil values and empty strings.
73
- #
74
- # @example Create a path from array
75
- # __pathify(['foo', '', nil, 'bar']) # => 'foo/bar'
76
- #
77
- # @example Create a path from arguments
78
- # __pathify('foo', '', nil, 'bar') # => 'foo/bar'
79
- #
80
- # # @example Encode special characters
81
- # __pathify(['foo', 'bar^bam']) # => 'foo/bar%5Ebam'
82
- #
83
- # @api private
84
- def __pathify(*segments)
85
- Array(segments).flatten
86
- .compact
87
- .reject { |s| s.to_s.strip.empty? }
88
- .join('/')
89
- .squeeze('/')
48
+ def self.build_url(*parts)
49
+ parts.compact.join('/').squeeze('/')
90
50
  end
91
51
 
92
52
  # Convert an array of payloads into OpenSearch `header\ndata` format
93
53
  #
94
54
  # Supports various different formats of the payload: Array of Strings, Header/Data pairs,
95
- # or the conveniency "combined" format where data is passed along with the header
55
+ # or the convenient "combined" format where data is passed along with the header
96
56
  # in a single item.
97
57
  #
98
58
  # OpenSearch::API::Utils.__bulkify [
@@ -104,13 +64,13 @@ module OpenSearch
104
64
  # # => {"title":"Test"}
105
65
  # # => {"update":{"_index":"myindexB","_id":"2"}}
106
66
  # # => {"doc":{"title":"Update"}}
107
- #
108
- def __bulkify(payload)
109
- operations = %w[index create delete update]
67
+ # TODO: refactor this method to be more readable
68
+ def self.bulkify(payload)
69
+ return payload unless payload.is_a?(Array)
110
70
 
111
71
  # Hashes with `:data`
112
72
  if payload.any? do |d|
113
- d.is_a?(Hash) && d.values.first.is_a?(Hash) && operations.include?(d.keys.first.to_s) && (d.values.first[:data] || d.values.first['data'])
73
+ d.is_a?(Hash) && d.values.first.is_a?(Hash) && BULK_OPERATIONS.include?(d.keys.first.to_s) && (d.values.first[:data] || d.values.first['data'])
114
74
  end
115
75
  payload = payload
116
76
  .each_with_object([]) do |item, sum|
@@ -134,163 +94,8 @@ module OpenSearch
134
94
  payload << ''
135
95
  end
136
96
 
137
- payload = payload.join("\n")
138
- end
139
-
140
- # Validates the argument Hash against common and valid API parameters
141
- #
142
- # @param arguments [Hash] Hash of arguments to verify and extract, **with symbolized keys**
143
- # @param valid_params [Array<Symbol>] An array of symbols with valid keys
144
- #
145
- # @return [Hash] Return whitelisted Hash
146
- # @raise [ArgumentError] If the arguments Hash contains invalid keys
147
- #
148
- # @example Extract parameters
149
- # __validate_and_extract_params( { :foo => 'qux' }, [:foo, :bar] )
150
- # # => { :foo => 'qux' }
151
- #
152
- # @example Raise an exception for invalid parameters
153
- # __validate_and_extract_params( { :foo => 'qux', :bam => 'mux' }, [:foo, :bar] )
154
- # # ArgumentError: "URL parameter 'bam' is not supported"
155
- #
156
- # @example Skip validating parameters
157
- # __validate_and_extract_params( { :foo => 'q', :bam => 'm' }, [:foo, :bar], { skip_parameter_validation: true } )
158
- # # => { :foo => "q", :bam => "m" }
159
- #
160
- # @example Skip validating parameters when the module setting is set
161
- # OpenSearch::API.settings[:skip_parameter_validation] = true
162
- # __validate_and_extract_params( { :foo => 'q', :bam => 'm' }, [:foo, :bar] )
163
- # # => { :foo => "q", :bam => "m" }
164
- #
165
- # @api private
166
- #
167
- def __validate_and_extract_params(arguments, params = [], options = {})
168
- if options[:skip_parameter_validation] || OpenSearch::API.settings[:skip_parameter_validation]
169
- arguments
170
- else
171
- __validate_params(arguments, params)
172
- __extract_params(arguments, params, options.merge(escape: false))
173
- end
174
- end
175
-
176
- def __validate_params(arguments, valid_params = [])
177
- arguments.each do |k, _v|
178
- raise ArgumentError, "URL parameter '#{k}' is not supported" \
179
- unless COMMON_PARAMS.include?(k) || COMMON_QUERY_PARAMS.include?(k) || valid_params.include?(k)
180
- end
97
+ payload.join("\n")
181
98
  end
182
-
183
- def __extract_params(arguments, params = [], options = {})
184
- result = arguments.select { |k, _v| COMMON_QUERY_PARAMS.include?(k) || params.include?(k) }
185
- result = result.to_h unless result.is_a?(Hash) # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
186
- result.map { |k, v| v.is_a?(Array) ? [k, __listify(v, options)] : [k, v] }.to_h # Listify Arrays
187
- end
188
-
189
- # Extracts the valid parts of the URL from the arguments
190
- #
191
- # @note Mutates the `arguments` argument, to prevent failures in `__validate_and_extract_params`.
192
- #
193
- # @param arguments [Hash] Hash of arguments to verify and extract, **with symbolized keys**
194
- # @param valid_parts [Array<Symbol>] An array of symbol with valid keys
195
- #
196
- # @return [Array<String>] Valid parts of the URL as an array of strings
197
- #
198
- # @example Extract parts
199
- # __extract_parts { :foo => true }, [:foo, :bar]
200
- # # => [:foo]
201
- #
202
- #
203
- # @api private
204
- #
205
- def __extract_parts(arguments, valid_parts = [])
206
- parts = arguments.select { |k, _v| valid_parts.include?(k) }.to_h
207
- parts = parts.reduce([]) do |sum, item|
208
- k, v = item
209
- sum << (v.is_a?(TrueClass) ? k.to_s : v)
210
- end
211
-
212
- arguments.delete_if { |k, _v| valid_parts.include? k }
213
- parts
214
- end
215
-
216
- # Calls the given block, rescuing from `StandardError`.
217
- #
218
- # Primary use case is the `:ignore` parameter for API calls.
219
- #
220
- # Returns `false` if exception contains NotFound in its class name or message,
221
- # else re-raises the exception.
222
- #
223
- # @yield [block] A block of code to be executed with exception handling.
224
- #
225
- # @api private
226
- #
227
- def __rescue_from_not_found
228
- yield
229
- rescue StandardError => e
230
- raise e unless e.class.to_s =~ /NotFound/ || e.message =~ /Not\s*Found/i
231
- false
232
- end
233
-
234
- def __report_unsupported_parameters(arguments, params = [])
235
- messages = []
236
- unsupported_params = params.select do |d|
237
- d.is_a?(Hash) ? arguments.include?(d.keys.first) : arguments.include?(d)
238
- end
239
-
240
- unsupported_params.each do |param|
241
- name = case param
242
- when Symbol
243
- param
244
- when Hash
245
- param.keys.first
246
- else
247
- raise ArgumentError, 'The param must be a Symbol or a Hash'
248
- end
249
-
250
- explanation = if param.is_a?(Hash)
251
- ". #{param.values.first[:explanation]}."
252
- else
253
- ". This parameter is not supported in the version you're using: #{OpenSearch::VERSION}, and will be removed in the next release."
254
- end
255
-
256
- message = "[!] You are using unsupported parameter [:#{name}]"
257
-
258
- if (source = caller&.last)
259
- message += " in `#{source}`"
260
- end
261
-
262
- message += explanation
263
-
264
- messages << message
265
- end
266
-
267
- return if messages.empty?
268
-
269
- messages << 'Suppress this warning by the `-WO` command line flag.'
270
-
271
- if $stderr.tty?
272
- Kernel.warn messages.map { |m| "\e[31;1m#{m}\e[0m" }.join("\n")
273
- else
274
- Kernel.warn messages.join("\n")
275
- end
276
- end
277
-
278
- def __report_unsupported_method(name)
279
- message = "[!] You are using unsupported method [#{name}]"
280
- if (source = caller&.last)
281
- message += " in `#{source}`"
282
- end
283
-
284
- message += ". This method is not supported in the version you're using: #{OpenSearch::VERSION}, and will be removed in the next release. Suppress this warning by the `-WO` command line flag."
285
-
286
- if $stderr.tty?
287
- Kernel.warn "\e[31;1m#{message}\e[0m"
288
- else
289
- Kernel.warn message
290
- end
291
- end
292
-
293
- extend self
294
99
  end
295
100
  end
296
101
  end
@@ -3,100 +3,28 @@
3
3
  # The OpenSearch Contributors require contributions made to
4
4
  # this file be licensed under the Apache-2.0 license or a
5
5
  # compatible open source license.
6
- #
7
- # Modifications Copyright OpenSearch Contributors. See
8
- # GitHub history for details.
9
- #
10
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
26
6
 
27
- # This code was generated from OpenSearch API Spec.
28
- # Update the code generation logic instead of modifying this file directly.
7
+ # This file is generated from the OpenSearch REST API spec.
8
+ # Do not modify it by hand. Instead, modify the generator or the spec.
29
9
 
30
10
  # frozen_string_literal: true
31
11
 
32
- require 'opensearch/api/namespace/common'
33
- require 'opensearch/api/utils'
34
- require 'opensearch/api/actions/params_registry'
35
-
36
- Dir[File.expand_path('api/actions/**/params_registry.rb', __dir__)].sort.each { |f| require f }
37
- Dir[File.expand_path('api/actions/**/*.rb', __dir__)].sort.each { |f| require f }
38
- Dir[File.expand_path('api/namespace/**/*.rb', __dir__)].sort.each { |f| require f }
39
-
40
12
  module OpenSearch
41
13
  module API
42
- DEFAULT_SERIALIZER = MultiJson
14
+ GLOBAL_QUERY_PARAMS = Set.new([
15
+ 'pretty', # Whether to pretty format the returned JSON response.
16
+ 'human', # Whether to return human readable values for statistics.
17
+ 'error_trace', # Whether to include the stack trace of returned errors.
18
+ 'source', # The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
19
+ 'filter_path' # Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
20
+ ]).freeze
43
21
 
44
- COMMON_PARAMS = [
45
- :ignore, # Client specific parameters
46
- :index, :id, # :index/:id
47
- :body, # Request body
48
- :node_id, # Cluster
49
- :name, # Alias, template, settings, warmer, ...
50
- :field # Get field mapping
51
- ]
52
-
53
- COMMON_QUERY_PARAMS = [
54
- :ignore, # Client specific parameters
55
- :format, # Search, Cat, ...
56
- :pretty, # Pretty-print the response
57
- :human, # Return numeric values in human readable format
58
- :filter_path, # Filter the JSON response
59
- :opaque_id # Use X-Opaque-Id
60
- ]
61
-
62
- HTTP_GET = 'GET'
63
- HTTP_HEAD = 'HEAD'
64
- HTTP_PATCH = 'PATCH'
65
- HTTP_POST = 'POST'
66
- HTTP_PUT = 'PUT'
67
- HTTP_DELETE = 'DELETE'
68
-
69
- UNDERSCORE_SEARCH = '_search'
70
- UNDERSCORE_ALL = '_all'
71
- DEFAULT_DOC = '_doc'
72
-
73
- # Auto-include all namespaces in the receiver
74
- def self.included(base)
75
- base.send :include,
76
- OpenSearch::API::Common,
77
- OpenSearch::API::Actions,
78
- OpenSearch::API::Cat,
79
- OpenSearch::API::Cluster,
80
- OpenSearch::API::DanglingIndices,
81
- OpenSearch::API::Features,
82
- OpenSearch::API::Http,
83
- OpenSearch::API::Indices,
84
- OpenSearch::API::Ingest,
85
- OpenSearch::API::Nodes,
86
- OpenSearch::API::Remote,
87
- OpenSearch::API::RemoteStore,
88
- OpenSearch::API::Security,
89
- OpenSearch::API::Shutdown,
90
- OpenSearch::API::Snapshot,
91
- OpenSearch::API::Tasks
92
- end
22
+ DEFAULT_SERIALIZER = MultiJson
93
23
 
94
- # The serializer class
95
24
  def self.serializer
96
25
  settings[:serializer] || DEFAULT_SERIALIZER
97
26
  end
98
27
 
99
- # Access the module settings
100
28
  def self.settings
101
29
  @settings ||= {}
102
30
  end
@@ -51,8 +51,8 @@ module OpenSearch
51
51
  # # => {:query=>{:match=>{:title=>"test"}}}
52
52
  #
53
53
  #
54
- def search(*args, &block)
55
- Search.new(*args, &block)
54
+ def search(...)
55
+ Search.new(...)
56
56
  end
57
57
 
58
58
  extend self
@@ -36,9 +36,9 @@ require 'opensearch/dsl/search/sort'
36
36
  require 'opensearch/dsl/search/options'
37
37
  require 'opensearch/dsl/search/suggest'
38
38
 
39
- Dir[File.expand_path('dsl/search/queries/**/*.rb', __dir__)].sort.each { |f| require f }
40
- Dir[File.expand_path('dsl/search/filters/**/*.rb', __dir__)].sort.each { |f| require f }
41
- Dir[File.expand_path('dsl/search/aggregations/**/*.rb', __dir__)].sort.each { |f| require f }
39
+ Dir[File.expand_path('dsl/search/queries/**/*.rb', __dir__)].each { |f| require f }
40
+ Dir[File.expand_path('dsl/search/filters/**/*.rb', __dir__)].each { |f| require f }
41
+ Dir[File.expand_path('dsl/search/aggregations/**/*.rb', __dir__)].each { |f| require f }
42
42
 
43
43
  require 'opensearch/dsl/search'
44
44
 
@@ -101,6 +101,8 @@ module OpenSearch
101
101
  #
102
102
  # @option arguments [Boolean] :reload_on_failure Reload connections after failure (false by default)
103
103
  #
104
+ # @option arguments [Boolean] :ignore_404_on_delete Whether to ignore 404/NotFound error on http DELETE (false by default)
105
+ #
104
106
  # @option arguments [Integer] :request_timeout The request timeout to be passed to transport in options
105
107
  #
106
108
  # @option arguments [Symbol] :adapter A specific adapter for Faraday (e.g. `:patron`)
@@ -134,7 +136,7 @@ module OpenSearch
134
136
  #
135
137
  def initialize(arguments = {}, &block)
136
138
  @options = arguments.transform_keys(&:to_sym)
137
- @arguments = @options
139
+ @arguments = @options.clone
138
140
  @arguments[:logger] ||= @arguments[:log] ? DEFAULT_LOGGER.call : nil
139
141
  @arguments[:tracer] ||= @arguments[:trace] ? DEFAULT_TRACER.call : nil
140
142
  @arguments[:reload_connections] ||= false
@@ -144,6 +146,7 @@ module OpenSearch
144
146
  @arguments[:transport_options] ||= {}
145
147
  @arguments[:http] ||= {}
146
148
  @options[:http] ||= {}
149
+ @options[:ignore_404_on_delete] ||= false
147
150
 
148
151
  set_api_key if (@api_key = @arguments[:api_key])
149
152
  set_compatibility_header if ENV['ELASTIC_CLIENT_APIVERSIONING']
@@ -180,7 +183,6 @@ module OpenSearch
180
183
  end
181
184
 
182
185
  # Performs a request through delegation to {#transport}.
183
- #
184
186
  def perform_request(method, path, params = {}, body = nil, headers = nil)
185
187
  method = @send_get_body_as if method == 'GET' && body
186
188
  if (opaque_id = params.delete(:opaque_id))
@@ -191,6 +193,32 @@ module OpenSearch
191
193
  transport.perform_request(method, path, params, body, headers)
192
194
  end
193
195
 
196
+ def perform_ping_request(*args)
197
+ perform_request(*args).status == 200
198
+ rescue StandardError => e
199
+ return false if e.class.to_s =~ /NotFound|ConnectionFailed/
200
+ return false if e.message =~ /Not *Found|404|ConnectionFailed/i
201
+ raise e
202
+ end
203
+
204
+ def perform_head_request(*args)
205
+ perform_request(*args).status == 200
206
+ rescue StandardError => e
207
+ return false if e.class.to_s =~ /NotFound/
208
+ return false if e.message =~ /Not\s*Found/i
209
+ raise e
210
+ end
211
+
212
+ def perform_delete_request(*args)
213
+ perform_request(*args).body
214
+ rescue StandardError => e
215
+ if @options[:ignore_404_on_delete]
216
+ return false if e.class.to_s =~ /NotFound/
217
+ return false if e.message =~ /Not\s*Found/i
218
+ end
219
+ raise e
220
+ end
221
+
194
222
  private
195
223
 
196
224
  def set_api_key
@@ -282,8 +282,6 @@ module OpenSearch
282
282
 
283
283
  params = params.clone
284
284
 
285
- ignore = Array(params.delete(:ignore)).compact.map(&:to_i)
286
-
287
285
  begin
288
286
  tries += 1
289
287
  connection = get_connection or raise(Error, 'Cannot get new connection from pool.')
@@ -343,10 +341,9 @@ module OpenSearch
343
341
  duration
344
342
  end
345
343
 
346
- # Log the failure only when `ignore` doesn't match the response status
347
- log_fatal "[#{response.status}] #{response.body}" unless ignore.include?(response.status.to_i)
344
+ log_fatal "[#{response.status}] #{response.body}"
348
345
 
349
- __raise_transport_error response unless ignore.include?(response.status.to_i)
346
+ __raise_transport_error response
350
347
  end
351
348
 
352
349
  if response.body && !response.body.empty? && response.headers && response.headers['content-type'] =~ /json/
@@ -358,9 +355,7 @@ module OpenSearch
358
355
  'n/a'
359
356
  end
360
357
 
361
- unless ignore.include?(response.status.to_i)
362
- __log_response method, path, params, body, url, response, json, took, duration
363
- end
358
+ __log_response method, path, params, body, url, response, json, took, duration
364
359
 
365
360
  if tracer
366
361
  __trace method, path, params, connection.connection.headers, body, url, response, nil, 'N/A',
@@ -24,6 +24,8 @@
24
24
  # specific language governing permissions and limitations
25
25
  # under the License.
26
26
 
27
+ require 'opensearch/version'
28
+
27
29
  module OpenSearch
28
30
  module Transport
29
31
  module Transport
@@ -91,7 +93,7 @@ module OpenSearch
91
93
  meta << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
92
94
  end
93
95
  meta << client.headers[USER_AGENT_STR].to_s
94
- "opensearch-ruby/#{VERSION} (#{meta.join('; ')})"
96
+ "opensearch-ruby/#{OpenSearch::VERSION} (#{meta.join('; ')})"
95
97
  end
96
98
  end
97
99
  end
@@ -25,5 +25,5 @@
25
25
  # under the License.
26
26
 
27
27
  module OpenSearch
28
- VERSION = '3.4.0'.freeze
28
+ VERSION = '4.0.0-beta.2'.freeze
29
29
  end