Skip to main content
Ahora la API de REST tiene control de versiones. Para obtener más información, consulta "Acerca del control de versiones de la API".

Puntos de conexión de la API de REST para interacciones de repositorio

Usa la API REST para restringir temporalmente qué tipo de usuario puede comentar, abrir incidencias o crear solicitudes de incorporación de cambios en un repositorio público.

¿Quién puede utilizar esta característica?

People with owner or admin access to temporarily restrict which type of user can comment, open issues, or create pull requests in a public repository.

Acerca de las interacciones del repositorio

Las personas con acceso administrativo o de propietario pueden usar la API REST para restringir temporalmente qué tipo de usuario puede comentar, abrir incidencias o crear solicitudes de incorporación de cambios en un repositorio público. Cuando se habilitan las restricciones, solo el tipo de usuario de GitHub Enterprise Cloud que hayas especificado podrá participar en las interacciones. Las restricciones expiran automáticamente después de una duración definida. Aquí puedes aprender más sobre los tipos de usuario de GitHub Enterprise Cloud:

  • Usuarios existentes: al limitar las interacciones a existing_users, los nuevos usuarios con cuentas con menos de 24 horas de antigüedad que no hayan contribuido previamente y no sean colaboradores se restringirán temporalmente. en el repositorio.
  • Solo colaboradores: cuando limita las interacciones a contributors_only, se restringe temporalmente a los usuarios que no han contribuido previamente y no son colaboradores. en el repositorio.
  • Solo colaboradores: al limitar las interacciones a collaborators_only, los usuarios que no son colaboradores se restringirán temporalmente. en el repositorio.

Si se habilita un límite de interacción para el usuario u organización a la que pertenece el repositorio, éste no podrá cambiarse para el repositorio individual. En su lugar, use los puntos de conexión de interacciones de usuario u organización para cambiar el límite de interacción.

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.

Tokens de acceso específicos para "Get interaction restrictions for a repository"

Este punto de conexión funciona con los siguientes tipos de token:

El token debe tener el siguiente conjunto de permisos.:

  • administration:read

Parámetros para "Get interaction restrictions for a repository"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

The account owner of the repository. The name is not case sensitive.

repo string Requerido

The name of the repository without the .git extension. The name is not case sensitive.

Códigos de estado de respuesta HTTP para "Get interaction restrictions for a repository"

status codeDescripción
200

OK

Ejemplos de código para "Get interaction restrictions for a repository"

Ejemplo de solicitud

get/repos/{owner}/{repo}/interaction-limits
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits

Response

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

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.

Tokens de acceso específicos para "Set interaction restrictions for a repository"

Este punto de conexión funciona con los siguientes tipos de token:

El token debe tener el siguiente conjunto de permisos.:

  • administration:write

Parámetros para "Set interaction restrictions for a repository"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

The account owner of the repository. The name is not case sensitive.

repo string Requerido

The name of the repository without the .git extension. The name is not case sensitive.

Parámetros del cuerpo
Nombre, Tipo, Descripción
limit string Requerido

The type of GitHub user that can comment, open issues, or create pull requests while the interaction limit is in effect.

Puede ser uno de los siguientes: existing_users, contributors_only, collaborators_only

expiry string

The duration of the interaction restriction. Default: one_day.

Puede ser uno de los siguientes: one_day, three_days, one_week, one_month, six_months

Códigos de estado de respuesta HTTP para "Set interaction restrictions for a repository"

status codeDescripción
200

OK

409

Conflict

Ejemplos de código para "Set interaction restrictions for a repository"

Ejemplo de solicitud

put/repos/{owner}/{repo}/interaction-limits
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits \ -d '{"limit":"collaborators_only","expiry":"one_day"}'

Response

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

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.

Tokens de acceso específicos para "Remove interaction restrictions for a repository"

Este punto de conexión funciona con los siguientes tipos de token:

El token debe tener el siguiente conjunto de permisos.:

  • administration:write

Parámetros para "Remove interaction restrictions for a repository"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

The account owner of the repository. The name is not case sensitive.

repo string Requerido

The name of the repository without the .git extension. The name is not case sensitive.

Códigos de estado de respuesta HTTP para "Remove interaction restrictions for a repository"

status codeDescripción
204

No Content

409

Conflict

Ejemplos de código para "Remove interaction restrictions for a repository"

Ejemplo de solicitud

delete/repos/{owner}/{repo}/interaction-limits
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/interaction-limits

Response

Status: 204