Skip to content

Commit

Permalink
load balancers: introduce new type field (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
asaha2 committed Jul 11, 2023
1 parent ccfdbc0 commit 43f27da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import (
"net/http"
)

const loadBalancersBasePath = "/v2/load_balancers"
const forwardingRulesPath = "forwarding_rules"
const (
dropletsPath = "droplets"
forwardingRulesPath = "forwarding_rules"
loadBalancersBasePath = "/v2/load_balancers"
)

const dropletsPath = "droplets"
// Load Balancer types.
const (
LoadBalancerTypeGlobal = "GLOBAL"
LoadBalancerTypeRegional = "REGIONAL"
)

// LoadBalancersService is an interface for managing load balancers with the DigitalOcean API.
// See: https://docs.digitalocean.com/reference/api/api-reference/#tag/Load-Balancers
Expand All @@ -35,6 +42,7 @@ type LoadBalancer struct {
SizeSlug string `json:"size,omitempty"`
// SizeUnit is mutually exclusive with SizeSlug. Only one should be specified
SizeUnit uint32 `json:"size_unit,omitempty"`
Type string `json:"type,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Status string `json:"status,omitempty"`
Created string `json:"created_at,omitempty"`
Expand Down Expand Up @@ -74,6 +82,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest {
Algorithm: l.Algorithm,
SizeSlug: l.SizeSlug,
SizeUnit: l.SizeUnit,
Type: l.Type,
ForwardingRules: append([]ForwardingRule(nil), l.ForwardingRules...),
DropletIDs: append([]int(nil), l.DropletIDs...),
Tag: l.Tag,
Expand Down Expand Up @@ -190,6 +199,7 @@ type LoadBalancerRequest struct {
SizeSlug string `json:"size,omitempty"`
// SizeUnit is mutually exclusive with SizeSlug. Only one should be specified
SizeUnit uint32 `json:"size_unit,omitempty"`
Type string `json:"type,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
HealthCheck *HealthCheck `json:"health_check,omitempty"`
StickySessions *StickySessions `json:"sticky_sessions,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func TestLoadBalancers_Create(t *testing.T) {

createRequest := &LoadBalancerRequest{
Name: "example-lb-01",
Type: LoadBalancerTypeRegional,
Algorithm: "round_robin",
Region: "nyc1",
ForwardingRules: []ForwardingRule{
Expand Down

0 comments on commit 43f27da

Please sign in to comment.