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 support for the type field when creating nodebalancers #669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 All @@ -52,6 +54,7 @@ type NodeBalancerCreateOptions struct {
Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"`
Tags []string `json:"tags"`
FirewallID int `json:"firewall_id,omitempty"`
Type NodeBalancerPlanType `json:"type,omitempty"`
}

// NodeBalancerUpdateOptions are the options permitted for UpdateNodeBalancer
Expand All @@ -61,6 +64,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 @@ -89,6 +101,7 @@ func (i NodeBalancer) GetCreateOptions() NodeBalancerCreateOptions {
Label: i.Label,
Region: i.Region,
ClientConnThrottle: &i.ClientConnThrottle,
Type: i.Type,
Tags: i.Tags,
}
}
Expand Down