import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; export interface ProjectRemoteMirrorSchema extends Record { enabled: boolean; id: number; last_error?: string; last_successful_update_at: string; last_update_at: string; last_update_started_at: string; only_protected_branches: boolean; keep_divergent_refs: boolean; update_status: string; url: string; } export class ProjectRemoteMirrors extends BaseResource { all( projectId: string | number, options?: Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/remote_mirrors`, options, ); } // Helper method - Duplicated from Projects createPullMirror( projectId: string | number, url: string, mirror: boolean, options?: { onlyProtectedBranches?: boolean } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/mirror/pull`, { importUrl: url, mirror, ...options, }, ); } createPushMirror( projectId: string | number, url: string, options?: { enabled?: boolean; onlyProtectedBranches?: boolean; keepDivergentRefs?: boolean; mirrorBranchRegex?: string; } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/remote_mirrors`, { url, ...options, }, ); } edit( projectId: string | number, mirrorId: number, options?: { enabled?: boolean; onlyProtectedBranches?: boolean; keepDivergentRefs?: boolean; mirrorBranchRegex?: string; } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/remote_mirrors/${mirrorId}`, options, ); } remove( projectId: string | number, mirrorId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/remote_mirrors/${mirrorId}`, options, ); } show( projectId: string | number, mirrorId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/remote_mirrors/${mirrorId}`, options, ); } sync( projectId: string | number, mirrorId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/remote_mirrors/${mirrorId}/sync`, options, ); } }