Files
pterodactyl-panel/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

38 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
use Knuckles\Scribe\Attributes\Endpoint;
use Knuckles\Scribe\Attributes\Group;
use Knuckles\Scribe\Attributes\Subgroup;
use Pterodactyl\Extensions\Scribe\Attributes\ResponseFromTransformer;
use Pterodactyl\Facades\Fractal;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
use Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\ServerFinderService;
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
#[Group('Application API', 'Root administrator endpoints for managing panel resources using application API tokens.')]
#[Subgroup('Servers', 'Create, update, retrieve, manage, and delete servers.')]
class ExternalServerController extends ApplicationApiController
{
/**
* Retrieve a specific server from the database using its external ID.
*
* @return ApiPayload
*/
#[Endpoint('Get server by external ID', 'Returns a single server by its external identifier.')]
#[ResponseFromTransformer(ServerTransformer::class, Server::class, factoryStates: ['withRelationships'], resourceKey: 'server')]
public function index(GetExternalServerRequest $request, ServerFinderService $finder, string $external_id): array
{
$server = $finder->byExternalId($external_id);
return Fractal::item($server)
->transformWith($this->getTransformer(ServerTransformer::class))
->toResponseArray();
}
}