Class: AnswersEngine::Client::Job

Inherits:
Base
  • Object
show all
Defined in:
lib/answersengine/client/job.rb

Instance Method Summary collapse

Methods inherited from Base

#auth_token, #auth_token=, #env_api_url, env_auth_token, #initialize

Constructor Details

This class inherits a constructor from AnswersEngine::Client::Base

Instance Method Details

#all(opts = {}) ⇒ Object



4
5
6
7
# File 'lib/answersengine/client/job.rb', line 4

def all(opts={})
  params = @options.merge(opts)
  self.class.get("/jobs", params)
end

#cancel(job_id, opts = {}) ⇒ Object



23
24
25
26
# File 'lib/answersengine/client/job.rb', line 23

def cancel(job_id, opts={})
  opts[:status] = 'cancelled'
  update(job_id, opts)
end

#find(job_id) ⇒ Object



9
10
11
# File 'lib/answersengine/client/job.rb', line 9

def find(job_id)
  self.class.get("/jobs/#{job_id}", @options)
end

#finisher_update(job_id, opts = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/answersengine/client/job.rb', line 50

def finisher_update(job_id, opts={})
  body = {}
  body[:outputs] = opts.fetch(:outputs) {[]}
  body[:finisher_status] = opts.fetch(:finisher_status){ nil }
  body[:log_error] = opts[:log_error] if opts[:log_error]

  params = @options.merge({body: body.to_json})

  self.class.put("/jobs/#{job_id}/finisher_update", params)
end

#pause(job_id, opts = {}) ⇒ Object



33
34
35
36
# File 'lib/answersengine/client/job.rb', line 33

def pause(job_id, opts={})
  opts[:status] = 'paused'
  update(job_id, opts)
end

#resume(job_id, opts = {}) ⇒ Object



28
29
30
31
# File 'lib/answersengine/client/job.rb', line 28

def resume(job_id, opts={})
  opts[:status] = 'active'
  update(job_id, opts)
end

#seeding_update(job_id, opts = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/answersengine/client/job.rb', line 38

def seeding_update(job_id, opts={})
  body = {}
  body[:outputs] = opts.fetch(:outputs) {[]}
  body[:pages] = opts.fetch(:pages) {[]}
  body[:seeding_status] = opts.fetch(:seeding_status){ nil }
  body[:log_error] = opts[:log_error] if opts[:log_error]

  params = @options.merge({body: body.to_json})

  self.class.put("/jobs/#{job_id}/seeding_update", params)
end

#update(job_id, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/answersengine/client/job.rb', line 13

def update(job_id, opts={})
  body = {}
  body[:status] = opts[:status] if opts[:status]
  body[:standard_worker_count] = opts[:workers] if opts[:workers]
  body[:browser_worker_count] = opts[:browsers] if opts[:browsers]
  params = @options.merge({body: body.to_json})

  self.class.put("/jobs/#{job_id}", params)
end