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