forked from huaweicloud/huaweicloud-sdk-go
/
results.go
212 lines (159 loc) · 6.18 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package publicips
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
type PublicIP struct {
// Specifies the ID of the elastic IP address, which uniquely
// identifies the elastic IP address.
ID string `json:"id"`
// Specifies the status of the elastic IP address.
Status string `json:"status"`
// ext data for order info
Profile Profile `json:"profile"`
// Specifies the type of the elastic IP address.
Type string `json:"type"`
// Specifies the obtained elastic IP address.
PublicIpAddress string `json:"public_ip_address"`
// Specifies the obtained elastic IPv6 address.
PublicIpV6Address string `json:"public_ipv6_address"`
//Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default
IPVersion int `json:"ip_version"`
// Specifies the private IP address bound to the elastic IP
// address.
PrivateIpAddress string `json:"private_ip_address,omitempty"`
// Specifies the port ID.
PortId string `json:"port_id,omitempty"`
// Specifies the tenant ID of the operator.
TenantId string `json:"tenant_id"`
// Specifies the time for applying for the elastic IP address.
CreateTime string `json:"create_time"`
// Specifies the bandwidth ID of the elastic IP address.
BandwidthId string `json:"bandwidth_id"`
// Specifies the bandwidth size.
BandwidthSize int `json:"bandwidth_size"`
// Specifies whether the bandwidth is shared or exclusive.
BandwidthShareType string `json:"bandwidth_share_type"`
//
// Specifies the bandwidth name.
BandwidthName string `json:"bandwidth_name"`
// Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0".
//When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP.
EnterpriseProjectId string `json:"enterprise_project_id,omitempty"`
}
type Profile struct {
UserID string `json:"user_id"`
ProductID string `json:"product_id"`
RegionID string `json:"region_id"`
OrderID string `json:"order_id"`
}
type PublicIPCreateResp struct {
// Specifies the ID of the elastic IP address, which uniquely
// identifies the elastic IP address.
ID string `json:"id"`
// Specifies the status of the elastic IP address.
Status string `json:"status"`
// Specifies the type of the elastic IP address.
Type string `json:"type"`
// Specifies the obtained elastic IP address.
PublicIpAddress string `json:"public_ip_address"`
// Specifies the obtained elastic IPv6 address.
PublicIpV6Address string `json:"public_ipv6_address"`
//Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default
IPVersion int `json:"ip_version"`
// Specifies the tenant ID of the operator.
TenantId string `json:"tenant_id"`
// Specifies the time for applying for the elastic IP address.
CreateTime string `json:"create_time"`
// Specifies the bandwidth size.
BandwidthSize int `json:"bandwidth_size"`
// Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0".
//When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP.
EnterpriseProjectId string `json:"enterprise_project_id,omitempty"`
}
type PublicIPUpdateResp struct {
// Specifies the ID of the elastic IP address, which uniquely
// identifies the elastic IP address.
ID string `json:"id"`
// Specifies the status of the elastic IP address.
Status string `json:"status"`
// Specifies the type of the elastic IP address.
Type string `json:"type"`
// Specifies the obtained elastic IP address.
PublicIpAddress string `json:"public_ip_address"`
// Specifies the private IP address bound to the elastic IP address.
PrivateIpAddress string `json:"private_ip_address"`
// Specifies the obtained elastic IPv6 address.
PublicIpV6Address string `json:"public_ipv6_address"`
//Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default
IPVersion int `json:"ip_version"`
// Specifies the port ID.
PortId string `json:"port_id,omitempty"`
// Specifies the tenant ID of the operator.
TenantId string `json:"tenant_id"`
// Specifies the time for applying for the elastic IP address.
CreateTime string `json:"create_time"`
// Specifies the bandwidth size.
BandwidthSize int `json:"bandwidth_size"`
// Specifies the bandwidth ID of the elastic IP address.
BandwidthId string `json:"bandwidth_id"`
// Specifies whether the bandwidth is shared or exclusive.
BandwidthShareType string `json:"bandwidth_share_type"`
// Specifies the bandwidth name.
BandwidthName string `json:"bandwidth_name"`
// Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0".
//When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP.
EnterpriseProjectId string `json:"enterprise_project_id"`
}
type commonResult struct {
gophercloud.Result
}
type CreateResult struct {
commonResult
}
func (r CreateResult) Extract() (*PublicIPCreateResp, error) {
var entity PublicIPCreateResp
err := r.ExtractIntoStructPtr(&entity, "publicip")
return &entity, err
}
type DeleteResult struct {
gophercloud.ErrResult
}
type GetResult struct {
commonResult
}
func (r GetResult) Extract() (*PublicIP, error) {
var entity PublicIP
err := r.ExtractIntoStructPtr(&entity, "publicip")
return &entity, err
}
type PublicIPPage struct {
pagination.LinkedPageBase
}
func (r PublicIPPage) NextPageURL() (string, error) {
publicIps, err := ExtractPublicIPs(r)
if err != nil {
return "", err
}
return r.WrapNextPageURL(publicIps[len(publicIps)-1].ID)
}
func ExtractPublicIPs(r pagination.Page) ([]PublicIP, error) {
var s struct {
PublicIPs []PublicIP `json:"publicips"`
}
err := r.(PublicIPPage).ExtractInto(&s)
return s.PublicIPs, err
}
// IsEmpty checks whether a NetworkPage struct is empty.
func (r PublicIPPage) IsEmpty() (bool, error) {
s, err := ExtractPublicIPs(r)
return len(s) == 0, err
}
type UpdateResult struct {
commonResult
}
func (r UpdateResult) Extract() (*PublicIPUpdateResp, error) {
var entity PublicIPUpdateResp
err := r.ExtractIntoStructPtr(&entity, "publicip")
return &entity, err
}