Skip to content

Project Deploy Keys API for User

Bala Kumar requested to merge 28766-user-deploy-keys-api into master

What does this MR do and why?

Adds GET api/v4/users/:user_id_or_name/project_deploy_keys api endpoint.

It implements the iteration proposal as discussed in

All enabled project deploy keys from projects that the user is already a maintainer/owner.

This API endpoint lists the project deploy keys only from those projects where the current_user (who is authenticated) and the given user_id are common project members.

Also the API endpoint is similar to https://docs.gitlab.com/ee/api/users.html#list-ssh-keys-for-user

Documentation additions will be covered in a separate MR

Screenshots or screen recordings

project_deploy_keys_api

  • In the screencast user: 101 is maintainer for demo project and user: 1 is also a maintainer of the demo project. user: 1 is also maintainer for other projects in addition to demo project.
  • GET api/v4/users/101/project_deploy_keys -> response is key with id 15 from the demo project.
  • GET api/v4/users/1/project_deploy_keys -> response is keys with id 11, 13 (keys of other projects) and keys with id 15 which is from the demo project.

How to set up and validate locally

  1. Create project deploy keys in local following the steps in doc link.
  2. > curl --header "PRIVATE-TOKEN: <token>" "http://localhost:3000/api/v4/users/<user_id>/project_deploy_keys should return keys as shown in the screencast above.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #28766 (closed)

Edited by Bala Kumar

Merge request reports