1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | namespace OpenSearch\Endpoints\Knn; |
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/_knn/$node_id/stats/$stat"; |
34: | } |
35: | if (isset($node_id)) { |
36: | return "/_plugins/_knn/$node_id/stats"; |
37: | } |
38: | if (isset($stat)) { |
39: | return "/_plugins/_knn/stats/$stat"; |
40: | } |
41: | return "/_plugins/_knn/stats"; |
42: | } |
43: | |
44: | public function getParamWhitelist(): array |
45: | { |
46: | return [ |
47: | 'timeout', |
48: | 'pretty', |
49: | 'human', |
50: | 'error_trace', |
51: | 'source', |
52: | 'filter_path' |
53: | ]; |
54: | } |
55: | |
56: | public function getMethod(): string |
57: | { |
58: | return 'GET'; |
59: | } |
60: | |
61: | public function setNodeId($node_id): static |
62: | { |
63: | if (isset($node_id) !== true) { |
64: | return $this; |
65: | } |
66: | if (is_array($node_id) === true) { |
67: | $node_id = implode(",", $node_id); |
68: | } |
69: | $this->node_id = $node_id; |
70: | |
71: | return $this; |
72: | } |
73: | |
74: | public function setStat($stat): static |
75: | { |
76: | if (isset($stat) !== true) { |
77: | return $this; |
78: | } |
79: | if (is_array($stat) === true) { |
80: | $stat = implode(",", $stat); |
81: | } |
82: | $this->stat = $stat; |
83: | |
84: | return $this; |
85: | } |
86: | } |
87: | |