1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\InsightsResponse; |
7
|
|
|
use AcquiaCloudApi\Response\InsightResponse; |
8
|
|
|
use AcquiaCloudApi\Response\InsightAlertsResponse; |
9
|
|
|
use AcquiaCloudApi\Response\InsightAlertResponse; |
10
|
|
|
use AcquiaCloudApi\Response\InsightModulesResponse; |
11
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Insights |
15
|
|
|
* @package AcquiaCloudApi\CloudApi |
16
|
|
|
*/ |
17
|
|
|
class Insights extends CloudApiBase implements CloudApiInterface |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Returns Insight data for all sites associated with the application by its UUID. |
22
|
|
|
* |
23
|
|
|
* @param string $applicationUuid |
24
|
|
|
* @return InsightsResponse |
25
|
|
|
*/ |
26
|
|
|
public function getAll($applicationUuid) |
27
|
|
|
{ |
28
|
|
|
return new InsightsResponse( |
29
|
|
|
$this->client->request( |
|
|
|
|
30
|
|
|
'get', |
31
|
|
|
"/applications/${applicationUuid}/insight" |
32
|
|
|
) |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Returns Insight data for all sites associated with the environment by its UUID. |
38
|
|
|
* |
39
|
|
|
* @param string $environmentUuid |
40
|
|
|
* @return InsightsResponse |
41
|
|
|
*/ |
42
|
|
|
public function getEnvironment($environmentUuid) |
43
|
|
|
{ |
44
|
|
|
return new InsightsResponse( |
45
|
|
|
$this->client->request( |
|
|
|
|
46
|
|
|
'get', |
47
|
|
|
"/environment/${environmentUuid}/insight" |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Returns insight data for a particular site. |
54
|
|
|
* |
55
|
|
|
* @param string $siteId |
56
|
|
|
* @return InsightResponse |
57
|
|
|
*/ |
58
|
|
|
public function get($siteId) |
59
|
|
|
{ |
60
|
|
|
return new InsightResponse( |
61
|
|
|
$this->client->request( |
|
|
|
|
62
|
|
|
'get', |
63
|
|
|
"/insight/${siteId}" |
64
|
|
|
) |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns a list of Insight alerts for this site. |
70
|
|
|
* |
71
|
|
|
* @param string $siteId |
72
|
|
|
* @return InsightAlertsResponse |
73
|
|
|
*/ |
74
|
|
|
public function getAllAlerts($siteId) |
75
|
|
|
{ |
76
|
|
|
return new InsightAlertsResponse( |
77
|
|
|
$this->client->request( |
|
|
|
|
78
|
|
|
'get', |
79
|
|
|
"/insight/${siteId}/alerts" |
80
|
|
|
) |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Returns a specific Insight alert for this site. |
86
|
|
|
* |
87
|
|
|
* @param string $siteId |
88
|
|
|
* @param string $alertUuid |
89
|
|
|
* @return InsightAlertResponse |
90
|
|
|
*/ |
91
|
|
|
public function getAlert($siteId, $alertUuid) |
92
|
|
|
{ |
93
|
|
|
return new InsightAlertResponse( |
94
|
|
|
$this->client->request( |
|
|
|
|
95
|
|
|
'get', |
96
|
|
|
"/insight/${siteId}/alerts/${alertUuid}" |
97
|
|
|
) |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Ignores an alert. An ignored alert will be included will not be counted in the Insight score calculation. |
103
|
|
|
* |
104
|
|
|
* @param string $siteId |
105
|
|
|
* @param string $alertUuid |
106
|
|
|
* @return OperationResponse |
107
|
|
|
*/ |
108
|
|
|
public function ignoreAlert($siteId, $alertUuid) |
109
|
|
|
{ |
110
|
|
|
return new OperationResponse( |
111
|
|
|
$this->client->request( |
|
|
|
|
112
|
|
|
'post', |
113
|
|
|
"/insight/${siteId}/alerts/${alertUuid}/actions/ignore" |
114
|
|
|
) |
115
|
|
|
); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Restores an alert. A restored alert will be included in the calculation of the Insight score. |
120
|
|
|
* |
121
|
|
|
* @param string $siteId |
122
|
|
|
* @param string $alertUuid |
123
|
|
|
* @return OperationResponse |
124
|
|
|
*/ |
125
|
|
|
public function restoreAlert($siteId, $alertUuid) |
126
|
|
|
{ |
127
|
|
|
return new OperationResponse( |
128
|
|
|
$this->client->request( |
|
|
|
|
129
|
|
|
'post', |
130
|
|
|
"/insight/${siteId}/alerts/${alertUuid}/actions/restore" |
131
|
|
|
) |
132
|
|
|
); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Revokes an Insight install so it can no longer submit data using the Acquia Connector module. |
137
|
|
|
* |
138
|
|
|
* @param string $siteId |
139
|
|
|
* @return OperationResponse |
140
|
|
|
*/ |
141
|
|
|
public function revoke($siteId) |
142
|
|
|
{ |
143
|
|
|
return new OperationResponse( |
144
|
|
|
$this->client->request( |
|
|
|
|
145
|
|
|
'post', |
146
|
|
|
"/insight/${siteId}/actions/revoke" |
147
|
|
|
) |
148
|
|
|
); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Un-revokes an Insight site so it can once again submit data using the Acquia Connector module. |
153
|
|
|
* Note that the site must also be unblocked using the Acquia Connector module. |
154
|
|
|
* |
155
|
|
|
* @param string $siteId |
156
|
|
|
* @return OperationResponse |
157
|
|
|
*/ |
158
|
|
|
public function unrevoke($siteId) |
159
|
|
|
{ |
160
|
|
|
return new OperationResponse( |
161
|
|
|
$this->client->request( |
|
|
|
|
162
|
|
|
'post', |
163
|
|
|
"/insight/${siteId}/actions/unrevoke" |
164
|
|
|
) |
165
|
|
|
); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Returns a list of Drupal modules for this site. |
170
|
|
|
* |
171
|
|
|
* @param string $siteId |
172
|
|
|
* @return InsightModulesResponse |
173
|
|
|
*/ |
174
|
|
|
public function getModules($siteId) |
175
|
|
|
{ |
176
|
|
|
return new InsightModulesResponse( |
177
|
|
|
$this->client->request( |
|
|
|
|
178
|
|
|
'get', |
179
|
|
|
"/insight/${siteId}/modules" |
180
|
|
|
) |
181
|
|
|
); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|