forked from ClusterLabs/hawk-apiserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_common.go
56 lines (51 loc) · 1.7 KB
/
api_common.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 main
import "encoding/json"
//go:generate bash gen.sh
func (c *Cib) MarshalJSON() ([]byte, error) {
var struct_interface interface{}
switch c.Configuration.URLType {
case "nodes":
switch c.Configuration.Nodes.URLType {
case "all":
struct_interface = c.Configuration.Nodes.Node
case "node":
index := c.Configuration.Nodes.URLIndex
struct_interface = c.Configuration.Nodes.Node[index]
}
case "cluster":
struct_interface = c.Configuration.CrmConfig
case "resources":
switch c.Configuration.Resources.URLType {
case "all":
struct_interface = c.Configuration.Resources
case "primitive":
index := c.Configuration.Resources.URLIndex
struct_interface = c.Configuration.Resources.Primitive[index]
case "group":
index := c.Configuration.Resources.URLIndex
struct_interface = c.Configuration.Resources.Group[index]
case "clone":
index := c.Configuration.Resources.URLIndex
struct_interface = c.Configuration.Resources.Clone[index]
case "master":
index := c.Configuration.Resources.URLIndex
struct_interface = c.Configuration.Resources.Master[index]
}
case "constraints":
switch c.Configuration.Constraints.URLType {
case "all":
struct_interface = c.Configuration.Constraints
case "location":
index := c.Configuration.Constraints.URLIndex
struct_interface = c.Configuration.Constraints.RscLocation[index]
case "colocation":
index := c.Configuration.Constraints.URLIndex
struct_interface = c.Configuration.Constraints.RscColocation[index]
case "order":
index := c.Configuration.Constraints.URLIndex
struct_interface = c.Configuration.Constraints.RscOrder[index]
}
}
jsonValue, err := json.Marshal(struct_interface)
return jsonValue, err
}