/
uuidpool_block.go
74 lines (53 loc) · 1.73 KB
/
uuidpool_block.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
package models
import (
"fmt"
"github.com/beevik/etree"
)
const UuidpoolBlockClassName = "uuidpoolBlock"
type UuidpoolBlock struct {
BaseAttributes
UuidpoolBlockAttributes
}
type UuidpoolBlockAttributes struct{
Child_action string `xml:",omitempty"`
Sacl string `xml:",omitempty"`
}
func NewUuidpoolBlock(uuidpoolBlockRn,parentDn,description string, uuidpoolBlockAttributes UuidpoolBlockAttributes) *UuidpoolBlock {
dn := fmt.Sprintf("%s/%s", parentDn, uuidpoolBlockRn)
return &UuidpoolBlock{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
ClassName: UuidpoolBlockClassName,
Status: "created, modified",
Description: description,
},
UuidpoolBlockAttributes: uuidpoolBlockAttributes,
}
}
func (uuidpoolBlock *UuidpoolBlock) ToMap() (map[string]string, error) {
uuidpoolBlockMap, err := uuidpoolBlock.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
uuidpoolBlockMap["childAction"] = uuidpoolBlock.Child_action
uuidpoolBlockMap["sacl"] = uuidpoolBlock.Sacl
return uuidpoolBlockMap, nil
}
func UuidpoolBlockFromDoc(doc *etree.Document, rootClass string) *UuidpoolBlock {
element, err := GetMoElement(doc, rootClass, UuidpoolBlockClassName)
if err != nil {
return nil
}
return &UuidpoolBlock{
BaseAttributes: BaseAttributes{
DistinguishedName: element.SelectAttrValue("dn", ""),
ClassName: UuidpoolBlockClassName,
Description: element.SelectAttrValue("descr", ""),
Status: element.SelectAttrValue("status", ""),
},
UuidpoolBlockAttributes: UuidpoolBlockAttributes{
Child_action: element.SelectAttrValue("childAction", ""),
Sacl: element.SelectAttrValue("sacl", ""),
},
}
}