Skip to content

Commit ac89354

Browse files
committed
[API] Updates indices.resolve_cluster - Adds timeout, name no longer a required parameter
1 parent 067fbe9 commit ac89354

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_cluster.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ module Elasticsearch
2222
module API
2323
module Indices
2424
module Actions
25-
# Resolves the specified index expressions to return information about each cluster, including the local cluster, if included.
25+
# Resolves the specified index expressions to return information about each cluster. If no index expression is provided, this endpoint will return information about all the remote clusters that are configured on the local cluster.
2626
#
2727
# @option arguments [List] :name A comma-separated list of cluster:index names or wildcard expressions
28-
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
29-
# @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled
30-
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
31-
# @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all)
28+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed). Only allowed when providing an index expression.
29+
# @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled. Only allowed when providing an index expression.
30+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). Only allowed when providing an index expression.
31+
# @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open). Only allowed when providing an index expression. (options: open, closed, hidden, none, all)
32+
# @option arguments [Time] :timeout The maximum time to wait for remote clusters to respond
3233
# @option arguments [Hash] :headers Custom HTTP headers
3334
#
3435
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.17/indices-resolve-cluster-api.html
@@ -41,8 +42,6 @@ def resolve_cluster(arguments = {})
4142
end
4243
request_opts[:defined_params] = defined_params unless defined_params.empty?
4344

44-
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
45-
4645
arguments = arguments.clone
4746
headers = arguments.delete(:headers) || {}
4847

@@ -51,7 +50,11 @@ def resolve_cluster(arguments = {})
5150
_name = arguments.delete(:name)
5251

5352
method = Elasticsearch::API::HTTP_GET
54-
path = "_resolve/cluster/#{Utils.__listify(_name)}"
53+
path = if _name
54+
"_resolve/cluster/#{Utils.__listify(_name)}"
55+
else
56+
'_resolve/cluster'
57+
end
5558
params = Utils.process_params(arguments)
5659

5760
Elasticsearch::API::Response.new(

elasticsearch-api/spec/elasticsearch/api/actions/indices/resolve_cluster_spec.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,38 @@
1717

1818
require 'spec_helper'
1919

20-
describe 'client.indices#delete_alias' do
21-
20+
describe 'client.indices#resolve_cluster' do
2221
let(:expected_args) do
2322
[
2423
'GET',
25-
'_resolve/cluster/foo',
24+
path,
2625
{},
2726
nil,
2827
{},
29-
{ defined_params: { name: 'foo'}, endpoint: 'indices.resolve_cluster' }
28+
otel
3029
]
3130
end
3231

3332
context 'when there is no name specified' do
3433
let(:client) do
3534
Class.new { include Elasticsearch::API }.new
3635
end
36+
let(:path) { '_resolve/cluster' }
37+
let(:otel) do
38+
{ endpoint: 'indices.resolve_cluster' }
39+
end
3740

38-
it 'raises an exception' do
39-
expect {
40-
client.indices.resolve_cluster
41-
}.to raise_exception(ArgumentError)
41+
it 'performs the request' do
42+
expect(client_double.indices.resolve_cluster).to be_a Elasticsearch::API::Response
4243
end
4344
end
4445

45-
4646
context 'when name is specified' do
47+
let(:path) { '_resolve/cluster/foo' }
48+
let(:otel) do
49+
{ defined_params: { name: 'foo' }, endpoint: 'indices.resolve_cluster' }
50+
end
51+
4752
it 'performs the request' do
4853
expect(client_double.indices.resolve_cluster(name: 'foo')).to be_a Elasticsearch::API::Response
4954
end

0 commit comments

Comments
 (0)