package api

import (
	controller "github.com/tidbcloud/aipower/internal/controller/central"

	"github.com/tidbcloud/aipower/docs"

	"github.com/gin-gonic/gin"
	swaggerfiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func RouteCentralAPI(router *gin.Engine) {
	router.Any(
		"/healthz", func(c *gin.Context) {
			c.Status(200)
		},
	)

	// Request Body Check
	router.Use(CheckRequestBodySize)

	docs.SwaggerInfo.BasePath = "/inner/aipower/api/v1"
	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
	central := router.Group("/inner/aipower/api/v1")
	{
		central.POST("/orgs/:org_id/projects/:project_id/bot", controller.InteractBot)
		central.GET("/api_key_info", controller.GetAPIKeyInfo)
		central.GET("/cluster_info", controller.GetClusterInfo)
		central.POST("/api_key_permission_check", controller.CheckAPIKeyPermission)
		central.POST("/user_permission_check", controller.CheckUserPermission)
	}
}
