Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from AzuraCast:main #123

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/src/Controller/Api/Admin/ApiKeysController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path: '/admin/api-keys',
operationId: 'adminListApiKeys',
description: 'List all current API keys across the system.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand All @@ -41,7 +41,7 @@
path: '/admin/api-key/{id}',
operationId: 'adminDeleteApiKey',
description: 'Delete a single API key.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'id',
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/AuditLogAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
path: '/admin/auditlog',
operationId: 'getAuditlog',
description: 'Return a list of all available permissions.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
56 changes: 39 additions & 17 deletions backend/src/Controller/Api/Admin/Backups/GetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,40 @@
namespace App\Controller\Api\Admin\Backups;

use App\Controller\SingleActionInterface;
use App\Entity\Api\Admin\Backup;
use App\Entity\Enums\StorageLocationTypes;
use App\Entity\Repository\StorageLocationRepository;
use App\Flysystem\Attributes\FileAttributes;
use App\Http\Response;
use App\Http\ServerRequest;
use App\OpenApi;
use App\Paginator;
use League\Flysystem\StorageAttributes;
use OpenApi\Attributes as OA;
use Psr\Http\Message\ResponseInterface;

/*
* TODO API
*/
#[
OA\Get(
path: '/admin/backups',
operationId: 'getBackups',
description: 'Return a list of all current backups.',
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
description: 'Success',
content: new OA\JsonContent(
type: 'array',
items: new OA\Items(
ref: Backup::class
)
)
),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
new OA\Response(ref: OpenApi::REF_RESPONSE_GENERIC_ERROR, response: 500),
]
)
]
final class GetAction implements SingleActionInterface
{
public function __construct(
Expand Down Expand Up @@ -49,34 +71,34 @@ public function __invoke(

$pathEncoded = base64_encode($storageLocation->getId() . '|' . $filename);

$backups[] = [
'path' => $filename,
'basename' => basename($filename),
'pathEncoded' => $pathEncoded,
'timestamp' => $file->lastModified(),
'size' => $file->fileSize(),
'storageLocationId' => $storageLocation->getId(),
];
$backups[] = new Backup(
$filename,
basename($filename),
$pathEncoded,
$file->lastModified() ?? 0,
$file->fileSize(),
$storageLocation->getIdRequired()
);
}
}

uasort(
$backups,
static function ($a, $b) {
return $b['timestamp'] <=> $a['timestamp'];
static function (Backup $a, Backup $b) {
return $b->timestamp <=> $a->timestamp;
}
);

$paginator = Paginator::fromArray($backups, $request);
$paginator->setPostprocessor(function ($row) use ($router) {
$row['links'] = [
$paginator->setPostprocessor(function (Backup $row) use ($router) {
$row->links = [
'download' => $router->fromHere(
'api:admin:backups:download',
['path' => $row['pathEncoded']]
['path' => $row->pathEncoded]
),
'delete' => $router->fromHere(
'api:admin:backups:delete',
['path' => $row['pathEncoded']]
['path' => $row->pathEncoded]
),
];
return $row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path: '/admin/custom_assets/{type}',
operationId: 'deleteAdminCustomAsset',
description: 'Removes the custom asset of the specified type.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'type',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path: '/admin/custom_assets/{type}',
operationId: 'getAdminCustomAsset',
description: 'Get the details of the custom asset of the specified type.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'type',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
operationId: 'postAdminCustomAsset',
description: 'Upload a new custom asset of the specified type.',
requestBody: new OA\RequestBody(ref: OpenApi::REF_REQUEST_BODY_FLOW_FILE_UPLOAD),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'type',
Expand Down
10 changes: 5 additions & 5 deletions backend/src/Controller/Api/Admin/CustomFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
path: '/admin/custom_fields',
operationId: 'getCustomFields',
description: 'List all current custom fields in the system.',
tags: ['Administration: Custom Fields'],
tags: [OpenApi::TAG_ADMIN_CUSTOM_FIELDS],
responses: [
new OA\Response(
response: 200,
Expand All @@ -42,7 +42,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: CustomField::class)
),
tags: ['Administration: Custom Fields'],
tags: [OpenApi::TAG_ADMIN_CUSTOM_FIELDS],
responses: [
new OA\Response(
response: 200,
Expand All @@ -62,7 +62,7 @@
path: '/admin/custom_field/{id}',
operationId: 'getCustomField',
description: 'Retrieve details for a single custom field.',
tags: ['Administration: Custom Fields'],
tags: [OpenApi::TAG_ADMIN_CUSTOM_FIELDS],
parameters: [
new OA\Parameter(
name: 'id',
Expand Down Expand Up @@ -95,7 +95,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: CustomField::class)
),
tags: ['Administration: Custom Fields'],
tags: [OpenApi::TAG_ADMIN_CUSTOM_FIELDS],
parameters: [
new OA\Parameter(
name: 'id',
Expand All @@ -116,7 +116,7 @@
path: '/admin/custom_field/{id}',
operationId: 'deleteCustomField',
description: 'Delete a single custom field.',
tags: ['Administration: Custom Fields'],
tags: [OpenApi::TAG_ADMIN_CUSTOM_FIELDS],
parameters: [
new OA\Parameter(
name: 'id',
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/GeoLite/GetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path: '/admin/geolite',
operationId: 'getGeoLite',
description: 'Get the current MaxMindDB GeoLite Database status.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/GeoLite/PostAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]
)
),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/Controller/Api/Admin/LogsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
path: '/admin/logs',
operationId: 'adminListLogs',
description: 'List all available log types for viewing.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand All @@ -39,7 +39,7 @@
path: '/admin/log/{key}',
operationId: 'adminViewLog',
description: 'View a specific log contents.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'key',
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/PermissionsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
path: '/admin/permissions',
operationId: 'getPermissions',
description: 'Return a list of all available permissions.',
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
responses: [
new OA\Response(
response: 200,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/RelaysAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
path: '/admin/relays/list',
operationId: 'adminGetRelays',
description: 'Return a list of all currently active AzuraRelay instances.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
10 changes: 5 additions & 5 deletions backend/src/Controller/Api/Admin/RolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
path: '/admin/roles',
operationId: 'getRoles',
description: 'List all current roles in the system.',
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
responses: [
new OA\Response(
response: 200,
Expand All @@ -51,7 +51,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: ApiRole::class)
),
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
responses: [
new OA\Response(
response: 200,
Expand All @@ -68,7 +68,7 @@
path: '/admin/role/{id}',
operationId: 'getRole',
description: 'Retrieve details for a single current role.',
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
parameters: [
new OA\Parameter(
name: 'id',
Expand Down Expand Up @@ -98,7 +98,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: ApiRole::class)
),
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
parameters: [
new OA\Parameter(
name: 'id',
Expand All @@ -119,7 +119,7 @@
path: '/admin/role/{id}',
operationId: 'deleteRole',
description: 'Delete a single role.',
tags: ['Administration: Roles'],
tags: [OpenApi::TAG_ADMIN_ROLES],
parameters: [
new OA\Parameter(
name: 'id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
path: '/admin/rsas/license',
operationId: 'deleteRsasLicense',
description: 'Removes the Rocket Streaming Audio Server (RSAS) license.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/Rsas/GetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
path: '/admin/rsas',
operationId: 'getRsas',
description: 'Get the current Rocket Streaming Audio Server (RSAS) status.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/Rsas/PostAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
operationId: 'postRsas',
description: 'Upload a new Rocket Streaming Audio Server (RSAS) binary.',
requestBody: new OA\RequestBody(ref: OpenApi::REF_REQUEST_BODY_FLOW_FILE_UPLOAD),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
operationId: 'postRsasLicense',
description: 'Upload a new Rocket Streaming Audio Server (RSAS) license key.',
requestBody: new OA\RequestBody(ref: OpenApi::REF_REQUEST_BODY_FLOW_FILE_UPLOAD),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/ServerStatsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
path: '/admin/server/stats',
operationId: 'getServerStats',
description: 'Return a list of all CPU usage stats.',
tags: ['Administration: CPU stats'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/Controller/Api/Admin/ServiceControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
path: '/admin/services',
operationId: 'getServiceDetails',
description: 'List the status of essential system services.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand All @@ -43,7 +43,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: CustomField::class)
),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
parameters: [
new OA\Parameter(
name: 'service',
Expand Down
4 changes: 2 additions & 2 deletions backend/src/Controller/Api/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
path: '/admin/settings',
operationId: 'getSettings',
description: 'List the current values of all editable system settings.',
tags: ['Administration: Settings'],
tags: [OpenApi::TAG_ADMIN_SETTINGS],
responses: [
new OA\Response(
response: 200,
Expand All @@ -41,7 +41,7 @@
requestBody: new OA\RequestBody(
content: new OA\JsonContent(ref: Settings::class)
),
tags: ['Administration: Settings'],
tags: [OpenApi::TAG_ADMIN_SETTINGS],
responses: [
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/Shoutcast/GetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
path: '/admin/shoutcast',
operationId: 'getShoutcast',
description: 'Get details about the Shoutcast installation.',
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(
response: 200,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Controller/Api/Admin/Shoutcast/PostAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
operationId: 'postShoutcast',
description: 'Upload a new Shoutcast binary.',
requestBody: new OA\RequestBody(ref: OpenApi::REF_REQUEST_BODY_FLOW_FILE_UPLOAD),
tags: ['Administration: General'],
tags: [OpenApi::TAG_ADMIN],
responses: [
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
Expand Down
Loading