-
Notifications
You must be signed in to change notification settings - Fork 83
/
network_reserved_ips.go
54 lines (45 loc) · 1.76 KB
/
network_reserved_ips.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package linodego
import (
"context"
)
// ReserveIPOptions represents the options for reserving an IP address
// NOTE: Reserved IP feature may not currently be available to all users.
type ReserveIPOptions struct {
Region string `json:"region"`
}
// ListReservedIPAddresses retrieves a list of reserved IP addresses
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) ListReservedIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error) {
e := formatAPIPath("networking/reserved/ips")
response, err := getPaginatedResults[InstanceIP](ctx, c, e, opts)
if err != nil {
return nil, err
}
return response, nil
}
// GetReservedIPAddress retrieves details of a specific reserved IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) GetReservedIPAddress(ctx context.Context, ipAddress string) (*InstanceIP, error) {
e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
response, err := doGETRequest[InstanceIP](ctx, c, e)
if err != nil {
return nil, err
}
return response, nil
}
// ReserveIPAddress reserves a new IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) ReserveIPAddress(ctx context.Context, opts ReserveIPOptions) (*InstanceIP, error) {
e := "networking/reserved/ips"
response, err := doPOSTRequest[InstanceIP](ctx, c, e, opts)
if err != nil {
return nil, err
}
return response, nil
}
// DeleteReservedIPAddress deletes a reserved IP address
// NOTE: Reserved IP feature may not currently be available to all users.
func (c *Client) DeleteReservedIPAddress(ctx context.Context, ipAddress string) error {
e := formatAPIPath("networking/reserved/ips/%s", ipAddress)
return doDELETERequest(ctx, c, e)
}