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