-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathGroupImportExports.ts
53 lines (48 loc) · 1.81 KB
/
GroupImportExports.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
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type { AsStream, GitlabAPIResponse, ShowExpanded, Sudo } from '../infrastructure';
import type { ImportStatusSchema } from './ProjectImportExports';
export class GroupImportExports<C extends boolean = false> extends BaseResource<C> {
download<E extends boolean = false>(
groupId: string | number,
options: { asStream: true } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<ReadableStream, void, E, void>>;
download<E extends boolean = false>(
groupId: string | number,
options?: { asStream?: boolean } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<Blob, void, E, void>>;
download<E extends boolean = false>(
groupId: string | number,
options?: AsStream & ShowExpanded<E> & Sudo,
): Promise<any> {
return RequestHelper.get<Blob | ReadableStream>()(
this,
endpoint`groups/${groupId}/export/download`,
options,
);
}
import<E extends boolean = false>(
file: { content: Blob; filename: string },
path: string,
{ parentId, name, ...options }: { parentId?: number; name?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<ImportStatusSchema, C, E, void>> {
return RequestHelper.post<ImportStatusSchema>()(this, 'groups/import', {
isForm: true,
...options,
file: [file.content, file.filename],
path,
name: name || path.split('/').at(0),
parentId,
});
}
scheduleExport<E extends boolean = false>(
groupId: string | number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<{ message: string }, C, E, void>> {
return RequestHelper.post<{ message: string }>()(
this,
endpoint`groups/${groupId}/export`,
options,
);
}
}