cn 我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

互动

本文内容

用户通过评论、开设议题和创建拉取请求与仓库进行交互。 交互 API 允许具有公共仓库所有者或具有管理员访问权限的用户临时将与公共仓库的交互限于特定类型的用户。

组织

组织交互 API 允许组织所有者临时限制哪类用户可以在组织的公共仓库中发表评论、开设议题或创建拉取请求。 启用限制后,只有指定的 GitHub 用户类型才能参与交互。 限制在定义的期限后自动过期。 以下是有关 GitHub 用户类型的更多信息:

  • 组织中的 现有用户:当您将交互限制为 existing_users时,帐户年龄小于 24 小时、以前未参与并且不是协作者的新用户将暂时受到限制。。
  • 组织中的 仅参与者:当您将交互限制为 contributors_only时,以前未参与并且不是协作者的用户将暂时受到限制。。
  • 组织中的 仅协作者:当您将交互限制为 collaborators_only 时,非协作者用户将暂时受到限制。。

在组织级别设置交互限制将覆盖为组织拥有的各个仓库设置的任何交互限制。 要为组织拥有的各个仓库设置不同的交互限制,请改用仓库交互端点。

Get interaction restrictions for an organization

Shows which type of GitHub user can interact with this organization and when the restriction expires. If there is no restrictions, you will see an empty response.

get /orgs/{org}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

org string path

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/orgs/ORG/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('GET /orgs/{org}/interaction-limits', {
  org: 'org'
})

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "organization",
  "expires_at": "2018-08-17T04:18:39Z"
}

Notes


Set interaction restrictions for an organization

Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization.

put /orgs/{org}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

org string path
limit string body

Required. The type of GitHub user that can comment, open issues, or create pull requests while the interaction limit is in effect. Can be one of: existing_users, contributors_only, collaborators_only.

expiry string body

The duration of the interaction restriction. Can be one of: one_day, three_days, one_week, one_month, six_months. Default: one_day.

代码示例

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/orgs/ORG/interaction-limits \
  -d '{"limit":"limit"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /orgs/{org}/interaction-limits', {
  org: 'org',
  limit: 'limit'
})

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "organization",
  "expires_at": "2018-08-17T04:18:39Z"
}

Validation failed

Status: 422 Unprocessable Entity

Notes


Remove interaction restrictions for an organization

Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions.

delete /orgs/{org}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

org string path

代码示例

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/orgs/ORG/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('DELETE /orgs/{org}/interaction-limits', {
  org: 'org'
})

Default Response

Status: 204 No Content

Notes


仓库

仓库交互 API 允许具有所有者或管理员权限的用户临时限制哪类用户可以在公共仓库中发表评论、开设议题或创建拉取请求。 启用限制后,只有指定的 GitHub 用户类型才能参与交互。 限制在定义的期限后自动过期。 以下是有关 GitHub 用户类型的更多信息:

  • 仓库中的 现有用户:当您将交互限制为 existing_users时,帐户年龄小于 24 小时、以前未参与并且不是协作者的新用户将暂时受到限制。。
  • 仓库中的 仅参与者:当您将交互限制为 contributors_only时,以前未参与并且不是协作者的用户将暂时受到限制。。
  • 仓库中的 仅协作者:当您将交互限制为 collaborators_only 时,非协作者用户将暂时受到限制。。

如果对拥有该仓库的用户或组织启用了交互限制,单个仓库的限制就不能更改。 而应使用用户组织交互端点来更改交互限制。

Get interaction restrictions for a repository

Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response.

get /repos/{owner}/{repo}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

owner string path
repo string path

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/octocat/hello-world/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('GET /repos/{owner}/{repo}/interaction-limits', {
  owner: 'octocat',
  repo: 'hello-world'
})

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "repository",
  "expires_at": "2018-08-17T04:18:39Z"
}

Notes


Set interaction restrictions for a repository

