1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\ApplicationResponse; |
7
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\DatabasesResponse; |
9
|
|
|
use AcquiaCloudApi\Response\BranchesResponse; |
10
|
|
|
use AcquiaCloudApi\Response\EnvironmentsResponse; |
11
|
|
|
use AcquiaCloudApi\Response\InsightsResponse; |
12
|
|
|
use AcquiaCloudApi\Response\TasksResponse; |
13
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
14
|
|
|
use AcquiaCloudApi\Response\NotificationsResponse; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Client |
18
|
|
|
* @package AcquiaCloudApi\CloudApi |
19
|
|
|
*/ |
20
|
|
|
class Applications implements CloudApi |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** @var ClientInterface The API client. */ |
24
|
|
|
protected $client; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Client constructor. |
28
|
|
|
* |
29
|
|
|
* @param ClientInterface $client |
30
|
|
|
*/ |
31
|
|
|
public function __construct(ClientInterface $client) |
32
|
|
|
{ |
33
|
|
|
$this->client = $client; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Shows all applications. |
38
|
|
|
* |
39
|
|
|
* @return ApplicationsResponse |
40
|
|
|
*/ |
41
|
|
|
public function getApplications() |
42
|
|
|
{ |
43
|
|
|
return new ApplicationsResponse($this->client->request('get', '/applications')); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Shows information about an application. |
48
|
|
|
* |
49
|
|
|
* @param string $applicationUuid |
50
|
|
|
* @return ApplicationResponse |
51
|
|
|
*/ |
52
|
|
|
public function getApplication($applicationUuid) |
53
|
|
|
{ |
54
|
|
|
return new ApplicationResponse( |
55
|
|
|
$this->client->request( |
|
|
|
|
56
|
|
|
'get', |
57
|
|
|
"/applications/${applicationUuid}" |
58
|
|
|
) |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Renames an application. |
64
|
|
|
* |
65
|
|
|
* @param string $applicationUuid |
66
|
|
|
* @param string $name |
67
|
|
|
* @return OperationResponse |
68
|
|
|
*/ |
69
|
|
|
public function renameApplication($applicationUuid, $name) |
70
|
|
|
{ |
71
|
|
|
|
72
|
|
|
$options = [ |
73
|
|
|
'form_params' => [ |
74
|
|
|
'name' => $name, |
75
|
|
|
], |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
return new OperationResponse( |
79
|
|
|
$this->client->request( |
|
|
|
|
80
|
|
|
'put', |
81
|
|
|
"/applications/${applicationUuid}", |
82
|
|
|
$options |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Shows all code branches and tags in an application. |
89
|
|
|
* |
90
|
|
|
* @param string $applicationUuid |
91
|
|
|
* @return BranchesResponse |
92
|
|
|
*/ |
93
|
|
|
public function getBranches($applicationUuid) |
94
|
|
|
{ |
95
|
|
|
return new BranchesResponse( |
96
|
|
|
$this->client->request( |
|
|
|
|
97
|
|
|
'get', |
98
|
|
|
"/applications/${applicationUuid}/code" |
99
|
|
|
) |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Shows all databases in an application. |
105
|
|
|
* |
106
|
|
|
* @param string $applicationUuid |
107
|
|
|
* @return DatabasesResponse |
108
|
|
|
*/ |
109
|
|
|
public function getDatabases($applicationUuid) |
110
|
|
|
{ |
111
|
|
|
return new DatabasesResponse( |
112
|
|
|
$this->client->request( |
|
|
|
|
113
|
|
|
'get', |
114
|
|
|
"/applications/${applicationUuid}/databases" |
115
|
|
|
) |
116
|
|
|
); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Create a new database. |
121
|
|
|
* |
122
|
|
|
* @param string $applicationUuid |
123
|
|
|
* @param string $name |
124
|
|
|
* @return OperationResponse |
125
|
|
|
*/ |
126
|
|
|
public function createDatabase($applicationUuid, $name) |
127
|
|
|
{ |
128
|
|
|
$options = [ |
129
|
|
|
'form_params' => [ |
130
|
|
|
'name' => $name, |
131
|
|
|
], |
132
|
|
|
]; |
133
|
|
|
|
134
|
|
|
return new OperationResponse( |
135
|
|
|
$this->client->request('post', "/applications/${applicationUuid}/databases", $options) |
|
|
|
|
136
|
|
|
); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Delete a database. |
141
|
|
|
* |
142
|
|
|
* @param string $applicationUuid |
143
|
|
|
* @param string $name |
144
|
|
|
* @return OperationResponse |
145
|
|
|
*/ |
146
|
|
|
public function deleteDatabase($applicationUuid, $name) |
147
|
|
|
{ |
148
|
|
|
return new OperationResponse( |
149
|
|
|
$this->client->request('delete', "/applications/${applicationUuid}/databases/${name}") |
|
|
|
|
150
|
|
|
); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Shows all tasks in an application. |
155
|
|
|
* |
156
|
|
|
* @param string $applicationUuid |
157
|
|
|
* @return TasksResponse |
158
|
|
|
*/ |
159
|
|
|
public function getTasks($applicationUuid) |
160
|
|
|
{ |
161
|
|
|
return new TasksResponse( |
162
|
|
|
$this->client->request( |
|
|
|
|
163
|
|
|
'get', |
164
|
|
|
"/applications/${applicationUuid}/tasks" |
165
|
|
|
) |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Shows all environments in an application. |
171
|
|
|
* |
172
|
|
|
* @param string $applicationUuid |
173
|
|
|
* @return EnvironmentsResponse |
174
|
|
|
*/ |
175
|
|
|
public function getEnvironments($applicationUuid) |
176
|
|
|
{ |
177
|
|
|
return new EnvironmentsResponse( |
178
|
|
|
$this->client->request( |
|
|
|
|
179
|
|
|
'get', |
180
|
|
|
"/applications/${applicationUuid}/environments" |
181
|
|
|
) |
182
|
|
|
); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Show insights data from an application. |
187
|
|
|
* |
188
|
|
|
* @param string $applicationUuid |
189
|
|
|
* @return InsightsResponse |
190
|
|
|
*/ |
191
|
|
|
public function getInsights($applicationUuid) |
192
|
|
|
{ |
193
|
|
|
return new InsightsResponse( |
194
|
|
|
$this->client->request('get', "/applications/${applicationUuid}/insight") |
|
|
|
|
195
|
|
|
); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Returns a list of notifications. |
200
|
|
|
* |
201
|
|
|
* @param string $applicationUuid |
202
|
|
|
* |
203
|
|
|
* @return NotificationsResponse |
204
|
|
|
*/ |
205
|
|
|
public function getNotifications($applicationUuid) |
206
|
|
|
{ |
207
|
|
|
return new NotificationsResponse( |
208
|
|
|
$this->client->request( |
|
|
|
|
209
|
|
|
'get', |
210
|
|
|
"/applications/${applicationUuid}/notifications" |
211
|
|
|
) |
212
|
|
|
); |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
|