MCPcopy Index your code
hub / github.com/coder/coder / AuditLogs

Method AuditLogs

codersdk/audit.go:248–274  ·  view source on GitHub ↗

AuditLogs retrieves audit logs from the given page.

(ctx context.Context, req AuditLogsRequest)

Source from the content-addressed store, hash-verified

246
247// AuditLogs retrieves audit logs from the given page.
248func (c *Client) AuditLogs(ctx context.Context, req AuditLogsRequest) (AuditLogResponse, error) {
249 res, err := c.Request(ctx, http.MethodGet, "/api/v2/audit", nil, req.Pagination.asRequestOption(), func(r *http.Request) {
250 q := r.URL.Query()
251 var params []string
252 if req.SearchQuery != "" {
253 params = append(params, req.SearchQuery)
254 }
255 q.Set("q", strings.Join(params, " "))
256 r.URL.RawQuery = q.Encode()
257 })
258 if err != nil {
259 return AuditLogResponse{}, err
260 }
261 defer res.Body.Close()
262
263 if res.StatusCode != http.StatusOK {
264 return AuditLogResponse{}, ReadBodyAsError(res)
265 }
266
267 var logRes AuditLogResponse
268 err = json.NewDecoder(res.Body).Decode(&logRes)
269 if err != nil {
270 return AuditLogResponse{}, err
271 }
272
273 return logRes, nil
274}
275
276// CreateTestAuditLog creates a fake audit log. Only owners of the organization
277// can perform this action. It's used for testing purposes.

Callers 10

TestScimFunction · 0.45
TestWorkspaceAutobuildFunction · 0.45
TestCreateGroupFunction · 0.45
TestPatchGroupFunction · 0.45
TestDeleteGroupFunction · 0.45
TestUpdateTemplateACLFunction · 0.45
TestEnterpriseAuditLogsFunction · 0.45
TestCheckInactiveUsersFunction · 0.45
TestSeatTrackerDBFunction · 0.45

Calls 6

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
EncodeMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
asRequestOptionMethod · 0.45

Tested by 10

TestScimFunction · 0.36
TestWorkspaceAutobuildFunction · 0.36
TestCreateGroupFunction · 0.36
TestPatchGroupFunction · 0.36
TestDeleteGroupFunction · 0.36
TestUpdateTemplateACLFunction · 0.36
TestEnterpriseAuditLogsFunction · 0.36
TestCheckInactiveUsersFunction · 0.36
TestSeatTrackerDBFunction · 0.36