Skip to content

Commit

Permalink
feat: Add support for the Packages API #430
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Aug 28, 2019
1 parent ef65273 commit 47e1ff4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ MergeRequests
MergeRequestAwardEmojis
MergeRequestDiscussions
MergeRequestNotes
Packages
Pipelines
PipelineSchedules
PipelineScheduleVariables
Expand Down Expand Up @@ -220,6 +221,7 @@ MergeRequests
MergeRequestAwardEmojis
MergeRequestDiscussions
MergeRequestNotes
Packages
Pipelines
PipelineSchedules
PipelineScheduleVariables
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ProjectsBundle = bundler({
MergeRequestAwardEmojis: APIServices.MergeRequestAwardEmojis,
MergeRequestDiscussions: APIServices.MergeRequestDiscussions,
MergeRequestNotes: APIServices.MergeRequestNotes,
Packages: APIServices.Packages,
Pipelines: APIServices.Pipelines,
PipelineSchedules: APIServices.PipelineSchedules,
PipelineScheduleVariables: APIServices.PipelineScheduleVariables,
Expand Down
30 changes: 30 additions & 0 deletions src/services/Packages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { BaseService, PaginatedRequestOptions, RequestHelper, Sudo } from '../infrastructure';
import { ProjectId } from '.';

class Packages extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {
const pId = encodeURIComponent(projectId);

return RequestHelper.get(this, `projects/${gId}/packages`, options);
}

remove(projectId: ProjectId, packageId: number, options?: Sudo) {
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);

return RequestHelper.del(this, `projects/${pId}/packages/${pkId}`, options);
}

show(projectId: ProjectId, packageId: number, options?: Sudo) {
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);

return RequestHelper.get(this, `projects/${pId}/packages/${pkId}`, options);
}

showFiles(projectId: ProjectId, packageId: number, options?: Sudo) {
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);

return RequestHelper.get(this, `projects/${pId}/packages/${pkId}/package_files`, options);
}
}

export default Packages;
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export { default as MergeRequests } from './MergeRequests';
export { default as MergeRequestAwardEmojis } from './MergeRequestAwardEmojis';
export { default as MergeRequestDiscussions } from './MergeRequestDiscussions';
export { default as MergeRequestNotes } from './MergeRequestNotes';
export { default as Packages } from './Packages';
export { default as Pipelines } from './Pipelines';
export { default as PipelineSchedules } from './PipelineSchedules';
export { default as PipelineScheduleVariables } from './PipelineScheduleVariables';
Expand Down

0 comments on commit 47e1ff4

Please sign in to comment.