Github Enterprise API - determine if a user is dormant?
Asked Answered
D

1

8

Running Github Enterprise 2.18. Is there any way to determine via the API that a user is dormant? I don't see a specific call for it anywhere...

Denotative answered 5/2, 2020 at 15:3 Comment(5)
I don't get the downvote. Did you want me to list all the sources I've looked at? I spent almost 2 weeks trying to figure this out. Between the Github API docs and everything I can find on Google/Stackoverflow I can't find a solution that's been published.Denotative
Me neither. Have an upvote.Gefen
Hi @RichardSchaefer, are you an admin? Have you considered using the log auditing option instead of the API? For example, audited actions include user.login (A user signed in) and a lot more.Tuna
That doesn't really help unless I'm going to do all the research to see if each user did anything in the last 30 days. I'd need to know all the things Github checks to produce the "dormant users" report. We have thousands of users and doing all that work seems counterproductive, but looking at the dormant users report and how long it takes to create I suspect even Github recalculates it every time. That's OK for a report but we were looking for something a little more dynamic per user. Oh well.Denotative
True, at least I was looking at this challenge as something requiring some work, like using the API (to check the activity endpoint) and/or auditing the logs (to check for sign-in and more). But I will keep coming back to this question to see if anyone knows of something ready and available to achieve this goal.Tuna
H
4

To answer your question....

Running Github Enterprise 2.18. Is there any way to determine via the API that a user is dormant?

No, it's not possible using GitHub API (Enterprise or not).

GitHub has a strict privacy agreement for it's users. Since repositories can be public as well as private, you're out of luck getting dormancy info via their API.

GitHub's own help page mentions it in their "Reports" section:

If you need to get information on the users, organizations, and repositories in your GitHub Enterprise Server instance, you would ordinarily fetch JSON data through the GitHub API. Unfortunately, the API may not provide all of the data that you want and it requires a bit of technical expertise to use. The site admin dashboard offers a Reports section as an alternative, making it easy for you to download CSV reports with most of the information that you are likely to need for users, organizations, and repositories.

Specifically, you can download CSV reports that list

  • all users
  • all users who have been active within the last month
  • all users who have been inactive for one month or more
  • all users whohave been suspended
  • all organizations
  • all repositories

The help page also goes on to show examples on how to invoke the report data via CURL (you could do this with other methods as well, like in Powershell, which I prefer)

curl -L -u username:password/token http(s)://hostname/stafftools/reports/dormant_users.csv

You could make use of that data, without the API and parse it into your application. The world is your oyster.

Hawkie answered 25/2, 2020 at 0:18 Comment(3)
This is Github Enterprise, not github.com and I'm a Github Enterprise admin so there's no privacy :-). I can run the entire report and parse it but the reason for the query is to determine the status of an individual user in real-time with "immediate" (i.e. 1 or 2 seconds) response time. It appears there's no simple, quick way to do that.Denotative
@RichardSchaefer okay, I updated the url for the license agreement page. It's even more verbose and longer for Enterprise edition. Also, read my answer more carefully, specifically the quote in yellow first sentence. It specifically mentions GitHub enterprise and how there is limitations in the GitHub API for it (admin or not). You have to use the CSV reports to get the data you're looking for, and they come in CSV format only. The API cannot do what you're asking. Also, there is a user last_active CSV report available as well.Hawkie
Thanks. I posted here primarily to make sure I hadn't missed anything. The Github API docs can be a bit obtuse. The use case I've been requested to develop for is real-time,immediate for a single user. It appears I'm limited to generating the CSV report so that won't work as it takes several minutes in our configuration due to the number of users and level of activity. I guess i'll have to tell the requester there's no real good way to do it. Thanks again.Denotative

© 2022 - 2024 — McMap. All rights reserved.