class DataSift::Pylon

Class for accessing DataSift's PYLON API

Public Instance Methods

analyze(hash = '', parameters = '', filter = '', start_time = nil, end_time = nil, id = '', service = 'facebook') click to toggle source

Perform a PYLON analysis query by making an /pylon/analyze API call

@param hash [String] Hash of the recording you wish to perform an

analysis against

@param parameters [String] Parameters of the analysis you wish to perform.

See the
{http://dev.datasift.com/pylon/docs/api-endpoints/pylonanalyze
/pylon/analyze API Docs} for full documentation

@param filter [String] Optional PYLON CSDL for a query filter @param start_time [Integer] Optional start timestamp for filtering by date @param end_time [Integer] Optional end timestamp for filtering by date @param id [String] ID of the recording you wish to analyze @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 159
def analyze(hash = '', parameters = '', filter = '', start_time = nil, end_time = nil, id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'parameters is required' if parameters.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = { parameters: parameters }
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(id: id) unless id.empty?
  params.merge!(filter: filter) unless filter.empty?
  params.merge!(start: start_time) unless start_time.nil?
  params.merge!(end: end_time) unless end_time.nil?

  DataSift.request(:POST, build_path(service, 'pylon/analyze', @config), @config, params)
end
compile(csdl, service = 'facebook') click to toggle source

Compile PYLON CSDL by making an /pylon/compile API call

@param csdl [String] CSDL you wish to compile @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 27
def compile(csdl, service = 'facebook')
  fail BadParametersError, 'csdl is required' if csdl.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = { csdl: csdl }

  DataSift.request(:POST, build_path(service, 'pylon/compile', @config), @config, params)
end
get(hash = '', id = '', service = 'facebook') click to toggle source

Perform /pylon/get API call to query status of your PYLON recordings

@param hash [String] Hash you with the get the status for @param id [String] The ID of the PYLON recording to get @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 42
def get(hash = '', id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(id: id) unless id.empty?

  DataSift.request(:GET, build_path(service, 'pylon/get', @config), @config, params)
end
list(page = nil, per_page = nil, order_by = '', order_dir = '', service = 'facebook') click to toggle source

Perform /pylon/get API call to list all PYLON Recordings

@param page [Integer] Which page of recordings to retreive @param per_page [Integer] How many recordings 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

order

@param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 62
def list(page = nil, per_page = nil, order_by = '', order_dir = '', service = 'facebook')
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(page: page) unless page.nil?
  params.merge!(per_page: per_page) unless per_page.nil?
  params.merge!(order_by: order_by) unless order_by.empty?
  params.merge!(order_dir: order_dir) unless order_dir.empty?

  DataSift.request(:GET, build_path(service, 'pylon/get', @config), @config, params)
end
reference(service:, slug: '', **opts) click to toggle source

Hit the PYLON Reference endpoint to expose reference data sets

@param service [String] The PYLON service to make this API call against @param slug [String] Optional slug of the reference data set you would like to explore **opts @param per_page [Integer] (Optional) How many data sets should be returned per page of results @param page [Integer] (Optional) Which page of results to return

# File lib/pylon.rb, line 228
def reference(service:, slug: '', **opts)
  params = {}
  params[:per_page] = opts[:per_page] if opts.key?(:per_page)
  params[:page] = opts[:page] if opts.key?(:page)

  DataSift.request(:GET, "pylon/#{service}/reference/#{slug}", @config, params)
end
restart(id, name = '', service = 'facebook') click to toggle source

Restart an existing PYLON recording by making an /pylon/start API call with a recording ID

@param id [String] CSDL you wish to begin (or resume) recording @param name [String] Give your recording a name. Required when starting a

new recording

@param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 118
def restart(id, name = '', service = 'facebook')
  fail BadParametersError, 'id is required' if id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = { id: id }
  params.merge!(name: name) unless name.empty?

  DataSift.request(:PUT, build_path(service, 'pylon/start', @config), @config, params)
end
sample(hash = '', count = nil, start_time = nil, end_time = nil, filter = '', id = '', service = 'facebook') click to toggle source

Hit the PYLON Sample endpoint to pull public sample data from a PYLON recording

@param hash [String] The CSDL hash that identifies the recording you want to sample @param count [Integer] Optional number of public interactions you wish to receive @param start_time [Integer] Optional start timestamp for filtering by date @param end_time [Integer] Optional end timestamp for filtering by date @param filter [String] Optional PYLON CSDL for a query filter @param id [String] ID of the recording you wish to sample @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 202
def sample(hash = '', count = nil, start_time = nil, end_time = nil, filter = '', id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(id: id) unless id.empty?
  params.merge!(count: count) unless count.nil?
  params.merge!(start_time: start_time) unless start_time.nil?
  params.merge!(end_time: end_time) unless end_time.nil?

  if filter.empty?
    DataSift.request(:GET, build_path(service, 'pylon/sample', @config), @config, params)
  else
    params.merge!(filter: filter)
    DataSift.request(:POST, build_path(service, 'pylon/sample', @config), @config, params)
  end
end
start(hash = '', name = '', id = '', service = 'facebook') click to toggle source

Start recording a PYLON filter by making an /pylon/start API call

@param hash [String] CSDL you wish to begin (or resume) recording @param name [String] Give your recording a name. Required when starting a @param id [String] ID of the recording you wish to start

new recording

@param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 99
def start(hash = '', name = '', id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(name: name) unless name.empty?
  params.merge!(id: id) unless id.empty?

  DataSift.request(:PUT, build_path(service, 'pylon/start', @config), @config, params)
end
stop(hash = '', id = '', service = 'facebook') click to toggle source

Stop an active PYLON recording by making an /pylon/stop API call

@param hash [String] CSDL you wish to stop recording @param id [String] ID of the recording you wish to stop @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 134
def stop(hash = '', id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(id: id) unless id.empty?

  DataSift.request(:PUT, build_path(service, 'pylon/stop', @config), @config, params)
end
tags(hash = '', id = '', service = 'facebook') click to toggle source

Query the tag hierarchy on interactions populated by a particular

recording

@param hash [String] Hash of the recording you wish to query @param id [String] ID of the recording you wish to query @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 181
def tags(hash = '', id = '', service = 'facebook')
  fail BadParametersError, 'hash or id is required' if hash.empty? && id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(id: id) unless id.empty?

  DataSift.request(:GET, build_path(service, 'pylon/tags', @config), @config, params)
end
update(id, hash = '', name = '', service = 'facebook') click to toggle source

Perform /pylon/update API call to update a given PYLON Recording

@param id [String] The ID of the PYLON recording to update @param hash [String] The CSDL filter hash this recording should be subscribed to @param name [String] Update the name of your recording @param service [String] The PYLON service to make this API call against @return [Object] API reponse object

# File lib/pylon.rb, line 81
def update(id, hash = '', name = '', service = 'facebook')
  fail BadParametersError, 'service is required' if service.empty?

  params = { id: id }
  params.merge!(hash: hash) unless hash.empty?
  params.merge!(name: name) unless name.empty?

  DataSift.request(:PUT, build_path(service, 'pylon/update', @config), @config, params)
end
valid?(csdl = '', boolResponse = true, service = 'facebook') click to toggle source

Check PYLON CSDL is valid by making an /pylon/validate API call

@param csdl [String] CSDL you wish to validate @param boolResponse [Boolean] True if you want a boolean response. @param service [String] The PYLON service to make this API call against

False if you want the full response object

@return [Boolean, Object] Dependent on value of boolResponse

# File lib/pylon.rb, line 12
def valid?(csdl = '', boolResponse = true, service = 'facebook')
  fail BadParametersError, 'csdl is required' if csdl.empty?
  fail BadParametersError, 'service is required' if service.empty?

  params = { csdl: csdl }

  res = DataSift.request(:POST, build_path(service, 'pylon/validate', @config), @config, params)
  boolResponse ? res[:http][:status] == 200 : res
end