package api

import (
	"github.com/gin-gonic/gin"

	"oci-portal/internal/service"
)

// registerTasksAndLogs 挂载后台任务与 OCI 日志回传相关路由。
func registerTasksAndLogs(secured *gin.RouterGroup, tasks *service.TaskService, logEvents *service.LogEventService) {
	t := &taskHandler{svc: tasks}
	secured.POST("/tasks", t.create)
	secured.GET("/tasks", t.list)
	secured.GET("/tasks/:id", t.get)
	secured.PUT("/tasks/:id", t.update)
	secured.DELETE("/tasks/:id", t.remove)
	secured.GET("/tasks/:id/logs", t.logs)
	secured.POST("/tasks/:id/run", t.run)

	le := &logEventHandler{svc: logEvents}
	secured.GET("/log-events", le.list)
	secured.GET("/oci-configs/:id/log-webhook", le.getWebhook)
	secured.POST("/oci-configs/:id/log-webhook", le.ensureWebhook)
	secured.DELETE("/oci-configs/:id/log-webhook", le.revokeWebhook)
	secured.GET("/oci-configs/:id/log-relay", le.getRelay)
	secured.POST("/oci-configs/:id/log-relay", le.setupRelay)
	secured.DELETE("/oci-configs/:id/log-relay", le.teardownRelay)
}
