api: cleanup controllers
This commit is contained in:
parent
00c42225e8
commit
f78aaea6a3
47 changed files with 323 additions and 764 deletions
|
@ -7,22 +7,14 @@ use Webmozart\Assert\Assert;
|
|||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Extensions\Spatie\Fractalistic\Fractal;
|
||||
use Pterodactyl\Transformers\Api\Application\BaseTransformer;
|
||||
|
||||
abstract class ApplicationApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal
|
||||
*/
|
||||
protected $fractal;
|
||||
protected Request $request;
|
||||
protected Fractal $fractal;
|
||||
|
||||
/**
|
||||
* ApplicationApiController constructor.
|
||||
|
@ -56,11 +48,9 @@ abstract class ApplicationApiController extends Controller
|
|||
/**
|
||||
* Return an instance of an application transformer.
|
||||
*
|
||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function getTransformer(string $abstract)
|
||||
public function getTransformer(string $abstract): BaseTransformer
|
||||
{
|
||||
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
|
||||
$transformer = Container::getInstance()->make($abstract);
|
||||
|
@ -72,6 +62,14 @@ abstract class ApplicationApiController extends Controller
|
|||
return $transformer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a HTTP/201 response for the API.
|
||||
*/
|
||||
protected function returnAccepted(): Response
|
||||
{
|
||||
return new Response('', Response::HTTP_ACCEPTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a HTTP/204 response for the API.
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Databases;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
@ -101,10 +102,10 @@ class DatabaseController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteDatabaseRequest $request, DatabaseHost $databaseHost): JsonResponse
|
||||
public function delete(DeleteDatabaseRequest $request, DatabaseHost $databaseHost): Response
|
||||
{
|
||||
$databaseHost->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Application\Eggs;
|
|||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\EggTransformer;
|
||||
|
@ -16,15 +17,10 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class EggController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
private EggRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* EggController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
{
|
||||
|
@ -36,10 +32,6 @@ class EggController extends ApplicationApiController
|
|||
/**
|
||||
* Return an array of all eggs on a given nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Eggs\GetEggsRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetEggsRequest $request, Nest $nest): array
|
||||
|
@ -56,10 +48,6 @@ class EggController extends ApplicationApiController
|
|||
/**
|
||||
* Returns a single egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Eggs\GetEggRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetEggRequest $request, Egg $egg): array
|
||||
|
@ -72,9 +60,6 @@ class EggController extends ApplicationApiController
|
|||
/**
|
||||
* Creates a new egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Eggs\StoreEggRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreEggRequest $request): JsonResponse
|
||||
|
@ -89,10 +74,6 @@ class EggController extends ApplicationApiController
|
|||
/**
|
||||
* Updates an egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Eggs\UpdateEggRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateEggRequest $request, Egg $egg): array
|
||||
|
@ -107,16 +88,12 @@ class EggController extends ApplicationApiController
|
|||
/**
|
||||
* Deletes an egg.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Eggs\DeleteEggRequest $request
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteEggRequest $request, Egg $egg): JsonResponse
|
||||
public function delete(DeleteEggRequest $request, Egg $egg): Response
|
||||
{
|
||||
$egg->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
@ -44,6 +45,8 @@ class LocationController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return all of the locations currently registered on the Panel.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetLocationsRequest $request): array
|
||||
{
|
||||
|
@ -66,6 +69,8 @@ class LocationController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return a single location.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetLocationRequest $request, Location $location): array
|
||||
{
|
||||
|
@ -79,6 +84,7 @@ class LocationController extends ApplicationApiController
|
|||
* new location attached.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreLocationRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -115,10 +121,10 @@ class LocationController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
||||
*/
|
||||
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse
|
||||
public function delete(DeleteLocationRequest $request, Location $location): Response
|
||||
{
|
||||
$this->deletionService->handle($location);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Mounts;
|
||||
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Transformers\Api\Application\MountTransformer;
|
||||
|
@ -12,8 +13,8 @@ use Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountsRequest;
|
|||
use Pterodactyl\Http\Requests\Api\Application\Mounts\MountEggsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\MountNodesRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\StoreMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\UpdateMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\DeleteMountRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Mounts\UpdateMountRequest;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
|
||||
class MountController extends ApplicationApiController
|
||||
|
@ -29,9 +30,6 @@ class MountController extends ApplicationApiController
|
|||
/**
|
||||
* Returns an array of all mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountsRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetMountsRequest $request): array
|
||||
|
@ -56,10 +54,6 @@ class MountController extends ApplicationApiController
|
|||
/**
|
||||
* Returns a single mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\GetMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetMountRequest $request, Mount $mount): array
|
||||
|
@ -72,9 +66,6 @@ class MountController extends ApplicationApiController
|
|||
/**
|
||||
* Creates a new mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\StoreMountRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreMountRequest $request): JsonResponse
|
||||
|
@ -89,10 +80,6 @@ class MountController extends ApplicationApiController
|
|||
/**
|
||||
* Updates a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\UpdateMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateMountRequest $request, Mount $mount): array
|
||||
|
@ -107,26 +94,19 @@ class MountController extends ApplicationApiController
|
|||
/**
|
||||
* Deletes a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\DeleteMountRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteMountRequest $request, Mount $mount): JsonResponse
|
||||
public function delete(DeleteMountRequest $request, Mount $mount): Response
|
||||
{
|
||||
$mount->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
* Attaches eggs to a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\MountEggsRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function addEggs(MountEggsRequest $request, Mount $mount): array
|
||||
{
|
||||
|
@ -143,12 +123,9 @@ class MountController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
* Attaches nodes to a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\MountNodesRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function addNodes(MountNodesRequest $request, Mount $mount): array
|
||||
{
|
||||
|
@ -165,12 +142,9 @@ class MountController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
* Detaches eggs from a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\MountEggsRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function deleteEggs(MountEggsRequest $request, Mount $mount): array
|
||||
{
|
||||
|
@ -187,12 +161,9 @@ class MountController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
* Detaches nodes from a mount.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Mounts\MountNodesRequest $request
|
||||
* @param \Pterodactyl\Models\Mount $mount
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function deleteNodes(MountNodesRequest $request, Mount $mount): array
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Nests;
|
||||
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Services\Nests\NestUpdateService;
|
||||
use Pterodactyl\Services\Nests\NestCreationService;
|
||||
use Pterodactyl\Services\Nests\NestDeletionService;
|
||||
|
@ -13,31 +13,16 @@ use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestRequest;
|
|||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
|
||||
class NestController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestCreationService
|
||||
*/
|
||||
protected $nestCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestDeletionService
|
||||
*/
|
||||
protected $nestDeletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestUpdateService
|
||||
*/
|
||||
protected $nestUpdateService;
|
||||
private NestRepositoryInterface $repository;
|
||||
protected NestCreationService $nestCreationService;
|
||||
protected NestDeletionService $nestDeletionService;
|
||||
protected NestUpdateService $nestUpdateService;
|
||||
|
||||
/**
|
||||
* NestController constructor.
|
||||
|
@ -59,6 +44,8 @@ class NestController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return all Nests that exist on the Panel.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetNestsRequest $request): array
|
||||
{
|
||||
|
@ -79,10 +66,6 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Return information about a single Nest model.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetNestRequest $request, Nest $nest): array
|
||||
|
@ -95,9 +78,6 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Creates a new nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\StoreNestRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
|
@ -113,10 +93,6 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Updates an existing nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\UpdateNestRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
|
@ -133,16 +109,12 @@ class NestController extends ApplicationApiController
|
|||
/**
|
||||
* Deletes an existing nest.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\DeleteNestRequest $request
|
||||
* @param \Pterodactyl\Models\Nest $nest
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function delete(DeleteNestRequest $request, Nest $nest): JsonResponse
|
||||
public function delete(DeleteNestRequest $request, Nest $nest): Response
|
||||
{
|
||||
$this->nestDeletionService->handle($nest->id);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Nodes;
|
||||
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Services\Allocations\AssignmentService;
|
||||
use Pterodactyl\Services\Allocations\AllocationDeletionService;
|
||||
|
@ -15,21 +15,11 @@ use Pterodactyl\Http\Requests\Api\Application\Allocations\DeleteAllocationReques
|
|||
|
||||
class AllocationController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AssignmentService
|
||||
*/
|
||||
private $assignmentService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
private AssignmentService $assignmentService;
|
||||
private AllocationDeletionService $deletionService;
|
||||
|
||||
/**
|
||||
* AllocationController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService
|
||||
* @param \Pterodactyl\Services\Allocations\AllocationDeletionService $deletionService
|
||||
*/
|
||||
public function __construct(
|
||||
AssignmentService $assignmentService,
|
||||
|
@ -44,10 +34,6 @@ class AllocationController extends ApplicationApiController
|
|||
/**
|
||||
* Return all of the allocations that exist for a given node.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\GetAllocationsRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetAllocationsRequest $request, Node $node): array
|
||||
|
@ -62,36 +48,28 @@ class AllocationController extends ApplicationApiController
|
|||
/**
|
||||
* Store new allocations for a given node.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\StoreAllocationRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException
|
||||
*/
|
||||
public function store(StoreAllocationRequest $request, Node $node): JsonResponse
|
||||
public function store(StoreAllocationRequest $request, Node $node): Response
|
||||
{
|
||||
$this->assignmentService->handle($node, $request->validated());
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific allocation from the Panel.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Allocations\DeleteAllocationRequest $request
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException
|
||||
*/
|
||||
public function delete(DeleteAllocationRequest $request, Node $node, Allocation $allocation): JsonResponse
|
||||
public function delete(DeleteAllocationRequest $request, Node $node, Allocation $allocation): Response
|
||||
{
|
||||
$this->deletionService->handle($allocation);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,9 @@ class NodeConfigurationController extends ApplicationApiController
|
|||
* to remote machines so long as an API key is provided to the machine to make the request
|
||||
* with, and the node is known.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function __invoke(GetNodeRequest $request, Node $node)
|
||||
public function __invoke(GetNodeRequest $request, Node $node): string
|
||||
{
|
||||
if ($request->query('format') === 'yaml') {
|
||||
return $node->getYamlConfiguration();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Nodes;
|
||||
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Services\Nodes\NodeUpdateService;
|
||||
|
@ -20,34 +21,19 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class NodeController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
private NodeRepositoryInterface $repository;
|
||||
private NodeCreationService $creationService;
|
||||
private NodeDeletionService $deletionService;
|
||||
private NodeUpdateService $updateService;
|
||||
|
||||
/**
|
||||
* NodeController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
NodeRepositoryInterface $repository,
|
||||
NodeCreationService $creationService,
|
||||
NodeDeletionService $deletionService,
|
||||
NodeUpdateService $updateService,
|
||||
NodeRepositoryInterface $repository
|
||||
NodeUpdateService $updateService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
|
@ -59,6 +45,8 @@ class NodeController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return all of the nodes currently available on the Panel.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetNodesRequest $request): array
|
||||
{
|
||||
|
@ -81,6 +69,8 @@ class NodeController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return data for a single instance of a node.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetNodeRequest $request, Node $node): array
|
||||
{
|
||||
|
@ -94,6 +84,7 @@ class NodeController extends ApplicationApiController
|
|||
* status response on success.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function store(StoreNodeRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -133,10 +124,10 @@ class NodeController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||
*/
|
||||
public function delete(DeleteNodeRequest $request, Node $node): JsonResponse
|
||||
public function delete(DeleteNodeRequest $request, Node $node): Response
|
||||
{
|
||||
$this->deletionService->handle($node);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,7 @@ use Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;
|
|||
|
||||
class NodeDeploymentController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Deployment\FindViableNodesService
|
||||
*/
|
||||
private $viableNodesService;
|
||||
private FindViableNodesService $viableNodesService;
|
||||
|
||||
/**
|
||||
* NodeDeploymentController constructor.
|
||||
|
@ -29,6 +26,7 @@ class NodeDeploymentController extends ApplicationApiController
|
|||
* similarly to the server creation process, but allows you to pass the deployment object
|
||||
* to this endpoint and get back a list of all Nodes satisfying the requirements.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
||||
*/
|
||||
public function __invoke(GetDeployableNodesRequest $request): array
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Api\Application\Roles;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Models\AdminRole;
|
||||
use Pterodactyl\Transformers\Api\Application\AdminRoleTransformer;
|
||||
|
@ -82,10 +83,10 @@ class RoleController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(DeleteRoleRequest $request, AdminRole $role): JsonResponse
|
||||
public function delete(DeleteRoleRequest $request, AdminRole $role): Response
|
||||
{
|
||||
$role->delete();
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,9 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatab
|
|||
|
||||
class DatabaseController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
|
||||
*/
|
||||
private $databaseManagementService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
|
||||
*/
|
||||
private $databasePasswordService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
private DatabaseManagementService $databaseManagementService;
|
||||
private DatabasePasswordService $databasePasswordService;
|
||||
private DatabaseRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
|
@ -51,6 +40,8 @@ class DatabaseController extends ApplicationApiController
|
|||
/**
|
||||
* Return a listing of all databases currently available to a single
|
||||
* server.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetServerDatabasesRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -61,6 +52,8 @@ class DatabaseController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Return a single server database.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
||||
{
|
||||
|
@ -74,11 +67,11 @@ class DatabaseController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse
|
||||
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): Response
|
||||
{
|
||||
$this->databasePasswordService->handle($database);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,12 +99,12 @@ class DatabaseController extends ApplicationApiController
|
|||
/**
|
||||
* Handle a request to delete a specific server database from the Panel.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
|
||||
public function delete(ServerDatabaseWriteRequest $request, Database $database): Response
|
||||
{
|
||||
$this->databaseManagementService->delete($database);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ class ExternalServerController extends ApplicationApiController
|
|||
{
|
||||
/**
|
||||
* Retrieve a specific server from the database using its external ID.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetExternalServerRequest $request): array
|
||||
{
|
||||
|
|
|
@ -92,11 +92,6 @@ class ServerController extends ApplicationApiController
|
|||
/**
|
||||
* Deletes a server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @param string $force
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
|
|
|
@ -12,15 +12,8 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigura
|
|||
|
||||
class ServerDetailsController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\BuildModificationService
|
||||
*/
|
||||
private $buildModificationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\DetailsModificationService
|
||||
*/
|
||||
private $detailsModificationService;
|
||||
private BuildModificationService $buildModificationService;
|
||||
private DetailsModificationService $detailsModificationService;
|
||||
|
||||
/**
|
||||
* ServerDetailsController constructor.
|
||||
|
@ -38,9 +31,7 @@ class ServerDetailsController extends ApplicationApiController
|
|||
/**
|
||||
* Update the details for a specific server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function details(UpdateServerDetailsRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -57,13 +48,7 @@ class ServerDetailsController extends ApplicationApiController
|
|||
/**
|
||||
* Update the build details for a specific server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
||||
{
|
||||
|
|
|
@ -11,15 +11,8 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class ServerManagementController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
||||
*/
|
||||
private $reinstallServerService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\SuspensionService
|
||||
*/
|
||||
private $suspensionService;
|
||||
private ReinstallServerService $reinstallServerService;
|
||||
private SuspensionService $suspensionService;
|
||||
|
||||
/**
|
||||
* SuspensionController constructor.
|
||||
|
@ -61,9 +54,7 @@ class ServerManagementController extends ApplicationApiController
|
|||
/**
|
||||
* Mark a server as needing to be reinstalled.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
||||
{
|
||||
|
|
|
@ -11,10 +11,7 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest
|
|||
|
||||
class StartupController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\StartupModificationService
|
||||
*/
|
||||
private $modificationService;
|
||||
private StartupModificationService $modificationService;
|
||||
|
||||
/**
|
||||
* StartupController constructor.
|
||||
|
@ -29,10 +26,7 @@ class StartupController extends ApplicationApiController
|
|||
/**
|
||||
* Update the startup and environment settings for a specific server.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(UpdateServerStartupRequest $request, Server $server): array
|
||||
{
|
||||
|
|
|
@ -10,6 +10,8 @@ class ExternalUserController extends ApplicationApiController
|
|||
{
|
||||
/**
|
||||
* Retrieve a specific user from the database using their external ID.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetExternalUserRequest $request): array
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Services\Users\UserUpdateService;
|
||||
|
@ -20,25 +21,10 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class UserController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
private UserRepositoryInterface $repository;
|
||||
private UserCreationService $creationService;
|
||||
private UserDeletionService $deletionService;
|
||||
private UserUpdateService $updateService;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
|
@ -62,9 +48,6 @@ class UserController extends ApplicationApiController
|
|||
* of a collection of users including any defined relations passed in
|
||||
* the request.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest $request
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function index(GetUsersRequest $request): array
|
||||
|
@ -89,6 +72,8 @@ class UserController extends ApplicationApiController
|
|||
/**
|
||||
* Handle a request to view a single user. Includes any relations that
|
||||
* were defined in the request.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetUserRequest $request, User $user): array
|
||||
{
|
||||
|
@ -146,10 +131,10 @@ class UserController extends ApplicationApiController
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(DeleteUserRequest $request, User $user): JsonResponse
|
||||
public function delete(DeleteUserRequest $request, User $user): Response
|
||||
{
|
||||
$this->deletionService->handle($user);
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,10 @@ use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
|||
|
||||
class VersionController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
private SoftwareVersionService $softwareVersionService;
|
||||
|
||||
/**
|
||||
* VersionController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $softwareVersionService
|
||||
*/
|
||||
public function __construct(SoftwareVersionService $softwareVersionService)
|
||||
{
|
||||
|
@ -26,8 +21,6 @@ class VersionController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Returns version information.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function __invoke(): JsonResponse
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue