1 package linodego
2 3 import (
4 "context"
5 )
6 7 // ChildAccount represents an account under the current account.
8 // NOTE: This is an alias to prevent any future breaking changes.
9 type ChildAccount = Account
10 11 // ChildAccountToken represents a short-lived token created using
12 // the CreateChildAccountToken(...) function.
13 // NOTE: This is an alias to prevent any future breaking changes.
14 type ChildAccountToken = Token
15 16 // ListChildAccounts lists child accounts under the current account.
17 // NOTE: Parent/Child related features may not be generally available.
18 func (c *Client) ListChildAccounts(ctx context.Context, opts *ListOptions) ([]ChildAccount, error) {
19 return getPaginatedResults[ChildAccount](
20 ctx,
21 c,
22 "account/child-accounts",
23 opts,
24 )
25 }
26 27 // GetChildAccount gets a single child accounts under the current account.
28 // NOTE: Parent/Child related features may not be generally available.
29 func (c *Client) GetChildAccount(ctx context.Context, euuid string) (*ChildAccount, error) {
30 return doGETRequest[ChildAccount](
31 ctx,
32 c,
33 formatAPIPath("account/child-accounts/%s", euuid),
34 )
35 }
36 37 // CreateChildAccountToken creates a short-lived token that can be used to
38 // access the Linode API under a child account.
39 // The attributes of this token are not currently configurable.
40 // NOTE: Parent/Child related features may not be generally available.
41 func (c *Client) CreateChildAccountToken(ctx context.Context, euuid string) (*ChildAccountToken, error) {
42 return doPOSTRequest[ChildAccountToken, any](
43 ctx,
44 c,
45 formatAPIPath("account/child-accounts/%s/token", euuid),
46 )
47 }
48