Skip to content

Commit ad23256

Browse files
committed
[API] Add indices/snapshot_index back
1 parent 8190836 commit ad23256

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module Elasticsearch
2+
module API
3+
module Indices
4+
module Actions
5+
6+
# When using the shared storage gateway, manually trigger the snapshot operation.
7+
#
8+
# @deprecated The shared gateway has been deprecated [https://github.com/elasticsearch/elasticsearch/issues/2458]
9+
#
10+
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
11+
# to perform the operation on all indices
12+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
13+
# no concrete indices. (This includes `_all` string or when no
14+
# indices have been specified)
15+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
16+
# are open, closed or both. (options: open, closed)
17+
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
18+
# `missing` ones (options: none, missing) @until 1.0
19+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
20+
# unavailable (missing, closed, etc)
21+
#
22+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/
23+
#
24+
def snapshot_index(arguments={})
25+
method = HTTP_POST
26+
path = Utils.__pathify Utils.__listify(arguments[:index]), '_gateway/snapshot'
27+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
28+
body = nil
29+
30+
perform_request(method, path, params, body).body
31+
end
32+
33+
# Register this action with its valid params when the module is loaded.
34+
#
35+
# @since 6.2.0
36+
ParamsRegistry.register(:snapshot_index, [
37+
:ignore_indices,
38+
:ignore_unavailable,
39+
:allow_no_indices,
40+
:expand_wildcards ].freeze)
41+
end
42+
end
43+
end
44+
end
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
require 'spec_helper'
2+
3+
describe 'client.cluster#snapshot_index' do
4+
5+
let(:expected_args) do
6+
[
7+
'POST',
8+
url,
9+
params,
10+
body,
11+
nil
12+
]
13+
end
14+
15+
let(:url) do
16+
'_gateway/snapshot'
17+
end
18+
19+
let(:body) do
20+
nil
21+
end
22+
23+
let(:params) do
24+
{}
25+
end
26+
27+
it 'performs the request' do
28+
expect(client_double.indices.snapshot_index).to eq({})
29+
end
30+
31+
context 'when an index is specified' do
32+
33+
let(:url) do
34+
'foo/_gateway/snapshot'
35+
end
36+
37+
it 'performs the request' do
38+
expect(client_double.indices.snapshot_index(index: 'foo')).to eq({})
39+
end
40+
end
41+
42+
context 'when multiple indicies are specified as a list' do
43+
44+
let(:url) do
45+
'foo,bar/_gateway/snapshot'
46+
end
47+
48+
it 'performs the request' do
49+
expect(client_double.indices.snapshot_index(index: ['foo', 'bar'])).to eq({})
50+
end
51+
end
52+
53+
context 'when multiple indicies are specified as a string' do
54+
55+
let(:url) do
56+
'foo,bar/_gateway/snapshot'
57+
end
58+
59+
it 'performs the request' do
60+
expect(client_double.indices.snapshot_index(index: 'foo,bar')).to eq({})
61+
end
62+
end
63+
64+
context 'when parameters are specified' do
65+
66+
let(:params) do
67+
{ ignore_indices: 'missing' }
68+
end
69+
70+
let(:url) do
71+
'foo/_gateway/snapshot'
72+
end
73+
74+
it 'performs the request' do
75+
expect(client_double.indices.snapshot_index(index: 'foo', ignore_indices: 'missing')).to eq({})
76+
end
77+
end
78+
79+
context 'when the path needs to be URL-escaped' do
80+
81+
let(:url) do
82+
'foo%5Ebar/_gateway/snapshot'
83+
end
84+
85+
it 'performs the request' do
86+
expect(client_double.indices.snapshot_index(index: 'foo^bar')).to eq({})
87+
end
88+
end
89+
end

0 commit comments

Comments
 (0)