1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\EnvironmentResponse; |
7
|
|
|
use AcquiaCloudApi\Response\EnvironmentsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Environments |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class Environments extends CloudApiBase implements CloudApiInterface |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Copies files from an environment to another environment. |
19
|
|
|
* |
20
|
|
|
* @param string $environmentUuidFrom |
21
|
|
|
* @param string $environmentUuidTo |
22
|
|
|
* @return OperationResponse |
23
|
|
|
*/ |
24
|
|
|
public function copyFiles($environmentUuidFrom, $environmentUuidTo) |
25
|
|
|
{ |
26
|
|
|
$options = [ |
27
|
|
|
'form_params' => [ |
28
|
|
|
'source' => $environmentUuidFrom, |
29
|
|
|
], |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
return new OperationResponse( |
33
|
|
|
$this->client->request('post', "/environments/${environmentUuidTo}/files", $options) |
|
|
|
|
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Gets information about an environment. |
39
|
|
|
* |
40
|
|
|
* @param string $environmentUuid |
41
|
|
|
* @return EnvironmentResponse |
42
|
|
|
*/ |
43
|
|
|
public function get($environmentUuid) |
44
|
|
|
{ |
45
|
|
|
return new EnvironmentResponse( |
46
|
|
|
$this->client->request( |
|
|
|
|
47
|
|
|
'get', |
48
|
|
|
"/environments/${environmentUuid}" |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Shows all environments in an application. |
55
|
|
|
* |
56
|
|
|
* @param string $applicationUuid |
57
|
|
|
* @return EnvironmentsResponse |
58
|
|
|
*/ |
59
|
|
|
public function getAll($applicationUuid) |
60
|
|
|
{ |
61
|
|
|
return new EnvironmentsResponse( |
62
|
|
|
$this->client->request( |
|
|
|
|
63
|
|
|
'get', |
64
|
|
|
"/applications/${applicationUuid}/environments" |
65
|
|
|
) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Modifies configuration settings for an environment. |
71
|
|
|
* |
72
|
|
|
* @param string $environmentUuid |
73
|
|
|
* @param array $config |
74
|
|
|
* @return OperationResponse |
75
|
|
|
*/ |
76
|
|
|
public function update($environmentUuid, array $config) |
77
|
|
|
{ |
78
|
|
|
|
79
|
|
|
$options = [ |
80
|
|
|
'form_params' => $config, |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
return new OperationResponse( |
84
|
|
|
$this->client->request( |
|
|
|
|
85
|
|
|
'put', |
86
|
|
|
"/environments/${environmentUuid}", |
87
|
|
|
$options |
88
|
|
|
) |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Renames an environment. |
94
|
|
|
* |
95
|
|
|
* @param string $environmentUuid |
96
|
|
|
* @param string $label |
97
|
|
|
* @return OperationResponse |
98
|
|
|
*/ |
99
|
|
|
public function rename($environmentUuid, $label) |
100
|
|
|
{ |
101
|
|
|
|
102
|
|
|
$options = [ |
103
|
|
|
'form_params' => [ |
104
|
|
|
'label' => $label, |
105
|
|
|
], |
106
|
|
|
]; |
107
|
|
|
|
108
|
|
|
return new OperationResponse( |
109
|
|
|
$this->client->request( |
|
|
|
|
110
|
|
|
'post', |
111
|
|
|
"/environments/${environmentUuid}/actions/change-label", |
112
|
|
|
$options |
113
|
|
|
) |
114
|
|
|
); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Enable livedev mode for an environment. |
119
|
|
|
* |
120
|
|
|
* @param string $environmentUuid |
121
|
|
|
* @return OperationResponse |
122
|
|
|
*/ |
123
|
|
|
public function enableLiveDev($environmentUuid) |
124
|
|
|
{ |
125
|
|
|
return new OperationResponse( |
126
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable") |
|
|
|
|
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Disable livedev mode for an environment. |
132
|
|
|
* |
133
|
|
|
* @param string $environmentUuid |
134
|
|
|
* @return OperationResponse |
135
|
|
|
*/ |
136
|
|
|
public function disableLiveDev($environmentUuid) |
137
|
|
|
{ |
138
|
|
|
|
139
|
|
|
$options = [ |
140
|
|
|
'form_params' => [ |
141
|
|
|
'discard' => 1, |
142
|
|
|
], |
143
|
|
|
]; |
144
|
|
|
|
145
|
|
|
return new OperationResponse( |
146
|
|
|
$this->client->request( |
|
|
|
|
147
|
|
|
'post', |
148
|
|
|
"/environments/${environmentUuid}/livedev/actions/disable", |
149
|
|
|
$options |
150
|
|
|
) |
151
|
|
|
); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Enable production mode for an environment. |
156
|
|
|
* |
157
|
|
|
* @param string $environmentUuid |
158
|
|
|
* @return OperationResponse |
159
|
|
|
*/ |
160
|
|
|
public function enableProductionMode($environmentUuid) |
161
|
|
|
{ |
162
|
|
|
return new OperationResponse( |
163
|
|
|
$this->client->request( |
|
|
|
|
164
|
|
|
'post', |
165
|
|
|
"/environments/${environmentUuid}/production-mode/actions/enable" |
166
|
|
|
) |
167
|
|
|
); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Disable production mode for an environment. |
172
|
|
|
* |
173
|
|
|
* @param string $environmentUuid |
174
|
|
|
* @return OperationResponse |
175
|
|
|
*/ |
176
|
|
|
public function disableProductionMode($environmentUuid) |
177
|
|
|
{ |
178
|
|
|
return new OperationResponse( |
179
|
|
|
$this->client->request( |
|
|
|
|
180
|
|
|
'post', |
181
|
|
|
"/environments/${environmentUuid}/production-mode/actions/disable" |
182
|
|
|
) |
183
|
|
|
); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Add a new continuous delivery environment to an application. |
188
|
|
|
* |
189
|
|
|
* @param string $applicationUuid |
190
|
|
|
* @param string $label |
191
|
|
|
* @param string $branch |
192
|
|
|
* @param array $databases |
193
|
|
|
* @return OperationResponse |
194
|
|
|
*/ |
195
|
|
|
public function create($applicationUuid, $label, $branch, array $databases) |
196
|
|
|
{ |
197
|
|
|
$options = [ |
198
|
|
|
'form_params' => [ |
199
|
|
|
'label' => $label, |
200
|
|
|
'branch' => $branch, |
201
|
|
|
'databases' => $databases, |
202
|
|
|
], |
203
|
|
|
]; |
204
|
|
|
|
205
|
|
|
return new OperationResponse( |
206
|
|
|
$this->client->request( |
|
|
|
|
207
|
|
|
'post', |
208
|
|
|
"/applications/${applicationUuid}/environments", |
209
|
|
|
$options |
210
|
|
|
) |
211
|
|
|
); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Deletes a CD environment. |
216
|
|
|
* |
217
|
|
|
* @param string $environmentUuid |
218
|
|
|
* @return OperationResponse |
219
|
|
|
*/ |
220
|
|
|
public function delete($environmentUuid) |
221
|
|
|
{ |
222
|
|
|
return new OperationResponse( |
223
|
|
|
$this->client->request( |
|
|
|
|
224
|
|
|
'delete', |
225
|
|
|
"/environments/${environmentUuid}" |
226
|
|
|
) |
227
|
|
|
); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
|