api-router.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. package router
  2. import (
  3. "github.com/QuantumNous/new-api/controller"
  4. "github.com/QuantumNous/new-api/middleware"
  5. // Import oauth package to register providers via init()
  6. _ "github.com/QuantumNous/new-api/oauth"
  7. "github.com/gin-contrib/gzip"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func SetApiRouter(router *gin.Engine) {
  11. apiRouter := router.Group("/api")
  12. apiRouter.Use(middleware.RouteTag("api"))
  13. apiRouter.Use(gzip.Gzip(gzip.DefaultCompression))
  14. apiRouter.Use(middleware.BodyStorageCleanup()) // 清理请求体存储
  15. apiRouter.Use(middleware.GlobalAPIRateLimit())
  16. {
  17. apiRouter.GET("/setup", controller.GetSetup)
  18. apiRouter.POST("/setup", controller.PostSetup)
  19. apiRouter.GET("/status", controller.GetStatus)
  20. apiRouter.GET("/uptime/status", controller.GetUptimeKumaStatus)
  21. apiRouter.GET("/models", middleware.UserAuth(), controller.DashboardListModels)
  22. apiRouter.GET("/status/test", middleware.AdminAuth(), controller.TestStatus)
  23. apiRouter.GET("/notice", controller.GetNotice)
  24. apiRouter.GET("/user-agreement", controller.GetUserAgreement)
  25. apiRouter.GET("/privacy-policy", controller.GetPrivacyPolicy)
  26. apiRouter.GET("/about", controller.GetAbout)
  27. //apiRouter.GET("/midjourney", controller.GetMidjourney)
  28. apiRouter.GET("/home_page_content", controller.GetHomePageContent)
  29. apiRouter.GET("/pricing", middleware.TryUserAuth(), controller.GetPricing)
  30. perfMetricsRoute := apiRouter.Group("/perf-metrics")
  31. perfMetricsRoute.Use(middleware.TryUserAuth())
  32. {
  33. perfMetricsRoute.GET("/summary", controller.GetPerfMetricsSummary)
  34. perfMetricsRoute.GET("", controller.GetPerfMetrics)
  35. }
  36. apiRouter.GET("/rankings", controller.GetRankings)
  37. apiRouter.GET("/verification", middleware.EmailVerificationRateLimit(), middleware.TurnstileCheck(), controller.SendEmailVerification)
  38. apiRouter.GET("/reset_password", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendPasswordResetEmail)
  39. apiRouter.POST("/user/reset", middleware.CriticalRateLimit(), controller.ResetPassword)
  40. // OAuth routes - specific routes must come before :provider wildcard
  41. apiRouter.GET("/oauth/state", middleware.CriticalRateLimit(), controller.GenerateOAuthCode)
  42. apiRouter.POST("/oauth/email/bind", middleware.CriticalRateLimit(), controller.EmailBind)
  43. // Non-standard OAuth (WeChat, Telegram) - keep original routes
  44. apiRouter.GET("/oauth/wechat", middleware.CriticalRateLimit(), controller.WeChatAuth)
  45. apiRouter.POST("/oauth/wechat/bind", middleware.CriticalRateLimit(), controller.WeChatBind)
  46. apiRouter.GET("/oauth/telegram/login", middleware.CriticalRateLimit(), controller.TelegramLogin)
  47. apiRouter.GET("/oauth/telegram/bind", middleware.CriticalRateLimit(), controller.TelegramBind)
  48. // Standard OAuth providers (GitHub, Discord, OIDC, LinuxDO) - unified route
  49. apiRouter.GET("/oauth/:provider", middleware.CriticalRateLimit(), controller.HandleOAuth)
  50. apiRouter.GET("/ratio_config", middleware.CriticalRateLimit(), controller.GetRatioConfig)
  51. apiRouter.POST("/stripe/webhook", controller.StripeWebhook)
  52. apiRouter.POST("/creem/webhook", controller.CreemWebhook)
  53. apiRouter.POST("/waffo/webhook", controller.WaffoWebhook)
  54. //apiRouter.POST("/waffo-pancake/webhook", controller.WaffoPancakeWebhook)
  55. // Universal secure verification routes
  56. apiRouter.POST("/verify", middleware.UserAuth(), middleware.CriticalRateLimit(), controller.UniversalVerify)
  57. userRoute := apiRouter.Group("/user")
  58. {
  59. userRoute.POST("/register", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.Register)
  60. userRoute.POST("/login", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.Login)
  61. userRoute.POST("/login/2fa", middleware.CriticalRateLimit(), controller.Verify2FALogin)
  62. userRoute.POST("/passkey/login/begin", middleware.CriticalRateLimit(), controller.PasskeyLoginBegin)
  63. userRoute.POST("/passkey/login/finish", middleware.CriticalRateLimit(), controller.PasskeyLoginFinish)
  64. //userRoute.POST("/tokenlog", middleware.CriticalRateLimit(), controller.TokenLog)
  65. userRoute.GET("/logout", controller.Logout)
  66. userRoute.POST("/epay/notify", controller.EpayNotify)
  67. userRoute.GET("/epay/notify", controller.EpayNotify)
  68. userRoute.GET("/groups", controller.GetUserGroups)
  69. selfRoute := userRoute.Group("/")
  70. selfRoute.Use(middleware.UserAuth())
  71. {
  72. selfRoute.GET("/self/groups", controller.GetUserGroups)
  73. selfRoute.GET("/self", controller.GetSelf)
  74. selfRoute.GET("/models", controller.GetUserModels)
  75. selfRoute.PUT("/self", controller.UpdateSelf)
  76. selfRoute.DELETE("/self", controller.DeleteSelf)
  77. selfRoute.GET("/token", controller.GenerateAccessToken)
  78. selfRoute.GET("/passkey", controller.PasskeyStatus)
  79. selfRoute.POST("/passkey/register/begin", controller.PasskeyRegisterBegin)
  80. selfRoute.POST("/passkey/register/finish", controller.PasskeyRegisterFinish)
  81. selfRoute.POST("/passkey/verify/begin", controller.PasskeyVerifyBegin)
  82. selfRoute.POST("/passkey/verify/finish", controller.PasskeyVerifyFinish)
  83. selfRoute.DELETE("/passkey", controller.PasskeyDelete)
  84. selfRoute.GET("/aff", controller.GetAffCode)
  85. selfRoute.GET("/topup/info", controller.GetTopUpInfo)
  86. selfRoute.GET("/topup/self", controller.GetUserTopUps)
  87. selfRoute.POST("/topup", middleware.CriticalRateLimit(), controller.TopUp)
  88. selfRoute.POST("/pay", middleware.CriticalRateLimit(), controller.RequestEpay)
  89. selfRoute.POST("/amount", controller.RequestAmount)
  90. selfRoute.POST("/stripe/pay", middleware.CriticalRateLimit(), controller.RequestStripePay)
  91. selfRoute.POST("/stripe/amount", controller.RequestStripeAmount)
  92. selfRoute.POST("/creem/pay", middleware.CriticalRateLimit(), controller.RequestCreemPay)
  93. selfRoute.POST("/waffo/amount", controller.RequestWaffoAmount)
  94. selfRoute.POST("/waffo/pay", middleware.CriticalRateLimit(), controller.RequestWaffoPay)
  95. //selfRoute.POST("/waffo-pancake/amount", controller.RequestWaffoPancakeAmount)
  96. //selfRoute.POST("/waffo-pancake/pay", middleware.CriticalRateLimit(), controller.RequestWaffoPancakePay)
  97. selfRoute.POST("/aff_transfer", controller.TransferAffQuota)
  98. selfRoute.PUT("/setting", controller.UpdateUserSetting)
  99. // 2FA routes
  100. selfRoute.GET("/2fa/status", controller.Get2FAStatus)
  101. selfRoute.POST("/2fa/setup", controller.Setup2FA)
  102. selfRoute.POST("/2fa/enable", controller.Enable2FA)
  103. selfRoute.POST("/2fa/disable", controller.Disable2FA)
  104. selfRoute.POST("/2fa/backup_codes", controller.RegenerateBackupCodes)
  105. // Check-in routes
  106. selfRoute.GET("/checkin", controller.GetCheckinStatus)
  107. selfRoute.POST("/checkin", middleware.TurnstileCheck(), controller.DoCheckin)
  108. // Custom OAuth bindings
  109. selfRoute.GET("/oauth/bindings", controller.GetUserOAuthBindings)
  110. selfRoute.DELETE("/oauth/bindings/:provider_id", controller.UnbindCustomOAuth)
  111. }
  112. adminRoute := userRoute.Group("/")
  113. adminRoute.Use(middleware.AdminAuth())
  114. {
  115. adminRoute.GET("/", controller.GetAllUsers)
  116. adminRoute.GET("/topup", controller.GetAllTopUps)
  117. adminRoute.POST("/topup/complete", controller.AdminCompleteTopUp)
  118. adminRoute.GET("/search", controller.SearchUsers)
  119. adminRoute.GET("/:id/oauth/bindings", controller.GetUserOAuthBindingsByAdmin)
  120. adminRoute.DELETE("/:id/oauth/bindings/:provider_id", controller.UnbindCustomOAuthByAdmin)
  121. adminRoute.DELETE("/:id/bindings/:binding_type", controller.AdminClearUserBinding)
  122. adminRoute.GET("/:id", controller.GetUser)
  123. adminRoute.POST("/", controller.CreateUser)
  124. adminRoute.POST("/manage", controller.ManageUser)
  125. adminRoute.PUT("/", controller.UpdateUser)
  126. adminRoute.DELETE("/:id", controller.DeleteUser)
  127. adminRoute.DELETE("/:id/reset_passkey", controller.AdminResetPasskey)
  128. // Admin 2FA routes
  129. adminRoute.GET("/2fa/stats", controller.Admin2FAStats)
  130. adminRoute.DELETE("/:id/2fa", controller.AdminDisable2FA)
  131. }
  132. }
  133. // Subscription billing (plans, purchase, admin management)
  134. subscriptionRoute := apiRouter.Group("/subscription")
  135. subscriptionRoute.Use(middleware.UserAuth())
  136. {
  137. subscriptionRoute.GET("/plans", controller.GetSubscriptionPlans)
  138. subscriptionRoute.GET("/self", controller.GetSubscriptionSelf)
  139. subscriptionRoute.PUT("/self/preference", controller.UpdateSubscriptionPreference)
  140. subscriptionRoute.POST("/epay/pay", middleware.CriticalRateLimit(), controller.SubscriptionRequestEpay)
  141. subscriptionRoute.POST("/stripe/pay", middleware.CriticalRateLimit(), controller.SubscriptionRequestStripePay)
  142. subscriptionRoute.POST("/creem/pay", middleware.CriticalRateLimit(), controller.SubscriptionRequestCreemPay)
  143. }
  144. subscriptionAdminRoute := apiRouter.Group("/subscription/admin")
  145. subscriptionAdminRoute.Use(middleware.AdminAuth())
  146. {
  147. subscriptionAdminRoute.GET("/plans", controller.AdminListSubscriptionPlans)
  148. subscriptionAdminRoute.POST("/plans", controller.AdminCreateSubscriptionPlan)
  149. subscriptionAdminRoute.PUT("/plans/:id", controller.AdminUpdateSubscriptionPlan)
  150. subscriptionAdminRoute.PATCH("/plans/:id", controller.AdminUpdateSubscriptionPlanStatus)
  151. subscriptionAdminRoute.POST("/bind", controller.AdminBindSubscription)
  152. // User subscription management (admin)
  153. subscriptionAdminRoute.GET("/users/:id/subscriptions", controller.AdminListUserSubscriptions)
  154. subscriptionAdminRoute.POST("/users/:id/subscriptions", controller.AdminCreateUserSubscription)
  155. subscriptionAdminRoute.POST("/user_subscriptions/:id/invalidate", controller.AdminInvalidateUserSubscription)
  156. subscriptionAdminRoute.DELETE("/user_subscriptions/:id", controller.AdminDeleteUserSubscription)
  157. }
  158. // Subscription payment callbacks (no auth)
  159. apiRouter.POST("/subscription/epay/notify", controller.SubscriptionEpayNotify)
  160. apiRouter.GET("/subscription/epay/notify", controller.SubscriptionEpayNotify)
  161. apiRouter.GET("/subscription/epay/return", controller.SubscriptionEpayReturn)
  162. apiRouter.POST("/subscription/epay/return", controller.SubscriptionEpayReturn)
  163. optionRoute := apiRouter.Group("/option")
  164. optionRoute.Use(middleware.RootAuth())
  165. {
  166. optionRoute.GET("/", controller.GetOptions)
  167. optionRoute.PUT("/", controller.UpdateOption)
  168. optionRoute.GET("/channel_affinity_cache", controller.GetChannelAffinityCacheStats)
  169. optionRoute.DELETE("/channel_affinity_cache", controller.ClearChannelAffinityCache)
  170. optionRoute.POST("/rest_model_ratio", controller.ResetModelRatio)
  171. optionRoute.POST("/migrate_console_setting", controller.MigrateConsoleSetting) // 用于迁移检测的旧键,下个版本会删除
  172. }
  173. // Custom OAuth provider management (root only)
  174. customOAuthRoute := apiRouter.Group("/custom-oauth-provider")
  175. customOAuthRoute.Use(middleware.RootAuth())
  176. {
  177. customOAuthRoute.POST("/discovery", controller.FetchCustomOAuthDiscovery)
  178. customOAuthRoute.GET("/", controller.GetCustomOAuthProviders)
  179. customOAuthRoute.GET("/:id", controller.GetCustomOAuthProvider)
  180. customOAuthRoute.POST("/", controller.CreateCustomOAuthProvider)
  181. customOAuthRoute.PUT("/:id", controller.UpdateCustomOAuthProvider)
  182. customOAuthRoute.DELETE("/:id", controller.DeleteCustomOAuthProvider)
  183. }
  184. performanceRoute := apiRouter.Group("/performance")
  185. performanceRoute.Use(middleware.RootAuth())
  186. {
  187. performanceRoute.GET("/stats", controller.GetPerformanceStats)
  188. performanceRoute.DELETE("/disk_cache", controller.ClearDiskCache)
  189. performanceRoute.POST("/reset_stats", controller.ResetPerformanceStats)
  190. performanceRoute.POST("/gc", controller.ForceGC)
  191. performanceRoute.GET("/logs", controller.GetLogFiles)
  192. performanceRoute.DELETE("/logs", controller.CleanupLogFiles)
  193. }
  194. ratioSyncRoute := apiRouter.Group("/ratio_sync")
  195. ratioSyncRoute.Use(middleware.RootAuth())
  196. {
  197. ratioSyncRoute.GET("/channels", controller.GetSyncableChannels)
  198. ratioSyncRoute.POST("/fetch", controller.FetchUpstreamRatios)
  199. }
  200. channelRoute := apiRouter.Group("/channel")
  201. channelRoute.Use(middleware.AdminAuth())
  202. {
  203. channelRoute.GET("/", controller.GetAllChannels)
  204. channelRoute.GET("/search", controller.SearchChannels)
  205. channelRoute.GET("/models", controller.ChannelListModels)
  206. channelRoute.GET("/models_enabled", controller.EnabledListModels)
  207. channelRoute.GET("/:id", controller.GetChannel)
  208. channelRoute.POST("/:id/key", middleware.RootAuth(), middleware.CriticalRateLimit(), middleware.DisableCache(), middleware.SecureVerificationRequired(), controller.GetChannelKey)
  209. channelRoute.GET("/test", controller.TestAllChannels)
  210. channelRoute.GET("/test/:id", controller.TestChannel)
  211. channelRoute.GET("/update_balance", controller.UpdateAllChannelsBalance)
  212. channelRoute.GET("/update_balance/:id", controller.UpdateChannelBalance)
  213. channelRoute.POST("/", controller.AddChannel)
  214. channelRoute.PUT("/", controller.UpdateChannel)
  215. channelRoute.DELETE("/disabled", controller.DeleteDisabledChannel)
  216. channelRoute.POST("/tag/disabled", controller.DisableTagChannels)
  217. channelRoute.POST("/tag/enabled", controller.EnableTagChannels)
  218. channelRoute.PUT("/tag", controller.EditTagChannels)
  219. channelRoute.DELETE("/:id", controller.DeleteChannel)
  220. channelRoute.POST("/batch", controller.DeleteChannelBatch)
  221. channelRoute.POST("/fix", controller.FixChannelsAbilities)
  222. channelRoute.GET("/fetch_models/:id", controller.FetchUpstreamModels)
  223. channelRoute.POST("/fetch_models", middleware.RootAuth(), controller.FetchModels)
  224. channelRoute.POST("/codex/oauth/start", controller.StartCodexOAuth)
  225. channelRoute.POST("/codex/oauth/complete", controller.CompleteCodexOAuth)
  226. channelRoute.POST("/:id/codex/oauth/start", controller.StartCodexOAuthForChannel)
  227. channelRoute.POST("/:id/codex/oauth/complete", controller.CompleteCodexOAuthForChannel)
  228. channelRoute.POST("/:id/codex/refresh", controller.RefreshCodexChannelCredential)
  229. channelRoute.GET("/:id/codex/usage", controller.GetCodexChannelUsage)
  230. channelRoute.POST("/ollama/pull", controller.OllamaPullModel)
  231. channelRoute.POST("/ollama/pull/stream", controller.OllamaPullModelStream)
  232. channelRoute.DELETE("/ollama/delete", controller.OllamaDeleteModel)
  233. channelRoute.GET("/ollama/version/:id", controller.OllamaVersion)
  234. channelRoute.POST("/batch/tag", controller.BatchSetChannelTag)
  235. channelRoute.GET("/tag/models", controller.GetTagModels)
  236. channelRoute.POST("/copy/:id", controller.CopyChannel)
  237. channelRoute.POST("/multi_key/manage", controller.ManageMultiKeys)
  238. channelRoute.POST("/upstream_updates/apply", controller.ApplyChannelUpstreamModelUpdates)
  239. channelRoute.POST("/upstream_updates/apply_all", controller.ApplyAllChannelUpstreamModelUpdates)
  240. channelRoute.POST("/upstream_updates/detect", controller.DetectChannelUpstreamModelUpdates)
  241. channelRoute.POST("/upstream_updates/detect_all", controller.DetectAllChannelUpstreamModelUpdates)
  242. }
  243. tokenRoute := apiRouter.Group("/token")
  244. tokenRoute.Use(middleware.UserAuth())
  245. {
  246. tokenRoute.GET("/", controller.GetAllTokens)
  247. tokenRoute.GET("/search", middleware.SearchRateLimit(), controller.SearchTokens)
  248. tokenRoute.GET("/:id", controller.GetToken)
  249. tokenRoute.POST("/:id/key", middleware.CriticalRateLimit(), middleware.DisableCache(), controller.GetTokenKey)
  250. tokenRoute.POST("/", controller.AddToken)
  251. tokenRoute.PUT("/", controller.UpdateToken)
  252. tokenRoute.DELETE("/:id", controller.DeleteToken)
  253. tokenRoute.POST("/batch", controller.DeleteTokenBatch)
  254. tokenRoute.POST("/batch/keys", middleware.CriticalRateLimit(), middleware.DisableCache(), controller.GetTokenKeysBatch)
  255. }
  256. usageRoute := apiRouter.Group("/usage")
  257. usageRoute.Use(middleware.CORS(), middleware.CriticalRateLimit())
  258. {
  259. tokenUsageRoute := usageRoute.Group("/token")
  260. tokenUsageRoute.Use(middleware.TokenAuthReadOnly())
  261. {
  262. tokenUsageRoute.GET("/", controller.GetTokenUsage)
  263. }
  264. }
  265. redemptionRoute := apiRouter.Group("/redemption")
  266. redemptionRoute.Use(middleware.AdminAuth())
  267. {
  268. redemptionRoute.GET("/", controller.GetAllRedemptions)
  269. redemptionRoute.GET("/search", controller.SearchRedemptions)
  270. redemptionRoute.GET("/:id", controller.GetRedemption)
  271. redemptionRoute.POST("/", controller.AddRedemption)
  272. redemptionRoute.PUT("/", controller.UpdateRedemption)
  273. redemptionRoute.DELETE("/invalid", controller.DeleteInvalidRedemption)
  274. redemptionRoute.DELETE("/:id", controller.DeleteRedemption)
  275. }
  276. logRoute := apiRouter.Group("/log")
  277. logRoute.GET("/", middleware.AdminAuth(), controller.GetAllLogs)
  278. logRoute.DELETE("/", middleware.AdminAuth(), controller.DeleteHistoryLogs)
  279. logRoute.GET("/stat", middleware.AdminAuth(), controller.GetLogsStat)
  280. logRoute.GET("/self/stat", middleware.UserAuth(), controller.GetLogsSelfStat)
  281. logRoute.GET("/channel_affinity_usage_cache", middleware.AdminAuth(), controller.GetChannelAffinityUsageCacheStats)
  282. logRoute.GET("/search", middleware.AdminAuth(), controller.SearchAllLogs)
  283. logRoute.GET("/self", middleware.UserAuth(), controller.GetUserLogs)
  284. logRoute.GET("/self/search", middleware.UserAuth(), middleware.SearchRateLimit(), controller.SearchUserLogs)
  285. dataRoute := apiRouter.Group("/data")
  286. dataRoute.GET("/", middleware.AdminAuth(), controller.GetAllQuotaDates)
  287. dataRoute.GET("/users", middleware.AdminAuth(), controller.GetQuotaDatesByUser)
  288. dataRoute.GET("/self", middleware.UserAuth(), controller.GetUserQuotaDates)
  289. logRoute.Use(middleware.CORS(), middleware.CriticalRateLimit())
  290. {
  291. logRoute.GET("/token", middleware.TokenAuthReadOnly(), controller.GetLogByKey)
  292. }
  293. groupRoute := apiRouter.Group("/group")
  294. groupRoute.Use(middleware.AdminAuth())
  295. {
  296. groupRoute.GET("/", controller.GetGroups)
  297. }
  298. prefillGroupRoute := apiRouter.Group("/prefill_group")
  299. prefillGroupRoute.Use(middleware.AdminAuth())
  300. {
  301. prefillGroupRoute.GET("/", controller.GetPrefillGroups)
  302. prefillGroupRoute.POST("/", controller.CreatePrefillGroup)
  303. prefillGroupRoute.PUT("/", controller.UpdatePrefillGroup)
  304. prefillGroupRoute.DELETE("/:id", controller.DeletePrefillGroup)
  305. }
  306. mjRoute := apiRouter.Group("/mj")
  307. mjRoute.GET("/self", middleware.UserAuth(), controller.GetUserMidjourney)
  308. mjRoute.GET("/", middleware.AdminAuth(), controller.GetAllMidjourney)
  309. taskRoute := apiRouter.Group("/task")
  310. {
  311. taskRoute.GET("/self", middleware.UserAuth(), controller.GetUserTask)
  312. taskRoute.GET("/", middleware.AdminAuth(), controller.GetAllTask)
  313. }
  314. vendorRoute := apiRouter.Group("/vendors")
  315. vendorRoute.Use(middleware.AdminAuth())
  316. {
  317. vendorRoute.GET("/", controller.GetAllVendors)
  318. vendorRoute.GET("/search", controller.SearchVendors)
  319. vendorRoute.GET("/:id", controller.GetVendorMeta)
  320. vendorRoute.POST("/", controller.CreateVendorMeta)
  321. vendorRoute.PUT("/", controller.UpdateVendorMeta)
  322. vendorRoute.DELETE("/:id", controller.DeleteVendorMeta)
  323. }
  324. modelsRoute := apiRouter.Group("/models")
  325. modelsRoute.Use(middleware.AdminAuth())
  326. {
  327. modelsRoute.GET("/sync_upstream/preview", controller.SyncUpstreamPreview)
  328. modelsRoute.POST("/sync_upstream", controller.SyncUpstreamModels)
  329. modelsRoute.GET("/missing", controller.GetMissingModels)
  330. modelsRoute.GET("/", controller.GetAllModelsMeta)
  331. modelsRoute.GET("/search", controller.SearchModelsMeta)
  332. modelsRoute.GET("/:id", controller.GetModelMeta)
  333. modelsRoute.POST("/", controller.CreateModelMeta)
  334. modelsRoute.PUT("/", controller.UpdateModelMeta)
  335. modelsRoute.DELETE("/:id", controller.DeleteModelMeta)
  336. }
  337. // Deployments (model deployment management)
  338. deploymentsRoute := apiRouter.Group("/deployments")
  339. deploymentsRoute.Use(middleware.AdminAuth())
  340. {
  341. deploymentsRoute.GET("/settings", controller.GetModelDeploymentSettings)
  342. deploymentsRoute.POST("/settings/test-connection", controller.TestIoNetConnection)
  343. deploymentsRoute.GET("/", controller.GetAllDeployments)
  344. deploymentsRoute.GET("/search", controller.SearchDeployments)
  345. deploymentsRoute.POST("/test-connection", controller.TestIoNetConnection)
  346. deploymentsRoute.GET("/hardware-types", controller.GetHardwareTypes)
  347. deploymentsRoute.GET("/locations", controller.GetLocations)
  348. deploymentsRoute.GET("/available-replicas", controller.GetAvailableReplicas)
  349. deploymentsRoute.POST("/price-estimation", controller.GetPriceEstimation)
  350. deploymentsRoute.GET("/check-name", controller.CheckClusterNameAvailability)
  351. deploymentsRoute.POST("/", controller.CreateDeployment)
  352. deploymentsRoute.GET("/:id", controller.GetDeployment)
  353. deploymentsRoute.GET("/:id/logs", controller.GetDeploymentLogs)
  354. deploymentsRoute.GET("/:id/containers", controller.ListDeploymentContainers)
  355. deploymentsRoute.GET("/:id/containers/:container_id", controller.GetContainerDetails)
  356. deploymentsRoute.PUT("/:id", controller.UpdateDeployment)
  357. deploymentsRoute.PUT("/:id/name", controller.UpdateDeploymentName)
  358. deploymentsRoute.POST("/:id/extend", controller.ExtendDeployment)
  359. deploymentsRoute.DELETE("/:id", controller.DeleteDeployment)
  360. }
  361. }
  362. }