1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenStack\DataProcessing\v1; |
4
|
|
|
|
5
|
|
|
use OpenStack\Common\Service\AbstractService; |
6
|
|
|
use OpenStack\Common\Transport\Utils; |
7
|
|
|
use OpenStack\DataProcessing\v1\Models\Cluster; |
8
|
|
|
use OpenStack\DataProcessing\v1\Models\ClusterTemplate; |
9
|
|
|
use OpenStack\DataProcessing\v1\Models\DataSource; |
10
|
|
|
use OpenStack\DataProcessing\v1\Models\Image; |
11
|
|
|
use OpenStack\DataProcessing\v1\Models\Job; |
12
|
|
|
use OpenStack\DataProcessing\v1\Models\JobBinary; |
13
|
|
|
use OpenStack\DataProcessing\v1\Models\JobBinaryInternal; |
14
|
|
|
use OpenStack\DataProcessing\v1\Models\JobConfig; |
15
|
|
|
use OpenStack\DataProcessing\v1\Models\JobExecution; |
16
|
|
|
use OpenStack\DataProcessing\v1\Models\NodeGroup; |
17
|
|
|
use OpenStack\DataProcessing\v1\Models\NodeGroupTemplate; |
18
|
|
|
use OpenStack\DataProcessing\v1\Models\Plugin; |
19
|
|
|
use Psr\Http\Message\StreamInterface; |
20
|
|
|
|
21
|
|
|
class Service extends AbstractService |
22
|
|
|
{ |
23
|
|
|
public function listClusters(array $options = [], callable $mapFn = null): \Generator |
24
|
|
|
{ |
25
|
|
|
return $this->model(Cluster::class)->enumerate($this->api->getClusters(), $options, $mapFn); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getCluster(array $options = []): Cluster |
29
|
|
|
{ |
30
|
|
|
$cluster = $this->model(Cluster::class); |
31
|
|
|
$cluster->populateFromArray($options); |
32
|
|
|
|
33
|
|
|
return $cluster; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function createCluster(array $options = []): Cluster |
37
|
|
|
{ |
38
|
|
|
return $this->model(Cluster::class)->create($options); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function createMultipleClusters(array $options = []) |
42
|
|
|
{ |
43
|
|
|
if (!array_key_exists("count", $options)) { |
44
|
|
|
throw new \RuntimeException("Require 'count'"); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$response = $this->execute($this->api->postClusters(), $options); |
|
|
|
|
48
|
|
|
# For multiple clusters, the current API returns only cluster IDs. |
49
|
|
|
$ids = Utils::flattenJson(Utils::jsonDecode($response), 'clusters'); |
50
|
|
|
if ($response->getStatusCode() === 204 || empty($ids)) { |
51
|
|
|
return; |
52
|
|
|
} |
53
|
|
|
foreach ($ids as $id) { |
54
|
|
|
$cluster = $this->model(Cluster::class); |
55
|
|
|
$cluster->id = $id; |
|
|
|
|
56
|
|
|
yield $cluster; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function scaleCluster(array $options = []): Cluster |
61
|
|
|
{ |
62
|
|
|
return $this->model(Cluster::class)->scale($options); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function createDataSource(array $options = []): Datasource |
66
|
|
|
{ |
67
|
|
|
return $this->model(DataSource::class)->create($options); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getDataSource(array $options = []): Datasource |
71
|
|
|
{ |
72
|
|
|
$source = $this->model(DataSource::class); |
73
|
|
|
$source->populateFromArray($options); |
74
|
|
|
|
75
|
|
|
return $source; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function listDataSources(array $options = [], callable $mapFn = null): \Generator |
79
|
|
|
{ |
80
|
|
|
return $this->model(DataSource::class)->enumerate($this->api->getDataSources(), $options, $mapFn); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function createClusterTemplate(array $options = []): ClusterTemplate |
84
|
|
|
{ |
85
|
|
|
return $this->model(ClusterTemplate::class)->create($options); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getClusterTemplate(array $options = []): ClusterTemplate |
89
|
|
|
{ |
90
|
|
|
$clusterTemplate = $this->model(ClusterTemplate::class); |
91
|
|
|
$clusterTemplate->populateFromArray($options); |
92
|
|
|
|
93
|
|
|
return $clusterTemplate; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function listClusterTemplates(array $options = [], callable $mapFn = null): \Generator |
97
|
|
|
{ |
98
|
|
|
return $this->model(ClusterTemplate::class)->enumerate($this->api->getClusterTemplates(), $options, $mapFn); |
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getNodeGroupTemplate(array $options = []): NodeGroupTemplate |
102
|
|
|
{ |
103
|
|
|
$nodeGroupTemplate = $this->model(NodeGroupTemplate::class); |
104
|
|
|
$nodeGroupTemplate->populateFromArray($options); |
105
|
|
|
|
106
|
|
|
return $nodeGroupTemplate; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function listNodeGroupTemplates(array $options = [], callable $mapFn = null): \Generator |
110
|
|
|
{ |
111
|
|
|
return $this->model(NodeGroupTemplate::class)->enumerate($this->api->getNodeGroupTemplates(), $options, $mapFn); |
|
|
|
|
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function createNodeGroupTemplate(array $options = []): NodeGroupTemplate |
115
|
|
|
{ |
116
|
|
|
return $this->model(NodeGroupTemplate::class)->create($options); |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function listJobBinaries(array $options = [], callable $mapFn = null): \Generator |
120
|
|
|
{ |
121
|
|
|
return $this->model(JobBinary::class)->enumerate($this->api->getJobBinaries(), $options, $mapFn); |
|
|
|
|
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function getJobBinary(array $options = []): JobBinary |
125
|
|
|
{ |
126
|
|
|
$binary = $this->model(JobBinary::class); |
127
|
|
|
$binary->populateFromArray($options); |
128
|
|
|
|
129
|
|
|
return $binary; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function createJobBinary(array $options = []): JobBinary |
133
|
|
|
{ |
134
|
|
|
return $this->model(JobBinary::class)->create($options); |
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getJobBinaryInternal(array $options = []): JobBinaryInternal |
138
|
|
|
{ |
139
|
|
|
$jobBinaryInternal = $this->model(JobBinaryInternal::class); |
140
|
|
|
$jobBinaryInternal->populateFromArray($options); |
141
|
|
|
|
142
|
|
|
return $jobBinaryInternal; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function listJobBinaryInternals(array $options = [], callable $mapFn = null): \Generator |
146
|
|
|
{ |
147
|
|
|
return $this->model(JobBinaryInternal::class)->enumerate($this->api->getJobBinaryInternals(), $options, $mapFn); |
|
|
|
|
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function createJobBinaryInternal(StreamInterface $stream): JobBinaryInternal |
151
|
|
|
{ |
152
|
|
|
$options = [ |
153
|
|
|
'name' => $stream->getMetadata('uri'), |
154
|
|
|
'data' => $stream, |
155
|
|
|
]; |
156
|
|
|
|
157
|
|
|
return $this->model(JobBinaryInternal::class)->create($options); |
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function createJob(array $options = []): Job |
161
|
|
|
{ |
162
|
|
|
return $this->model(Job::class)->create($options); |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getJob(array $options = []): Job |
166
|
|
|
{ |
167
|
|
|
$Job = $this->model(Job::class); |
168
|
|
|
$Job->populateFromArray($options); |
169
|
|
|
|
170
|
|
|
return $Job; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function listJobs(array $options = [], callable $mapFn = null): \Generator |
174
|
|
|
{ |
175
|
|
|
return $this->model(Job::class)->enumerate($this->api->getJobs(), $options, $mapFn); |
|
|
|
|
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function getJobExecution(array $options = []): JobExecution |
179
|
|
|
{ |
180
|
|
|
$JobExecution = $this->model(JobExecution::class); |
181
|
|
|
$JobExecution->populateFromArray($options); |
182
|
|
|
|
183
|
|
|
return $JobExecution; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function listJobExecutions(array $options = [], callable $mapFn = null): \Generator |
187
|
|
|
{ |
188
|
|
|
return $this->model(JobExecution::class)->enumerate($this->api->getJobExecutions(), $options, $mapFn); |
|
|
|
|
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
public function runJob(array $options = []): JobExecution |
192
|
|
|
{ |
193
|
|
|
return $this->getJob($options)->executeJob($options); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
public function getPlugin(array $options = []): Plugin |
197
|
|
|
{ |
198
|
|
|
$plugin = $this->model(Plugin::class); |
199
|
|
|
$plugin->populateFromArray($options); |
200
|
|
|
|
201
|
|
|
return $plugin; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
public function listPlugins(array $options = [], callable $mapFn = null): \Generator |
205
|
|
|
{ |
206
|
|
|
return $this->model(Plugin::class)->enumerate($this->api->getPlugins(), $options, $mapFn); |
|
|
|
|
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function getImage(array $options = []): Image |
210
|
|
|
{ |
211
|
|
|
$image = $this->model(Image::class); |
212
|
|
|
$image->populateFromArray($options); |
213
|
|
|
|
214
|
|
|
return $image; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function listImages(array $options = [], callable $mapFn = null): \Generator |
218
|
|
|
{ |
219
|
|
|
return $this->model(Image::class)->enumerate($this->api->getImages(), $options, $mapFn); |
|
|
|
|
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function listJobTypes(array $options = [], callable $mapFn = null): array |
|
|
|
|
223
|
|
|
{ |
224
|
|
|
return $this->model(Job::class)->getJobTypes($options); |
|
|
|
|
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
public function listNodeGroups(array $options = [], callable $mapFn = null): \Generator |
228
|
|
|
{ |
229
|
|
|
return $this->model(NodeGroup::class)->enumerate($this->api->getNodeGroups(), $options, $mapFn); |
|
|
|
|
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function getNodeGroup(array $options = [], callable $mapFn = null): array |
233
|
|
|
{ |
234
|
|
|
$nodeGroups = $this->model(NodeGroup::class)->enumerate($this->api->getNodeGroup(), $options, $mapFn); |
|
|
|
|
235
|
|
|
foreach ($nodeGroups as $nodeGroup) { |
236
|
|
|
$nodegroups = $nodeGroup->nodeGroups; |
237
|
|
|
foreach ($nodegroups as $nodegroup) { |
238
|
|
|
if ($nodegroup['id'] === $options['id']) { |
239
|
|
|
return $nodegroup; |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
return []; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function listJobConfigs(array $options = [], callable $mapFn = null): \Generator |
248
|
|
|
{ |
249
|
|
|
return $this->model(JobConfig::class)->enumerate($this->api->getJobConfigs(), $options, $mapFn); |
|
|
|
|
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function getJobConfig(array $options = []): JobConfig |
253
|
|
|
{ |
254
|
|
|
$jobConfig = $this->model(JobConfig::class); |
255
|
|
|
$jobConfig->populateFromArray($options); |
256
|
|
|
|
257
|
|
|
return $jobConfig; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.