forked from huaweicloud/huaweicloud-sdk-go
/
results.go
66 lines (52 loc) · 1.37 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
package database
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
// ActionResult represents the result of server action operations, like reboot.
// Call its ExtractErr method to determine if the action succeeded or failed.
type CreateDatabaseResult struct {
gophercloud.Result
}
type CreateDatabaseResp struct {
Resp string `json:"resp"`
}
func (r CreateDatabaseResult) Extract() (*CreateDatabaseResp, error) {
var response CreateDatabaseResp
err := r.ExtractInto(&response)
return &response, err
}
type ListDataBaseResp struct {
DatabasesList []Databases `json:"databases"`
Totalcount int `json:"total_count"`
}
type Databases struct {
Name string `json:"name"`
CharacterSet string `json:"character_set"`
}
type DataBasePage struct {
pagination.Offset
}
func (r DataBasePage) IsEmpty() (bool, error) {
data, err := ExtractDataBase(r)
if err != nil {
return false, err
}
return len(data.DatabasesList) == 0, err
}
func ExtractDataBase(r pagination.Page) (ListDataBaseResp, error) {
var s ListDataBaseResp
err := (r.(DataBasePage)).ExtractInto(&s)
return s, err
}
type commonResult struct {
gophercloud.Result
}
type DeleteDataBase struct {
Resp string `json:"resp"`
}
func (r commonResult) Extract() (*DeleteDataBase, error) {
var response DeleteDataBase
err := r.ExtractInto(&response)
return &response, err
}