Go handlers, models, stores and migrations for all SDK modules. Updates developer portal navigation and BYOEH page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
2.2 KiB
Go
81 lines
2.2 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/breakpilot/ai-compliance-sdk/internal/rbac"
|
|
"github.com/breakpilot/ai-compliance-sdk/internal/reporting"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ReportingHandlers struct {
|
|
store *reporting.Store
|
|
}
|
|
|
|
func NewReportingHandlers(store *reporting.Store) *ReportingHandlers {
|
|
return &ReportingHandlers{store: store}
|
|
}
|
|
|
|
// GetExecutiveReport generates a comprehensive compliance report
|
|
// GET /sdk/v1/reporting/executive
|
|
func (h *ReportingHandlers) GetExecutiveReport(c *gin.Context) {
|
|
tenantID := rbac.GetTenantID(c)
|
|
|
|
report, err := h.store.GenerateReport(c.Request.Context(), tenantID)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, report)
|
|
}
|
|
|
|
// GetComplianceScore returns just the overall compliance score
|
|
// GET /sdk/v1/reporting/score
|
|
func (h *ReportingHandlers) GetComplianceScore(c *gin.Context) {
|
|
tenantID := rbac.GetTenantID(c)
|
|
|
|
report, err := h.store.GenerateReport(c.Request.Context(), tenantID)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"compliance_score": report.ComplianceScore,
|
|
"risk_level": report.RiskOverview.OverallLevel,
|
|
"generated_at": report.GeneratedAt,
|
|
})
|
|
}
|
|
|
|
// GetUpcomingDeadlines returns deadlines across all modules
|
|
// GET /sdk/v1/reporting/deadlines
|
|
func (h *ReportingHandlers) GetUpcomingDeadlines(c *gin.Context) {
|
|
tenantID := rbac.GetTenantID(c)
|
|
|
|
report, err := h.store.GenerateReport(c.Request.Context(), tenantID)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"deadlines": report.UpcomingDeadlines,
|
|
"total": len(report.UpcomingDeadlines),
|
|
})
|
|
}
|
|
|
|
// GetRiskOverview returns the aggregated risk assessment
|
|
// GET /sdk/v1/reporting/risks
|
|
func (h *ReportingHandlers) GetRiskOverview(c *gin.Context) {
|
|
tenantID := rbac.GetTenantID(c)
|
|
|
|
report, err := h.store.GenerateReport(c.Request.Context(), tenantID)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, report.RiskOverview)
|
|
}
|