| 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\Exception\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) || $this->policy_id === '') { |
| 31: | throw new RuntimeException('policy_id is required for put_policy'); |
| 32: | } |
| 33: | $policy_id = $this->policy_id; |
| 34: | |
| 35: | return '/_plugins/_ism/policies/' . rawurlencode($policy_id); |
| 36: | } |
| 37: | |
| 38: | public function getParamWhitelist(): array |
| 39: | { |
| 40: | return [ |
| 41: | 'if_primary_term', |
| 42: | 'if_seq_no', |
| 43: | 'pretty', |
| 44: | 'human', |
| 45: | 'error_trace', |
| 46: | 'source', |
| 47: | 'filter_path' |
| 48: | ]; |
| 49: | } |
| 50: | |
| 51: | public function getMethod(): string |
| 52: | { |
| 53: | return 'PUT'; |
| 54: | } |
| 55: | |
| 56: | public function setBody($body): static |
| 57: | { |
| 58: | if (is_null($body)) { |
| 59: | return $this; |
| 60: | } |
| 61: | $this->body = $body; |
| 62: | |
| 63: | return $this; |
| 64: | } |
| 65: | |
| 66: | public function setPolicyId($policy_id): static |
| 67: | { |
| 68: | if (is_null($policy_id)) { |
| 69: | return $this; |
| 70: | } |
| 71: | $this->policy_id = $policy_id; |
| 72: | |
| 73: | return $this; |
| 74: | } |
| 75: | } |
| 76: | |