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.



67
68
69
# File 'lib/rundeck-ruby-client/execution.rb', line 67

def max
  @max
end

#offsetObject

Returns the value of attribute offset.



67
68
69
# File 'lib/rundeck-ruby-client/execution.rb', line 67

def offset
  @offset
end

#statusObject

Returns the value of attribute status.



67
68
69
# File 'lib/rundeck-ruby-client/execution.rb', line 67

def status
  @status
end

Class Method Details

.valid_statusesObject



69
70
71
# File 'lib/rundeck-ruby-client/execution.rb', line 69

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

Instance Method Details

#queryObject



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rundeck-ruby-client/execution.rb', line 79

def query
  validate

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

#validateObject



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

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