MCPcopy Create free account
hub / github.com/53AI/53AIHub / ListAPIKeys

Method ListAPIKeys

api/service/mcp/key_service.go:76–96  ·  view source on GitHub ↗
(ctx context.Context, eid, userID int64, role int64, keyType string, libraryID *int64)

Source from the content-addressed store, hash-verified

74}
75
76func (s *APIKeyService) ListAPIKeys(ctx context.Context, eid, userID int64, role int64, keyType string, libraryID *int64) ([]model.APIKey, error) {
77 if libraryID != nil {
78 if _, err := s.resolveAPIKeyScope(eid, userID, role, libraryID); err != nil {
79 return nil, err
80 }
81 return model.GetAPIKeysByEidAndLibraryID(eid, *libraryID)
82 }
83
84 if role < model.RoleAdminUser {
85 return []model.APIKey{}, nil
86 }
87
88 switch keyType {
89 case "", "library":
90 return model.GetAPIKeysByEidWithLibrary(eid)
91 case "personal":
92 return model.GetAPIKeysByEidAndCreatorIDWithoutLibrary(eid, userID)
93 default:
94 return nil, errors.New("无效的API密钥类型参数")
95 }
96}
97
98func (s *APIKeyService) DeleteAPIKey(ctx context.Context, eid, userID int64, role int64, keyID int64, libraryID *int64) error {
99 apiKey, err := model.GetAPIKeyByID(keyID)

Callers 1

GetAPIKeysMethod · 0.95

Calls 2

resolveAPIKeyScopeMethod · 0.95
NewMethod · 0.45

Tested by

no test coverage detected