1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | namespace OpenSearch\Endpoints\Ism; |
17: | |
18: | use OpenSearch\Common\Exceptions\RuntimeException; |
19: | use OpenSearch\Endpoints\AbstractEndpoint; |
20: | |
21: | |
22: | |
23: | |
24: | class PutPolicy extends AbstractEndpoint |
25: | { |
26: | protected $policy_id; |
27: | |
28: | public function getURI(): string |
29: | { |
30: | if (isset($this->policy_id) !== true) { |
31: | throw new RuntimeException( |
32: | 'policy_id is required for put_policy' |
33: | ); |
34: | } |
35: | $policy_id = $this->policy_id; |
36: | return "/_plugins/_ism/policies/$policy_id"; |
37: | } |
38: | |
39: | public function getParamWhitelist(): array |
40: | { |
41: | return [ |
42: | 'if_primary_term', |
43: | 'if_seq_no', |
44: | 'pretty', |
45: | 'human', |
46: | 'error_trace', |
47: | 'source', |
48: | 'filter_path' |
49: | ]; |
50: | } |
51: | |
52: | public function getMethod(): string |
53: | { |
54: | return 'PUT'; |
55: | } |
56: | |
57: | public function setBody($body): static |
58: | { |
59: | if (isset($body) !== true) { |
60: | return $this; |
61: | } |
62: | $this->body = $body; |
63: | |
64: | return $this; |
65: | } |
66: | |
67: | public function setPolicyId($policy_id): static |
68: | { |
69: | if (isset($policy_id) !== true) { |
70: | return $this; |
71: | } |
72: | $this->policy_id = $policy_id; |
73: | |
74: | return $this; |
75: | } |
76: | } |
77: | |