Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoSSL and GlobalRegions to load balancers #350

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type LoadBalancerService interface {
Get(ctx context.Context, lbID string) (*LoadBalancer, *http.Response, error)
Update(ctx context.Context, lbID string, updateReq *LoadBalancerReq) error
Delete(ctx context.Context, lbID string) error
DeleteSSL(ctx context.Context, lbID string) error
DeleteAutoSSL(ctx context.Context, lbID string) error
List(ctx context.Context, options *ListOptions) ([]LoadBalancer, *Meta, *http.Response, error)
CreateForwardingRule(ctx context.Context, lbID string, rule *ForwardingRule) (*ForwardingRule, *http.Response, error)
GetForwardingRule(ctx context.Context, lbID string, ruleID string) (*ForwardingRule, *http.Response, error)
Expand Down Expand Up @@ -49,6 +51,7 @@ type LoadBalancer struct {
HTTP3 *bool `json:"http3,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
FirewallRules []LBFirewallRule `json:"firewall_rules,omitempty"`
GlobalRegions []string `json:"global_regions,omitempty"`
}

// LoadBalancerReq gives options for creating or updating a load balancer
Expand All @@ -61,6 +64,7 @@ type LoadBalancerReq struct {
StickySessions *StickySessions `json:"sticky_session,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
SSL *SSL `json:"ssl,omitempty"`
AutoSSL *SSL `json:"auto_ssl,omitempty"`
SSLRedirect *bool `json:"ssl_redirect,omitempty"`
HTTP2 *bool `json:"http2,omitempty"`
HTTP3 *bool `json:"http3,omitempty"`
Expand All @@ -69,6 +73,7 @@ type LoadBalancerReq struct {
FirewallRules []LBFirewallRule `json:"firewall_rules,omitempty"`
Timeout int `json:"timeout,omitempty"`
VPC *string `json:"vpc,omitempty"`
GlobalRegions []string `json:"global_regions,omitempty"`
}

// InstanceList represents instances that are attached to your load balancer
Expand Down Expand Up @@ -348,3 +353,27 @@ func (l *LoadBalancerHandler) ListFirewallRules(ctx context.Context, lbID string

return fwRules.FirewallRules, fwRules.Meta, resp, nil
}

// DeleteSSL removes the SSL configuration from a load balancer subscription.
func (l *LoadBalancerHandler) DeleteSSL(ctx context.Context, lbID string) error {
uri := fmt.Sprintf("%s/%s/ssl", lbPath, lbID)
req, err := l.client.NewRequest(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
}

_, err = l.client.DoWithContext(ctx, req, nil)
return err
}

// DeleteAutoSSL removes the AutoSSL configuration from a load balancer subscription.
func (l *LoadBalancerHandler) DeleteAutoSSL(ctx context.Context, lbID string) error {
uri := fmt.Sprintf("%s/%s/auto_ssl", lbPath, lbID)
req, err := l.client.NewRequest(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
}

_, err = l.client.DoWithContext(ctx, req, nil)
return err
}
Loading