Small api docs improvements (#1032)

* update scramble

* cleanup application api endpoints

* cleanup client api endpoints

* fix security schema and make docs homepage nicer

* remove duplicate myclabs/deep-copy

* style(api-docs): use Blade template and Tailwind for styling

* Publish scramble view

* Use localStorage theme instead of config

* Update routes/docs.php

Co-authored-by: Lance Pioch <git@lance.sh>

---------

Co-authored-by: Quinten <67589015+QuintenQVD0@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
Co-authored-by: Lance Pioch <git@lance.sh>
This commit is contained in:
Boy132 2025-02-26 16:12:19 +01:00 committed by GitHub
parent 2d937229fb
commit e1308cb04d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 436 additions and 29 deletions

View File

@ -28,6 +28,8 @@ class DatabaseHostController extends ApplicationApiController
} }
/** /**
* List database hosts
*
* Return all the database hosts currently registered on the Panel. * Return all the database hosts currently registered on the Panel.
*/ */
public function index(GetDatabaseHostRequest $request): array public function index(GetDatabaseHostRequest $request): array
@ -43,6 +45,8 @@ class DatabaseHostController extends ApplicationApiController
} }
/** /**
* View database host
*
* Return a single database host. * Return a single database host.
*/ */
public function view(GetDatabaseHostRequest $request, DatabaseHost $databaseHost): array public function view(GetDatabaseHostRequest $request, DatabaseHost $databaseHost): array
@ -53,6 +57,8 @@ class DatabaseHostController extends ApplicationApiController
} }
/** /**
* Create database host
*
* Store a new database host on the Panel and return an HTTP/201 response code with the * Store a new database host on the Panel and return an HTTP/201 response code with the
* new database host attached. * new database host attached.
* *
@ -73,6 +79,8 @@ class DatabaseHostController extends ApplicationApiController
} }
/** /**
* Update database host
*
* Update a database host on the Panel and return the updated record to the user. * Update a database host on the Panel and return the updated record to the user.
* *
* @throws \Throwable * @throws \Throwable
@ -87,6 +95,8 @@ class DatabaseHostController extends ApplicationApiController
} }
/** /**
* Delete database host
*
* Delete a database host from the Panel. * Delete a database host from the Panel.
* *
* @throws \Exception * @throws \Exception

View File

@ -11,6 +11,8 @@ use App\Transformers\Api\Application\EggTransformer;
class EggController extends ApplicationApiController class EggController extends ApplicationApiController
{ {
/** /**
* List eggs
*
* Return all eggs * Return all eggs
*/ */
public function index(GetEggsRequest $request): array public function index(GetEggsRequest $request): array
@ -21,6 +23,8 @@ class EggController extends ApplicationApiController
} }
/** /**
* View egg
*
* Return a single egg that exists * Return a single egg that exists
*/ */
public function view(GetEggRequest $request, Egg $egg): array public function view(GetEggRequest $request, Egg $egg): array

View File

@ -18,6 +18,8 @@ use App\Exceptions\Service\HasActiveServersException;
class MountController extends ApplicationApiController class MountController extends ApplicationApiController
{ {
/** /**
* List mounts
*
* Return all the mounts currently available on the Panel. * Return all the mounts currently available on the Panel.
*/ */
public function index(GetMountRequest $request): array public function index(GetMountRequest $request): array
@ -33,6 +35,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* View mount
*
* Return data for a single instance of a mount. * Return data for a single instance of a mount.
*/ */
public function view(GetMountRequest $request, Mount $mount): array public function view(GetMountRequest $request, Mount $mount): array
@ -43,6 +47,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Create mount
*
* Create a new mount on the Panel. Returns the created mount and an HTTP/201 * Create a new mount on the Panel. Returns the created mount and an HTTP/201
* status response on success. * status response on success.
* *
@ -67,6 +73,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Update mount
*
* Update an existing mount on the Panel. * Update an existing mount on the Panel.
* *
* @throws \Throwable * @throws \Throwable
@ -81,6 +89,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Delete mount
*
* Deletes a given mount from the Panel as long as there are no servers * Deletes a given mount from the Panel as long as there are no servers
* currently attached to it. * currently attached to it.
* *
@ -98,6 +108,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Assign eggs to mount
*
* Adds eggs to the mount's many-to-many relation. * Adds eggs to the mount's many-to-many relation.
*/ */
public function addEggs(Request $request, Mount $mount): array public function addEggs(Request $request, Mount $mount): array
@ -117,6 +129,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Assign mounts to mount
*
* Adds nodes to the mount's many-to-many relation. * Adds nodes to the mount's many-to-many relation.
*/ */
public function addNodes(Request $request, Mount $mount): array public function addNodes(Request $request, Mount $mount): array
@ -134,6 +148,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Unassign egg from mount
*
* Deletes an egg from the mount's many-to-many relation. * Deletes an egg from the mount's many-to-many relation.
*/ */
public function deleteEgg(Mount $mount, int $egg_id): JsonResponse public function deleteEgg(Mount $mount, int $egg_id): JsonResponse
@ -144,6 +160,8 @@ class MountController extends ApplicationApiController
} }
/** /**
* Unassign node from mount
*
* Deletes a node from the mount's many-to-many relation. * Deletes a node from the mount's many-to-many relation.
*/ */
public function deleteNode(Mount $mount, int $node_id): JsonResponse public function deleteNode(Mount $mount, int $node_id): JsonResponse

View File

@ -14,7 +14,9 @@ use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Allocations\GetAllocationsRequest; use App\Http\Requests\Api\Application\Allocations\GetAllocationsRequest;
use App\Http\Requests\Api\Application\Allocations\StoreAllocationRequest; use App\Http\Requests\Api\Application\Allocations\StoreAllocationRequest;
use App\Http\Requests\Api\Application\Allocations\DeleteAllocationRequest; use App\Http\Requests\Api\Application\Allocations\DeleteAllocationRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Node - Allocation')]
class AllocationController extends ApplicationApiController class AllocationController extends ApplicationApiController
{ {
/** /**
@ -27,6 +29,8 @@ class AllocationController extends ApplicationApiController
} }
/** /**
* List allocations
*
* Return all the allocations that exist for a given node. * Return all the allocations that exist for a given node.
*/ */
public function index(GetAllocationsRequest $request, Node $node): array public function index(GetAllocationsRequest $request, Node $node): array
@ -52,6 +56,8 @@ class AllocationController extends ApplicationApiController
} }
/** /**
* Create allocation
*
* Store new allocations for a given node. * Store new allocations for a given node.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -68,6 +74,8 @@ class AllocationController extends ApplicationApiController
} }
/** /**
* Delete allocation
*
* Delete a specific allocation from the Panel. * Delete a specific allocation from the Panel.
*/ */
public function delete(DeleteAllocationRequest $request, Node $node, Allocation $allocation): JsonResponse public function delete(DeleteAllocationRequest $request, Node $node, Allocation $allocation): JsonResponse

View File

