Class: Datahen::Client::Job
- Inherits:
-
Base
- Object
- Base
- Datahen::Client::Job
show all
- Defined in:
- lib/datahen/client/job.rb
Instance Method Summary
collapse
Methods inherited from Base
#auth_token, #auth_token=, #env_api_url, env_auth_token, env_ignore_ssl, #ignore_ssl, #initialize
Instance Method Details
#all(opts = {}) ⇒ Object
4
5
6
7
|
# File 'lib/datahen/client/job.rb', line 4
def all(opts={})
params = @options.merge(opts)
self.class.get("/jobs", params)
end
|
#cancel(job_id, opts = {}) ⇒ Object
32
33
34
35
|
# File 'lib/datahen/client/job.rb', line 32
def cancel(job_id, opts={})
opts[:status] = 'cancelled'
update(job_id, opts)
end
|
#delete(job_id, opts = {}) ⇒ Object
77
78
79
80
|
# File 'lib/datahen/client/job.rb', line 77
def delete(job_id, opts={})
params = @options.merge(opts)
self.class.delete("/jobs/#{job_id}", params)
end
|
#find(job_id, opts = {}) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/datahen/client/job.rb', line 9
def find(job_id, opts={})
if opts[:live]
self.class.get("/jobs/#{job_id}", @options)
else
self.class.get("/cached/jobs/#{job_id}", @options)
end
end
|
#finisher_update(job_id, opts = {}) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/datahen/client/job.rb', line 60
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
42
43
44
45
|
# File 'lib/datahen/client/job.rb', line 42
def pause(job_id, opts={})
opts[:status] = 'paused'
update(job_id, opts)
end
|
#profile(job_id, opts = {}) ⇒ Object
71
72
73
74
75
|
# File 'lib/datahen/client/job.rb', line 71
def profile(job_id, opts={})
params = @options.merge(opts)
self.class.get("/jobs/#{job_id}/profile", params)
end
|
#resume(job_id, opts = {}) ⇒ Object
37
38
39
40
|
# File 'lib/datahen/client/job.rb', line 37
def resume(job_id, opts={})
opts[:status] = 'active'
update(job_id, opts)
end
|
#seeding_update(job_id, opts = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/datahen/client/job.rb', line 47
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]
body[:keep_outputs] = !!opts[:keep_outputs] if opts.has_key?(:keep_outputs)
params = @options.merge({body: body.to_json})
self.class.put("/jobs/#{job_id}/seeding_update", params)
end
|
#update(job_id, opts = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/datahen/client/job.rb', line 17
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]
body[:proxy_type] = opts[:proxy_type] if opts[:proxy_type]
body[:profile] = opts[:profile] if opts[:profile]
body[:max_page_size] = opts[:max_page_size] if opts[:max_page_size]
body[:enable_global_cache] = opts[:enable_global_cache] if opts.has_key?("enable_global_cache") || opts.has_key?(:enable_global_cache)
body[:retry_interval] = opts[:retry_interval] if opts[:retry_interval]
params = @options.merge({body: body.to_json})
self.class.put("/jobs/#{job_id}", params)
end
|