droboticflow/internal/api/routes_annotation.go

71 lines
5.8 KiB
Go

package api
import "github.com/go-chi/chi/v5"
// mountAnnotationRoutes registers data-collection tasks, the annotation-qa
// plugin's templates and tasks (plus their deprecated /api/annotation-*
// aliases), and the annotation label dictionaries.
func (server *server) mountAnnotationRoutes(router chi.Router) {
router.Get("/api/plugins/annotation-qa/source-readiness", server.handleSourceAdmissionReadiness)
router.Get("/api/data-collection-tasks", server.handleCollectionTasksList)
router.Get("/api/data-collection-tasks/{id}", server.handleCollectionTaskGet)
router.Get("/api/annotation-templates", deprecatedAnnotationEndpoint(server.handleAnnotationTemplatesList))
router.Get("/api/annotation-tasks", deprecatedAnnotationEndpoint(server.handleAnnotationTasksList))
router.Get("/api/annotation-tasks/{id}", deprecatedAnnotationEndpoint(server.handleAnnotationTaskGet))
router.Get("/api/annotation-workload-summary", deprecatedAnnotationEndpoint(server.handleAnnotationWorkloadSummary))
router.Get("/api/plugins/annotation-qa/templates", server.handleAnnotationTemplatesList)
router.Get("/api/plugins/annotation-qa/tasks", server.handleAnnotationTasksList)
router.Get("/api/plugins/annotation-qa/tasks/{id}", server.handleAnnotationTaskGet)
router.Get("/api/plugins/annotation-qa/tasks/{id}/frame-timeline", server.handleAnnotationTaskFrameTimelineGet)
router.Get("/api/plugins/annotation-qa/sidebar", server.handleAnnotationSidebar)
router.Get("/api/plugins/annotation-qa/admin-pool", server.handleAdminAnnotationPool)
// The workload summary is a read-only aggregate over 30 days of worklog
// events. The shared 45s per-user response cache (invalidated by any
// /api write) keeps the annotation center's initial load from re-running
// the window scan on every visit, mirroring the dashboard workforce path.
router.Get("/api/plugins/annotation-qa/workload-summary", server.withDashboardResponseCache("workload-summary", server.handleAnnotationWorkloadSummary))
annotators := server.withRoles(router, rolesAnnotationWork...)
annotators.Post("/api/data-collection-tasks", server.handleCollectionTaskCreate)
annotators.Patch("/api/data-collection-tasks/{id}", server.handleCollectionTaskUpdate)
annotators.Post("/api/data-collection-tasks/{id}/complete", server.handleCollectionTaskComplete)
annotators.Post("/api/annotation-tasks", deprecatedAnnotationEndpoint(server.handleAnnotationTaskCreate))
annotators.Post("/api/annotation-tasks/{id}/revisions", deprecatedAnnotationEndpoint(server.handleAnnotationRevisionCreate))
annotators.Post("/api/annotation-tasks/{id}/slice-revisions", deprecatedAnnotationEndpoint(server.handleSliceRevisionCreate))
annotators.Post("/api/annotation-tasks/{id}/combined-submissions", deprecatedAnnotationEndpoint(server.handleCombinedAnnotationSubmission))
annotators.Post("/api/plugins/annotation-qa/tasks", server.handleAnnotationTaskCreate)
annotators.Put("/api/plugins/annotation-qa/tasks/{id}/drafts", server.handleCombinedAnnotationDraftPut)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/annotation-confirmations", server.handleAnnotationConfirmationCreate)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-edit-restorations", server.handleSliceEditRestoration)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-edit-applications", server.handleSliceEditApplication)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-dispositions", server.handleSliceDisposition)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-confirmations", server.handleSliceConfirmationCreate)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-reset", server.handleSliceResetCreate)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/slice-revisions", server.handleSliceRevisionCreate)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/combined-submissions", server.handleCombinedAnnotationSubmission)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/reject", server.handleAnnotationTaskReject)
annotators.Post("/api/plugins/annotation-qa/tasks/{id}/revisions", server.handleAnnotationRevisionCreate)
reviewers := server.withRoles(router, rolesReviewWork...)
reviewers.Post("/api/annotation-tasks/{id}/reviews", deprecatedAnnotationEndpoint(server.handleAnnotationReviewCreate))
reviewers.Post("/api/plugins/annotation-qa/tasks/{id}/reviews", server.handleAnnotationReviewCreate)
admin := server.withRoles(router, rolesAdmin...)
admin.Post("/api/plugins/annotation-qa/tasks/{id}/source-validation-retries", server.handleAnnotationSourceValidationRetry)
admin.Post("/api/annotation-templates", deprecatedAnnotationEndpoint(server.handleAnnotationTemplateCreate))
admin.Post("/api/annotation-templates/{id}/publish", deprecatedAnnotationEndpoint(server.handleAnnotationTemplatePublish))
admin.Post("/api/plugins/annotation-qa/templates", server.handleAnnotationTemplateCreate)
admin.Post("/api/plugins/annotation-qa/templates/{id}/publish", server.handleAnnotationTemplatePublish)
router.Get("/api/annotation-labels", server.handleAnnotationLabelsList)
router.Get("/api/projects/{id}/annotation-labels", server.handleProjectAnnotationLabelsGet)
router.Get("/api/projects/{id}/slice-labels", server.handleProjectAnnotationLabelsGet)
router.Get("/api/projects/{id}/discard-reason-labels", server.handleProjectAnnotationLabelsGet)
admin.Post("/api/annotation-labels", server.handleAnnotationLabelCreate)
admin.Patch("/api/annotation-labels/{id}", server.handleAnnotationLabelPatch)
admin.Put("/api/projects/{id}/annotation-labels", server.handleProjectAnnotationLabelsPut)
admin.Put("/api/projects/{id}/slice-labels", server.handleProjectAnnotationLabelsPut)
admin.Put("/api/projects/{id}/discard-reason-labels", server.handleProjectAnnotationLabelsPut)
admin.Post("/api/projects/{id}/dictionary-labels/import", server.handleProjectDictionaryLabelsImport)
}