forked from lusis/go-rundeck
/
nodes.go
56 lines (49 loc) · 1.53 KB
/
nodes.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
package rundeck
import "encoding/xml"
type Nodes struct {
Nodes []Node `xml:"node"`
}
// TODO: Convert to a Basic Node that just has "name,attr"
type Node struct {
XMLName xml.Name `xml:"node"`
Name string `xml:"name,attr"`
Description string `xml:"description,attr,omitempty"`
Tags string `xml:"tags,attr,omitempty"`
Hostname string `xml:"hostname,attr,omitempty"`
OsArch string `xml:"osArch,attr,omitempty"`
OsFamily string `xml:"osFamily,attr,omitempty"`
OsName string `xml:"osName,attr,omitempty"`
OsVersion string `xml:"osVersion,attr,omitempty"`
Username string `xml:"username,attr,omitempty"`
}
type NodeState struct {
XMLName xml.Name `xml:"nodeState"`
Name string `xml:"name,attr"`
StartTime string `xml:"startTime"`
UpdateTime string `xml:"updateTime"`
EndTime string `xml:"endTime"`
ExecutionState string `xml:"executionState"`
}
type NodeStep struct {
XMLName xml.Name `xml:"step"`
StepCtx int64 `xml:"stepctx"`
ExecutionState string `xml:"executionState"`
}
type NodeWithSteps struct {
XMLName xml.Name `xml:"node"`
Name string `xml:"name,attr"`
Steps []NodeStep `xml:"steps>step"`
}
func (c *RundeckClient) ListNodes(projectId string) (Nodes, error) {
options := make(map[string]string)
options["project"] = projectId
var res []byte
var data Nodes
err := c.Get(&res, "resources", options)
if err != nil {
return data, err
} else {
xml.Unmarshal(res, &data)
return data, nil
}
}