通过API确定协作者的权限(对一个组织回购)? [英] Determine a collaborator's permissions (to an organization repos) via the api?

查看:132
本文介绍了通过API确定协作者的权限(对一个组织回购)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在属于一个组织(而不是个人)一个回购协议,合作者小组的成员,和团队可以有三种不同的权限:


  • 仅拉出

  • 推&放大器;拉

  • 推,拉,&安培;行政

我可以看到这样的回购合作者的名单:

  GET /回购/:业主/:回购/​​合作者

...但它并没有告诉我的合作者有什么类型的权限。

在这种特殊情况下,我的合作者之一;我没有自己的资源库。

有没有一种方法以编程方式确定我的合作者许可的类型?


解决方案

在一个查询,其中应包括您的许可中提到的列表用户小组

  GET /用户/支


  

列出所有在所有经过身份验证的用户所属的组织的团队。此方法需要用户或回购范围通过的 OAuth的


答案是这样的:

 状态:200 OK
的X RateLimit限额:5000
的X RateLimit-剩余:4999[
  {
    URL:https://api.github.com/teams/1
    名:业主,
    标识:1,
    权限:管理,< ============
    MEMBERS_COUNT:3,
    repos_count:10,
    组织:{
      登录:github上
      标识:1,
      URL:https://api.github.com/orgs/github
      avatar_url:https://github.com/images/error/octocat_happy.gif
    }
  }
]

您需要的结果过滤,以球队以匹配正确的回购以及你应当得到相关于回购这样的权限级别。

In a repos that belongs to an organization (as opposed to an individual), collaborators are members of "teams", and teams can have three different kinds of permissions:

  • Pull Only
  • Push & Pull
  • Push, Pull, & Administrative

I can see a list of collaborators on a repos like this:

GET /repos/:owner/:repo/collaborators

...but it does not tell me what type of permissions a collaborator has.

In this particular case, I am one of the collaborators; I do not own the repository.

Is there a way to programmatically determine the type of collaborator permission I have?

解决方案

The one query which should include your permission is mentioned in "List User Teams"

GET /user/teams

List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth.

The answer looks like:

Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999

[
  {
    "url": "https://api.github.com/teams/1",
    "name": "Owners",
    "id": 1,
    "permission": "admin",                     <============
    "members_count": 3,
    "repos_count": 10,
    "organization": {
      "login": "github",
      "id": 1,
      "url": "https://api.github.com/orgs/github",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif"
    }
  }
]

You need to filter that result in order to match the team with the right repo, and you should get back the permission level associated to that repo that way.

这篇关于通过API确定协作者的权限(对一个组织回购)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