Skip to main content
L’API REST est maintenant versionnée. Pour plus d’informations, consultez « À propos des versions de l’API ».

Points de terminaison d’API REST pour les interactions de dépôt

Utilisez l’API REST pour restreindre temporairement le type d’utilisateur qui peut commenter, ouvrir des problèmes ou créer des demandes de tirage sur un référentiel public.

Qui peut utiliser cette fonctionnalité ?

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.

À propos des interactions de référentiel

Les personnes avec un accès propriétaire ou administrateur peuvent utiliser l’API REST pour restreindre temporairement le type d’utilisateur qui peut commenter, ouvrir des problèmes ou créer des demandes de tirage sur un référentiel public. Lorsque des restrictions sont activées, seul le type spécifié d’utilisateur GitHub Enterprise Cloud pourra participer aux interactions. Les restrictions expirent automatiquement après une durée définie. Voici plus d’informations sur les types d’utilisateurs GitHub Enterprise Cloud :

  • Utilisateurs existants : Lorsque vous limitez les interactions aux existing_users, les nouveaux utilisateurs avec des comptes de moins de 24 heures qui n’ont pas déjà contribué et qui ne sont pas collaborateurs seront temporairement limités. dans le référentiel.
  • Contributeurs uniquement : Lorsque vous limitez les interactions aux contributors_only, les utilisateurs qui n’ont pas déjà contribué et qui ne sont pas collaborateurs sont temporairement limités. dans le référentiel.
  • Collaborateurs uniquement : lorsque vous limitez les interactions en choisissant collaborators_only, les utilisateurs qui ne sont pas des collaborateurs sont temporairement limités dans le référentiel.

Si une limite d’interaction est activée pour l’utilisateur ou l’organisation propriétaire du référentiel, la limite ne peut pas être modifiée pour le référentiel individuel. Utilisez plutôt des points de terminaison d’interaction utilisateur ou d’organisation pour modifier la limite d’interaction.

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.

Jetons d’accès affinés pour « Get interaction restrictions for a repository »

Ce point de terminaison fonctionne avec les types de jetons suivants:

Le jeton doit avoir l’ensemble d’autorisations suivant:

  • administration:read

Paramètres pour « Get interaction restrictions for a repository »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Codes d’état de la réponse HTTP pour « Get interaction restrictions for a repository »

Code d’étatDescription
200

OK

Exemples de code pour « Get interaction restrictions for a repository »

Exemple de requête

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.

Jetons d’accès affinés pour « Set interaction restrictions for a repository »

Ce point de terminaison fonctionne avec les types de jetons suivants:

Le jeton doit avoir l’ensemble d’autorisations suivant:

  • administration:write

Paramètres pour « Set interaction restrictions for a repository »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Paramètres du corps
Nom, Type, Description
limit string Obligatoire

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

Peut être: existing_users, contributors_only, collaborators_only

expiry string

The duration of the interaction restriction. Default: one_day.

Peut être: one_day, three_days, one_week, one_month, six_months

Codes d’état de la réponse HTTP pour « Set interaction restrictions for a repository »

Code d’étatDescription
200

OK

409

Conflict

Exemples de code pour « Set interaction restrictions for a repository »

Exemple de requête

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.

Jetons d’accès affinés pour « Remove interaction restrictions for a repository »

Ce point de terminaison fonctionne avec les types de jetons suivants:

Le jeton doit avoir l’ensemble d’autorisations suivant:

  • administration:write

Paramètres pour « Remove interaction restrictions for a repository »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Codes d’état de la réponse HTTP pour « Remove interaction restrictions for a repository »

Code d’étatDescription
204

No Content

409

Conflict

Exemples de code pour « Remove interaction restrictions for a repository »

Exemple de requête

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