-
Notifications
You must be signed in to change notification settings - Fork 7
/
results.go
78 lines (66 loc) · 1.8 KB
/
results.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
package block_devices
import (
"encoding/json"
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud"
)
// VolumeAttachment is the structure of the detail of disk mounting.
type VolumeAttachment struct {
// Specifies the ECS ID in UUID format.
ServerId string `json:"serverId"`
// Specifies the EVS disk ID in UUID format.
VolumeId string `json:"volumeId"`
// Specifies the mount ID, which is the same as the EVS disk ID.
// The value is in UUID format.
Id string `json:"id"`
// Specifies the drive letter of the EVS disk, which is the device name of the EVS disk.
Device string `json:"device"`
// Specifies the PCI address.
PciAddress string `json:"pciAddress"`
// Specifies the EVS disk size in GB.
Size int `json:"size"`
// Specifies the EVS disk boot sequence.
// 0 indicates the system disk.
// Non-0 indicates a data disk.
BootIndex int `json:"bootIndex"`
// Specifies the disk bus type.
// Options: virtio and scsi
BusType string `json:"bus"`
}
func (r *VolumeAttachment) UnmarshalJSON(b []byte) error {
type tmp VolumeAttachment
var s struct {
tmp
BootIndex interface{} `json:"bootIndex"`
}
err := json.Unmarshal(b, &s)
if err != nil {
return err
}
*r = VolumeAttachment(s.tmp)
if s.BootIndex == nil {
r.BootIndex = -1
} else {
r.BootIndex = int(s.BootIndex.(float64))
}
return err
}
type GetResult struct {
golangsdk.Result
}
func (r GetResult) Extract() (*VolumeAttachment, error) {
s := &VolumeAttachment{}
return s, r.ExtractInto(s)
}
func (r GetResult) ExtractInto(v interface{}) error {
return r.Result.ExtractIntoStructPtr(v, "volumeAttachment")
}
type ErrorResponse struct {
// Response error.
Error Error `json:"error"`
}
type Error struct {
// Error code.
Code string `json:"code"`
// Error message.
Message string `json:"message"`
}