Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions transports/bifrost-http/handlers/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,41 +1012,6 @@ func (h *GovernanceHandler) RegisterRoutes(r *router.Router, middlewares ...sche

// getVirtualKeys handles GET /api/governance/virtual-keys - Get all virtual keys with relationships
func (h *GovernanceHandler) getVirtualKeys(ctx *fasthttp.RequestCtx) {
// Check if "from_memory" query parameter is set to true
fromMemory := string(ctx.QueryArgs().Peek("from_memory")) == "true"
if fromMemory {
data := h.governanceManager.GetGovernanceData(ctx)
if data == nil {
SendError(ctx, 500, "Governance data is not available")
return
}
// Convert map to slice to match the non-memory response format (array)
virtualKeys := make([]*configstoreTables.TableVirtualKey, 0, len(data.VirtualKeys))
for _, vk := range data.VirtualKeys {
virtualKeys = append(virtualKeys, vk)
}
sort.Slice(virtualKeys, func(i, j int) bool {
return virtualKeys[i].CreatedAt.Before(virtualKeys[j].CreatedAt)
})
byKey := buildVKModelConfigIndex(data.ModelConfigs)
hydratedVKs := make([]*configstoreTables.TableVirtualKey, len(virtualKeys))
for i, vk := range virtualKeys {
clone := *vk
pcs := make([]configstoreTables.TableVirtualKeyProviderConfig, len(vk.ProviderConfigs))
copy(pcs, vk.ProviderConfigs)
clone.ProviderConfigs = pcs
applyVKGovernanceFromModelConfigs(&clone, byKey)
hydratedVKs[i] = &clone
}
SendJSON(ctx, map[string]interface{}{
"virtual_keys": hydratedVKs,
"count": len(hydratedVKs),
"total_count": len(hydratedVKs),
"limit": len(hydratedVKs),
"offset": 0,
})
return
}
// Check for pagination/filter parameters
limitStr := string(ctx.QueryArgs().Peek("limit"))
offsetStr := string(ctx.QueryArgs().Peek("offset"))
Expand Down Expand Up @@ -1339,31 +1304,6 @@ func (h *GovernanceHandler) createVirtualKey(ctx *fasthttp.RequestCtx) {
// getVirtualKey handles GET /api/governance/virtual-keys/{vk_id} - Get a specific virtual key
func (h *GovernanceHandler) getVirtualKey(ctx *fasthttp.RequestCtx) {
vkID := ctx.UserValue("vk_id").(string)
// Check if "from_memory" query parameter is set to true
fromMemory := string(ctx.QueryArgs().Peek("from_memory")) == "true"
if fromMemory {
data := h.governanceManager.GetGovernanceData(ctx)
if data == nil {
SendError(ctx, 500, "Governance data is not available")
return
}
byKey := buildVKModelConfigIndex(data.ModelConfigs)
for _, vk := range data.VirtualKeys {
if vk.ID == vkID {
clone := *vk
pcs := make([]configstoreTables.TableVirtualKeyProviderConfig, len(vk.ProviderConfigs))
copy(pcs, vk.ProviderConfigs)
clone.ProviderConfigs = pcs
applyVKGovernanceFromModelConfigs(&clone, byKey)
SendJSON(ctx, map[string]interface{}{
"virtual_key": &clone,
})
return
}
}
SendError(ctx, 404, "Virtual key not found")
return
}
vk, err := h.configStore.GetVirtualKey(ctx, vkID)
if err != nil {
if errors.Is(err, configstore.ErrNotFound) {
Expand Down
Loading