-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathLinkedEpics.ts
75 lines (69 loc) · 2.19 KB
/
LinkedEpics.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
import { EpicSchema } from './Epics';
export interface RelatedEpicSchema extends EpicSchema {
related_epic_link_id: number;
}
export interface RelatedEpicLinkSchema extends Record<string, unknown> {
source_epic: RelatedEpicSchema;
target_epic: RelatedEpicSchema;
}
export type RelatedEpicLinkType = 'relates_to' | 'blocks' | 'is_blocked_by';
export class LinkedEpics<C extends boolean = false> extends BaseResource<C> {
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
groupId: string | number,
epicIId: number,
options?: {
createdAfter?: string;
createdBefore?: string;
updatedAfter?: string;
updatedBefore?: string;
} & Sudo &
ShowExpanded<E> &
PaginationRequestOptions<P>,
): Promise<GitlabAPIResponse<RelatedEpicSchema[], C, E, P>> {
return RequestHelper.get<RelatedEpicSchema[]>()(
this,
endpoint`groups/${groupId}/epics/${epicIId}/related_epics`,
options,
);
}
create<E extends boolean = false>(
groupId: string | number,
epicIId: number,
targetEpicIId: string | number,
targetGroupId: string | number,
options?: { linkType?: RelatedEpicLinkType } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<RelatedEpicLinkSchema, C, E, void>> {
return RequestHelper.post<RelatedEpicLinkSchema>()(
this,
endpoint`groups/${groupId}/epics/${epicIId}/related_epics`,
{
searchParams: {
targetGroupId,
targetEpicIid: targetEpicIId,
},
...options,
},
);
}
remove<E extends boolean = false>(
groupId: string | number,
epicIId: number,
relatedEpicLinkId: string | number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<RelatedEpicLinkSchema, C, E, void>> {
return RequestHelper.del<RelatedEpicLinkSchema>()(
this,
endpoint`groups/${groupId}/epics/${epicIId}/related_epics/${relatedEpicLinkId}`,
options,
);
}
}