此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持。
� �签
关于� �签 API
� �签 API 支持管理存储库的� �签,以及为议题和拉取请求添� 或� 除� �签。 每个拉取请求都是一个议题,但并非每个议题都是拉取请求。 For this reason, "shared" actions for both features, like managing assignees, labels, and milestones, are provided within Issues API.
List labels for an issue
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
issue_numberinteger必选The number that identifies the issue. |
| 查询参数 |
| 名称, 类型, 描述 |
per_pageintegerThe number of results per page (max 100). 默认值: |
pageintegerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
410 | Gone |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsResponse
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
issue_numberinteger必选The number that identifies the issue. |
| 正文参数 |
| 名称, 类型, 描述 |
labelsarray 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 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
代� �示例
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.
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
issue_numberinteger必选The number that identifies the issue. |
| 正文参数 |
| 名称, 类型, 描述 |
labelsarray 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 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
代� �示例
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
issue_numberinteger必选The number that identifies the issue. |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
204 | No Content |
410 | Gone |
代� �示例
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/labelsResponse
Status: 204Remove 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.
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
issue_numberinteger必选The number that identifies the issue. |
namestring必选 |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
410 | Gone |
代� �示例
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/NAMEResponse
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
| 查询参数 |
| 名称, 类型, 描述 |
per_pageintegerThe number of results per page (max 100). 默认值: |
pageintegerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labelsResponse
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
| 正文参数 |
| 名称, 类型, 描述 |
namestring必选The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
colorstringThe hexadecimal color code for the label, without the leading |
descriptionstringA short description of the label. Must be 100 characters or fewer. |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
201 | Created |
404 | Resource not found |
422 | Validation failed |
代� �示例
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
namestring必选 |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
404 | Resource not found |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAMEResponse
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
namestring必选 |
| 正文参数 |
| 名称, 类型, 描述 |
new_namestringThe new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
colorstringThe hexadecimal color code for the label, without the leading |
descriptionstringA short description of the label. Must be 100 characters or fewer. |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
代� �示例
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
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
namestring必选 |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
204 | No Content |
代� �示例
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAMEResponse
Status: 204List labels for issues in a milestone
参数
| � �头 |
|---|
| 名称, 类型, 描述 |
acceptstringSetting to |
| 路径参数 |
| 名称, 类型, 描述 |
ownerstring必选The account owner of the repository. The name is not case sensitive. |
repostring必选The name of the repository. The name is not case sensitive. |
milestone_numberinteger必选The number that identifies the milestone. |
| 查询参数 |
| 名称, 类型, 描述 |
per_pageintegerThe number of results per page (max 100). 默认值: |
pageintegerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
| 状态代� � | 描述 |
|---|---|
200 | OK |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labelsResponse
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
}
]