-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.go
99 lines (78 loc) · 1.91 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
package peerings
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
type Peering struct {
// Specifies a resource ID in UUID format.
ID string `json:"id"`
Name string `json:"name,omitempty"`
Status string `json:"status"`
Description string `json:"description"`
RequestVpcInfo VPCInfo `json:"request_vpc_info"`
AcceptVpcInfo VPCInfo `json:"accept_vpc_info"`
}
type VPCInfo struct {
VpcID string `json:"vpc_id"`
TenantID string `json:"tenant_id,omitempty"`
}
type ActionResult struct {
commonResult
}
func (r ActionResult) Extract() (*Peering, error) {
var entity Peering
err := r.ExtractInto(&entity)
return &entity, err
}
type commonResult struct {
gophercloud.Result
}
type CreateResult struct {
commonResult
}
func (r CreateResult) Extract() (*Peering, error) {
var entity Peering
err := r.ExtractIntoStructPtr(&entity, "peering")
return &entity, err
}
type DeleteResult struct {
gophercloud.ErrResult
}
type GetResult struct {
commonResult
}
func (r GetResult) Extract() (*Peering, error) {
var entity Peering
err := r.ExtractIntoStructPtr(&entity, "peering")
return &entity, err
}
type PeeringPage struct {
pagination.LinkedPageBase
}
func ExtractPeerings(r pagination.Page) ([]Peering, error) {
var s struct {
Peering []Peering `json:"peerings"`
}
err := r.(PeeringPage).ExtractInto(&s)
return s.Peering, err
}
func (r PeeringPage) NextPageURL() (string, error) {
publicIps, err := ExtractPeerings(r)
if err != nil {
return "", err
}
return r.WrapNextPageURL(publicIps[len(publicIps)-1].ID)
}
// IsEmpty checks whether a NetworkPage struct is empty.
func (r PeeringPage) IsEmpty() (bool, error) {
s, err := ExtractPeerings(r)
return len(s) == 0, err
}
type UpdateResult struct {
commonResult
}
func (r UpdateResult) Extract() (*Peering, error) {
var entity Peering
err := r.ExtractIntoStructPtr(&entity, "peering")
return &entity, err
}