elasticsearch-serverless 0.0.8.20231031.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +7 -0
  2. data/lib/elasticsearch-serverless/api/async_search/delete.rb +53 -0
  3. data/lib/elasticsearch-serverless/api/async_search/get.rb +56 -0
  4. data/lib/elasticsearch-serverless/api/async_search/status.rb +53 -0
  5. data/lib/elasticsearch-serverless/api/async_search/submit.rb +102 -0
  6. data/lib/elasticsearch-serverless/api/bulk.rb +72 -0
  7. data/lib/elasticsearch-serverless/api/cat/aliases.rb +64 -0
  8. data/lib/elasticsearch-serverless/api/cat/component_templates.rb +62 -0
  9. data/lib/elasticsearch-serverless/api/cat/count.rb +63 -0
  10. data/lib/elasticsearch-serverless/api/cat/help.rb +55 -0
  11. data/lib/elasticsearch-serverless/api/cat/indices.rb +69 -0
  12. data/lib/elasticsearch-serverless/api/cat/ml_data_frame_analytics.rb +67 -0
  13. data/lib/elasticsearch-serverless/api/cat/ml_datafeeds.rb +66 -0
  14. data/lib/elasticsearch-serverless/api/cat/ml_jobs.rb +67 -0
  15. data/lib/elasticsearch-serverless/api/cat/ml_trained_models.rb +68 -0
  16. data/lib/elasticsearch-serverless/api/cat/transforms.rb +68 -0
  17. data/lib/elasticsearch-serverless/api/clear_scroll.rb +67 -0
  18. data/lib/elasticsearch-serverless/api/close_point_in_time.rb +47 -0
  19. data/lib/elasticsearch-serverless/api/cluster/delete_component_template.rb +55 -0
  20. data/lib/elasticsearch-serverless/api/cluster/exists_component_template.rb +57 -0
  21. data/lib/elasticsearch-serverless/api/cluster/get_component_template.rb +59 -0
  22. data/lib/elasticsearch-serverless/api/cluster/info.rb +53 -0
  23. data/lib/elasticsearch-serverless/api/cluster/put_component_template.rb +57 -0
  24. data/lib/elasticsearch-serverless/api/count.rb +73 -0
  25. data/lib/elasticsearch-serverless/api/create.rb +51 -0
  26. data/lib/elasticsearch-serverless/api/delete.rb +71 -0
  27. data/lib/elasticsearch-serverless/api/delete_by_query.rb +82 -0
  28. data/lib/elasticsearch-serverless/api/delete_script.rb +53 -0
  29. data/lib/elasticsearch-serverless/api/enrich/delete_policy.rb +53 -0
  30. data/lib/elasticsearch-serverless/api/enrich/execute_policy.rb +54 -0
  31. data/lib/elasticsearch-serverless/api/enrich/get_policy.rb +55 -0
  32. data/lib/elasticsearch-serverless/api/enrich/put_policy.rb +55 -0
  33. data/lib/elasticsearch-serverless/api/enrich/stats.rb +48 -0
  34. data/lib/elasticsearch-serverless/api/eql/delete.rb +53 -0
  35. data/lib/elasticsearch-serverless/api/eql/get.rb +55 -0
  36. data/lib/elasticsearch-serverless/api/eql/get_status.rb +53 -0
  37. data/lib/elasticsearch-serverless/api/eql/search.rb +61 -0
  38. data/lib/elasticsearch-serverless/api/exists.rb +67 -0
  39. data/lib/elasticsearch-serverless/api/exists_source.rb +66 -0
  40. data/lib/elasticsearch-serverless/api/explain.rb +73 -0
  41. data/lib/elasticsearch-serverless/api/field_caps.rb +66 -0
  42. data/lib/elasticsearch-serverless/api/get.rb +73 -0
  43. data/lib/elasticsearch-serverless/api/get_script.rb +52 -0
  44. data/lib/elasticsearch-serverless/api/get_source.rb +65 -0
  45. data/lib/elasticsearch-serverless/api/graph/explore.rb +61 -0
  46. data/lib/elasticsearch-serverless/api/index.rb +71 -0
  47. data/lib/elasticsearch-serverless/api/indices/add_block.rb +62 -0
  48. data/lib/elasticsearch-serverless/api/indices/analyze.rb +61 -0
  49. data/lib/elasticsearch-serverless/api/indices/create.rb +57 -0
  50. data/lib/elasticsearch-serverless/api/indices/create_data_stream.rb +53 -0
  51. data/lib/elasticsearch-serverless/api/indices/data_streams_stats.rb +56 -0
  52. data/lib/elasticsearch-serverless/api/indices/delete.rb +66 -0
  53. data/lib/elasticsearch-serverless/api/indices/delete_alias.rb +61 -0
  54. data/lib/elasticsearch-serverless/api/indices/delete_data_lifecycle.rb +56 -0
  55. data/lib/elasticsearch-serverless/api/indices/delete_data_stream.rb +54 -0
  56. data/lib/elasticsearch-serverless/api/indices/delete_index_template.rb +55 -0
  57. data/lib/elasticsearch-serverless/api/indices/exists.rb +61 -0
  58. data/lib/elasticsearch-serverless/api/indices/exists_alias.rb +66 -0
  59. data/lib/elasticsearch-serverless/api/indices/exists_index_template.rb +56 -0
  60. data/lib/elasticsearch-serverless/api/indices/explain_data_lifecycle.rb +55 -0
  61. data/lib/elasticsearch-serverless/api/indices/get.rb +61 -0
  62. data/lib/elasticsearch-serverless/api/indices/get_alias.rb +66 -0
  63. data/lib/elasticsearch-serverless/api/indices/get_data_lifecycle.rb +55 -0
  64. data/lib/elasticsearch-serverless/api/indices/get_data_stream.rb +57 -0
  65. data/lib/elasticsearch-serverless/api/indices/get_index_template.rb +59 -0
  66. data/lib/elasticsearch-serverless/api/indices/get_mapping.rb +60 -0
  67. data/lib/elasticsearch-serverless/api/indices/get_settings.rb +69 -0
  68. data/lib/elasticsearch-serverless/api/indices/migrate_to_data_stream.rb +53 -0
  69. data/lib/elasticsearch-serverless/api/indices/modify_data_stream.rb +51 -0
  70. data/lib/elasticsearch-serverless/api/indices/put_alias.rb +62 -0
  71. data/lib/elasticsearch-serverless/api/indices/put_data_lifecycle.rb +57 -0
  72. data/lib/elasticsearch-serverless/api/indices/put_index_template.rb +56 -0
  73. data/lib/elasticsearch-serverless/api/indices/put_mapping.rb +61 -0
  74. data/lib/elasticsearch-serverless/api/indices/put_settings.rb +65 -0
  75. data/lib/elasticsearch-serverless/api/indices/put_template.rb +60 -0
  76. data/lib/elasticsearch-serverless/api/indices/refresh.rb +58 -0
  77. data/lib/elasticsearch-serverless/api/indices/resolve_index.rb +54 -0
  78. data/lib/elasticsearch-serverless/api/indices/rollover.rb +66 -0
  79. data/lib/elasticsearch-serverless/api/indices/simulate_index_template.rb +57 -0
  80. data/lib/elasticsearch-serverless/api/indices/simulate_template.rb +59 -0
  81. data/lib/elasticsearch-serverless/api/indices/update_aliases.rb +53 -0
  82. data/lib/elasticsearch-serverless/api/indices/validate_query.rb +73 -0
  83. data/lib/elasticsearch-serverless/api/info.rb +46 -0
  84. data/lib/elasticsearch-serverless/api/ingest/delete_pipeline.rb +55 -0
  85. data/lib/elasticsearch-serverless/api/ingest/get_pipeline.rb +57 -0
  86. data/lib/elasticsearch-serverless/api/ingest/processor_grok.rb +48 -0
  87. data/lib/elasticsearch-serverless/api/ingest/put_pipeline.rb +58 -0
  88. data/lib/elasticsearch-serverless/api/ingest/simulate.rb +59 -0
  89. data/lib/elasticsearch-serverless/api/license/get.rb +50 -0
  90. data/lib/elasticsearch-serverless/api/logstash/delete_pipeline.rb +53 -0
  91. data/lib/elasticsearch-serverless/api/logstash/get_pipeline.rb +55 -0
  92. data/lib/elasticsearch-serverless/api/logstash/put_pipeline.rb +55 -0
  93. data/lib/elasticsearch-serverless/api/machine_learning/close_job.rb +57 -0
  94. data/lib/elasticsearch-serverless/api/machine_learning/delete_calendar.rb +53 -0
  95. data/lib/elasticsearch-serverless/api/machine_learning/delete_calendar_event.rb +57 -0
  96. data/lib/elasticsearch-serverless/api/machine_learning/delete_calendar_job.rb +57 -0
  97. data/lib/elasticsearch-serverless/api/machine_learning/delete_data_frame_analytics.rb +55 -0
  98. data/lib/elasticsearch-serverless/api/machine_learning/delete_datafeed.rb +54 -0
  99. data/lib/elasticsearch-serverless/api/machine_learning/delete_filter.rb +53 -0
  100. data/lib/elasticsearch-serverless/api/machine_learning/delete_job.rb +56 -0
  101. data/lib/elasticsearch-serverless/api/machine_learning/delete_trained_model.rb +54 -0
  102. data/lib/elasticsearch-serverless/api/machine_learning/delete_trained_model_alias.rb +57 -0
  103. data/lib/elasticsearch-serverless/api/machine_learning/estimate_model_memory.rb +51 -0
  104. data/lib/elasticsearch-serverless/api/machine_learning/evaluate_data_frame.rb +51 -0
  105. data/lib/elasticsearch-serverless/api/machine_learning/flush_job.rb +59 -0
  106. data/lib/elasticsearch-serverless/api/machine_learning/get_calendar_events.rb +58 -0
  107. data/lib/elasticsearch-serverless/api/machine_learning/get_calendars.rb +63 -0
  108. data/lib/elasticsearch-serverless/api/machine_learning/get_data_frame_analytics.rb +59 -0
  109. data/lib/elasticsearch-serverless/api/machine_learning/get_data_frame_analytics_stats.rb +59 -0
  110. data/lib/elasticsearch-serverless/api/machine_learning/get_datafeed_stats.rb +56 -0
  111. data/lib/elasticsearch-serverless/api/machine_learning/get_datafeeds.rb +57 -0
  112. data/lib/elasticsearch-serverless/api/machine_learning/get_filters.rb +57 -0
  113. data/lib/elasticsearch-serverless/api/machine_learning/get_job_stats.rb +56 -0
  114. data/lib/elasticsearch-serverless/api/machine_learning/get_jobs.rb +57 -0
  115. data/lib/elasticsearch-serverless/api/machine_learning/get_overall_buckets.rb +66 -0
  116. data/lib/elasticsearch-serverless/api/machine_learning/get_trained_models.rb +62 -0
  117. data/lib/elasticsearch-serverless/api/machine_learning/get_trained_models_stats.rb +58 -0
  118. data/lib/elasticsearch-serverless/api/machine_learning/infer_trained_model.rb +63 -0
  119. data/lib/elasticsearch-serverless/api/machine_learning/open_job.rb +55 -0
  120. data/lib/elasticsearch-serverless/api/machine_learning/post_calendar_events.rb +55 -0
  121. data/lib/elasticsearch-serverless/api/machine_learning/preview_data_frame_analytics.rb +61 -0
  122. data/lib/elasticsearch-serverless/api/machine_learning/preview_datafeed.rb +63 -0
  123. data/lib/elasticsearch-serverless/api/machine_learning/put_calendar.rb +54 -0
  124. data/lib/elasticsearch-serverless/api/machine_learning/put_calendar_job.rb +57 -0
  125. data/lib/elasticsearch-serverless/api/machine_learning/put_data_frame_analytics.rb +55 -0
  126. data/lib/elasticsearch-serverless/api/machine_learning/put_datafeed.rb +59 -0
  127. data/lib/elasticsearch-serverless/api/machine_learning/put_filter.rb +55 -0
  128. data/lib/elasticsearch-serverless/api/machine_learning/put_job.rb +55 -0
  129. data/lib/elasticsearch-serverless/api/machine_learning/put_trained_model.rb +56 -0
  130. data/lib/elasticsearch-serverless/api/machine_learning/put_trained_model_alias.rb +58 -0
  131. data/lib/elasticsearch-serverless/api/machine_learning/put_trained_model_definition_part.rb +59 -0
  132. data/lib/elasticsearch-serverless/api/machine_learning/put_trained_model_vocabulary.rb +55 -0
  133. data/lib/elasticsearch-serverless/api/machine_learning/reset_job.rb +55 -0
  134. data/lib/elasticsearch-serverless/api/machine_learning/start_data_frame_analytics.rb +54 -0
  135. data/lib/elasticsearch-serverless/api/machine_learning/start_datafeed.rb +57 -0
  136. data/lib/elasticsearch-serverless/api/machine_learning/start_trained_model_deployment.rb +60 -0
  137. data/lib/elasticsearch-serverless/api/machine_learning/stop_data_frame_analytics.rb +56 -0
  138. data/lib/elasticsearch-serverless/api/machine_learning/stop_datafeed.rb +57 -0
  139. data/lib/elasticsearch-serverless/api/machine_learning/stop_trained_model_deployment.rb +55 -0
  140. data/lib/elasticsearch-serverless/api/machine_learning/update_data_frame_analytics.rb +55 -0
  141. data/lib/elasticsearch-serverless/api/machine_learning/update_datafeed.rb +59 -0
  142. data/lib/elasticsearch-serverless/api/machine_learning/update_filter.rb +55 -0
  143. data/lib/elasticsearch-serverless/api/machine_learning/update_job.rb +55 -0
  144. data/lib/elasticsearch-serverless/api/mget.rb +64 -0
  145. data/lib/elasticsearch-serverless/api/msearch.rb +91 -0
  146. data/lib/elasticsearch-serverless/api/msearch_template.rb +72 -0
  147. data/lib/elasticsearch-serverless/api/mtermvectors.rb +75 -0
  148. data/lib/elasticsearch-serverless/api/open_point_in_time.rb +56 -0
  149. data/lib/elasticsearch-serverless/api/ping.rb +52 -0
  150. data/lib/elasticsearch-serverless/api/put_script.rb +62 -0
  151. data/lib/elasticsearch-serverless/api/query_ruleset/delete.rb +57 -0
  152. data/lib/elasticsearch-serverless/api/query_ruleset/get.rb +57 -0
  153. data/lib/elasticsearch-serverless/api/query_ruleset/list.rb +54 -0
  154. data/lib/elasticsearch-serverless/api/query_ruleset/put.rb +59 -0
  155. data/lib/elasticsearch-serverless/api/rank_eval.rb +60 -0
  156. data/lib/elasticsearch-serverless/api/reindex.rb +59 -0
  157. data/lib/elasticsearch-serverless/api/render_search_template.rb +59 -0
  158. data/lib/elasticsearch-serverless/api/response.rb +48 -0
  159. data/lib/elasticsearch-serverless/api/scripts_painless_execute.rb +56 -0
  160. data/lib/elasticsearch-serverless/api/scroll.rb +66 -0
  161. data/lib/elasticsearch-serverless/api/search.rb +102 -0
  162. data/lib/elasticsearch-serverless/api/search_application/delete.rb +57 -0
  163. data/lib/elasticsearch-serverless/api/search_application/delete_behavioral_analytics.rb +57 -0
  164. data/lib/elasticsearch-serverless/api/search_application/get.rb +57 -0
  165. data/lib/elasticsearch-serverless/api/search_application/get_behavioral_analytics.rb +59 -0
  166. data/lib/elasticsearch-serverless/api/search_application/list.rb +55 -0
  167. data/lib/elasticsearch-serverless/api/search_application/put.rb +60 -0
  168. data/lib/elasticsearch-serverless/api/search_application/put_behavioral_analytics.rb +57 -0
  169. data/lib/elasticsearch-serverless/api/search_application/search.rb +63 -0
  170. data/lib/elasticsearch-serverless/api/search_mvt.rb +75 -0
  171. data/lib/elasticsearch-serverless/api/search_template.rb +69 -0
  172. data/lib/elasticsearch-serverless/api/security/authenticate.rb +48 -0
  173. data/lib/elasticsearch-serverless/api/security/create_api_key.rb +52 -0
  174. data/lib/elasticsearch-serverless/api/security/get_api_key.rb +54 -0
  175. data/lib/elasticsearch-serverless/api/security/has_privileges.rb +58 -0
  176. data/lib/elasticsearch-serverless/api/security/invalidate_api_key.rb +51 -0
  177. data/lib/elasticsearch-serverless/api/security/query_api_keys.rb +55 -0
  178. data/lib/elasticsearch-serverless/api/security/update_api_key.rb +54 -0
  179. data/lib/elasticsearch-serverless/api/sql/clear_cursor.rb +51 -0
  180. data/lib/elasticsearch-serverless/api/sql/delete_async.rb +53 -0
  181. data/lib/elasticsearch-serverless/api/sql/get_async.rb +57 -0
  182. data/lib/elasticsearch-serverless/api/sql/get_async_status.rb +53 -0
  183. data/lib/elasticsearch-serverless/api/sql/query.rb +52 -0
  184. data/lib/elasticsearch-serverless/api/sql/translate.rb +51 -0
  185. data/lib/elasticsearch-serverless/api/synonyms/delete_synonym.rb +57 -0
  186. data/lib/elasticsearch-serverless/api/synonyms/delete_synonym_rule.rb +61 -0
  187. data/lib/elasticsearch-serverless/api/synonyms/get_synonym.rb +59 -0
  188. data/lib/elasticsearch-serverless/api/synonyms/get_synonym_rule.rb +61 -0
  189. data/lib/elasticsearch-serverless/api/synonyms/get_synonyms_sets.rb +54 -0
  190. data/lib/elasticsearch-serverless/api/synonyms/put_synonym.rb +59 -0
  191. data/lib/elasticsearch-serverless/api/synonyms/put_synonym_rule.rb +63 -0
  192. data/lib/elasticsearch-serverless/api/tasks/get.rb +57 -0
  193. data/lib/elasticsearch-serverless/api/terms_enum.rb +57 -0
  194. data/lib/elasticsearch-serverless/api/termvectors.rb +82 -0
  195. data/lib/elasticsearch-serverless/api/transform/delete_transform.rb +55 -0
  196. data/lib/elasticsearch-serverless/api/transform/get_transform.rb +59 -0
  197. data/lib/elasticsearch-serverless/api/transform/get_transform_stats.rb +57 -0
  198. data/lib/elasticsearch-serverless/api/transform/preview_transform.rb +62 -0
  199. data/lib/elasticsearch-serverless/api/transform/put_transform.rb +57 -0
  200. data/lib/elasticsearch-serverless/api/transform/reset_transform.rb +54 -0
  201. data/lib/elasticsearch-serverless/api/transform/schedule_now_transform.rb +54 -0
  202. data/lib/elasticsearch-serverless/api/transform/start_transform.rb +55 -0
  203. data/lib/elasticsearch-serverless/api/transform/stop_transform.rb +58 -0
  204. data/lib/elasticsearch-serverless/api/transform/update_transform.rb +57 -0
  205. data/lib/elasticsearch-serverless/api/update.rb +77 -0
  206. data/lib/elasticsearch-serverless/api/update_by_query.rb +83 -0
  207. data/lib/elasticsearch-serverless/api/utils.rb +138 -0
  208. data/lib/elasticsearch-serverless/api.rb +98 -0
  209. data/lib/elasticsearch-serverless/version.rb +22 -0
  210. data/lib/elasticsearch-serverless.rb +105 -0
  211. metadata +321 -0
