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
127 lines (105 loc) · 3.17 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package instances
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/pagination"
)
type GaussDBResponse struct {
Id string `json:"id"`
Status string `json:"status"`
}
type CreateResponse struct {
Instance GaussDBResponse `json:"instance"`
}
type GaussDBInstance struct {
Id string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Type string `json:"type"`
Port int `json:"port"`
VpcId string `json:"vpc_id"`
SubnetId string `json:"subnet_id"`
SecurityGroupId string `json:"security_group_id"`
TimeZone string `json:"time_zone"`
Region string `json:"region"`
FlavorRef string `json:"flavor_ref"`
DbUserName string `json:"db_user_name"`
DiskEncryptionId string `json:"disk_encryption_id"`
DsspoolId string `json:"dsspool_id"`
SwitchStrategy string `json:"switch_strategy"`
MaintenanceWindow string `json:"maintenance_window"`
PublicIps []string `json:"public_ips"`
PrivateIps []string `json:"private_ips"`
Volume VolumeOpt `json:"volume"`
Ha HaOpt `json:"ha"`
Nodes []Nodes `json:"nodes"`
DataStore DataStoreOpt `json:"datastore"`
BackupStrategy BackupStrategyOpt `json:"backup_strategy"`
EnterpriseProjectId string `json:"enterprise_project_id"`
}
type Nodes struct {
Id string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Role string `json:"role"`
AvailabilityZone string `json:"availability_zone"`
}
type commonResult struct {
golangsdk.Result
}
type CreateResult struct {
commonResult
}
type UpdateResult struct {
commonResult
}
func (r CreateResult) Extract() (*CreateResponse, error) {
var response CreateResponse
err := r.ExtractInto(&response)
return &response, err
}
type DeleteResult struct {
commonResult
}
type DeleteResponse struct {
JobId string `json:"job_id"`
}
func (r DeleteResult) Extract() (*DeleteResponse, error) {
var response DeleteResponse
err := r.ExtractInto(&response)
return &response, err
}
type ListGaussDBResult struct {
commonResult
}
type ListGaussDBResponse struct {
Instances []GaussDBInstance `json:"instances"`
TotalCount int `json:"total_count"`
}
type GaussDBPage struct {
pagination.SinglePageBase
}
func (r GaussDBPage) IsEmpty() (bool, error) {
data, err := ExtractGaussDBInstances(r)
if err != nil {
return false, err
}
return len(data.Instances) == 0, err
}
// ExtractGaussDBInstances is a function that takes a ListResult and returns the services' information.
func ExtractGaussDBInstances(r pagination.Page) (ListGaussDBResponse, error) {
var s ListGaussDBResponse
err := (r.(GaussDBPage)).ExtractInto(&s)
return s, err
}
type RenameResponse struct {
Instance GaussDBResponse `json:"instance"`
JobId string `json:"job_id"`
}
type RenameResult struct {
commonResult
}
func (r RenameResult) Extract() (*RenameResponse, error) {
var response RenameResponse
err := r.ExtractInto(&response)
return &response, err
}