Add api call for getting the list of all billable members of a Self-Managed instance
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
A large premium customer would like a simpler set of API to query the value of billable users on a Self-Managed instance.
We currently can:
- List all billable members of a group, which is great for SaaS customers, but not fitting instance wide for a Self-Managed installation.
- Make a GraphQL request to get the Billable Users Count, but not the list of users:
GraphQL request to get the Billable Users Count
#!/bin/bash
# GitLab instance URL
URL="YOUR_GITLAB_URL/api/graphql"
# Your personal access token
TOKEN="YOUR_TOKEN"
# GraphQL query
QUERY='
{
"query": "{ currentLicense { billableUsersCount } }"
}
'
# Make the GraphQL request
response=$(curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$QUERY" \
"$URL")
# Extract the billableUsersCount from the response
billable_users_count=$(echo $response | jq -r '.data.currentLicense.billableUsersCount')
# Check if the request was successful
if [ $? -eq 0 ] && [ "$billable_users_count" != "null" ]; then
echo "Billable Users Count: $billable_users_count"
else
echo "Error: Failed to retrieve billableUsersCount"
echo "Response: $response"
fi
The only way we found for the customer to get this is the following:
Right now we're querying the API with these commands, and then merge the 2 jsons together to get the output required, but we still have to filter the results afterwards to get the true number of billable users.
https://gitlab.example.com/api/v4/users?per_page=100&active=true&page=1https://gitlab.example.com/api/v4/users?per_page=100&active=true&page=2If we filter on "using_license_seat":true" we get the same number, but the total number of users in that combined json is 178 (if we search for the term below to filter out unique users).
,{"id"So if possible, we'd like to be able to get a json or some output that only contains those 142 billable users without having to filter the results afterwards.
So having an API call which provide the list of all billable members would be quite handy.