forked from cloudscale-ch/cloudscale-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_balancer_pool_members.go
81 lines (69 loc) · 3.6 KB
/
load_balancer_pool_members.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
package cloudscale
import (
"context"
"fmt"
"time"
)
const loadBalancerPoolMemberBasePath = "v1/load-balancers/pools/%s/members"
type LoadBalancerPoolMember struct {
TaggedResource
// Just use omitempty everywhere. This makes it easy to use restful. Errors
// will be coming from the API if something is disabled.
HREF string `json:"href,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
Enabled bool `json:"enabled,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Pool LoadBalancerPoolStub `json:"pool,omitempty"`
LoadBalancer LoadBalancerStub `json:"load_balancer,omitempty"`
ProtocolPort int `json:"protocol_port,omitempty"`
MonitorPort int `json:"monitor_port,omitempty"`
Address string `json:"address,omitempty"`
Subnet SubnetStub `json:"subnet,omitempty"`
MonitorStatus string `json:"monitor_status,omitempty"`
}
type LoadBalancerPoolMemberRequest struct {
TaggedResourceRequest
Name string `json:"name,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
ProtocolPort int `json:"protocol_port,omitempty"`
MonitorPort int `json:"monitor_port,omitempty"`
Address string `json:"address,omitempty"`
Subnet string `json:"subnet,omitempty"`
}
type LoadBalancerPoolMemberService interface {
Create(ctx context.Context, poolID string, createRequest *LoadBalancerPoolMemberRequest) (*LoadBalancerPoolMember, error)
Get(ctx context.Context, poolID string, resourceID string) (*LoadBalancerPoolMember, error)
List(ctx context.Context, poolID string, modifiers ...ListRequestModifier) ([]LoadBalancerPoolMember, error)
Update(ctx context.Context, poolID string, resourceID string, updateRequest *LoadBalancerPoolMemberRequest) error
Delete(ctx context.Context, poolID string, resourceID string) error
}
type LoadBalancerPoolMemberServiceOperations struct {
client *Client
}
func (l LoadBalancerPoolMemberServiceOperations) Create(ctx context.Context, poolID string, createRequest *LoadBalancerPoolMemberRequest) (*LoadBalancerPoolMember, error) {
g := parameterizeGenericInstance(l, poolID)
return g.Create(ctx, createRequest)
}
func (l LoadBalancerPoolMemberServiceOperations) Get(ctx context.Context, poolID string, resourceID string) (*LoadBalancerPoolMember, error) {
g := parameterizeGenericInstance(l, poolID)
return g.Get(ctx, resourceID)
}
func (l LoadBalancerPoolMemberServiceOperations) List(ctx context.Context, poolID string, modifiers ...ListRequestModifier) ([]LoadBalancerPoolMember, error) {
g := parameterizeGenericInstance(l, poolID)
return g.List(ctx, modifiers...)
}
func (l LoadBalancerPoolMemberServiceOperations) Update(ctx context.Context, poolID string, resourceID string, updateRequest *LoadBalancerPoolMemberRequest) error {
g := parameterizeGenericInstance(l, poolID)
return g.Update(ctx, resourceID, updateRequest)
}
func (l LoadBalancerPoolMemberServiceOperations) Delete(ctx context.Context, poolID string, resourceID string) error {
g := parameterizeGenericInstance(l, poolID)
return g.Delete(ctx, resourceID)
}
func parameterizeGenericInstance(l LoadBalancerPoolMemberServiceOperations, poolID string) GenericServiceOperations[LoadBalancerPoolMember, LoadBalancerPoolMemberRequest, LoadBalancerPoolMemberRequest] {
return GenericServiceOperations[LoadBalancerPoolMember, LoadBalancerPoolMemberRequest, LoadBalancerPoolMemberRequest]{
client: l.client,
path: fmt.Sprintf(loadBalancerPoolMemberBasePath, poolID),
}
}