1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | namespace OpenSearch\Endpoints\Knn; |
17: | |
18: | use OpenSearch\Endpoints\AbstractEndpoint; |
19: | |
20: | |
21: | |
22: | |
23: | class TrainModel extends AbstractEndpoint |
24: | { |
25: | protected $model_id; |
26: | |
27: | public function getURI(): string |
28: | { |
29: | $model_id = $this->model_id ?? null; |
30: | if (isset($model_id)) { |
31: | return "/_plugins/_knn/models/$model_id/_train"; |
32: | } |
33: | return "/_plugins/_knn/models/_train"; |
34: | } |
35: | |
36: | public function getParamWhitelist(): array |
37: | { |
38: | return [ |
39: | 'preference', |
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 (isset($body) !== true) { |
56: | return $this; |
57: | } |
58: | $this->body = $body; |
59: | |
60: | return $this; |
61: | } |
62: | |
63: | public function setModelId($model_id): static |
64: | { |
65: | if (isset($model_id) !== true) { |
66: | return $this; |
67: | } |
68: | $this->model_id = $model_id; |
69: | |
70: | return $this; |
71: | } |
72: | } |
73: | |