diff --git a/docs/api.rst b/docs/api.rst
index 3e69437f..77827abe 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -38,3 +38,9 @@ Cluster
.. autoclass:: ClusterClient
:members:
+Nodes
+-----
+
+.. autoclass:: NodesClient
+ :members:
+
diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py
index 081f2d17..e3e7e454 100644
--- a/elasticsearch/client/__init__.py
+++ b/elasticsearch/client/__init__.py
@@ -5,6 +5,7 @@ from ..transport import Transport
from ..exceptions import NotFoundError, TransportError
from .indices import IndicesClient
from .cluster import ClusterClient
+from .nodes import NodesClient
from .utils import query_params, _make_path
logger = logging.getLogger('elasticsearch')
@@ -78,6 +79,7 @@ class Elasticsearch(object):
# use weakref to make GC's work a little easier
self.indices = IndicesClient(weakref.proxy(self))
self.cluster = ClusterClient(weakref.proxy(self))
+ self.nodes = NodesClient(weakref.proxy(self))
def __repr__(self):
try:
diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py
index a86a021a..750be98e 100644
--- a/elasticsearch/client/cluster.py
+++ b/elasticsearch/client/cluster.py
@@ -117,67 +117,3 @@ class ClusterClient(NamespacedClient):
_, data = self.transport.perform_request('PUT', '/_cluster/settings', params=params, body=body)
return data
- @query_params('fields')
- def node_stats(self, node_id=None, metric_family=None, metric=None, params=None):
- """
- Retrieve one or more (or all) of the cluster nodes statistics.
- ``_
-
- :arg node_id: A comma-separated list of node IDs or names to limit the
- returned information; use `_local` to return information from the node
- you're connecting to, leave empty to get information from all nodes
- :arg metric_family: Limit the information returned to a certain metric
- family. A comma-separated list, metric families:
- "all","fs","http","indices","jvm","network","os","process","thread_pool"
- or "transport".
- :arg metric: Limit the information returned for `indices` family to a
- specific metric. Isn't used if `indices` (or `all`) metric family isn't
- specified. Possible values: "completion","docs", "fielddata",
- "filter_cache", "flush", "get", "id_cache", "indexing", "merges",
- "refresh", "search", "store", "warmer"
- :arg fields: A comma-separated list of fields to return detailed information
- for, when returning the `indices` metric family (supports wildcards)
- """
- if metric and not metric_family:
- metric_family = 'all'
- _, data = self.transport.perform_request('GET',
- _make_path('_nodes', node_id, 'stats', metric_family, metric), params=params)
- return data
-
- @query_params('flat_settings')
- def node_info(self, node_id=None, metric=None, params=None):
- """
- Retrieve one or more (or all) of the cluster nodes' information.
- ``_
-
- :arg node_id: A comma-separated list of node IDs or names to limit the
- returned information; use `_local` to return information from the node
- you're connecting to, leave empty to get information from all nodes
- :arg metric: A comma-separated list of metrics you wish returned. Leave
- empty to return all. Possible options are "settings", "os",
- "process", "jvm", "thread_pool", "network", "transport", "http" and
- "plugin"
- :arg flat_settings: Return settings in flat format (default: false)
- """
- if not node_id and metric:
- node_id = '_all'
- _, data = self.transport.perform_request('GET',
- _make_path('_nodes', node_id, metric), params=params)
- return data
-
- @query_params('delay', 'exit')
- def node_shutdown(self, node_id=None, params=None):
- """
- Shutdown one or more (or all) nodes in the cluster.
- ``_
-
- :arg node_id: A comma-separated list of node IDs or names to perform
- the operation on; use `_local` to perform the operation on the node
- you're connected to, leave empty to perform the operation on all nodes
- :arg delay: Set the delay for the operation (default: 1s)
- :arg exit: Exit the JVM as well (default: true)
- """
- _, data = self.transport.perform_request('POST',
- _make_path('_cluster', 'nodes', node_id, '_shutdown'), params=params)
- return data
-
diff --git a/elasticsearch/client/nodes.py b/elasticsearch/client/nodes.py
new file mode 100644
index 00000000..77474d62
--- /dev/null
+++ b/elasticsearch/client/nodes.py
@@ -0,0 +1,106 @@
+from .utils import NamespacedClient, query_params, _make_path
+
+class NodesClient(NamespacedClient):
+ @query_params('flat_settings', 'human')
+ def info(self, node_id=None, metric=None, params=None):
+ """
+ The cluster nodes info API allows to retrieve one or more (or all) of
+ the cluster nodes information.
+ ``_
+
+ :arg node_id: A comma-separated list of node IDs or names to limit the
+ returned information; use `_local` to return information from the
+ node you're connecting to, leave empty to get information from all
+ nodes
+ :arg metric: A comma-separated list of metrics you wish returned. Leave
+ empty to return all. Choices are "settings", "os", "process",
+ "jvm", "thread_pool", "network", "transport", "http", "plugin"
+ :arg flat_settings: Return settings in flat format (default: false)
+ :arg human: Whether to return time and byte values in human-readable
+ format., default False
+ """
+ _, data = self.transport.perform_request('GET', _make_path('_nodes',
+ node_id, metric), params=params)
+ return data
+
+ @query_params('delay', 'exit')
+ def shutdown(self, node_id=None, params=None):
+ """
+ The nodes shutdown API allows to shutdown one or more (or all) nodes in
+ the cluster.
+ ``_
+
+ :arg node_id: A comma-separated list of node IDs or names to perform the
+ operation on; use `_local` to perform the operation on the node
+ you're connected to, leave empty to perform the operation on all
+ nodes
+ :arg delay: Set the delay for the operation (default: 1s)
+ :arg exit: Exit the JVM as well (default: true)
+ """
+ _, data = self.transport.perform_request('POST', _make_path('_cluster',
+ 'nodes', node_id, '_shutdown'), params=params)
+ return data
+
+ @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', 'human', 'level', 'types')
+ def stats(self, node_id=None, metric=None, index_metric=None, params=None):
+ """
+ The cluster nodes stats API allows to retrieve one or more (or all) of
+ the cluster nodes statistics.
+ ``_
+
+ :arg node_id: A comma-separated list of node IDs or names to limit the
+ returned information; use `_local` to return information from the
+ node you're connecting to, leave empty to get information from all
+ nodes
+ :arg metric: Limit the information returned to the specified metrics.
+ Possible options are: "_all", "breaker", "fs", "http", "indices",
+ "jvm", "network", "os", "process", "thread_pool", "transport"
+ :arg index_metric: Limit the information returned for `indices` metric
+ to the specific index metrics. Isn't used if `indices` (or `all`)
+ metric isn't specified. Possible options are: "_all", "completion",
+ "docs", "fielddata", "filter_cache", "flush", "get", "id_cache",
+ "indexing", "merge", "percolate", "refresh", "search", "segments",
+ "store", "warmer"
+ :arg completion_fields: A comma-separated list of fields for `fielddata`
+ and `suggest` index metric (supports wildcards)
+ :arg fielddata_fields: A comma-separated list of fields for `fielddata`
+ index metric (supports wildcards)
+ :arg fields: A comma-separated list of fields for `fielddata` and
+ `completion` index metric (supports wildcards)
+ :arg groups: A comma-separated list of search groups for `search` index
+ metric
+ :arg human: Whether to return time and byte values in human-readable
+ format., default False
+ :arg level: Return indices stats aggregated at node, index or shard
+ level, default 'node'
+ :arg types: A comma-separated list of document types for the `indexing`
+ index metric
+ """
+ _, data = self.transport.perform_request('GET', _make_path('_nodes',
+ node_id, 'stats', metric, index_metric), params=params)
+ return data
+
+ @query_params('type_', 'interval', 'snapshots', 'threads')
+ def hot_threads(self, node_id=None, params=None):
+ """
+ An API allowing to get the current hot threads on each node in the cluster.
+ ``_
+
+ :arg node_id: A comma-separated list of node IDs or names to limit the
+ returned information; use `_local` to return information from the
+ node you're connecting to, leave empty to get information from all
+ nodes
+ :arg type_: The type to sample (default: cpu)
+ :arg interval: The interval for the second sampling of threads
+ :arg snapshots: Number of samples of thread stacktrace (default: 10)
+ :arg threads: Specify the number of threads to provide information for
+ (default: 3)
+ """
+ # avoid python reserved words
+ if params and 'type_' in params:
+ params['type'] = params.pop('type_')
+ _, data = self.transport.perform_request('GET', _make_path('_nodes',
+ node_id, 'hot_threads'), params=params)
+ return data
+
+