Skip to content

Commit b23dd29

Browse files
committed
feat: Adding missing endpoints for deploy keys #373
BREAKING CHANGE: all method now takes an optional object since projectId is no longer required. If no projectId is passed, the all method returns all deploy keys across all projects of the GitLab instance
1 parent 4cbb633 commit b23dd29

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/services/DeployKeys.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseService, RequestHelper, Sudo, PaginatedRequestOptions } from '../infrastructure';
1+
import { BaseService, RequestHelper, Sudo, BaseRequestOptions, PaginatedRequestOptions } from '../infrastructure';
22
import { ProjectId, KeyId } from '.';
33

44
class DeployKeys extends BaseService {
@@ -8,23 +8,44 @@ class DeployKeys extends BaseService {
88
return RequestHelper.post(this, `projects/${pId}/deploy_keys`, options);
99
}
1010

11-
all(projectId: ProjectId, options?: PaginatedRequestOptions) {
12-
const pId = encodeURIComponent(projectId);
11+
all({
12+
projectId,
13+
...options
14+
}:{ projectId?: ProjectId } & PaginatedRequestOptions) {
15+
let url;
16+
17+
if (projectId) {
18+
url = `projects/${encodeURIComponent(projectId)}/deploy_keys`;
19+
} else {
20+
url = 'deploy_keys';
21+
}
1322

14-
return RequestHelper.get(this, `projects/${pId}/deploy_keys`, options);
23+
return RequestHelper.get(this, url, options);
1524
}
1625

17-
show(projectId: ProjectId, keyId: KeyId, options?: Sudo) {
26+
edit(projectId: ProjectId, keyId: KeyId, options?:BaseRequestOptions) {
1827
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
1928

20-
return RequestHelper.get(this, `projects/${pId}/deploy_keys/${kId}`, options);
29+
return RequestHelper.put(this, `projects/${pId}/deploy_keys/${kId}`, options);
2130
}
2231

2332
enable(projectId: ProjectId, keyId: KeyId, options?: Sudo) {
2433
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
2534

2635
return RequestHelper.post(this, `projects/${pId}/deploy_keys/${kId}/enable`, options);
2736
}
37+
38+
remove(projectId: ProjectId, keyId: KeyId, options?:Sudo) {
39+
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
40+
41+
return RequestHelper.del(this, `projects/${pId}/deploy_keys/${kId}`, options);
42+
}
43+
44+
show(projectId: ProjectId, keyId: KeyId, options?: Sudo) {
45+
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
46+
47+
return RequestHelper.get(this, `projects/${pId}/deploy_keys/${kId}`, options);
48+
}
2849
}
2950

3051
export default DeployKeys;

0 commit comments

Comments
 (0)