network_ranges.go raw
1 package linodego
2
3 import (
4 "context"
5 )
6
7 // IPv6RangeCreateOptions fields are those accepted by CreateIPv6Range
8 type IPv6RangeCreateOptions struct {
9 LinodeID int `json:"linode_id,omitempty"`
10 PrefixLength int `json:"prefix_length"`
11 RouteTarget string `json:"route_target,omitempty"`
12 }
13
14 // ListIPv6Ranges lists IPv6Ranges
15 func (c *Client) ListIPv6Ranges(ctx context.Context, opts *ListOptions) ([]IPv6Range, error) {
16 return getPaginatedResults[IPv6Range](ctx, c, "networking/ipv6/ranges", opts)
17 }
18
19 // GetIPv6Range gets details about an IPv6 range
20 func (c *Client) GetIPv6Range(ctx context.Context, ipRange string) (*IPv6Range, error) {
21 e := formatAPIPath("networking/ipv6/ranges/%s", ipRange)
22 return doGETRequest[IPv6Range](ctx, c, e)
23 }
24
25 // CreateIPv6Range creates an IPv6 Range and assigns it based on the provided Linode or route target IPv6 SLAAC address.
26 func (c *Client) CreateIPv6Range(ctx context.Context, opts IPv6RangeCreateOptions) (*IPv6Range, error) {
27 return doPOSTRequest[IPv6Range](ctx, c, "networking/ipv6/ranges", opts)
28 }
29
30 // DeleteIPv6Range deletes an IPv6 Range.
31 func (c *Client) DeleteIPv6Range(ctx context.Context, ipRange string) error {
32 e := formatAPIPath("networking/ipv6/ranges/%s", ipRange)
33 return doDELETERequest(ctx, c, e)
34 }
35