Skip to content

Commit 03a2f2d

Browse files
committed
feat: Updating Jobs API
- Added cancel, retry, erase, keepArtifacts, downloadLatestArtifacts and downloadTraceFile
1 parent b6ccb80 commit 03a2f2d

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

src/services/Jobs.js

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,88 @@ class Jobs extends BaseService {
77
return RequestHelper.get(this, `projects/${pId}/jobs`, options);
88
}
99

10+
cancel(projectId, jobId) {
11+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
12+
13+
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/cancel`);
14+
}
15+
16+
downloadSingleArtifactFile(
17+
projectId,
18+
jobId,
19+
artifactPath,
20+
options = { stream: false },
21+
) {
22+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
23+
24+
return RequestHelper.get(
25+
this,
26+
`projects/${pId}/jobs/${jId}/artifacts/${artifactPath}`,
27+
options,
28+
{ stream: options.stream },
29+
);
30+
}
31+
32+
downloadLatestArtifactFile(
33+
projectId,
34+
ref,
35+
name,
36+
options = { stream: false },
37+
) {
38+
const [pId, rId, jobName] = [projectId, ref, name].map(encodeURIComponent);
39+
40+
return RequestHelper.get(
41+
this,
42+
`projects/${pId}/jobs/artifacts/${rId}/download?job=${jobName}`,
43+
options,
44+
{ stream: options.stream },
45+
);
46+
}
47+
48+
downloadTraceFile(projectId, jobId) {
49+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
50+
51+
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}/trace`);
52+
}
53+
54+
erase(projectId, jobId) {
55+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
56+
57+
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/erase`);
58+
}
59+
60+
keepArtifacts(projectId, jobId) {
61+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
62+
63+
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/artifacts/keep`);
64+
}
65+
1066
play(projectId, jobId) {
11-
const pId = encodeURIComponent(projectId);
67+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
1268

13-
return RequestHelper.post(this, `projects/${pId}/jobs/${jobId}/play`);
69+
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/play`);
1470
}
1571

16-
downloadSingleArtifactFile(projectId, jobId, artifactPath, { stream }) {
17-
const pId = encodeURIComponent(projectId);
72+
retry(projectId, jobId) {
73+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
1874

19-
return RequestHelper.get(this, `projects/${pId}/jobs/${jobId}/artifacts/${artifactPath}`, {}, { stream });
75+
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/retry`);
2076
}
2177

2278
show(projectId, jobId) {
23-
const pId = encodeURIComponent(projectId);
79+
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
2480

25-
return RequestHelper.get(this, `projects/${pId}/jobs/${jobId}`);
81+
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}`);
2682
}
2783

2884
showPipelineJobs(projectId, pipelineId, options) {
29-
const pId = encodeURIComponent(projectId);
85+
const [pId, ppId] = [projectId, pipelineId].map(encodeURIComponent);
3086

31-
return RequestHelper.get(this, `projects/${pId}/pipelines/${pipelineId}/jobs`, options);
87+
return RequestHelper.get(
88+
this,
89+
`projects/${pId}/pipelines/${ppId}/jobs`,
90+
options,
91+
);
3292
}
3393
}
3494

0 commit comments

Comments
 (0)