| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace OpenSearch\Endpoints\Ml; |
| 15: | |
| 16: | use OpenSearch\Exception\RuntimeException; |
| 17: | use OpenSearch\Endpoints\AbstractEndpoint; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | class Predict extends AbstractEndpoint |
| 23: | { |
| 24: | protected $algorithm_name; |
| 25: | protected $model_id; |
| 26: | |
| 27: | public function getURI(): string |
| 28: | { |
| 29: | $algorithm_name = $this->algorithm_name ?? null; |
| 30: | $model_id = $this->model_id ?? null; |
| 31: | if (isset($algorithm_name) && isset($model_id)) { |
| 32: | return '/_plugins/_ml/_predict/' . rawurlencode($algorithm_name) . '/' . rawurlencode($model_id); |
| 33: | } |
| 34: | throw new RuntimeException('Missing parameter for the endpoint ml.predict'); |
| 35: | } |
| 36: | |
| 37: | public function getParamWhitelist(): array |
| 38: | { |
| 39: | return [ |
| 40: | 'pretty', |
| 41: | 'human', |
| 42: | 'error_trace', |
| 43: | 'source', |
| 44: | 'filter_path' |
| 45: | ]; |
| 46: | } |
| 47: | |
| 48: | public function getMethod(): string |
| 49: | { |
| 50: | return 'POST'; |
| 51: | } |
| 52: | |
| 53: | public function setBody($body): static |
| 54: | { |
| 55: | if (is_null($body)) { |
| 56: | return $this; |
| 57: | } |
| 58: | $this->body = $body; |
| 59: | |
| 60: | return $this; |
| 61: | } |
| 62: | |
| 63: | public function setAlgorithmName($algorithm_name): static |
| 64: | { |
| 65: | if (is_null($algorithm_name)) { |
| 66: | return $this; |
| 67: | } |
| 68: | $this->algorithm_name = $algorithm_name; |
| 69: | |
| 70: | return $this; |
| 71: | } |
| 72: | |
| 73: | public function setModelId($model_id): static |
| 74: | { |
| 75: | if (is_null($model_id)) { |
| 76: | return $this; |
| 77: | } |
| 78: | $this->model_id = $model_id; |
| 79: | |
| 80: | return $this; |
| 81: | } |
| 82: | } |
| 83: | |