Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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,omitempty"`
}

type NodeBalancerBackendVPCOptions struct {
IPv4Range string `json:"ipv4_range,omitempty"`
IPv6Range string `json:"ipv6_range,omitempty"`
SubnetID int `json:"subnet_id"`
IPv4RangeAutoAssign bool `json:"ipv4_range_auto_assign,omitempty"`
}

type NodeBalancerFrontendVPCOptions struct {
IPv4Range string `json:"ipv4_range,omitempty"`
IPv6Range string `json:"ipv6_range,omitempty"`
SubnetID int `json:"subnet_id"`
}

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

// 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,omitempty"`
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"`
NodeBalancerID int `json:"nodebalancer_id"`
Comment thread
mawilk90 marked this conversation as resolved.
SubnetID int `json:"subnet_id"`
VPCID int `json:"vpc_id"`
Purpose NodeBalancerVPCConfigPurpose `json:"purpose"`
}

// 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
Loading