2018-03-17 19:01:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Transformers\Api\Client;
|
|
|
|
|
2019-08-17 23:03:10 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2021-08-07 20:06:45 +00:00
|
|
|
use Pterodactyl\Transformers\Api\Transformer;
|
2018-03-17 19:01:53 +00:00
|
|
|
|
2021-08-07 20:06:45 +00:00
|
|
|
class StatsTransformer extends Transformer
|
2018-03-17 19:01:53 +00:00
|
|
|
{
|
|
|
|
public function getResourceName(): string
|
|
|
|
{
|
|
|
|
return 'stats';
|
|
|
|
}
|
|
|
|
|
2021-08-07 20:06:45 +00:00
|
|
|
public function transform(array $data): array
|
2018-03-17 19:01:53 +00:00
|
|
|
{
|
|
|
|
return [
|
2019-08-17 23:03:10 +00:00
|
|
|
'current_state' => Arr::get($data, 'state', 'stopped'),
|
2021-04-04 17:25:54 +00:00
|
|
|
'is_suspended' => Arr::get($data, 'is_suspended', false),
|
2019-08-17 23:03:10 +00:00
|
|
|
'resources' => [
|
2021-04-04 17:25:54 +00:00
|
|
|
'memory_bytes' => Arr::get($data, 'utilization.memory_bytes', 0),
|
|
|
|
'cpu_absolute' => Arr::get($data, 'utilization.cpu_absolute', 0),
|
|
|
|
'disk_bytes' => Arr::get($data, 'utilization.disk_bytes', 0),
|
|
|
|
'network_rx_bytes' => Arr::get($data, 'utilization.network.rx_bytes', 0),
|
|
|
|
'network_tx_bytes' => Arr::get($data, 'utilization.network.tx_bytes', 0),
|
2021-10-24 17:12:17 +00:00
|
|
|
'uptime' => Arr::get($data, 'utilization.uptime', 0),
|
2018-03-17 19:01:53 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|