MCPcopy Index your code
hub / github.com/tbphp/gpt-load / ListKeysInGroup

Method ListKeysInGroup

internal/handler/key_handler.go:194–238  ·  view source on GitHub ↗

ListKeysInGroup handles listing all keys within a specific group with pagination.

(c *gin.Context)

Source from the content-addressed store, hash-verified

192
193// ListKeysInGroup handles listing all keys within a specific group with pagination.
194func (s *Server) ListKeysInGroup(c *gin.Context) {
195 groupID, ok := validateGroupIDFromQuery(c)
196 if !ok {
197 return
198 }
199
200 if _, ok := s.findGroupByID(c, groupID); !ok {
201 return
202 }
203
204 statusFilter := c.Query("status")
205 if statusFilter != "" && statusFilter != models.KeyStatusActive && statusFilter != models.KeyStatusInvalid {
206 response.ErrorI18nFromAPIError(c, app_errors.ErrValidation, "validation.invalid_status_filter")
207 return
208 }
209
210 searchKeyword := c.Query("key_value")
211 searchHash := ""
212 if searchKeyword != "" {
213 searchHash = s.EncryptionSvc.Hash(searchKeyword)
214 }
215
216 query := s.KeyService.ListKeysInGroupQuery(groupID, statusFilter, searchHash)
217
218 var keys []models.APIKey
219 paginatedResult, err := response.Paginate(c, query, &keys)
220 if err != nil {
221 response.Error(c, app_errors.ParseDBError(err))
222 return
223 }
224
225 // Decrypt all keys for display
226 for i := range keys {
227 decryptedValue, err := s.EncryptionSvc.Decrypt(keys[i].KeyValue)
228 if err != nil {
229 logrus.WithError(err).WithField("key_id", keys[i].ID).Error("Failed to decrypt key value for listing")
230 keys[i].KeyValue = "failed-to-decrypt"
231 } else {
232 keys[i].KeyValue = decryptedValue
233 }
234 }
235 paginatedResult.Items = keys
236
237 response.Success(c, paginatedResult)
238}
239
240// DeleteMultipleKeys handles deleting keys from a text block within a specific group.
241func (s *Server) DeleteMultipleKeys(c *gin.Context) {

Callers

nothing calls this directly

Calls 10

findGroupByIDMethod · 0.95
ErrorI18nFromAPIErrorFunction · 0.92
PaginateFunction · 0.92
ErrorFunction · 0.92
SuccessFunction · 0.92
validateGroupIDFromQueryFunction · 0.85
ListKeysInGroupQueryMethod · 0.80
HashMethod · 0.65
DecryptMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected