diff --git a/opensearchpy/_async/client/cluster.py b/opensearchpy/_async/client/cluster.py index 9178c2b5d..bf03f26d2 100644 --- a/opensearchpy/_async/client/cluster.py +++ b/opensearchpy/_async/client/cluster.py @@ -267,11 +267,11 @@ async def state( ) async def stats( self, - metric: Any = None, - index_metric: Any = None, node_id: Any = None, params: Any = None, headers: Any = None, + metric: Any = None, + index_metric: Any = None, ) -> Any: """ Returns high-level overview of cluster statistics. @@ -308,7 +308,9 @@ async def stats( ( "/_cluster/stats" if node_id in SKIP_IN_PATH - else _make_path("_cluster", "stats", "nodes", node_id) + else _make_path( + "_cluster", "stats", "nodes", node_id, metric, index_metric + ) ), params=params, headers=headers, diff --git a/opensearchpy/client/cluster.py b/opensearchpy/client/cluster.py index a5e8dd7d5..a968a32fe 100644 --- a/opensearchpy/client/cluster.py +++ b/opensearchpy/client/cluster.py @@ -267,11 +267,11 @@ def state( ) def stats( self, - metric: Any = None, - index_metric: Any = None, node_id: Any = None, params: Any = None, headers: Any = None, + metric: Any = None, + index_metric: Any = None, ) -> Any: """ Returns high-level overview of cluster statistics. @@ -308,7 +308,9 @@ def stats( ( "/_cluster/stats" if node_id in SKIP_IN_PATH - else _make_path("_cluster", "stats", "nodes", node_id) + else _make_path( + "_cluster", "stats", "nodes", node_id, metric, index_metric + ) ), params=params, headers=headers, diff --git a/test_opensearchpy/test_client/test_overrides.py b/test_opensearchpy/test_client/test_overrides.py index 160a8bdd5..b7057dc87 100644 --- a/test_opensearchpy/test_client/test_overrides.py +++ b/test_opensearchpy/test_client/test_overrides.py @@ -98,6 +98,12 @@ def test_cluster_stats(self) -> None: self.client.cluster.stats(node_id="test-node") self.assert_url_called("GET", "/_cluster/stats/nodes/test-node") + self.client.cluster.stats(node_id="test-node", metric="indices") + self.assert_url_called("GET", "/_cluster/stats/indices/nodes/test-node") + + self.client.cluster.stats(node_id="test-node", metric="indices", index_metric="analysis") + self.assert_url_called("GET", "/_cluster/stats/indices/analysis/nodes/test-node") + def test_indices_put_mapping(self) -> None: self.client.indices.put_mapping(body={}) self.assert_url_called("PUT", "/_all/_mapping") diff --git a/utils/templates/overrides/cluster/stats b/utils/templates/overrides/cluster/stats index 3223013a7..0db78ea1a 100644 --- a/utils/templates/overrides/cluster/stats +++ b/utils/templates/overrides/cluster/stats @@ -1,5 +1,12 @@ {% extends "base" %} +{% block func_params %} + node_id: Any = None, + params: Any = None, + headers: Any = None, + metric: Any = None, + index_metric: Any = None, +{% endblock %} {% block request %} - return await self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params, headers=headers) + return await self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", metric, index_metric, "nodes", node_id), params=params, headers=headers) {% endblock%}