1 | <?php |
||
11 | class Server implements ArrayAccess |
||
12 | { |
||
13 | use ArrayAccessTrait; |
||
14 | |||
15 | /** |
||
16 | * API provider. |
||
17 | * |
||
18 | * @var \Laravel\Forge\ApiProvider |
||
19 | */ |
||
20 | protected $api; |
||
21 | |||
22 | /** |
||
23 | * Server data. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $data; |
||
28 | |||
29 | /** |
||
30 | * Create new server instance. |
||
31 | * |
||
32 | * @param \Laravel\Forge\ApiProvider $api = null |
||
33 | * @param array $data = [] |
||
34 | */ |
||
35 | public function __construct(ApiProvider $api = null, array $data = []) |
||
40 | |||
41 | /** |
||
42 | * Create new server instance from HTTP response. |
||
43 | * |
||
44 | * @param \Psr\Http\Message\ResponseInterface $response |
||
45 | * @param \Laravel\Forge\ApiProvider $api = null |
||
46 | * |
||
47 | * @throws \Laravel\Forge\Exceptions\Servers\ServerWasNotFoundException |
||
48 | * |
||
49 | * @return static |
||
50 | */ |
||
51 | public static function createFromResponse(ResponseInterface $response, ApiProvider $api = null) |
||
61 | |||
62 | /** |
||
63 | * Server data. |
||
64 | * |
||
65 | * @param string $key = null |
||
66 | * @param mixed $default = null |
||
67 | * |
||
68 | * @return mixed|array|null |
||
69 | */ |
||
70 | protected function serverData(string $key = null, $default = null) |
||
78 | |||
79 | /** |
||
80 | * API provider. |
||
81 | * |
||
82 | * @return \Laravel\Forge\ApiProvider |
||
83 | */ |
||
84 | public function getApi(): ApiProvider |
||
88 | |||
89 | /** |
||
90 | * Server ID. |
||
91 | * |
||
92 | * @return int |
||
93 | */ |
||
94 | public function id(): int |
||
98 | |||
99 | /** |
||
100 | * Credential ID. |
||
101 | * |
||
102 | * @return int |
||
103 | */ |
||
104 | public function credentialId(): int |
||
108 | |||
109 | /** |
||
110 | * Server name. |
||
111 | * |
||
112 | * @return string|null |
||
113 | */ |
||
114 | public function name() |
||
118 | |||
119 | /** |
||
120 | * Human readable server size. |
||
121 | * |
||
122 | * @return string|null |
||
123 | */ |
||
124 | public function size() |
||
128 | |||
129 | /** |
||
130 | * Server region. |
||
131 | * |
||
132 | * @return string|null |
||
133 | */ |
||
134 | public function region() |
||
138 | |||
139 | /** |
||
140 | * Server's PHP version. |
||
141 | * |
||
142 | * @return string|null |
||
143 | */ |
||
144 | public function phpVersion() |
||
148 | |||
149 | /** |
||
150 | * Server public IP address. |
||
151 | * |
||
152 | * @return string|null |
||
153 | */ |
||
154 | public function ip() |
||
158 | |||
159 | /** |
||
160 | * Server private IP address. |
||
161 | */ |
||
162 | public function privateIp() |
||
166 | |||
167 | /** |
||
168 | * Blackfire service status. |
||
169 | * |
||
170 | * @return string|null |
||
171 | */ |
||
172 | public function blackfireStatus() |
||
176 | |||
177 | /** |
||
178 | * Papertrail service status. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function parerTrailStatus() |
||
186 | |||
187 | /** |
||
188 | * Determines if server access was revoked from Forge. |
||
189 | * |
||
190 | * @return bool |
||
191 | */ |
||
192 | public function isRevoked(): bool |
||
196 | |||
197 | /** |
||
198 | * Determines if server was provisioned and ready to use. |
||
199 | * |
||
200 | * @return bool |
||
201 | */ |
||
202 | public function isReady(): bool |
||
206 | |||
207 | /** |
||
208 | * Network status. |
||
209 | * |
||
210 | * @return array|null |
||
211 | */ |
||
212 | public function network() |
||
216 | |||
217 | /** |
||
218 | * Server's API URL. |
||
219 | * |
||
220 | * @param string $path = '' |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | public function apiUrl(string $path = ''): string |
||
230 | |||
231 | /** |
||
232 | * Update server data. |
||
233 | * |
||
234 | * @param array $payload |
||
235 | * |
||
236 | * @return bool |
||
237 | */ |
||
238 | public function update(array $payload): bool |
||
256 | |||
257 | /** |
||
258 | * Reboot the server. |
||
259 | * |
||
260 | * @return bool |
||
261 | */ |
||
262 | public function reboot(): bool |
||
268 | |||
269 | /** |
||
270 | * Revoke Forge access to server. |
||
271 | * |
||
272 | * @return bool |
||
273 | **/ |
||
274 | public function revokeAccess(): bool |
||
280 | |||
281 | /** |
||
282 | * Reconnect revoked server. |
||
283 | * |
||
284 | * @return string Public SSH key. |
||
285 | */ |
||
286 | public function reconnect(): string |
||
300 | |||
301 | /** |
||
302 | * Reactivate revoked server. Make sure you've installed public SSH key |
||
303 | * before calling this method. |
||
304 | * |
||
305 | * @return bool |
||
306 | */ |
||
307 | public function reactivate(): bool |
||
313 | |||
314 | /** |
||
315 | * Delete the server. |
||
316 | * |
||
317 | * @return bool |
||
318 | */ |
||
319 | public function delete(): bool |
||
325 | } |
||
326 |