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: | class UploadChunk extends AbstractEndpoint |
25: | { |
26: | protected $chunk_number; |
27: | protected $model_id; |
28: | |
29: | public function getURI(): string |
30: | { |
31: | $chunk_number = $this->chunk_number ?? null; |
32: | $model_id = $this->model_id ?? null; |
33: | if (isset($model_id) && isset($chunk_number)) { |
34: | return "/_plugins/_ml/models/$model_id/upload_chunk/$chunk_number"; |
35: | } |
36: | throw new RuntimeException('Missing parameter for the endpoint ml.upload_chunk'); |
37: | } |
38: | |
39: | public function getParamWhitelist(): array |
40: | { |
41: | return [ |
42: | 'pretty', |
43: | 'human', |
44: | 'error_trace', |
45: | 'source', |
46: | 'filter_path' |
47: | ]; |
48: | } |
49: | |
50: | public function getMethod(): string |
51: | { |
52: | return 'POST'; |
53: | } |
54: | |
55: | public function setBody($body): static |
56: | { |
57: | if (is_null($body)) { |
58: | return $this; |
59: | } |
60: | $this->body = $body; |
61: | |
62: | return $this; |
63: | } |
64: | |
65: | public function setChunkNumber($chunk_number): static |
66: | { |
67: | if (is_null($chunk_number)) { |
68: | return $this; |
69: | } |
70: | $this->chunk_number = $chunk_number; |
71: | |
72: | return $this; |
73: | } |
74: | |
75: | public function setModelId($model_id): static |
76: | { |
77: | if (is_null($model_id)) { |
78: | return $this; |
79: | } |
80: | $this->model_id = $model_id; |
81: | |
82: | return $this; |
83: | } |
84: | } |
85: | |