diff --git a/app.rb b/app.rb index 74bc41ed5..ea1b363cc 100644 --- a/app.rb +++ b/app.rb @@ -558,8 +558,9 @@ def render_template(name) # # @todo danielp 2013-06-26: this should be some sort of discovery, not a # hand-coded list, but ... it will do, for now. - COLLECTIONS = [:brokers, :repos, :tags, :policies, [:nodes, {'start' => {"type" => "number"}, 'limit' => {"type" => "number"}}], - :tasks, :commands, + COLLECTIONS = [:brokers, :repos, :tags, :policies, + [:nodes, {'start' => {"type" => "number"}, 'limit' => {"type" => "number"}}], + :tasks, [:commands, {'start' => {'type' => 'number'}, 'limit' => {'type' => 'number'}}], [:events, {'start' => {"type" => "number"}, 'limit' => {"type" => "number"}}], :hooks] # @@ -692,7 +693,18 @@ def render_template(name) end get '/api/collections/commands' do - collection_view Razor::Data::Command.order(:submitted_at).order(:id), 'commands' + limit = params[:limit] + start = params[:start] + + raise TypeError, _('limit must be a number, but was %{limit}') % + {limit: limit} unless limit.to_i.to_s == limit or limit.nil? + raise TypeError, _('start must be a number, but was %{start}') % + {start: start} unless start.to_i.to_s == start or start.nil? + limit = Integer(limit) if limit + start = Integer(start) if start + + collection_view Razor::Data::Command.order(:submitted_at).order(:id), + 'commands', limit: limit, start: start, facts: true end get '/api/collections/commands/:id' do