Class: Rundeck::Job::JobExecutionQueryBuilder

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

Defined Under Namespace

Classes: ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxObject

Returns the value of attribute max.



43
44
45
# File 'lib/rundeck-ruby/job.rb', line 43

def max
  @max
end

#offsetObject

Returns the value of attribute offset.



43
44
45
# File 'lib/rundeck-ruby/job.rb', line 43

def offset
  @offset
end

#statusObject

Returns the value of attribute status.



43
44
45
# File 'lib/rundeck-ruby/job.rb', line 43

def status
  @status
end

Class Method Details

.valid_statusesObject



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

def self.valid_statuses
  Execution::QueryBuilder.valid_statuses
end

Instance Method Details

#queryObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rundeck-ruby/job.rb', line 63

def query
  validate

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

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

#validateObject

Raises:



57
58
59
60
61
# File 'lib/rundeck-ruby/job.rb', line 57

def validate
  raise ValidationError.new("status", status) unless status.nil? || self.class.valid_statuses.include?(status.to_s)
  raise ValidationError.new("offset", offset) unless offset.nil? || offset.to_i >= 0
  raise ValidationError.new("max", max) unless max.nil? || max.to_i >= 0
end