Add get/delete/update API methods for instance deploy keys

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Proposal

I wish to propose adding three API endpoints:

  • Delete instance-level deploy_key
  • Get a single instance-level deploy_key
  • Update an instance-level deploy_key

The reason for this is that:

  • The Terraform provider for Gitlab only has resources for project-level deploy keys and a data source for listing all instance-level deploy keys.
  • The Terraform provider would (generally) require standard CRUD methods for a resource. Currently, only a create API endpoint exists and an endpoint to list instance-level deploy keys.

Proposition for API endpoint details:

  • All endpoints would only be available in self-hosted instances for Administrators (as per the "list all instance-level deploy keys"

Delete endpoint

This would mimic the same behavoir as the DELETE method for the project-level deploy key.

DELETE /deploy_keys/:key_id`

Get endpoint

This mimicss the GET method for a single project-level deploy key, minus the "can_push" attribute, as this is not set at instance-level keys

GET /deploy_keys/:key_id
Response:
{
  "id": 1,
  "title": "Public key",
  "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNJAkI3Wdf0r13c8a5pEExB2YowPWCSVzfZV22pNBc1CuEbyYLHpUyaD0GwpGvFdx2aP7lMEk35k6Rz3ccBF6jRaVJyhsn5VNnW92PMpBJ/P1UebhXwsFHdQf5rTt082cSxWuk61kGWRQtk4ozt/J2DF/dIUVaLvc+z4HomT41fQ==",
  "fingerprint": "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9",
  "fingerprint_sha256": "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU",
  "created_at": "2013-10-02T10:12:29Z",
  "expires_at": null
}

Update endpoint:

PUT /deploy_keys/:key_id
Body:
{
  "title": "New title"
}
Repsonse:
{
   "id": 11,
   "title": "New title",
   "key": "ssh-rsa AAAA...",
   "created_at": "2015-08-29T12:44:31.550Z",
   "expires_at": null
}
Edited by 🤖 GitLab Bot 🤖