@ -6,10 +6,14 @@ use App\Models\Node;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use App\Http\Requests\Api\Application\Nodes\GetNodeRequest; use App\Http\Requests\Api\Application\Nodes\GetNodeRequest;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use Dedoc\Scramble\Attributes\Group;
#[Group('Node', weight: 1)]
class NodeConfigurationController extends ApplicationApiController class NodeConfigurationController extends ApplicationApiController
{ {
/** /**
* Get node configuration
*
* Returns the configuration information for a node. This allows for automated deployments * Returns the configuration information for a node. This allows for automated deployments
* to remote machines so long as an API key is provided to the machine to make the request * to remote machines so long as an API key is provided to the machine to make the request
* with, and the node is known. * with, and the node is known.

View File

@ -15,7 +15,9 @@ use App\Http\Requests\Api\Application\Nodes\StoreNodeRequest;
use App\Http\Requests\Api\Application\Nodes\DeleteNodeRequest; use App\Http\Requests\Api\Application\Nodes\DeleteNodeRequest;
use App\Http\Requests\Api\Application\Nodes\UpdateNodeRequest; use App\Http\Requests\Api\Application\Nodes\UpdateNodeRequest;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use Dedoc\Scramble\Attributes\Group;
#[Group('Node', weight: 0)]
class NodeController extends ApplicationApiController class NodeController extends ApplicationApiController
{ {
/** /**
@ -30,6 +32,8 @@ class NodeController extends ApplicationApiController
} }
/** /**
* List nodes
*
* Return all the nodes currently available on the Panel. * Return all the nodes currently available on the Panel.
*/ */
public function index(GetNodesRequest $request): array public function index(GetNodesRequest $request): array
@ -45,6 +49,8 @@ class NodeController extends ApplicationApiController
} }
/** /**
* View node
*
* Return data for a single instance of a node. * Return data for a single instance of a node.
*/ */
public function view(GetNodeRequest $request, Node $node): array public function view(GetNodeRequest $request, Node $node): array
@ -55,6 +61,8 @@ class NodeController extends ApplicationApiController
} }
/** /**
* Create node
*
* Create a new node on the Panel. Returns the created node and an HTTP/201 * Create a new node on the Panel. Returns the created node and an HTTP/201
* status response on success. * status response on success.
* *
@ -75,6 +83,8 @@ class NodeController extends ApplicationApiController
} }
/** /**
* Update node
*
* Update an existing node on the Panel. * Update an existing node on the Panel.
* *
* @throws \Throwable * @throws \Throwable
@ -93,6 +103,8 @@ class NodeController extends ApplicationApiController
} }
/** /**
* Delete node
*
* Deletes a given node from the Panel as long as there are no servers * Deletes a given node from the Panel as long as there are no servers
* currently attached to it. * currently attached to it.
* *

View File

@ -6,7 +6,9 @@ use App\Services\Deployment\FindViableNodesService;
use App\Transformers\Api\Application\NodeTransformer; use App\Transformers\Api\Application\NodeTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest; use App\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Node', weight: 2)]
class NodeDeploymentController extends ApplicationApiController class NodeDeploymentController extends ApplicationApiController
{ {
public function __construct(private FindViableNodesService $viableNodesService) public function __construct(private FindViableNodesService $viableNodesService)
@ -15,6 +17,8 @@ class NodeDeploymentController extends ApplicationApiController
} }
/** /**
* Get deployable nodes
*
* Finds any nodes that are available using the given deployment criteria. This works * Finds any nodes that are available using the given deployment criteria. This works
* similarly to the server creation process, but allows you to pass the deployment object * 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. * to this endpoint and get back a list of all Nodes satisfying the requirements.

View File

@ -17,6 +17,8 @@ use App\Http\Requests\Api\Application\Roles\UpdateRoleRequest;
class RoleController extends ApplicationApiController class RoleController extends ApplicationApiController
{ {
/** /**
* List roles
*
* Return all the roles currently registered on the Panel. * Return all the roles currently registered on the Panel.
*/ */
public function index(GetRoleRequest $request): array public function index(GetRoleRequest $request): array
@ -32,6 +34,8 @@ class RoleController extends ApplicationApiController
} }
/** /**
* View role
*
* Return a single role. * Return a single role.
*/ */
public function view(GetRoleRequest $request, Role $role): array public function view(GetRoleRequest $request, Role $role): array
@ -42,6 +46,8 @@ class RoleController extends ApplicationApiController
} }
/** /**
* Create role
*
* Store a new role on the Panel and return an HTTP/201 response code with the * Store a new role on the Panel and return an HTTP/201 response code with the
* new role attached. * new role attached.
* *
@ -62,6 +68,8 @@ class RoleController extends ApplicationApiController
} }
/** /**
* Update role
*
* Update a role on the Panel and return the updated record to the user. * Update a role on the Panel and return the updated record to the user.
* *
* @throws \Throwable * @throws \Throwable
@ -80,6 +88,8 @@ class RoleController extends ApplicationApiController
} }
/** /**
* Delete role
*
* Delete a role from the Panel. * Delete a role from the Panel.
* *
* @throws \Exception * @throws \Exception

View File

@ -14,7 +14,9 @@ use App\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest
use App\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest; use App\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest;
use App\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest; use App\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest;
use App\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest; use App\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Database')]
class DatabaseController extends ApplicationApiController class DatabaseController extends ApplicationApiController
{ {
/** /**
@ -28,6 +30,8 @@ class DatabaseController extends ApplicationApiController
} }
/** /**
* List databases
*
* Return a listing of all databases currently available to a single * Return a listing of all databases currently available to a single
* server. * server.
*/ */
@ -39,6 +43,8 @@ class DatabaseController extends ApplicationApiController
} }
/** /**
* View database
*
* Return a single server database. * Return a single server database.
*/ */
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
@ -49,6 +55,8 @@ class DatabaseController extends ApplicationApiController
} }
/** /**
* Reset password
*
* Reset the password for a specific server database. * Reset the password for a specific server database.
* *
* @throws \Throwable * @throws \Throwable
@ -61,6 +69,8 @@ class DatabaseController extends ApplicationApiController
} }
/** /**
* Create database
*
* Create a new database on the Panel for a given server. * Create a new database on the Panel for a given server.
* *
* @throws \Throwable * @throws \Throwable
@ -83,6 +93,8 @@ class DatabaseController extends ApplicationApiController
} }
/** /**
* Delete database
*
* Handle a request to delete a specific server database from the Panel. * Handle a request to delete a specific server database from the Panel.
*/ */
public function delete(ServerDatabaseWriteRequest $request, Server $server, Database $database): Response public function delete(ServerDatabaseWriteRequest $request, Server $server, Database $database): Response

View File

