Class: DataSift::Task

Inherits:
ApiResource show all
Defined in:
lib/tasks.rb

Overview

Class for accessing DataSift’s Tasks API

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

Methods inherited from ApiResource

#initialize, #requires

Methods included from DataSift

#build_path, request

Constructor Details

This class inherits a constructor from DataSift::ApiResource

Instance Method Details

#create(service:, type:, subscription_id:, name:, parameters:) ⇒ Object

Creates a Task; this call requires use of an identity API key

Parameters:

  • service (String)

    Service you wish to create a Task for

  • type (String)

    Type of Task to be run

  • subscription_id (String)

    Subscription ID as returned by /pylon/start

  • name (String)

    Human identifier for this Task

  • parameters (Hash)

    Object representing the parameters for the Task type

Returns:

  • (Object)

    API reponse object



13
14
15
16
17
18
19
20
# File 'lib/tasks.rb', line 13

def create(service:, type:, subscription_id:, name:, parameters:)
  DataSift.request(:POST, "pylon/#{service}/task", @config, {
    type: type,
    subscription_id: subscription_id,
    name: name,
    parameters: parameters
  })
end

#get(service:, type: 'analysis', id:) ⇒ Object

Gets a single task by ID; this call requires use of the identity API key associated with the

Task requested

Parameters:

  • service (String)

    Service of the Task you wish to return

  • type (String) (defaults to: 'analysis')

    (Optional) Type of Task to be run (Default: ‘analysis’)

  • id (String)

    ID of the Task you wish to return

Returns:

  • (Object)

    API reponse object



29
30
31
# File 'lib/tasks.rb', line 29

def get(service:, type: 'analysis', id:)
  DataSift.request(:GET, "pylon/#{service}/task/#{type}/#{id}", @config)
end

#list(service:, type: 'analysis', **opts) ⇒ Object

Gets a list of all current Tasks on the service. This call may be accessed using either a

main or identity-level API key.

Parameters:

  • service (String)

    Search Tasks by Service

  • type (String) (defaults to: 'analysis')

    (Optional) Type of Task to be run (Default: ‘analysis’)

  • per_page (Integer)

    (Optional) How many Tasks should be returned per page of results

  • page (Integer)

    (Optional) Which page of results to return

  • status (String)

    (Optional) Filter by Tasks on Status

Returns:

  • (Object)

    API reponse object



42
43
44
45
46
47
48
49
# File 'lib/tasks.rb', line 42

def list(service:, type: 'analysis', **opts)
  params = {}
  params[:per_page] = opts[:per_page] if opts.key?(:per_page)
  params[:page] = opts[:page] if opts.key?(:page)
  params[:status] = opts[:status] if opts.key?(:status)

  DataSift.request(:GET, "pylon/#{service}/task/#{type}", @config, params)
end