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