@ -6,10 +6,14 @@ use App\Models\Server;
use App\Transformers\Api\Application\ServerTransformer; use App\Transformers\Api\Application\ServerTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Servers\GetExternalServerRequest; use App\Http\Requests\Api\Application\Servers\GetExternalServerRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server', weight: 1)]
class ExternalServerController extends ApplicationApiController class ExternalServerController extends ApplicationApiController
{ {
/** /**
* View server (external id)
*
* Retrieve a specific server from the database using its external ID. * Retrieve a specific server from the database using its external ID.
*/ */
public function index(GetExternalServerRequest $request, string $external_id): array public function index(GetExternalServerRequest $request, string $external_id): array

View File

@ -14,7 +14,9 @@ use App\Http\Requests\Api\Application\Servers\GetServersRequest;
use App\Http\Requests\Api\Application\Servers\ServerWriteRequest; use App\Http\Requests\Api\Application\Servers\ServerWriteRequest;
use App\Http\Requests\Api\Application\Servers\StoreServerRequest; use App\Http\Requests\Api\Application\Servers\StoreServerRequest;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server', weight: 0)]
class ServerController extends ApplicationApiController class ServerController extends ApplicationApiController
{ {
/** /**
@ -28,6 +30,8 @@ class ServerController extends ApplicationApiController
} }
/** /**
* List servers
*
* Return all the servers that currently exist on the Panel. * Return all the servers that currently exist on the Panel.
*/ */
public function index(GetServersRequest $request): array public function index(GetServersRequest $request): array
@ -43,6 +47,8 @@ class ServerController extends ApplicationApiController
} }
/** /**
* Create server
*
* Create a new server on the system. * Create a new server on the system.
* *
* @throws \Throwable * @throws \Throwable
@ -61,6 +67,8 @@ class ServerController extends ApplicationApiController
} }
/** /**
* View server
*
* Show a single server transformed for the application API. * Show a single server transformed for the application API.
*/ */
public function view(GetServerRequest $request, Server $server): array public function view(GetServerRequest $request, Server $server): array
@ -71,6 +79,8 @@ class ServerController extends ApplicationApiController
} }
/** /**
* Delete server
*
* Deletes a server. * Deletes a server.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException

View File

@ -9,7 +9,9 @@ use App\Transformers\Api\Application\ServerTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest; use App\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest;
use App\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest; use App\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server', weight: 2)]
class ServerDetailsController extends ApplicationApiController class ServerDetailsController extends ApplicationApiController
{ {
/** /**
@ -23,6 +25,8 @@ class ServerDetailsController extends ApplicationApiController
} }
/** /**
* Update details
*
* Update the details for a specific server. * Update the details for a specific server.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -41,6 +45,8 @@ class ServerDetailsController extends ApplicationApiController
} }
/** /**
* Update build
*
* Update the build details for a specific server. * Update the build details for a specific server.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException

View File

@ -10,9 +10,11 @@ use App\Repositories\Daemon\DaemonServerRepository;
use App\Services\Servers\ReinstallServerService; use App\Services\Servers\ReinstallServerService;
use App\Services\Servers\SuspensionService; use App\Services\Servers\SuspensionService;
use App\Services\Servers\TransferServerService; use App\Services\Servers\TransferServerService;
use Dedoc\Scramble\Attributes\Group;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Response; use Illuminate\Http\Response;
#[Group('Server', weight: 4)]
class ServerManagementController extends ApplicationApiController class ServerManagementController extends ApplicationApiController
{ {
/** /**
@ -28,6 +30,8 @@ class ServerManagementController extends ApplicationApiController
} }
/** /**
* Suspsend
*
* Suspend a server on the Panel. * Suspend a server on the Panel.
* *
* @throws \Throwable * @throws \Throwable
@ -40,6 +44,8 @@ class ServerManagementController extends ApplicationApiController
} }
/** /**
* Unsuspsend
*
* Unsuspend a server on the Panel. * Unsuspend a server on the Panel.
* *
* @throws \Throwable * @throws \Throwable
@ -52,6 +58,8 @@ class ServerManagementController extends ApplicationApiController
} }
/** /**
* Reinstall
*
* Mark a server as needing to be reinstalled. * Mark a server as needing to be reinstalled.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -65,6 +73,8 @@ class ServerManagementController extends ApplicationApiController
} }
/** /**
* Start transfer
*
* Starts a transfer of a server to a new node. * Starts a transfer of a server to a new node.
*/ */
public function startTransfer(ServerWriteRequest $request, Server $server): Response public function startTransfer(ServerWriteRequest $request, Server $server): Response
@ -85,6 +95,8 @@ class ServerManagementController extends ApplicationApiController
} }
/** /**
* Cancel transfer
*
* Cancels a transfer of a server to a new node. * Cancels a transfer of a server to a new node.
* *
* @throws ConnectionException * @throws ConnectionException

View File

@ -9,9 +9,11 @@ use App\Services\Servers\StartupModificationService;
use App\Transformers\Api\Application\ServerTransformer; use App\Transformers\Api\Application\ServerTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest; use App\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest;
use Dedoc\Scramble\Attributes\Group;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
#[Group('Server', weight: 3)]
class StartupController extends ApplicationApiController class StartupController extends ApplicationApiController
{ {
/** /**
@ -23,6 +25,8 @@ class StartupController extends ApplicationApiController
} }
/** /**
* Update startup
*
* Update the startup and environment settings for a specific server. * Update the startup and environment settings for a specific server.
* *
* @throws ValidationException * @throws ValidationException

View File

@ -6,10 +6,14 @@ use App\Models\User;
use App\Transformers\Api\Application\UserTransformer; use App\Transformers\Api\Application\UserTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Users\GetExternalUserRequest; use App\Http\Requests\Api\Application\Users\GetExternalUserRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('User', weight: 1)]
class ExternalUserController extends ApplicationApiController class ExternalUserController extends ApplicationApiController
{ {
/** /**
* View user (external id)
*
* Retrieve a specific user from the database using their external ID. * Retrieve a specific user from the database using their external ID.
*/ */
public function index(GetExternalUserRequest $request, string $external_id): array public function index(GetExternalUserRequest $request, string $external_id): array

View File

@ -15,7 +15,9 @@ use App\Http\Requests\Api\Application\Users\UpdateUserRequest;
use App\Http\Controllers\Api\Application\ApplicationApiController; use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Users\AssignUserRolesRequest; use App\Http\Requests\Api\Application\Users\AssignUserRolesRequest;
use App\Models\Role; use App\Models\Role;
use Dedoc\Scramble\Attributes\Group;
#[Group('User', weight: 0)]
class UserController extends ApplicationApiController class UserController extends ApplicationApiController
{ {
/** /**
@ -29,6 +31,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* List users
*
* Handle request to list all users on the panel. Returns a JSON-API representation * Handle request to list all users on the panel. Returns a JSON-API representation
* of a collection of users including any defined relations passed in * of a collection of users including any defined relations passed in
* the request. * the request.
@ -46,6 +50,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* View user
*
* Handle a request to view a single user. Includes any relations that * Handle a request to view a single user. Includes any relations that
* were defined in the request. * were defined in the request.
*/ */
@ -57,6 +63,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* Update user
*
* Update an existing user on the system and return the response. Returns the * Update an existing user on the system and return the response. Returns the
* updated user model response on success. Supports handling of token revocation * updated user model response on success. Supports handling of token revocation
* errors when switching a user from an admin to a normal user. * errors when switching a user from an admin to a normal user.
@ -78,6 +86,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* Assign role to user
*
* Assign roles to a user. * Assign roles to a user.
*/ */
public function assignRoles(AssignUserRolesRequest $request, User $user): array public function assignRoles(AssignUserRolesRequest $request, User $user): array
@ -97,6 +107,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* Unassign role from user
*
* Removes roles from a user. * Removes roles from a user.
*/ */
public function removeRoles(AssignUserRolesRequest $request, User $user): array public function removeRoles(AssignUserRolesRequest $request, User $user): array
@ -116,6 +128,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* Create user
*
* Store a new user on the system. Returns the created user and an HTTP/201 * Store a new user on the system. Returns the created user and an HTTP/201
* header on successful creation. * header on successful creation.
* *
@ -137,6 +151,8 @@ class UserController extends ApplicationApiController
} }
/** /**
* Delete user
*
* Handle a request to delete a user from the Panel. Returns a HTTP/204 response on successful deletion. * Handle a request to delete a user from the Panel. Returns a HTTP/204 response on successful deletion.
*/ */
public function delete(DeleteUserRequest $request, User $user): JsonResponse public function delete(DeleteUserRequest $request, User $user): JsonResponse

