Skip to content

Commit 1829781

Browse files
committed
[XPACK] Top level methods defined in xpack client
1 parent a738419 commit 1829781

File tree

1 file changed

+20
-8
lines changed
  • elasticsearch-xpack/lib/elasticsearch

1 file changed

+20
-8
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ class Client
4545
module Elasticsearch
4646
module Transport
4747
class Client
48+
# When a method is called on the client, if it's one of the xpack root
49+
# namespace methods, send them to the xpack client.
50+
# E.g.: client.xpack.usage => client.usage
51+
# Excluding `info` since OSS and XPACK both have info endpoints.
52+
TOP_LEVEL_METHODS = [
53+
:open_point_in_time,
54+
:close_point_in_time,
55+
:usage
56+
].freeze
57+
58+
def method_missing(method, *args, &block)
59+
return xpack.send(method, *args, &block) if TOP_LEVEL_METHODS.include?(method)
60+
61+
super
62+
end
63+
64+
def respond_to_missing?(method_name, *args)
65+
TOP_LEVEL_METHODS.include?(method_name) || super
66+
end
67+
4868
def xpack
4969
@xpack_client ||= Elasticsearch::XPack::API::Client.new(self)
5070
end
@@ -132,14 +152,6 @@ def eql
132152
def snapshot_lifecycle_management
133153
@snapshot_lifecycle_management ||= xpack.snapshot_lifecycle_management
134154
end
135-
136-
def open_point_in_time(arguments = {})
137-
xpack.open_point_in_time(arguments)
138-
end
139-
140-
def close_point_in_time(arguments = {})
141-
xpack.close_point_in_time(arguments)
142-
end
143155
end
144156
end
145157
end if defined?(Elasticsearch::Transport::Client)

0 commit comments

Comments
 (0)