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 { source_epic: RelatedEpicSchema; target_epic: RelatedEpicSchema; } export type RelatedEpicLinkType = 'relates_to' | 'blocks' | 'is_blocked_by'; export class LinkedEpics extends BaseResource { all( groupId: string | number, epicIId: number, options?: { createdAfter?: string; createdBefore?: string; updatedAfter?: string; updatedBefore?: string; } & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise> { return RequestHelper.get()( this, endpoint`groups/${groupId}/epics/${epicIId}/related_epics`, options, ); } create( groupId: string | number, epicIId: number, targetEpicIId: string | number, targetGroupId: string | number, options?: { linkType?: RelatedEpicLinkType } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`groups/${groupId}/epics/${epicIId}/related_epics`, { searchParams: { targetGroupId, targetEpicIid: targetEpicIId, }, ...options, }, ); } remove( groupId: string | number, epicIId: number, relatedEpicLinkId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`groups/${groupId}/epics/${epicIId}/related_epics/${relatedEpicLinkId}`, options, ); } }