-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathftp.go
95 lines (71 loc) · 2.06 KB
/
ftp.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
package maestropanel
import (
"encoding/json"
)
type FTPAccount struct {
DomainName string `json:"name"`
Account string `json:"account"`
Password string `json:"password"`
HomePath string `json:"homePath"`
ReadOnly string `json:"ronly"`
}
type ChangeFTPAccountPassword struct {
DomainName string `json:"name"`
Account string `json:"account"`
NewPassword string `json:"newpassword"`
SuppressPasswordPolicy bool `json:"suppress_password_policy"`
}
type FTPUsers struct {
Users []FTPAccount
}
type GetFTPAccountsResult struct {
Result
Details FTPUsers
}
type FTP struct {
mp MaestroPanel
}
func (m *FTP) AddFtpAccount(ftpAccount FTPAccount) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
response, err := m.mp.writeData(addFtpAccountAction.Method, m.mp.getURL(addFtpAccountAction), ftpAccount)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *FTP) DeleteFtpAccount(domainName string, account string) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
extra := struct {
Name string `json:"name"`
Account string `json:"account"`
}{
domainName,
account,
}
response, err := m.mp.writeData(deleteFtpAccountAction.Method, m.mp.getURL(deleteFtpAccountAction), extra)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *FTP) ChangeFTPAccountPassword(model ChangeFTPAccountPassword) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
response, err := m.mp.writeData(changeFtpAccountPasswordAction.Method, m.mp.getURL(changeFtpAccountPasswordAction), model)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *FTP) GetFTPAccounts(domainName string) (result GetFTPAccountsResult, err error) {
result = GetFTPAccountsResult{}
extra := struct {
Name string `json:"name"`
}{
domainName,
}
response, err := m.mp.writeData(getFtpAccountsAction.Method, m.mp.getURL(getFtpAccountsAction), extra)
if err == nil {
json.Unmarshal(response, &result)
}
return
}