-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Added the "Snapshot Status" API
Related: elastic/elasticsearch#4946
- Loading branch information
Showing
5 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Elasticsearch | ||
module API | ||
module Snapshot | ||
module Actions | ||
|
||
# Return information about a running snapshot | ||
# | ||
# @example Return information about all currently running snapshots | ||
# | ||
# client.snapshot.status repository: 'my-backups', human: true | ||
# | ||
# @example Return information about a specific snapshot | ||
# | ||
# client.snapshot.status repository: 'my-backups', human: true | ||
# | ||
# @option arguments [String] :repository A repository name | ||
# @option arguments [List] :snapshot A comma-separated list of snapshot names | ||
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node | ||
# | ||
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_snapshot_status | ||
# | ||
def status(arguments={}) | ||
valid_params = [ | ||
:master_timeout ] | ||
|
||
repository = arguments.delete(:repository) | ||
snapshot = arguments.delete(:snapshot) | ||
|
||
method = 'GET' | ||
|
||
path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot), '_status') | ||
params = Utils.__validate_and_extract_params arguments, valid_params | ||
body = nil | ||
|
||
perform_request(method, path, params, body).body | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'test_helper' | ||
|
||
module Elasticsearch | ||
module Test | ||
class SnapshotStatusTest < ::Test::Unit::TestCase | ||
|
||
context "Snapshot: Status" 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 '_snapshot/_status', url | ||
assert_equal Hash.new, params | ||
assert_nil body | ||
true | ||
end.returns(FakeResponse.new) | ||
|
||
subject.snapshot.status | ||
end | ||
|
||
should "encode repository and snapshot" do | ||
subject.expects(:perform_request).with do |method, url, params, body| | ||
assert_equal 'GET', method | ||
assert_equal '_snapshot/foo/bar/_status', url | ||
assert_equal Hash.new, params | ||
assert_equal nil, body | ||
true | ||
end.returns(FakeResponse.new) | ||
|
||
subject.snapshot.status :repository => 'foo', :snapshot => 'bar' | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |