github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Does the github api support getting a collaborator by username?

Open darewreck54 opened this issue 5 years ago • 2 comments

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

darewreck54 avatar Oct 28 '19 04:10 darewreck54

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

bitwiseman avatar Oct 29 '19 00:10 bitwiseman

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.

tedyoung avatar Jun 03 '21 01:06 tedyoung