Skip to content

Commit ca0d712

Browse files
committed
[API] Add put_template back
1 parent 0ff8d71 commit ca0d712

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Elasticsearch
2+
module API
3+
module Actions
4+
5+
# Store a template for the search definition in Elasticsearch,
6+
# to be later used with the `search_template` method
7+
#
8+
# @option arguments [String] :id Template ID (*Required*)
9+
# @option arguments [Hash] :body The document (*Required*)
10+
#
11+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html
12+
#
13+
def put_template(arguments={})
14+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
15+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
16+
method = HTTP_POST
17+
path = "_scripts/#{arguments[:id]}"
18+
params = {}
19+
body = arguments[:body]
20+
21+
perform_request(method, path, params, body).body
22+
end
23+
end
24+
end
25+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe 'client#put_template' do
4+
5+
let(:expected_args) do
6+
[
7+
'POST',
8+
'_scripts/foo',
9+
{ },
10+
{ }
11+
]
12+
end
13+
14+
it 'performs the request' do
15+
expect(client_double.put_template(id: 'foo', body: { })).to eq({})
16+
end
17+
end

0 commit comments

Comments
 (0)