Skip to content

API option for returning top level namespaces only

Tyler Amos requested to merge 7600-ns-api-top-level-only into master

What does this MR do and why?

Related to customers-gitlab-com#7600 (closed)

This MR adds the option top_level_only to the GET namespaces API endpoint which returns only top level namespaces.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Ensure the user you test with has the following:
    1. at least one group with a subgroup. If not, create one in GDK.
    2. a personal access token with API access. If not create one and note the token.
  2. On the master branch:
    1. Using Postman (you could also use curl or even your browser if you wanted), setup the GET request http://localhost:3000/api/v4/namespaces?top_level_only=true
    2. You'll need to set the header PRIVATE-TOKEN and supply the access token for your user.
    3. Send the request and note how many namespaces are returned. It should include subgroups. If you search for the attribute parent_id it should include those that are null (top level groups) but also have some that have a value (sub-groups).
  3. Now switch to this branch, 7600-ns-api-top-level-only:
    1. Retry the request from before. You should see that subgroups are not included.
    2. Also try the request following requests and ensure they still include subgroups:
      1. http://localhost:3000/api/v4/namespaces?top_level_only=false
      2. http://localhost:3000/api/v4/namespaces
Edited by Tyler Amos

Merge request reports