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
|
|
|
/** |
15
|
|
|
* Class SystemModel |
16
|
|
|
* |
17
|
|
|
* @package Gnello\MattermostRestApi\Models |
18
|
|
|
*/ |
19
|
|
|
class SystemModel extends AbstractModel |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
private static $endpoint = '/system'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
28
|
|
|
*/ |
29
|
|
|
public function pingServer() |
30
|
|
|
{ |
31
|
|
|
return $this->client->get(self::$endpoint . '/ping'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
36
|
|
|
*/ |
37
|
|
|
public function recycleDatabaseConnections() |
38
|
|
|
{ |
39
|
|
|
$customEndpoint = '/database'; |
40
|
|
|
return $this->client->post($customEndpoint . '/recycle'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
45
|
|
|
*/ |
46
|
|
|
public function sendTestEmail() |
47
|
|
|
{ |
48
|
|
|
$customEndpoint = '/email'; |
49
|
|
|
return $this->client->post($customEndpoint . '/test'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
54
|
|
|
*/ |
55
|
|
|
public function getConfiguration() |
56
|
|
|
{ |
57
|
|
|
$customEndpoint = '/config'; |
58
|
|
|
return $this->client->get($customEndpoint); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param array $requestOptions |
63
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
64
|
|
|
*/ |
65
|
|
|
public function updateConfiguration(array $requestOptions) |
66
|
|
|
{ |
67
|
|
|
$customEndpoint = '/config'; |
68
|
|
|
return $this->client->put($customEndpoint, $requestOptions); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
73
|
|
|
*/ |
74
|
|
|
public function reloadConfiguration() |
75
|
|
|
{ |
76
|
|
|
$customEndpoint = '/config'; |
77
|
|
|
return $this->client->post($customEndpoint . '/reload'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param array $requestOptions |
82
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
83
|
|
|
*/ |
84
|
|
|
public function getClientConfiguration(array $requestOptions) |
85
|
|
|
{ |
86
|
|
|
$customEndpoint = '/config'; |
87
|
|
|
return $this->client->get($customEndpoint . '/client', $requestOptions); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param $requestOptions |
92
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
93
|
|
|
*/ |
94
|
|
|
public function getClientLicense(array $requestOptions) |
95
|
|
|
{ |
96
|
|
|
$customEndpoint = '/license'; |
97
|
|
|
return $this->client->get($customEndpoint . '/client', $requestOptions); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
102
|
|
|
*/ |
103
|
|
|
public function removeLicenseFile() |
104
|
|
|
{ |
105
|
|
|
$customEndpoint = '/license'; |
106
|
|
|
return $this->client->delete($customEndpoint); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param array $requestOptions |
111
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
112
|
|
|
*/ |
113
|
|
|
public function uploadLicenseFile(array $requestOptions) |
114
|
|
|
{ |
115
|
|
|
$customEndpoint = '/license'; |
116
|
|
|
return $this->client->post($customEndpoint, $requestOptions, 'multipart'); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param array $requestOptions |
121
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
122
|
|
|
*/ |
123
|
|
|
public function getAudits(array $requestOptions) |
124
|
|
|
{ |
125
|
|
|
$customEndpoint = '/audits'; |
126
|
|
|
return $this->client->get($customEndpoint, $requestOptions); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
131
|
|
|
*/ |
132
|
|
|
public function invalidateAllCaches() |
133
|
|
|
{ |
134
|
|
|
$customEndpoint = '/caches'; |
135
|
|
|
return $this->client->post($customEndpoint . '/invalidate'); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param array $requestOptions |
140
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
141
|
|
|
*/ |
142
|
|
|
public function getLogs(array $requestOptions) |
143
|
|
|
{ |
144
|
|
|
$customEndpoint = '/logs'; |
145
|
|
|
return $this->client->get($customEndpoint, $requestOptions); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param array $requestOptions |
150
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
151
|
|
|
*/ |
152
|
|
|
public function addLogMessage(array $requestOptions) |
153
|
|
|
{ |
154
|
|
|
$customEndpoint = '/logs'; |
155
|
|
|
return $this->client->post($customEndpoint, $requestOptions); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
160
|
|
|
*/ |
161
|
|
|
public function getWebRtcToken() |
162
|
|
|
{ |
163
|
|
|
$customEndpoint = '/webrtc'; |
164
|
|
|
return $this->client->get($customEndpoint . '/token'); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
169
|
|
|
*/ |
170
|
|
|
public function getAnalytics() |
171
|
|
|
{ |
172
|
|
|
$customEndpoint = '/analytics'; |
173
|
|
|
return $this->client->get($customEndpoint . '/old'); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|