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\Snapshot; |
23: | |
24: | use OpenSearch\Common\Exceptions\RuntimeException; |
25: | use OpenSearch\Endpoints\AbstractEndpoint; |
26: | |
27: | |
28: | |
29: | |
30: | class Get extends AbstractEndpoint |
31: | { |
32: | protected $repository; |
33: | protected $snapshot; |
34: | |
35: | public function getURI(): string |
36: | { |
37: | $repository = $this->repository ?? null; |
38: | $snapshot = $this->snapshot ?? null; |
39: | if (isset($repository) && isset($snapshot)) { |
40: | return "/_snapshot/$repository/$snapshot"; |
41: | } |
42: | throw new RuntimeException('Missing parameter for the endpoint snapshot.get'); |
43: | } |
44: | |
45: | public function getParamWhitelist(): array |
46: | { |
47: | return [ |
48: | 'cluster_manager_timeout', |
49: | 'ignore_unavailable', |
50: | 'master_timeout', |
51: | 'verbose', |
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 setRepository($repository): static |
66: | { |
67: | if (isset($repository) !== true) { |
68: | return $this; |
69: | } |
70: | $this->repository = $repository; |
71: | |
72: | return $this; |
73: | } |
74: | |
75: | public function setSnapshot($snapshot): static |
76: | { |
77: | if (isset($snapshot) !== true) { |
78: | return $this; |
79: | } |
80: | if (is_array($snapshot) === true) { |
81: | $snapshot = implode(",", $snapshot); |
82: | } |
83: | $this->snapshot = $snapshot; |
84: | |
85: | return $this; |
86: | } |
87: | |
88: | protected function getParamDeprecation(): array |
89: | { |
90: | return ['master_timeout' => 'cluster_manager_timeout']; |
91: | } |
92: | } |
93: | |