1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class CloudApiBase |
9
|
|
|
* |
10
|
|
|
* @package AcquiaCloudApi\CloudApi |
11
|
|
|
*/ |
12
|
|
|
abstract class CloudApiBase implements CloudApiInterface |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var ClientInterface The API client. |
17
|
|
|
*/ |
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
|
|
|
* @param array{type:string, path:string} $link |
32
|
|
|
* @return mixed |
33
|
|
|
*/ |
34
|
|
|
public function getLinkedResource($link) |
35
|
|
|
{ |
36
|
|
|
// Remove https://cloud.acquia.com/api from the path as this is already added by the Connector. |
37
|
|
|
$path = substr($link['path'], 28); |
38
|
|
|
|
39
|
|
|
switch ($link['type']) { |
40
|
|
|
case 'alerts': |
41
|
|
|
return new \AcquiaCloudApi\Response\InsightAlertsResponse( |
42
|
|
|
$this->client->request('get', $path) |
|
|
|
|
43
|
|
|
); |
44
|
|
|
break; |
|
|
|
|
45
|
|
|
case 'applications': |
46
|
|
|
return new \AcquiaCloudApi\Response\ApplicationsResponse( |
47
|
|
|
$this->client->request('get', $path) |
|
|
|
|
48
|
|
|
); |
49
|
|
|
break; |
50
|
|
|
case 'backups': |
51
|
|
|
return new \AcquiaCloudApi\Response\BackupsResponse( |
52
|
|
|
$this->client->request('get', $path) |
|
|
|
|
53
|
|
|
); |
54
|
|
|
break; |
55
|
|
|
case 'code': |
56
|
|
|
return new \AcquiaCloudApi\Response\BranchesResponse( |
57
|
|
|
$this->client->request('get', $path) |
|
|
|
|
58
|
|
|
); |
59
|
|
|
break; |
60
|
|
|
case 'crons': |
61
|
|
|
return new \AcquiaCloudApi\Response\CronsResponse( |
62
|
|
|
$this->client->request('get', $path) |
|
|
|
|
63
|
|
|
); |
64
|
|
|
break; |
65
|
|
|
case 'databases': |
66
|
|
|
return new \AcquiaCloudApi\Response\DatabasesResponse( |
67
|
|
|
$this->client->request('get', $path) |
|
|
|
|
68
|
|
|
); |
69
|
|
|
break; |
70
|
|
|
case 'domains': |
71
|
|
|
return new \AcquiaCloudApi\Response\DomainsResponse( |
72
|
|
|
$this->client->request('get', $path) |
|
|
|
|
73
|
|
|
); |
74
|
|
|
break; |
75
|
|
|
case 'environments': |
76
|
|
|
return new \AcquiaCloudApi\Response\EnvironmentsResponse( |
77
|
|
|
$this->client->request('get', $path) |
|
|
|
|
78
|
|
|
); |
79
|
|
|
break; |
80
|
|
|
case 'ides': |
81
|
|
|
return new \AcquiaCloudApi\Response\IdesResponse( |
82
|
|
|
$this->client->request('get', $path) |
|
|
|
|
83
|
|
|
); |
84
|
|
|
break; |
85
|
|
|
case 'insight': |
86
|
|
|
return new \AcquiaCloudApi\Response\InsightsResponse( |
87
|
|
|
$this->client->request('get', $path) |
|
|
|
|
88
|
|
|
); |
89
|
|
|
break; |
90
|
|
|
case 'logs': |
91
|
|
|
return new \AcquiaCloudApi\Response\LogsResponse( |
92
|
|
|
$this->client->request('get', $path) |
|
|
|
|
93
|
|
|
); |
94
|
|
|
break; |
95
|
|
|
case 'members': |
96
|
|
|
return new \AcquiaCloudApi\Response\MembersResponse( |
97
|
|
|
$this->client->request('get', $path) |
|
|
|
|
98
|
|
|
); |
99
|
|
|
break; |
100
|
|
|
case 'metrics': |
101
|
|
|
return new \AcquiaCloudApi\Response\MetricsResponse( |
102
|
|
|
$this->client->request('get', $path) |
|
|
|
|
103
|
|
|
); |
104
|
|
|
break; |
105
|
|
|
case 'modules': |
106
|
|
|
return new \AcquiaCloudApi\Response\InsightModulesResponse( |
107
|
|
|
$this->client->request('get', $path) |
|
|
|
|
108
|
|
|
); |
109
|
|
|
break; |
110
|
|
|
case 'notification': |
111
|
|
|
return new \AcquiaCloudApi\Response\NotificationResponse( |
112
|
|
|
$this->client->request('get', $path) |
113
|
|
|
); |
114
|
|
|
break; |
115
|
|
|
case 'permissions': |
116
|
|
|
return new \AcquiaCloudApi\Response\PermissionsResponse( |
117
|
|
|
$this->client->request('get', $path) |
|
|
|
|
118
|
|
|
); |
119
|
|
|
break; |
120
|
|
|
case 'servers': |
121
|
|
|
return new \AcquiaCloudApi\Response\ServersResponse( |
122
|
|
|
$this->client->request('get', $path) |
|
|
|
|
123
|
|
|
); |
124
|
|
|
break; |
125
|
|
|
case 'ssl': |
126
|
|
|
return new \AcquiaCloudApi\Response\SslCertificatesResponse( |
127
|
|
|
$this->client->request('get', $path) |
|
|
|
|
128
|
|
|
); |
129
|
|
|
break; |
130
|
|
|
case 'teams': |
131
|
|
|
return new \AcquiaCloudApi\Response\TeamsResponse( |
132
|
|
|
$this->client->request('get', $path) |
|
|
|
|
133
|
|
|
); |
134
|
|
|
break; |
135
|
|
|
case 'variables': |
136
|
|
|
return new \AcquiaCloudApi\Response\VariablesResponse( |
137
|
|
|
$this->client->request('get', $path) |
|
|
|
|
138
|
|
|
); |
139
|
|
|
break; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
throw new \Exception('Not found'); |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|