Class: Rundeck::Execution::QueryBuilder

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxObject

Returns the value of attribute max.



75
76
77
# File 'lib/rundeck-ruby-client/execution.rb', line 75

def max
  @max
end

#offsetObject

Returns the value of attribute offset.



75
76
77
# File 'lib/rundeck-ruby-client/execution.rb', line 75

def offset
  @offset
end

#statusObject

Returns the value of attribute status.



75
76
77
# File 'lib/rundeck-ruby-client/execution.rb', line 75

def status
  @status
end

Class Method Details

.valid_statusesObject



77
78
79
# File 'lib/rundeck-ruby-client/execution.rb', line 77

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

Instance Method Details

#queryObject



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rundeck-ruby-client/execution.rb', line 87

def query
  validate

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

#validateObject



81
82
83
84
85
# File 'lib/rundeck-ruby-client/execution.rb', line 81

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