Skip to content

Commit

Permalink
# Removed empty query params list
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong committed Dec 16, 2024
1 parent 4decf22 commit da8ee14
Show file tree
Hide file tree
Showing 179 changed files with 184 additions and 709 deletions.
4 changes: 4 additions & 0 deletions api_generator/lib/generators/action_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def url
api_path.build
end

def has_query
@action.query_params.any?
end

def http_verb
case @action.http_verbs.sort
when %w[GET POST]
Expand Down
4 changes: 3 additions & 1 deletion api_generator/lib/templates/action.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ module OpenSearch
method = {{{http_verb}}}
url = {{{url}}}

Utils.validate_query_params args, {{valid_params_constant_name}}
Utils.validate_query_params args{{#has_query}}, {{valid_params_constant_name}}{{/has_query}}
{{{perform_request}}}
end
{{#has_query}}

{{{valid_params_constant_name}}} = Set.new(%w[
{{#query_params}}
{{{name}}}
{{/query_params}}
]).freeze
{{/has_query}}
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/asynchronous_search/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ def delete(args = {})
method = 'DELETE'
url = ['_plugins/_asynchronous_search', _id].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, DELETE_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/asynchronous_search/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ def get(args = {})
method = 'GET'
url = ['_plugins/_asynchronous_search', _id].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, GET_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/asynchronous_search/stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def stats(args = {})
method = 'GET'
url = '_plugins/_asynchronous_search/stats'

Utils.validate_query_params args, STATS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

STATS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/cat/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def help(args = {})
method = 'GET'
url = '_cat'

Utils.validate_query_params args, HELP_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

HELP_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/clear_scroll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ def clear_scroll(args = {})
method = 'DELETE'
url = ['_search/scroll', _scroll_id].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, CLEAR_SCROLL_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

CLEAR_SCROLL_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ def delete_decommission_awareness(args = {})
method = 'DELETE'
url = '_cluster/decommission/awareness'

Utils.validate_query_params args, DELETE_DECOMMISSION_AWARENESS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_DECOMMISSION_AWARENESS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def delete_weighted_routing(args = {})
method = 'DELETE'
url = '_cluster/routing/awareness/weights'

Utils.validate_query_params args, DELETE_WEIGHTED_ROUTING_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_WEIGHTED_ROUTING_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ def get_decommission_awareness(args = {})
method = 'GET'
url = ['_cluster/decommission/awareness', _awareness_attribute_name, '_status'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, GET_DECOMMISSION_AWARENESS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_DECOMMISSION_AWARENESS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/cluster/get_weighted_routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ def get_weighted_routing(args = {})
method = 'GET'
url = ['_cluster/routing/awareness', _attribute, 'weights'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, GET_WEIGHTED_ROUTING_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_WEIGHTED_ROUTING_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ def put_decommission_awareness(args = {})
method = 'PUT'
url = ['_cluster/decommission/awareness', _awareness_attribute_name, _awareness_attribute_value].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, PUT_DECOMMISSION_AWARENESS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

PUT_DECOMMISSION_AWARENESS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/cluster/put_weighted_routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ def put_weighted_routing(args = {})
method = 'PUT'
url = ['_cluster/routing/awareness', _attribute, 'weights'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, PUT_WEIGHTED_ROUTING_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

PUT_WEIGHTED_ROUTING_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/cluster/remote_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def remote_info(args = {})
method = 'GET'
url = '_remote/info'

Utils.validate_query_params args, REMOTE_INFO_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

REMOTE_INFO_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def list_dangling_indices(args = {})
method = 'GET'
url = '_dangling'

Utils.validate_query_params args, LIST_DANGLING_INDICES_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

LIST_DANGLING_INDICES_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/delete_all_pits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ def delete_all_pits(args = {})
method = 'DELETE'
url = '_search/point_in_time/_all'

Utils.validate_query_params args, DELETE_ALL_PITS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_ALL_PITS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/delete_pit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def delete_pit(args = {})
method = 'DELETE'
url = '_search/point_in_time'

Utils.validate_query_params args, DELETE_PIT_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_PIT_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/flow_framework/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ def get(args = {})
method = 'GET'
url = ['_plugins/_flow_framework/workflow', _workflow_id].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, GET_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/flow_framework/provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ def provision(args = {})
method = 'POST'
url = ['_plugins/_flow_framework/workflow', _workflow_id, '_provision'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, PROVISION_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

PROVISION_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/flow_framework/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def search(args = {})
method = body ? 'POST' : 'GET'
url = '_plugins/_flow_framework/workflow/_search'

Utils.validate_query_params args, SEARCH_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

SEARCH_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/flow_framework/search_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def search_state(args = {})
method = body ? 'POST' : 'GET'
url = '_plugins/_flow_framework/workflow/state/_search'

Utils.validate_query_params args, SEARCH_STATE_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

SEARCH_STATE_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/get_all_pits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def get_all_pits(args = {})
method = 'GET'
url = '_search/point_in_time/_all'

Utils.validate_query_params args, GET_ALL_PITS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_ALL_PITS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/get_script_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def get_script_context(args = {})
method = 'GET'
url = '_script_context'

Utils.validate_query_params args, GET_SCRIPT_CONTEXT_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_SCRIPT_CONTEXT_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/get_script_languages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def get_script_languages(args = {})
method = 'GET'
url = '_script_language'

Utils.validate_query_params args, GET_SCRIPT_LANGUAGES_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

GET_SCRIPT_LANGUAGES_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/indices/analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ def analyze(args = {})
method = body ? 'POST' : 'GET'
url = [_index, '_analyze'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, ANALYZE_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

ANALYZE_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/indices/create_data_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ def create_data_stream(args = {})
method = 'PUT'
url = ['_data_stream', _name].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, CREATE_DATA_STREAM_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

CREATE_DATA_STREAM_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/indices/data_streams_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def data_streams_stats(args = {})
method = 'GET'
url = ['_data_stream', _name, '_stats'].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, DATA_STREAMS_STATS_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_request(method, url, args, body, headers).body
end

DATA_STREAMS_STATS_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions lib/opensearch/api/actions/indices/delete_data_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ def delete_data_stream(args = {})
method = 'DELETE'
url = ['_data_stream', _name].filter(&:present?).join('/').squeeze('/')

Utils.validate_query_params args, DELETE_DATA_STREAM_QUERY_PARAMS
Utils.validate_query_params args
transport.perform_delete_request method, url, args, body, headers, ignore.include?(404)
end

DELETE_DATA_STREAM_QUERY_PARAMS = Set.new(%w[
]).freeze
end
end
end
Expand Down
Loading

0 comments on commit da8ee14

Please sign in to comment.