-
Notifications
You must be signed in to change notification settings - Fork 0
/
os.go
95 lines (80 loc) · 1.97 KB
/
os.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 vmmanagerapi
import (
"encoding/json"
"fmt"
"github.com/gadost/go-vmmanager-api/types"
)
// OSes get os list
func (a *Api) OSes() (*types.OSList, error) {
bodyResp, err := a.NewRequest(
NilPayload,
"/os",
requestTypeGet,
DefaultService)
var t *types.OSList
json.Unmarshal(bodyResp, &t)
return t, err
}
// OSUpdate update os params
func (a *Api) OSUpdate(oid int, params *types.OSUpdateParams) (*types.Tasks, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
fmt.Sprintf("/os/%d", oid),
requestTypePost,
DefaultService)
var t *types.Tasks
json.Unmarshal(bodyResp, &t)
return t, err
}
// OSDelete delete os
func (a *Api) OSDelete(oid int) (*types.DeletedResponse, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/os/%d", oid),
requestTypeDelete,
DefaultService)
var t *types.DeletedResponse
json.Unmarshal(bodyResp, &t)
return t, err
}
// OSNodeDelete delete os on node
func (a *Api) OSNodeDelete(oid int, nid int) (*types.DeletedResponse, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/os/%d/node/%d", oid, nid),
requestTypeDelete,
DefaultService)
var t *types.DeletedResponse
json.Unmarshal(bodyResp, &t)
return t, err
}
// OSNodeDisable disable os on node
func (a *Api) OSNodeDisable(oid int, nid int) ([]byte, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/os/%d/node/%d/disable", oid, nid),
requestTypePost,
DefaultService)
return bodyResp, err
}
// OSNodeEnable enable os on node
func (a *Api) OSNodeEnable(oid int, nid int) ([]byte, error) {
bodyResp, err := a.NewRequest(
NilPayload,
fmt.Sprintf("/os/%d/node/%d/enable", oid, nid),
requestTypePost,
DefaultService)
return bodyResp, err
}
// OSesAll get all available os
func (a *Api) OSesAll() (*types.OSList, error) {
bodyResp, err := a.NewRequest(
NilPayload,
"/os/all",
requestTypeGet,
DefaultService)
var t *types.OSList
json.Unmarshal(bodyResp, &t)
return t, err
}