github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rds/v3/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/openstack/common/tags" 6 "github.com/huaweicloud/golangsdk/pagination" 7 ) 8 9 type commonResult struct { 10 golangsdk.Result 11 } 12 13 type CreateResult struct { 14 commonResult 15 } 16 17 type DeleteResult struct { 18 commonResult 19 } 20 21 type RestartResult struct { 22 commonResult 23 } 24 25 type RenameResult struct { 26 commonResult 27 } 28 29 type SingleToHaResult struct { 30 commonResult 31 } 32 33 type ResizeFlavorResult struct { 34 commonResult 35 } 36 37 type EnlargeVolumeResult struct { 38 commonResult 39 } 40 41 type Instance struct { 42 Id string `json:"id"` 43 Name string `json:"name"` 44 Status string `json:"status"` 45 Datastore Datastore `json:"datastore"` 46 Ha Ha `json:"ha"` 47 ConfigurationId string `json:"configuration_id"` 48 Port string `json:"port"` 49 BackupStrategy BackupStrategy `json:"backup_strategy"` 50 EnterpriseProjectId string `json:"enterprise_project_id"` 51 DiskEncryptionId string `json:"disk_encryption_id"` 52 FlavorRef string `json:"flavor_ref"` 53 Volume Volume `json:"volume"` 54 Region string `json:"region"` 55 AvailabilityZone string `json:"availability_zone"` 56 VpcId string `json:"vpc_id"` 57 SubnetId string `json:"subnet_id"` 58 SecurityGroupId string `json:"security_group_id"` 59 ChargeInfo ChargeResponse `json:"charge_info"` 60 } 61 62 type ChargeResponse struct { 63 ChargeMode string `json:"charge_mode"` 64 } 65 66 type CreateResponse struct { 67 Instance Instance `json:"instance"` 68 JobId string `json:"job_id"` 69 OrderId string `json:"order_id"` 70 } 71 72 func (r CreateResult) Extract() (*CreateResponse, error) { 73 var response CreateResponse 74 err := r.ExtractInto(&response) 75 return &response, err 76 } 77 78 type DeleteResponse struct { 79 JobId string `json:"job_id"` 80 } 81 82 func (r DeleteResult) Extract() (*DeleteResponse, error) { 83 var response DeleteResponse 84 err := r.ExtractInto(&response) 85 return &response, err 86 } 87 88 type RestartResponse struct { 89 JobId string `json:"job_id"` 90 } 91 92 func (r RestartResult) Extract() (*RestartResponse, error) { 93 var response RestartResponse 94 err := r.ExtractInto(&response) 95 return &response, err 96 } 97 98 type SingleToHaResponse struct { 99 JobId string `json:"job_id"` 100 } 101 102 func (r SingleToHaResult) Extract() (*SingleToHaResponse, error) { 103 var response SingleToHaResponse 104 err := r.ExtractInto(&response) 105 return &response, err 106 } 107 108 type ResizeFlavor struct { 109 JobId string `json:"job_id"` 110 } 111 112 func (r ResizeFlavorResult) Extract() (*ResizeFlavor, error) { 113 var response ResizeFlavor 114 err := r.ExtractInto(&response) 115 return &response, err 116 } 117 118 type EnlargeVolumeResp struct { 119 JobId string `json:"job_id"` 120 } 121 122 func (r EnlargeVolumeResult) Extract() (*EnlargeVolumeResp, error) { 123 var response EnlargeVolumeResp 124 err := r.ExtractInto(&response) 125 return &response, err 126 } 127 128 type ListRdsResult struct { 129 commonResult 130 } 131 132 type ListRdsResponse struct { 133 Instances []RdsInstanceResponse `json:"instances"` 134 TotalCount int `json:"total_count"` 135 } 136 137 type RdsInstanceResponse struct { 138 Id string `json:"id"` 139 Name string `json:"name"` 140 Status string `json:"status"` 141 PrivateIps []string `json:"private_ips"` 142 PublicIps []string `json:"public_ips"` 143 Port int `json:"port"` 144 Type string `json:"type"` 145 Ha Ha `json:"ha"` 146 Region string `json:"region"` 147 DataStore Datastore `json:"datastore"` 148 Created string `json:"created"` 149 Updated string `json:"updated"` 150 DbUserName string `json:"db_user_name"` 151 VpcId string `json:"vpc_id"` 152 SubnetId string `json:"subnet_id"` 153 SecurityGroupId string `json:"security_group_id"` 154 FlavorRef string `json:"flavor_ref"` 155 Volume Volume `json:"volume"` 156 SwitchStrategy string `json:"switch_strategy"` 157 BackupStrategy BackupStrategy `json:"backup_strategy"` 158 ChargeInfo ChargeResponse `json:"charge_info"` 159 MaintenanceWindow string `json:"maintenance_window"` 160 Nodes []Nodes `json:"nodes"` 161 RelatedInstance []RelatedInstance `json:"related_instance"` 162 DiskEncryptionId string `json:"disk_encryption_id"` 163 EnterpriseProjectId string `json:"enterprise_project_id"` 164 TimeZone string `json:"time_zone"` 165 Tags []tags.ResourceTag `json:"tags"` 166 } 167 168 type Nodes struct { 169 Id string `json:"id"` 170 Name string `json:"name"` 171 Role string `json:"role"` 172 Status string `json:"status"` 173 AvailabilityZone string `json:"availability_zone"` 174 } 175 176 type RelatedInstance struct { 177 Id string `json:"id"` 178 Type string `json:"type"` 179 } 180 181 type RdsPage struct { 182 pagination.SinglePageBase 183 } 184 185 func (r RdsPage) IsEmpty() (bool, error) { 186 data, err := ExtractRdsInstances(r) 187 if err != nil { 188 return false, err 189 } 190 return len(data.Instances) == 0, err 191 } 192 193 // ExtractRdsInstances is a function that takes a ListResult and returns the instances' information. 194 func ExtractRdsInstances(r pagination.Page) (ListRdsResponse, error) { 195 var s ListRdsResponse 196 err := (r.(RdsPage)).ExtractInto(&s) 197 return s, err 198 } 199 200 type ErrorLogResult struct { 201 golangsdk.Result 202 } 203 204 type ErrorLogResp struct { 205 ErrorLogList []Errorlog `json:"error_log_list"` 206 TotalRecord int `json:"total_record"` 207 } 208 209 type Errorlog struct { 210 Time string `json:"time"` 211 Level string `json:"level"` 212 Content string `json:"content"` 213 } 214 215 type ErrorLogPage struct { 216 pagination.SinglePageBase 217 } 218 219 // IsEmpty returns true if a ListResult contains no services. 220 func (r ErrorLogPage) IsEmpty() (bool, error) { 221 data, err := ExtractErrorLog(r) 222 if err != nil { 223 return false, err 224 } 225 return len(data.ErrorLogList) == 0, err 226 } 227 228 func ExtractErrorLog(r pagination.Page) (ErrorLogResp, error) { 229 var s ErrorLogResp 230 err := (r.(ErrorLogPage)).ExtractInto(&s) 231 return s, err 232 } 233 234 type SlowLogResp struct { 235 Slowloglist []Slowloglist `json:"slow_log_list"` 236 TotalRecord int `json:"total_record"` 237 } 238 239 type Slowloglist struct { 240 Count string `json:"count"` 241 Time string `json:"time"` 242 Locktime string `json:"lock_time"` 243 Rowssent string `json:"rows_sent"` 244 Rowsexamined string `json:"rows_examined"` 245 Database string `json:"database"` 246 Users string `json:"users"` 247 QuerySample string `json:"query_sample"` 248 Type string `json:"type"` 249 } 250 251 type SlowLogPage struct { 252 pagination.SinglePageBase 253 } 254 255 // IsEmpty returns true if a ListResult contains no services. 256 func (r SlowLogPage) IsEmpty() (bool, error) { 257 data, err := ExtractSlowLog(r) 258 if err != nil { 259 return false, err 260 } 261 return len(data.Slowloglist) == 0, err 262 } 263 264 // ExtractCloudServers is a function that takes a ListResult and returns the services' information. 265 func ExtractSlowLog(r pagination.Page) (SlowLogResp, error) { 266 var s SlowLogResp 267 err := (r.(SlowLogPage)).ExtractInto(&s) 268 return s, err 269 } 270 271 type RDSJobResult struct { 272 commonResult 273 } 274 275 type ListJob struct { 276 Job Job `json:"job"` 277 } 278 279 type Job struct { 280 ID string `json:"id"` 281 Name string `json:"name"` 282 Status string `json:"status"` 283 Created string `json:"created"` 284 Ended string `json:"ended"` 285 Process string `json:"process"` 286 FailReason string `json:"fail_reason"` 287 } 288 289 func (r RDSJobResult) Extract() (ListJob, error) { 290 var s ListJob 291 err := r.ExtractInto(&s) 292 return s, err 293 }