BigW Consortium Gitlab

Commit e7551214 by Robert Schilling

API: Remove `DELETE projects/:id/deploy_keys/:key_id/disable`

parent 12cd4c83
---
title: 'API: Remove `DELETE projects/:id/deploy_keys/:key_id/disable`'
merge_request: 9365
author: Robert Schilling
......@@ -137,7 +137,7 @@ Example response:
## Delete deploy key
Delete a deploy key from a project
Removes a deploy key from the project. If the deploy is used only for this project, it will be deleted from the system.
```
DELETE /projects/:id/deploy_keys/:key_id
......@@ -156,14 +156,11 @@ Example response:
```json
{
"updated_at" : "2015-08-29T12:50:57.259Z",
"key" : "ssh-rsa AAAA...",
"public" : false,
"title" : "My deploy key",
"user_id" : null,
"created_at" : "2015-08-29T12:50:57.259Z",
"fingerprint" : "6a:33:1f:74:51:c0:39:81:79:ec:7a:31:f8:40:20:43",
"id" : 13
"id": 6,
"deploy_key_id": 14,
"project_id": 1,
"created_at" : "2015-08-29T12:50:57.259Z",
"updated_at" : "2015-08-29T12:50:57.259Z"
}
```
......@@ -190,27 +187,3 @@ Example response:
"created_at" : "2015-08-29T12:44:31.550Z"
}
```
## Disable a deploy key
Disable a deploy key for a project. Returns the disabled key.
```bash
curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/deploy_keys/13/disable
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of the project |
| `key_id` | integer | yes | The ID of the deploy key |
Example response:
```json
{
"key" : "ssh-rsa AAAA...",
"id" : 12,
"title" : "My deploy key",
"created_at" : "2015-08-29T12:44:31.550Z"
}
```
......@@ -25,3 +25,4 @@ changes are in V4:
- Moved `/projects/fork/:id` to `/projects/:id/fork`
- Endpoints `/projects/owned`, `/projects/visible`, `/projects/starred` & `/projects/all` are consolidated into `/projects` using query parameters
- Return pagination headers for all endpoints that return an array
- Removed `DELETE projects/:id/deploy_keys/:key_id/disable`. Use `DELETE projects/:id/deploy_keys/:key_id` instead
......@@ -93,20 +93,6 @@ module API
end
end
desc 'Disable a deploy key for a project' do
detail 'This feature was added in GitLab 8.11'
success Entities::SSHKey
end
params do
requires :key_id, type: Integer, desc: 'The ID of the deploy key'
end
delete ":id/deploy_keys/:key_id/disable" do
key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id])
key.destroy
present key.deploy_key, with: Entities::SSHKey
end
desc 'Delete deploy key for a project' do
success Key
end
......@@ -115,11 +101,9 @@ module API
end
delete ":id/deploy_keys/:key_id" do
key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id])
if key
key.destroy
else
not_found!('Deploy Key')
end
not_found!('Deploy Key') unless key
key.destroy
end
end
end
......
......@@ -148,25 +148,4 @@ describe API::DeployKeys, api: true do
end
end
end
describe 'DELETE /projects/:id/deploy_keys/:key_id/disable' do
context 'when the user can admin the project' do
it 'disables the key' do
expect do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}/disable", admin)
end.to change { project.deploy_keys.count }.from(1).to(0)
expect(response).to have_http_status(200)
expect(json_response['id']).to eq(deploy_key.id)
end
end
context 'when authenticated as non-admin user' do
it 'should return a 404 error' do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}/disable", user)
expect(response).to have_http_status(404)
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment