1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | namespace OpenSearch\Endpoints; |
23: | |
24: | use OpenSearch\Endpoints\AbstractEndpoint; |
25: | |
26: | |
27: | |
28: | |
29: | class Count extends AbstractEndpoint |
30: | { |
31: | public function getURI(): string |
32: | { |
33: | $index = $this->index ?? null; |
34: | if (isset($index)) { |
35: | return "/$index/_count"; |
36: | } |
37: | return "/_count"; |
38: | } |
39: | |
40: | public function getParamWhitelist(): array |
41: | { |
42: | return [ |
43: | 'allow_no_indices', |
44: | 'analyze_wildcard', |
45: | 'analyzer', |
46: | 'default_operator', |
47: | 'df', |
48: | 'expand_wildcards', |
49: | 'ignore_throttled', |
50: | 'ignore_unavailable', |
51: | 'lenient', |
52: | 'min_score', |
53: | 'preference', |
54: | 'q', |
55: | 'routing', |
56: | 'terminate_after', |
57: | 'pretty', |
58: | 'human', |
59: | 'error_trace', |
60: | 'source', |
61: | 'filter_path' |
62: | ]; |
63: | } |
64: | |
65: | public function getMethod(): string |
66: | { |
67: | return isset($this->body) ? 'POST' : 'GET'; |
68: | } |
69: | |
70: | public function setBody($body): static |
71: | { |
72: | if (isset($body) !== true) { |
73: | return $this; |
74: | } |
75: | $this->body = $body; |
76: | |
77: | return $this; |
78: | } |
79: | } |
80: | |