Class: Rundeck::Execution::SearchQueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rundeck-ruby/execution.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.



85
86
87
# File 'lib/rundeck-ruby/execution.rb', line 85

def max
  @max
end

#offsetObject

Returns the value of attribute offset.



85
86
87
# File 'lib/rundeck-ruby/execution.rb', line 85

def offset
  @offset
end

#statusObject

Returns the value of attribute status.



85
86
87
# File 'lib/rundeck-ruby/execution.rb', line 85

def status
  @status
end

Class Method Details

.valid_statusesObject



95
96
97
# File 'lib/rundeck-ruby/execution.rb', line 95

def self.valid_statuses
  %w(succeeded failed aborted running) << nil
end

Instance Method Details

#queryObject



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rundeck-ruby/execution.rb', line 105

def query
  validate

  [
    "",
    status && "statusFilter=#{status}",
    max && "max=#{max.to_i}",
    offset && "offset=#{offset.to_i}",
  ].compact
    .join("&")
    .chomp("&")
end

#validateObject

Raises:



99
100
101
102
103
# File 'lib/rundeck-ruby/execution.rb', line 99

def validate
  raise ValidationError.new("requested 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