Skip to content

Commit 7b76f68

Browse files
committed
[API] Update methods: when body is required, always use POST
1 parent 682b4cd commit 7b76f68

File tree

6 files changed

+32
-62
lines changed

6 files changed

+32
-62
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,12 @@ def simulate(arguments = {})
3737

3838
_id = arguments.delete(:id)
3939

40-
method = if arguments[:body]
41-
Elasticsearch::API::HTTP_POST
40+
method = Elasticsearch::API::HTTP_POST
41+
path = if _id
42+
"_ingest/pipeline/#{Utils.__listify(_id)}/_simulate"
4243
else
43-
Elasticsearch::API::HTTP_GET
44+
"_ingest/pipeline/_simulate"
4445
end
45-
46-
path = if _id
47-
"_ingest/pipeline/#{Utils.__listify(_id)}/_simulate"
48-
else
49-
"_ingest/pipeline/_simulate"
50-
end
5146
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
5247

5348
body = arguments[:body]

elasticsearch-api/lib/elasticsearch/api/actions/mget.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,14 @@ def mget(arguments = {})
5151

5252
_type = arguments.delete(:type)
5353

54-
method = if arguments[:body]
55-
Elasticsearch::API::HTTP_POST
54+
method = Elasticsearch::API::HTTP_POST
55+
path = if _index && _type
56+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mget"
57+
elsif _index
58+
"#{Utils.__listify(_index)}/_mget"
5659
else
57-
Elasticsearch::API::HTTP_GET
60+
"_mget"
5861
end
59-
60-
path = if _index && _type
61-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mget"
62-
elsif _index
63-
"#{Utils.__listify(_index)}/_mget"
64-
else
65-
"_mget"
66-
end
6762
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
6863

6964
body = arguments[:body]

elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,14 @@ def msearch(arguments = {})
5252

5353
_type = arguments.delete(:type)
5454

55-
method = if arguments[:body]
56-
Elasticsearch::API::HTTP_POST
55+
method = Elasticsearch::API::HTTP_POST
56+
path = if _index && _type
57+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch"
58+
elsif _index
59+
"#{Utils.__listify(_index)}/_msearch"
5760
else
58-
Elasticsearch::API::HTTP_GET
61+
"_msearch"
5962
end
60-
61-
path = if _index && _type
62-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch"
63-
elsif _index
64-
"#{Utils.__listify(_index)}/_msearch"
65-
else
66-
"_msearch"
67-
end
6863
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
6964

7065
body = arguments[:body]

elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,14 @@ def msearch_template(arguments = {})
5050

5151
_type = arguments.delete(:type)
5252

53-
method = if arguments[:body]
54-
Elasticsearch::API::HTTP_POST
53+
method = Elasticsearch::API::HTTP_POST
54+
path = if _index && _type
55+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch/template"
56+
elsif _index
57+
"#{Utils.__listify(_index)}/_msearch/template"
5558
else
56-
Elasticsearch::API::HTTP_GET
59+
"_msearch/template"
5760
end
58-
59-
path = if _index && _type
60-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch/template"
61-
elsif _index
62-
"#{Utils.__listify(_index)}/_msearch/template"
63-
else
64-
"_msearch/template"
65-
end
6661
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
6762

6863
body = arguments[:body]

elasticsearch-api/lib/elasticsearch/api/actions/rank_eval.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,12 @@ def rank_eval(arguments = {})
4343

4444
_index = arguments.delete(:index)
4545

46-
method = if arguments[:body]
47-
Elasticsearch::API::HTTP_POST
46+
method = Elasticsearch::API::HTTP_POST
47+
path = if _index
48+
"#{Utils.__listify(_index)}/_rank_eval"
4849
else
49-
Elasticsearch::API::HTTP_GET
50+
"_rank_eval"
5051
end
51-
52-
path = if _index
53-
"#{Utils.__listify(_index)}/_rank_eval"
54-
else
55-
"_rank_eval"
56-
end
5752
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
5853

5954
body = arguments[:body]

elasticsearch-api/lib/elasticsearch/api/actions/search_template.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,14 @@ def search_template(arguments = {})
6060

6161
_type = arguments.delete(:type)
6262

63-
method = if arguments[:body]
64-
Elasticsearch::API::HTTP_POST
63+
method = Elasticsearch::API::HTTP_POST
64+
path = if _index && _type
65+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search/template"
66+
elsif _index
67+
"#{Utils.__listify(_index)}/_search/template"
6568
else
66-
Elasticsearch::API::HTTP_GET
69+
"_search/template"
6770
end
68-
69-
path = if _index && _type
70-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search/template"
71-
elsif _index
72-
"#{Utils.__listify(_index)}/_search/template"
73-
else
74-
"_search/template"
75-
end
7671
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
7772

7873
body = arguments[:body]

0 commit comments

Comments
 (0)