Skip to content

Commit 35c64a3

Browse files
upcoming: [UIE-9569] - New IAM getUserEntitiesByPermission (types, queries, hooks, mocks) (linode#13070)
* save progress * new hook = naming conventions * improve hook and usage * test * cleanup * comments * comments * Added changeset: New IAM getUserEntitiesByPermission (types, queries, hooks, mocks) * Added changeset: New IAM getUserEntitiesByPermission endpoint * Added changeset: New IAM getUserEntitiesByPermission queries * test fix
1 parent 1c4902e commit 35c64a3

File tree

15 files changed

+1039
-18
lines changed

15 files changed

+1039
-18
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Upcoming Features
3+
---
4+
5+
New IAM getUserEntitiesByPermission endpoint ([#13070](https://github.com/linode/manager/pull/13070))

packages/api-v4/src/iam/iam.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import Request, { setData, setMethod, setURL } from '../request';
33

44
import type {
55
AccessType,
6+
EntityByPermission,
67
IamAccountRoles,
78
IamUserRoles,
89
PermissionType,
910
} from './types';
11+
import type { EntityType } from 'src/entities/types';
1012

1113
/**
1214
* getUserRoles
@@ -100,3 +102,26 @@ export const getUserEntityPermissions = (
100102
),
101103
setMethod('GET'),
102104
);
105+
106+
/**
107+
* getUserEntitiesByPermission
108+
*
109+
* Returns the available entities for a given permission.
110+
*/
111+
export interface GetEntitiesByPermissionParams {
112+
entityType: EntityType;
113+
permission: PermissionType;
114+
username: string | undefined;
115+
}
116+
117+
export const getUserEntitiesByPermission = ({
118+
username,
119+
entityType,
120+
permission,
121+
}: GetEntitiesByPermissionParams) =>
122+
Request<EntityByPermission[]>(
123+
setURL(
124+
`${BETA_API_ROOT}/iam/users/${username}/entities/${entityType}?permission=${permission}`,
125+
),
126+
setMethod('GET'),
127+
);

packages/api-v4/src/iam/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ export interface Roles {
456456
name: RoleName;
457457
permissions: PermissionType[];
458458
}
459+
export interface EntityByPermission {
460+
id: number;
461+
label: string;
462+
type: EntityType;
463+
}
459464

460465
export type IamAccessType = keyof IamAccountRoles;
461466

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
New IAM getUserEntitiesByPermission (types, queries, hooks, mocks) ([#13070](https://github.com/linode/manager/pull/13070))

packages/manager/src/features/IAM/hooks/adapters/permissionAdapters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
Profile,
1616
} from '@linode/api-v4';
1717

18-
export type EntityPermissionMap = Record<number, PermissionMap>;
18+
export type EntityPermissionMap = Record<number | string, PermissionMap>;
1919

2020
export type PermissionMap = Record<PermissionType, boolean>;
2121

0 commit comments

Comments
 (0)