|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
|
4
|
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
|
6
|
|
|
use AcquiaCloudApi\Response\BranchesResponse; |
|
7
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class Code |
|
11
|
|
|
* @package AcquiaCloudApi\CloudApi |
|
12
|
|
|
*/ |
|
13
|
|
|
class Code extends CloudApiBase implements CloudApiInterface |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Shows all code branches and tags in an application. |
|
18
|
|
|
* |
|
19
|
|
|
* @param string $applicationUuid |
|
20
|
|
|
* @return BranchesResponse |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getAll($applicationUuid) |
|
23
|
|
|
{ |
|
24
|
|
|
return new BranchesResponse( |
|
25
|
|
|
$this->client->request( |
|
|
|
|
|
|
26
|
|
|
'get', |
|
27
|
|
|
"/applications/${applicationUuid}/code" |
|
28
|
|
|
) |
|
29
|
|
|
); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Deploys a code branch/tag to an environment. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $environmentUuid |
|
36
|
|
|
* @param string $branch |
|
37
|
|
|
* @return OperationResponse |
|
38
|
|
|
*/ |
|
39
|
|
|
public function switch($environmentUuid, $branch) |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
$options = [ |
|
43
|
|
|
'form_params' => [ |
|
44
|
|
|
'branch' => $branch, |
|
45
|
|
|
], |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
return new OperationResponse( |
|
49
|
|
|
$this->client->request( |
|
|
|
|
|
|
50
|
|
|
'post', |
|
51
|
|
|
"/environments/${environmentUuid}/code/actions/switch", |
|
52
|
|
|
$options |
|
53
|
|
|
) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Deploys code from one environment to another environment. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $environmentFromUuid |
|
61
|
|
|
* @param string $environmentToUuid |
|
62
|
|
|
* @param string $commitMessage |
|
63
|
|
|
*/ |
|
64
|
|
|
public function deploy($environmentFromUuid, $environmentToUuid, $commitMessage = null) |
|
65
|
|
|
{ |
|
66
|
|
|
|
|
67
|
|
|
$options = [ |
|
68
|
|
|
'form_params' => [ |
|
69
|
|
|
'source' => $environmentFromUuid, |
|
70
|
|
|
'message' => $commitMessage, |
|
71
|
|
|
], |
|
72
|
|
|
]; |
|
73
|
|
|
|
|
74
|
|
|
return new OperationResponse( |
|
75
|
|
|
$this->client->request( |
|
|
|
|
|
|
76
|
|
|
'post', |
|
77
|
|
|
"/environments/${environmentToUuid}/code", |
|
78
|
|
|
$options |
|
79
|
|
|
) |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|