-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfloating_ips.go
More file actions
59 lines (51 loc) · 1.8 KB
/
floating_ips.go
File metadata and controls
59 lines (51 loc) · 1.8 KB
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
package cloudscale
import (
"strconv"
"strings"
"time"
)
const floatingIPsBasePath = "v1/floating-ips"
type FloatingIP struct {
Region *RegionStub `json:"region"` // not using RegionalResource here, as FloatingIP can be regional or global
TaggedResource
HREF string `json:"href"`
Network string `json:"network"`
IPVersion int `json:"ip_version"`
NextHop string `json:"next_hop"`
Server *ServerStub `json:"server"`
LoadBalancer *LoadBalancerStub `json:"load_balancer"`
Type string `json:"type"`
ReversePointer string `json:"reverse_ptr,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type FloatingIPCreateRequest struct {
RegionalResourceRequest
TaggedResourceRequest
IPVersion int `json:"ip_version"`
Server string `json:"server,omitempty"`
LoadBalancer string `json:"load_balancer,omitempty"`
Type string `json:"type,omitempty"`
PrefixLength int `json:"prefix_length,omitempty"`
ReversePointer string `json:"reverse_ptr,omitempty"`
}
func (f FloatingIP) IP() string {
return strings.Split(f.Network, "/")[0]
}
func (f FloatingIP) PrefixLength() int {
result, _ := strconv.Atoi(strings.Split(f.Network, "/")[1])
return result
}
type FloatingIPUpdateRequest struct {
TaggedResourceRequest
Server string `json:"server,omitempty"`
LoadBalancer string `json:"load_balancer,omitempty"`
ReversePointer string `json:"reverse_ptr,omitempty"`
}
type FloatingIPsService interface {
GenericCreateService[FloatingIP, FloatingIPCreateRequest]
GenericGetService[FloatingIP]
GenericListService[FloatingIP]
GenericUpdateService[FloatingIP, FloatingIPUpdateRequest]
GenericDeleteService[FloatingIP]
GenericWaitForService[FloatingIP]
}