Skip to content

Add `gitlab_com_paid_user?` to the users API

Kenneth Chu requested to merge kenneth-gitlab-paid-users-api into master

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:

  1. Make a new Group
  2. Make a new user. Let's assume the ID of the user in this example is 70.
  3. Add the user as a guest user to the group we created in step (1).
  4. As an administrator user, go to http://<gdk_instance>/api/v4/users/70
  5. using_license_seat should be false for this user. and gitlab_com_paid_user should not be present in the API response.
  6. Simulate SaaS and make the group on the Ultimate plan.
  7. As an administrator user, go to http://<gdk_instance>/api/v4/users/70
  8. gitlab_com_paid_user should be true for this user, and using_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.

Merge request reports