Skip to content

Commit 57ba44a

Browse files
committed
[API] Adds cat.component_templates
1 parent 2eeecce commit 57ba44a

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Elasticsearch
19+
module API
20+
module Cat
21+
module Actions
22+
# Returns information about existing component_templates templates.
23+
#
24+
# @option arguments [String] :name A pattern that returned component template names must match
25+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
26+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
27+
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
28+
# @option arguments [List] :h Comma-separated list of column names to display
29+
# @option arguments [Boolean] :help Return help information
30+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
31+
# @option arguments [Boolean] :v Verbose mode. Display column headers
32+
# @option arguments [Hash] :headers Custom HTTP headers
33+
#
34+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-compoentn-templates.html
35+
#
36+
def component_templates(arguments = {})
37+
headers = arguments.delete(:headers) || {}
38+
39+
body = nil
40+
41+
arguments = arguments.clone
42+
43+
_name = arguments.delete(:name)
44+
45+
method = Elasticsearch::API::HTTP_GET
46+
path = if _name
47+
"_cat/component_templates/#{Utils.__listify(_name)}"
48+
else
49+
"_cat/component_templates"
50+
end
51+
params = Utils.process_params(arguments)
52+
53+
Elasticsearch::API::Response.new(
54+
perform_request(method, path, params, body, headers)
55+
)
56+
end
57+
end
58+
end
59+
end
60+
end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.cat#component_templates' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
url,
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
context 'without a name' do
32+
let(:url) { '_cat/component_templates' }
33+
34+
it 'performs the request' do
35+
expect(client_double.cat.component_templates).to be_a Elasticsearch::API::Response
36+
end
37+
end
38+
39+
context 'with a name' do
40+
let(:url) { '_cat/component_templates/foo' }
41+
42+
it 'performs the request' do
43+
expect(client_double.cat.component_templates(name: 'foo')).to be_a Elasticsearch::API::Response
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)