Skip to content

Commit 2790b49

Browse files
committed
[API] Updates transform.preview_transform, adds body
1 parent 3019c45 commit 2790b49

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/transform/preview_transform.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,30 @@ module Transform
2222
module Actions
2323
# Previews a transform.
2424
#
25+
# @option arguments [String] :transform_id The id of the transform to preview.
2526
# @option arguments [Hash] :headers Custom HTTP headers
26-
# @option arguments [Hash] :body The definition for the transform to preview (*Required*)
27+
# @option arguments [Hash] :body The definition for the transform to preview
2728
#
2829
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/preview-transform.html
2930
#
3031
def preview_transform(arguments = {})
31-
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
32-
3332
headers = arguments.delete(:headers) || {}
3433

3534
arguments = arguments.clone
3635

37-
method = Elasticsearch::API::HTTP_POST
38-
path = "_transform/_preview"
36+
_transform_id = arguments.delete(:transform_id)
37+
38+
method = if arguments[:body]
39+
Elasticsearch::API::HTTP_POST
40+
else
41+
Elasticsearch::API::HTTP_GET
42+
end
43+
44+
path = if _transform_id
45+
"_transform/#{Elasticsearch::API::Utils.__listify(_transform_id)}/_preview"
46+
else
47+
"_transform/_preview"
48+
end
3949
params = {}
4050

4151
body = arguments[:body]

0 commit comments

Comments
 (0)