Skip to content

Commit 4df83ea

Browse files
committed
[API] Adds nodes.get_metering_info
1 parent 0a12e2e commit 4df83ea

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# Returns cluster repositories metering information.
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 A comma-separated list of node IDs or names to limit the returned information.
29+
# @option arguments [Hash] :headers Custom HTTP headers
30+
#
31+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/get-repositories-metering-api.html
32+
#
33+
def get_metering_info(arguments = {})
34+
raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id]
35+
36+
headers = arguments.delete(:headers) || {}
37+
38+
arguments = arguments.clone
39+
40+
_node_id = arguments.delete(:node_id)
41+
42+
method = Elasticsearch::API::HTTP_GET
43+
path = "_nodes/#{Utils.__listify(_node_id)}/_repositories_metering"
44+
params = {}
45+
46+
body = nil
47+
perform_request(method, path, params, body, headers).body
48+
end
49+
end
50+
end
51+
end
52+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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#get_metering_info' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_nodes/foo/_repositories_metering',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.nodes.get_metering_info(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.get_metering_info
42+
end.to raise_exception(ArgumentError)
43+
end
44+
end

0 commit comments

Comments
 (0)