Skip to content

Commit

Permalink
Support for Adding Additional Reserved IP to Existing Linodes (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
AniJ98 authored Sep 25, 2024
1 parent ac81d65 commit b20be2e
Show file tree
Hide file tree
Showing 15 changed files with 4,396 additions and 0 deletions.
16 changes: 16 additions & 0 deletions instance_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ type IPv6Range struct {
Linodes []int `json:"linodes"`
}

type InstanceReserveIPOptions struct {
Type string `json:"type"`
Public bool `json:"public"`
Address string `json:"address"`
}

// InstanceIPType constants start with IPType and include Linode Instance IP Types
type InstanceIPType string

Expand Down Expand Up @@ -144,3 +150,13 @@ func (c *Client) DeleteInstanceIPAddress(ctx context.Context, linodeID int, ipAd
err := doDELETERequest(ctx, c, e)
return err
}

// Function to add additional reserved IPV4 addresses to an existing linode
func (c *Client) AssignInstanceReservedIP(ctx context.Context, linodeID int, opts InstanceReserveIPOptions) (*InstanceIP, error) {
endpoint := formatAPIPath("linode/instances/%d/ips", linodeID)
response, err := doPOSTRequest[InstanceIP](ctx, c, endpoint, opts)
if err != nil {
return nil, err
}
return response, nil
}
2 changes: 2 additions & 0 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ type InstanceCreateOptions struct {

// Deprecated: group is a deprecated property denoting a group label for the Linode.
Group string `json:"group,omitempty"`

IPv4 []string `json:"ipv4,omitempty"`
}

// InstanceCreatePlacementGroupOptions represents the placement group
Expand Down
Loading

0 comments on commit b20be2e

Please sign in to comment.