1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This Driver is based entirely on official documentation of the Mattermost Web |
4
|
|
|
* Services API and you can extend it by following the directives of the documentation. |
5
|
|
|
* |
6
|
|
|
* God bless this mess. |
7
|
|
|
* |
8
|
|
|
* @author Luca Agnello <[email protected]> |
9
|
|
|
* @link https://api.mattermost.com/ |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gnello\Mattermost\Models; |
13
|
|
|
|
14
|
|
|
use GuzzleHttp\RequestOptions; |
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class SystemModel |
19
|
|
|
* |
20
|
|
|
* @package Gnello\MattermostRestApi\Models |
21
|
|
|
*/ |
22
|
|
|
class SystemModel extends AbstractModel |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private static $endpoint = '/system'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return ResponseInterface |
31
|
|
|
*/ |
32
|
|
|
public function pingServer() |
33
|
|
|
{ |
34
|
|
|
return $this->client->get(self::$endpoint . '/ping'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return ResponseInterface |
39
|
|
|
*/ |
40
|
|
|
public function recycleDatabaseConnections() |
41
|
|
|
{ |
42
|
|
|
$customEndpoint = '/database'; |
43
|
|
|
return $this->client->post($customEndpoint . '/recycle'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return ResponseInterface |
48
|
|
|
*/ |
49
|
|
|
public function sendTestEmail() |
50
|
|
|
{ |
51
|
|
|
$customEndpoint = '/email'; |
52
|
|
|
return $this->client->post($customEndpoint . '/test'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return ResponseInterface |
57
|
|
|
*/ |
58
|
|
|
public function getConfiguration() |
59
|
|
|
{ |
60
|
|
|
$customEndpoint = '/config'; |
61
|
|
|
return $this->client->get($customEndpoint); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param array $requestOptions |
66
|
|
|
* @return ResponseInterface |
67
|
|
|
*/ |
68
|
|
|
public function updateConfiguration(array $requestOptions) |
69
|
|
|
{ |
70
|
|
|
$customEndpoint = '/config'; |
71
|
|
|
return $this->client->put($customEndpoint, $requestOptions); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return ResponseInterface |
76
|
|
|
*/ |
77
|
|
|
public function reloadConfiguration() |
78
|
|
|
{ |
79
|
|
|
$customEndpoint = '/config'; |
80
|
|
|
return $this->client->post($customEndpoint . '/reload'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param array $requestOptions |
85
|
|
|
* @return ResponseInterface |
86
|
|
|
*/ |
87
|
|
|
public function getClientConfiguration(array $requestOptions) |
88
|
|
|
{ |
89
|
|
|
$customEndpoint = '/config'; |
90
|
|
|
return $this->client->get($customEndpoint . '/client', $requestOptions); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param array $requestOptions |
95
|
|
|
* @return ResponseInterface |
96
|
|
|
*/ |
97
|
|
|
public function patchConfiguration(array $requestOptions) |
98
|
|
|
{ |
99
|
|
|
$customEndpoint = '/config'; |
100
|
|
|
return $this->client->put($customEndpoint . '/patch', $requestOptions); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param $requestOptions |
105
|
|
|
* @return ResponseInterface |
106
|
|
|
*/ |
107
|
|
|
public function getClientLicense(array $requestOptions) |
108
|
|
|
{ |
109
|
|
|
$customEndpoint = '/license'; |
110
|
|
|
return $this->client->get($customEndpoint . '/client', $requestOptions); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return ResponseInterface |
115
|
|
|
*/ |
116
|
|
|
public function removeLicenseFile() |
117
|
|
|
{ |
118
|
|
|
$customEndpoint = '/license'; |
119
|
|
|
return $this->client->delete($customEndpoint); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param array $requestOptions |
124
|
|
|
* @return ResponseInterface |
125
|
|
|
*/ |
126
|
|
|
public function uploadLicenseFile(array $requestOptions) |
127
|
|
|
{ |
128
|
|
|
$customEndpoint = '/license'; |
129
|
|
|
$internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['license']); |
130
|
|
|
|
131
|
|
|
return $this->client->post($customEndpoint, $internalRequestOptions, RequestOptions::MULTIPART); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param array $requestOptions |
136
|
|
|
* @return ResponseInterface |
137
|
|
|
*/ |
138
|
|
|
public function getAudits(array $requestOptions) |
139
|
|
|
{ |
140
|
|
|
$customEndpoint = '/audits'; |
141
|
|
|
return $this->client->get($customEndpoint, $requestOptions); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return ResponseInterface |
146
|
|
|
*/ |
147
|
|
|
public function invalidateAllCaches() |
148
|
|
|
{ |
149
|
|
|
$customEndpoint = '/caches'; |
150
|
|
|
return $this->client->post($customEndpoint . '/invalidate'); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param array $requestOptions |
155
|
|
|
* @return ResponseInterface |
156
|
|
|
*/ |
157
|
|
|
public function getLogs(array $requestOptions) |
158
|
|
|
{ |
159
|
|
|
$customEndpoint = '/logs'; |
160
|
|
|
return $this->client->get($customEndpoint, $requestOptions); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param array $requestOptions |
165
|
|
|
* @return ResponseInterface |
166
|
|
|
*/ |
167
|
|
|
public function addLogMessage(array $requestOptions) |
168
|
|
|
{ |
169
|
|
|
$customEndpoint = '/logs'; |
170
|
|
|
return $this->client->post($customEndpoint, $requestOptions); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return ResponseInterface |
175
|
|
|
*/ |
176
|
|
|
public function getWebRtcToken() |
177
|
|
|
{ |
178
|
|
|
$customEndpoint = '/webrtc'; |
179
|
|
|
return $this->client->get($customEndpoint . '/token'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return ResponseInterface |
184
|
|
|
*/ |
185
|
|
|
public function getAnalytics() |
186
|
|
|
{ |
187
|
|
|
$customEndpoint = '/analytics'; |
188
|
|
|
return $this->client->get($customEndpoint . '/old'); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param array $requestOptions |
193
|
|
|
* @return ResponseInterface |
194
|
|
|
*/ |
195
|
|
|
public function setServerBusyFlag(array $requestOptions) |
196
|
|
|
{ |
197
|
|
|
$customEndpoint = '/server_busy'; |
198
|
|
|
return $this->client->post($customEndpoint, $requestOptions); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return ResponseInterface |
203
|
|
|
*/ |
204
|
|
|
public function getServerBusyExpiryTime() |
205
|
|
|
{ |
206
|
|
|
$customEndpoint = '/server_busy'; |
207
|
|
|
return $this->client->get($customEndpoint); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @return ResponseInterface |
212
|
|
|
*/ |
213
|
|
|
public function clearServerBusyFlag() |
214
|
|
|
{ |
215
|
|
|
$customEndpoint = '/server_busy'; |
216
|
|
|
return $this->client->delete($customEndpoint); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return ResponseInterface |
221
|
|
|
*/ |
222
|
|
|
public function getWarnMetricsStatus() |
223
|
|
|
{ |
224
|
|
|
$customEndpoint = '/warn_metrics/status'; |
225
|
|
|
return $this->client->get($customEndpoint); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param $warnMetricId |
230
|
|
|
* @param array $requestOptions |
231
|
|
|
* @return ResponseInterface |
232
|
|
|
*/ |
233
|
|
|
public function acknowledgeWarningOfMetricStatus($warnMetricId, array $requestOptions) |
234
|
|
|
{ |
235
|
|
|
$customEndpoint = '/warn_metrics/ack'; |
236
|
|
|
return $this->client->post($customEndpoint . '/' . $warnMetricId, $requestOptions); |
237
|
|
|
} |
238
|
|
|
} |
239
|
|
|
|