File: account_child.go

package info (click to toggle)
golang-github-linode-linodego 1.47.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 10,032 kB
  • sloc: makefile: 95; sh: 52; python: 24
file content (47 lines) | stat: -rw-r--r-- 1,582 bytes parent folder | download
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
package linodego

import (
	"context"
)

// ChildAccount represents an account under the current account.
// NOTE: This is an alias to prevent any future breaking changes.
type ChildAccount = Account

// ChildAccountToken represents a short-lived token created using
// the CreateChildAccountToken(...) function.
// NOTE: This is an alias to prevent any future breaking changes.
type ChildAccountToken = Token

// ListChildAccounts lists child accounts under the current account.
// NOTE: Parent/Child related features may not be generally available.
func (c *Client) ListChildAccounts(ctx context.Context, opts *ListOptions) ([]ChildAccount, error) {
	return getPaginatedResults[ChildAccount](
		ctx,
		c,
		"account/child-accounts",
		opts,
	)
}

// GetChildAccount gets a single child accounts under the current account.
// NOTE: Parent/Child related features may not be generally available.
func (c *Client) GetChildAccount(ctx context.Context, euuid string) (*ChildAccount, error) {
	return doGETRequest[ChildAccount](
		ctx,
		c,
		formatAPIPath("account/child-accounts/%s", euuid),
	)
}

// CreateChildAccountToken creates a short-lived token that can be used to
// access the Linode API under a child account.
// The attributes of this token are not currently configurable.
// NOTE: Parent/Child related features may not be generally available.
func (c *Client) CreateChildAccountToken(ctx context.Context, euuid string) (*ChildAccountToken, error) {
	return doPOSTRequest[ChildAccountToken, any](
		ctx,
		c,
		formatAPIPath("account/child-accounts/%s/token", euuid),
	)
}