class DataSift::Push

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

Public Instance Methods

create(params) click to toggle source

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 options 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

@param params [Hash] Hash of Push subscription parameters

# File lib/push.rb, line 29
def create(params)
  DataSift.request(:POST, 'push/create', @config, params)
end
delete(id) click to toggle source

Deletes an existing push subscription

@param id [String] ID of the Push subscription to delete

# 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) click to toggle source

Get details of all subscriptions within the given page constraints

@param page [Integer] Which page of logs to retreive @param per_page [Integer] How many logs to return per page @param order_by [String, Symbol] Which field to sort results by @param order_dir [String, Symbol] Order results in ascending or descending @param include_finished [Integer] Include Push subscriptions in a

'finished' state in your results

@param all [Boolean] Also include Push subscriptions created via the web

UI in your results
# 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) click to toggle source

Get details of the subscription with the given filter hash

@param hash [String] CSDL filter hash @param page [Integer] Which page of logs to retreive @param per_page [Integer] How many logs to return per page @param order_by [String, Symbol] Which field to sort results by @param order_dir [String, Symbol] Order results in ascending or descending @param include_finished [Integer] Include Push subscriptions in a

'finished' state in your results

@param all [Boolean] Also include Push subscriptions created via the web

UI in your results
# 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) click to toggle source

Get details of the subscription with the given Historics ID

@param historics_id [String] ID of the Historics query for which you are

searching for the related Push subscription

@param page [Integer] Which page of logs to retreive @param per_page [Integer] How many logs to return per page @param order_by [String, Symbol] Which field to sort results by @param order_dir [String, Symbol] Order results in ascending or descending @param include_finished [Integer] Include Push subscriptions in a

'finished' state in your results

@param all [Boolean] Also include Push subscriptions created via the web

UI in your results
# 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) click to toggle source

Get details of the subscription with the given ID

@param id [String] ID of the subscription to retrieve

# 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) click to toggle source

Retrieve log messages for all subscriptions

@param page [Integer] Which page of logs to retreive @param per_page [Integer] How many logs to return per page @param order_by [String, Symbol] Which field to sort results by @param order_dir [String, Symbol] Order results in ascending or descending

# 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) click to toggle source

Retrieve log messages for a specific subscription

@param id [String] ID of the Push subscription to retrieve logs for @param page [Integer] Which page of logs to retreive @param per_page [Integer] How many logs to return per page @param order_by [String, Symbol] Which field to sort results by @param order_dir [String, Symbol] Order results in ascending or descending

# 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) click to toggle source

Pause a subscription and buffer the data for up to an hour

@param id [String] ID of the Push subscription to pause

# 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) click to toggle source

Pull data from a 'pull' type Push Subscription

@param id [String] ID of the Push subscription to pull data from @param size [Integer] Max size (bytes) of the data that should be returned @param cursor [String] Point to a specific point in your Push buffer using

a cursor

@param callback [Method] Pass a callback to process each interaction

returned from a successful pull request
# 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) click to toggle source

Resume a Push subscription that was previously paused

@param id [String] ID of the Push subscription to resume

# File lib/push.rb, line 52
def resume(id)
  params = { :id => id }
  requires params
  DataSift.request(:PUT, 'push/resume', @config, params)
end
stop(id) click to toggle source

Stop a Push subscription; you will not be able to resume this

@param id [String] ID of the Push subscription to stop

# File lib/push.rb, line 61
def stop(id)
  params = { :id => id }
  requires params
  DataSift.request(:PUT, 'push/stop', @config, params)
end
update(params) click to toggle source

Update the name or output parameters for an existing subscription

@param params [Hash] Hash of Push subscription parameters

# File lib/push.rb, line 36
def update(params)
  DataSift.request(:POST, 'push/update', @config, params)
end
valid?(params, bool_response = true) click to toggle source

Check that a Push subscription definition is valid

@param params [Hash] Hash of Push subscription parameters @param bool_response [Boolean] True if you want a boolean response. False

if you want the full response object
# 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