Group Labels API

原文:https://docs.gitlab.com/ee/api/group_labels.html

Group Labels API

在 GitLab 11.8 中引入 .

该 API 支持组标签的管理. 它允许列出,创建,更新和删除组标签. 此外,用户可以订阅和取消订阅组标签.

注意: description_html已添加到GitLab 12.7 中的响应 JSON.

List group labels

获取给定组的所有标签.

  1. GET /groups/:id/labels
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径 .
with_counts boolean no 是否包括发布和合并请求计数. 默认为false . 在 GitLab 12.2 中引入
include_ancestor_groups boolean no 包括祖先组. 默认为true .
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels?with_counts=true"

响应示例:

  1. [ { "id": 7, "name": "bug", "color": "#FF0000", "text_color" : "#FFFFFF", "description": null, "description_html": null, "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false }, { "id": 4, "name": "feature", "color": "#228B22", "text_color" : "#FFFFFF", "description": null, "description_html": null, "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false } ]

Get a single group label

获取给定组的单个标签.

  1. GET /groups/:id/labels/:label_id
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径 .
label_id 整数或字符串 yes 群组标签的 ID 或标题.
include_ancestor_groups boolean no 包括祖先组. 默认为true .
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/bug"

Example response:

  1. { "id": 7, "name": "bug", "color": "#FF0000", "text_color" : "#FFFFFF", "description": null, "description_html": null, "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false }

Create a new group label

为给定的组创建一个新的组标签.

  1. POST /groups/:id/labels
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径
name string yes 标签名称
color string yes 标签的颜色以 6 位十六进制表示法加上前导”#”符号(例如#FFAABB)或CSS 颜色名称之一给出
description string no 标签的说明,
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" --data '{"name": "Feature Proposal", "color": "#FFA500", "description": "Describes new ideas" }' "https://gitlab.example.com/api/v4/groups/5/labels"

响应示例:

  1. { "id": 9, "name": "Feature Proposal", "color": "#FFA500", "text_color" : "#FFFFFF", "description": "Describes new ideas", "description_html": "Describes new ideas", "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false }

Update a group label

更新现有的组标签. 至少需要一个参数来更新组标签.

  1. PUT /groups/:id/labels/:label_id
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径
label_id 整数或字符串 yes 群组标签的 ID 或标题.
new_name string no 标签的新名称
color string no 标签的颜色以 6 位十六进制表示法加上前导”#”符号(例如#FFAABB)或CSS 颜色名称之一给出
description string no 标签的描述.
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" --data '{"new_name": "Feature Idea" }' "https://gitlab.example.com/api/v4/groups/5/labels/Feature%20Proposal"

响应示例:

  1. { "id": 9, "name": "Feature Idea", "color": "#FFA500", "text_color" : "#FFFFFF", "description": "Describes new ideas", "description_html": "Describes new ideas", "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false }

注意:参数中带有name的较早的端点PUT /groups/:id/labels仍然可用,但已弃用.

Delete a group label

删除具有给定名称的组标签.

  1. DELETE /groups/:id/labels/:label_id
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径
label_id 整数或字符串 yes 群组标签的 ID 或标题.
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/bug"

注意:参数中带有name的较旧的端点DELETE /groups/:id/labels仍然可用,但已弃用.

Subscribe to a group label

将经过身份验证的用户订阅到组标签以接收通知. 如果用户已经订阅了标签,则返回状态码304 .

  1. POST /groups/:id/labels/:label_id/subscribe
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径
label_id 整数或字符串 yes 群组标签的 ID 或标题.
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/9/subscribe"

响应示例:

  1. { "id": 9, "name": "Feature Idea", "color": "#FFA500", "text_color" : "#FFFFFF", "description": "Describes new ideas", "description_html": "Describes new ideas", "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": true }

Unsubscribe from a group label

从组标签退订已认证的用户以不接收来自该组标签的通知. 如果用户未订阅标签,则返回状态码304 .

  1. POST /groups/:id/labels/:label_id/unsubscribe
Attribute Type Required Description
id integer/string yes 认证用户拥有的组的 ID 或URL 编码路径
label_id 整数或字符串 yes 群组标签的 ID 或标题.
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/9/unsubscribe"

响应示例:

  1. { "id": 9, "name": "Feature Idea", "color": "#FFA500", "text_color" : "#FFFFFF", "description": "Describes new ideas", "description_html": "Describes new ideas", "open_issues_count": 0, "closed_issues_count": 0, "open_merge_requests_count": 0, "subscribed": false }