Add `gitlab_com_paid_user?` to the users API
What does this MR do and why?
Why: The Support team finds it useful in our automations if the API can reveal if a user is associated with a paid namespace or not. We have been using using_license_seat
in the API, but it seems that always returns true on GitLab.com because part of its' checks is to see if the instance has a license or not, rather than the namespace. (Meaning it's only effective on Self-Managed instances).
What: This MR attempts to introduce a gitlab_com_paid_user?
function to the codebase and is exposed in the API that checks if a user is a member (including the guest role) of a paid namespace. I did not use the using_gitlab_com_seat?
method that was already present because it skips counting guest users on the Ultimate plan.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Using GDK:
- Make a new Group
- Make a new user. Let's assume the ID of the user in this example is
70
. - Add the user as a guest user to the group we created in step (1).
- As an administrator user, go to
http://<gdk_instance>/api/v4/users/70
-
using_license_seat
should be false for this user. andgitlab_com_paid_user
should not be present in the API response. -
Simulate SaaS and make the group on the
Ultimate
plan. - As an administrator user, go to
http://<gdk_instance>/api/v4/users/70
-
gitlab_com_paid_user
should be true for this user, andusing_license_seat
should not be present in the API response.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.