-
Notifications
You must be signed in to change notification settings - Fork 30
/
file_remote_path.go
120 lines (110 loc) · 4.53 KB
/
file_remote_path.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const (
DnfileRemotePath = "uni/fabric/path-%s"
RnfileRemotePath = "path-%s"
ParentDnfileRemotePath = "uni/fabric"
FileremotepathClassName = "fileRemotePath"
)
type RemotePathofaFile struct {
BaseAttributes
NameAliasAttribute
RemotePathofaFileAttributes
}
type RemotePathofaFileAttributes struct {
Annotation string `json:",omitempty"`
AuthType string `json:",omitempty"`
Host string `json:",omitempty"`
IdentityPrivateKeyContents string `json:",omitempty"`
IdentityPrivateKeyPassphrase string `json:",omitempty"`
Name string `json:",omitempty"`
Protocol string `json:",omitempty"`
RemotePath string `json:",omitempty"`
RemotePort string `json:",omitempty"`
UserName string `json:",omitempty"`
UserPasswd string `json:",omitempty"`
}
func NewRemotePathofaFile(fileRemotePathRn, parentDn, description, nameAlias string, fileRemotePathAttr RemotePathofaFileAttributes) *RemotePathofaFile {
dn := fmt.Sprintf("%s/%s", parentDn, fileRemotePathRn)
return &RemotePathofaFile{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FileremotepathClassName,
Rn: fileRemotePathRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
RemotePathofaFileAttributes: fileRemotePathAttr,
}
}
func (fileRemotePath *RemotePathofaFile) ToMap() (map[string]string, error) {
fileRemotePathMap, err := fileRemotePath.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := fileRemotePath.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(fileRemotePathMap, key, value)
}
A(fileRemotePathMap, "annotation", fileRemotePath.Annotation)
A(fileRemotePathMap, "authType", fileRemotePath.AuthType)
A(fileRemotePathMap, "host", fileRemotePath.Host)
A(fileRemotePathMap, "identityPrivateKeyContents", fileRemotePath.IdentityPrivateKeyContents)
A(fileRemotePathMap, "identityPrivateKeyPassphrase", fileRemotePath.IdentityPrivateKeyPassphrase)
A(fileRemotePathMap, "name", fileRemotePath.Name)
A(fileRemotePathMap, "protocol", fileRemotePath.Protocol)
A(fileRemotePathMap, "remotePath", fileRemotePath.RemotePath)
A(fileRemotePathMap, "remotePort", fileRemotePath.RemotePort)
A(fileRemotePathMap, "userName", fileRemotePath.UserName)
A(fileRemotePathMap, "userPasswd", fileRemotePath.UserPasswd)
return fileRemotePathMap, err
}
func RemotePathofaFileFromContainerList(cont *container.Container, index int) *RemotePathofaFile {
RemotePathofaFileCont := cont.S("imdata").Index(index).S(FileremotepathClassName, "attributes")
return &RemotePathofaFile{
BaseAttributes{
DistinguishedName: G(RemotePathofaFileCont, "dn"),
Description: G(RemotePathofaFileCont, "descr"),
Status: G(RemotePathofaFileCont, "status"),
ClassName: FileremotepathClassName,
Rn: G(RemotePathofaFileCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(RemotePathofaFileCont, "nameAlias"),
},
RemotePathofaFileAttributes{
Annotation: G(RemotePathofaFileCont, "annotation"),
AuthType: G(RemotePathofaFileCont, "authType"),
Host: G(RemotePathofaFileCont, "host"),
IdentityPrivateKeyContents: G(RemotePathofaFileCont, "identityPrivateKeyContents"),
IdentityPrivateKeyPassphrase: G(RemotePathofaFileCont, "identityPrivateKeyPassphrase"),
Name: G(RemotePathofaFileCont, "name"),
Protocol: G(RemotePathofaFileCont, "protocol"),
RemotePath: G(RemotePathofaFileCont, "remotePath"),
RemotePort: G(RemotePathofaFileCont, "remotePort"),
UserName: G(RemotePathofaFileCont, "userName"),
UserPasswd: G(RemotePathofaFileCont, "userPasswd"),
},
}
}
func RemotePathofaFileFromContainer(cont *container.Container) *RemotePathofaFile {
return RemotePathofaFileFromContainerList(cont, 0)
}
func RemotePathofaFileListFromContainer(cont *container.Container) []*RemotePathofaFile {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*RemotePathofaFile, length)
for i := 0; i < length; i++ {
arr[i] = RemotePathofaFileFromContainerList(cont, i)
}
return arr
}