Skip to content

Commit f72673d

Browse files
committed
[API] Adds watched.get_settings and watcher.update_settings
1 parent ad430d9 commit f72673d

File tree

4 files changed

+179
-0
lines changed

4 files changed

+179
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Watcher
24+
module Actions
25+
# Retrieve settings for the watcher system index
26+
#
27+
# @option arguments [Hash] :headers Custom HTTP headers
28+
#
29+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html
30+
#
31+
def get_settings(arguments = {})
32+
arguments = arguments.clone
33+
headers = arguments.delete(:headers) || {}
34+
35+
body = nil
36+
37+
method = Elasticsearch::API::HTTP_GET
38+
path = "_watcher/settings"
39+
params = {}
40+
41+
Elasticsearch::API::Response.new(
42+
perform_request(method, path, params, body, headers)
43+
)
44+
end
45+
end
46+
end
47+
end
48+
end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Watcher
24+
module Actions
25+
# Update settings for the watcher system index
26+
#
27+
# @option arguments [Hash] :headers Custom HTTP headers
28+
# @option arguments [Hash] :body An object with the new index settings (*Required*)
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html
31+
#
32+
def update_settings(arguments = {})
33+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
34+
35+
arguments = arguments.clone
36+
headers = arguments.delete(:headers) || {}
37+
38+
body = arguments.delete(:body)
39+
40+
method = Elasticsearch::API::HTTP_PUT
41+
path = "_watcher/settings"
42+
params = {}
43+
44+
Elasticsearch::API::Response.new(
45+
perform_request(method, path, params, body, headers)
46+
)
47+
end
48+
end
49+
end
50+
end
51+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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#watcher.get_settings' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_watcher/settings',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.watcher.get_settings).to be_a Elasticsearch::API::Response
33+
end
34+
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#watcher.get_settings' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_watcher/settings',
25+
{},
26+
{},
27+
{}
28+
]
29+
end
30+
31+
context 'when using body' do
32+
it 'performs the request' do
33+
expect(client_double.watcher.update_settings(body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end
36+
37+
context 'without a body' do
38+
let(:client) { Class.new { include Elasticsearch::API }.new }
39+
40+
it 'raises ArgumentError' do
41+
expect do
42+
client.watcher.update_settings
43+
end.to raise_exception(ArgumentError)
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)