Class: Runcible::Resources::Task

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/task.rb

Overview

Class Method Summary collapse

Methods inherited from Base

add_http_auth_header, add_oauth_header, call, combine_get_params, config, config=, generate_log_message, generate_payload, get_response, log_debug, log_exception, process_response, required_params

Class Method Details

.cancel(id) ⇒ RestClient::Response

Cancels a task

Parameters:

  • id (String)

    the id of the task

Returns:

  • (RestClient::Response)


50
51
52
53
54
# File 'lib/runcible/resources/task.rb', line 50

def self.cancel(id)
  #cancelling a task may require cancelling some higher level
  #  task, so query the tasks _href field to make sure
  call(:delete, poll(id)['_href'])
end

.list(tags = []) ⇒ RestClient::Response

List all tasks based on a set of tags

Parameters:

  • tags (Array) (defaults to: [])

    array of tags to scope the list on

Returns:

  • (RestClient::Response)


60
61
62
# File 'lib/runcible/resources/task.rb', line 60

def self.list(tags=[])
  call(:get, path, :params=>{:tag=>tags})
end

.path(id = nil) ⇒ String

Generates the API path for Tasks

Parameters:

  • id (String) (defaults to: nil)

    the id of the task

Returns:

  • (String)

    the task path, may contain the id if passed



34
35
36
# File 'lib/runcible/resources/task.rb', line 34

def self.path(id=nil)
  (id == nil) ? "tasks/" : "tasks/#{id}/" 
end

.poll(id) ⇒ RestClient::Response

Polls for the status of a task

Parameters:

  • id (String)

    the id of the task

Returns:

  • (RestClient::Response)


42
43
44
# File 'lib/runcible/resources/task.rb', line 42

def self.poll(id)
  call(:get, path(id))
end

.poll_all(ids) ⇒ Array

Polls all tasks based on array of IDs temporary solution until bugzilla.redhat.com/show_bug.cgi?id=860089

Parameters:

  • ids (Array)

    array of ids to poll the status of

Returns:

  • (Array)

    array of RestClient::Response task poll objects



69
70
71
# File 'lib/runcible/resources/task.rb', line 69

def self.poll_all(ids)
  return ids.collect{|id| self.poll(id)}
end