This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
results.go
110 lines (90 loc) · 2.62 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package instances
import "github.com/huaweicloud/golangsdk"
type Instance struct {
ID string `json:"id"`
Status string `json:"status"`
Name string `json:"name"`
Created string `json:"created"`
HostName string `json:"hostname"`
Type string `json:"type"`
Region string `json:"region"`
Updated string `json:"updated"`
AvailabilityZone string `json:"availabilityZone"`
Vpc string `json:"vpc"`
Nics NicsInfor `json:"nics"`
SecurityGroup SecurityGroupInfor `json:"securityGroup"`
Flavor FlavorInfo `json:"flavor"`
Volume VolumeInfor `json:"volume"`
DbPort int `json:"dbPort"`
DataStore DataStoreInfo `json:"dataStoreInfo"`
ExtendParameters ExtendParamInfo `json:"extendparam"`
BackupStrategy BackupStrategyInfor `json:"backupStrategy"`
Ha HaInfor `json:"ha"`
SlaveId string `json:"slaveId"`
}
type ExtendParamInfo struct {
Jobs []Job `json:"jobs"`
}
type FlavorInfo struct {
Id string `json:"id"`
}
type DataStoreInfo struct {
Type string `json:"type"`
Version string `json:"version"`
}
type VolumeInfor struct {
Type string `json:"type"`
Size int `json:"size"`
}
type NicsInfor struct {
SubnetId string `json:"subnetId"`
}
type SecurityGroupInfor struct {
Id string `json:"id"`
}
type BackupStrategyInfor struct {
StartTime string `json:"startTime"`
KeepDays int `json:"keepDays"`
}
type HaInfor struct {
Enable bool `json:"enable"`
ReplicationMode string `json:"replicationMode"`
}
type Job struct {
ID string `json:"id"`
}
// Extract will get the Instance object out of the commonResult object.
func (r commonResult) Extract() (*Instance, error) {
var s Instance
err := r.ExtractInto(&s)
return &s, err
}
func (r commonResult) ExtractInto(v interface{}) error {
return r.Result.ExtractIntoStructPtr(v, "instance")
}
type commonResult struct {
golangsdk.Result
}
// CreateResult contains the response body and error from a Create request.
type CreateResult struct {
commonResult
}
type UpdateResult struct {
commonResult
}
type DeleteResult struct {
commonResult
}
type GetResult struct {
commonResult
}
type ListResult struct {
golangsdk.Result
}
func (lr ListResult) Extract() ([]Instance, error) {
var a struct {
Instances []Instance `json:"instances"`
}
err := lr.Result.ExtractInto(&a)
return a.Instances, err
}