-
Notifications
You must be signed in to change notification settings - Fork 5
/
logs.go
49 lines (45 loc) · 1.16 KB
/
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
44
45
46
47
48
49
package oneandone
import (
"net/http"
"time"
)
type Log struct {
ApiPtr
idField
typeField
SiteId string `json:"site_id,omitempty"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
Action string `json:"action,omitempty"`
Duration int `json:"duration"`
Status *Status `json:"Status,omitempty"`
Resource *Identity `json:"resource,omitempty"`
User *Identity `json:"user,omitempty"`
}
// GET /logs
func (api *API) ListLogs(period string, sd *time.Time, ed *time.Time, args ...interface{}) ([]Log, error) {
result := []Log{}
url, err := processQueryParamsExt(createUrl(api, logPathSegment), period, sd, ed, args...)
if err != nil {
return nil, err
}
err = api.Client.Get(url, &result, http.StatusOK)
if err != nil {
return nil, err
}
for index, _ := range result {
result[index].api = api
}
return result, nil
}
// GET /logs/{id}
func (api *API) GetLog(log_id string) (*Log, error) {
result := new(Log)
url := createUrl(api, logPathSegment, log_id)
err := api.Client.Get(url, &result, http.StatusOK)
if err != nil {
return nil, err
}
result.api = api
return result, nil
}