github-api
github-api copied to clipboard
Does the github api support getting a collaborator by username?
Is the following API supported?
GET /repos/:owner/:repo/collaborators/:username
https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
Also does collaborator just imply a user that has write access?
I looked at the code but i'm not seeing it in the GHRepository.java file. Wanted to verify if I was just not seeing it?
Thanks, Derek
Not for a single user, but you can get a list and go from there. https://github.com/github-api/github-api/blob/efb87c5a9ec5ae2c7e63b0fe7b43ccc199f627b2/src/main/java/org/kohsuke/github/GHRepository.java#L484
Collaborator is distinct from write access and differs depending on the type of repository:
-
User repo: https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/permission-levels-for-a-user-account-repository#collaborator-access-on-a-repository-owned-by-a-user-account
-
Organization repo: https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/adding-outside-collaborators-to-repositories-in-your-organization
I came across a need for this behavior, i.e., checking if a single user was already a Collaborator on a Repository, so I don't have to fetch the entire list each time (or deal with caching it).
It seems fairly straightforward to implement, as the API returns either a 204 (user is a collaborator) or 404 (they're not), and is similar to the hasAssignee
code.
I can submit a pull request to implement this if desired.