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\Common\Exceptions\RuntimeException; |
25: | use OpenSearch\Endpoints\AbstractEndpoint; |
26: | |
27: | |
28: | |
29: | |
30: | class Index extends AbstractEndpoint |
31: | { |
32: | public function getURI(): string |
33: | { |
34: | if (isset($this->index) !== true) { |
35: | throw new RuntimeException( |
36: | 'index is required for index' |
37: | ); |
38: | } |
39: | $index = $this->index; |
40: | $id = $this->id ?? null; |
41: | if (isset($id)) { |
42: | return "/$index/_doc/$id"; |
43: | } |
44: | return "/$index/_doc"; |
45: | } |
46: | |
47: | public function getParamWhitelist(): array |
48: | { |
49: | return [ |
50: | 'if_primary_term', |
51: | 'if_seq_no', |
52: | 'op_type', |
53: | 'pipeline', |
54: | 'refresh', |
55: | 'require_alias', |
56: | 'routing', |
57: | 'timeout', |
58: | 'version', |
59: | 'version_type', |
60: | 'wait_for_active_shards', |
61: | 'pretty', |
62: | 'human', |
63: | 'error_trace', |
64: | 'source', |
65: | 'filter_path' |
66: | ]; |
67: | } |
68: | |
69: | public function getMethod(): string |
70: | { |
71: | return 'POST'; |
72: | } |
73: | |
74: | public function setBody($body): static |
75: | { |
76: | if (isset($body) !== true) { |
77: | return $this; |
78: | } |
79: | $this->body = $body; |
80: | |
81: | return $this; |
82: | } |
83: | } |
84: | |