Module: Elasticsearch::API::QueryRules::Actions

Included in:
QueryRulesClient
Defined in:
lib/elasticsearch/api/namespace/query_rules.rb,
lib/elasticsearch/api/actions/query_rules/get_rule.rb,
lib/elasticsearch/api/actions/query_rules/put_rule.rb,
lib/elasticsearch/api/actions/query_rules/delete_rule.rb,
lib/elasticsearch/api/actions/query_rules/get_ruleset.rb,
lib/elasticsearch/api/actions/query_rules/put_ruleset.rb,
lib/elasticsearch/api/actions/query_rules/list_rulesets.rb,
lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb

Instance Method Summary collapse

Instance Method Details

#delete_rule(arguments = {}) ⇒ Object

Deletes an individual query rule within a ruleset.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset this rule exists in

  • :rule_id (String)

    The unique identifier of the rule to delete.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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 = {}) ⇒ Object

Deletes a query ruleset.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset to delete

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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 = {}

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

#get_rule(arguments = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset the rule exists within

  • :rule_id (String)

    The unique identifier of the rule to be retrieved.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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 = {}) ⇒ Object

Returns the details about a query ruleset.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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 = {}) ⇒ Object

Lists query rulesets.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :from (Integer)

    Starting offset (default: 0)

  • :size (Integer)

    specifies a max number of results to get (default: 100)

  • :headers (Hash)

    Custom HTTP headers

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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 = {}) ⇒ Object

Creates or updates a query rule within a ruleset.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the ruleset this rule should be added to. The ruleset will be created if it does not exist.

  • :rule_id (String)

    The unique identifier of the rule to be created or updated.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    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)

Raises:

  • (ArgumentError)

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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 = {}) ⇒ Object

Creates or updates a query ruleset.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the ruleset to be created or updated.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The query ruleset configuration, including ‘rules` (Required)

Raises:

  • (ArgumentError)

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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