class Sensit::Api::Percolator

A Percolator is a reverse query much like a match rule which is run whenever a new feed is added. These can be used to create alerts by causing the sensit to publish the feed that was just added. A percolator query is defined by a ‘name` and and valid `query` according to the according the the [elasticsearch Query DSL](www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html). For more information about Percolator queries please refer to the [elasticsearch percolator documentation](www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html).

topic_id - The key for the parent topic id - The name of the percolator query

Public Class Methods

new(topic_id, id, client) click to toggle source
# File lib/sensit/api/percolator.rb, line 11
def initialize(topic_id, id, client)
  @topic_id = topic_id
  @id = id
  @client = client
end

Public Instance Methods

create(percolator, options = {}) click to toggle source

Create a percolator on the associated Topic with the specified name and query. Requires authorization of manage_any_percolators, or manage_application_percolators. ‘/topics/:topic_id/percolators’ POST

percolator - A Hash containing ‘name`: The name of the percolator(required).`query`: The query hash according to the according the the [elasticsearch Query DSL](www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html)

# File lib/sensit/api/percolator.rb, line 43
def create(percolator, options = {})
  body = options.has_key?(:body) ? options[:body] : {}
  body[:percolator] = percolator

  response = @client.post "/topics/#{@topic_id}/percolators", body, options

  return response
end
delete(options = {}) click to toggle source

Delete a percolator on the associated topic. Requires authorization of manage_any_percolators, or manage_application_percolators. ‘/topics/:topic_id/percolators/:id’ DELETE

# File lib/sensit/api/percolator.rb, line 68
def delete(options = {})
  body = options.has_key?(:body) ? options[:body] : {}

  response = @client.delete "/topics/#{@topic_id}/percolators/#{@id}", body, options

  return response
end
find(options = {}) click to toggle source

Return a specific percolator of the associated Topic by Id. Requires authorization of read_any_percolators, or read_application_percolators. ‘/topics/:topic_id/percolators/:id’ GET

# File lib/sensit/api/percolator.rb, line 31
def find(options = {})
  body = options.has_key?(:query) ? options[:query] : {}

  response = @client.get "/topics/#{@topic_id}/percolators/#{@id}", body, options

  return response
end
list(options = {}) click to toggle source

Returns a list or percolators for a given topic. Requires authorization of read_any_percolators, or read_application_percolators. ‘/topics/:topic_id/percolators’ GET

# File lib/sensit/api/percolator.rb, line 20
def list(options = {})
  body = options.has_key?(:query) ? options[:query] : {}

  response = @client.get "/topics/#{@topic_id}/percolators", body, options

  return response
end
update(percolator, options = {}) click to toggle source

Update the query for a specific percolator. Requires authorization of manage_any_percolators, or manage_application_percolators. ‘/topics/:topic_id/percolators/:id’ PUT

percolator - A Hash containing the ‘query` hash according to the according the the [elasticsearch Query DSL](www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html)

# File lib/sensit/api/percolator.rb, line 56
def update(percolator, options = {})
  body = options.has_key?(:body) ? options[:body] : {}
  body[:percolator] = percolator

  response = @client.put "/topics/#{@topic_id}/percolators/#{@id}", body, options

  return response
end