适用于企业团队组织的 REST API 终结点
使用 REST API 为 GitHub enterprise 中的企业团队创建和管理组织分配。
关于企业团队的组织构架
注意
这些终结点目前为 公共预览版,可能会更改。
此 API 文档适用于使用 GitHub Enterprise Cloud 的企业。
如果你的企业使用的是面向非 GHE 的 Copilot Business,请参考此前已向你共享的早期访问文档链接。
这些终结点仅对拥有经典 personal access tokens 且具备 read:enterprisescope 权限(针对 GET API)和 admin:enterprise 权限(针对其他 API)的企业团队中经过身份验证的成员开放。
这些终结点与 fine-grained personal access tokens 或 GitHub Apps 访问令牌不兼容。
GitHub 会从团队 name 生成企业团队的 slug,并添加 ent: 前缀。
Get organization assignments
Get all organizations assigned to an enterprise team
“Get organization assignments”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (read)
“Get organization assignments”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
| 名称, 类型, 说明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“Get organization assignments”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | An array of organizations the team is assigned to |
“Get organization assignments”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizationsAn array of organizations the team is assigned to
Status: 200{
"login": "github",
"id": 1,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://HOSTNAME/orgs/github",
"repos_url": "https://HOSTNAME/orgs/github/repos",
"events_url": "https://HOSTNAME/orgs/github/events",
"hooks_url": "https://HOSTNAME/orgs/github/hooks",
"issues_url": "https://HOSTNAME/orgs/github/issues",
"members_url": "https://HOSTNAME/orgs/github/members{/member}",
"public_members_url": "https://HOSTNAME/orgs/github/public_members{/member}",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}Add organization assignments
Assign an enterprise team to multiple organizations.
“Add organization assignments”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“Add organization assignments”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
| 名称, 类型, 说明 |
|---|
organization_slugs array of strings 必须Organization slug to assign the team to. |
“Add organization assignments”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | Successfully assigned the enterprise team to organizations. |
“Add organization assignments”的示例代码
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/add \
-d '{"organization_slugs":["github"]}'Successfully assigned the enterprise team to organizations.
Status: 200[
{
"login": "github",
"id": 1,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://HOSTNAME/orgs/github",
"repos_url": "https://HOSTNAME/orgs/github/repos",
"events_url": "https://HOSTNAME/orgs/github/events",
"hooks_url": "https://HOSTNAME/orgs/github/hooks",
"issues_url": "https://HOSTNAME/orgs/github/issues",
"members_url": "https://HOSTNAME/orgs/github/members{/member}",
"public_members_url": "https://HOSTNAME/orgs/github/public_members{/member}",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}
]Remove organization assignments
Unassign an enterprise team from multiple organizations.
“Remove organization assignments”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“Remove organization assignments”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
| 名称, 类型, 说明 |
|---|
organization_slugs array of strings 必须Organization slug to unassign the team from. |
“Remove organization assignments”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
204 | Successfully unassigned the enterprise team from organizations. |
“Remove organization assignments”的示例代码
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/remove \
-d '{"organization_slugs":["github"]}'Successfully unassigned the enterprise team from organizations.
Status: 204Get organization assignment
Check if an enterprise team is assigned to an organization
“Get organization assignment”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (read)
“Get organization assignment”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
org string 必须The organization name. The name is not case sensitive. |
“Get organization assignment”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | The team is assigned to the organization |
404 | The team is not assigned to the organization |
“Get organization assignment”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORGThe team is assigned to the organization
Status: 200{
"login": "github",
"id": 1,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://HOSTNAME/orgs/github",
"repos_url": "https://HOSTNAME/orgs/github/repos",
"events_url": "https://HOSTNAME/orgs/github/events",
"hooks_url": "https://HOSTNAME/orgs/github/hooks",
"issues_url": "https://HOSTNAME/orgs/github/issues",
"members_url": "https://HOSTNAME/orgs/github/members{/member}",
"public_members_url": "https://HOSTNAME/orgs/github/public_members{/member}",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}Add an organization assignment
Assign an enterprise team to an organization.
“Add an organization assignment”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“Add an organization assignment”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
org string 必须The organization name. The name is not case sensitive. |
“Add an organization assignment”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
201 | Successfully assigned the enterprise team to the organization. |
“Add an organization assignment”的示例代码
请求示例
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORGSuccessfully assigned the enterprise team to the organization.
Status: 201{
"login": "github",
"id": 1,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://HOSTNAME/orgs/github",
"repos_url": "https://HOSTNAME/orgs/github/repos",
"events_url": "https://HOSTNAME/orgs/github/events",
"hooks_url": "https://HOSTNAME/orgs/github/hooks",
"issues_url": "https://HOSTNAME/orgs/github/issues",
"members_url": "https://HOSTNAME/orgs/github/members{/member}",
"public_members_url": "https://HOSTNAME/orgs/github/public_members{/member}",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}Delete an organization assignment
Unassign an enterprise team from an organization.
“Delete an organization assignment”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“Delete an organization assignment”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
enterprise-team string 必须The slug version of the enterprise team name. You can also substitute this value with the enterprise team id. |
org string 必须The organization name. The name is not case sensitive. |
“Delete an organization assignment”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
204 | Successfully unassigned the enterprise team from the organization. |
“Delete an organization assignment”的示例代码
请求示例
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORGSuccessfully unassigned the enterprise team from the organization.
Status: 204