View File

@ -23,6 +23,9 @@ class AccountController extends ClientApiController
parent::__construct(); parent::__construct();
} }
/**
* View account
*/
public function index(Request $request): array public function index(Request $request): array
{ {
return $this->fractal->item($request->user()) return $this->fractal->item($request->user())
@ -31,6 +34,8 @@ class AccountController extends ClientApiController
} }
/** /**
* Update email
*
* Update the authenticated user's email address. * Update the authenticated user's email address.
*/ */
public function updateEmail(UpdateEmailRequest $request): JsonResponse public function updateEmail(UpdateEmailRequest $request): JsonResponse
@ -48,6 +53,8 @@ class AccountController extends ClientApiController
} }
/** /**
* Update password
*
* Update the authenticated user's password. All existing sessions will be logged * Update the authenticated user's password. All existing sessions will be logged
* out immediately. * out immediately.
* *

View File

@ -11,6 +11,8 @@ use App\Transformers\Api\Client\ActivityLogTransformer;
class ActivityLogController extends ClientApiController class ActivityLogController extends ClientApiController
{ {
/** /**
* List activity logs
*
* Returns a paginated set of the user's activity logs. * Returns a paginated set of the user's activity logs.
*/ */
public function __invoke(ClientApiRequest $request): array public function __invoke(ClientApiRequest $request): array

View File

@ -13,6 +13,8 @@ use App\Http\Requests\Api\Client\Account\StoreApiKeyRequest;
class ApiKeyController extends ClientApiController class ApiKeyController extends ClientApiController
{ {
/** /**
* List api keys
*
* Returns all the API keys that exist for the given client. * Returns all the API keys that exist for the given client.
*/ */
public function index(ClientApiRequest $request): array public function index(ClientApiRequest $request): array
@ -23,6 +25,8 @@ class ApiKeyController extends ClientApiController
} }
/** /**
* Create api key
*
* Store a new API key for a user's account. * Store a new API key for a user's account.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -50,6 +54,8 @@ class ApiKeyController extends ClientApiController
} }
/** /**
* Delete api key
*
* Deletes a given API key. * Deletes a given API key.
*/ */
public function delete(ClientApiRequest $request, string $identifier): JsonResponse public function delete(ClientApiRequest $request, string $identifier): JsonResponse

View File

@ -9,7 +9,9 @@ use Spatie\QueryBuilder\AllowedFilter;
use App\Models\Filters\MultiFieldServerFilter; use App\Models\Filters\MultiFieldServerFilter;
use App\Transformers\Api\Client\ServerTransformer; use App\Transformers\Api\Client\ServerTransformer;
use App\Http\Requests\Api\Client\GetServersRequest; use App\Http\Requests\Api\Client\GetServersRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Base')]
class ClientController extends ClientApiController class ClientController extends ClientApiController
{ {
/** /**
@ -21,6 +23,8 @@ class ClientController extends ClientApiController
} }
/** /**
* List servers
*
* Return all the servers available to the client making the API * Return all the servers available to the client making the API
* request, including servers the user has access to as a subuser. * request, including servers the user has access to as a subuser.
*/ */
@ -67,6 +71,8 @@ class ClientController extends ClientApiController
} }
/** /**
* List subuser permissions
*
* Returns all the subuser permissions available on the system. * Returns all the subuser permissions available on the system.
*/ */
public function permissions(): array public function permissions(): array

View File

@ -11,6 +11,8 @@ use App\Http\Requests\Api\Client\Account\StoreSSHKeyRequest;
class SSHKeyController extends ClientApiController class SSHKeyController extends ClientApiController
{ {
/** /**
* List ssh keys
*
* Returns all the SSH keys that have been configured for the logged-in * Returns all the SSH keys that have been configured for the logged-in
* user account. * user account.
*/ */
@ -22,6 +24,8 @@ class SSHKeyController extends ClientApiController
} }
/** /**
* Create ssh keys
*
* Stores a new SSH key for the authenticated user's account. * Stores a new SSH key for the authenticated user's account.
*/ */
public function store(StoreSSHKeyRequest $request): array public function store(StoreSSHKeyRequest $request): array
@ -43,6 +47,8 @@ class SSHKeyController extends ClientApiController
} }
/** /**
* Delete ssh keys
*
* Deletes an SSH key from the user's account. * Deletes an SSH key from the user's account.
*/ */
public function delete(ClientApiRequest $request): JsonResponse public function delete(ClientApiRequest $request): JsonResponse

View File

