Skip to content

Commit a446ded

Browse files
committed
[API] Generator: Use full namespace for Utils only in xpack
1 parent d98ba07 commit a446ded

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

elasticsearch-api/utils/thor/generate_source.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __http_path
171171
def __parse_path(path)
172172
path.gsub(/^\//, '')
173173
.gsub(/\/$/, '')
174-
.gsub('{', '#{Elasticsearch::API::Utils.__listify(_')
174+
.gsub('{', "\#{#{__utils}.__listify(_")
175175
.gsub('}', ')}')
176176
end
177177

@@ -237,6 +237,10 @@ def print_tree
237237
say_status('tree', lines.first + "\n" + lines[1, lines.size].map { |l| ' ' * 14 + l }.join("\n"))
238238
end
239239

240+
def __utils
241+
@xpack ? 'Elasticsearch::API::Utils' : 'Utils'
242+
end
243+
240244
def run_rubocop
241245
system("rubocop --format autogenconf -x #{FilesHelper::output_dir(@xpack)}")
242246
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<%- end -%>
2626
<%= ' '*(@namespace_depth+4) %>path = <%= @http_path %>
2727
<%- unless @params.empty? -%>
28-
<%= ' '*(@namespace_depth+4) %>params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
28+
<%= ' '*(@namespace_depth+4) %>params = <%= __utils %>.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
2929
<%- else -%>
3030
<%= ' '*(@namespace_depth+4) %>params = {}
3131
<%- end -%>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ when 'mtermvectors'
1010
<%- when 'cluster.reroute', 'cluster.put_settings' %>
1111
body = arguments[:body] || {}
1212
<%- when 'ml.find_file_structure' %>
13-
body = Elasticsearch::API::Utils.__bulkify(arguments.delete(:body))
13+
body = <%= __utils %>.__bulkify(arguments.delete(:body))
1414
<%- else -%>
1515
<%= ' '*(@namespace_depth+3) %>body = <%= @spec['body'].nil? ? 'nil' : 'arguments[:body]' %>
1616
<%- end -%>
@@ -21,12 +21,12 @@ when 'mtermvectors'
2121
<%= ping_perform_request %>
2222
<%- else -%>
2323
<%- if needs_ignore_404?(@endpoint_name) %>
24-
Elasticsearch::API::Utils.__rescue_from_not_found do
24+
<%= __utils %>.__rescue_from_not_found do
2525
perform_request(method, path, params, body).status == 200 ? true : false
2626
end
2727
<%- elsif needs_complex_ignore_404?(@endpoint_name) -%>
2828
if Array(arguments[:ignore]).include?(404)
29-
Elasticsearch::API::Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
29+
<%= __utils %>.__rescue_from_not_found { perform_request(method, path, params, body).body }
3030
else
3131
perform_request(method, path, params, body).body
3232
end

0 commit comments

Comments
 (0)