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