@ -14,10 +14,14 @@ use App\Http\Requests\Api\Client\ClientApiRequest;
use App\Transformers\Api\Client\ActivityLogTransformer; use App\Transformers\Api\Client\ActivityLogTransformer;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Models\Role; use App\Models\Role;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Activity log')]
class ActivityLogController extends ClientApiController class ActivityLogController extends ClientApiController
{ {
/** /**
* List activity logs
*
* Returns the activity logs for a server. * Returns the activity logs for a server.
*/ */
public function __invoke(ClientApiRequest $request, Server $server): array public function __invoke(ClientApiRequest $request, Server $server): array

View File

@ -19,7 +19,9 @@ use App\Http\Controllers\Api\Client\ClientApiController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use App\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest; use App\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
use App\Http\Requests\Api\Client\Servers\Backups\RestoreBackupRequest; use App\Http\Requests\Api\Client\Servers\Backups\RestoreBackupRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Backup')]
class BackupController extends ClientApiController class BackupController extends ClientApiController
{ {
public function __construct( public function __construct(
@ -32,6 +34,8 @@ class BackupController extends ClientApiController
} }
/** /**
* List backups
*
* Returns all the backups for a given server instance in a paginated * Returns all the backups for a given server instance in a paginated
* result set. * result set.
* *
@ -54,6 +58,8 @@ class BackupController extends ClientApiController
} }
/** /**
* Create backup
*
* Starts the backup process for a server. * Starts the backup process for a server.
* *
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation * @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
@ -86,6 +92,8 @@ class BackupController extends ClientApiController
} }
/** /**
* Toggle lock
*
* Toggles the lock status of a given backup for a server. * Toggles the lock status of a given backup for a server.
* *
* @throws \Throwable * @throws \Throwable
@ -109,6 +117,8 @@ class BackupController extends ClientApiController
} }
/** /**
* View backup
*
* Returns information about a single backup. * Returns information about a single backup.
* *
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
@ -125,6 +135,8 @@ class BackupController extends ClientApiController
} }
/** /**
* Delete backup
*
* Deletes a backup from the panel as well as the remote source where it is currently * Deletes a backup from the panel as well as the remote source where it is currently
* being stored. * being stored.
* *
@ -147,6 +159,8 @@ class BackupController extends ClientApiController
} }
/** /**
* Download backup
*
* Download the backup for a given server instance. For daemon local files, the file * Download the backup for a given server instance. For daemon local files, the file
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated * will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
* which the user is redirected to. * which the user is redirected to.
@ -175,6 +189,8 @@ class BackupController extends ClientApiController
} }
/** /**
* Restore backup
*
* Handles restoring a backup by making a request to the daemon instance telling it * Handles restoring a backup by making a request to the daemon instance telling it
* to begin the process of finding (or downloading) the backup and unpacking it * to begin the process of finding (or downloading) the backup and unpacking it
* over the server files. * over the server files.

View File

@ -9,12 +9,16 @@ use GuzzleHttp\Exception\BadResponseException;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\SendCommandRequest; use App\Http\Requests\Api\Client\Servers\SendCommandRequest;
use Dedoc\Scramble\Attributes\Group;
use Exception; use Exception;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
#[Group('Server', weight: 1)]
class CommandController extends ClientApiController class CommandController extends ClientApiController
{ {
/** /**
* Send command
*
* Send a command to a running server. * Send a command to a running server.
* *
* @throws ConnectionException * @throws ConnectionException

View File

@ -15,7 +15,9 @@ use App\Http\Requests\Api\Client\Servers\Databases\GetDatabasesRequest;
use App\Http\Requests\Api\Client\Servers\Databases\StoreDatabaseRequest; use App\Http\Requests\Api\Client\Servers\Databases\StoreDatabaseRequest;
use App\Http\Requests\Api\Client\Servers\Databases\DeleteDatabaseRequest; use App\Http\Requests\Api\Client\Servers\Databases\DeleteDatabaseRequest;
use App\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest; use App\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Database')]
class DatabaseController extends ClientApiController class DatabaseController extends ClientApiController
{ {
/** /**
@ -30,6 +32,8 @@ class DatabaseController extends ClientApiController
} }
/** /**
* List databases
*
* Return all the databases that belong to the given server. * Return all the databases that belong to the given server.
*/ */
public function index(GetDatabasesRequest $request, Server $server): array public function index(GetDatabasesRequest $request, Server $server): array
@ -40,6 +44,8 @@ class DatabaseController extends ClientApiController
} }
/** /**
* Create database
*
* Create a new database for the given server and return it. * Create a new database for the given server and return it.
* *
* @throws \Throwable * @throws \Throwable
@ -62,6 +68,8 @@ class DatabaseController extends ClientApiController
} }
/** /**
* Rotate password
*
* Rotates the password for the given server model and returns a fresh instance to * Rotates the password for the given server model and returns a fresh instance to
* the caller. * the caller.
* *
@ -84,6 +92,8 @@ class DatabaseController extends ClientApiController
} }
/** /**
* Delete database
*
* Removes a database from the server. * Removes a database from the server.
*/ */
public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response

View File

@ -22,8 +22,10 @@ use App\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest;
use App\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest; use App\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest;
use App\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest; use App\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest;
use App\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest; use App\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest;
use Dedoc\Scramble\Attributes\Group;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
#[Group('Server - File', weight: 0)]
class FileController extends ClientApiController class FileController extends ClientApiController
{ {
/** /**
@ -37,6 +39,8 @@ class FileController extends ClientApiController
} }
/** /**
* List files
*
* Returns a listing of files in a given directory. * Returns a listing of files in a given directory.
* *
* @throws ConnectionException * @throws ConnectionException
@ -53,6 +57,8 @@ class FileController extends ClientApiController
} }
/** /**
* View file
*
* Return the contents of a specified file for the user. * Return the contents of a specified file for the user.
* *
* @throws \Throwable * @throws \Throwable
@ -72,6 +78,8 @@ class FileController extends ClientApiController
} }
/** /**
* Download file
*
* Generates a one-time token with a link that the user can use to * Generates a one-time token with a link that the user can use to
* download a given file. * download a given file.
* *
@ -103,6 +111,8 @@ class FileController extends ClientApiController
} }
/** /**
* Write file
*
* Writes the contents of the specified file to the server. * Writes the contents of the specified file to the server.
* *
* @throws ConnectionException * @throws ConnectionException
@ -121,6 +131,8 @@ class FileController extends ClientApiController
} }
/** /**
* Create directory
*
* Creates a new folder on the server. * Creates a new folder on the server.
* *
* @throws \Throwable * @throws \Throwable
@ -140,6 +152,8 @@ class FileController extends ClientApiController
} }
/** /**
* Rename file
*
* Renames a file on the remote machine. * Renames a file on the remote machine.
* *
* @throws \Throwable * @throws \Throwable
@ -163,6 +177,8 @@ class FileController extends ClientApiController
} }
/** /**
* Copy file
*
* Copies a file on the server. * Copies a file on the server.
* *
* @throws ConnectionException * @throws ConnectionException
@ -181,6 +197,8 @@ class FileController extends ClientApiController
} }
/** /**
* Compress files
*
* @throws ConnectionException * @throws ConnectionException
*/ */
public function compress(CompressFilesRequest $request, Server $server): array public function compress(CompressFilesRequest $request, Server $server): array
@ -201,6 +219,8 @@ class FileController extends ClientApiController
} }
/** /**
* Decompress files
*
* @throws ConnectionException * @throws ConnectionException
*/ */
public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse
@ -221,6 +241,8 @@ class FileController extends ClientApiController
} }
/** /**
* Delete files/ folders
*
* Deletes files or folders for the server in the given root directory. * Deletes files or folders for the server in the given root directory.
* *
* @throws ConnectionException * @throws ConnectionException
@ -241,6 +263,8 @@ class FileController extends ClientApiController
} }
/** /**
* Update file permissions
*
* Updates file permissions for file(s) in the given root directory. * Updates file permissions for file(s) in the given root directory.
* *
* @throws ConnectionException * @throws ConnectionException
@ -256,6 +280,8 @@ class FileController extends ClientApiController
} }
/** /**
* Pull remote file
*
* Requests that a file be downloaded from a remote location by daemon. * Requests that a file be downloaded from a remote location by daemon.
* *
* @throws \Throwable * @throws \Throwable

View File

@ -9,7 +9,9 @@ use Illuminate\Http\JsonResponse;
use App\Services\Nodes\NodeJWTService; use App\Services\Nodes\NodeJWTService;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\Files\UploadFileRequest; use App\Http\Requests\Api\Client\Servers\Files\UploadFileRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - File', weight: 1)]
class FileUploadController extends ClientApiController class FileUploadController extends ClientApiController
{ {
/** /**
@ -22,6 +24,8 @@ class FileUploadController extends ClientApiController
} }
/** /**
* Get upload url
*
* Returns an url where files can be uploaded to. * Returns an url where files can be uploaded to.
*/ */
public function __invoke(UploadFileRequest $request, Server $server): JsonResponse public function __invoke(UploadFileRequest $request, Server $server): JsonResponse

View File

