Class: Rundeck::Job::JobExecutionQueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rundeck-ruby-client/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxObject

Returns the value of attribute max.



46
47
48
# File 'lib/rundeck-ruby-client/job.rb', line 46

def max
  @max
end

#offsetObject

Returns the value of attribute offset.



46
47
48
# File 'lib/rundeck-ruby-client/job.rb', line 46

def offset
  @offset
end

#statusObject

Returns the value of attribute status.



46
47
48
# File 'lib/rundeck-ruby-client/job.rb', line 46

def status
  @status
end

Class Method Details

.valid_statusesObject



48
49
50
# File 'lib/rundeck-ruby-client/job.rb', line 48

def self.valid_statuses
  Execution::QueryBuilder.valid_statuses
end

Instance Method Details

#queryObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rundeck-ruby-client/job.rb', line 58

def query
  validate

  clauses = [
    status && "status=#{status}",
    max && "max=#{max.to_i}",
    offset && "offset=#{offset.to_i}",
  ].compact.join('&')

  "?#{clauses}".chomp('?')
end

#validateObject



52
53
54
55
56
# File 'lib/rundeck-ruby-client/job.rb', line 52

def validate
  raise "Invalid requested status: #{status}" unless status.nil? || self.class.valid_statuses.include?(status.to_s)
  raise "Invalid offset" unless offset.nil? || offset.to_i >= 0
  raise "Invalid max" unless max.nil? || max.to_i >= 0
end