|
| 1 | +package linodego |
| 2 | + |
| 3 | +import "context" |
| 4 | + |
| 5 | +type UserRolePermissions struct { |
| 6 | + AccountAccess []string `json:"account_access"` |
| 7 | + EntityAccess []UserAccess `json:"entity_access"` |
| 8 | +} |
| 9 | + |
| 10 | +func (p *UserRolePermissions) GetUpdateOptions() UserRolePermissionsUpdateOptions { |
| 11 | + return UserRolePermissionsUpdateOptions{ |
| 12 | + AccountAccess: p.AccountAccess, |
| 13 | + EntityAccess: p.EntityAccess, |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +type UserRolePermissionsUpdateOptions struct { |
| 18 | + AccountAccess []string `json:"account_access"` |
| 19 | + EntityAccess []UserAccess `json:"entity_access"` |
| 20 | +} |
| 21 | + |
| 22 | +type UserAccess struct { |
| 23 | + ID int `json:"id"` |
| 24 | + Type string `json:"type"` |
| 25 | + Roles []string `json:"roles"` |
| 26 | +} |
| 27 | + |
| 28 | +type AccountRolePermissions struct { |
| 29 | + AccountAccess []AccountAccess `json:"account_access"` |
| 30 | + EntityAccess []AccountAccess `json:"entity_access"` |
| 31 | +} |
| 32 | + |
| 33 | +type AccountAccess struct { |
| 34 | + Type string `json:"type"` |
| 35 | + Roles []Role `json:"roles"` |
| 36 | +} |
| 37 | + |
| 38 | +type Role struct { |
| 39 | + Name string `json:"name"` |
| 40 | + Description string `json:"description"` |
| 41 | + Permissions []string `json:"permissions"` |
| 42 | +} |
| 43 | + |
| 44 | +func (c *Client) GetUserRolePermissions(ctx context.Context, username string) (*UserRolePermissions, error) { |
| 45 | + return doGETRequest[UserRolePermissions](ctx, c, |
| 46 | + formatAPIPath("iam/users/%s/role-permissions", username), |
| 47 | + ) |
| 48 | +} |
| 49 | + |
| 50 | +func (c *Client) UpdateUserRolePermissions(ctx context.Context, username string, opts UserRolePermissionsUpdateOptions) (*UserRolePermissions, error) { |
| 51 | + return doPUTRequest[UserRolePermissions](ctx, c, |
| 52 | + formatAPIPath("iam/users/%s/role-permissions", username), |
| 53 | + opts, |
| 54 | + ) |
| 55 | +} |
| 56 | + |
| 57 | +func (c *Client) GetAccountRolePermissions(ctx context.Context) (*AccountRolePermissions, error) { |
| 58 | + return doGETRequest[AccountRolePermissions](ctx, c, "iam/role-permissions") |
| 59 | +} |
0 commit comments