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

互动

本文内容

此文档对您有帮助吗?

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

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

做出贡献

或, 了解如何参与。

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

组织

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

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

  • 组织中的 仅参与者:当您将交互限制为 contributors_only时,以前未参与并且不是协作者的用户将暂时受到限制。。

  • 组织中的 仅协作者:当您将交互限制为 collaborators_only 时,非协作者用户将暂时受到限制。。

    Get interaction restrictions for an organization

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

    get /orgs/{org}/interaction-limits

    参数

    Name Type In Description
    accept string header

    This API is under preview and subject to change. 查看预览通知

    org string path

    代码示例

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

    Default response

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

    Notes

    预览通知

    The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

    application/vnd.github.sombra-preview
    
    ☝️ 此标头必填.

    Set interaction restrictions for an organization

    Temporarily restricts interactions to certain GitHub users in any public repository in the given organization. You must be an organization owner to set these restrictions.

    put /orgs/{org}/interaction-limits

    参数

    Name Type In Description
    accept string header

    This API is under preview and subject to change. 查看预览通知

    org string path
    limit string body

    Required. Specifies the group of GitHub users who can comment, open issues, or create pull requests in public repositories for the given organization. Must be one of: existing_users, contributors_only, or collaborators_only.

    代码示例

    Shell
    curl \
      -X PUT \
      -H "Accept: application/vnd.github.sombra-preview+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',
      mediaType: {
        previews: [
          'sombra'
        ]
      }
    })
    

    Default response

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

    Validation failed

    Status: 422 Unprocessable Entity

    Notes

    预览通知

    The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

    application/vnd.github.sombra-preview
    
    ☝️ 此标头必填.

    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

    This API is under preview and subject to change. 查看预览通知

    org string path

    代码示例

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

    Default Response

    Status: 204 No Content

    Notes

    预览通知

    The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

    application/vnd.github.sombra-preview
    
    ☝️ 此标头必填.

仓库

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

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

Get interaction restrictions for a repository

Shows which group of GitHub users 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

This API is under preview and subject to change. 查看预览通知

owner string path
repo string path

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.sombra-preview+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',
  mediaType: {
    previews: [
      'sombra'
    ]
  }
})

Default response

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

Notes

预览通知

The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.sombra-preview
☝️ 此标头必填.

Set interaction restrictions for a repository

Temporarily restricts interactions to certain GitHub users within the given repository. You must have owner or admin access to set restrictions.

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

参数

Name Type In Description
accept string header

This API is under preview and subject to change. 查看预览通知

owner string path
repo string path
limit string body

Required. Specifies the group of GitHub users who can comment, open issues, or create pull requests for the given repository. Must be one of: existing_users, contributors_only, or collaborators_only.

代码示例

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.sombra-preview+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',
  mediaType: {
    previews: [
      'sombra'
    ]
  }
})

Default response

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

Notes

预览通知

The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.sombra-preview
☝️ 此标头必填.

Remove interaction restrictions for a repository

Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions.

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

参数

Name Type In Description
accept string header

This API is under preview and subject to change. 查看预览通知

owner string path
repo string path

代码示例

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.sombra-preview+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',
  mediaType: {
    previews: [
      'sombra'
    ]
  }
})

Default Response

Status: 204 No Content

Notes

预览通知

The Interactions API is currently in public preview. See the blog post preview for more details. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.sombra-preview
☝️ 此标头必填.

此文档对您有帮助吗?

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

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

做出贡献

或, 了解如何参与。