forked from lusis/go-rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.go
61 lines (54 loc) · 1.73 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
57
58
59
60
61
package rundeck
import "encoding/xml"
// Nodes is a collection of `Node`
type Nodes struct {
Nodes []Node `xml:"node"`
}
// Node represents a 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"`
}
// NodeState represents a node's state
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"`
}
// NodeStep represents a node step
type NodeStep struct {
XMLName xml.Name `xml:"step"`
StepCtx int64 `xml:"stepctx"`
ExecutionState string `xml:"executionState"`
}
// NodeWithSteps represents a node with its steps
type NodeWithSteps struct {
XMLName xml.Name `xml:"node"`
Name string `xml:"name,attr"`
Steps []NodeStep `xml:"steps>step"`
}
// ListNodes lists nodes
func (c *Client) 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
}
xmlErr := xml.Unmarshal(res, &data)
return data, xmlErr
}