@ -15,7 +15,9 @@ use App\Http\Requests\Api\Client\Servers\Network\NewAllocationRequest;
use App\Http\Requests\Api\Client\Servers\Network\DeleteAllocationRequest; use App\Http\Requests\Api\Client\Servers\Network\DeleteAllocationRequest;
use App\Http\Requests\Api\Client\Servers\Network\UpdateAllocationRequest; use App\Http\Requests\Api\Client\Servers\Network\UpdateAllocationRequest;
use App\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationRequest; use App\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Allocation')]
class NetworkAllocationController extends ClientApiController class NetworkAllocationController extends ClientApiController
{ {
/** /**
@ -28,6 +30,8 @@ class NetworkAllocationController extends ClientApiController
} }
/** /**
* List allocations
*
* Lists all the allocations available to a server and whether * Lists all the allocations available to a server and whether
* they are currently assigned as the primary for this server. * they are currently assigned as the primary for this server.
*/ */
@ -39,6 +43,8 @@ class NetworkAllocationController extends ClientApiController
} }
/** /**
* Update allocation
*
* Set the primary allocation for a server. * Set the primary allocation for a server.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -62,6 +68,8 @@ class NetworkAllocationController extends ClientApiController
} }
/** /**
* Set primar<
*
* Set the primary allocation for a server. * Set the primary allocation for a server.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -82,8 +90,9 @@ class NetworkAllocationController extends ClientApiController
} }
/** /**
* Create allocation
*
* Set the notes for the allocation for a server. * Set the notes for the allocation for a server.
*s.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
*/ */
@ -106,6 +115,8 @@ class NetworkAllocationController extends ClientApiController
} }
/** /**
* Delete allocation
*
* Delete an allocation from a server. * Delete an allocation from a server.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException

View File

@ -8,7 +8,9 @@ use App\Facades\Activity;
use App\Repositories\Daemon\DaemonPowerRepository; use App\Repositories\Daemon\DaemonPowerRepository;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\SendPowerRequest; use App\Http\Requests\Api\Client\Servers\SendPowerRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server', weight: 2)]
class PowerController extends ClientApiController class PowerController extends ClientApiController
{ {
/** /**
@ -20,6 +22,8 @@ class PowerController extends ClientApiController
} }
/** /**
* Send power action
*
* Send a power action to a server. * Send a power action to a server.
*/ */
public function index(SendPowerRequest $request, Server $server): Response public function index(SendPowerRequest $request, Server $server): Response

View File

@ -9,8 +9,10 @@ use App\Transformers\Api\Client\StatsTransformer;
use App\Repositories\Daemon\DaemonServerRepository; use App\Repositories\Daemon\DaemonServerRepository;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\GetServerRequest; use App\Http\Requests\Api\Client\Servers\GetServerRequest;
use Dedoc\Scramble\Attributes\Group;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
#[Group('Server', weight: 3)]
class ResourceUtilizationController extends ClientApiController class ResourceUtilizationController extends ClientApiController
{ {
/** /**
@ -22,6 +24,8 @@ class ResourceUtilizationController extends ClientApiController
} }
/** /**
* View resources
*
* Return the current resource utilization for a server. This value is cached for up to * Return the current resource utilization for a server. This value is cached for up to
* 20 seconds at a time to ensure that repeated requests to this endpoint do not cause * 20 seconds at a time to ensure that repeated requests to this endpoint do not cause
* a flood of unnecessary API calls. * a flood of unnecessary API calls.

View File

@ -21,7 +21,9 @@ use App\Http\Requests\Api\Client\Servers\Schedules\StoreScheduleRequest;
use App\Http\Requests\Api\Client\Servers\Schedules\DeleteScheduleRequest; use App\Http\Requests\Api\Client\Servers\Schedules\DeleteScheduleRequest;
use App\Http\Requests\Api\Client\Servers\Schedules\UpdateScheduleRequest; use App\Http\Requests\Api\Client\Servers\Schedules\UpdateScheduleRequest;
use App\Http\Requests\Api\Client\Servers\Schedules\TriggerScheduleRequest; use App\Http\Requests\Api\Client\Servers\Schedules\TriggerScheduleRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Schedule', weight: 0)]
class ScheduleController extends ClientApiController class ScheduleController extends ClientApiController
{ {
/** /**
@ -33,6 +35,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* List schedules
*
* Returns all the schedules belonging to a given server. * Returns all the schedules belonging to a given server.
*/ */
public function index(ViewScheduleRequest $request, Server $server): array public function index(ViewScheduleRequest $request, Server $server): array
@ -45,6 +49,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* Create schedule
*
* Store a new schedule for a server. * Store a new schedule for a server.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -77,6 +83,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* View schedule
*
* Returns a specific schedule for the server. * Returns a specific schedule for the server.
*/ */
public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule): array public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule): array
@ -93,6 +101,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* Update schedule
*
* Updates a given schedule with the new data provided. * Updates a given schedule with the new data provided.
* *
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -133,6 +143,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* Run schedule
*
* Executes a given schedule immediately rather than waiting on it's normally scheduled time * Executes a given schedule immediately rather than waiting on it's normally scheduled time
* to pass. This does not care about the schedule state. * to pass. This does not care about the schedule state.
* *
@ -148,6 +160,8 @@ class ScheduleController extends ClientApiController
} }
/** /**
* Delete schedule
*
* Deletes a schedule and it's associated tasks. * Deletes a schedule and it's associated tasks.
*/ */
public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse

View File

