import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, OneOf, ShowExpanded } from '../infrastructure'; export class PyPI extends BaseResource { downloadPackageFile( sha: string, fileIdentifier: string, { projectId, groupId, ...options }: OneOf<{ projectId: string | number; groupId: string | number }> & ShowExpanded = {} as any, ): Promise> { let url: string; if (projectId) { url = endpoint`projects/${projectId}/packages/pypi/files/${sha}/${fileIdentifier}`; } else if (groupId) { url = endpoint`groups/${groupId}/packages/pypi/files/${sha}/${fileIdentifier}`; } else { throw new Error( 'Missing required argument. Please supply a projectId or a groupId in the options parameter', ); } return RequestHelper.get()(this, url, options); } showPackageDescriptor( packageName: string, { projectId, groupId, ...options }: OneOf<{ projectId: string | number; groupId: string | number }> & ShowExpanded, ): Promise> { let url: string; if (projectId) { url = endpoint`projects/${projectId}/packages/pypi/simple/${packageName}`; } else if (groupId) { url = endpoint`groups/${groupId}/packages/pypi/simple/${packageName}`; } else { throw new Error( 'Missing required argument. Please supply a projectId or a groupId in the options parameter', ); } return RequestHelper.get()(this, url, options); } uploadPackageFile( projectId: string | number, packageFile: { content: Blob; filename: string }, options?: ShowExpanded, ): Promise> { return RequestHelper.put()(this, endpoint`projects/${projectId}/packages/pypi`, { ...options, isForm: true, file: [packageFile.content, packageFile.filename], }); } }