Sha256: c79f8655d326e5be41ddce54e00f9810ccccd18842692c792c711ff1059e2545

Contents?: true

Size: 1.75 KB

Versions: 8

Compression:

Stored size: 1.75 KB

Contents

module AnswersEngine
  module Client
    class Job < AnswersEngine::Client::Base
      def all(opts={})
        params = @options.merge(opts)
        self.class.get("/jobs", params)
      end

      def find(job_id)
        self.class.get("/jobs/#{job_id}", @options)
      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]
        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]

        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

8 entries across 8 versions & 1 rubygems

Version Path
answersengine-0.10.1 lib/answersengine/client/job.rb
answersengine-0.10.0 lib/answersengine/client/job.rb
answersengine-0.9.1 lib/answersengine/client/job.rb
answersengine-0.9.0 lib/answersengine/client/job.rb
answersengine-0.8.0 lib/answersengine/client/job.rb
answersengine-0.7.0 lib/answersengine/client/job.rb
answersengine-0.6.0 lib/answersengine/client/job.rb
answersengine-0.5.0 lib/answersengine/client/job.rb