Skip to content

Commit c70e034

Browse files
committed
[API] Added the "Verify Snapshot" API
1 parent 798ef25 commit c70e034

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Elasticsearch
2+
module API
3+
module Snapshot
4+
module Actions
5+
6+
# Explicitely perform the verification of a repository
7+
#
8+
# @option arguments [String] :repository A repository name (*Required*)
9+
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
10+
# @option arguments [Time] :timeout Explicit operation timeout
11+
#
12+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
13+
#
14+
def verify_repository(arguments={})
15+
raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
16+
17+
valid_params = [
18+
:repository,
19+
:master_timeout,
20+
:timeout ]
21+
22+
repository = arguments.delete(:repository)
23+
method = 'POST'
24+
path = Utils.__pathify( '_snapshot', Utils.__escape(repository), '_verify' )
25+
params = Utils.__validate_and_extract_params arguments, valid_params
26+
body = nil
27+
28+
perform_request(method, path, params, body).body
29+
end
30+
end
31+
end
32+
end
33+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'test_helper'
2+
3+
module Elasticsearch
4+
module Test
5+
class SnapshotVerifyRepositoryTest < ::Test::Unit::TestCase
6+
7+
context "Snapshot: Verify repository" do
8+
subject { FakeClient.new }
9+
10+
should "perform correct request" do
11+
subject.expects(:perform_request).with do |method, url, params, body|
12+
assert_equal 'POST', method
13+
assert_equal '_snapshot/foo/_verify', url
14+
assert_equal Hash.new, params
15+
assert_nil body
16+
true
17+
end.returns(FakeResponse.new)
18+
19+
subject.snapshot.verify_repository :repository => 'foo'
20+
end
21+
22+
end
23+
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)