1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | namespace OpenSearch\Endpoints\Neural; |
17: | |
18: | use OpenSearch\Endpoints\AbstractEndpoint; |
19: | |
20: | |
21: | |
22: | |
23: | class Stats extends AbstractEndpoint |
24: | { |
25: | protected $node_id; |
26: | protected $stat; |
27: | |
28: | public function getURI(): string |
29: | { |
30: | $node_id = $this->node_id ?? null; |
31: | $stat = $this->stat ?? null; |
32: | if (isset($node_id) && isset($stat)) { |
33: | return '/_plugins/_neural/' . rawurlencode($node_id) . '/stats/' . rawurlencode($stat); |
34: | } |
35: | if (isset($node_id)) { |
36: | return '/_plugins/_neural/' . rawurlencode($node_id) . '/stats'; |
37: | } |
38: | if (isset($stat)) { |
39: | return '/_plugins/_neural/stats/' . rawurlencode($stat); |
40: | } |
41: | return '/_plugins/_neural/stats'; |
42: | } |
43: | |
44: | public function getParamWhitelist(): array |
45: | { |
46: | return [ |
47: | 'flat_stat_paths', |
48: | 'include_all_nodes', |
49: | 'include_individual_nodes', |
50: | 'include_info', |
51: | 'include_metadata', |
52: | 'pretty', |
53: | 'human', |
54: | 'error_trace', |
55: | 'source', |
56: | 'filter_path' |
57: | ]; |
58: | } |
59: | |
60: | public function getMethod(): string |
61: | { |
62: | return 'GET'; |
63: | } |
64: | |
65: | public function setNodeId($node_id): static |
66: | { |
67: | if (is_null($node_id)) { |
68: | return $this; |
69: | } |
70: | $this->node_id = $node_id; |
71: | |
72: | return $this; |
73: | } |
74: | |
75: | public function setStat($stat): static |
76: | { |
77: | if (isset($stat) !== true) { |
78: | return $this; |
79: | } |
80: | if (is_array($stat) === true) { |
81: | $stat = implode(",", $stat); |
82: | } |
83: | $this->stat = $stat; |
84: | |
85: | return $this; |
86: | } |
87: | } |
88: | |