-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataSource.gen.go
92 lines (73 loc) · 2.21 KB
/
DataSource.gen.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This is a generated file. DO NOT EDIT manually.
//go:generate goimports -w DataSource.gen.go
package go_xen_client
import (
"reflect"
"github.com/nilshell/xmlrpc"
)
//DataSource: Data sources for logging in RRDs
type DataSource struct {
NameLabel string // a human-readable name
NameDescription string // a notes field containing human-readable description
Enabled bool // true if the data source is being logged
Standard bool // true if the data source is enabled by default. Non-default data sources cannot be disabled
Units string // the units of the value
Min float32 // the minimum value of the data source
Max float32 // the maximum value of the data source
Value float32 // current value of the data source
}
func FromDataSourceToXml(data_source *DataSource) (result xmlrpc.Struct) {
result = make(xmlrpc.Struct)
result["name_label"] = data_source.NameLabel
result["name_description"] = data_source.NameDescription
result["enabled"] = data_source.Enabled
result["standard"] = data_source.Standard
result["units"] = data_source.Units
result["min"] = data_source.Min
result["max"] = data_source.Max
result["value"] = data_source.Value
return result
}
func ToDataSource(obj interface{}) (resultObj *DataSource) {
objValue := reflect.ValueOf(obj)
resultObj = &DataSource{}
for _, oKey := range objValue.MapKeys() {
keyName := oKey.String()
keyValue := objValue.MapIndex(oKey).Interface()
switch keyName {
case "name_label":
if v, ok := keyValue.(string); ok {
resultObj.NameLabel = v
}
case "name_description":
if v, ok := keyValue.(string); ok {
resultObj.NameDescription = v
}
case "enabled":
if v, ok := keyValue.(bool); ok {
resultObj.Enabled = v
}
case "standard":
if v, ok := keyValue.(bool); ok {
resultObj.Standard = v
}
case "units":
if v, ok := keyValue.(string); ok {
resultObj.Units = v
}
case "min":
if v, ok := keyValue.(float32); ok {
resultObj.Min = v
}
case "max":
if v, ok := keyValue.(float32); ok {
resultObj.Max = v
}
case "value":
if v, ok := keyValue.(float32); ok {
resultObj.Value = v
}
}
}
return resultObj
}