Skip to content

Commit 0a12e2e

Browse files
committed
[API] Adds nodes.clear_metering_archive
1 parent 13d52cd commit 0a12e2e

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 Nodes
21+
module Actions
22+
# Removes the archived repositories metering information present in the cluster.
23+
# This functionality is Experimental and may be changed or removed
24+
# completely in a future release. Elastic will take a best effort approach
25+
# to fix any issues, but experimental features are not subject to the
26+
# support SLA of official GA features.
27+
#
28+
# @option arguments [List] :node_id Comma-separated list of node IDs or names used to limit returned information.
29+
# @option arguments [Long] :max_archive_version Specifies the maximum archive_version to be cleared from the archive.
30+
# @option arguments [Hash] :headers Custom HTTP headers
31+
#
32+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/clear-repositories-metering-archive-api.html
33+
#
34+
def clear_metering_archive(arguments = {})
35+
raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id]
36+
37+
raise ArgumentError,
38+
"Required argument 'max_archive_version' missing" unless arguments[:max_archive_version]
39+
40+
headers = arguments.delete(:headers) || {}
41+
42+
arguments = arguments.clone
43+
44+
_node_id = arguments.delete(:node_id)
45+
46+
_max_archive_version = arguments.delete(:max_archive_version)
47+
48+
method = Elasticsearch::API::HTTP_DELETE
49+
path = "_nodes/#{Utils.__listify(_node_id)}/_repositories_metering/#{Utils.__listify(_max_archive_version)}"
50+
params = {}
51+
52+
body = nil
53+
perform_request(method, path, params, body, headers).body
54+
end
55+
end
56+
end
57+
end
58+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.nodes#clear_metering_archive' do
21+
let(:expected_args) do
22+
[
23+
'DELETE',
24+
'_nodes/foo/_repositories_metering/bar',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.nodes.clear_metering_archive(node_id: 'foo', max_archive_version: 'bar')).to eq({})
33+
end
34+
35+
let(:client) do
36+
Class.new { include Elasticsearch::API }.new
37+
end
38+
39+
it 'raises an error if no node_id is provided' do
40+
expect do
41+
client.nodes.clear_metering_archive(max_archive_version: 'bar')
42+
end.to raise_exception(ArgumentError)
43+
end
44+
45+
it 'raises an error if no max_archive_version is provided' do
46+
expect do
47+
client.nodes.clear_metering_archive(node_id: 'foo')
48+
end.to raise_exception(ArgumentError)
49+
end
50+
end

0 commit comments

Comments
 (0)