module Elasticsearch::API::QueryRules::Actions

Public Instance Methods

delete_rule(arguments = {}) click to toggle source

Deletes an individual query rule within a ruleset.

@option arguments [String] :ruleset_id The unique identifier of the query ruleset this rule exists in @option arguments [String] :rule_id The unique identifier of the rule to delete. @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/delete-query-rule.html

# File lib/elasticsearch/api/actions/query_rules/delete_rule.rb, line 33
def delete_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_rule' }

  defined_params = %i[ruleset_id rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}/_rule/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
delete_ruleset(arguments = {}) click to toggle source

Deletes a query ruleset.

@option arguments [String] :ruleset_id The unique identifier of the query ruleset to delete @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/delete-query-ruleset.html

# File lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb, line 32
def delete_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}"
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end
get_rule(arguments = {}) click to toggle source

Returns the details about an individual query rule within a ruleset.

@option arguments [String] :ruleset_id The unique identifier of the query ruleset the rule exists within @option arguments [String] :rule_id The unique identifier of the rule to be retrieved. @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/get-query-rule.html

# File lib/elasticsearch/api/actions/query_rules/get_rule.rb, line 33
def get_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_rule' }

  defined_params = %i[ruleset_id rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}/_rule/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
get_ruleset(arguments = {}) click to toggle source

Returns the details about a query ruleset.

@option arguments [String] :ruleset_id The unique identifier of the query ruleset @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/get-query-ruleset.html

# File lib/elasticsearch/api/actions/query_rules/get_ruleset.rb, line 32
def get_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
list_rulesets(arguments = {}) click to toggle source

Lists query rulesets.

@option arguments [Integer] :from Starting offset (default: 0) @option arguments [Integer] :size specifies a max number of results to get (default: 100) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/list-query-rulesets.html

# File lib/elasticsearch/api/actions/query_rules/list_rulesets.rb, line 33
def list_rulesets(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.list_rulesets' }

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = nil

  method = Elasticsearch::API::HTTP_GET
  path   = '_query_rules'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
put_rule(arguments = {}) click to toggle source

Creates or updates a query rule within a ruleset.

@option arguments [String] :ruleset_id The unique identifier of the ruleset this rule should be added to. The ruleset will be created if it does not exist. @option arguments [String] :rule_id The unique identifier of the rule to be created or updated. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The query rule configuration, including the type of rule, the criteria to match the rule, and the action that should be taken if the rule matches. (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/put-query-rule.html

# File lib/elasticsearch/api/actions/query_rules/put_rule.rb, line 34
def put_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_rule' }

  defined_params = %i[ruleset_id rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}/_rule/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
put_ruleset(arguments = {}) click to toggle source

Creates or updates a query ruleset.

@option arguments [String] :ruleset_id The unique identifier of the ruleset to be created or updated. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The query ruleset configuration, including ‘rules` (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/put-query-ruleset.html

# File lib/elasticsearch/api/actions/query_rules/put_ruleset.rb, line 33
def put_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
test(arguments = {}) click to toggle source

Tests a query ruleset to identify the rules that would match input criteria This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [String] :ruleset_id The unique identifier of the ruleset to test. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The match criteria to test against the ruleset (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/test-query-ruleset.html

# File lib/elasticsearch/api/actions/query_rules/test.rb, line 37
def test(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.test' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_query_rules/#{Utils.__listify(_ruleset_id)}/_test"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end