Skip to content

Commit 7b5139b

Browse files
committed
[Breaking] Return all server allocations in API response
1 parent d3c749a commit 7b5139b

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

app/Transformers/Api/Client/ServerTransformer.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Pterodactyl\Models\Egg;
66
use Pterodactyl\Models\Server;
77
use Pterodactyl\Models\Subuser;
8+
use Pterodactyl\Models\Allocation;
89

910
class ServerTransformer extends BaseClientTransformer
1011
{
@@ -41,10 +42,14 @@ public function transform(Server $server): array
4142
'port' => $server->node->daemonSFTP,
4243
],
4344
'description' => $server->description,
44-
'allocation' => [
45-
'ip' => $server->allocation->alias,
46-
'port' => $server->allocation->port,
47-
],
45+
'allocations' => $server->allocations->map(function (Allocation $allocation) use ($server) {
46+
return [
47+
'ip' => $allocation->ip,
48+
'ip_alias' => $allocation->ip_alias,
49+
'port' => $allocation->port,
50+
'is_default' => $allocation->id === $server->allocation_id,
51+
];
52+
}),
4853
'limits' => [
4954
'memory' => $server->memory,
5055
'swap' => $server->swap,

resources/scripts/api/server/getServer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ export const rawDataToServerObject = (data: any): Server => ({
4545
port: data.sftp_details.port,
4646
},
4747
description: data.description ? ((data.description.length > 0) ? data.description : null) : null,
48-
allocations: [ {
49-
ip: data.allocation.ip,
50-
alias: null,
51-
port: data.allocation.port,
52-
default: true,
53-
} ],
48+
allocations: (data.allocations || []).map((datum: any) => ({
49+
ip: datum.ip,
50+
alias: datum.ip_alias,
51+
port: datum.port,
52+
default: datum.is_default,
53+
})),
5454
limits: { ...data.limits },
5555
featureLimits: { ...data.feature_limits },
5656
isSuspended: data.is_suspended,

0 commit comments

Comments
 (0)