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\Indices; |
23: | |
24: | use OpenSearch\Common\Exceptions\RuntimeException; |
25: | use OpenSearch\Endpoints\AbstractEndpoint; |
26: | |
27: | |
28: | |
29: | |
30: | class GetFieldMapping extends AbstractEndpoint |
31: | { |
32: | protected $fields; |
33: | |
34: | public function getURI(): string |
35: | { |
36: | if (isset($this->fields) !== true) { |
37: | throw new RuntimeException( |
38: | 'fields is required for get_field_mapping' |
39: | ); |
40: | } |
41: | $fields = $this->fields; |
42: | $index = $this->index ?? null; |
43: | if (isset($index)) { |
44: | return "/$index/_mapping/field/$fields"; |
45: | } |
46: | return "/_mapping/field/$fields"; |
47: | } |
48: | |
49: | public function getParamWhitelist(): array |
50: | { |
51: | return [ |
52: | 'allow_no_indices', |
53: | 'expand_wildcards', |
54: | 'ignore_unavailable', |
55: | 'include_defaults', |
56: | 'local', |
57: | 'pretty', |
58: | 'human', |
59: | 'error_trace', |
60: | 'source', |
61: | 'filter_path' |
62: | ]; |
63: | } |
64: | |
65: | public function getMethod(): string |
66: | { |
67: | return 'GET'; |
68: | } |
69: | |
70: | public function setFields($fields): static |
71: | { |
72: | if (isset($fields) !== true) { |
73: | return $this; |
74: | } |
75: | if (is_array($fields) === true) { |
76: | $fields = implode(",", $fields); |
77: | } |
78: | $this->fields = $fields; |
79: | |
80: | return $this; |
81: | } |
82: | } |
83: | |