Class: Rundeck::Job
- Inherits:
-
Object
- Object
- Rundeck::Job
- Defined in:
- lib/rundeck-ruby-client/job.rb
Defined Under Namespace
Classes: JobExecutionQueryBuilder
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
- #execute!(args_hash) ⇒ Object
- #executions {|qb| ... } ⇒ Object
-
#initialize(session, project, id, name) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(session, project, id, name) ⇒ Job
Returns a new instance of Job.
17 18 19 20 21 22 |
# File 'lib/rundeck-ruby-client/job.rb', line 17 def initialize(session, project, id, name) @session = session @project = project @id = id @name = name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
24 25 26 |
# File 'lib/rundeck-ruby-client/job.rb', line 24 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/rundeck-ruby-client/job.rb', line 24 def name @name end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
24 25 26 |
# File 'lib/rundeck-ruby-client/job.rb', line 24 def project @project end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
24 25 26 |
# File 'lib/rundeck-ruby-client/job.rb', line 24 def session @session end |
Class Method Details
.find(session, id) ⇒ Object
4 5 6 7 8 9 10 |
# 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 |
Instance Method Details
#execute!(args_hash) ⇒ Object
36 37 38 39 40 41 42 43 |
# 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| ... } ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 |