Class: DataSift::Push
- Inherits:
-
ApiResource
- Object
- ApiResource
- DataSift::Push
- Defined in:
- lib/push.rb
Overview
Push is a simple and robust mechanism for periodically delivering your data
directly to a given destination. Several widely adopted storage locations
are available including Amazon S3, (S)FTP, HTTP, DynamoDB, CouchDB,
MongoDB, Splunk, ElasticSearch and more! See
http://dev.datasift.com/docs/push/connectors
Constant Summary
Constants inherited from ApiResource
ApiResource::TLSv1, ApiResource::TLSv1_2
Constants included from DataSift
APPLICATION_JSON, DELETE, DETECT_DEAD_SOCKETS, GET, HEAD, IS_WINDOWS, KNOWN_SOCKETS, SOCKET_DETECTOR_TIMEOUT, VERSION, X_ANALYSIS_TASKS_QUEUED, X_ANALYSIS_TASKS_QUEUE_LIMIT, X_INSIGHT_TASKS_QUEUED, X_INSIGHT_TASKS_QUEUE_LIMIT, X_RATELIMIT_COST, X_RATELIMIT_LIMIT, X_RATELIMIT_REMAINING, X_TASKS_QUEUED, X_TASKS_QUEUE_LIMIT
Instance Method Summary collapse
-
#create(params) ⇒ Object
Create a new subscription to a live stream or historics query.
-
#delete(id) ⇒ Object
Deletes an existing push subscription.
-
#get(page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of all subscriptions within the given page constraints.
-
#get_by_hash(hash, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of the subscription with the given filter hash.
-
#get_by_historics_id(historics_id, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of the subscription with the given Historics ID.
-
#get_by_subscription(id) ⇒ Object
Get details of the subscription with the given ID.
-
#log(page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) ⇒ Object
Retrieve log messages for all subscriptions.
-
#log_for(id, page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) ⇒ Object
Retrieve log messages for a specific subscription.
-
#pause(id) ⇒ Object
Pause a subscription and buffer the data for up to an hour.
-
#pull(id, size = 52_428_800, cursor = '', callback = nil) ⇒ Object
Pull data from a ‘pull’ type Push Subscription.
-
#resume(id) ⇒ Object
Resume a Push subscription that was previously paused.
-
#stop(id) ⇒ Object
Stop a Push subscription; you will not be able to resume this.
-
#update(params) ⇒ Object
Update the name or output parameters for an existing subscription.
-
#valid?(params, bool_response = true) ⇒ Boolean
Check that a Push subscription definition is valid.
Methods inherited from ApiResource
Methods included from DataSift
Constructor Details
This class inherits a constructor from DataSift::ApiResource
Instance Method Details
#create(params) ⇒ Object
Create a new subscription to a live stream or historics query. Possible
params are hash, historics_id, name, output_type, initial_status, start,
end and output_params.* where output_params.* depends on the output_type
for specific see the documentation at
http://dev.datasift.com/docs/rest-api/pushcreate For a list of available
connectors see http://dev.datasift.com/docs/push/connectors
29 30 31 |
# File 'lib/push.rb', line 29 def create(params) DataSift.request(:POST, 'push/create', @config, params) end |
#delete(id) ⇒ Object
Deletes an existing push subscription
70 71 72 73 74 |
# File 'lib/push.rb', line 70 def delete(id) params = {:id => id} requires params DataSift.request(:DELETE, 'push/delete', @config, params) end |
#get(page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of all subscriptions within the given page constraints
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/push.rb', line 183 def get(page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) params = { :page => page, :per_page => per_page, :order_by => order_by, :order_dir => order_dir, :include_finished => include_finished, :all => all } DataSift.request(:GET, 'push/get', @config, params) end |
#get_by_hash(hash, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of the subscription with the given filter hash
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/push.rb', line 132 def get_by_hash(hash, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) params = { :hash => hash } requires params params.merge!( :page => page, :per_page => per_page, :order_by => order_by, :order_dir => order_dir, :include_finished => include_finished, :all => all ) DataSift.request(:GET, 'push/get', @config, params) end |
#get_by_historics_id(historics_id, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) ⇒ Object
Get details of the subscription with the given Historics ID
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/push.rb', line 160 def get_by_historics_id(historics_id, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false) params = { :historics_id => historics_id, :page => page, :per_page => per_page, :order_by => order_by, :order_dir => order_dir, :include_finished => include_finished, :all => all } DataSift.request(:GET, 'push/get', @config, params) end |
#get_by_subscription(id) ⇒ Object
Get details of the subscription with the given ID
116 117 118 119 |
# File 'lib/push.rb', line 116 def get_by_subscription(id) params = { :id => id } DataSift.request(:GET, 'push/get', @config, params) end |
#log(page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) ⇒ Object
Retrieve log messages for all subscriptions
103 104 105 106 107 108 109 110 111 |
# File 'lib/push.rb', line 103 def log(page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) params = { :page => page, :per_page => per_page, :order_by => order_by, :order_dir => order_dir } DataSift.request(:GET, 'push/log', @config, params) end |
#log_for(id, page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) ⇒ Object
Retrieve log messages for a specific subscription
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/push.rb', line 83 def log_for(id, page = 1, per_page = 20, order_by = :request_time, order_dir = :desc) params = { :id => id } requires params params.merge!( :page => page, :per_page => per_page, :order_by => order_by, :order_dir => order_dir ) DataSift.request(:GET, 'push/log', @config, params) end |
#pause(id) ⇒ Object
Pause a subscription and buffer the data for up to an hour
43 44 45 46 47 |
# File 'lib/push.rb', line 43 def pause(id) params = { :id => id } requires params DataSift.request(:PUT, 'push/pause', @config, params) end |
#pull(id, size = 52_428_800, cursor = '', callback = nil) ⇒ Object
Pull data from a ‘pull’ type Push Subscription
203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/push.rb', line 203 def pull(id, size = 52_428_800, cursor = '', callback = nil) params = { :id => id } requires params params.merge!( :size => size, :cursor => cursor ) params.merge!({:on_interaction => callback}) unless callback.nil? DataSift.request(:GET, 'pull', @config, params, {}, 30, 30, true) end |
#resume(id) ⇒ Object
Resume a Push subscription that was previously paused
52 53 54 55 56 |
# File 'lib/push.rb', line 52 def resume(id) params = { :id => id } requires params DataSift.request(:PUT, 'push/resume', @config, params) end |
#stop(id) ⇒ Object
Stop a Push subscription; you will not be able to resume this
61 62 63 64 65 |
# File 'lib/push.rb', line 61 def stop(id) params = { :id => id } requires params DataSift.request(:PUT, 'push/stop', @config, params) end |
#update(params) ⇒ Object
Update the name or output parameters for an existing subscription
36 37 38 |
# File 'lib/push.rb', line 36 def update(params) DataSift.request(:POST, 'push/update', @config, params) end |
#valid?(params, bool_response = true) ⇒ Boolean
Check that a Push subscription definition is valid
15 16 17 18 19 |
# File 'lib/push.rb', line 15 def valid?(params, bool_response = true) requires params res = DataSift.request(:POST, 'push/validate', @config, params) bool_response ? res[:http][:status] == 200 : res end |