Class: DataSift::Historics

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

Overview

Methods for using DataSift Historics

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

#delete(id) ⇒ Object

Delete an Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to delete



96
97
98
99
100
# File 'lib/historics.rb', line 96

def delete(id)
  params = { :id => id }
  requires params
  DataSift.request(:DELETE, 'historics/delete', @config, params)
end

#get(max = 20, page = 1, with_estimate = 1) ⇒ Object

Get details for a list of Historics within the given page constraints

Parameters:

  • max (Integer) (defaults to: 20)

    Max number of Historics you wish to return per page

  • page (Integer) (defaults to: 1)

    Which page of results you need returned

  • with_estimate (Boolean) (defaults to: 1)

    1 or 0 indicating whether you want to see the estimated completion time of the Historics query



119
120
121
122
123
# File 'lib/historics.rb', line 119

def get(max = 20, page = 1, with_estimate = 1)
  params = { :max => max, :page => page, :with_estimate => with_estimate }
  requires params
  DataSift.request(:GET, 'historics/get', @config, params)
end

#get_by_id(id, with_estimate = 1) ⇒ Object

Get details for a given Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to get

  • with_estimate (Boolean) (defaults to: 1)

    1 or 0 indicating whether you want to see the estimated completion time of the Historics query



107
108
109
110
111
# File 'lib/historics.rb', line 107

def get_by_id(id, with_estimate = 1)
  params = { :id => id, :with_estimate => with_estimate }
  requires params
  DataSift.request(:GET, 'historics/get', @config, params)
end

#pause(id, reason = '') ⇒ Object

Pause Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to pause

  • reason (String) (defaults to: '')

    You can give a reason for pausing the query



33
34
35
36
37
38
# File 'lib/historics.rb', line 33

def pause(id, reason = '')
  params = { :id => id }
  requires params
  params[:reason] = reason
  DataSift.request(:PUT, 'historics/pause', @config, params)
end

#prepare(hash, start, end_time, name, sources = '', sample = 100) ⇒ Object

Prepare a new Historics query

Parameters:

  • hash (String)

    Hash of compiled CSDL filter

  • start (Integer)

    Start timestamp for your Historics Query. Should be provided as a Unix timestamp

  • end_time (Integer)

    End timestamp for your Historics Query. Should be provided as a Unix timestamp

  • name (String)

    The name of your Historics query

  • sources (String) (defaults to: '')

    Comma separated list of data sources you wish to query

  • sample (Integer) (defaults to: 100)

    Sample size of your Historics query

Returns:

  • (Object)

    API reponse object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/historics.rb', line 16

def prepare(hash, start, end_time, name, sources = '', sample = 100)
  params = {
    :hash => hash,
    :start => start,
    :end => end_time,
    :name => name,
    :sources => sources,
    :sample => sample
  }
  requires params
  DataSift.request(:POST, 'historics/prepare', @config, params)
end

#resume(id) ⇒ Object

Resume Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to resume



43
44
45
46
47
# File 'lib/historics.rb', line 43

def resume(id)
  params = { :id => id }
  requires params
  DataSift.request(:PUT, 'historics/resume', @config, params)
end

#start(id) ⇒ Object

Start Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to start



52
53
54
55
56
# File 'lib/historics.rb', line 52

def start(id)
  params = { :id => id }
  requires params
  DataSift.request(:POST, 'historics/start', @config, params)
end

#status(start, end_time, sources = '') ⇒ Object

Check the data coverage in the archive for a specified interval

Parameters:

  • start (Integer)

    Start timestamp for the period you wish to query. Should be provided as a Unix timestamp

  • end_time (Integer)

    End timestamp for the period you wish to query. Should be provided as a Unix timestamp

  • sources (String) (defaults to: '')

    Comma separated list of data sources you wish to query



77
78
79
80
81
# File 'lib/historics.rb', line 77

def status(start, end_time, sources = '')
  params = { :start => start, :end => end_time, :sources => sources }
  requires params
  DataSift.request(:GET, 'historics/status', @config, params)
end

#stop(id, reason = '') ⇒ Object

Stop Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to stop

  • reason (String) (defaults to: '')

    You can give a reason for stopping the query



62
63
64
65
66
67
# File 'lib/historics.rb', line 62

def stop(id, reason = '')
  params = { :id => id }
  requires params
  params[:reason] = reason
  DataSift.request(:POST, 'historics/stop', @config, params)
end

#update(id, name) ⇒ Object

Update the name of an Historics query

Parameters:

  • id (String)

    ID of the Historics query you need to update

  • name (String)

    New name for the Historics query



87
88
89
90
91
# File 'lib/historics.rb', line 87

def update(id, name)
  params = { :id => id, :name => name }
  requires params
  DataSift.request(:POST, 'historics/update', @config, params)
end