feat(ai): add provider connection test (#38)

This commit is contained in:
2026-11-24 16:21:48 +01:00
parent 2e865204c8
commit 54fced1ffb
16 changed files with 599 additions and 18 deletions

View File

@ -551,3 +551,22 @@ func (h *Handler) CreateAdminUser(c *gin.Context) {
}
httputil.Created(c, user)
}
// TestAIProvider returns only bounded outcomes from saved configuration.
func (h *Handler) TestAIProvider(c *gin.Context) {
err := h.connectionTester.Test(c.Request.Context(), c.Param("id"))
switch {
case err == nil:
c.JSON(200, gin.H{"status": "success"})
case errors.Is(err, ai.ErrConnectionAuth):
c.JSON(200, gin.H{"status": "auth_rejected"})
case errors.Is(err, ai.ErrConnectionUnavailable):
c.JSON(200, gin.H{"status": "unavailable"})
case errors.Is(err, ai.ErrConnectionUnsupported):
c.JSON(200, gin.H{"status": "auth_check_unsupported"})
case errors.Is(err, ai.ErrConnectionNotFound):
c.JSON(404, gin.H{"error": "not found"})
default:
c.JSON(500, gin.H{"error": "internal server error"})
}
}