Esta versão do GitHub Enterprise foi descontinuada em 2022-06-03. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, melhorar a segurança e novos recursos, upgrade to the latest version of GitHub Enterprise. Para ajuda com a atualização, contact GitHub Enterprise support.
Etiquetas
Sobre a API de etiquetas
A API de Etiquetas é compatível com o gerenciamento de etiquetas para um repositório e com a adição ou remoção de etiquetas para problemas e pull requests. Cada pull request é um problema, mas nem todos os problemas são um pull request. For this reason, "shared" actions for both features, like managing assignees, labels, and milestones, are provided within Issues API.
List labels for an issue
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
issue_number integerObrigatórioThe number that identifies the issue. |
Parâmetros de consulta |
Nome, Tipo, Descrição |
per_page integerThe number of results per page (max 100). Padrão: |
page integerPage number of the results to fetch. Padrão: |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
410 | Gone |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]
Add labels to an issue
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
issue_number integerObrigatórioThe number that identifies the issue. |
Body parameters |
Nome, Tipo, Descrição |
labels array of stringsThe names of the labels to add to the issue's existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
Amostras de código
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]
Set labels for an issue
Removes any previous labels and sets the new labels for an issue.
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
issue_number integerObrigatórioThe number that identifies the issue. |
Body parameters |
Nome, Tipo, Descrição |
labels array of stringsThe names of the labels to set for the issue. The labels you set replace any existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
Amostras de código
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]
Remove all labels from an issue
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
issue_number integerObrigatórioThe number that identifies the issue. |
HTTP response status codes
Status code | Descrição |
---|---|
204 | No Content |
410 | Gone |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels
Response
Status: 204
Remove a label from an issue
Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a 404 Not Found
status if the label does not exist.
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
issue_number integerObrigatórioThe number that identifies the issue. |
name stringObrigatório |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
404 | Resource not found |
410 | Gone |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAME
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}
]
List labels for a repository
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
Parâmetros de consulta |
Nome, Tipo, Descrição |
per_page integerThe number of results per page (max 100). Padrão: |
page integerPage number of the results to fetch. Padrão: |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]
Create a label
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
Body parameters |
Nome, Tipo, Descrição |
name stringObrigatórioThe name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
color stringThe hexadecimal color code for the label, without the leading |
description stringA short description of the label. Must be 100 characters or fewer. |
HTTP response status codes
Status code | Descrição |
---|---|
201 | Created |
404 | Resource not found |
422 | Validation failed |
Amostras de código
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels \
-d '{"name":"bug","description":"Something isn't working","color":"f29513"}'
Response
Status: 201
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}
Get a label
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
name stringObrigatório |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME
Response
Status: 200
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}
Update a label
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
name stringObrigatório |
Body parameters |
Nome, Tipo, Descrição |
new_name stringThe new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
color stringThe hexadecimal color code for the label, without the leading |
description stringA short description of the label. Must be 100 characters or fewer. |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
Amostras de código
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME \
-d '{"new_name":"bug :bug:","description":"Small bug fix required","color":"b01f26"}'
Response
Status: 200
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug%20:bug:",
"name": "bug :bug:",
"description": "Small bug fix required",
"color": "b01f26",
"default": true
}
Delete a label
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
name stringObrigatório |
HTTP response status codes
Status code | Descrição |
---|---|
204 | No Content |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME
Response
Status: 204
List labels for issues in a milestone
Parâmetros
Headers |
---|
Nome, Tipo, Descrição |
accept stringSetting to |
Path parameters |
Nome, Tipo, Descrição |
owner stringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo stringObrigatórioThe name of the repository. The name is not case sensitive. |
milestone_number integerObrigatórioThe number that identifies the milestone. |
Parâmetros de consulta |
Nome, Tipo, Descrição |
per_page integerThe number of results per page (max 100). Padrão: |
page integerPage number of the results to fetch. Padrão: |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labels
Response
Status: 200
[
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
},
{
"id": 208045947,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDc=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
"name": "enhancement",
"description": "New feature or request",
"color": "a2eeef",
"default": false
}
]