Skip to content

Commit

Permalink
[API] Added the "Pending Tasks" API
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi committed Jan 23, 2014
1 parent aa2b182 commit bcb3e3c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
@@ -0,0 +1,33 @@
module Elasticsearch
module API
module Cluster
module Actions

# Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard)
# which have not yet been executed and are queued up.
#
# @example Get a list of currently queued up tasks in the cluster
#
# client.cluster.pending_tasks
#
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
# (default: false)
# @option arguments [Time] :master_timeout Specify timeout for connection to master
#
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cluster-pending.html
#
def pending_tasks(arguments={})
valid_params = [
:local,
:master_timeout ]
method = 'GET'
path = "/_cluster/pending_tasks"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil

perform_request(method, path, params, body).body
end
end
end
end
end
26 changes: 26 additions & 0 deletions elasticsearch-api/test/unit/cluster/pending_tasks_test.rb
@@ -0,0 +1,26 @@
require 'test_helper'

module Elasticsearch
module Test
class ClusterPendingTasksTest < ::Test::Unit::TestCase

context "Cluster: Pending tasks" do
subject { FakeClient.new }

should "perform correct request" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal 'GET', method
assert_equal '/_cluster/pending_tasks', url
assert_equal Hash.new, params
assert_nil body
true
end.returns(FakeResponse.new)

subject.cluster.pending_tasks
end

end

end
end
end

0 comments on commit bcb3e3c

Please sign in to comment.