Skip to content

Commit 3aeebf4

Browse files
committed
[API] Generator: Updates code to return Elasticsearch::API:Response
1 parent bb51be1 commit 3aeebf4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

elasticsearch-api/utils/thor/templates/_perform_request.erb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,32 @@
1919
<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%>
2020
<%= self.send("#{@method_name}_body_helper".to_s) %>
2121
headers.merge!("Content-Type" => "application/x-ndjson")
22-
<%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, headers).body
22+
Elasticsearch::API::Response.new(
23+
perform_request(method, path, params, payload, headers)
24+
)
2325
<%- elsif @method_name == 'ping' -%>
2426
<%= ping_perform_request %>
2527
<%- else -%>
2628
<%- if needs_ignore_404?(@endpoint_name) %>
2729
Utils.__rescue_from_not_found do
28-
perform_request(method, path, params, body, headers).status == 200 ? true : false
30+
perform_request(method, path, params, body, headers).status == 200 ? true : false
2931
end
3032
<%- elsif needs_complex_ignore_404?(@endpoint_name) -%>
3133
if Array(arguments[:ignore]).include?(404)
32-
Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
34+
Utils.__rescue_from_not_found {
35+
Elasticsearch::API::Response.new(
36+
perform_request(method, path, params, body, headers)
37+
)
38+
}
3339
else
34-
perform_request(method, path, params, body, headers).body
40+
Elasticsearch::API::Response.new(
41+
perform_request(method, path, params, body, headers)
42+
)
3543
end
3644
<%- else -%>
37-
perform_request(method, path, params, body, headers).body
45+
Elasticsearch::API::Response.new(
46+
perform_request(method, path, params, body, headers)
47+
)
3848
<%- end -%>
3949
<%- end -%>
4050
<%= ' '*(@namespace_depth+3) %>end

0 commit comments

Comments
 (0)