feat(http): add owner/member endpoints for tasks

pull/10616/head
Jade McGough 2018-10-09 11:29:04 -07:00
parent bf29ff7ca3
commit 4c7f66a1c3
2 changed files with 17 additions and 3 deletions

View File

@ -100,6 +100,7 @@ func NewAPIHandler(b *APIBackend) *APIHandler {
h.TaskHandler = NewTaskHandler(b.Logger)
h.TaskHandler.TaskService = b.TaskService
h.TaskHandler.UserResourceMappingService = b.UserResourceMappingService
h.WriteHandler = NewWriteHandler(b.PointsWriter)
h.WriteHandler.AuthorizationService = b.AuthorizationService

View File

@ -21,12 +21,17 @@ type TaskHandler struct {
TaskService platform.TaskService
AuthorizationService platform.AuthorizationService
OrganizationService platform.OrganizationService
UserResourceMappingService platform.UserResourceMappingService
}
const (
tasksPath = "/api/v2/tasks"
tasksIDPath = "/api/v2/tasks/:tid"
tasksIDLogsPath = "/api/v2/tasks/:tid/logs"
tasksIDMembersPath = "/api/v2/tasks/:tid/members"
tasksIDMembersIDPath = "/api/v2/tasks/:tid/members/:userID"
tasksIDOwnersPath = "/api/v2/tasks/:tid/owners"
tasksIDOwnersIDPath = "/api/v2/tasks/:tid/owners/:userID"
tasksIDRunsPath = "/api/v2/tasks/:tid/runs"
tasksIDRunsIDPath = "/api/v2/tasks/:tid/runs/:rid"
tasksIDRunsIDLogsPath = "/api/v2/tasks/:tid/runs/:rid/logs"
@ -50,6 +55,14 @@ func NewTaskHandler(logger *zap.Logger) *TaskHandler {
h.HandlerFunc("GET", tasksIDLogsPath, h.handleGetLogs)
h.HandlerFunc("GET", tasksIDRunsIDLogsPath, h.handleGetLogs)
h.HandlerFunc("POST", tasksIDMembersPath, newPostMemberHandler(h.UserResourceMappingService, platform.Member))
h.HandlerFunc("GET", tasksIDMembersPath, newGetMembersHandler(h.UserResourceMappingService, platform.Member))
h.HandlerFunc("DELETE", tasksIDMembersIDPath, newDeleteMemberHandler(h.UserResourceMappingService, platform.Member))
h.HandlerFunc("POST", tasksIDOwnersPath, newPostMemberHandler(h.UserResourceMappingService, platform.Owner))
h.HandlerFunc("GET", tasksIDOwnersPath, newGetMembersHandler(h.UserResourceMappingService, platform.Owner))
h.HandlerFunc("DELETE", tasksIDOwnersIDPath, newDeleteMemberHandler(h.UserResourceMappingService, platform.Owner))
h.HandlerFunc("GET", tasksIDRunsPath, h.handleGetRuns)
h.HandlerFunc("GET", tasksIDRunsIDPath, h.handleGetRun)
h.HandlerFunc("POST", tasksIDRunsIDRetryPath, h.handleRetryRun)