Skip to content
Open
Show file tree
Hide file tree
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
33 changes: 31 additions & 2 deletions nodebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type NodeBalancer struct {
// NOTE: Locks can only be used with v4beta.
Locks []LockType `json:"locks"`

FrontendAddressType NodeBalancerVPCFrontendAddressType `json:"frontend_address_type"`
FrontendVPCSubnetID *int `json:"frontend_vpc_subnet_id"`

Created *time.Time `json:"-"`
Updated *time.Time `json:"-"`
}
Expand All @@ -66,6 +69,19 @@ type NodeBalancerVPCOptions struct {
IPv4RangeAutoAssign bool `json:"ipv4_range_auto_assign,omitzero"`
}

type NodeBalancerBackendVPCOptions struct {
IPv4Range string `json:"ipv4_range,omitzero"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a pointer?

IPv6Range string `json:"ipv6_range,omitzero"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

SubnetID int `json:"subnet_id"`
IPv4RangeAutoAssign bool `json:"ipv4_range_auto_assign,omitzero"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

}

type NodeBalancerFrontendVPCOptions struct {
IPv4Range string `json:"ipv4_range,omitzero"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

IPv6Range string `json:"ipv6_range,omitzero"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@mawilk90 mawilk90 Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ezilber-akamai, all the fields you mentioned above (IPv4Range, IPv6Range, IPv4RangeAutoAssign) seems to be optional and can be skipped in the API request. Does it mean that they need to be a pointers for omitzero anyway? In the current implementation, aren't both "" and lack of these fields treated the same?

SubnetID int `json:"subnet_id"`
}

// NodeBalancerCreateOptions are the options permitted for CreateNodeBalancer
type NodeBalancerCreateOptions struct {
Label *string `json:"label,omitzero"`
Expand All @@ -79,8 +95,12 @@ type NodeBalancerCreateOptions struct {
Tags []string `json:"tags"`
FirewallID int `json:"firewall_id,omitzero"`
Type NodeBalancerPlanType `json:"type,omitzero"`
VPCs []NodeBalancerVPCOptions `json:"vpcs,omitzero"`
IPv4 *string `json:"ipv4,omitzero"`
// Deprecated: `VPCs` is deprecated in favor of `BackendVPCs`.
// This field may be removed in a later release.
VPCs []NodeBalancerVPCOptions `json:"vpcs,omitzero"`
BackendVPCs []NodeBalancerBackendVPCOptions `json:"backend_vpcs,omitzero"`
FrontendVPCs []NodeBalancerFrontendVPCOptions `json:"frontend_vpcs,omitzero"`
IPv4 *string `json:"ipv4,omitzero"`
}

// NodeBalancerUpdateOptions are the options permitted for UpdateNodeBalancer
Expand Down Expand Up @@ -115,6 +135,15 @@ const (
NBTypeCommon NodeBalancerPlanType = "common"
)

// NodeBalancerVPCFrontendAddressType constants start with NodeBalancerVPCFrontendAddressType and include the types of frontend addresses a NodeBalancer VPC can have
type NodeBalancerVPCFrontendAddressType string

// NodeBalancerVPCFrontendAddressType constants reflect the types of frontend addresses a NodeBalancer VPC can have
const (
NodeBalancerVPCFrontendAddressTypeVPC NodeBalancerVPCFrontendAddressType = "vpc"
NodeBalancerVPCFrontendAddressTypePublic NodeBalancerVPCFrontendAddressType = "public"
)

// UnmarshalJSON implements the json.Unmarshaler interface
func (i *NodeBalancer) UnmarshalJSON(b []byte) error {
type Mask NodeBalancer
Expand Down
37 changes: 28 additions & 9 deletions nodebalancer_config_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,43 @@ import (
)

// NodeBalancerVPCConfig objects represent a VPC config for a NodeBalancer
// s
// NOTE: NodeBalancer VPC support may not currently be available to all users.
type NodeBalancerVPCConfig struct {
ID int `json:"id"`
IPv4Range string `json:"ipv4_range"`
IPv6Range string `json:"ipv6_range,omitzero"`
NodeBalancerID int `json:"nodebalancer_id"`
SubnetID int `json:"subnet_id"`
VPCID int `json:"vpc_id"`
ID int `json:"id"`
IPv4Range string `json:"ipv4_range"`
IPv6Range string `json:"ipv6_range,omitzero"`
NodeBalancerID int `json:"nodebalancer_id"`
SubnetID int `json:"subnet_id"`
VPCID int `json:"vpc_id"`
Purpose NodeBalancerVPCConfigPurpose `json:"purpose,omitzero"`
}

// NodeBalancerVPCConfigPurpose constants start with NodeBalancerVPCConfigPurpose and include the purposes of a NodeBalancer VPC config
type NodeBalancerVPCConfigPurpose string

// NodeBalancerVPCConfigPurpose constants reflect the purpose of a NodeBalancer VPC config
const (
NodeBalancerVPCConfigPurposeFrontend NodeBalancerVPCConfigPurpose = "frontend"
NodeBalancerVPCConfigPurposeBackend NodeBalancerVPCConfigPurpose = "backend"
)

// ListNodeBalancerVPCConfigs lists NodeBalancer VPC configs
func (c *Client) ListNodeBalancerVPCConfigs(ctx context.Context, nodebalancerID int, opts *ListOptions) ([]NodeBalancerVPCConfig, error) {
return getPaginatedResults[NodeBalancerVPCConfig](ctx, c, formatAPIPath("nodebalancers/%d/vpcs", nodebalancerID), opts)
}

// ListNodeBalancerVPCBackendConfigs lists NodeBalancer Backend VPC configs
func (c *Client) ListNodeBalancerVPCBackendConfigs(ctx context.Context, nodebalancerID int, opts *ListOptions) ([]NodeBalancerVPCConfig, error) {
return getPaginatedResults[NodeBalancerVPCConfig](ctx, c, formatAPIPath("nodebalancers/%d/backend_vpcs", nodebalancerID), opts)
}

// ListNodeBalancerVPCFrontendConfigs lists NodeBalancer Frontend VPC configs
func (c *Client) ListNodeBalancerVPCFrontendConfigs(ctx context.Context, nodebalancerID int, opts *ListOptions) ([]NodeBalancerVPCConfig, error) {
return getPaginatedResults[NodeBalancerVPCConfig](ctx, c, formatAPIPath("nodebalancers/%d/frontend_vpcs", nodebalancerID), opts)
}

// GetNodeBalancerVPCConfig gets the NodeBalancer VPC config with the specified id
func (c *Client) GetNodeBalancerVPCConfig(ctx context.Context, nodebalancerID int, vpcID int) (*NodeBalancerVPCConfig, error) {
e := formatAPIPath("nodebalancers/%d/vpcs/%d", nodebalancerID, vpcID)
func (c *Client) GetNodeBalancerVPCConfig(ctx context.Context, nodebalancerID int, vpcConfigID int) (*NodeBalancerVPCConfig, error) {
e := formatAPIPath("nodebalancers/%d/vpcs/%d", nodebalancerID, vpcConfigID)
return doGETRequest[NodeBalancerVPCConfig](ctx, c, e)
}
Loading