forked from lusis/go-rundeck
-
Notifications
You must be signed in to change notification settings - Fork 1
/
history.go
50 lines (46 loc) · 1.32 KB
/
history.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
package rundeck
import "encoding/xml"
type Events struct {
XMLName xml.Name `xml:"events"`
Count int64 `xml:"count,attr"`
Total int64 `xml:"total,attr"`
Max int64 `xml:"max,attr"`
Offset int64 `xml:"offset,attr"`
Events []Event `xml:"event"`
}
type Event struct {
XMLName xml.Name `xml:"event"`
StartTime string `xml:"starttime,attr"`
EndTime string `xml:"endtime,attr"`
Title string `xml:"title"`
Status string `xml:"status"`
Summary string `xml:"summary"`
NodeSummary struct {
XMLName xml.Name
Succeeded int64 `xml:"succeeded,attr"`
Failed int64 `xml:"failed,attr"`
Total int64 `xml:"total,attr"`
} `xml:"node-summary"`
User string `xml:"user"`
Project string `xml:"project"`
DateStarted string `xml:"date-started"`
DateEnded string `xml:"date-ended"`
AbortedBy string `xml:"abortedby,omitempty"`
Job *struct {
XMLName xml.Name
ID string `xml:"id,attr"`
} `xml:"job,omitempty"`
Execution struct {
XMLName xml.Name
ID int64 `xml:"id,attr"`
} `xml:"execution,omitempty"`
}
func (c *RundeckClient) GetHistory(project string) (Events, error) {
u := make(map[string]string)
u["project"] = project
var data Events
var res []byte
err := c.Get(&res, "history", u)
xml.Unmarshal(res, &data)
return data, err
}