diff --git a/backend/src/Controller/Api/Stations/Playlists/DeleteQueueAction.php b/backend/src/Controller/Api/Stations/Playlists/DeleteQueueAction.php index fe10822cb6..26e95cd6ad 100644 --- a/backend/src/Controller/Api/Stations/Playlists/DeleteQueueAction.php +++ b/backend/src/Controller/Api/Stations/Playlists/DeleteQueueAction.php @@ -10,11 +10,32 @@ use App\Entity\Repository\StationPlaylistRepository; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[OA\Delete( + path: '/station/{station_id}/playlist/{id}/queue', + operationId: 'deletePlaylistQueue', + description: 'Reset the internal playback queue of a shuffled, song-based playlist.', + tags: [OpenApi::TAG_STATIONS_PLAYLISTS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + new OA\Parameter( + name: 'id', + description: 'Playlist ID', + in: 'path', + required: true, + schema: new OA\Schema(type: 'int', format: 'int64') + ), + ], + responses: [ + new OpenApi\Response\Success(), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] +)] final class DeleteQueueAction implements SingleActionInterface { public function __construct( diff --git a/backend/src/Controller/Api/Stations/Playlists/EmptyAction.php b/backend/src/Controller/Api/Stations/Playlists/EmptyAction.php index 8d9bf6812f..72840e5f78 100644 --- a/backend/src/Controller/Api/Stations/Playlists/EmptyAction.php +++ b/backend/src/Controller/Api/Stations/Playlists/EmptyAction.php @@ -12,11 +12,32 @@ use App\Exception; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[OA\Delete( + path: '/station/{station_id}/playlist/{id}/empty', + operationId: 'deleteEmptyPlaylist', + description: 'Empty the contents of a song-based playlist.', + tags: [OpenApi::TAG_STATIONS_PLAYLISTS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + new OA\Parameter( + name: 'id', + description: 'Playlist ID', + in: 'path', + required: true, + schema: new OA\Schema(type: 'int', format: 'int64') + ), + ], + responses: [ + new OpenApi\Response\Success(), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] +)] final class EmptyAction implements SingleActionInterface { public function __construct( diff --git a/backend/src/Controller/Api/Stations/Playlists/ExportAction.php b/backend/src/Controller/Api/Stations/Playlists/ExportAction.php index 54aa3d64c5..833775ba2d 100644 --- a/backend/src/Controller/Api/Stations/Playlists/ExportAction.php +++ b/backend/src/Controller/Api/Stations/Playlists/ExportAction.php @@ -8,12 +8,44 @@ use App\Entity\Repository\StationPlaylistRepository; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; use InvalidArgumentException; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[OA\Get( + path: '/station/{station_id}/playlist/{id}/export/{format}', + operationId: 'getExportPlaylist', + description: 'Export a playlist contents in standard media player playlist format.', + tags: [OpenApi::TAG_STATIONS_PLAYLISTS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + new OA\Parameter( + name: 'id', + description: 'Playlist ID', + in: 'path', + required: true, + schema: new OA\Schema(type: 'int', format: 'int64') + ), + new OA\Parameter( + name: 'format', + description: 'Export Playlist Format', + in: 'path', + required: true, + schema: new OA\Schema( + type: 'string', + default: 'pls', + enum: ['pls', 'm3u'] + ) + ), + ], + responses: [ + new OpenApi\Response\SuccessWithDownload(), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] +)] final class ExportAction implements SingleActionInterface { public function __construct( diff --git a/backend/src/Controller/Api/Stations/Playlists/ReshuffleAction.php b/backend/src/Controller/Api/Stations/Playlists/ReshuffleAction.php index 56c5b20a2b..59b3575ff6 100644 --- a/backend/src/Controller/Api/Stations/Playlists/ReshuffleAction.php +++ b/backend/src/Controller/Api/Stations/Playlists/ReshuffleAction.php @@ -10,11 +10,32 @@ use App\Entity\Repository\StationPlaylistRepository; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[OA\Put( + path: '/station/{station_id}/playlist/{id}/reshuffle', + operationId: 'putReshufflePlaylist', + description: 'Re-shuffle a playlist whose playback order is "shuffled".', + tags: [OpenApi::TAG_STATIONS_PLAYLISTS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + new OA\Parameter( + name: 'id', + description: 'Playlist ID', + in: 'path', + required: true, + schema: new OA\Schema(type: 'int', format: 'int64') + ), + ], + responses: [ + new OpenApi\Response\Success(), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] +)] final class ReshuffleAction implements SingleActionInterface { public function __construct( diff --git a/backend/src/Controller/Api/Stations/Playlists/ToggleAction.php b/backend/src/Controller/Api/Stations/Playlists/ToggleAction.php index 32cc1f6ceb..986bfbfcf5 100644 --- a/backend/src/Controller/Api/Stations/Playlists/ToggleAction.php +++ b/backend/src/Controller/Api/Stations/Playlists/ToggleAction.php @@ -9,11 +9,32 @@ use App\Entity\Repository\StationPlaylistRepository; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[OA\Put( + path: '/station/{station_id}/playlist/{id}/toggle', + operationId: 'putTogglePlaylist', + description: 'Toggle a playlist between enabled and disabled status.', + tags: [OpenApi::TAG_STATIONS_PLAYLISTS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + new OA\Parameter( + name: 'id', + description: 'Playlist ID', + in: 'path', + required: true, + schema: new OA\Schema(type: 'int', format: 'int64') + ), + ], + responses: [ + new OpenApi\Response\Success(), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] +)] final class ToggleAction implements SingleActionInterface { public function __construct( diff --git a/backend/src/Controller/Api/Stations/ProfileAction.php b/backend/src/Controller/Api/Stations/ProfileAction.php index 61e0af965a..5b423cb014 100644 --- a/backend/src/Controller/Api/Stations/ProfileAction.php +++ b/backend/src/Controller/Api/Stations/ProfileAction.php @@ -11,13 +11,31 @@ use App\Entity\Repository\StationScheduleRepository; use App\Http\Response; use App\Http\ServerRequest; +use App\OpenApi; use App\Radio\Adapters; use GuzzleHttp\Psr7\Uri; +use OpenApi\Attributes as OA; use Psr\Http\Message\ResponseInterface; -/* - * TODO API - */ +#[ + OA\Get( + path: '/station/{station_id}/profile', + operationId: 'getStationProfile', + description: 'Retrieve the profile of the given station.', + tags: [OpenApi::TAG_STATIONS], + parameters: [ + new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED), + ], + responses: [ + new OpenApi\Response\Success( + content: new OA\JsonContent(ref: StationProfile::class) + ), + new OpenApi\Response\AccessDenied(), + new OpenApi\Response\NotFound(), + new OpenApi\Response\GenericError(), + ] + ) +] final class ProfileAction implements SingleActionInterface { public function __construct( diff --git a/web/static/openapi.yml b/web/static/openapi.yml index 4b172aa9ce..81d9c2bad0 100644 --- a/web/static/openapi.yml +++ b/web/static/openapi.yml @@ -2385,6 +2385,147 @@ paths: $ref: '#/components/responses/RecordNotFound' '500': $ref: '#/components/responses/GenericError' + '/station/{station_id}/playlist/{id}/queue': + delete: + tags: + - 'Stations: Playlists' + description: 'Reset the internal playback queue of a shuffled, song-based playlist.' + operationId: deletePlaylistQueue + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + - + name: id + in: path + description: 'Playlist ID' + required: true + schema: + type: int + format: int64 + responses: + '200': + $ref: '#/components/responses/Success' + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' + '/station/{station_id}/playlist/{id}/empty': + delete: + tags: + - 'Stations: Playlists' + description: 'Empty the contents of a song-based playlist.' + operationId: deleteEmptyPlaylist + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + - + name: id + in: path + description: 'Playlist ID' + required: true + schema: + type: int + format: int64 + responses: + '200': + $ref: '#/components/responses/Success' + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' + '/station/{station_id}/playlist/{id}/export/{format}': + get: + tags: + - 'Stations: Playlists' + description: 'Export a playlist contents in standard media player playlist format.' + operationId: getExportPlaylist + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + - + name: id + in: path + description: 'Playlist ID' + required: true + schema: + type: int + format: int64 + - + name: format + in: path + description: 'Export Playlist Format' + required: true + schema: + type: string + default: pls + enum: + - pls + - m3u + responses: + '200': + $ref: '#/components/responses/SuccessWithDownload' + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' + '/station/{station_id}/playlist/{id}/reshuffle': + put: + tags: + - 'Stations: Playlists' + description: 'Re-shuffle a playlist whose playback order is "shuffled".' + operationId: putReshufflePlaylist + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + - + name: id + in: path + description: 'Playlist ID' + required: true + schema: + type: int + format: int64 + responses: + '200': + $ref: '#/components/responses/Success' + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' + '/station/{station_id}/playlist/{id}/toggle': + put: + tags: + - 'Stations: Playlists' + description: 'Toggle a playlist between enabled and disabled status.' + operationId: putTogglePlaylist + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + - + name: id + in: path + description: 'Playlist ID' + required: true + schema: + type: int + format: int64 + responses: + '200': + $ref: '#/components/responses/Success' + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' '/station/{station_id}/playlists': get: tags: @@ -3103,6 +3244,28 @@ paths: $ref: '#/components/responses/RecordNotFound' '500': $ref: '#/components/responses/GenericError' + '/station/{station_id}/profile': + get: + tags: + - 'Stations: General' + description: 'Retrieve the profile of the given station.' + operationId: getStationProfile + parameters: + - + $ref: '#/components/parameters/StationIdRequired' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: App\Entity\Api\StationProfile + '403': + $ref: '#/components/responses/AccessDenied' + '404': + $ref: '#/components/responses/RecordNotFound' + '500': + $ref: '#/components/responses/GenericError' '/station/{station_id}/queue': get: tags: