-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathGroupMemberRoles.ts
56 lines (52 loc) · 1.66 KB
/
GroupMemberRoles.ts
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
48
49
50
51
52
53
54
55
56
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
import { AccessLevel } from '../constants';
export interface MemberRoleSchema extends Record<string, unknown> {
id: number;
group_id: number;
base_access_level: number;
read_code: boolean;
}
export class GroupMemberRoles<C extends boolean = false> extends BaseResource<C> {
add<E extends boolean = false>(
groupId: string | number,
baseAccessLevel: Exclude<
AccessLevel,
AccessLevel.NO_ACCESS | AccessLevel.MINIMAL_ACCESS | AccessLevel.ADMIN
>,
options?: { readCode?: boolean } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<MemberRoleSchema, C, E, void>> {
return RequestHelper.post<MemberRoleSchema>()(this, endpoint`groups/${groupId}/members`, {
baseAccessLevel,
...options,
});
}
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
groupId: string | number,
options: PaginationRequestOptions<P> & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<MemberRoleSchema[], C, E, P>> {
return RequestHelper.get<MemberRoleSchema[]>()(
this,
endpoint`groups/${groupId}/member_roles`,
options,
);
}
remove<E extends boolean = false>(
groupId: string | number,
memberRoleId: number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<void, C, E, void>> {
return RequestHelper.del()(
this,
endpoint`groups/${groupId}/member_roles/${memberRoleId}`,
options,
);
}
}