Points de terminaison d’API REST pour les suites de règles
Utilisez l’API REST pour gérer les suites de règles pour les référentiels.
List repository rule suites
Lists suites of rule evaluations at the repository level. For more information, see "Managing rulesets for a repository."
Jetons d’accès affinés pour « List repository rule suites »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Administration" repository permissions (write)
Paramètres pour « List repository rule suites »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
Nom, Type, Description |
---|
ref string The name of the ref. Cannot contain wildcard characters. Optionally prefix with |
time_period string The time period to filter by. For example, Default: Peut être: |
actor_name string The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned. |
rule_suite_result string The rule results to filter on. When specified, only suites with this result will be returned. Default: Peut être: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: |
Codes d’état de la réponse HTTP pour « List repository rule suites »
Code d’état | Description |
---|---|
200 | OK |
404 | Resource not found |
500 | Internal Error |
Exemples de code pour « List repository rule suites »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
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/rulesets/rule-suites
Response
Status: 200
[
{
"id": 21,
"actor_id": 12,
"actor_name": "octocat",
"before_sha": "893f768e172fb1bc9c5d6f3dd48557e45f14e01d",
"after_sha": "dedd88641a362b6b4ea872da4847d6131a164d01",
"ref": "refs/heads/i-see-everything",
"repository_id": 404,
"repository_name": "octo-repo",
"pushed_at": "2023-07-06T08:43:03Z",
"result": "bypass"
},
{
"id": 25,
"actor_id": 11,
"actor_name": "not-octocat",
"before_sha": "48994e4e01ccc943624c6231f172702b82b233cc",
"after_sha": "ecfd5a1025fa271a33ca5608d089476a2df3c9a1",
"ref": "refs/heads/i-am-everything",
"repository_id": 404,
"repository_name": "octo-repo",
"pushed_at": "2023-07-07T08:43:03Z",
"result": "pass",
"evaluation_result": "fail"
}
]
Get a repository rule suite
Gets information about a suite of rule evaluations from within a repository. For more information, see "Managing rulesets for a repository."
Jetons d’accès affinés pour « Get a repository rule suite »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Administration" repository permissions (write)
Paramètres pour « Get a repository rule suite »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
rule_suite_id integer ObligatoireThe unique identifier of the rule suite result. To get this ID, you can use GET /repos/{owner}/{repo}/rulesets/rule-suites for repositories and GET /orgs/{org}/rulesets/rule-suites for organizations. |
Codes d’état de la réponse HTTP pour « Get a repository rule suite »
Code d’état | Description |
---|---|
200 | OK |
404 | Resource not found |
500 | Internal Error |
Exemples de code pour « Get a repository rule suite »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
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/rulesets/rule-suites/RULE_SUITE_ID
Response
Status: 200
{
"id": 21,
"actor_id": 12,
"actor_name": "octocat",
"before_sha": "893f768e172fb1bc9c5d6f3dd48557e45f14e01d",
"after_sha": "dedd88641a362b6b4ea872da4847d6131a164d01",
"ref": "refs/heads/i-see-everything",
"repository_id": 404,
"repository_name": "octo-repo",
"pushed_at": "2023-07-06T08:43:03Z",
"result": "bypass",
"evaluation_result": "fail",
"rule_evaluations": [
{
"rule_source": {
"type": "ruleset",
"id": 2,
"name": "Author email must be a GitHub email address"
},
"enforcement": "active",
"result": "pass",
"rule_type": "commit_author_email_pattern"
},
{
"rule_source": {
"type": "protected_branch"
},
"enforcement": "active",
"result": "fail",
"rule_type": "pull_request",
"details": "Changes must be made through a pull request."
},
{
"rule_source": {
"type": "ruleset",
"id": 3,
"name": "Evaluate commit message pattern"
},
"enforcement": "evaluate",
"result": "fail",
"rule_type": "commit_message_pattern"
}
]
}