Skip to content

Commit

Permalink
add support for the type field when creating nodebalancers (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
eljohnson92 authored Feb 28, 2025
1 parent 4a29499 commit 41a199a
Show file tree
Hide file tree
Showing 6 changed files with 529 additions and 8 deletions.
13 changes: 13 additions & 0 deletions nodebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type NodeBalancer struct {
ClientConnThrottle int `json:"client_conn_throttle"`
// Information about the amount of transfer this NodeBalancer has had so far this month.
Transfer NodeBalancerTransfer `json:"transfer"`
// This NodeBalancer's plan Type
Type NodeBalancerPlanType `json:"type"`

// An array of tags applied to this object. Tags are for organizational purposes only.
Tags []string `json:"tags"`
Expand Down Expand Up @@ -58,6 +60,7 @@ type NodeBalancerCreateOptions struct {
Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"`
Tags []string `json:"tags"`
FirewallID int `json:"firewall_id,omitempty"`
Type NodeBalancerPlanType `json:"type,omitempty"`
VPCs []NodeBalancerVPCOptions `json:"vpcs,omitempty"`
}

Expand All @@ -68,6 +71,15 @@ type NodeBalancerUpdateOptions struct {
Tags *[]string `json:"tags,omitempty"`
}

// NodeBalancerPlanType constants start with NBType and include Linode API NodeBalancer's plan types
type NodeBalancerPlanType string

// NodeBalancerPlanType constants reflect the plan type used by a NodeBalancer Config
const (
NBTypePremium NodeBalancerPlanType = "premium"
NBTypeCommon NodeBalancerPlanType = "common"
)

// UnmarshalJSON implements the json.Unmarshaler interface
func (i *NodeBalancer) UnmarshalJSON(b []byte) error {
type Mask NodeBalancer
Expand Down Expand Up @@ -96,6 +108,7 @@ func (i NodeBalancer) GetCreateOptions() NodeBalancerCreateOptions {
Label: i.Label,
Region: i.Region,
ClientConnThrottle: &i.ClientConnThrottle,
Type: i.Type,
Tags: i.Tags,
}
}
Expand Down
Loading

0 comments on commit 41a199a

Please sign in to comment.