-
Notifications
You must be signed in to change notification settings - Fork 7
/
event.go
66 lines (53 loc) · 1.61 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package gsclient
import (
"context"
"net/http"
)
//EventList is JSON struct of a list of events
type EventList struct {
//Array of events
List []EventProperties `json:"events"`
}
//Event is JSOn struct of a single firewall's event
type Event struct {
//Properties of an event
Properties EventProperties `json:"event"`
}
//EventProperties is JSON struct of an event properties
type EventProperties struct {
//Type of object (server, storage, IP) etc
ObjectType string `json:"object_type"`
//The UUID of the event
RequestUUID string `json:"request_uuid"`
//The UUID of the objects the event was executed on
ObjectUUID string `json:"object_uuid"`
//The type of change
Activity string `json:"activity"`
//The type of request
RequestType string `json:"request_type"`
//True or false, whether the request was successful or not
RequestStatus string `json:"request_status"`
//A detailed description of the change.
Change string `json:"change"`
//Time the event was triggered
Timestamp GSTime `json:"timestamp"`
//The UUID of the user that triggered the event
UserUUID string `json:"user_uuid"`
}
//GetEventList gets a list of events
//
//See: https://gridscale.io/en//api-documentation/index.html#operation/EventGetAll
func (c *Client) GetEventList(ctx context.Context) ([]Event, error) {
r := request{
uri: apiEventBase,
method: http.MethodGet,
skipCheckingRequest: true,
}
var response EventList
var events []Event
err := r.execute(ctx, *c, &response)
for _, properties := range response.List {
events = append(events, Event{Properties: properties})
}
return events, err
}