-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport.go
77 lines (65 loc) · 1.75 KB
/
import.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
package vmmanagerapi
import (
"encoding/json"
"fmt"
"github.com/gadost/go-vmmanager-api/types"
)
// ImportHistory import history
func (a *Api) ImportHistory() (*types.ImportHistoryResponse, error) {
bodyResp, err := a.NewRequest(
NilPayload,
"/import_history",
requestTypeGet,
DefaultService)
var t *types.ImportHistoryResponse
json.Unmarshal(bodyResp, &t)
return t, err
}
// ImportHistoryNew create new history entry
func (a *Api) ImportHistoryNew(params *types.ImportHistoryRequest) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
"/import_history",
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// ImportHistoryUpdate update history entry
func (a *Api) ImportHistoryUpdate(hsid int, params *types.State) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
fmt.Sprintf("/import_history/%d", hsid),
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// ImportHistoryResult returns history results
func (a *Api) ImportHistoryResult(hsid int, params *types.ImportHistoryResult) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
fmt.Sprintf("/import_history/%d/result", hsid),
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}
// ImportCluster import cluster
func (a *Api) ImportCluster(hsid int, params *types.ImportClusterParams) (*types.ID, error) {
payload, _ := json.Marshal(params)
bodyResp, err := a.NewRequest(
payload,
"/import/cluster",
requestTypePost,
DefaultService)
var t *types.ID
json.Unmarshal(bodyResp, &t)
return t, err
}