-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
Maven.ts
39 lines (35 loc) · 1.32 KB
/
Maven.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
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type { GitlabAPIResponse, OneOrNoneOf, ShowExpanded } from '../infrastructure';
export class Maven<C extends boolean = false> extends BaseResource<C> {
downloadPackageFile<E extends boolean = false>(
path: string,
filename: string,
{
projectId,
groupId,
...options
}: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & ShowExpanded<E>,
): Promise<GitlabAPIResponse<Blob, void, E, void>> {
let url = endpoint`packages/maven/${path}/${filename}`;
if (projectId) url = endpoint`projects/${projectId}/${url}`;
else if (groupId) url = endpoint`groups/${groupId}/-/${url}`;
return RequestHelper.get<Blob>()(this, url, options as ShowExpanded<E>);
}
uploadPackageFile<E extends boolean = false>(
projectId: string | number,
path: string,
packageFile: { content: Blob; filename: string },
options?: ShowExpanded<E>,
): Promise<GitlabAPIResponse<void, C, E, void>> {
return RequestHelper.put<void>()(
this,
endpoint`projects/${projectId}/packages/maven/${path}/${packageFile.filename}`,
{
isForm: true,
...options,
file: [packageFile.content, packageFile.filename],
},
);
}
}