|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\CloudApi; |
|
4
|
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\ApplicationResponse; |
|
6
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
|
7
|
|
|
use AcquiaCloudApi\Response\BackupResponse; |
|
8
|
|
|
use AcquiaCloudApi\Response\BackupsResponse; |
|
9
|
|
|
use AcquiaCloudApi\Response\BranchesResponse; |
|
10
|
|
|
use AcquiaCloudApi\Response\CronResponse; |
|
11
|
|
|
use AcquiaCloudApi\Response\CronsResponse; |
|
12
|
|
|
use AcquiaCloudApi\Response\DatabasesResponse; |
|
13
|
|
|
use AcquiaCloudApi\Response\DomainsResponse; |
|
14
|
|
|
use AcquiaCloudApi\Response\EnvironmentResponse; |
|
15
|
|
|
use AcquiaCloudApi\Response\EnvironmentsResponse; |
|
16
|
|
|
use AcquiaCloudApi\Response\InsightsResponse; |
|
17
|
|
|
use AcquiaCloudApi\Response\InvitationsResponse; |
|
18
|
|
|
use AcquiaCloudApi\Response\MembersResponse; |
|
19
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
|
20
|
|
|
use AcquiaCloudApi\Response\OrganizationsResponse; |
|
21
|
|
|
use AcquiaCloudApi\Response\PermissionsResponse; |
|
22
|
|
|
use AcquiaCloudApi\Response\RolesResponse; |
|
23
|
|
|
use AcquiaCloudApi\Response\ServersResponse; |
|
24
|
|
|
use AcquiaCloudApi\Response\TasksResponse; |
|
25
|
|
|
use AcquiaCloudApi\Response\TeamsResponse; |
|
26
|
|
|
use Psr\Http\Message\StreamInterface; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class Client |
|
30
|
|
|
* @package AcquiaCloudApi\CloudApi |
|
31
|
|
|
*/ |
|
32
|
|
|
class Client implements ClientInterface |
|
33
|
|
|
{ |
|
34
|
|
|
protected $connector; |
|
35
|
|
|
|
|
36
|
|
|
protected $query = []; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Client constructor. |
|
40
|
|
|
* @param ConnectorInterface $connector |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(ConnectorInterface $connector) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->connector = $connector; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param ConnectorInterface $connector |
|
49
|
|
|
* |
|
50
|
|
|
* @return static |
|
51
|
|
|
*/ |
|
52
|
|
|
public static function factory(ConnectorInterface $connector) |
|
53
|
|
|
{ |
|
54
|
|
|
$client = new static( |
|
55
|
|
|
$connector |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
return $client; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get query from Client. |
|
63
|
|
|
* |
|
64
|
|
|
* @return array |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getQuery() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->query; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Clear query. |
|
73
|
|
|
*/ |
|
74
|
|
|
public function clearQuery() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->query = []; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param string $name |
|
81
|
|
|
* @param string $value |
|
82
|
|
|
*/ |
|
83
|
|
|
public function addQuery($name, $value) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->query = array_merge_recursive($this->query, [$name => $value]); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Shows all applications. |
|
90
|
|
|
* |
|
91
|
|
|
* @return ApplicationsResponse |
|
92
|
|
|
*/ |
|
93
|
|
|
public function applications() |
|
94
|
|
|
{ |
|
95
|
|
|
return new ApplicationsResponse($this->connector->request('get', '/applications', $this->query)); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Shows information about an application. |
|
100
|
|
|
* |
|
101
|
|
|
* @param string $uuid |
|
102
|
|
|
* @return ApplicationResponse |
|
103
|
|
|
*/ |
|
104
|
|
|
public function application($uuid) |
|
105
|
|
|
{ |
|
106
|
|
|
return new ApplicationResponse($this->connector->request('get', "/applications/${uuid}", $this->query)); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Renames an application. |
|
111
|
|
|
* |
|
112
|
|
|
* @param string $uuid |
|
113
|
|
|
* @param string $name |
|
114
|
|
|
* @return OperationResponse |
|
115
|
|
|
*/ |
|
116
|
|
|
public function renameApplication($uuid, $name) |
|
117
|
|
|
{ |
|
118
|
|
|
|
|
119
|
|
|
$options = [ |
|
120
|
|
|
'form_params' => [ |
|
121
|
|
|
'name' => $name, |
|
122
|
|
|
], |
|
123
|
|
|
]; |
|
124
|
|
|
|
|
125
|
|
|
return new OperationResponse($this->connector->request('put', "/applications/${uuid}", $options, $this->query)); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Shows all code branches and tags in an application. |
|
130
|
|
|
* |
|
131
|
|
|
* @param string $uuid |
|
132
|
|
|
* @return BranchesResponse |
|
133
|
|
|
*/ |
|
134
|
|
|
public function code($uuid) |
|
135
|
|
|
{ |
|
136
|
|
|
return new BranchesResponse($this->connector->request('get', "/applications/${uuid}/code", $this->query)); |
|
|
|
|
|
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Shows all databases in an application. |
|
141
|
|
|
* |
|
142
|
|
|
* @param string $uuid |
|
143
|
|
|
* @return DatabasesResponse |
|
144
|
|
|
*/ |
|
145
|
|
|
public function databases($uuid) |
|
146
|
|
|
{ |
|
147
|
|
|
return new DatabasesResponse($this->connector->request('get', "/applications/${uuid}/databases", $this->query)); |
|
|
|
|
|
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Shows all databases in an environment. |
|
152
|
|
|
* |
|
153
|
|
|
* @param string $id |
|
154
|
|
|
* @return DatabasesResponse |
|
155
|
|
|
*/ |
|
156
|
|
|
public function environmentDatabases($id) |
|
157
|
|
|
{ |
|
158
|
|
|
return new DatabasesResponse($this->connector->request('get', "/environments/${id}/databases", $this->query)); |
|
|
|
|
|
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* Copies a database from an environment to an environment. |
|
163
|
|
|
* |
|
164
|
|
|
* @param string $environmentFromUuid |
|
165
|
|
|
* @param string $dbName |
|
166
|
|
|
* @param string $environmentToUuid |
|
167
|
|
|
* @return OperationResponse |
|
168
|
|
|
*/ |
|
169
|
|
View Code Duplication |
public function databaseCopy($environmentFromUuid, $dbName, $environmentToUuid) |
|
|
|
|
|
|
170
|
|
|
{ |
|
171
|
|
|
$options = [ |
|
172
|
|
|
'form_params' => [ |
|
173
|
|
|
'name' => $dbName, |
|
174
|
|
|
'source' => $environmentFromUuid, |
|
175
|
|
|
], |
|
176
|
|
|
]; |
|
177
|
|
|
|
|
178
|
|
|
return new OperationResponse( |
|
179
|
|
|
$this->connector->request('post', "/environments/${environmentToUuid}/databases", $this->query, $options) |
|
180
|
|
|
); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Create a new database. |
|
185
|
|
|
* |
|
186
|
|
|
* @param string $uuid |
|
187
|
|
|
* @param string $name |
|
188
|
|
|
* @return OperationResponse |
|
189
|
|
|
*/ |
|
190
|
|
|
public function databaseCreate($uuid, $name) |
|
191
|
|
|
{ |
|
192
|
|
|
$options = [ |
|
193
|
|
|
'form_params' => [ |
|
194
|
|
|
'name' => $name, |
|
195
|
|
|
], |
|
196
|
|
|
]; |
|
197
|
|
|
|
|
198
|
|
|
return new OperationResponse( |
|
199
|
|
|
$this->connector->request('post', "/applications/${uuid}/databases", $this->query, $options) |
|
200
|
|
|
); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Delete a database. |
|
205
|
|
|
* |
|
206
|
|
|
* @param string $uuid |
|
207
|
|
|
* @param string $name |
|
208
|
|
|
* @return OperationResponse |
|
209
|
|
|
*/ |
|
210
|
|
|
public function databaseDelete($uuid, $name) |
|
211
|
|
|
{ |
|
212
|
|
|
return new OperationResponse( |
|
213
|
|
|
$this->connector->request('post', "/applications/${uuid}/databases/${name}", $this->query) |
|
214
|
|
|
); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Backup a database. |
|
219
|
|
|
* |
|
220
|
|
|
* @param string $id |
|
221
|
|
|
* @param string $dbName |
|
222
|
|
|
* @return OperationResponse |
|
223
|
|
|
*/ |
|
224
|
|
|
public function createDatabaseBackup($id, $dbName) |
|
225
|
|
|
{ |
|
226
|
|
|
return new OperationResponse( |
|
227
|
|
|
$this->connector->request('post', "/environments/${id}/databases/${dbName}/backups", $this->query) |
|
228
|
|
|
); |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* Shows all database backups in an environment. |
|
233
|
|
|
* |
|
234
|
|
|
* @param string $id |
|
235
|
|
|
* @param string $dbName |
|
236
|
|
|
* @return BackupsResponse |
|
237
|
|
|
*/ |
|
238
|
|
|
public function databaseBackups($id, $dbName) |
|
239
|
|
|
{ |
|
240
|
|
|
return new BackupsResponse( |
|
241
|
|
|
$this->connector->request('get', "/environments/${id}/databases/${dbName}/backups", $this->query) |
|
|
|
|
|
|
242
|
|
|
); |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* Gets information about a database backup. |
|
247
|
|
|
* |
|
248
|
|
|
* @param string $id |
|
249
|
|
|
* @param string $backupId |
|
250
|
|
|
* @return BackupResponse |
|
251
|
|
|
*/ |
|
252
|
|
|
public function databaseBackup($id, $backupId) |
|
253
|
|
|
{ |
|
254
|
|
|
return new BackupResponse( |
|
255
|
|
|
$this->connector->request('get', "/environments/${id}/database-backups/${backupId}", $this->query) |
|
256
|
|
|
); |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* Restores a database backup to a database in an environment. |
|
261
|
|
|
* |
|
262
|
|
|
* @param string $id |
|
263
|
|
|
* @param string $backupId |
|
264
|
|
|
* @return OperationResponse |
|
265
|
|
|
*/ |
|
266
|
|
|
public function restoreDatabaseBackup($id, $backupId) |
|
267
|
|
|
{ |
|
268
|
|
|
return new OperationResponse( |
|
269
|
|
|
$this->connector->request( |
|
270
|
|
|
'post', |
|
271
|
|
|
"/environments/${id}/database-backups/${backupId}/actions/restore", |
|
272
|
|
|
$this->query |
|
273
|
|
|
) |
|
274
|
|
|
); |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* Copies files from an environment to another environment. |
|
279
|
|
|
* |
|
280
|
|
|
* @param string $idFrom |
|
281
|
|
|
* @param string $idTo |
|
282
|
|
|
* @return OperationResponse |
|
283
|
|
|
*/ |
|
284
|
|
|
public function copyFiles($idFrom, $idTo) |
|
285
|
|
|
{ |
|
286
|
|
|
$options = [ |
|
287
|
|
|
'form_params' => [ |
|
288
|
|
|
'source' => $idFrom, |
|
289
|
|
|
], |
|
290
|
|
|
]; |
|
291
|
|
|
|
|
292
|
|
|
return new OperationResponse( |
|
293
|
|
|
$this->connector->request('post', "/environments/${idTo}/files", $this->query, $options) |
|
294
|
|
|
); |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* Deploys a code branch/tag to an environment. |
|
299
|
|
|
* |
|
300
|
|
|
* @param string $id |
|
301
|
|
|
* @param string $branch |
|
302
|
|
|
* @return OperationResponse |
|
303
|
|
|
*/ |
|
304
|
|
|
public function switchCode($id, $branch) |
|
305
|
|
|
{ |
|
306
|
|
|
|
|
307
|
|
|
$options = [ |
|
308
|
|
|
'form_params' => [ |
|
309
|
|
|
'branch' => $branch, |
|
310
|
|
|
], |
|
311
|
|
|
]; |
|
312
|
|
|
|
|
313
|
|
|
return new OperationResponse( |
|
314
|
|
|
$this->connector->request('post', "/environments/${id}/code/actions/switch", $this->query, $options) |
|
315
|
|
|
); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* Shows all domains on an environment. |
|
320
|
|
|
* |
|
321
|
|
|
* @param string $id |
|
322
|
|
|
* @return DomainsResponse |
|
323
|
|
|
*/ |
|
324
|
|
|
public function domains($id) |
|
325
|
|
|
{ |
|
326
|
|
|
return new DomainsResponse($this->connector->request('get', "/environments/${id}/domains", $this->query)); |
|
|
|
|
|
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* Adds a domain to an environment. |
|
331
|
|
|
* |
|
332
|
|
|
* @param string $id |
|
333
|
|
|
* @param string $hostname |
|
334
|
|
|
* @return OperationResponse |
|
335
|
|
|
*/ |
|
336
|
|
|
public function createDomain($id, $hostname) |
|
337
|
|
|
{ |
|
338
|
|
|
|
|
339
|
|
|
$options = [ |
|
340
|
|
|
'form_params' => [ |
|
341
|
|
|
'hostname' => $hostname, |
|
342
|
|
|
], |
|
343
|
|
|
]; |
|
344
|
|
|
|
|
345
|
|
|
return new OperationResponse( |
|
346
|
|
|
$this->connector->request('post', "/environments/${id}/domains", $this->query, $options) |
|
347
|
|
|
); |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* Deletes a domain from an environment. |
|
352
|
|
|
* |
|
353
|
|
|
* @param string $id |
|
354
|
|
|
* @param string $domain |
|
355
|
|
|
* @return OperationResponse |
|
356
|
|
|
*/ |
|
357
|
|
|
public function deleteDomain($id, $domain) |
|
358
|
|
|
{ |
|
359
|
|
|
return new OperationResponse( |
|
360
|
|
|
$this->connector->request('delete', "/environments/${id}/domains/${domain}", $this->query) |
|
361
|
|
|
); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* Purges varnish for selected domains in an environment. |
|
366
|
|
|
* |
|
367
|
|
|
* @param string $id |
|
368
|
|
|
* @param array $domains |
|
369
|
|
|
* @return OperationResponse |
|
370
|
|
|
*/ |
|
371
|
|
|
public function purgeVarnishCache($id, array $domains) |
|
372
|
|
|
{ |
|
373
|
|
|
|
|
374
|
|
|
$options = [ |
|
375
|
|
|
'form_params' => [ |
|
376
|
|
|
'domains' => $domains, |
|
377
|
|
|
], |
|
378
|
|
|
]; |
|
379
|
|
|
|
|
380
|
|
|
return new OperationResponse( |
|
381
|
|
|
$this->connector->request( |
|
382
|
|
|
'post', |
|
383
|
|
|
"/environments/${id}/domains/actions/clear-varnish", |
|
384
|
|
|
$this->query, |
|
385
|
|
|
$this->query, |
|
386
|
|
|
$options |
|
|
|
|
|
|
387
|
|
|
) |
|
388
|
|
|
); |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* Shows all tasks in an application. |
|
393
|
|
|
* |
|
394
|
|
|
* @param string $uuid |
|
395
|
|
|
* @return TasksResponse |
|
396
|
|
|
*/ |
|
397
|
|
|
public function tasks($uuid) |
|
398
|
|
|
{ |
|
399
|
|
|
return new TasksResponse($this->connector->request('get', "/applications/${uuid}/tasks", $this->query)); |
|
|
|
|
|
|
400
|
|
|
} |
|
401
|
|
|
|
|
402
|
|
|
/** |
|
403
|
|
|
* Shows all environments in an application. |
|
404
|
|
|
* |
|
405
|
|
|
* @param string $uuid |
|
406
|
|
|
* @return EnvironmentsResponse |
|
407
|
|
|
*/ |
|
408
|
|
|
public function environments($uuid) |
|
409
|
|
|
{ |
|
410
|
|
|
return new EnvironmentsResponse( |
|
411
|
|
|
$this->connector->request('get', "/applications/${uuid}/environments", $this->query) |
|
|
|
|
|
|
412
|
|
|
); |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* Gets information about an environment. |
|
417
|
|
|
* |
|
418
|
|
|
* @param string $id |
|
419
|
|
|
* @return EnvironmentResponse |
|
420
|
|
|
*/ |
|
421
|
|
|
public function environment($id) |
|
422
|
|
|
{ |
|
423
|
|
|
return new EnvironmentResponse($this->connector->request('get', "/environments/${id}", $this->query)); |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* Renames an environment. |
|
428
|
|
|
* |
|
429
|
|
|
* @param string $id |
|
430
|
|
|
* @param string $label |
|
431
|
|
|
* @return OperationResponse |
|
432
|
|
|
*/ |
|
433
|
|
|
public function renameEnvironment($id, $label) |
|
434
|
|
|
{ |
|
435
|
|
|
|
|
436
|
|
|
$options = [ |
|
437
|
|
|
'form_params' => [ |
|
438
|
|
|
'label' => $label, |
|
439
|
|
|
], |
|
440
|
|
|
]; |
|
441
|
|
|
|
|
442
|
|
|
return new OperationResponse( |
|
443
|
|
|
$this->connector->request('post', "/environments/${id}/actions/change-label", $this->query, $options) |
|
444
|
|
|
); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* Show all servers associated with an environment. |
|
449
|
|
|
* |
|
450
|
|
|
* @param string $id |
|
451
|
|
|
* @return ServersResponse |
|
452
|
|
|
*/ |
|
453
|
|
|
public function servers($id) |
|
454
|
|
|
{ |
|
455
|
|
|
return new ServersResponse($this->connector->request('get', "/environments/${id}/servers", $this->query)); |
|
|
|
|
|
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* Enable livedev mode for an environment. |
|
460
|
|
|
* |
|
461
|
|
|
* @param string $id |
|
462
|
|
|
* @return OperationResponse |
|
463
|
|
|
*/ |
|
464
|
|
|
public function enableLiveDev($id) |
|
465
|
|
|
{ |
|
466
|
|
|
return new OperationResponse( |
|
467
|
|
|
$this->connector->request('post', "/environments/${id}/livedev/actions/enable", $this->query) |
|
468
|
|
|
); |
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
/** |
|
472
|
|
|
* Disable livedev mode for an environment. |
|
473
|
|
|
* |
|
474
|
|
|
* @param string $id |
|
475
|
|
|
* @return OperationResponse |
|
476
|
|
|
*/ |
|
477
|
|
|
public function disableLiveDev($id) |
|
478
|
|
|
{ |
|
479
|
|
|
|
|
480
|
|
|
$options = [ |
|
481
|
|
|
'form_params' => [ |
|
482
|
|
|
'discard' => 1, |
|
483
|
|
|
], |
|
484
|
|
|
]; |
|
485
|
|
|
|
|
486
|
|
|
return new OperationResponse( |
|
487
|
|
|
$this->connector->request('post', "/environments/${id}/livedev/actions/disable", $this->query, $options) |
|
488
|
|
|
); |
|
489
|
|
|
} |
|
490
|
|
|
|
|
491
|
|
|
/** |
|
492
|
|
|
* Enable production mode for an environment. |
|
493
|
|
|
* |
|
494
|
|
|
* @param string $id |
|
495
|
|
|
* @return OperationResponse |
|
496
|
|
|
*/ |
|
497
|
|
|
public function enableProductionMode($id) |
|
498
|
|
|
{ |
|
499
|
|
|
return new OperationResponse( |
|
500
|
|
|
$this->connector->request('post', "/environments/${id}/production-mode/actions/enable", $this->query) |
|
501
|
|
|
); |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* Disable production mode for an environment. |
|
506
|
|
|
* |
|
507
|
|
|
* @param string $id |
|
508
|
|
|
* @return OperationResponse |
|
509
|
|
|
*/ |
|
510
|
|
|
public function disableProductionMode($id) |
|
511
|
|
|
{ |
|
512
|
|
|
return new OperationResponse( |
|
513
|
|
|
$this->connector->request('post', "/environments/${id}/production-mode/actions/disable", $this->query) |
|
514
|
|
|
); |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* Show all cron tasks for an environment. |
|
519
|
|
|
* |
|
520
|
|
|
* @param string $id The environment ID |
|
521
|
|
|
* @return CronsResponse |
|
522
|
|
|
*/ |
|
523
|
|
|
public function crons($id) |
|
524
|
|
|
{ |
|
525
|
|
|
return new CronsResponse($this->connector->request('get', "/environments/${id}/crons", $this->query)); |
|
|
|
|
|
|
526
|
|
|
} |
|
527
|
|
|
|
|
528
|
|
|
/** |
|
529
|
|
|
* Get information about a cron task. |
|
530
|
|
|
* |
|
531
|
|
|
* @param string $id The environment ID |
|
532
|
|
|
* @param int $cronId |
|
533
|
|
|
* @return CronResponse |
|
534
|
|
|
*/ |
|
535
|
|
|
public function cron($id, $cronId) |
|
536
|
|
|
{ |
|
537
|
|
|
return new CronResponse($this->connector->request('get', "/environments/${id}/crons/${cronId}", $this->query)); |
|
538
|
|
|
} |
|
539
|
|
|
|
|
540
|
|
|
/** |
|
541
|
|
|
* Add a cron task. |
|
542
|
|
|
* |
|
543
|
|
|
* @param string $id |
|
544
|
|
|
* @param string $command |
|
545
|
|
|
* @param string $frequency |
|
546
|
|
|
* @param string $label |
|
547
|
|
|
* @return OperationResponse |
|
548
|
|
|
*/ |
|
549
|
|
View Code Duplication |
public function createCron($id, $command, $frequency, $label) |
|
|
|
|
|
|
550
|
|
|
{ |
|
551
|
|
|
|
|
552
|
|
|
$options = [ |
|
553
|
|
|
'form_params' => [ |
|
554
|
|
|
'command' => $command, |
|
555
|
|
|
'frequency' => $frequency, |
|
556
|
|
|
'label' => $label, |
|
557
|
|
|
], |
|
558
|
|
|
]; |
|
559
|
|
|
|
|
560
|
|
|
return new OperationResponse( |
|
561
|
|
|
$this->connector->request('post', "/environments/${id}/crons", $this->query, $options) |
|
562
|
|
|
); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
/** |
|
566
|
|
|
* Delete a cron task. |
|
567
|
|
|
* |
|
568
|
|
|
* @param string $id |
|
569
|
|
|
* @param int $cronId |
|
570
|
|
|
* @return OperationResponse |
|
571
|
|
|
*/ |
|
572
|
|
|
public function deleteCron($id, $cronId) |
|
573
|
|
|
{ |
|
574
|
|
|
return new OperationResponse( |
|
575
|
|
|
$this->connector->request('delete', "/environments/${id}/crons/${cronId}", $this->query) |
|
576
|
|
|
); |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
/** |
|
580
|
|
|
* Disable a cron task. |
|
581
|
|
|
* |
|
582
|
|
|
* @param string $id |
|
583
|
|
|
* @param int $cronId |
|
584
|
|
|
* @return OperationResponse |
|
585
|
|
|
*/ |
|
586
|
|
|
public function disableCron($id, $cronId) |
|
587
|
|
|
{ |
|
588
|
|
|
return new OperationResponse( |
|
589
|
|
|
$this->connector->request('post', "/environments/${id}/crons/${cronId}/actions/disable", $this->query) |
|
590
|
|
|
); |
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
/** |
|
594
|
|
|
* Enable a cron task. |
|
595
|
|
|
* |
|
596
|
|
|
* @param string $id |
|
597
|
|
|
* @param int $cronId |
|
598
|
|
|
* @return OperationResponse |
|
599
|
|
|
*/ |
|
600
|
|
|
public function enableCron($id, $cronId) |
|
601
|
|
|
{ |
|
602
|
|
|
return new OperationResponse( |
|
603
|
|
|
$this->connector->request('post', "/environments/${id}/crons/${cronId}/actions/enable", $this->query) |
|
604
|
|
|
); |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* @return StreamInterface |
|
609
|
|
|
*/ |
|
610
|
|
|
public function drushAliases() |
|
611
|
|
|
{ |
|
612
|
|
|
return $this->connector->request('get', '/account/drush-aliases/download', $this->query); |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
/** |
|
616
|
|
|
* Show insights data from an application. |
|
617
|
|
|
* |
|
618
|
|
|
* @param string $uuid |
|
619
|
|
|
* @return InsightsResponse |
|
620
|
|
|
*/ |
|
621
|
|
|
public function applicationInsights($uuid) |
|
622
|
|
|
{ |
|
623
|
|
|
return new InsightsResponse($this->connector->request('get', "/applications/${uuid}/insight", $this->query)); |
|
|
|
|
|
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
/** |
|
627
|
|
|
* Show insights data from a specific environment. |
|
628
|
|
|
* |
|
629
|
|
|
* @param string $id |
|
630
|
|
|
* @return InsightsResponse |
|
631
|
|
|
*/ |
|
632
|
|
|
public function environmentInsights($id) |
|
633
|
|
|
{ |
|
634
|
|
|
return new InsightsResponse($this->connector->request('get', "/environments/${id}/insight", $this->query)); |
|
|
|
|
|
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
/** |
|
638
|
|
|
* Show all organizations. |
|
639
|
|
|
* |
|
640
|
|
|
* @return OrganizationsResponse |
|
641
|
|
|
*/ |
|
642
|
|
|
public function organizations() |
|
643
|
|
|
{ |
|
644
|
|
|
return new OrganizationsResponse($this->connector->request('get', '/organizations', $this->query)); |
|
|
|
|
|
|
645
|
|
|
} |
|
646
|
|
|
|
|
647
|
|
|
/** |
|
648
|
|
|
* Show all applications in an organisation. |
|
649
|
|
|
* |
|
650
|
|
|
* @param string $uuid |
|
651
|
|
|
* |
|
652
|
|
|
* @return ApplicationsResponse |
|
653
|
|
|
*/ |
|
654
|
|
|
public function organizationApplications($uuid) |
|
655
|
|
|
{ |
|
656
|
|
|
return new ApplicationsResponse( |
|
657
|
|
|
$this->connector->request('get', "/organizations/${uuid}/applications", $this->query) |
|
|
|
|
|
|
658
|
|
|
); |
|
659
|
|
|
} |
|
660
|
|
|
|
|
661
|
|
|
/** |
|
662
|
|
|
* @param $name |
|
663
|
|
|
* @return OperationResponse |
|
664
|
|
|
*/ |
|
665
|
|
|
// public function organizationCreate($name) |
|
666
|
|
|
// { |
|
667
|
|
|
// $options = [ |
|
668
|
|
|
// 'form_params' => [ |
|
669
|
|
|
// 'name' => $name, |
|
670
|
|
|
// ], |
|
671
|
|
|
// ]; |
|
672
|
|
|
// |
|
673
|
|
|
// return new OperationResponse($this->request('post', '/organizations', $options)); |
|
674
|
|
|
// } |
|
675
|
|
|
|
|
676
|
|
|
/** |
|
677
|
|
|
* Show all roles in an organization. |
|
678
|
|
|
* |
|
679
|
|
|
* @param string $uuid |
|
680
|
|
|
* @return RolesResponse |
|
681
|
|
|
*/ |
|
682
|
|
|
public function organizationRoles($uuid) |
|
683
|
|
|
{ |
|
684
|
|
|
return new RolesResponse($this->connector->request('get', "/organizations/${uuid}/roles", $this->query)); |
|
|
|
|
|
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
/** |
|
688
|
|
|
* @param string $roleUuid |
|
689
|
|
|
* @param array $permissions |
|
690
|
|
|
* @return OperationResponse |
|
691
|
|
|
*/ |
|
692
|
|
|
public function updateRole($roleUuid, array $permissions) |
|
693
|
|
|
{ |
|
694
|
|
|
$options = [ |
|
695
|
|
|
'form_params' => [ |
|
696
|
|
|
'permissions' => $permissions, |
|
697
|
|
|
], |
|
698
|
|
|
]; |
|
699
|
|
|
|
|
700
|
|
|
return new OperationResponse( |
|
701
|
|
|
$this->connector->request('put', "/roles/${roleUuid}", $this->query, $options) |
|
702
|
|
|
); |
|
703
|
|
|
} |
|
704
|
|
|
|
|
705
|
|
|
/** |
|
706
|
|
|
* @param string $uuid |
|
707
|
|
|
* @param string $name |
|
708
|
|
|
* @param array $permissions |
|
709
|
|
|
* @param null|string $description |
|
710
|
|
|
* @return OperationResponse |
|
711
|
|
|
*/ |
|
712
|
|
View Code Duplication |
public function createRole($uuid, $name, array $permissions, $description = null) |
|
|
|
|
|
|
713
|
|
|
{ |
|
714
|
|
|
$options = [ |
|
715
|
|
|
'form_params' => [ |
|
716
|
|
|
'name' => $name, |
|
717
|
|
|
'permissions' => $permissions, |
|
718
|
|
|
'description' => $description, |
|
719
|
|
|
], |
|
720
|
|
|
]; |
|
721
|
|
|
|
|
722
|
|
|
return new OperationResponse( |
|
723
|
|
|
$this->connector->request('post', "/organizations/${uuid}/roles", $this->query, $options) |
|
724
|
|
|
); |
|
725
|
|
|
} |
|
726
|
|
|
|
|
727
|
|
|
/** |
|
728
|
|
|
* @param string $roleUuid |
|
729
|
|
|
* @return OperationResponse |
|
730
|
|
|
*/ |
|
731
|
|
|
public function deleteRole($roleUuid) |
|
732
|
|
|
{ |
|
733
|
|
|
return new OperationResponse($this->connector->request('delete', "/roles/${roleUuid}", $this->query)); |
|
734
|
|
|
} |
|
735
|
|
|
|
|
736
|
|
|
/** |
|
737
|
|
|
* Show all teams in an organization. |
|
738
|
|
|
* |
|
739
|
|
|
* @param string $organizationUuid |
|
740
|
|
|
* @return TeamsResponse |
|
741
|
|
|
*/ |
|
742
|
|
|
public function organizationTeams($organizationUuid) |
|
743
|
|
|
{ |
|
744
|
|
|
return new TeamsResponse( |
|
745
|
|
|
$this->connector->request('get', "/organizations/${organizationUuid}/teams", $this->query) |
|
|
|
|
|
|
746
|
|
|
); |
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
/** |
|
750
|
|
|
* Show all teams. |
|
751
|
|
|
* |
|
752
|
|
|
* @return TeamsResponse |
|
753
|
|
|
*/ |
|
754
|
|
|
public function teams() |
|
755
|
|
|
{ |
|
756
|
|
|
return new TeamsResponse( |
|
757
|
|
|
$this->connector->request('get', '/teams', $this->query) |
|
|
|
|
|
|
758
|
|
|
); |
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
|
|
/** |
|
762
|
|
|
* @param string $teamUuid |
|
763
|
|
|
* @param string $name |
|
764
|
|
|
* @return OperationResponse |
|
765
|
|
|
*/ |
|
766
|
|
|
public function renameTeam($teamUuid, $name) |
|
767
|
|
|
{ |
|
768
|
|
|
$options = [ |
|
769
|
|
|
'form_params' => [ |
|
770
|
|
|
'name' => $name, |
|
771
|
|
|
], |
|
772
|
|
|
]; |
|
773
|
|
|
|
|
774
|
|
|
return new OperationResponse( |
|
775
|
|
|
$this->connector->request('put', "/teams/${teamUuid}", $options) |
|
776
|
|
|
); |
|
777
|
|
|
} |
|
778
|
|
|
|
|
779
|
|
|
/** |
|
780
|
|
|
* Create a new team. |
|
781
|
|
|
* |
|
782
|
|
|
* @param string $uuid |
|
783
|
|
|
* @param string $name |
|
784
|
|
|
* @return OperationResponse |
|
785
|
|
|
*/ |
|
786
|
|
|
public function createTeam($uuid, $name) |
|
787
|
|
|
{ |
|
788
|
|
|
$options = [ |
|
789
|
|
|
'form_params' => [ |
|
790
|
|
|
'name' => $name, |
|
791
|
|
|
], |
|
792
|
|
|
]; |
|
793
|
|
|
|
|
794
|
|
|
return new OperationResponse( |
|
795
|
|
|
$this->connector->request('post', "/organizations/${uuid}/teams", $this->query, $options) |
|
796
|
|
|
); |
|
797
|
|
|
} |
|
798
|
|
|
|
|
799
|
|
|
/** |
|
800
|
|
|
* @param string $teamUuid |
|
801
|
|
|
* @return OperationResponse |
|
802
|
|
|
*/ |
|
803
|
|
|
public function deleteTeam($teamUuid) |
|
804
|
|
|
{ |
|
805
|
|
|
return new OperationResponse( |
|
806
|
|
|
$this->connector->request('delete', "/teams/${teamUuid}", $this->query) |
|
807
|
|
|
); |
|
808
|
|
|
} |
|
809
|
|
|
|
|
810
|
|
|
/** |
|
811
|
|
|
* @param string $teamUuid |
|
812
|
|
|
* @param string $applicationUuid |
|
813
|
|
|
* @return OperationResponse |
|
814
|
|
|
*/ |
|
815
|
|
|
public function addApplicationToTeam($teamUuid, $applicationUuid) |
|
816
|
|
|
{ |
|
817
|
|
|
$options = [ |
|
818
|
|
|
'form_params' => [ |
|
819
|
|
|
'uuid' => $applicationUuid, |
|
820
|
|
|
], |
|
821
|
|
|
]; |
|
822
|
|
|
|
|
823
|
|
|
return new OperationResponse( |
|
824
|
|
|
$this->connector->request('post', "/teams/${teamUuid}/applications", $this->query, $options) |
|
825
|
|
|
); |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
/** |
|
829
|
|
|
* Invites a user to join a team. |
|
830
|
|
|
* |
|
831
|
|
|
* @param string $teamUuid |
|
832
|
|
|
* @param string $email |
|
833
|
|
|
* @param array $roles |
|
834
|
|
|
* @return OperationResponse |
|
835
|
|
|
*/ |
|
836
|
|
View Code Duplication |
public function createTeamInvite($teamUuid, $email, $roles) |
|
|
|
|
|
|
837
|
|
|
{ |
|
838
|
|
|
$options = [ |
|
839
|
|
|
'form_params' => [ |
|
840
|
|
|
'email' => $email, |
|
841
|
|
|
'roles' => $roles |
|
842
|
|
|
], |
|
843
|
|
|
]; |
|
844
|
|
|
|
|
845
|
|
|
return new OperationResponse( |
|
846
|
|
|
$this->connector->request('post', "/teams/${teamUuid}/invites", $options) |
|
847
|
|
|
); |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
/** |
|
851
|
|
|
* Invites a user to become admin of an organization. |
|
852
|
|
|
* |
|
853
|
|
|
* @param string $organizationUuid |
|
854
|
|
|
* @param string $email |
|
855
|
|
|
* @return OperationResponse |
|
856
|
|
|
*/ |
|
857
|
|
|
public function createOrganizationAdminInvite($organizationUuid, $email) |
|
858
|
|
|
{ |
|
859
|
|
|
$options = [ |
|
860
|
|
|
'form_params' => [ |
|
861
|
|
|
'email' => $email, |
|
862
|
|
|
], |
|
863
|
|
|
]; |
|
864
|
|
|
|
|
865
|
|
|
return new OperationResponse( |
|
866
|
|
|
$this->connector->request('post', "/teams/${organizationUuid}/invites", $this->query, $options) |
|
867
|
|
|
); |
|
868
|
|
|
} |
|
869
|
|
|
|
|
870
|
|
|
/** |
|
871
|
|
|
* Show all applications associated with a team. |
|
872
|
|
|
* |
|
873
|
|
|
* @param string $teamUuid |
|
874
|
|
|
* @return ApplicationResponse |
|
875
|
|
|
*/ |
|
876
|
|
|
public function teamApplications($teamUuid) |
|
877
|
|
|
{ |
|
878
|
|
|
return new ApplicationsResponse( |
|
|
|
|
|
|
879
|
|
|
$this->connector->request('get', "/teams/${teamUuid}/applications", $this->query) |
|
|
|
|
|
|
880
|
|
|
); |
|
881
|
|
|
} |
|
882
|
|
|
|
|
883
|
|
|
/** |
|
884
|
|
|
* Show all members of an organisation. |
|
885
|
|
|
* |
|
886
|
|
|
* @param string $organizationUuid |
|
887
|
|
|
* @return MembersResponse |
|
888
|
|
|
*/ |
|
889
|
|
|
public function members($organizationUuid) |
|
890
|
|
|
{ |
|
891
|
|
|
return new MembersResponse( |
|
892
|
|
|
$this->connector->request('get', "/organizations/${organizationUuid}/members", $this->query) |
|
|
|
|
|
|
893
|
|
|
); |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
/** |
|
897
|
|
|
* Show all members invited to an organisation. |
|
898
|
|
|
* |
|
899
|
|
|
* @param string $organizationUuid |
|
900
|
|
|
* @return InvitationsResponse |
|
901
|
|
|
*/ |
|
902
|
|
|
public function invitees($organizationUuid) |
|
903
|
|
|
{ |
|
904
|
|
|
return new InvitationsResponse( |
|
905
|
|
|
$this->connector->request('get', "/organizations/${organizationUuid}/team-invites", $this->query) |
|
906
|
|
|
); |
|
907
|
|
|
} |
|
908
|
|
|
|
|
909
|
|
|
/** |
|
910
|
|
|
* Delete a member from an organisation. |
|
911
|
|
|
* |
|
912
|
|
|
* @param string $organizationUuid |
|
913
|
|
|
* @param string $memberUuid |
|
914
|
|
|
* @return OperationResponse |
|
915
|
|
|
*/ |
|
916
|
|
|
public function deleteMember($organizationUuid, $memberUuid) |
|
917
|
|
|
{ |
|
918
|
|
|
return new OperationResponse( |
|
919
|
|
|
$this->connector->request( |
|
920
|
|
|
'delete', |
|
921
|
|
|
"/organizations/${organizationUuid}/members/${memberUuid}", |
|
922
|
|
|
$this->query |
|
923
|
|
|
) |
|
924
|
|
|
); |
|
925
|
|
|
} |
|
926
|
|
|
|
|
927
|
|
|
/** |
|
928
|
|
|
* Show all available permissions. |
|
929
|
|
|
* |
|
930
|
|
|
* @return PermissionsResponse |
|
931
|
|
|
*/ |
|
932
|
|
|
public function permissions() |
|
933
|
|
|
{ |
|
934
|
|
|
return new PermissionsResponse($this->connector->request('get', '/permissions', $this->query)); |
|
|
|
|
|
|
935
|
|
|
} |
|
936
|
|
|
} |
|
937
|
|
|
|