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