MCPcopy Create free account
hub / github.com/tbphp/gpt-load / ValidateGroupKeys

Method ValidateGroupKeys

internal/handler/key_handler.go:372–403  ·  view source on GitHub ↗

ValidateGroupKeys initiates a manual validation task for all keys in a group.

(c *gin.Context)

Source from the content-addressed store, hash-verified

370
371// ValidateGroupKeys initiates a manual validation task for all keys in a group.
372func (s *Server) ValidateGroupKeys(c *gin.Context) {
373 var req ValidateGroupKeysRequest
374 if err := c.ShouldBindJSON(&req); err != nil {
375 response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error()))
376 return
377 }
378
379 // Validate status if provided
380 if req.Status != "" && req.Status != models.KeyStatusActive && req.Status != models.KeyStatusInvalid {
381 response.ErrorI18nFromAPIError(c, app_errors.ErrValidation, "validation.invalid_status_value")
382 return
383 }
384
385 groupDB, ok := s.findGroupByID(c, req.GroupID)
386 if !ok {
387 return
388 }
389
390 group, err := s.GroupManager.GetGroupByName(groupDB.Name)
391 if err != nil {
392 response.ErrorI18nFromAPIError(c, app_errors.ErrResourceNotFound, "validation.group_not_found")
393 return
394 }
395
396 taskStatus, err := s.KeyManualValidationService.StartValidationTask(group, req.Status)
397 if err != nil {
398 response.Error(c, app_errors.NewAPIError(app_errors.ErrTaskInProgress, err.Error()))
399 return
400 }
401
402 response.Success(c, taskStatus)
403}
404
405// RestoreAllInvalidKeys sets the status of all 'inactive' keys in a group to 'active'.
406func (s *Server) RestoreAllInvalidKeys(c *gin.Context) {

Callers

nothing calls this directly

Calls 7

findGroupByIDMethod · 0.95
ErrorFunction · 0.92
ErrorI18nFromAPIErrorFunction · 0.92
SuccessFunction · 0.92
GetGroupByNameMethod · 0.80
StartValidationTaskMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected