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
106 lines (92 loc) · 3.43 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
package replicationconsistencygroups
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/pagination"
)
// ReplicationConsistencyGroupCreateorUpdate response
type ReplicationConsistencyGroupCreateorUpdate struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"`
PriorityStation string `json:"priority_station"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// CreateResult is a struct that contains all the return parameters of creation
type CreateResult struct {
golangsdk.Result
}
// Extract from CreateResult
func (r CreateResult) Extract() (*ReplicationConsistencyGroupCreateorUpdate, error) {
var s struct {
ReplicationConsistencyGroup *ReplicationConsistencyGroupCreateorUpdate `json:"replication_consistency_group"`
}
err := r.Result.ExtractInto(&s)
return s.ReplicationConsistencyGroup, err
}
// DeleteResult is a struct which contains the result of deletion
type DeleteResult struct {
golangsdk.ErrResult
}
// ReplicationConsistencyGroup response
type ReplicationConsistencyGroup struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"`
PriorityStation string `json:"priority_station"`
ReplicationModel string `json:"replication_model"`
ReplicationStatus string `json:"replication_status"`
ReplicationIDs []string `json:"replication_ids"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
FailureDetail string `json:"failure_detail"`
FaultLevel string `json:"fault_level"`
}
// GetResult contains the body of getting detailed
type GetResult struct {
golangsdk.Result
}
// Extract from GetResult
func (r GetResult) Extract() (*ReplicationConsistencyGroup, error) {
var s struct {
ReplicationConsistencyGroup *ReplicationConsistencyGroup `json:"replication_consistency_group"`
}
err := r.Result.ExtractInto(&s)
return s.ReplicationConsistencyGroup, err
}
// ReplicationConsistencyGroupPage may be embedded in a Page
// that contains all of the results from an operation at once.
type ReplicationConsistencyGroupPage struct {
pagination.SinglePageBase
}
// IsEmpty returns true if a ListResult contains no replications.
func (r ReplicationConsistencyGroupPage) IsEmpty() (bool, error) {
rs, err := ExtractReplicationConsistencyGroups(r)
return len(rs) == 0, err
}
// ExtractReplicationConsistencyGroups from List
func ExtractReplicationConsistencyGroups(r pagination.Page) ([]ReplicationConsistencyGroup, error) {
var s struct {
ReplicationConsistencyGroups []ReplicationConsistencyGroup `json:"replication_consistency_groups"`
}
err := (r.(ReplicationConsistencyGroupPage)).ExtractInto(&s)
return s.ReplicationConsistencyGroups, err
}
// UpdateResult is a struct from which can get the result of update method
type UpdateResult struct {
golangsdk.Result
}
// Extract from UpdateResult
func (r UpdateResult) Extract() (*ReplicationConsistencyGroupCreateorUpdate, error) {
var s struct {
ReplicationConsistencyGroup *ReplicationConsistencyGroupCreateorUpdate `json:"replication_consistency_group"`
}
err := r.Result.ExtractInto(&s)
return s.ReplicationConsistencyGroup, err
}
// ActionResult is the result of action operations
type ActionResult struct {
golangsdk.ErrResult
}