Sha256: 4e44896296fbdee1e09d6611a422cc1de01e8cd02fb9eb5495766f8dce26b167
Contents?: true
Size: 2 KB
Versions: 6
Compression:
Stored size: 2 KB
Contents
module Datahen module Client class Job < Datahen::Client::Base def all(opts={}) params = @options.merge(opts) self.class.get("/jobs", params) end 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 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] params = @options.merge({body: body.to_json}) self.class.put("/jobs/#{job_id}", params) end def cancel(job_id, opts={}) opts[:status] = 'cancelled' update(job_id, opts) end def resume(job_id, opts={}) opts[:status] = 'active' update(job_id, opts) end def pause(job_id, opts={}) opts[:status] = 'paused' update(job_id, opts) end 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 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems