-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathImport.ts
76 lines (70 loc) · 2.47 KB
/
Import.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
76
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper } from '../infrastructure';
import type { GitlabAPIResponse, ShowExpanded, Sudo } from '../infrastructure';
export interface RepositoryImportStatusSchema extends Record<string, unknown> {
id: number;
name: string;
full_path: string;
full_name: string;
}
export interface ExpandedRepositoryImportStatusSchema extends RepositoryImportStatusSchema {
import_source: string;
import_status: string;
human_import_status_name: string;
provider_link: string;
}
export class Import<C extends boolean = false> extends BaseResource<C> {
importGithubRepository<E extends boolean = false>(
personalAccessToken: string,
repositoryId: number,
targetNamespace: string,
options?: {
newName?: string;
githubHostname?: string;
optionalStages?: Record<string, string>;
} & Sudo &
ShowExpanded<E>,
): Promise<GitlabAPIResponse<RepositoryImportStatusSchema, C, E, void>> {
return RequestHelper.post<RepositoryImportStatusSchema>()(this, 'import/github', {
personalAccessToken,
repoId: repositoryId,
targetNamespace,
...options,
});
}
cancelGithubRepositoryImport<E extends boolean = false>(
projectId: number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<RepositoryImportStatusSchema, C, E, void>> {
return RequestHelper.post<RepositoryImportStatusSchema>()(this, 'import/github/cancel', {
projectId,
...options,
});
}
importGithubGists<E extends boolean = false>(
personalAccessToken: string,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<void, C, E, void>> {
return RequestHelper.post<void>()(this, 'import/github/gists', {
personalAccessToken,
...options,
});
}
importBitbucketServerRepository<E extends boolean = false>(
bitbucketServerUrl: string,
bitbucketServerUsername: string,
personalAccessToken: string,
bitbucketServerProject: string,
bitbucketServerRepository: string,
options?: { newName?: string; targetNamespace?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<RepositoryImportStatusSchema, C, E, void>> {
return RequestHelper.post<RepositoryImportStatusSchema>()(this, 'import/bitbucket_server', {
bitbucketServerUrl,
bitbucketServerUsername,
personalAccessToken,
bitbucketServerProject,
bitbucketServerRepo: bitbucketServerRepository,
...options,
});
}
}