-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.go
99 lines (83 loc) · 2.38 KB
/
platform.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
package vmmanagerapi
import (
"encoding/json"
"fmt"
"github.com/gadost/go-vmmanager-api/types"
)
// PlatformBackup get platform backup params
func (a *Api) PlatformBackup(bid int) ([]byte, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/platform/backup/%d", bid),
requestTypeGet,
DefaultService)
return bodyResp, err
}
// PlatformBackupInfo get platform backup info
func (a *Api) PlatformBackupInfo(bid int) ([]byte, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/platform/backup/%d/info", bid),
requestTypeGet,
DefaultService)
return bodyResp, err
}
// PlatformBackupSchedule return liost of scheduled platform backups
func (a *Api) PlatformBackupSchedule() (*types.PlatformBackupSchedule, error) {
bodyResp, err := a.NewRequest(
NilPayload,
"/platform/backup/schedule",
requestTypeGet,
DefaultService)
var t *types.PlatformBackupSchedule
json.Unmarshal(bodyResp, &t)
return t, err
}
// PlatformBackupScheduleNew schedule new platform backup
func (a *Api) PlatformBackupScheduleNew(
params *types.PlatformBackupScheduleRequest) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
"/platform/backup/schedule",
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// PlatformBackupScheduleUpdate update scheduled platform backup
func (a *Api) PlatformBackupScheduleUpdate(scid int,
params *types.PlatformBackupScheduleRequest) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
fmt.Sprintf("/platform/backup/schedule/%d", scid),
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// PlatformBackupScheduleRun start scheduled platform backup
func (a *Api) PlatformBackupScheduleRun(scid int) (*types.ID, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/platform/backup/schedule/%d", scid),
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// PlatformBackupScheduleDelete delete scheduled platform backup
func (a *Api) PlatformBackupScheduleDelete(scid int) (*types.ID, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/platform/backup/schedule/%d", scid),
requestTypeDelete,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}