(m KeyReportingManager, prod bool)
| 125 | } |
| 126 | |
| 127 | func getGetEventsHandler(m KeyReportingManager, prod bool) gin.HandlerFunc { |
| 128 | return func(c *gin.Context) { |
| 129 | log := util.GetLogFromCtx(c) |
| 130 | telemetry.Incr("bricksllm.admin.get_get_events_handler.requests", nil, 1) |
| 131 | |
| 132 | start := time.Now() |
| 133 | defer func() { |
| 134 | dur := time.Since(start) |
| 135 | telemetry.Timing("bricksllm.admin.get_get_events_handler.latency", dur, nil, 1) |
| 136 | }() |
| 137 | |
| 138 | path := "/api/events" |
| 139 | |
| 140 | if c == nil || c.Request == nil { |
| 141 | c.JSON(http.StatusInternalServerError, &ErrorResponse{ |
| 142 | Type: "/errors/empty-context", |
| 143 | Title: "context is empty error", |
| 144 | Status: http.StatusInternalServerError, |
| 145 | Detail: "gin context is empty", |
| 146 | Instance: path, |
| 147 | }) |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | customId, ciok := c.GetQuery("customId") |
| 152 | userId, uiok := c.GetQuery("userId") |
| 153 | keyIds, kiok := c.GetQueryArray("keyIds") |
| 154 | if !ciok && !kiok && !uiok { |
| 155 | c.JSON(http.StatusBadRequest, &ErrorResponse{ |
| 156 | Type: "/errors/no-filters-empty", |
| 157 | Title: "none of customId, keyIds and userId is specified", |
| 158 | Status: http.StatusBadRequest, |
| 159 | Detail: "customId, userId and keyIds are empty. one of them is required for retrieving events.", |
| 160 | Instance: path, |
| 161 | }) |
| 162 | |
| 163 | return |
| 164 | } |
| 165 | |
| 166 | var qstart int64 = 0 |
| 167 | var qend int64 = 0 |
| 168 | |
| 169 | if kiok { |
| 170 | startstr, sok := c.GetQuery("start") |
| 171 | if !sok { |
| 172 | c.JSON(http.StatusBadRequest, &ErrorResponse{ |
| 173 | Type: "/errors/query-param-start-missing", |
| 174 | Title: "query param start is missing", |
| 175 | Status: http.StatusBadRequest, |
| 176 | Detail: "start query param is not provided", |
| 177 | Instance: path, |
| 178 | }) |
| 179 | |
| 180 | return |
| 181 | } |
| 182 | |
| 183 | parsedStart, err := strconv.ParseInt(startstr, 10, 64) |
| 184 | if err != nil { |
no test coverage detected