@ -17,7 +17,9 @@ use App\Http\Controllers\Api\Client\ClientApiController;
use App\Exceptions\Service\ServiceLimitExceededException; use App\Exceptions\Service\ServiceLimitExceededException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use App\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest; use App\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Schedule', weight: 1)]
class ScheduleTaskController extends ClientApiController class ScheduleTaskController extends ClientApiController
{ {
/** /**
@ -30,6 +32,8 @@ class ScheduleTaskController extends ClientApiController
} }
/** /**
* Create task
*
* Create a new task for a given schedule and store it in the database. * Create a new task for a given schedule and store it in the database.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -91,6 +95,8 @@ class ScheduleTaskController extends ClientApiController
} }
/** /**
* Update task
*
* Updates a given task for a server. * Updates a given task for a server.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -145,6 +151,8 @@ class ScheduleTaskController extends ClientApiController
} }
/** /**
* Delete task
*
* Delete a given task for a schedule. If there are subsequent tasks stored in the database * Delete a given task for a schedule. If there are subsequent tasks stored in the database
* for this schedule their sequence IDs are decremented properly. * for this schedule their sequence IDs are decremented properly.
* *

View File

@ -7,7 +7,9 @@ use App\Transformers\Api\Client\ServerTransformer;
use App\Services\Servers\GetUserPermissionsService; use App\Services\Servers\GetUserPermissionsService;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\GetServerRequest; use App\Http\Requests\Api\Client\Servers\GetServerRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server', weight: 0)]
class ServerController extends ClientApiController class ServerController extends ClientApiController
{ {
/** /**
@ -19,6 +21,8 @@ class ServerController extends ClientApiController
} }
/** /**
* View server
*
* Transform an individual server into a response that can be consumed by a * Transform an individual server into a response that can be consumed by a
* client using the API. * client using the API.
*/ */

View File

@ -9,10 +9,12 @@ use App\Http\Requests\Api\Client\Servers\Settings\RenameServerRequest;
use App\Http\Requests\Api\Client\Servers\Settings\SetDockerImageRequest; use App\Http\Requests\Api\Client\Servers\Settings\SetDockerImageRequest;
use App\Models\Server; use App\Models\Server;
use App\Services\Servers\ReinstallServerService; use App\Services\Servers\ReinstallServerService;
use Dedoc\Scramble\Attributes\Group;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
#[Group('Server - Settings')]
class SettingsController extends ClientApiController class SettingsController extends ClientApiController
{ {
/** /**
@ -25,6 +27,8 @@ class SettingsController extends ClientApiController
} }
/** /**
* Rename
*
* Renames a server. * Renames a server.
*/ */
public function rename(RenameServerRequest $request, Server $server): JsonResponse public function rename(RenameServerRequest $request, Server $server): JsonResponse
@ -56,6 +60,8 @@ class SettingsController extends ClientApiController
} }
/** /**
* Reinstall
*
* Reinstalls the server on the daemon. * Reinstalls the server on the daemon.
* *
* @throws \Throwable * @throws \Throwable
@ -70,6 +76,8 @@ class SettingsController extends ClientApiController
} }
/** /**
* Change docker image
*
* Changes the Docker image in use by the server. * Changes the Docker image in use by the server.
* *
* @throws \Throwable * @throws \Throwable

View File

@ -11,7 +11,9 @@ use App\Http\Controllers\Api\Client\ClientApiController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use App\Http\Requests\Api\Client\Servers\Startup\GetStartupRequest; use App\Http\Requests\Api\Client\Servers\Startup\GetStartupRequest;
use App\Http\Requests\Api\Client\Servers\Startup\UpdateStartupVariableRequest; use App\Http\Requests\Api\Client\Servers\Startup\UpdateStartupVariableRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Startup')]
class StartupController extends ClientApiController class StartupController extends ClientApiController
{ {
/** /**
@ -24,6 +26,8 @@ class StartupController extends ClientApiController
} }
/** /**
* List startup variables
*
* Returns the startup information for the server including all the variables. * Returns the startup information for the server including all the variables.
*/ */
public function index(GetStartupRequest $request, Server $server): array public function index(GetStartupRequest $request, Server $server): array
@ -43,6 +47,8 @@ class StartupController extends ClientApiController
} }
/** /**
* Update startup variable
*
* Updates a single variable for a server. * Updates a single variable for a server.
* *
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException

View File

@ -17,7 +17,9 @@ use App\Http\Requests\Api\Client\Servers\Subusers\GetSubuserRequest;
use App\Http\Requests\Api\Client\Servers\Subusers\StoreSubuserRequest; use App\Http\Requests\Api\Client\Servers\Subusers\StoreSubuserRequest;
use App\Http\Requests\Api\Client\Servers\Subusers\DeleteSubuserRequest; use App\Http\Requests\Api\Client\Servers\Subusers\DeleteSubuserRequest;
use App\Http\Requests\Api\Client\Servers\Subusers\UpdateSubuserRequest; use App\Http\Requests\Api\Client\Servers\Subusers\UpdateSubuserRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Subuser')]
class SubuserController extends ClientApiController class SubuserController extends ClientApiController
{ {
/** /**
@ -32,6 +34,8 @@ class SubuserController extends ClientApiController
} }
/** /**
* List subusers
*
* Return the users associated with this server instance. * Return the users associated with this server instance.
*/ */
public function index(GetSubuserRequest $request, Server $server): array public function index(GetSubuserRequest $request, Server $server): array
@ -42,6 +46,8 @@ class SubuserController extends ClientApiController
} }
/** /**
* View subusers
*
* Returns a single subuser associated with this server instance. * Returns a single subuser associated with this server instance.
*/ */
public function view(GetSubuserRequest $request, Server $server, User $user): array public function view(GetSubuserRequest $request, Server $server, User $user): array
@ -54,6 +60,8 @@ class SubuserController extends ClientApiController
} }
/** /**
* Create subuser
*
* Create a new subuser for the given server. * Create a new subuser for the given server.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -80,6 +88,8 @@ class SubuserController extends ClientApiController
} }
/** /**
* Update subuser
*
* Update a given subuser in the system for the server. * Update a given subuser in the system for the server.
* *
* @throws \App\Exceptions\Model\DataValidationException * @throws \App\Exceptions\Model\DataValidationException
@ -97,6 +107,8 @@ class SubuserController extends ClientApiController
} }
/** /**
* Delete subuser
*
* Removes a subusers from a server's assignment. * Removes a subusers from a server's assignment.
*/ */
public function delete(DeleteSubuserRequest $request, Server $server, User $user): JsonResponse public function delete(DeleteSubuserRequest $request, Server $server, User $user): JsonResponse

View File

@ -11,7 +11,9 @@ use App\Exceptions\Http\HttpForbiddenException;
use App\Http\Requests\Api\Client\ClientApiRequest; use App\Http\Requests\Api\Client\ClientApiRequest;
use App\Services\Servers\GetUserPermissionsService; use App\Services\Servers\GetUserPermissionsService;
use App\Http\Controllers\Api\Client\ClientApiController; use App\Http\Controllers\Api\Client\ClientApiController;
use Dedoc\Scramble\Attributes\Group;
#[Group('Server - Websocket')]
class WebsocketController extends ClientApiController class WebsocketController extends ClientApiController
{ {
/** /**
@ -25,6 +27,8 @@ class WebsocketController extends ClientApiController
} }
/** /**
* Get websocket token
*
* Generates a one-time token that is sent along in every websocket call to the Daemon. * Generates a one-time token that is sent along in every websocket call to the Daemon.
* This is a signed JWT that the Daemon then uses to verify the user's identity, and * This is a signed JWT that the Daemon then uses to verify the user's identity, and
* allows us to continually renew this token and avoid users maintaining sessions wrongly, * allows us to continually renew this token and avoid users maintaining sessions wrongly,

View File

@ -26,6 +26,8 @@ class TwoFactorController extends ClientApiController
} }
/** /**
* Setup 2fa
*
* Returns two-factor token credentials that allow a user to configure * Returns two-factor token credentials that allow a user to configure
* it on their account. If two-factor is already enabled this endpoint * it on their account. If two-factor is already enabled this endpoint
* will return a 400 error. * will return a 400 error.
@ -44,6 +46,8 @@ class TwoFactorController extends ClientApiController
} }
/** /**
* Enable 2fa
*
* Updates a user's account to have two-factor enabled. * Updates a user's account to have two-factor enabled.
* *
* @throws \Throwable * @throws \Throwable
@ -74,6 +78,8 @@ class TwoFactorController extends ClientApiController
} }
/** /**
* Disable 2fa
*
* Disables two-factor authentication on an account if the password provided * Disables two-factor authentication on an account if the password provided
* is valid. * is valid.
* *

View File

@ -79,11 +79,11 @@ class AppServiceProvider extends ServiceProvider
Sanctum::usePersonalAccessTokenModel(ApiKey::class); Sanctum::usePersonalAccessTokenModel(ApiKey::class);
$bearerTokens = fn (OpenApi $openApi) => $openApi->secure(SecurityScheme::http('bearer'));
Gate::define('viewApiDocs', fn () => true); Gate::define('viewApiDocs', fn () => true);
Scramble::registerApi('application', ['api_path' => 'api/application', 'info' => ['version' => '1.0']]);
$bearerTokens = fn (OpenApi $openApi) => $openApi->secure(SecurityScheme::http('bearer'));
Scramble::registerApi('application', ['api_path' => 'api/application', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens);
Scramble::registerApi('client', ['api_path' => 'api/client', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens); Scramble::registerApi('client', ['api_path' => 'api/client', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens);
Scramble::registerApi('remote', ['api_path' => 'api/remote', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens);
// Default OAuth providers included with Socialite // Default OAuth providers included with Socialite
CommonProvider::register($app, 'facebook', null, 'tabler-brand-facebook-f', '#1877f2'); CommonProvider::register($app, 'facebook', null, 'tabler-brand-facebook-f', '#1877f2');
@ -164,7 +164,6 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function register(): void public function register(): void
{ {
Scramble::extendOpenApi(fn (OpenApi $openApi) => $openApi->secure(SecurityScheme::http('bearer')));
Scramble::ignoreDefaultRoutes(); Scramble::ignoreDefaultRoutes();
} }
} }

View File

@ -13,7 +13,7 @@
"calebporzio/sushi": "^2.5", "calebporzio/sushi": "^2.5",
"chillerlan/php-qrcode": "^5.0.2", "chillerlan/php-qrcode": "^5.0.2",
"coderflex/filament-turnstile": "^2.2", "coderflex/filament-turnstile": "^2.2",
"dedoc/scramble": "^0.10.0", "dedoc/scramble": "^0.12.10",
"doctrine/dbal": "~3.6.0", "doctrine/dbal": "~3.6.0",
"filament/filament": "^3.2", "filament/filament": "^3.2",
"guzzlehttp/guzzle": "^7.8.1", "guzzlehttp/guzzle": "^7.8.1",

28
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d19bcea154a71f70e16c50cf517db560", "content-hash": "bb85f026a4ef019989d0cf14be8dc8d9",
"packages": [ "packages": [
{ {
"name": "abdelhamiderrahmouni/filament-monaco-editor", "name": "abdelhamiderrahmouni/filament-monaco-editor",
@ -1057,32 +1057,34 @@
}, },
{ {
"name": "dedoc/scramble", "name": "dedoc/scramble",
"version": "v0.10.13", "version": "v0.12.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dedoc/scramble.git", "url": "https://github.com/dedoc/scramble.git",
"reference": "d8c3ed9c69fe6c0900f22ec0c7520b9b579d9ec3" "reference": "996dc8db3e09e7f893d4883dfdfa8f2839fee531"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dedoc/scramble/zipball/d8c3ed9c69fe6c0900f22ec0c7520b9b579d9ec3", "url": "https://api.github.com/repos/dedoc/scramble/zipball/996dc8db3e09e7f893d4883dfdfa8f2839fee531",
"reference": "d8c3ed9c69fe6c0900f22ec0c7520b9b579d9ec3", "reference": "996dc8db3e09e7f893d4883dfdfa8f2839fee531",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/contracts": "^10.0|^11.0", "illuminate/contracts": "^10.0|^11.0|^12.0",
"myclabs/deep-copy": "^1.12",
"nikic/php-parser": "^5.0", "nikic/php-parser": "^5.0",
"php": "^8.1", "php": "^8.1",
"phpstan/phpdoc-parser": "^1.0", "phpstan/phpdoc-parser": "^1.0|^2.0",
"spatie/laravel-package-tools": "^1.9.2" "spatie/laravel-package-tools": "^1.9.2"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "^v1.1.0", "laravel/pint": "^v1.1.0",
"nunomaduro/collision": "^7.0|^8.0", "nunomaduro/collision": "^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0", "orchestra/testbench": "^8.0|^9.0|^10.0",
"pestphp/pest": "^2.34", "pestphp/pest": "^2.34|^3.7",
"pestphp/pest-plugin-laravel": "^2.3", "pestphp/pest-plugin-laravel": "^2.3|^3.1",
"phpunit/phpunit": "^10.5", "phpunit/phpunit": "^10.5|^11.5.3",
"spatie/laravel-permission": "^6.10",
"spatie/pest-plugin-snapshots": "^2.1" "spatie/pest-plugin-snapshots": "^2.1"
}, },
"type": "library", "type": "library",
@ -1119,7 +1121,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/dedoc/scramble/issues", "issues": "https://github.com/dedoc/scramble/issues",
"source": "https://github.com/dedoc/scramble/tree/v0.10.13" "source": "https://github.com/dedoc/scramble/tree/v0.12.10"
}, },
"funding": [ "funding": [
{ {
@ -1127,7 +1129,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-06-05T17:01:46+00:00" "time": "2025-02-24T20:12:29+00:00"
}, },
{ {
"name": "dflydev/dot-access-data", "name": "dflydev/dot-access-data",

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Documentation</title>
@vite('resources/css/app.css')
</head>
<body class="bg-gray-100 min-h-screen flex items-center justify-center">
<div class="bg-white shadow-lg rounded-lg py-8 px-8 max-w-md w-full text-center">
<h2 class="text-xl font-bold text-gray-800 mb-4">API Documentation</h2>
<div class="mb-2">
<a href="/docs/api/application" class="inline-flex items-center">
<span class="mr-2">📘</span> <span style="color: #2563EB;">Application API</span>
</a>
</div>
<div class="mb-4">
<a href="/docs/api/client" class="inline-flex items-center">
<span class="mr-2">📗</span> <span style="color: #10B981;">Client API</span>
</a>
</div>
<div class="text-sm mt-4 flex items-center justify-center">
<span class="text-yellow-500 mr-2">⚠️</span>
<span style="color: #EF4444;">Note: You need to be logged in to view the API docs!</span>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,72 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{ $config->get('ui.title', config('app.name') . ' - API Docs') }}</title>
<script src="https://unpkg.com/@stoplight/elements@8.3.4/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements@8.3.4/styles.min.css">
<script>
const theme = localStorage.getItem('theme') === 'system'
? (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
: localStorage.getItem('theme') ?? 'dark';
document.documentElement.setAttribute('data-theme', theme);
const originalFetch = window.fetch;
// intercept TryIt requests and add the XSRF-TOKEN header,
// which is necessary for Sanctum cookie-based authentication to work correctly
window.fetch = (url, options) => {
const CSRF_TOKEN_COOKIE_KEY = "XSRF-TOKEN";
const CSRF_TOKEN_HEADER_KEY = "X-XSRF-TOKEN";
const getCookieValue = (key) => {
const cookie = document.cookie.split(';').find((cookie) => cookie.trim().startsWith(key));
return cookie?.split("=")[1];
};
const updateFetchHeaders = (
headers,
headerKey,
headerValue,
) => {
if (headers instanceof Headers) {
headers.set(headerKey, headerValue);
} else if (Array.isArray(headers)) {
headers.push([headerKey, headerValue]);
} else if (headers) {
headers[headerKey] = headerValue;
}
};
const csrfToken = getCookieValue(CSRF_TOKEN_COOKIE_KEY);
if (csrfToken) {
const { headers = new Headers() } = options || {};
updateFetchHeaders(headers, CSRF_TOKEN_HEADER_KEY, decodeURIComponent(csrfToken));
return originalFetch(url, {
...options,
headers,
});
}
return originalFetch(url, options);
};
</script>
</head>
<body style="height: 100vh; overflow-y: hidden">
<elements-api
id="docs"
tryItCredentialsPolicy="{{ $config->get('ui.try_it_credentials_policy', 'include') }}"
router="hash"
@if($config->get('ui.hide_try_it')) hideTryIt="true" @endif
logo="{{ $config->get('ui.logo') }}"
/>
<script>
(async () => {
const docs = document.getElementById('docs');
docs.apiDescriptionDocument = @json($spec);
})();
</script>
</body>
</html>

View File

@ -10,12 +10,5 @@ Route::group(['prefix' => 'api'], function () {
Scramble::registerUiRoute(path: 'client', api: 'client'); Scramble::registerUiRoute(path: 'client', api: 'client');
Scramble::registerJsonSpecificationRoute(path: 'client.json', api: 'client'); Scramble::registerJsonSpecificationRoute(path: 'client.json', api: 'client');
Scramble::registerUiRoute(path: 'remote', api: 'remote'); Route::view('', 'docs.api-index');
Scramble::registerJsonSpecificationRoute(path: 'remote.json', api: 'remote');
Route::get('', fn () => '
<li><a href="/docs/api/application">Application API for Admins</a></li>
<li><a href="/docs/api/client">Client API for Users</a></li>
<li><a href="/docs/api/remote">Daemon API for Wings</a></li>
');
}); });