forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDaemonConfigurationRepository.php
More file actions
47 lines (42 loc) · 1.49 KB
/
DaemonConfigurationRepository.php
File metadata and controls
47 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Pterodactyl\Repositories\Wings;
use Pterodactyl\Models\Node;
use GuzzleHttp\Exception\TransferException;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class DaemonConfigurationRepository extends DaemonRepository
{
/**
* Returns system information from the wings instance.
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function getSystemInformation(): array
{
try {
$response = $this->getHttpClient()->get('/api/system');
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
return json_decode($response->getBody()->__toString(), true);
}
/**
* Updates the configuration information for a daemon. Updates the information for
* this instance using a passed-in model. This allows us to change plenty of information
* in the model, and still use the old, pre-update model to actually make the HTTP request.
*
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function update(Node $node)
{
try {
return $this->getHttpClient()->post(
'/api/update',
['json' => $node->getConfiguration()]
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
}
}