Skip to content

Commit 614161b

Browse files
committed
Update method template to handle create endpoint forwarding to index
1 parent 8386ee8 commit 614161b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

elasticsearch-api/utils/endpoint_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def initialize(filepath)
3939
@params = @spec['params'] || {}
4040
@paths = @spec['url']['paths'].map { |b| b['path'] } if @spec['url']
4141
@path_params = path_variables.flatten.uniq.collect(&:to_sym)
42-
@perform_request_opts = { endpoint: @endpoint_name }
4342
@http_method = parse_http_method(@spec)
4443
@deprecation_note = @spec['url']['paths'].last&.[]('deprecated')
4544
@http_path = parse_http_path(@paths)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Elasticsearch
2424
<%= ERB.new(File.new("./thor/templates/_documentation_top.erb").read, trim_mode: '-').result(binding) -%>
2525
<%# Method definition -%>
2626
<%= ' '*(@spec.namespace_depth+3) -%>def <%= @spec.method_name %>(arguments = {})
27-
request_opts = <%= @spec.perform_request_opts %>
27+
request_opts = { endpoint: arguments[:endpoint] || "<%= @spec.endpoint_name %>" }
2828
<%- unless @spec.path_params.empty? %>
2929
defined_params =<%= @spec.path_params %>.inject({}) do |set_variables, variable|
3030
set_variables[variable] = arguments[variable] if arguments.key?(variable)
@@ -34,6 +34,7 @@ request_opts = <%= @spec.perform_request_opts %>
3434
<%- end %>
3535
<%- %>
3636
<%- if @spec.endpoint_name == 'create' -%>
37+
<%= ' '*(@spec.namespace_depth+3) %>arguments.update endpoint: 'create'
3738
<%= ' '*(@spec.namespace_depth+3) %>if arguments[:id]
3839
<%= ' '*(@spec.namespace_depth+3) %> index arguments.update op_type: 'create'
3940
<%= ' '*(@spec.namespace_depth+3) %>else

0 commit comments

Comments
 (0)