1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Namespaces;
6
7/**
8 * Class NodesNamespace
9 *
10 * @category Elasticsearch
11 * @package  Elasticsearch\Namespaces\NodesNamespace
12 * @author   Zachary Tong <zach@elastic.co>
13 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
14 * @link     http://elastic.co
15 */
16class NodesNamespace extends AbstractNamespace
17{
18    /**
19     * $params['fields']        = (list) A comma-separated list of fields for `fielddata` metric (supports wildcards)
20     *        ['metric_family'] = (enum) Limit the information returned to a certain metric family
21     *        ['metric']        = (enum) Limit the information returned for `indices` family to a specific metric
22     *        ['node_id']       = (list) 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
23     *        ['all']           = (boolean) Return all available information
24     *        ['clear']         = (boolean) Reset the default level of detail
25     *        ['fs']            = (boolean) Return information about the filesystem
26     *        ['http']          = (boolean) Return information about HTTP
27     *        ['indices']       = (boolean) Return information about indices
28     *        ['jvm']           = (boolean) Return information about the JVM
29     *        ['network']       = (boolean) Return information about network
30     *        ['os']            = (boolean) Return information about the operating system
31     *        ['process']       = (boolean) Return information about the Elasticsearch process
32     *        ['thread_pool']   = (boolean) Return information about the thread pool
33     *        ['transport']     = (boolean) Return information about transport
34     *
35     * @return callable|array
36     */
37    public function stats(array $params = [])
38    {
39        $nodeID = $this->extractArgument($params, 'node_id');
40        $metric = $this->extractArgument($params, 'metric');
41        $index_metric = $this->extractArgument($params, 'index_metric');
42
43        /**
44 * @var callable $endpointBuilder
45*/
46        $endpointBuilder = $this->endpoints;
47
48        /**
49 * @var \Elasticsearch\Endpoints\Cluster\Nodes\Stats $endpoint
50*/
51        $endpoint = $endpointBuilder('Cluster\Nodes\Stats');
52        $endpoint->setNodeID($nodeID)
53            ->setMetric($metric)
54            ->setIndexMetric($index_metric)
55            ->setParams($params);
56
57        return $this->performRequest($endpoint);
58    }
59
60    /**
61     * $params['node_id']       = (list) 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
62     *        ['metric']        = (list) A comma-separated list of metrics you wish returned. Leave empty to return all.
63     *        ['timeout']       = (time) Explicit operation timeout
64     *
65     * @return callable|array
66     */
67    public function usage(array $params = [])
68    {
69        $nodeID = $this->extractArgument($params, 'node_id');
70        $metric = $this->extractArgument($params, 'metric');
71
72        /**
73 * @var callable $endpointBuilder
74*/
75        $endpointBuilder = $this->endpoints;
76
77        /**
78 * @var \Elasticsearch\Endpoints\Cluster\Nodes\Usage $endpoint
79*/
80        $endpoint = $endpointBuilder('Cluster\Nodes\Usage');
81        $endpoint->setNodeID($nodeID)->setMetric($metric);
82        $endpoint->setParams($params);
83
84        return $this->performRequest($endpoint);
85    }
86
87    /**
88     * $params['node_id']       = (list) 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
89     *        ['metric']        = (list) A comma-separated list of metrics you wish returned. Leave empty to return all.
90     *        ['flat_settings'] = (boolean) Return settings in flat format (default: false)
91     *        ['human']         = (boolean) Whether to return time and byte values in human-readable format.
92     *
93     * @return callable|array
94     */
95    public function info(array $params = [])
96    {
97        $nodeID = $this->extractArgument($params, 'node_id');
98        $metric = $this->extractArgument($params, 'metric');
99
100        /**
101 * @var callable $endpointBuilder
102*/
103        $endpointBuilder = $this->endpoints;
104
105        /**
106 * @var \Elasticsearch\Endpoints\Cluster\Nodes\Info $endpoint
107*/
108        $endpoint = $endpointBuilder('Cluster\Nodes\Info');
109        $endpoint->setNodeID($nodeID)->setMetric($metric);
110        $endpoint->setParams($params);
111
112        return $this->performRequest($endpoint);
113    }
114
115    /**
116     * $params['node_id']   = (list) 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
117     *        ['interval']  = (time) The interval for the second sampling of threads
118     *        ['snapshots'] = (number) Number of samples of thread stacktrace (default: 10)
119     *        ['threads']   = (number) Specify the number of threads to provide information for (default: 3)
120     *        ['type']      = (enum) The type to sample (default: cpu)
121     *
122     * @return callable|array
123     */
124    public function hotThreads(array $params = [])
125    {
126        $nodeID = $this->extractArgument($params, 'node_id');
127
128        /**
129 * @var callable $endpointBuilder
130*/
131        $endpointBuilder = $this->endpoints;
132
133        /**
134 * @var \Elasticsearch\Endpoints\Cluster\Nodes\HotThreads $endpoint
135*/
136        $endpoint = $endpointBuilder('Cluster\Nodes\HotThreads');
137        $endpoint->setNodeID($nodeID);
138        $endpoint->setParams($params);
139
140        return $this->performRequest($endpoint);
141    }
142
143    /**
144     * $params['node_id']   = (list) 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
145     *
146     * @return callable|array
147     */
148    public function reloadSecureSettings(array $params = [])
149    {
150        $nodeID = $this->extractArgument($params, 'node_id');
151
152        /**
153 * @var callable $endpointBuilder
154*/
155        $endpointBuilder = $this->endpoints;
156
157        /**
158 * @var \Elasticsearch\Endpoints\Cluster\Nodes\ReloadSecureSettings $endpoint
159*/
160        $endpoint = $endpointBuilder('Cluster\Nodes\ReloadSecureSettings');
161        $endpoint->setNodeID($nodeID);
162        $endpoint->setParams($params);
163
164        return $this->performRequest($endpoint);
165    }
166}
167