entities.go raw
1 package linodego
2
3 import "context"
4
5 // LinodeEntity is anything in Linode with IAM Permissions
6 type LinodeEntity struct {
7 ID int `json:"id"`
8 Label string `json:"label"`
9 Type string `json:"type"`
10 }
11
12 // ListEntities returns a paginated list of all entities
13 func (c *Client) ListEntities(ctx context.Context, opts *ListOptions) ([]LinodeEntity, error) {
14 return getPaginatedResults[LinodeEntity](ctx, c, "entities", opts)
15 }
16
17 // GetEntityRoles returns a list of roles for the entity and user
18 func (c *Client) GetEntityRoles(ctx context.Context, username string, entityType string, entityID int) ([]string, error) {
19 perms, err := doGETRequest[[]string](ctx, c,
20 formatAPIPath("iam/users/%s/permissions/%s/%d", username, entityType, entityID))
21 if err != nil || perms == nil {
22 return nil, err
23 }
24
25 return (*perms), err
26 }
27