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
02aaf8a9
Verified
Commit
02aaf8a9
authored
4 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: make /imports a valid request without showId
parent
e6072d9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/v1/files_import.go
+35
-9
35 additions, 9 deletions
api/v1/files_import.go
with
35 additions
and
9 deletions
api/v1/files_import.go
+
35
−
9
View file @
02aaf8a9
...
...
@@ -19,17 +19,18 @@
package
v1
import
(
"gitlab.servus.at/autoradio/tank/importer"
"net/http"
"github.com/gin-gonic/gin"
)
// ListImportsOfShow returns a list of all running and pending imports for files belonging to
this
show.
// ListImportsOfShow returns a list of all running and pending imports for files belonging to
a
show
if specified
.
//
// @Summary List imports
// @Description Lists all running and pending imports
// @Produce json
// @Param showId query int
tru
e "ID of the show"
// @Param showId query int
fals
e "ID of the show"
// @Param limit query int false "Limit number of results"
// @Param offset query int false "Start listing from offset"
// @Success 200 {object} JobsListing
...
...
@@ -38,24 +39,49 @@ import (
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/imports [get]
func
(
api
*
API
)
ListImportsOfShow
(
c
*
gin
.
Context
)
{
showID
,
err
:=
idFromString
(
c
.
Query
(
"showId"
))
if
err
!=
nil
{
return
}
var
err
error
var
jobs
[]
*
importer
.
Job
var
showIDs
[]
uint64
var
showID
uint64
if
authorized
,
_
:=
authorizeRequestForShow
(
c
,
showID
);
!
authorized
{
return
if
showId
:=
c
.
Query
(
"showId"
);
showId
!=
""
{
if
showID
,
err
=
idFromString
(
showId
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid showId: "
+
err
.
Error
()})
return
}
else
{
if
authorized
,
_
:=
authorizeRequestForShow
(
c
,
showID
);
!
authorized
{
return
}
}
}
else
{
if
authorized
,
sess
:=
authorizeRequestPrivilegedOrEntitled
(
c
);
!
authorized
{
return
}
else
{
if
sess
.
Privileged
{
showIDs
=
sess
.
PublicShows
}
if
sess
.
Entitled
{
showIDs
=
sess
.
Shows
}
}
}
offset
,
limit
,
ok
:=
getPaginationParameter
(
c
)
if
!
ok
{
return
}
jobs
,
err
:=
api
.
importer
.
ListJobs
(
showID
,
offset
,
limit
)
if
showID
!=
0
{
jobs
,
err
=
api
.
importer
.
ListJobsForShows
([]
uint64
{
showID
},
offset
,
limit
)
}
else
{
jobs
,
err
=
api
.
importer
.
ListJobsForShows
(
showIDs
,
offset
,
limit
)
}
if
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
JobsListing
{
jobs
})
}
...
...
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