MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / getGetUserIdsHandler

Function getGetUserIdsHandler

internal/server/web/admin/events.go:16–69  ·  view source on GitHub ↗
(m KeyReportingManager, prod bool)

Source from the content-addressed store, hash-verified

14)
15
16func getGetUserIdsHandler(m KeyReportingManager, prod bool) gin.HandlerFunc {
17 return func(c *gin.Context) {
18 log := util.GetLogFromCtx(c)
19 telemetry.Incr("bricksllm.admin.get_get_user_ids_handler.requests", nil, 1)
20
21 start := time.Now()
22 defer func() {
23 dur := time.Since(start)
24 telemetry.Timing("bricksllm.admin.get_get_user_ids_handler.latency", dur, nil, 1)
25 }()
26
27 path := "/api/reporting/user-ids"
28 if c == nil || c.Request == nil {
29 c.JSON(http.StatusInternalServerError, &ErrorResponse{
30 Type: "/errors/empty-context",
31 Title: "context is empty error",
32 Status: http.StatusInternalServerError,
33 Detail: "gin context is empty",
34 Instance: path,
35 })
36 return
37 }
38
39 kid := c.Query("keyId")
40 if len(kid) == 0 {
41 c.JSON(http.StatusBadRequest, &ErrorResponse{
42 Type: "/errors/missing-key-id",
43 Title: "key id query param is missing",
44 Status: http.StatusBadRequest,
45 Detail: "key id query is missing",
46 Instance: path,
47 })
48 return
49 }
50
51 cids, err := m.GetUserIds(kid)
52 if err != nil {
53 telemetry.Incr("bricksllm.admin.get_get_user_ids_handler.get_user_ids_err", nil, 1)
54
55 logError(log, "error when getting userIds", prod, err)
56 c.JSON(http.StatusInternalServerError, &ErrorResponse{
57 Type: "/errors/key-reporting-manager",
58 Title: "getting user ids error",
59 Status: http.StatusInternalServerError,
60 Detail: err.Error(),
61 Instance: path,
62 })
63 return
64 }
65
66 telemetry.Incr("bricksllm.admin.get_get_user_ids_handler.success", nil, 1)
67 c.JSON(http.StatusOK, cids)
68 }
69}
70
71func getGetCustomIdsHandler(m KeyReportingManager, prod bool) gin.HandlerFunc {
72 return func(c *gin.Context) {

Callers 1

NewAdminServerFunction · 0.85

Calls 6

GetLogFromCtxFunction · 0.92
IncrFunction · 0.92
TimingFunction · 0.92
logErrorFunction · 0.70
GetUserIdsMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected