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