Class: Sensit::Api::Percolator
- Inherits:
-
Object
- Object
- Sensit::Api::Percolator
- Defined in:
- lib/sensit/api/percolator.rb
Overview
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
Instance Method Summary collapse
-
#create(name, query, options = {}) ⇒ Object
Create a percolator on the associated Topic with the specified name and query.
-
#delete(options = {}) ⇒ Object
Delete a percolator on the associated topic.
-
#find(options = {}) ⇒ Object
Return a specific percolator of the associated Topic by Id.
-
#initialize(topic_id, id, client) ⇒ Percolator
constructor
A new instance of Percolator.
-
#list(options = {}) ⇒ Object
Returns a list or percolators for a given topic.
-
#update(query, options = {}) ⇒ Object
Update the query for a specific percolator.
Constructor Details
#initialize(topic_id, id, client) ⇒ Percolator
Returns a new instance of Percolator.
11 12 13 14 15 |
# File 'lib/sensit/api/percolator.rb', line 11 def initialize(topic_id, id, client) @topic_id = topic_id @id = id @client = client end |
Instance Method Details
#create(name, query, options = {}) ⇒ Object
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
name - The time zone of the time. Defaults to UTC query - A hash of data to be stored
44 45 46 47 48 49 50 51 52 |
# File 'lib/sensit/api/percolator.rb', line 44 def create(name, query, = {}) body = .has_key?(:body) ? [:body] : {} body[:name] = name body[:query] = query response = @client.post "/topics/#{@topic_id}/percolators", body, return response end |
#delete(options = {}) ⇒ Object
Delete a percolator on the associated topic. Requires authorization of manage_any_percolators, or manage_application_percolators. ‘/topics/:topic_id/percolators/:id’ DELETE
70 71 72 73 74 75 76 |
# File 'lib/sensit/api/percolator.rb', line 70 def delete( = {}) body = .has_key?(:body) ? [:body] : {} response = @client.delete "/topics/#{@topic_id}/percolators/#{@id}", body, return response end |
#find(options = {}) ⇒ Object
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
31 32 33 34 35 36 37 |
# File 'lib/sensit/api/percolator.rb', line 31 def find( = {}) body = .has_key?(:query) ? [:query] : {} response = @client.get "/topics/#{@topic_id}/percolators/#{@id}", body, return response end |
#list(options = {}) ⇒ Object
Returns a list or percolators for a given topic. Requires authorization of read_any_percolators, or read_application_percolators. ‘/topics/:topic_id/percolators’ GET
20 21 22 23 24 25 26 |
# File 'lib/sensit/api/percolator.rb', line 20 def list( = {}) body = .has_key?(:query) ? [:query] : {} response = @client.get "/topics/#{@topic_id}/percolators", body, return response end |
#update(query, options = {}) ⇒ Object
Update the query for a specific percolator. Requires authorization of manage_any_percolators, or manage_application_percolators. ‘/topics/:topic_id/percolators/:id’ PUT
query - A hash of data to be stored
58 59 60 61 62 63 64 65 |
# File 'lib/sensit/api/percolator.rb', line 58 def update(query, = {}) body = .has_key?(:body) ? [:body] : {} body[:query] = query response = @client.put "/topics/#{@topic_id}/percolators/#{@id}", body, return response end |