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(percolator, 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(percolator, 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(percolator, 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
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)
43 44 45 46 47 48 49 50 |
# File 'lib/sensit/api/percolator.rb', line 43 def create(percolator, = {}) body = .has_key?(:body) ? [:body] : {} body[:percolator] = percolator 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
68 69 70 71 72 73 74 |
# File 'lib/sensit/api/percolator.rb', line 68 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(percolator, 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
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)
56 57 58 59 60 61 62 63 |
# File 'lib/sensit/api/percolator.rb', line 56 def update(percolator, = {}) body = .has_key?(:body) ? [:body] : {} body[:percolator] = percolator response = @client.put "/topics/#{@topic_id}/percolators/#{@id}", body, return response end |