1 package linodego
2 3 import (
4 "context"
5 )
6 7 // ReserveIPOptions represents the options for reserving an IP address
8 // NOTE: Reserved IP feature may not currently be available to all users.
9 type ReserveIPOptions struct {
10 Region string `json:"region"`
11 }
12 13 // ListReservedIPAddresses retrieves a list of reserved IP addresses
14 // NOTE: Reserved IP feature may not currently be available to all users.
15 func (c *Client) ListReservedIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error) {
16 e := formatAPIPath("networking/reserved/ips")
17 return getPaginatedResults[InstanceIP](ctx, c, e, opts)
18 }
19 20 // GetReservedIPAddress retrieves details of a specific reserved IP address
21 // NOTE: Reserved IP feature may not currently be available to all users.
22 func (c *Client) GetReservedIPAddress(ctx context.Context, ipAddress string) (*InstanceIP, error) {
23 e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
24 return doGETRequest[InstanceIP](ctx, c, e)
25 }
26 27 // ReserveIPAddress reserves a new IP address
28 // NOTE: Reserved IP feature may not currently be available to all users.
29 func (c *Client) ReserveIPAddress(ctx context.Context, opts ReserveIPOptions) (*InstanceIP, error) {
30 return doPOSTRequest[InstanceIP](ctx, c, "networking/reserved/ips", opts)
31 }
32 33 // DeleteReservedIPAddress deletes a reserved IP address
34 // NOTE: Reserved IP feature may not currently be available to all users.
35 func (c *Client) DeleteReservedIPAddress(ctx context.Context, ipAddress string) error {
36 e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
37 return doDELETERequest(ctx, c, e)
38 }
39