-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent.go
51 lines (41 loc) · 1.22 KB
/
event.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
44
45
46
47
48
49
50
51
//go:generate go run tools/withoutctx.go
package redash
import (
"context"
"time"
"github.com/winebarrel/redash-go/v2/internal/util"
)
type EventPage struct {
Count int `json:"count"`
Page int `json:"page"`
PageSize int `json:"page_size"`
Results []Event `json:"results"`
}
type Event struct {
Action string `json:"action"`
Browser string `json:"browser"`
CreatedAt time.Time `json:"created_at"`
Details map[string]string `json:"details"`
Location string `json:"location"`
ObjectID string `json:"object_id"`
ObjectType string `json:"object_type"`
OrgID int `json:"org_id"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
}
type ListEventsInput struct {
Page int `url:"page,omitempty"`
PageSize int `url:"page_size,omitempty"`
}
func (client *Client) ListEvents(ctx context.Context, input *ListEventsInput) (*EventPage, error) {
res, close, err := client.Get(ctx, "api/events", input)
defer close()
if err != nil {
return nil, err
}
page := &EventPage{}
if err := util.UnmarshalBody(res, &page); err != nil {
return nil, err
}
return page, nil
}