Temporarily restricts interactions to a certain type of GitHub user within the given repository. You must have owner or admin access to set these restrictions. If an interaction limit is set for the user or organization that owns this repository, you will receive a 409 Conflict response and will not be able to use this endpoint to change the interaction limit for a single repository.

put /repos/{owner}/{repo}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

owner string path
repo string path
limit string body

Required. The type of GitHub user that can comment, open issues, or create pull requests while the interaction limit is in effect. Can be one of: existing_users, contributors_only, collaborators_only.

expiry string body

The duration of the interaction restriction. Can be one of: one_day, three_days, one_week, one_month, six_months. Default: one_day.

代码示例

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/octocat/hello-world/interaction-limits \
  -d '{"limit":"limit"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /repos/{owner}/{repo}/interaction-limits', {
  owner: 'octocat',
  repo: 'hello-world',
  limit: 'limit'
})

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "repository",
  "expires_at": "2018-08-17T04:18:39Z"
}

Conflict

Status: 409 Conflict

Notes


Remove interaction restrictions for a repository

Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions. If the interaction limit is set for the user or organization that owns this repository, you will receive a 409 Conflict response and will not be able to use this endpoint to change the interaction limit for a single repository.

delete /repos/{owner}/{repo}/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

owner string path
repo string path

代码示例

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/octocat/hello-world/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('DELETE /repos/{owner}/{repo}/interaction-limits', {
  owner: 'octocat',
  repo: 'hello-world'
})

Default Response

Status: 204 No Content

Conflict

Status: 409 Conflict

Notes


用户

用户交互 API 允许您临时限制哪类用户可以在公共仓库上发表评论、开设问题或创建拉取请求。 启用限制后,只有指定的 GitHub 用户类型才能参与交互。 限制在定义的期限后自动过期。 以下是有关 GitHub 用户类型的更多信息:

  • 与仓库交互产生的 现有用户:当您将交互限制为 existing_users时,帐户年龄小于 24 小时、以前未参与并且不是协作者的新用户将暂时受到限制。。
  • 与仓库交互产生的 仅参与者:当您将交互限制为 contributors_only时,以前未参与并且不是协作者的用户将暂时受到限制。。
  • 与仓库交互产生的 仅协作者:当您将交互限制为 collaborators_only 时,非协作者用户将暂时受到限制。。

在用户级别设置交互限制将覆盖为用户拥有的各个仓库设置的任何交互限制。 要为用户拥有的个别仓库设置不同的交互限制,请使用仓库交互端点。

Get interaction restrictions for your public repositories

Shows which type of GitHub user can interact with your public repositories and when the restriction expires. If there are no restrictions, you will see an empty response.

get /user/interaction-limits

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('GET /user/interaction-limits')

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "user",
  "expires_at": "2018-08-17T04:18:39Z"
}

Set interaction restrictions for your public repositories

Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user.

put /user/interaction-limits

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

limit string body

Required. The type of GitHub user that can comment, open issues, or create pull requests while the interaction limit is in effect. Can be one of: existing_users, contributors_only, collaborators_only.

expiry string body

The duration of the interaction restriction. Can be one of: one_day, three_days, one_week, one_month, six_months. Default: one_day.

代码示例

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/interaction-limits \
  -d '{"limit":"limit"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /user/interaction-limits', {
  limit: 'limit'
})

Default response

Status: 200 OK
{
  "limit": "collaborators_only",
  "origin": "user",
  "expires_at": "2018-08-17T04:18:39Z"
}

Validation failed

Status: 422 Unprocessable Entity

Remove interaction restrictions from your public repositories

Removes any interaction restrictions from your public repositories.

delete /user/interaction-limits

代码示例

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/interaction-limits
JavaScript (@octokit/core.js)
await octokit.request('DELETE /user/interaction-limits')

Default Response

Status: 204 No Content

此文档对您有帮助吗?

Privacy policy

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。