From c73c44062f07d6e6ffe790197d7e05f49b5dde85 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 10 Oct 2025 16:04:25 +0100 Subject: [PATCH 1/3] [API] Request body was incorrectly marked as not required in several APIs. This commit generates the code for commit 62d200f5597fbf3529686f7ae7063d6b0a77f1cb of `elasticsearch-specification`, adding the body requirement in these 68 APIs: `clear_scroll` `close_point_in_time` `cluster.allocation_explain` `cluster.reroute` `count` `explain` `field_caps` `fleet.search` `graph.explore` `index_lifecycle_management.move_to_step` `index_lifecycle_management.put_lifecycle` `indices.analyze` `indices.clone` `indices.create` `indices.put_data_lifecycle` `indices.put_data_stream_options` `indices.rollover` `indices.shrink` `indices.split` `indices.validate_query` `inference.completion` `inference.inference` `inference.put_ai21` `inference.put_alibabacloud` `inference.put_amazonbedrock` `inference.put_amazonsagemaker` `inference.put_anthropic` `inference.put_azureaistudio` `inference.put_azureopenai` `inference.put_cohere` `inference.put_contextualai` `inference.put_custom` `inference.put_deepseek` `inference.put_elasticsearch` `inference.put_elser` `inference.put_googleaistudio` `inference.put_googlevertexai` `inference.put_hugging_face` `inference.put_jinaai` `inference.put_llama` `inference.put_mistral` `inference.put_openai` `inference.put_voyageai` `inference.put_watsonx` `inference.rerank` `inference.sparse_embedding` `inference.stream_completion` `inference.text_embedding` `license.post` `machine_learning.delete_expired_data` `machine_learning.flush_job` `machine_learning.get_buckets` `machine_learning.get_calendars` `machine_learning.get_categories` `machine_learning.get_influencers` `machine_learning.get_model_snapshots` `machine_learning.get_overall_buckets` `machine_learning.get_records` `machine_learning.revert_model_snapshot` `machine_learning.start_datafeed` `open_point_in_time` `render_search_template` `scripts_painless_execute` `scroll` `search` `snapshot_lifecycle_management.put_lifecycle` `terms_enum` `update_by_query` --- .../lib/elasticsearch/api/actions/clear_scroll.rb | 2 ++ .../lib/elasticsearch/api/actions/close_point_in_time.rb | 2 ++ .../api/actions/cluster/allocation_explain.rb | 9 +++------ .../lib/elasticsearch/api/actions/cluster/reroute.rb | 2 ++ elasticsearch-api/lib/elasticsearch/api/actions/count.rb | 2 ++ .../lib/elasticsearch/api/actions/explain.rb | 8 ++------ .../lib/elasticsearch/api/actions/field_caps.rb | 9 +++------ .../lib/elasticsearch/api/actions/fleet/search.rb | 8 ++------ .../lib/elasticsearch/api/actions/graph/explore.rb | 8 ++------ .../actions/index_lifecycle_management/move_to_step.rb | 1 + .../actions/index_lifecycle_management/put_lifecycle.rb | 1 + .../lib/elasticsearch/api/actions/indices/analyze.rb | 9 +++------ .../lib/elasticsearch/api/actions/indices/clone.rb | 1 + .../lib/elasticsearch/api/actions/indices/create.rb | 1 + .../api/actions/indices/put_data_lifecycle.rb | 1 + .../api/actions/indices/put_data_stream_options.rb | 1 + .../lib/elasticsearch/api/actions/indices/rollover.rb | 1 + .../lib/elasticsearch/api/actions/indices/shrink.rb | 1 + .../lib/elasticsearch/api/actions/indices/split.rb | 1 + .../elasticsearch/api/actions/indices/validate_query.rb | 9 +++------ .../elasticsearch/api/actions/inference/completion.rb | 1 + .../lib/elasticsearch/api/actions/inference/inference.rb | 1 + .../lib/elasticsearch/api/actions/inference/put_ai21.rb | 1 + .../api/actions/inference/put_alibabacloud.rb | 1 + .../api/actions/inference/put_amazonbedrock.rb | 1 + .../api/actions/inference/put_amazonsagemaker.rb | 1 + .../elasticsearch/api/actions/inference/put_anthropic.rb | 1 + .../api/actions/inference/put_azureaistudio.rb | 1 + .../api/actions/inference/put_azureopenai.rb | 1 + .../elasticsearch/api/actions/inference/put_cohere.rb | 1 + .../api/actions/inference/put_contextualai.rb | 1 + .../elasticsearch/api/actions/inference/put_custom.rb | 1 + .../elasticsearch/api/actions/inference/put_deepseek.rb | 1 + .../api/actions/inference/put_elasticsearch.rb | 1 + .../lib/elasticsearch/api/actions/inference/put_elser.rb | 1 + .../api/actions/inference/put_googleaistudio.rb | 1 + .../api/actions/inference/put_googlevertexai.rb | 1 + .../api/actions/inference/put_hugging_face.rb | 1 + .../elasticsearch/api/actions/inference/put_jinaai.rb | 1 + .../lib/elasticsearch/api/actions/inference/put_llama.rb | 1 + .../elasticsearch/api/actions/inference/put_mistral.rb | 1 + .../elasticsearch/api/actions/inference/put_openai.rb | 1 + .../elasticsearch/api/actions/inference/put_voyageai.rb | 1 + .../elasticsearch/api/actions/inference/put_watsonx.rb | 1 + .../lib/elasticsearch/api/actions/inference/rerank.rb | 1 + .../api/actions/inference/sparse_embedding.rb | 1 + .../api/actions/inference/stream_completion.rb | 1 + .../api/actions/inference/text_embedding.rb | 1 + .../lib/elasticsearch/api/actions/license/post.rb | 2 ++ .../api/actions/machine_learning/delete_expired_data.rb | 2 ++ .../api/actions/machine_learning/flush_job.rb | 1 + .../api/actions/machine_learning/get_buckets.rb | 8 ++------ .../api/actions/machine_learning/get_calendars.rb | 9 +++------ .../api/actions/machine_learning/get_categories.rb | 8 ++------ .../api/actions/machine_learning/get_influencers.rb | 8 ++------ .../api/actions/machine_learning/get_model_snapshots.rb | 8 ++------ .../api/actions/machine_learning/get_overall_buckets.rb | 8 ++------ .../api/actions/machine_learning/get_records.rb | 8 ++------ .../actions/machine_learning/revert_model_snapshot.rb | 1 + .../api/actions/machine_learning/start_datafeed.rb | 1 + .../lib/elasticsearch/api/actions/open_point_in_time.rb | 1 + .../elasticsearch/api/actions/render_search_template.rb | 9 +++------ .../api/actions/scripts_painless_execute.rb | 9 +++------ .../lib/elasticsearch/api/actions/scroll.rb | 9 +++------ .../lib/elasticsearch/api/actions/search.rb | 9 +++------ .../snapshot_lifecycle_management/put_lifecycle.rb | 1 + .../lib/elasticsearch/api/actions/terms_enum.rb | 8 ++------ .../lib/elasticsearch/api/actions/update_by_query.rb | 1 + elasticsearch-api/lib/elasticsearch/api/version.rb | 2 +- 69 files changed, 103 insertions(+), 115 deletions(-) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb b/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb index 096e3e67b3..43d9189084 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb @@ -51,6 +51,8 @@ module Actions def clear_scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'clear_scroll' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb b/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb index 4adf2ca4c2..75b55c4f9b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb @@ -46,6 +46,8 @@ module Actions def close_point_in_time(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'close_point_in_time' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb index 965257ffea..4d002e4acc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb @@ -56,17 +56,14 @@ module Actions def allocation_explain(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'cluster.allocation_explain' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = '_cluster/allocation/explain' params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb index 9dcc896ba3..fa4e09f806 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb @@ -59,6 +59,8 @@ module Actions def reroute(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'cluster.reroute' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/count.rb b/elasticsearch-api/lib/elasticsearch/api/actions/count.rb index 04a287bdab..44a45facfe 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/count.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/count.rb @@ -94,6 +94,8 @@ def count(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb index 61f6a0e528..87fc7eddb4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb @@ -75,6 +75,7 @@ def explain(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -87,12 +88,7 @@ def explain(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_explain/#{Utils.listify(_id)}" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb b/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb index 5cc055737c..834803abb5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb @@ -72,6 +72,8 @@ def field_caps(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -79,12 +81,7 @@ def field_caps(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_field_caps" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb index 50a1867f17..fd5ad84ea9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb @@ -102,6 +102,7 @@ def search(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone @@ -111,12 +112,7 @@ def search(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_fleet/_fleet_search" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb b/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb index 2c130aa113..04b7d0566c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb @@ -58,6 +58,7 @@ def explore(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone @@ -67,12 +68,7 @@ def explore(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_graph/explore" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb index a34ff2dad1..94ef76a198 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb @@ -59,6 +59,7 @@ def move_to_step(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb index 0a81e562a4..ac628484e8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb @@ -53,6 +53,7 @@ def put_lifecycle(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'policy' missing" unless arguments[:policy] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb index deccf943ef..bec9bd4069 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb @@ -56,6 +56,8 @@ def analyze(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -63,12 +65,7 @@ def analyze(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_analyze" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb index f1065694ff..3b5c691aea 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb @@ -86,6 +86,7 @@ def clone(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb index a378aa4dc5..09bebbacc1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb @@ -78,6 +78,7 @@ def create(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb index 3dfc9774ca..286f2ba3e5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb @@ -59,6 +59,7 @@ def put_data_lifecycle(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_stream_options.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_stream_options.rb index 5c7e4f671b..68ed17ca45 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_stream_options.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_stream_options.rb @@ -59,6 +59,7 @@ def put_data_stream_options(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb index 2044006eca..3275f2f3fa 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb @@ -86,6 +86,7 @@ def rollover(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'alias' missing" unless arguments[:alias] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb index 4689b7f7bc..df624ad063 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb @@ -78,6 +78,7 @@ def shrink(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb index 86b0ad3e02..062c3fad3e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb @@ -81,6 +81,7 @@ def split(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb index d9637d9a65..b14cd5c96a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb @@ -69,6 +69,8 @@ def validate_query(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -76,12 +78,7 @@ def validate_query(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_validate/query" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb index 0475c49ab6..45ce47c3b9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb @@ -50,6 +50,7 @@ def completion(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb index 8b0aa2ebc2..4ec82363c4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb @@ -55,6 +55,7 @@ def inference(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_ai21.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_ai21.rb index df7f3a439c..4d95dbff1a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_ai21.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_ai21.rb @@ -52,6 +52,7 @@ def put_ai21(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] raise ArgumentError, "Required argument 'ai21_inference_id' missing" unless arguments[:ai21_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb index 7484179b91..f4d44742e8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb @@ -52,6 +52,7 @@ def put_alibabacloud(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:alibabacloud_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb index cb0b583456..a3768d54d0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb @@ -52,6 +52,7 @@ def put_amazonbedrock(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:amazonbedrock_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonsagemaker.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonsagemaker.rb index 43c06f9b47..6cf6c60f6a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonsagemaker.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonsagemaker.rb @@ -52,6 +52,7 @@ def put_amazonsagemaker(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:amazonsagemaker_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb index 99113a7f81..c5fda36d84 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb @@ -53,6 +53,7 @@ def put_anthropic(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:anthropic_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb index 7fa0aec566..3955b426ab 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb @@ -52,6 +52,7 @@ def put_azureaistudio(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:azureaistudio_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb index 64e1cd829b..14f2bd83b4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb @@ -57,6 +57,7 @@ def put_azureopenai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:azureopenai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb index c087699473..87af1099c7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb @@ -52,6 +52,7 @@ def put_cohere(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:cohere_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_contextualai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_contextualai.rb index 4e63d822ed..5d35d7e4d2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_contextualai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_contextualai.rb @@ -53,6 +53,7 @@ def put_contextualai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:contextualai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb index a8937cbb55..4a9890d776 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb @@ -82,6 +82,7 @@ def put_custom(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:custom_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb index 066b07d529..a857227044 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb @@ -52,6 +52,7 @@ def put_deepseek(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:deepseek_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb index 23f0304060..cbf2bae051 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb @@ -53,6 +53,7 @@ def put_elasticsearch(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:elasticsearch_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb index 23781d41fe..20604438cc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb @@ -53,6 +53,7 @@ def put_elser(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] raise ArgumentError, "Required argument 'elser_inference_id' missing" unless arguments[:elser_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb index e17a2c2034..c1a368a455 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb @@ -52,6 +52,7 @@ def put_googleaistudio(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:googleaistudio_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb index 4d8db90eec..98d0a0334c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb @@ -52,6 +52,7 @@ def put_googlevertexai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:googlevertexai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb index daaa7d2e48..cdf0800114 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb @@ -80,6 +80,7 @@ def put_hugging_face(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:huggingface_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb index fff81ef27a..55f6c78d87 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb @@ -54,6 +54,7 @@ def put_jinaai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:jinaai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_llama.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_llama.rb index a4abbf2664..6bcc34cd20 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_llama.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_llama.rb @@ -52,6 +52,7 @@ def put_llama(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] raise ArgumentError, "Required argument 'llama_inference_id' missing" unless arguments[:llama_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb index 9a30ff2759..7e335841d9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb @@ -52,6 +52,7 @@ def put_mistral(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:mistral_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb index f6c92df0c9..8eaa8ce13e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb @@ -53,6 +53,7 @@ def put_openai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:openai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb index a4033870c6..0a6b83c0c3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb @@ -53,6 +53,7 @@ def put_voyageai(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:voyageai_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb index a08c0ce112..eba8a93d14 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb @@ -54,6 +54,7 @@ def put_watsonx(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] unless arguments[:watsonx_inference_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb index 8f65a97c47..810c706c03 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb @@ -50,6 +50,7 @@ def rerank(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb index dd823864e3..835a45aeee 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb @@ -50,6 +50,7 @@ def sparse_embedding(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb index 8ffbad6192..80e55c604a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb @@ -54,6 +54,7 @@ def stream_completion(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb index 7a81cca33c..b552b746c4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb @@ -50,6 +50,7 @@ def text_embedding(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb index 170f3aa240..1e6c0f5613 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb @@ -52,6 +52,8 @@ module Actions def post(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'license.post' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb index 8d7ae72bf4..0ef466d59a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb @@ -61,6 +61,8 @@ def delete_expired_data(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb index d1c05511b0..14efd2e3a2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb @@ -67,6 +67,7 @@ def flush_job(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb index 9168ffb6b4..13a2e2a3de 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb @@ -63,6 +63,7 @@ def get_buckets(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -74,12 +75,7 @@ def get_buckets(arguments = {}) _timestamp = arguments.delete(:timestamp) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _job_id && _timestamp "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/buckets/#{Utils.listify(_timestamp)}" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb index a9b97b3c41..7baa6d06ff 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb @@ -51,6 +51,8 @@ def get_calendars(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -58,12 +60,7 @@ def get_calendars(arguments = {}) _calendar_id = arguments.delete(:calendar_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _calendar_id "_ml/calendars/#{Utils.listify(_calendar_id)}" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb index 154da74930..fa5c0e568b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb @@ -57,6 +57,7 @@ def get_categories(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -68,12 +69,7 @@ def get_categories(arguments = {}) _category_id = arguments.delete(:category_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _job_id && _category_id "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/categories/#{Utils.listify(_category_id)}" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb index 91b9e23b68..5eaf8b79fc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb @@ -66,6 +66,7 @@ def get_influencers(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -75,12 +76,7 @@ def get_influencers(arguments = {}) _job_id = arguments.delete(:job_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/influencers" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb index 25ee58380f..ffb928dabc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb @@ -59,6 +59,7 @@ def get_model_snapshots(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -70,12 +71,7 @@ def get_model_snapshots(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _job_id && _snapshot_id "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb index 13ea6f211c..541dcb68d1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb @@ -88,6 +88,7 @@ def get_overall_buckets(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -97,12 +98,7 @@ def get_overall_buckets(arguments = {}) _job_id = arguments.delete(:job_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/overall_buckets" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb index ad69302684..6f16bda4a3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb @@ -69,6 +69,7 @@ def get_records(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -78,12 +79,7 @@ def get_records(arguments = {}) _job_id = arguments.delete(:job_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/records" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb index 53ac06188f..55cf70fce4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb @@ -65,6 +65,7 @@ def revert_model_snapshot(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb index 65895120b2..2945df1a0f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb @@ -75,6 +75,7 @@ def start_datafeed(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb index a27aec66f6..a982bc669b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb @@ -93,6 +93,7 @@ def open_point_in_time(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb index 9892557a15..99a0e84d37 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb @@ -50,6 +50,8 @@ def render_search_template(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -57,12 +59,7 @@ def render_search_template(arguments = {}) _id = arguments.delete(:id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _id "_render/template/#{Utils.listify(_id)}" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb b/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb index e23ff0246c..51c6c4cde9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb @@ -51,17 +51,14 @@ module Actions def scripts_painless_execute(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scripts_painless_execute' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = '_scripts/painless/_execute' params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb index 2f92c9b944..f557ba5d44 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb @@ -59,6 +59,8 @@ module Actions def scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scroll' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -66,12 +68,7 @@ def scroll(arguments = {}) _scroll_id = arguments.delete(:scroll_id) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = '_search/scroll' params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb index 3f8bd68501..2ccad9f087 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb @@ -180,6 +180,8 @@ def search(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -187,12 +189,7 @@ def search(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_search" else diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb index 8ebac084b9..961a38d1bc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb @@ -58,6 +58,7 @@ def put_lifecycle(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'policy_id' missing" unless arguments[:policy_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb b/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb index 1720c9b04c..1a3d7984a4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb @@ -52,6 +52,7 @@ def terms_enum(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone @@ -61,12 +62,7 @@ def terms_enum(arguments = {}) _index = arguments.delete(:index) - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - + method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_terms_enum" params = Utils.process_params(arguments) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb index b612b2a62a..1dc6e7a8a1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb @@ -180,6 +180,7 @@ def update_by_query(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index a56be4679a..f5bff647c9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -18,6 +18,6 @@ module Elasticsearch module API VERSION = '9.2.0'.freeze - ES_SPECIFICATION_COMMIT = '88ed8664f1c6662d0a277627092255bde3259c5c'.freeze + ES_SPECIFICATION_COMMIT = '62d200f5597fbf3529686f7ae7063d6b0a77f1cb'.freeze end end From abd73e79b635e1c043b4f3ddc82e5a2cab6ee8ec Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 10 Oct 2025 16:42:31 +0100 Subject: [PATCH 2/3] [API] Updates unit tests for 68 APIs with required body --- .../unit/actions/close_point_in_time_spec.rb | 4 +- .../cluster/allocation_explain_spec.rb | 6 +- .../spec/unit/actions/cluster/reroute_spec.rb | 22 +------- .../spec/unit/actions/count_spec.rb | 12 ++-- .../unit/actions/explain_document_spec.rb | 6 +- .../spec/unit/actions/field_caps_spec.rb | 14 ++--- .../spec/unit/actions/fleet/search_spec.rb | 6 +- .../spec/unit/actions/graph/explore_spec.rb | 6 +- .../move_to_step_spec.rb | 4 +- .../spec/unit/actions/indices/analyze_spec.rb | 8 +-- .../spec/unit/actions/indices/clone_spec.rb | 55 ++++++++++--------- .../spec/unit/actions/indices/create_spec.rb | 24 ++++---- .../indices/put_data_lifecycle_spec.rb | 4 +- .../indices/put_data_stream_options_spec.rb | 4 +- .../unit/actions/indices/rollover_spec.rb | 19 +++---- .../spec/unit/actions/indices/shrink_spec.rb | 6 +- .../spec/unit/actions/indices/split_spec.rb | 4 +- .../actions/indices/validate_query_spec.rb | 20 +++---- .../unit/actions/inference/completion_spec.rb | 4 +- .../unit/actions/inference/inference_spec.rb | 4 +- .../unit/actions/inference/put_ai21_spec.rb | 4 +- .../inference/put_alibabacloud_spec.rb | 4 +- .../inference/put_amazonbedrock_spec.rb | 4 +- .../inference/put_amazonsagemaker_spec.rb | 4 +- .../actions/inference/put_anthropic_spec.rb | 4 +- .../inference/put_azureaistudio_spec.rb | 4 +- .../actions/inference/put_azureopenai_spec.rb | 4 +- .../unit/actions/inference/put_cohere_spec.rb | 4 +- .../inference/put_contextualai_spec.rb | 4 +- .../unit/actions/inference/put_custom_spec.rb | 4 +- .../actions/inference/put_deepseek_spec.rb | 4 +- .../inference/put_elasticsearch_spec.rb | 4 +- .../unit/actions/inference/put_elser_spec.rb | 4 +- .../inference/put_googleaistudio_spec.rb | 4 +- .../inference/put_googlevertexai_spec.rb | 4 +- .../inference/put_hugging_face_spec.rb | 4 +- .../unit/actions/inference/put_jinaai_spec.rb | 4 +- .../unit/actions/inference/put_llama_spec.rb | 4 +- .../actions/inference/put_mistral_spec.rb | 4 +- .../unit/actions/inference/put_openai_spec.rb | 4 +- .../actions/inference/put_voyageai_spec.rb | 4 +- .../actions/inference/put_watsonx_spec.rb | 4 +- .../unit/actions/inference/rerank_spec.rb | 4 +- .../inference/sparse_embedding_spec.rb | 4 +- .../inference/stream_completion_spec.rb | 4 +- .../actions/inference/text_embedding_spec.rb | 4 +- .../spec/unit/actions/license/post_spec.rb | 4 +- .../unit/actions/open_point_in_time_spec.rb | 4 +- .../spec/unit/actions/scroll_spec.rb | 6 +- .../spec/unit/actions/search_spec.rb | 12 ++-- .../spec/unit/actions/terms_enum_spec.rb | 23 ++------ .../spec/unit/actions/update_by_query_spec.rb | 4 +- 52 files changed, 178 insertions(+), 211 deletions(-) diff --git a/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb b/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb index d770830179..b4707c0c9f 100644 --- a/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb +++ b/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb @@ -23,13 +23,13 @@ 'DELETE', '_pit', {}, - nil, + {}, {}, { endpoint: 'close_point_in_time' } ] end it 'performs the request' do - expect(client_double.close_point_in_time).to be_a Elasticsearch::API::Response + expect(client_double.close_point_in_time(body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb index 3577130b2c..ab7e342fd7 100644 --- a/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb @@ -21,16 +21,16 @@ let(:expected_args) do [ - 'GET', + 'POST', '_cluster/allocation/explain', {}, - nil, + {}, {}, { endpoint: 'cluster.allocation_explain' } ] end it 'performs the request' do - expect(client_double.cluster.allocation_explain).to be_a Elasticsearch::API::Response + expect(client_double.cluster.allocation_explain(body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb index b0278bbab8..eee674e4fb 100644 --- a/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb @@ -18,36 +18,18 @@ require 'spec_helper' describe 'client.cluster#reroute' do - let(:expected_args) do [ 'POST', '_cluster/reroute', {}, - nil, + { commands: [ move: { index: 'myindex', shard: 0 }] }, {}, { endpoint: 'cluster.reroute' } ] end it 'performs the request' do - expect(client_double.cluster.reroute).to be_a Elasticsearch::API::Response - end - - context 'when a body is specified' do - let(:expected_args) do - [ - 'POST', - '_cluster/reroute', - {}, - { commands: [ move: { index: 'myindex', shard: 0 }] }, - {}, - { endpoint: 'cluster.reroute' } - ] - end - - it 'performs the request' do - expect(client_double.cluster.reroute(body: { commands: [ move: { index: 'myindex', shard: 0 }] })).to be_a Elasticsearch::API::Response - end + expect(client_double.cluster.reroute(body: { commands: [ move: { index: 'myindex', shard: 0 }] })).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/count_spec.rb b/elasticsearch-api/spec/unit/actions/count_spec.rb index e7806501dd..4c56c43851 100644 --- a/elasticsearch-api/spec/unit/actions/count_spec.rb +++ b/elasticsearch-api/spec/unit/actions/count_spec.rb @@ -20,33 +20,33 @@ describe 'client#count' do let(:expected_args) do [ - 'GET', + 'POST', '_count', {}, - nil, + {}, {}, { endpoint: 'count' } ] end it 'performs the request' do - expect(client_double.count).to be_a Elasticsearch::API::Response + expect(client_double.count(body: {})).to be_a Elasticsearch::API::Response end context 'when an index and type are specified' do let(:expected_args) do [ - 'GET', + 'POST', 'foo,bar/_count', {}, - nil, + {}, {}, { defined_params: { index: ['foo', 'bar'] }, endpoint: 'count' } ] end it 'performs the request' do - expect(client_double.count(index: ['foo','bar'])).to be_a Elasticsearch::API::Response + expect(client_double.count(index: ['foo','bar'], body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/explain_document_spec.rb b/elasticsearch-api/spec/unit/actions/explain_document_spec.rb index 50f6ce7f88..aa8d66b572 100644 --- a/elasticsearch-api/spec/unit/actions/explain_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/explain_document_spec.rb @@ -64,7 +64,7 @@ end context 'when a query is provided' do - let(:method) { 'GET' } + let(:method) { 'POST' } let(:params) do { q: 'abc123' } end @@ -81,11 +81,11 @@ end let(:body) do - nil + {} end it 'passes the query' do - expect(client_double.explain(index: 'foo', id: '1', q: 'abc123')).to be_a Elasticsearch::API::Response + expect(client_double.explain(index: 'foo', id: '1', q: 'abc123', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/field_caps_spec.rb b/elasticsearch-api/spec/unit/actions/field_caps_spec.rb index e7c905a27e..48b5172bd3 100644 --- a/elasticsearch-api/spec/unit/actions/field_caps_spec.rb +++ b/elasticsearch-api/spec/unit/actions/field_caps_spec.rb @@ -21,16 +21,16 @@ let(:expected_args) do [ - 'GET', - 'foo/_field_caps', - { fields: 'bar' }, - nil, - {}, - { defined_params: { index: 'foo' }, endpoint: 'field_caps' } + 'POST', + 'foo/_field_caps', + { fields: 'bar' }, + {}, + {}, + { defined_params: { index: 'foo' }, endpoint: 'field_caps' } ] end it 'performs the request' do - expect(client_double.field_caps(index: 'foo', fields: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.field_caps(index: 'foo', fields: 'bar', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb b/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb index 6f49db20b4..fd2b32a18b 100644 --- a/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb +++ b/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb @@ -20,17 +20,17 @@ describe 'client#fleet.search' do let(:expected_args) do [ - 'GET', + 'POST', 'foo/_fleet/_fleet_search', {}, - nil, + {}, {}, { defined_params: { index: 'foo' }, endpoint: 'fleet.search' } ] end it 'performs the request' do - expect(client_double.fleet.search(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.fleet.search(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end let(:client) do diff --git a/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb b/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb index 7415a7b4ab..4cce7b7d01 100644 --- a/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb +++ b/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb @@ -20,16 +20,16 @@ describe 'client#eql.search' do let(:expected_args) do [ - 'GET', + 'POST', 'foo/_graph/explore', {}, - nil, + {}, {}, { defined_params: { index: 'foo' }, endpoint: 'graph.explore' } ] end it 'performs the request' do - expect(client_double.graph.explore(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.graph.explore(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb index 35de205b91..365d2e33d6 100644 --- a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb @@ -23,7 +23,7 @@ 'POST', '_ilm/move/foo', {}, - nil, + {}, {}, { defined_params: { index: 'foo' }, endpoint: 'ilm.move_to_step' } ] @@ -32,6 +32,6 @@ let(:index) { 'foo' } it 'performs the request' do - expect(client_double.index_lifecycle_management.move_to_step(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.index_lifecycle_management.move_to_step(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb b/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb index c23218b8b7..1bd941c4a1 100644 --- a/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb @@ -28,10 +28,10 @@ { endpoint: 'indices.analyze' } ] end - let(:method) { 'GET' } + let(:method) { 'POST' } let(:body) do - nil + {} end let(:url) do @@ -43,7 +43,7 @@ end it 'performs the request' do - expect(client_double.indices.analyze).to be_a Elasticsearch::API::Response + expect(client_double.indices.analyze(body: {})).to be_a Elasticsearch::API::Response end context 'when an index is specified' do @@ -63,7 +63,7 @@ end it 'performs the request' do - expect(client_double.indices.analyze(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.analyze(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb b/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb index ab080402ca..0730d4fe8e 100644 --- a/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb @@ -21,13 +21,13 @@ let(:expected_args) do [ - 'PUT', - url, - params, - body, - {}, - { defined_params: { index: 'my_source_index', target: 'my_target_index' }, - endpoint: 'indices.clone' } + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: 'my_source_index', target: 'my_target_index' }, + endpoint: 'indices.clone' } ] end @@ -36,15 +36,14 @@ end let(:body) do - nil + {} end let(:url) do 'my_source_index/_clone/my_target_index' end - context 'when there is no index specified' do - + context 'when there is no index or body specified' do let(:client) do Class.new { include Elasticsearch::API }.new end @@ -72,12 +71,17 @@ context 'when an index and target are specified' do it 'performs the request' do - expect(client_double.indices.clone(index: 'my_source_index', target: 'my_target_index')).to be_a Elasticsearch::API::Response + expect( + client_double.indices.clone( + index: 'my_source_index', + target: 'my_target_index', + body: {} + ) + ).to be_a Elasticsearch::API::Response end end context 'when params are provided' do - let(:params) do { timeout: '1s', @@ -91,7 +95,8 @@ target: 'my_target_index', timeout: '1s', master_timeout: '10s', - wait_for_active_shards: 1)).to be_a Elasticsearch::API::Response + wait_for_active_shards: 1, + body: {})).to be_a Elasticsearch::API::Response end end @@ -99,12 +104,12 @@ let(:body) do { - settings: { - 'index.number_of_shards' => 5 - }, - aliases: { - my_search_indices: {} - } + settings: { + 'index.number_of_shards' => 5 + }, + aliases: { + my_search_indices: {} + } } end @@ -112,12 +117,12 @@ expect(client_double.indices.clone(index: 'my_source_index', target: 'my_target_index', body: { - settings: { - 'index.number_of_shards' => 5 - }, - aliases: { - my_search_indices: {} - } + settings: { + 'index.number_of_shards' => 5 + }, + aliases: { + my_search_indices: {} + } })).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/create_spec.rb b/elasticsearch-api/spec/unit/actions/indices/create_spec.rb index 719b493ef9..c4c7445d74 100644 --- a/elasticsearch-api/spec/unit/actions/indices/create_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/create_spec.rb @@ -21,12 +21,12 @@ let(:expected_args) do [ - 'PUT', - url, - params, - nil, - {}, - { defined_params: { index: 'foo' }, endpoint: 'indices.create' } + 'PUT', + url, + params, + {}, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.create' } ] end @@ -35,7 +35,6 @@ end context 'when there is no index specified' do - let(:client) do Class.new { include Elasticsearch::API }.new end @@ -48,18 +47,16 @@ end context 'when an index is specified' do - let(:url) do 'foo' end it 'performs the request' do - expect(client_double.indices.create(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.create(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end context 'when params are specified' do - let(:params) do { timeout: '1s' } end @@ -69,12 +66,11 @@ end it 'performs the request' do - expect(client_double.indices.create(index: 'foo', timeout: '1s')).to be_a Elasticsearch::API::Response + expect(client_double.indices.create(index: 'foo', timeout: '1s', body: {})).to be_a Elasticsearch::API::Response end end context 'when the path must be URL-escaped' do - let(:url) do 'foo%5Ebar' end @@ -84,14 +80,14 @@ 'PUT', url, params, - nil, + {}, {}, { defined_params: { index: 'foo^bar' }, endpoint: 'indices.create' } ] end it 'performs the request' do - expect(client_double.indices.create(index: 'foo^bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.create(index: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response end end end diff --git a/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb index fedb498df3..2ea789d888 100644 --- a/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb @@ -23,13 +23,13 @@ 'PUT', '_data_stream/foo/_lifecycle', {}, - nil, + {}, {}, { defined_params: { name: 'foo' }, endpoint: 'indices.put_data_lifecycle' } ] end it 'performs the request' do - expect(client_double.indices.put_data_lifecycle(name: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.put_data_lifecycle(name: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/put_data_stream_options_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_data_stream_options_spec.rb index 427e76fba5..feaf07d96c 100644 --- a/elasticsearch-api/spec/unit/actions/indices/put_data_stream_options_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_data_stream_options_spec.rb @@ -23,13 +23,13 @@ 'PUT', '_data_stream/foo/_options', {}, - nil, + {}, {}, { endpoint: 'indices.put_data_stream_options', defined_params: { name: 'foo' } } ] end it 'performs the request' do - expect(client_double.indices.put_data_stream_options(name: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.put_data_stream_options(name: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb b/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb index 59a32a09de..e2b1d2440f 100644 --- a/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb @@ -20,12 +20,12 @@ describe 'client.indices#rollover' do let(:expected_args) do [ - 'POST', - url, - params, - body, - {}, - { defined_params: { alias: 'foo' }, endpoint: 'indices.rollover' } + 'POST', + url, + params, + body, + {}, + { defined_params: { alias: 'foo' }, endpoint: 'indices.rollover' } ] end @@ -34,7 +34,7 @@ end let(:body) do - nil + {} end let(:params) do @@ -42,11 +42,10 @@ end it 'performs the request' do - expect(client_double.indices.rollover(alias: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.rollover(alias: 'foo', body: {})).to be_a Elasticsearch::API::Response end context 'when an index is specified' do - let(:url) do 'foo/_rollover/bar' end @@ -63,7 +62,7 @@ end it 'performs the request' do - expect(client_double.indices.rollover(alias: 'foo', new_index: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.rollover(alias: 'foo', new_index: 'bar', body: {})).to be_a Elasticsearch::API::Response end end end diff --git a/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb b/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb index 519754714f..614762e688 100644 --- a/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb @@ -24,7 +24,7 @@ 'PUT', 'foo/_shrink/bar', {}, - nil, + {}, {}, { defined_params: { index: 'foo', target: 'bar' }, endpoint: 'indices.shrink' } @@ -32,11 +32,11 @@ end it 'performs the request' do - expect(client_double.indices.shrink(index: 'foo', target: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.shrink(index: 'foo', target: 'bar', body: {})).to be_a Elasticsearch::API::Response end it 'does not mutate the arguments' do - arguments = { index: 'foo', target: 'bar' } + arguments = { index: 'foo', target: 'bar', body: {} } client_double.indices.shrink(arguments) expect(arguments[:index]).to eq('foo') expect(arguments[:target]).to eq('bar') diff --git a/elasticsearch-api/spec/unit/actions/indices/split_spec.rb b/elasticsearch-api/spec/unit/actions/indices/split_spec.rb index a90d749b41..04b73d8379 100644 --- a/elasticsearch-api/spec/unit/actions/indices/split_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/split_spec.rb @@ -24,7 +24,7 @@ 'PUT', 'foo/_split/bar', {}, - nil, + {}, {}, { defined_params: { index: 'foo', target: 'bar' }, endpoint:'indices.split' } @@ -32,6 +32,6 @@ end it 'performs the request' do - expect(client_double.indices.split(index: 'foo', target: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.split(index: 'foo', target: 'bar', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb b/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb index b6059ed253..5d3f29e981 100644 --- a/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb @@ -29,14 +29,14 @@ ] end - let(:method) { 'GET' } + let(:method) { 'POST' } let(:url) do '_validate/query' end let(:body) do - nil + {} end let(:params) do @@ -44,7 +44,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(body: {})).to be_a Elasticsearch::API::Response end context 'when an index is specified' do @@ -64,7 +64,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end @@ -85,7 +85,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(index: ['foo', 'bar'], body: {})).to be_a Elasticsearch::API::Response end end @@ -106,7 +106,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo,bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(index: 'foo,bar', body: {})).to be_a Elasticsearch::API::Response end end @@ -121,7 +121,7 @@ let(:expected_args) do [ - method, + 'POST', url, params, body, @@ -131,7 +131,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query(explain: true, q: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(explain: true, q: 'foo', body: {})).to be_a Elasticsearch::API::Response end end @@ -164,7 +164,7 @@ let(:expected_args) do [ - method, + 'POST', url, params, body, @@ -174,7 +174,7 @@ end it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo^bar')).to be_a Elasticsearch::API::Response + expect(client_double.indices.validate_query(index: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response end end end diff --git a/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb index 8817e72a32..e949d6f9a3 100644 --- a/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb @@ -23,7 +23,7 @@ 'POST', '_inference/completion/bar', {}, - nil, + {}, {}, { defined_params: { inference_id: 'bar' }, endpoint: 'inference.completion' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.completion(inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.completion(inference_id: 'bar', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb b/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb index dfa2a51890..7b06841095 100644 --- a/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb @@ -23,7 +23,7 @@ 'POST', '_inference/bar', {}, - nil, + {}, {}, { defined_params: { inference_id: 'bar' }, endpoint: 'inference.inference' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.inference(inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.inference(inference_id: 'bar', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_ai21_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_ai21_spec.rb index ee902011c9..bc7f31bff3 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_ai21_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_ai21_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { ai21_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_ai21' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_ai21(task_type: 'foo', ai21_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_ai21(task_type: 'foo', body: {}, ai21_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb index 0ac550822f..728e5d2cd7 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { alibabacloud_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_alibabacloud' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_alibabacloud(task_type: 'foo', alibabacloud_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_alibabacloud(task_type: 'foo', body: {}, alibabacloud_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb index 23d5b57c39..eeded5052b 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { amazonbedrock_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_amazonbedrock' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_amazonbedrock(task_type: 'foo', amazonbedrock_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_amazonbedrock(task_type: 'foo', body: {}, amazonbedrock_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_amazonsagemaker_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_amazonsagemaker_spec.rb index 2d5a686e43..4865779c25 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_amazonsagemaker_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_amazonsagemaker_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { amazonsagemaker_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_amazonsagemaker' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_amazonsagemaker(task_type: 'foo', amazonsagemaker_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_amazonsagemaker(task_type: 'foo', body: {}, amazonsagemaker_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb index 3f4c22cbba..b35a55ea07 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { anthropic_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_anthropic' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_anthropic(task_type: 'foo', anthropic_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_anthropic(task_type: 'foo', body: {}, anthropic_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb index add3ed7eec..aba9422729 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { azureaistudio_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_azureaistudio' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_azureaistudio(task_type: 'foo', azureaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_azureaistudio(task_type: 'foo', body: {}, azureaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb index ca0ade65b7..ed395e2513 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { azureopenai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_azureopenai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_azureopenai(task_type: 'foo', azureopenai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_azureopenai(task_type: 'foo', body: {}, azureopenai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb index 7eb82de752..dc5d851684 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { cohere_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_cohere' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_cohere(task_type: 'foo', cohere_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_cohere(task_type: 'foo', body: {}, cohere_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_contextualai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_contextualai_spec.rb index 092f9508e5..d83027316e 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_contextualai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_contextualai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { contextualai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_contextualai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_contextualai(task_type: 'foo', contextualai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_contextualai(task_type: 'foo', body: {}, contextualai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb index a409676f1b..ea3da2d7d7 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/baz', {}, - nil, + {}, {}, { defined_params: { custom_inference_id: 'baz', task_type: 'foo' }, endpoint: 'inference.put_custom' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_custom(task_type: 'foo', custom_inference_id: 'baz')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_custom(task_type: 'foo', body: {}, custom_inference_id: 'baz')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb index 25cbe4e72e..d0e15fb57a 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { deepseek_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_deepseek' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_deepseek(task_type: 'foo', deepseek_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_deepseek(task_type: 'foo', body: {}, deepseek_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb index e91a89c850..1dd95845ea 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { elasticsearch_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_elasticsearch' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_elasticsearch(task_type: 'foo', elasticsearch_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_elasticsearch(task_type: 'foo', body: {}, elasticsearch_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb index 1862e22721..eb18eaa0e8 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { elser_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_elser' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_elser(task_type: 'foo', elser_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_elser(task_type: 'foo', body: {}, elser_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb index 22c5284990..a8ced651f0 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { googleaistudio_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_googleaistudio' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_googleaistudio(task_type: 'foo', googleaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_googleaistudio(task_type: 'foo', body: {}, googleaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb index ccf6c883bf..b4c37355fa 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { googlevertexai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_googlevertexai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_googlevertexai(task_type: 'foo', googlevertexai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_googlevertexai(task_type: 'foo', body: {}, googlevertexai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb index 8feb11c28e..b23971a08c 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { huggingface_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_hugging_face' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_hugging_face(task_type: 'foo', huggingface_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_hugging_face(task_type: 'foo', body: {}, huggingface_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb index bcbf0e0f00..630b09f162 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { jinaai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_jinaai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_jinaai(task_type: 'foo', jinaai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_jinaai(task_type: 'foo', body: {}, jinaai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_llama_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_llama_spec.rb index dc5623d513..28253622be 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_llama_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_llama_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { llama_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_llama' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_llama(task_type: 'foo', llama_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_llama(task_type: 'foo', body: {}, llama_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb index 2d8d8dbd3f..6485a6f6ae 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { mistral_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_mistral' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_mistral(task_type: 'foo', mistral_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_mistral(task_type: 'foo', body: {}, mistral_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb index b58dd6e568..a108190747 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { openai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_openai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_openai(task_type: 'foo', openai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_openai(task_type: 'foo', body: {}, openai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb index 8bac99b82d..a4417167fc 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { voyageai_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_voyageai' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_voyageai(task_type: 'foo', voyageai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_voyageai(task_type: 'foo', body: {}, voyageai_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb index 44245b8b02..19b055c06b 100644 --- a/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb @@ -23,7 +23,7 @@ 'PUT', '_inference/foo/bar', {}, - nil, + {}, {}, { defined_params: { watsonx_inference_id: 'bar', task_type: 'foo' }, endpoint: 'inference.put_watsonx' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.put_watsonx(task_type: 'foo', watsonx_inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.put_watsonx(task_type: 'foo', body: {}, watsonx_inference_id: 'bar')).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb b/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb index 7417cd74fa..b07793a6b6 100644 --- a/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb @@ -23,13 +23,13 @@ 'POST', '_inference/rerank/foo', {}, - nil, + {}, {}, { defined_params: { inference_id: 'foo' }, endpoint: 'inference.rerank' } ] end it 'performs the request' do - expect(client_double.inference.rerank(inference_id: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.inference.rerank(inference_id: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb b/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb index 856dface5a..3aa98c4911 100644 --- a/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb @@ -23,13 +23,13 @@ 'POST', '_inference/sparse_embedding/foo', {}, - nil, + {}, {}, { defined_params: { inference_id: 'foo' }, endpoint: 'inference.sparse_embedding' } ] end it 'performs the request' do - expect(client_double.inference.sparse_embedding(inference_id: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.inference.sparse_embedding(inference_id: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb index 542b1d9941..fcd887a7e0 100644 --- a/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb @@ -23,13 +23,13 @@ 'POST', '_inference/completion/foo/_stream', {}, - nil, + {}, {}, { defined_params: { inference_id: 'foo' }, endpoint: 'inference.stream_completion' } ] end it 'performs the request' do - expect(client_double.inference.stream_completion(inference_id: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.inference.stream_completion(inference_id: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb b/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb index e97fda5865..455c9a3fc4 100644 --- a/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb @@ -23,13 +23,13 @@ 'POST', '_inference/text_embedding/foo', {}, - nil, + {}, {}, { defined_params: { inference_id: 'foo' }, endpoint: 'inference.text_embedding' } ] end it 'performs the request' do - expect(client_double.inference.text_embedding(inference_id: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.inference.text_embedding(inference_id: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/license/post_spec.rb b/elasticsearch-api/spec/unit/actions/license/post_spec.rb index 7805b8824b..93558da1ae 100644 --- a/elasticsearch-api/spec/unit/actions/license/post_spec.rb +++ b/elasticsearch-api/spec/unit/actions/license/post_spec.rb @@ -23,13 +23,13 @@ 'PUT', '_license', { }, - nil, + {}, {}, { endpoint: 'license.post' } ] end it 'performs the request' do - expect(client_double.license.post).to be_a Elasticsearch::API::Response + expect(client_double.license.post(body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb b/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb index 3636a9c490..a1e73a1ca9 100644 --- a/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb +++ b/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb @@ -23,13 +23,13 @@ 'POST', 'foo/_pit', {}, - nil, + {}, {}, { defined_params: { index: 'foo' }, endpoint: 'open_point_in_time' } ] end it 'performs the request' do - expect(client_double.open_point_in_time(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.open_point_in_time(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/scroll_spec.rb b/elasticsearch-api/spec/unit/actions/scroll_spec.rb index d7b2b3aee4..58839988f6 100644 --- a/elasticsearch-api/spec/unit/actions/scroll_spec.rb +++ b/elasticsearch-api/spec/unit/actions/scroll_spec.rb @@ -21,17 +21,17 @@ context 'with scroll_id as a param' do let(:expected_args) do [ - 'GET', + 'POST', '_search/scroll', {}, - nil, + {}, {}, { endpoint: 'scroll' } ] end it 'performs the request' do - expect(client_double.scroll(scroll_id: 'cXVlcn...')).to be_a Elasticsearch::API::Response + expect(client_double.scroll(scroll_id: 'cXVlcn...', body: {})).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/search_spec.rb b/elasticsearch-api/spec/unit/actions/search_spec.rb index 02e10edabe..282f087039 100644 --- a/elasticsearch-api/spec/unit/actions/search_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_spec.rb @@ -28,10 +28,10 @@ { endpoint: 'search' } ] end - let(:method) { 'GET' } + let(:method) { 'POST' } let(:body) do - nil + {} end let(:params) do @@ -43,7 +43,7 @@ end it 'has a default value for index' do - expect(client_double.search()) + expect(client_double.search(body: {})) end context 'when a request definition is specified' do @@ -78,7 +78,7 @@ end it 'performs the request' do - expect(client_double.search(index: 'foo')) + expect(client_double.search(index: 'foo', body: {})) end end @@ -99,7 +99,7 @@ end it 'performs the request' do - expect(client_double.search(index: ['foo', 'bar'])) + expect(client_double.search(index: ['foo', 'bar'], body: {})) end end @@ -113,7 +113,7 @@ end it 'performs the request' do - expect(client_double.search(search_type: 'count')) + expect(client_double.search(search_type: 'count', body: {})) end end end diff --git a/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb b/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb index a183a53c31..7d8be99b2d 100644 --- a/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb +++ b/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb @@ -29,25 +29,10 @@ ] end - context 'without a body' do - let(:method) { 'GET' } - let(:body) { nil } + let(:method) { 'POST' } + let(:body) { {} } - it 'performs a GET request' do - expect(client_double.terms_enum(index: 'foo')).to be_a Elasticsearch::API::Response - end - end - - context 'with a body' do - let(:method) { 'POST' } - let(:body) { {} } - - it 'performs a POST request' do - expect(client_double.terms_enum(index: 'foo', body: body)).to be_a Elasticsearch::API::Response - end - end - - it 'requires the :index argument' do - expect { client.terms_enum }.to raise_exception(ArgumentError) + it 'performs a POST request' do + expect(client_double.terms_enum(index: 'foo', body: body)).to be_a Elasticsearch::API::Response end end diff --git a/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb b/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb index b67daa0b6c..0165a001c5 100644 --- a/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb +++ b/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb @@ -23,13 +23,13 @@ 'POST', 'foo/_update_by_query', {}, - nil, + {}, {}, { defined_params: { index: 'foo' }, endpoint: 'update_by_query' } ] end it 'performs the request' do - expect(client_double.update_by_query(index: 'foo')).to be_a Elasticsearch::API::Response + expect(client_double.update_by_query(index: 'foo', body: {})).to be_a Elasticsearch::API::Response end end From 6a5cf11c82b81c0b6f2385601403e2284621a536 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 10 Oct 2025 16:58:03 +0100 Subject: [PATCH 3/3] [Client] Updates elasticsearch tests for APIs with required body --- .../elasticsearch_product_validation_spec.rb | 16 +++++++-------- elasticsearch/spec/unit/headers_spec.rb | 20 +++++++++---------- elasticsearch/spec/unit/opaque_id_spec.rb | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb b/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb index 2b8c6e9856..c8434dd5cd 100644 --- a/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb +++ b/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb @@ -21,11 +21,11 @@ describe 'Elasticsearch: Validation' do let(:host) { 'http://localhost:9200' } let(:count_request_stub) do - stub_request(:get, "#{host}/_count") - .to_return(status: status, body: nil, headers: headers) + stub_request(:post, "#{host}/_count") + .to_return(status: status, body: '', headers: headers) end let(:status) { 200 } - let(:body) { nil } + let(:body) { '' } let(:headers) { {} } let(:client) { Elasticsearch::Client.new } @@ -39,7 +39,7 @@ expect(client.instance_variable_get('@verified')).to be false count_request_stub expect do - client.count + client.count(body: '') end.to raise_error Elastic::Transport::Transport::Errors::Unauthorized expect(client.instance_variable_get('@verified')).to be true @@ -61,7 +61,7 @@ expect(client.instance_variable_get('@verified')).to be false count_request_stub expect do - client.count + client.count(body: '') end.to raise_error Elastic::Transport::Transport::Errors::Forbidden expect(client.instance_variable_get('@verified')).to be true @@ -83,7 +83,7 @@ expect(client.instance_variable_get('@verified')).to be false count_request_stub expect do - client.count + client.count(body: '') end.to raise_error Elastic::Transport::Transport::Errors::RequestEntityTooLarge expect(client.instance_variable_get('@verified')).to be true @@ -107,7 +107,7 @@ expect(client.instance_variable_get('@verified')).to be false count_request_stub expect do - client.count + client.count(body: '') end.to raise_error Elastic::Transport::Transport::Errors::ServiceUnavailable expect(client.instance_variable_get('@verified')).to be false @@ -131,7 +131,7 @@ it 'Makes requests and passes validation' do expect(client.instance_variable_get('@verified')).to be false count_request_stub - client.count + client.count(body: '') expect(client.instance_variable_get('@verified')).to be true end end diff --git a/elasticsearch/spec/unit/headers_spec.rb b/elasticsearch/spec/unit/headers_spec.rb index 3751c74488..803e604d02 100644 --- a/elasticsearch/spec/unit/headers_spec.rb +++ b/elasticsearch/spec/unit/headers_spec.rb @@ -24,9 +24,9 @@ it 'performs the request with the header' do allow(client).to receive(:perform_request) { OpenStruct.new(body: '') } - expect { client.search(headers: headers) }.not_to raise_error + expect { client.search(headers: headers, body: '') }.not_to raise_error expect(client).to have_received(:perform_request) - .with('GET', '_search', {}, nil, headers, { endpoint: 'search' }) + .with('POST', '_search', {}, '', headers, { endpoint: 'search' }) end end @@ -47,9 +47,9 @@ expect_any_instance_of(Faraday::Connection) .to receive(:run_request) - .with(:get, 'http://localhost:9200/_search', nil, expected_headers) { OpenStruct.new(body: '') } + .with(:post, 'http://localhost:9200/_search', '', expected_headers) { OpenStruct.new(body: '') } - client.search(headers: param_headers) + client.search(headers: param_headers, body: '') end end @@ -73,8 +73,8 @@ expect_any_instance_of(Faraday::Connection) .to receive(:run_request) - .with(:get, 'http://localhost:9200/_search', nil, connection_headers) { OpenStruct.new(body: '') } - client.search + .with(:post, 'http://localhost:9200/_search', '', connection_headers) { OpenStruct.new(body: '') } + client.search(body: '') end end @@ -98,8 +98,8 @@ expect_any_instance_of(Faraday::Connection) .to receive(:run_request) - .with(:get, 'http://localhost:9200/_search', nil, connection_headers) { OpenStruct.new(body: '') } - client.search + .with(:post, 'http://localhost:9200/_search', '', connection_headers) { OpenStruct.new(body: '') } + client.search(body: '') end end @@ -117,8 +117,8 @@ expect_any_instance_of(Faraday::Connection) .to receive(:run_request) - .with(:get, 'http://localhost:9200/_search', nil, expected_headers) { OpenStruct.new(body: '') } - client.search + .with(:post, 'http://localhost:9200/_search', '', expected_headers) { OpenStruct.new(body: '') } + client.search(body: '') end end end diff --git a/elasticsearch/spec/unit/opaque_id_spec.rb b/elasticsearch/spec/unit/opaque_id_spec.rb index 09e1a5232d..19a122234a 100644 --- a/elasticsearch/spec/unit/opaque_id_spec.rb +++ b/elasticsearch/spec/unit/opaque_id_spec.rb @@ -27,9 +27,9 @@ context 'when x-opaque-id is set' do it 'uses x-opaque-id on a request' do - client.search(opaque_id: '12345') + client.search(opaque_id: '12345', body: '') expect(transport).to have_received(:perform_request) - .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => '12345' }, {:endpoint=>"search"}) + .with('POST', '_search', {}, '', { 'X-Opaque-Id' => '12345' }, {:endpoint=>"search"}) end end @@ -40,9 +40,9 @@ end it 'uses x-opaque-id on a request' do - expect { client.search(opaque_id: '12345') }.not_to raise_error + expect { client.search(opaque_id: '12345', body: '') }.not_to raise_error expect(transport).to have_received(:perform_request) - .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => 'elastic_cloud12345' }, {:endpoint=>"search"}) + .with('POST', '_search', {}, '', { 'X-Opaque-Id' => 'elastic_cloud12345' }, {:endpoint=>"search"}) end end end