@@ -0,0 +1,77 @@
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
+ # Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19
+ # @see https://github.com/elastic/elasticsearch-specification
20
+ #
21
+ module ElasticsearchServerless
22
+ module API
23
+ module Actions
24
+ # Updates a document with a script or partial document.
25
+ #
26
+ # @option arguments [String] :id Document ID (*Required*)
27
+ # @option arguments [String] :index The name of the index (*Required*)
28
+ # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term.
29
+ # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number.
30
+ # @option arguments [String] :lang The script language. Server default: painless.
31
+ # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search, if 'wait_for' then wait for a refresh to make this operation visible to search, if 'false' do nothing with refreshes. Server default: false.
32
+ # @option arguments [Boolean] :require_alias If true, the destination must be an index alias.
33
+ # @option arguments [Integer] :retry_on_conflict Specify how many times should the operation be retried when a conflict occurs. Server default: 0.
34
+ # @option arguments [String] :routing Custom value used to route operations to a specific shard.
35
+ # @option arguments [Time] :timeout Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m.
36
+ # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard. Server default: 1.
37
+ # @option arguments [Boolean, String, Array<String>] :_source Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve. Server default: true.
38
+ # @option arguments [String, Array<String>] :_source_excludes Specify the source fields you want to exclude.
39
+ # @option arguments [String, Array<String>] :_source_includes Specify the source fields you want to retrieve.
40
+ # @option arguments [Hash] :headers Custom HTTP headers
41
+ # @option arguments [Hash] :body request body
42
+ #
43
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html
44
+ #
45
+ def update(arguments = {})
46
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
47
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
48
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
49
+
50
+ arguments = arguments.clone
51
+ headers = arguments.delete(:headers) || {}
52
+
53
+ body = arguments.delete(:body)
54
+
55
+ _id = arguments.delete(:id)
56
+
57
+ _index = arguments.delete(:index)
58
+
59
+ method = ElasticsearchServerless::API::HTTP_POST
60
+ path = "#{Utils.listify(_index)}/_update/#{Utils.listify(_id)}"
61
+ params = Utils.process_params(arguments)
62
+
63
+ if Array(arguments[:ignore]).include?(404)
64
+ Utils.rescue_from_not_found {
65
+ ElasticsearchServerless::API::Response.new(
66
+ perform_request(method, path, params, body, headers)
67
+ )
68
+ }
69
+ else
70
+ ElasticsearchServerless::API::Response.new(
71
+ perform_request(method, path, params, body, headers)
72
+ )
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,83 @@
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
+ # Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19
+ # @see https://github.com/elastic/elasticsearch-specification
20
+ #
21
+ module ElasticsearchServerless
22
+ module API
23
+ module Actions
24
+ # Performs an update on every document in the index without changing the source,
25
+ # for example to pick up a mapping change.
26
+ #
27
+ # @option arguments [String, Array] :index Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (+*+). To search all data streams or indices, omit this parameter or use +*+ or +_all+. (*Required*)
28
+ # @option arguments [Boolean] :allow_no_indices If +false+, the request returns an error if any wildcard expression, index alias, or +_all+ value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true.
29
+ # @option arguments [String] :analyzer Analyzer to use for the query string.
30
+ # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed.
31
+ # @option arguments [String] :conflicts What to do if update by query hits version conflicts: +abort+ or +proceed+. Server default: abort.
32
+ # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. Server default: OR.
33
+ # @option arguments [String] :df Field to use as default where no field prefix is given in the query string.
34
+ # @option arguments [String, Array<String>] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as +open,hidden+. Valid values are: +all+, +open+, +closed+, +hidden+, +none+.
35
+ # @option arguments [Integer] :from Starting offset (default: 0)
36
+ # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index.
37
+ # @option arguments [Boolean] :lenient If +true+, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
38
+ # @option arguments [Integer] :max_docs Maximum number of documents to process. Defaults to all documents.
39
+ # @option arguments [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to +_none+ disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter.
40
+ # @option arguments [String] :preference Specifies the node or shard the operation should be performed on. Random by default.
41
+ # @option arguments [Boolean] :refresh If +true+, Elasticsearch refreshes affected shards to make the operation visible to search.
42
+ # @option arguments [Boolean] :request_cache If +true+, the request cache is used for this request.
43
+ # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. Server default: -1.
44
+ # @option arguments [String] :routing Custom value used to route operations to a specific shard.
45
+ # @option arguments [Time] :scroll Period to retain the search context for scrolling.
46
+ # @option arguments [Integer] :scroll_size Size of the scroll request that powers the operation. Server default: 1000.
47
+ # @option arguments [Time] :search_timeout Explicit timeout for each search request.
48
+ # @option arguments [String] :search_type The type of the search operation. Available options: +query_then_fetch+, +dfs_query_then_fetch+.
49
+ # @option arguments [Integer, String] :slices The number of slices this task should be divided into. Server default: 1.
50
+ # @option arguments [Array<String>] :sort A comma-separated list of <field>:<direction> pairs.
51
+ # @option arguments [Array<String>] :stats Specific +tag+ of the request for logging and statistical purposes.
52
+ # @option arguments [Integer] :terminate_after Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.
53
+ # @option arguments [Time] :timeout Period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. Server default: 1m.
54
+ # @option arguments [Boolean] :version If +true+, returns the document version as part of a hit.
55
+ # @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex)
56
+ # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to +all+ or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). Server default: 1.
57
+ # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the operation is complete. Server default: true.
58
+ # @option arguments [Hash] :headers Custom HTTP headers
59
+ # @option arguments [Hash] :body request body
60
+ #
61
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html
62
+ #
63
+ def update_by_query(arguments = {})
64
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
65
+
66
+ arguments = arguments.clone
67
+ headers = arguments.delete(:headers) || {}
68
+
69
+ body = arguments.delete(:body)
70
+
71
+ _index = arguments.delete(:index)
72
+
73
+ method = ElasticsearchServerless::API::HTTP_POST
74
+ path = "#{Utils.listify(_index)}/_update_by_query"
75
+ params = Utils.process_params(arguments)
76
+
77
+ ElasticsearchServerless::API::Response.new(
78
+ perform_request(method, path, params, body, headers)
79
+ )
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,138 @@
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 'json'
19
+ require 'erb'
20
+
21
+ module ElasticsearchServerless
22
+ module API
23
+ module Utils
24
+ def self.process_params(arguments)
25
+ arguments = Hash[arguments] unless arguments.is_a?(Hash)
26
+ Hash[arguments.map { |k, v| v.is_a?(Array) ? [k, listify(v, { escape: false })] : [k, v] }] # Listify Arrays
27
+ end
28
+
29
+ # Convert an array of payloads into Elasticsearch `header\ndata` format
30
+ #
31
+ # Supports various different formats of the payload: Array of Strings, Header/Data pairs,
32
+ # or the conveniency "combined" format where data is passed along with the header
33
+ # in a single item.
34
+ #
35
+ # Elasticsearch::API::Utils.bulkify [
36
+ # { :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } },
37
+ # { :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } }
38
+ # ]
39
+ #
40
+ # # => {"index":{"_index":"myindexA","_type":"mytype","_id":"1"}}
41
+ # # => {"title":"Test"}
42
+ # # => {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}}
43
+ # # => {"doc":{"title":"Update"}}
44
+ #
45
+ def self.bulkify(payload)
46
+ operations = %w[index create delete update]
47
+
48
+ case
49
+ # Hashes with `:data`
50
+ when payload.any? { |d|
51
+ 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'])
52
+ }
53
+ payload = payload
54
+ .inject([]) do |sum, item|
55
+ operation, meta = item.to_a.first
56
+ meta = meta.clone
57
+ data = meta.delete(:data) || meta.delete('data')
58
+
59
+ sum << { operation => meta }
60
+ sum << data if data
61
+ sum
62
+ end.map { |item| JSON.dump(item) }
63
+ payload << '' unless payload.empty?
64
+ # Array of strings
65
+ when payload.all? { |d| d.is_a? String }
66
+ payload << ''
67
+ # Header/Data pairs
68
+ else
69
+ payload = payload.map { |item| JSON.dump(item) }
70
+ payload << ''
71
+ end
72
+
73
+ payload = payload.join("\n")
74
+ end
75
+
76
+ # Create a "list" of values from arguments, ignoring nil values and encoding special characters.
77
+ #
78
+ # @example Create a list from array
79
+ # listify(['A','B']) # => 'A,B'
80
+ #
81
+ # @example Create a list from arguments
82
+ # listify('A','B') # => 'A,B'
83
+ #
84
+ # @example Escape values
85
+ # listify('foo','bar^bam') # => 'foo,bar%5Ebam'
86
+ #
87
+ # @example Do not escape the values
88
+ # listify('foo','bar^bam', escape: false) # => 'foo,bar^bam'
89
+ #
90
+ # @api private
91
+ def self.listify(*list)
92
+ options = list.last.is_a?(Hash) ? list.pop : {}
93
+
94
+ escape = options[:escape]
95
+ Array(list)
96
+ .flat_map { |e| e.respond_to?(:split) ? e.split(',') : e }
97
+ .flatten
98
+ .compact
99
+ .map { |e| escape == false ? e : escape(e) }
100
+ .join(',')
101
+ end
102
+
103
+ # URL-escape a string
104
+ #
105
+ # @example
106
+ # __escape('foo/bar') # => 'foo%2Fbar'
107
+ # __escape('bar^bam') # => 'bar%5Ebam'
108
+ #
109
+ # @api private
110
+ def self.escape(string)
111
+ return string if string == '*'
112
+
113
+ ERB::Util.url_encode(string.to_s)
114
+ end
115
+
116
+ # Calls the given block, rescuing from `StandardError`.
117
+ #
118
+ # Primary use case is the `:ignore` parameter for API calls.
119
+ #
120
+ # Returns `false` if exception contains NotFound in its class name or message,
121
+ # else re-raises the exception.
122
+ #
123
+ # @yield [block] A block of code to be executed with exception handling.
124
+ #
125
+ # @api private
126
+ #
127
+ def self.rescue_from_not_found(&block)
128
+ yield
129
+ rescue StandardError => e
130
+ if e.class.to_s =~ /NotFound/ || e.message =~ /Not\s*Found/i
131
+ false
132
+ else
133
+ raise e
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,98 @@
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 'elasticsearch-serverless/api/response'
19
+ require 'elasticsearch-serverless/api/utils'
20
+
21
+ # Require everything in /api
22
+ Dir["#{File.dirname(__FILE__)}/api/**/*.rb"].each { |f| require f}
23
+
24
+ module ElasticsearchServerless
25
+ module API
26
+ include ElasticsearchServerless::API::Actions
27
+ HTTP_GET = 'GET'.freeze
28
+ HTTP_HEAD = 'HEAD'.freeze
29
+ HTTP_POST = 'POST'.freeze
30
+ HTTP_PUT = 'PUT'.freeze
31
+ HTTP_DELETE = 'DELETE'.freeze
32
+
33
+ # The serializer class
34
+ #
35
+ def self.serializer
36
+ JSON
37
+ end
38
+
39
+ # Namespace definitions
40
+ #
41
+ # Shortcuts for namespaces allows using methods for namespaces:
42
+ # +client.namespace.action+
43
+ #
44
+ module CommonClient
45
+ attr_reader :client
46
+
47
+ def initialize(client)
48
+ @client = client
49
+ end
50
+
51
+ def perform_request(method, path, params = {}, body = nil, headers = nil)
52
+ client.perform_request method, path, params, body, headers
53
+ end
54
+ end
55
+
56
+ # Add new namespaces to this constant
57
+ #
58
+ API_NAMESPACES = [
59
+ :async_search,
60
+ :cat,
61
+ :cluster,
62
+ :enrich,
63
+ :eql,
64
+ :graph,
65
+ :indices,
66
+ :ingest,
67
+ :license,
68
+ :logstash,
69
+ :search_application,
70
+ :security,
71
+ :sql,
72
+ :synonyms,
73
+ :transform
74
+ ].freeze
75
+
76
+ UPPERCASE_APIS = ['sql'].freeze
77
+
78
+ API_NAMESPACES.each do |namespace|
79
+ name = namespace.to_s
80
+ # TODO: consider if we need to do something for APIs that have aliases (if any of these are
81
+ # available in serverless), like 'ccr', 'ilm', 'ml' and 'slm'
82
+ module_name = if UPPERCASE_APIS.include?(name)
83
+ name.upcase
84
+ else
85
+ name.split("_").map(&:capitalize).join
86
+ end
87
+ class_name = "#{module_name}Client"
88
+
89
+ klass = Class.new(Object) do
90
+ include CommonClient, Object.const_get("ElasticsearchServerless::API::#{module_name}::Actions")
91
+ end
92
+ Object.const_set(class_name, klass)
93
+ define_method(name) do
94
+ instance_variable_set("@#{name}", klass.new(self))
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,22 @@
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
+ module ElasticsearchServerless
19
+ API_VERSION = '20231031'
20
+ CLIENT_VERSION = '0.0.8'
21
+ VERSION = "#{CLIENT_VERSION}.#{API_VERSION}.pre".freeze
22
+ end
@@ -0,0 +1,105 @@
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 'elastic/transport'
19
+ require 'elasticsearch-serverless/api'
20
+ require 'elasticsearch-serverless/version'
21
+
22
+ module ElasticsearchServerless
23
+ class Client
24
+ include ElasticsearchServerless::API
25
+
26
+ VALID_PARAMETERS = [:adapter, :log, :logger, :serializer_class, :trace, :tracer, :headers]
27
+
28
+ # Initializes an Elasticsearch Serverless Client
29
+ #
30
+ # @param :api_key [String] Base64 String, format used to authenticate with Elasticsearch
31
+ # @param :url [String] Elasticsearch endpoint
32
+ # @param :arguments [Hash] Other optional arguments.
33
+ # @option arguments [Symbol] :adapter A specific adapter for Faraday (e.g. `:patron`)
34
+ # @option arguments [Boolean] :log Use the default logger (disabled by default)
35
+ # @option arguments [Object] :logger An instance of a Logger-compatible object
36
+ # @option arguments [Boolean] :trace Use the default tracer (disabled by default)
37
+ # @option arguments [Object] :tracer An instance of a Logger-compatible object
38
+ # @option arguments [Constant] :serializer_class A specific serializer class to use, will be initialized by
39
+ # the transport and passed the transport instance
40
+ # @option arguments [Hash] :headers Custom HTTP Request Headers
41
+ #
42
+ def initialize(api_key:, url:, arguments: {})
43
+ validate_arguments(arguments)
44
+ arguments.merge!(essential_parameters(url, api_key))
45
+ @transport = Elastic::Transport::Client.new(arguments)
46
+ end
47
+
48
+ def essential_parameters(url, api_key)
49
+ {
50
+ host: url,
51
+ transport_options: {
52
+ headers: {
53
+ 'Authorization' => "ApiKey #{api_key}",
54
+ user_agent: user_agent
55
+ },
56
+ },
57
+ compression: true
58
+ }
59
+ end
60
+
61
+ def validate_arguments(arguments)
62
+ arguments.map do |k, _|
63
+ raise ArgumentError, "Parameter #{k}" unless VALID_PARAMETERS.include?(k)
64
+ end
65
+ end
66
+
67
+ # Metaprogramming for integration with Transport
68
+ def method_missing(name, *args, &block)
69
+ if methods.include?(name)
70
+ super
71
+ else
72
+ @transport.send(name, *args, &block)
73
+ end
74
+ end
75
+
76
+ def respond_to_missing?(method_name, *args)
77
+ @transport.respond_to?(method_name) || super
78
+ end
79
+
80
+ def user_agent
81
+ user_agent = [
82
+ "elasticsearch-serverless-ruby/#{ElasticsearchServerless::VERSION}",
83
+ "elastic-transport-ruby/#{Elastic::Transport::VERSION}",
84
+ "RUBY_VERSION: #{RUBY_VERSION}"
85
+ ]
86
+ if RbConfig::CONFIG && RbConfig::CONFIG['host_os']
87
+ user_agent << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
88
+ end
89
+ user_agent.join("; ")
90
+ end
91
+ end
92
+ end
93
+
94
+ module Elastic
95
+ # If the version is X.X.X.pre/alpha/beta, use X.X.Xp for the meta-header:
96
+ def self.client_meta_version
97
+ regexp = /^([0-9]+\.[0-9]+\.[0-9]+)\.?([a-z0-9.-]+)?$/
98
+ match = ElasticsearchServerless::VERSION.match(regexp)
99
+ return "#{match[1]}p" if match[2]
100
+
101
+ ElasticsearchServerless::VERSION
102
+ end
103
+
104
+ ELASTICSEARCH_SERVICE_VERSION = [:esv, client_meta_version].freeze
105
+ end