package api

import (
	"github.com/gin-gonic/gin"
	"gitlab.com/tensorsecurity-rd/waf-console/internal/controller"
	"gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
	"gorm.io/gorm"
)

func SetWafRouter(e *gin.Engine, clusterClientManager *utils.ClusterClientManager, db *gorm.DB, gatewayUrl string) {
	v1 := e.Group("v1/api/waf")

	wafController := controller.NewWafController(clusterClientManager, db, gatewayUrl)
	v1.GET("", wafController.Waf)
	v1.POST("/", wafController.CreateWaf)
	v1.PUT("mode", wafController.UpdateMode)
	v1.PUT("rules", wafController.UpdateRule)
	v1.PUT("listener/enable", wafController.EnableListenerWaf)
	v1.PUT("gateway/enable", wafController.EnableGatewayWaf)
	v1.POST("listeners/enable", wafController.EnableListenerWafs)
	v1.DELETE("listener/:region_code/:namespace/:gateway_name/:port", wafController.DeleteListenerWaf)
	v1.DELETE("gateway/:region_code/:namespace/:gateway_name", wafController.DeleteGatewayWaf)
	v1.POST("debug/savecatagory", wafController.SaveRuleCategoryToDB)
}
