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 Client |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class Environments implements CloudApi |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** @var ClientInterface The API client. */ |
18
|
|
|
protected $client; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Client constructor. |
22
|
|
|
* |
23
|
|
|
* @param ClientInterface $client |
24
|
|
|
*/ |
25
|
|
|
public function __construct(ClientInterface $client) |
26
|
|
|
{ |
27
|
|
|
$this->client = $client; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Copies files from an environment to another environment. |
32
|
|
|
* |
33
|
|
|
* @param string $environmentUuidFrom |
34
|
|
|
* @param string $environmentUuidTo |
35
|
|
|
* @return OperationResponse |
36
|
|
|
*/ |
37
|
|
|
public function copyFiles($environmentUuidFrom, $environmentUuidTo) |
38
|
|
|
{ |
39
|
|
|
$options = [ |
40
|
|
|
'form_params' => [ |
41
|
|
|
'source' => $environmentUuidFrom, |
42
|
|
|
], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
return new OperationResponse( |
46
|
|
|
$this->client->request('post', "/environments/${environmentUuidTo}/files", $options) |
|
|
|
|
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Gets information about an environment. |
52
|
|
|
* |
53
|
|
|
* @param string $environmentUuid |
54
|
|
|
* @return EnvironmentResponse |
55
|
|
|
*/ |
56
|
|
|
public function get($environmentUuid) |
57
|
|
|
{ |
58
|
|
|
return new EnvironmentResponse( |
59
|
|
|
$this->client->request( |
|
|
|
|
60
|
|
|
'get', |
61
|
|
|
"/environments/${environmentUuid}" |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Shows all environments in an application. |
68
|
|
|
* |
69
|
|
|
* @param string $applicationUuid |
70
|
|
|
* @return EnvironmentsResponse |
71
|
|
|
*/ |
72
|
|
|
public function getAll($applicationUuid) |
73
|
|
|
{ |
74
|
|
|
return new EnvironmentsResponse( |
75
|
|
|
$this->client->request( |
|
|
|
|
76
|
|
|
'get', |
77
|
|
|
"/applications/${applicationUuid}/environments" |
78
|
|
|
) |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Modifies configuration settings for an environment. |
84
|
|
|
* |
85
|
|
|
* @param string $environmentUuid |
86
|
|
|
* @param array $config |
87
|
|
|
* @return OperationResponse |
88
|
|
|
*/ |
89
|
|
|
public function update($environmentUuid, array $config) |
90
|
|
|
{ |
91
|
|
|
|
92
|
|
|
$options = [ |
93
|
|
|
'form_params' => $config, |
94
|
|
|
]; |
95
|
|
|
|
96
|
|
|
return new OperationResponse( |
97
|
|
|
$this->client->request( |
|
|
|
|
98
|
|
|
'put', |
99
|
|
|
"/environments/${environmentUuid}", |
100
|
|
|
$options |
101
|
|
|
) |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Renames an environment. |
107
|
|
|
* |
108
|
|
|
* @param string $environmentUuid |
109
|
|
|
* @param string $label |
110
|
|
|
* @return OperationResponse |
111
|
|
|
*/ |
112
|
|
|
public function rename($environmentUuid, $label) |
113
|
|
|
{ |
114
|
|
|
|
115
|
|
|
$options = [ |
116
|
|
|
'form_params' => [ |
117
|
|
|
'label' => $label, |
118
|
|
|
], |
119
|
|
|
]; |
120
|
|
|
|
121
|
|
|
return new OperationResponse( |
122
|
|
|
$this->client->request( |
|
|
|
|
123
|
|
|
'post', |
124
|
|
|
"/environments/${environmentUuid}/actions/change-label", |
125
|
|
|
$options |
126
|
|
|
) |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Enable livedev mode for an environment. |
132
|
|
|
* |
133
|
|
|
* @param string $environmentUuid |
134
|
|
|
* @return OperationResponse |
135
|
|
|
*/ |
136
|
|
|
public function enableLiveDev($environmentUuid) |
137
|
|
|
{ |
138
|
|
|
return new OperationResponse( |
139
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable") |
|
|
|
|
140
|
|
|
); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Disable livedev mode for an environment. |
145
|
|
|
* |
146
|
|
|
* @param string $environmentUuid |
147
|
|
|
* @return OperationResponse |
148
|
|
|
*/ |
149
|
|
|
public function disableLiveDev($environmentUuid) |
150
|
|
|
{ |
151
|
|
|
|
152
|
|
|
$options = [ |
153
|
|
|
'form_params' => [ |
154
|
|
|
'discard' => 1, |
155
|
|
|
], |
156
|
|
|
]; |
157
|
|
|
|
158
|
|
|
return new OperationResponse( |
159
|
|
|
$this->client->request( |
|
|
|
|
160
|
|
|
'post', |
161
|
|
|
"/environments/${environmentUuid}/livedev/actions/disable", |
162
|
|
|
$options |
163
|
|
|
) |
164
|
|
|
); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Enable production mode for an environment. |
169
|
|
|
* |
170
|
|
|
* @param string $environmentUuid |
171
|
|
|
* @return OperationResponse |
172
|
|
|
*/ |
173
|
|
|
public function enableProductionMode($environmentUuid) |
174
|
|
|
{ |
175
|
|
|
return new OperationResponse( |
176
|
|
|
$this->client->request( |
|
|
|
|
177
|
|
|
'post', |
178
|
|
|
"/environments/${environmentUuid}/production-mode/actions/enable" |
179
|
|
|
) |
180
|
|
|
); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Disable production mode for an environment. |
185
|
|
|
* |
186
|
|
|
* @param string $environmentUuid |
187
|
|
|
* @return OperationResponse |
188
|
|
|
*/ |
189
|
|
|
public function disableProductionMode($environmentUuid) |
190
|
|
|
{ |
191
|
|
|
return new OperationResponse( |
192
|
|
|
$this->client->request( |
|
|
|
|
193
|
|
|
'post', |
194
|
|
|
"/environments/${environmentUuid}/production-mode/actions/disable" |
195
|
|
|
) |
196
|
|
|
); |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|