-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit_logs.go
executable file
·43 lines (38 loc) · 1.09 KB
/
audit_logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package turso
import (
"encoding/json"
"fmt"
"net/http"
)
type auditLog struct {
Author string `json:"author"`
Code string `json:"code"`
CreatedAt string `json:"created_at"`
Data map[string]interface{} `json:"data"`
Message string `json:"message"`
Origin string `json:"origin"`
}
type pagination struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
TotalPages int `json:"total_pages"`
TotalRows int `json:"total_rows"`
}
type AuditLogs struct {
client *client
AuditLogs []auditLog `json:"audit_logs"`
Pagination pagination `json:"pagination"`
}
func (t *AuditLogs) List(orgSlug string) (*AuditLogs, error) {
endpoint := fmt.Sprintf("%s/v1/organizations/%s/audit-logs", tursoBaseURL, orgSlug)
resp, err := t.client.tursoAPIrequest(endpoint, http.MethodGet, nil)
if err != nil {
return nil, err
}
var auditLogs AuditLogs
if err := json.NewDecoder(resp.Body).Decode(&auditLogs); err != nil {
return nil, err
}
defer resp.Body.Close()
return &auditLogs, nil
}