/
get_vm_disk.go
46 lines (40 loc) · 1.06 KB
/
get_vm_disk.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
package main
import (
apiclient "github.com/Yuyz0112/cloudtower-go-sdk/client"
"github.com/Yuyz0112/cloudtower-go-sdk/client/operations"
"github.com/Yuyz0112/cloudtower-go-sdk/models"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
func strPtr(s string) *string {
return &s
}
func main() {
transport := httptransport.New("192.168.31.209", "/v2/api/", []string{"http"})
c := apiclient.New(transport, strfmt.Default)
where := &models.VMWhereInput{
NameContains: strPtr("test"),
}
getVmsParams := operations.NewGetVmsParams()
getVmsParams.RequestBody = &models.GetVmsRequestBody{
Where: where,
}
_, err := c.Operations.GetVms(getVmsParams)
if err != nil {
panic(err)
}
vmDiskWhere := &models.VMDiskWhereInput{
VM: where,
}
getVmDiskParams := operations.NewGetVMDisksParams()
getVmDiskParams.RequestBody = &models.GetVMDisksRequestBody{
Where: vmDiskWhere,
}
diskRsp, err := c.Operations.GetVMDisks(getVmDiskParams)
if err != nil {
panic(err)
}
for _, v := range diskRsp.Payload {
println(*v.ID, *v.Type)
}
}