diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 23cef512..5f60581d 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -12,9 +12,26 @@ from .nodes import NodesClient from .remote import RemoteClient from .snapshot import SnapshotClient from .tasks import TasksClient -from .xpack import XPackClient, XPACK_NAMESPACES +from .xpack import XPackClient from .utils import query_params, _make_path, SKIP_IN_PATH +# xpack APIs +from .ccr import CcrClient +from .data_frame import Data_FrameClient +from .deprecation import DeprecationClient +from .graph import GraphClient +from .ilm import IlmClient +from .license import LicenseClient +from .migration import MigrationClient +from .ml import MlClient +from .monitoring import MonitoringClient +from .rollup import RollupClient +from .security import SecurityClient +from .sql import SqlClient +from .ssl import SslClient +from .watcher import WatcherClient + + logger = logging.getLogger("elasticsearch") @@ -215,12 +232,22 @@ class Elasticsearch(object): self.snapshot = SnapshotClient(self) self.tasks = TasksClient(self) - # new style access to x-pack features without .xpack step - for namespace, NamespacedClient in XPACK_NAMESPACES.items(): - setattr(self, namespace, NamespacedClient(self)) - - # old style xpack access self.xpack = XPackClient(self) + self.ccr = CcrClient(self) + self.data_frame = Data_FrameClient(self) + self.deprecation = DeprecationClient(self) + self.graph = GraphClient(self) + self.ilm = IlmClient(self) + self.indices = IndicesClient(self) + self.license = LicenseClient(self) + self.migration = MigrationClient(self) + self.ml = MlClient(self) + self.monitoring = MonitoringClient(self) + self.rollup = RollupClient(self) + self.security = SecurityClient(self) + self.sql = SqlClient(self) + self.ssl = SslClient(self) + self.watcher = WatcherClient(self) def __repr__(self): try: @@ -245,6 +272,8 @@ class Elasticsearch(object): return body + # AUTO-GENERATED-API-DEFINITIONS # + @query_params() def ping(self, params=None): """ diff --git a/elasticsearch/client/xpack/ccr.py b/elasticsearch/client/ccr.py similarity index 98% rename from elasticsearch/client/xpack/ccr.py rename to elasticsearch/client/ccr.py index c9153eaa..469e556f 100644 --- a/elasticsearch/client/xpack/ccr.py +++ b/elasticsearch/client/ccr.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class CcrClient(NamespacedClient): diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index 361f7754..cd186bae 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -122,7 +122,7 @@ class ClusterClient(NamespacedClient): """ url = "/_cluster/stats" if node_id: - url = _make_path("_cluster","stats","nodes", node_id) + url = _make_path("_cluster", "stats", "nodes", node_id) return self.transport.perform_request("GET", url, params=params) @query_params( diff --git a/elasticsearch/client/xpack/data_frame.py b/elasticsearch/client/data_frame.py similarity index 98% rename from elasticsearch/client/xpack/data_frame.py rename to elasticsearch/client/data_frame.py index 8be6aae4..fc758ce0 100644 --- a/elasticsearch/client/xpack/data_frame.py +++ b/elasticsearch/client/data_frame.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class Data_FrameClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/deprecation.py b/elasticsearch/client/deprecation.py similarity index 87% rename from elasticsearch/client/xpack/deprecation.py rename to elasticsearch/client/deprecation.py index b8ca7510..48e99446 100644 --- a/elasticsearch/client/xpack/deprecation.py +++ b/elasticsearch/client/deprecation.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, query_params, _make_path class DeprecationClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/graph.py b/elasticsearch/client/graph.py similarity index 91% rename from elasticsearch/client/xpack/graph.py rename to elasticsearch/client/graph.py index f847151d..2d438b5e 100644 --- a/elasticsearch/client/xpack/graph.py +++ b/elasticsearch/client/graph.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class GraphClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/ilm.py b/elasticsearch/client/ilm.py similarity index 97% rename from elasticsearch/client/xpack/ilm.py rename to elasticsearch/client/ilm.py index ea0c91da..6b3938bc 100644 --- a/elasticsearch/client/xpack/ilm.py +++ b/elasticsearch/client/ilm.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IlmClient(NamespacedClient): diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 979f3ebf..cee065db 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -79,10 +79,7 @@ class IndicesClient(NamespacedClient): ) @query_params( - "master_timeout", - "timeout", - "wait_for_active_shards", - "include_type_name", + "master_timeout", "timeout", "wait_for_active_shards", "include_type_name", ) def create(self, index, body=None, params=None): """ @@ -104,11 +101,7 @@ class IndicesClient(NamespacedClient): "PUT", _make_path(index), params=params, body=body ) - @query_params( - "master_timeout", - "timeout", - "wait_for_active_shards" - ) + @query_params("master_timeout", "timeout", "wait_for_active_shards") def clone(self, index, target, body=None, params=None): """ Clones an index @@ -127,7 +120,7 @@ class IndicesClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'target'.") return self.transport.perform_request( - "PUT", _make_path(index, '_clone', target), params=params, body=body + "PUT", _make_path(index, "_clone", target), params=params, body=body ) @query_params( @@ -1035,9 +1028,7 @@ class IndicesClient(NamespacedClient): "POST", _make_path(index, "_forcemerge"), params=params ) - @query_params( - "master_timeout", "timeout", "wait_for_active_shards" - ) + @query_params("master_timeout", "timeout", "wait_for_active_shards") def shrink(self, index, target, body=None, params=None): """ The shrink index API allows you to shrink an existing index into a new diff --git a/elasticsearch/client/xpack/license.py b/elasticsearch/client/license.py similarity index 97% rename from elasticsearch/client/xpack/license.py rename to elasticsearch/client/license.py index 071c2382..2f0fbc8c 100644 --- a/elasticsearch/client/xpack/license.py +++ b/elasticsearch/client/license.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class LicenseClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/migration.py b/elasticsearch/client/migration.py similarity index 84% rename from elasticsearch/client/xpack/migration.py rename to elasticsearch/client/migration.py index 589eb569..dd32e531 100644 --- a/elasticsearch/client/xpack/migration.py +++ b/elasticsearch/client/migration.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class MigrationClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/ml.py b/elasticsearch/client/ml.py similarity index 99% rename from elasticsearch/client/xpack/ml.py rename to elasticsearch/client/ml.py index dcccd53a..5b919edf 100644 --- a/elasticsearch/client/xpack/ml.py +++ b/elasticsearch/client/ml.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class MlClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/monitoring.py b/elasticsearch/client/monitoring.py similarity index 92% rename from elasticsearch/client/xpack/monitoring.py rename to elasticsearch/client/monitoring.py index b0776c0c..09086ab0 100644 --- a/elasticsearch/client/xpack/monitoring.py +++ b/elasticsearch/client/monitoring.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class MonitoringClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/rollup.py b/elasticsearch/client/rollup.py similarity index 98% rename from elasticsearch/client/xpack/rollup.py rename to elasticsearch/client/rollup.py index a2fe67da..ea82682c 100644 --- a/elasticsearch/client/xpack/rollup.py +++ b/elasticsearch/client/rollup.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class RollupClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/security.py b/elasticsearch/client/security.py similarity index 99% rename from elasticsearch/client/xpack/security.py rename to elasticsearch/client/security.py index 81114fa4..5c43452e 100644 --- a/elasticsearch/client/xpack/security.py +++ b/elasticsearch/client/security.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SecurityClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/sql.py b/elasticsearch/client/sql.py similarity index 94% rename from elasticsearch/client/xpack/sql.py rename to elasticsearch/client/sql.py index cab2383f..e545228d 100644 --- a/elasticsearch/client/xpack/sql.py +++ b/elasticsearch/client/sql.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SqlClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/ssl.py b/elasticsearch/client/ssl.py similarity index 81% rename from elasticsearch/client/xpack/ssl.py rename to elasticsearch/client/ssl.py index 9043d679..64cce183 100644 --- a/elasticsearch/client/xpack/ssl.py +++ b/elasticsearch/client/ssl.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SslClient(NamespacedClient): diff --git a/elasticsearch/client/xpack/watcher.py b/elasticsearch/client/watcher.py similarity index 98% rename from elasticsearch/client/xpack/watcher.py rename to elasticsearch/client/watcher.py index 657e1989..df77f164 100644 --- a/elasticsearch/client/xpack/watcher.py +++ b/elasticsearch/client/watcher.py @@ -1,4 +1,4 @@ -from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class WatcherClient(NamespacedClient): diff --git a/elasticsearch/client/xpack.py b/elasticsearch/client/xpack.py new file mode 100644 index 00000000..7de877c9 --- /dev/null +++ b/elasticsearch/client/xpack.py @@ -0,0 +1,29 @@ +from .utils import NamespacedClient, query_params + + +class XPackClient(NamespacedClient): + def __getattr__(self, attr_name): + return getattr(self.client, attr_name) + + # AUTO-GENERATED-API-DEFINITIONS # + @query_params("categories", "human") + def info(self, params=None): + """ + Retrieve information about xpack, including build number/timestamp and license status + ``_ + + :arg categories: Comma-separated list of info categories. Can be any of: + build, license, features + :arg human: Presents additional info for humans (feature descriptions + and X-Pack tagline) + """ + return self.transport.perform_request("GET", "/_xpack", params=params) + + @query_params("master_timeout") + def usage(self, params=None): + """ + Retrieve information about xpack features usage + + :arg master_timeout: Specify timeout for watch write operation + """ + return self.transport.perform_request("GET", "/_xpack/usage", params=params) diff --git a/elasticsearch/client/xpack/__init__.py b/elasticsearch/client/xpack/__init__.py deleted file mode 100644 index 12d6f093..00000000 --- a/elasticsearch/client/xpack/__init__.py +++ /dev/null @@ -1,64 +0,0 @@ -from ..utils import NamespacedClient, query_params - -from .ccr import CcrClient -from .data_frame import Data_FrameClient -from .deprecation import DeprecationClient -from .graph import GraphClient -from .ilm import IlmClient -from ..indices import IndicesClient -from .license import LicenseClient -from .migration import MigrationClient -from .ml import MlClient -from .monitoring import MonitoringClient -from .rollup import RollupClient -from .security import SecurityClient -from .sql import SqlClient -from .ssl import SslClient -from .watcher import WatcherClient - -XPACK_NAMESPACES = { - "ccr": CcrClient, - "data_frame": Data_FrameClient, - "deprecation": DeprecationClient, - "graph": GraphClient, - "ilm": IlmClient, - "indices": IndicesClient, - "license": LicenseClient, - "migration": MigrationClient, - "ml": MlClient, - "monitoring": MonitoringClient, - "rollup": RollupClient, - "security": SecurityClient, - "sql": SqlClient, - "ssl": SslClient, - "watcher": WatcherClient, -} - -class XPackClient(NamespacedClient): - def __init__(self, *args, **kwargs): - super(XPackClient, self).__init__(*args, **kwargs) - - for namespace in XPACK_NAMESPACES: - setattr(self, namespace, getattr(self.client, namespace)) - - @query_params("categories", "human") - def info(self, params=None): - """ - Retrieve information about xpack, including build number/timestamp and license status - ``_ - - :arg categories: Comma-separated list of info categories. Can be any of: - build, license, features - :arg human: Presents additional info for humans (feature descriptions - and X-Pack tagline) - """ - return self.transport.perform_request("GET", "/_xpack", params=params) - - @query_params("master_timeout") - def usage(self, params=None): - """ - Retrieve information about xpack features usage - - :arg master_timeout: Specify timeout for watch write operation - """ - return self.transport.perform_request("GET", "/_xpack/usage", params=params)