1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\CodebasesResponse; |
6
|
|
|
use AcquiaCloudApi\Response\CodebaseResponse; |
7
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\ReferencesResponse; |
9
|
|
|
use AcquiaCloudApi\Response\ReferenceResponse; |
10
|
|
|
use AcquiaCloudApi\Response\BulkCodeSwitchResponse; |
11
|
|
|
use AcquiaCloudApi\Response\CodebaseEnvironmentsResponse; |
12
|
|
|
use AcquiaCloudApi\Response\SitesResponse; |
13
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
14
|
|
|
|
15
|
|
|
class Codebases extends CloudApiBase |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Shows all codebases. |
19
|
|
|
*/ |
20
|
|
|
public function getAll(): CodebasesResponse |
21
|
|
|
{ |
22
|
|
|
return new CodebasesResponse( |
23
|
|
|
$this->client->request( |
24
|
|
|
'get', |
25
|
|
|
"/codebases" |
26
|
|
|
) |
27
|
|
|
); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Shows information about a specific codebase. |
32
|
|
|
* |
33
|
|
|
* @param string $codebaseUuid The codebase UUID. |
34
|
|
|
*/ |
35
|
|
|
public function get(string $codebaseUuid): CodebaseResponse |
36
|
|
|
{ |
37
|
|
|
return new CodebaseResponse( |
38
|
|
|
$this->client->request( |
39
|
|
|
'get', |
40
|
|
|
"/codebases/$codebaseUuid" |
41
|
|
|
) |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Shows all codebases for a subscription. |
47
|
|
|
* |
48
|
|
|
* @param string $subscriptionUuid The subscription UUID. |
49
|
|
|
*/ |
50
|
|
|
public function getBySubscription(string $subscriptionUuid): CodebasesResponse |
51
|
|
|
{ |
52
|
|
|
return new CodebasesResponse( |
53
|
|
|
$this->client->request( |
54
|
|
|
'get', |
55
|
|
|
"/subscriptions/$subscriptionUuid/codebases" |
56
|
|
|
) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Shows all applications associated with a codebase. |
62
|
|
|
* |
63
|
|
|
* @param string $codebaseUuid The codebase UUID. |
64
|
|
|
*/ |
65
|
|
|
public function getApplications(string $codebaseUuid): ApplicationsResponse |
66
|
|
|
{ |
67
|
|
|
return new ApplicationsResponse( |
68
|
|
|
$this->client->request( |
69
|
|
|
'get', |
70
|
|
|
"/codebases/$codebaseUuid/applications" |
71
|
|
|
) |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Shows all git references for a codebase. |
77
|
|
|
* |
78
|
|
|
* @param string $codebaseUuid The codebase UUID. |
79
|
|
|
*/ |
80
|
|
|
public function getReferences(string $codebaseUuid): ReferencesResponse |
81
|
|
|
{ |
82
|
|
|
return new ReferencesResponse( |
83
|
|
|
$this->client->request( |
84
|
|
|
'get', |
85
|
|
|
"/codebases/$codebaseUuid/references" |
86
|
|
|
) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Shows information about a specific git reference. |
92
|
|
|
* |
93
|
|
|
* @param string $codebaseUuid The codebase UUID. |
94
|
|
|
* @param string $referenceName The reference name (branch or tag). |
95
|
|
|
*/ |
96
|
|
|
public function getReference(string $codebaseUuid, string $referenceName): ReferenceResponse |
97
|
|
|
{ |
98
|
|
|
return new ReferenceResponse( |
99
|
|
|
$this->client->request( |
100
|
|
|
'get', |
101
|
|
|
"/codebases/$codebaseUuid/references/$referenceName" |
102
|
|
|
) |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Shows all sites associated with a codebase. |
108
|
|
|
* |
109
|
|
|
* @param string $codebaseUuid The codebase UUID. |
110
|
|
|
*/ |
111
|
|
|
public function getSites(string $codebaseUuid): SitesResponse |
112
|
|
|
{ |
113
|
|
|
return new SitesResponse( |
114
|
|
|
$this->client->request( |
115
|
|
|
'get', |
116
|
|
|
"/codebases/$codebaseUuid/sites" |
117
|
|
|
) |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
/** |
121
|
|
|
* Shows all environments associated with a codebase. |
122
|
|
|
* |
123
|
|
|
* @param string $codebaseUuid The codebase UUID. |
124
|
|
|
*/ |
125
|
|
|
public function getEnvironments(string $codebaseUuid): CodebaseEnvironmentsResponse |
126
|
|
|
{ |
127
|
|
|
return new CodebaseEnvironmentsResponse( |
128
|
|
|
$this->client->request( |
129
|
|
|
'get', |
130
|
|
|
"/codebases/$codebaseUuid/environments" |
131
|
|
|
) |
132
|
|
|
); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Retrieves a list of bulk code switches performed on a codebase. |
137
|
|
|
* |
138
|
|
|
* @param string $codebaseUuid The codebase UUID. |
139
|
|
|
* @param array<string, mixed> $options Query parameters (limit, offset). |
140
|
|
|
*/ |
141
|
|
|
public function getBulkCodeSwitches(string $codebaseUuid, array $options = []): BulkCodeSwitchResponse |
142
|
|
|
{ |
143
|
|
|
$path = "/codebases/$codebaseUuid/bulk-code-switch"; |
144
|
|
|
return new BulkCodeSwitchResponse( |
145
|
|
|
$this->client->request('get', $path, $options) |
146
|
|
|
); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Shows information about a specific bulk code switch. |
151
|
|
|
* |
152
|
|
|
* @param string $codebaseUuid The codebase UUID. |
153
|
|
|
* @param string $bulkCodeSwitchId The bulk code switch ID. |
154
|
|
|
*/ |
155
|
|
|
public function getBulkCodeSwitch(string $codebaseUuid, string $bulkCodeSwitchId): BulkCodeSwitchResponse |
156
|
|
|
{ |
157
|
|
|
return new BulkCodeSwitchResponse( |
158
|
|
|
$this->client->request( |
159
|
|
|
'get', |
160
|
|
|
"/codebases/$codebaseUuid/bulk-code-switch/$bulkCodeSwitchId" |
161
|
|
|
) |
162
|
|
|
); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Starts a new bulk code switch for a codebase. |
167
|
|
|
* |
168
|
|
|
* @param string $codebaseUuid The codebase UUID. |
169
|
|
|
* @param string $reference The reference to switch to (branch name or tag). |
170
|
|
|
* @param array<int, array<string, mixed>> $targets Array of targets with environment_id and optional cloud_actions. |
171
|
|
|
* @param array<string, mixed> $cloudActions Optional global cloud actions to perform. |
172
|
|
|
*/ |
173
|
|
|
public function createBulkCodeSwitch( |
174
|
|
|
string $codebaseUuid, |
175
|
|
|
string $reference, |
176
|
|
|
array $targets, |
177
|
|
|
array $cloudActions = [] |
178
|
|
|
): OperationResponse { |
179
|
|
|
$data = [ |
180
|
|
|
'reference' => $reference, |
181
|
|
|
'targets' => $targets, |
182
|
|
|
]; |
183
|
|
|
|
184
|
|
|
if (!empty($cloudActions)) { |
185
|
|
|
$data['cloud_actions'] = $cloudActions; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
$options = [ |
189
|
|
|
'json' => $data, |
190
|
|
|
]; |
191
|
|
|
|
192
|
|
|
return new OperationResponse( |
193
|
|
|
$this->client->request( |
194
|
|
|
'post', |
195
|
|
|
"/codebases/$codebaseUuid/bulk-code-switch", |
196
|
|
|
$options |
197
|
|
|
) |
198
|
|
|
); |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|