class Rundeck::Job
Attributes
id[R]
name[R]
project[R]
session[R]
Public Class Methods
find(session, id)
click to toggle source
# File lib/rundeck-ruby-client/job.rb, line 4 def self.find(session, id) result = session.get("api/1/job/#{id}", 'joblist', 'job') return nil unless result project = Project.find(session, result['context']['project']) return nil unless project Job.new(session, project, result['id'], result['name']) end
from_hash(session, hash)
click to toggle source
# File lib/rundeck-ruby-client/job.rb, line 12 def self.from_hash(session, hash) project = Project.find(session, hash['project']) new(session, project, hash['id'], hash['name']) end
new(session, project, id, name)
click to toggle source
# File lib/rundeck-ruby-client/job.rb, line 17 def initialize(session, project, id, name) @session = session @project = project @id = id @name = name end
Public Instance Methods
execute!(args_hash)
click to toggle source
# File lib/rundeck-ruby-client/job.rb, line 36 def execute!(args_hash) argstr="" args_hash.map {|param, value| argstr += "-#{param} \"#{value}\" "} encoded_args = URI::encode(argstr) query = "api/1/job/#{id}/run?argString=#{encoded_args}" hash = session.get(query, 'result', 'executions', 'execution') || {} Execution.new(session, hash, self) end
executions() { |qb| ... }
click to toggle source
# File lib/rundeck-ruby-client/job.rb, line 26 def executions qb = JobExecutionQueryBuilder.new yield qb if block_given? endpoint = "api/1/job/#{id}/executions#{qb.query}" results = session.get(endpoint, 'result', 'executions', 'execution') || [] results = [results] if results.is_a?(Hash) #Work around an inconsistency in the API results.map{|hash| Execution.from_hash(session, hash)} end