Commit b1141910 authored by robwa's avatar robwa
Browse files

feat: Add API doc for uploads and playlists

parent dba4d34a
This diff is collapsed.
...@@ -37,6 +37,18 @@ import ( ...@@ -37,6 +37,18 @@ import (
//******* simple binary http upload //******* simple binary http upload
// UploadFileSimple uploads file content.
// @Summary Upload file content
// @Description Uploads file content. Only available if file was created using SourceURI set to upload://-type and file import state is running.
// @Accept octet-stream
// @Produce json
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the file"
// @Success 200
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/files/{id}/upload [put]
func (api *API) UploadFileSimple(c *gin.Context) { func (api *API) UploadFileSimple(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -364,6 +376,18 @@ func getFlowJSParameterFromQuery(r *http.Request) (id string, chunk, totalChunks ...@@ -364,6 +376,18 @@ func getFlowJSParameterFromQuery(r *http.Request) (id string, chunk, totalChunks
return return
} }
// UploadFileFlowJS uploads file content via flow.js.
// @Summary Upload file content
// @Description Uploads file content via flow.js. Only available if file was created using SourceURI set to upload://-type and file import state is running.
// @Accept mpfd
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the file"
// @Success 200 {object} nil
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 409 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/files/{id}/upload [post]
func (api *API) UploadFileFlowJS(c *gin.Context) { func (api *API) UploadFileFlowJS(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -429,6 +453,20 @@ func (api *API) UploadFileFlowJS(c *gin.Context) { ...@@ -429,6 +453,20 @@ func (api *API) UploadFileFlowJS(c *gin.Context) {
c.JSON(http.StatusOK, nil) c.JSON(http.StatusOK, nil)
} }
// TestFileFlowJS uploads file content.
// @Summary Upload file content
// @Description Uploads file content. Only available if file was created using SourceURI set to upload://-type and file import state is running.
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the file"
// @Param flowIdentifier query string true "A unique identifier for the uploaded file"
// TODO: document all flow.js params
// @Success 200 {object} nil
// @Success 204 {object} nil
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 409 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/files/{id}/upload [get]
func (api *API) TestFileFlowJS(c *gin.Context) { func (api *API) TestFileFlowJS(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
......
...@@ -26,6 +26,17 @@ import ( ...@@ -26,6 +26,17 @@ import (
"gitlab.servus.at/autoradio/tank/store" "gitlab.servus.at/autoradio/tank/store"
) )
// ListPlaylistsOfShow lists playlists.
// @Summary List playlists
// @Description Lists playlists of show.
// @Produce json
// @Param name path string true "Name of the show"
// @Param limit query int false "Limit number of results"
// @Param offset query int false "Start listing from offset"
// @Success 200 {object} PlaylistsListing
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/playlists [get]
func (api *API) ListPlaylistsOfShow(c *gin.Context) { func (api *API) ListPlaylistsOfShow(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -44,6 +55,18 @@ func (api *API) ListPlaylistsOfShow(c *gin.Context) { ...@@ -44,6 +55,18 @@ func (api *API) ListPlaylistsOfShow(c *gin.Context) {
c.JSON(http.StatusOK, PlaylistsListing{playlists}) c.JSON(http.StatusOK, PlaylistsListing{playlists})
} }
// CreatePlaylistForShow creates a new playlist.
// @Summary Create playlist
// @Description Creates a new playlist for the show.
// @Accept json
// @Produce json
// @Param name path string true "Name of the show"
// @Param playlist body store.Playlist true "Playlist data"
// @Success 201 {object} store.Playlist
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/playlists [post]
func (api *API) CreatePlaylistForShow(c *gin.Context) { func (api *API) CreatePlaylistForShow(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -63,6 +86,17 @@ func (api *API) CreatePlaylistForShow(c *gin.Context) { ...@@ -63,6 +86,17 @@ func (api *API) CreatePlaylistForShow(c *gin.Context) {
c.JSON(http.StatusCreated, playlist) c.JSON(http.StatusCreated, playlist)
} }
// ReadPlaylistOfShow retrieves a playlist of a show.
// @Summary Retrieve playlist
// @Description Retrieves a playlist of a show.
// @Produce json
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the playlist"
// @Success 200 {object} store.Playlist
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/playlists/{id} [get]
func (api *API) ReadPlaylistOfShow(c *gin.Context) { func (api *API) ReadPlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -82,6 +116,19 @@ func (api *API) ReadPlaylistOfShow(c *gin.Context) { ...@@ -82,6 +116,19 @@ func (api *API) ReadPlaylistOfShow(c *gin.Context) {
c.JSON(http.StatusOK, playlist) c.JSON(http.StatusOK, playlist)
} }
// UpdatePlaylistOfShow updates a playlist of a show.
// @Summary Update playlist
// @Description Updates a playlist of a show.
// @Accept json
// @Produce json
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the playlist"
// @Param playlist body store.Playlist true "Playlist data"
// @Success 200 {object} store.Playlist
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/playlists/{id} [put]
func (api *API) UpdatePlaylistOfShow(c *gin.Context) { func (api *API) UpdatePlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -105,6 +152,16 @@ func (api *API) UpdatePlaylistOfShow(c *gin.Context) { ...@@ -105,6 +152,16 @@ func (api *API) UpdatePlaylistOfShow(c *gin.Context) {
c.JSON(http.StatusOK, playlist) c.JSON(http.StatusOK, playlist)
} }
// DeletePlaylistOfShow deletes a playlist of a show.
// @Summary Delete playlist
// @Description Deletes a playlist of a show.
// @Param name path string true "Name of the show"
// @Param id path int true "ID of the playlist"
// @Success 204 {object} nil
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/shows/{name}/playlists/{id} [delete]
func (api *API) DeletePlaylistOfShow(c *gin.Context) { func (api *API) DeletePlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id") showID := c.Param("show-id")
if authorized, _ := authorizeRequestForShow(c, showID); !authorized { if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
...@@ -125,6 +182,16 @@ func (api *API) DeletePlaylistOfShow(c *gin.Context) { ...@@ -125,6 +182,16 @@ func (api *API) DeletePlaylistOfShow(c *gin.Context) {
// global // global
// ListPlaylists lists all playlists.
// @Summary List playlists
// @Description Lists all playlists.
// @Produce json
// @Param limit query int false "Limit number of results"
// @Param offset query int false "Start listing from offset"
// @Success 200 {object} PlaylistsListing
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists [get]
func (api *API) ListPlaylists(c *gin.Context) { func (api *API) ListPlaylists(c *gin.Context) {
if authorized, _ := authorizeRequestAllShows(c); !authorized { if authorized, _ := authorizeRequestAllShows(c); !authorized {
return return
...@@ -142,6 +209,16 @@ func (api *API) ListPlaylists(c *gin.Context) { ...@@ -142,6 +209,16 @@ func (api *API) ListPlaylists(c *gin.Context) {
c.JSON(http.StatusOK, PlaylistsListing{playlists}) c.JSON(http.StatusOK, PlaylistsListing{playlists})
} }
// ReadPlaylist retrieves a playlist.
// @Summary Retrieve playlist
// @Description Retrieves a playlist.
// @Produce json
// @Param id path int true "ID of the playlist"
// @Success 200 {object} store.Playlist
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists/{id} [get]
func (api *API) ReadPlaylist(c *gin.Context) { func (api *API) ReadPlaylist(c *gin.Context) {
if authorized, _ := authorizeRequestAllShows(c); !authorized { if authorized, _ := authorizeRequestAllShows(c); !authorized {
return return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment