Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
855acaee
Verified
Commit
855acaee
authored
4 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: remove playlists routes
parent
5753b065
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v1/api.go
+0
-9
0 additions, 9 deletions
api/v1/api.go
api/v1/playlists.go
+0
-247
0 additions, 247 deletions
api/v1/playlists.go
with
0 additions
and
256 deletions
api/v1/api.go
+
0
−
9
View file @
855acaee
...
...
@@ -88,15 +88,6 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
imports
.
GET
(
""
,
api
.
ListImportsOfShow
)
}
playlists
:=
r
.
Group
(
"playlists"
)
{
playlists
.
GET
(
""
,
api
.
ListPlaylists
)
playlists
.
POST
(
""
,
api
.
CreatePlaylistForShow
)
playlists
.
GET
(
":playlist-id"
,
api
.
ReadPlaylist
)
playlists
.
PUT
(
":playlist-id"
,
api
.
UpdatePlaylistOfShow
)
playlists
.
DELETE
(
":playlist-id"
,
api
.
DeletePlaylistOfShow
)
}
files
:=
r
.
Group
(
"files"
)
{
files
.
GET
(
""
,
api
.
ListFilesOfShow
)
...
...
This diff is collapsed.
Click to expand it.
api/v1/playlists.go
deleted
100644 → 0
+
0
−
247
View file @
5753b065
//
// tank, Import and Playlist Daemon for Aura project
// Copyright (C) 2017-2020 Christian Pointner <equinox@helsinki.at>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
package
v1
import
(
"encoding/json"
"github.com/gin-gonic/gin"
"gitlab.servus.at/autoradio/tank/store"
"net/http"
)
// CreatePlaylistForShow creates a new playlist.
//
// @Summary Create playlist
// @Description Creates a new playlist for the show.
// @Accept json
// @Produce json
// @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/playlists [post]
func
(
api
*
API
)
CreatePlaylistForShow
(
c
*
gin
.
Context
)
{
playlist
:=
&
store
.
Playlist
{}
err
:=
json
.
NewDecoder
(
c
.
Request
.
Body
)
.
Decode
(
playlist
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"error decoding playlist: "
+
err
.
Error
()})
return
}
if
authorized
,
_
:=
authorizeRequestForShow
(
c
,
playlist
.
ShowID
);
!
authorized
{
return
}
if
playlist
,
err
=
api
.
store
.
CreatePlaylist
(
playlist
.
ShowID
,
*
playlist
);
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusCreated
,
playlist
)
}
// UpdatePlaylistOfShow updates a playlist of a show.
//
// @Summary Update playlist
// @Description Updates a playlist of a show.
// @Accept json
// @Produce json
// @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 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists/{id} [put]
func
(
api
*
API
)
UpdatePlaylistOfShow
(
c
*
gin
.
Context
)
{
playlistID
,
err
:=
idFromString
(
c
.
Param
(
"playlist-id"
))
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid playlist-id: "
+
err
.
Error
()})
return
}
// with this we are actively subverting the checks performed in api.store.UpdatePlaylist
showID
,
err
:=
api
.
store
.
GetPlaylistShowID
(
playlistID
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"wrong playlist-id: "
+
err
.
Error
()})
return
}
if
authorized
,
_
:=
authorizeRequestForShow
(
c
,
showID
);
!
authorized
{
return
}
playlist
:=
&
store
.
Playlist
{}
if
err
:=
json
.
NewDecoder
(
c
.
Request
.
Body
)
.
Decode
(
playlist
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"error decoding playlist: "
+
err
.
Error
()})
return
}
if
playlist
,
err
=
api
.
store
.
UpdatePlaylist
(
showID
,
playlistID
,
*
playlist
);
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
playlist
)
}
// DeletePlaylistOfShow deletes a playlist of a show.
//
// @Summary Delete playlist
// @Description Deletes a playlist of a show.
// @Param id path int true "ID of the playlist"
// @Success 204
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists/{id} [delete]
func
(
api
*
API
)
DeletePlaylistOfShow
(
c
*
gin
.
Context
)
{
playlistID
,
err
:=
idFromString
(
c
.
Param
(
"playlist-id"
))
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid playlist-id: "
+
err
.
Error
()})
return
}
// with this we are actively subverting the checks performed in api.store.DeletePlaylist
showID
,
err
:=
api
.
store
.
GetPlaylistShowID
(
playlistID
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"wrong playlist-id: "
+
err
.
Error
()})
return
}
if
authorized
,
_
:=
authorizeRequestForShow
(
c
,
showID
);
!
authorized
{
return
}
if
err
=
api
.
store
.
DeletePlaylist
(
showID
,
playlistID
);
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusNoContent
,
nil
)
}
// global
// ListPlaylists lists playlists.
//
// @Summary List playlists
// @Description Lists all playlists, the ones of a show or the ones that include a file
// @Produce json
// @Param showId query int false "ID of the show"
// @Param fileId query int false "ID of the file"
// @Param limit query int false "Limit number of results"
// @Param offset query int false "Start listing from offset"
// @Success 200 {object} PlaylistsListing
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists [get]
func
(
api
*
API
)
ListPlaylists
(
c
*
gin
.
Context
)
{
if
authorized
,
_
:=
authorizeRequest
(
c
,
api
);
!
authorized
{
return
}
offset
,
limit
,
ok
:=
getPaginationParameter
(
c
)
if
!
ok
{
return
}
showID
,
_
:=
idFromString
(
c
.
Query
(
"showId"
))
// we ignore error because showId is an optional query parameter
if
fileId
:=
c
.
Query
(
"fileId"
);
fileId
!=
""
{
fileID
,
err
:=
idFromString
(
fileId
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid file-id: "
+
err
.
Error
()})
return
}
// filter the playlists that include the file
if
fileID
!=
0
{
result
:=
FileUsageListing
{}
if
result
.
Usage
.
Playlists
,
err
=
api
.
store
.
GetFileUsage
(
showID
,
fileID
);
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
result
)
}
}
if
showID
!=
0
{
playlists
,
err
:=
api
.
store
.
ListPlaylists
(
showID
,
offset
,
limit
)
if
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
PlaylistsListing
{
playlists
})
}
else
{
playlists
,
err
:=
api
.
store
.
ListPlaylistsAllShows
(
offset
,
limit
)
if
err
!=
nil
{
sendError
(
c
,
err
)
return
}
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 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists/{id} [get]
func
(
api
*
API
)
ReadPlaylist
(
c
*
gin
.
Context
)
{
if
authorized
,
_
:=
authorizeRequest
(
c
,
api
);
!
authorized
{
return
}
id
,
err
:=
idFromString
(
c
.
Param
(
"playlist-id"
))
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid playlist-id: "
+
err
.
Error
()})
return
}
showID
,
_
:=
idFromString
(
c
.
Query
(
"showId"
))
// we ignore error because the showId is an optional query parameter
if
showID
!=
0
{
playlist
,
err
:=
api
.
store
.
GetPlaylist
(
showID
,
id
)
if
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
playlist
)
}
else
{
playlist
,
err
:=
api
.
store
.
GetPlaylistAllShows
(
id
)
if
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
playlist
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment