{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
此 API 支持管理群组标签。它允许用户列出、创建、更新和删除群组标签。此外,用户还可以订阅和取消订阅群组标签。
列出群组标签
获取给定群组的所有标签。
GET /groups/:id/labels
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 群组的 ID 或URL 编码路径。 |
with_counts |
boolean | 否 | 是否包含议题和合并请求计数。默认为 false 。 |
include_ancestor_groups |
boolean | 否 | 包含上级群组。默认为 true 。 |
include_descendant_groups |
boolean | 否 | 包含下级群组。默认为 false 。 |
only_group_labels |
boolean | 否 | 切换为仅包含群组标签或项目标签。默认为 true 。 |
search |
string | 否 | 按关键字过滤标签。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels?with_counts=true"
示例响应:
[
{
"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 /groups/:id/labels/:label_id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径。 |
label_id |
integer or string | 是 | 群组标签的 ID 或标题。 |
include_ancestor_groups |
boolean | 否 | 包含上级群组。默认为 true 。 |
include_descendant_groups |
boolean | 否 | 包含下级群组。默认为 false 。 |
only_group_labels |
boolean | 否 | 切换为仅包含群组标签或项目标签。默认为 true 。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/bug"
示例响应:
{
"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
}
创建新的群组标签
为给定群组创建新的群组标签。
POST /groups/:id/labels
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 群组的 ID 或URL 编码路径 |
name |
string | 是 | 标签的名称 |
color |
string | 是 | 标签的颜色,以 6 位十六进制格式表示,并以 # 号开头(例如,#FFAABB),或CSS 颜色名称之一 |
description |
string | 否 | 标签的描述, |
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"
示例响应:
{
"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
}
更新群组标签
更新现有群组标签。至少需要一个参数来更新群组标签。
PUT /groups/:id/labels/:label_id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径 |
label_id |
integer or string | 是 | 群组标签的 ID 或标题。 |
new_name |
string | 否 | 标签的新名称 |
color |
string | 否 | 标签的颜色,以 6 位十六进制格式表示,并以 # 号开头(例如,#FFAABB),或CSS 颜色名称之一 |
description |
string | 否 | 标签的描述。 |
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"
示例响应:
{
"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
}
{{< alert type=”note” >}}
旧的端点 PUT /groups/:id/labels
带有 name
参数仍然可用,但已弃用。
{{< /alert >}}
删除群组标签
删除具有给定名称的群组标签。
DELETE /groups/:id/labels/:label_id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径 |
label_id |
integer or string | 是 | 群组标签的 ID 或标题。 |
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/bug"
{{< alert type=”note” >}}
旧的端点 DELETE /groups/:id/labels
带有 name
参数仍然可用,但已弃用。
{{< /alert >}}
订阅群组标签
订阅经过身份验证的用户以接收群组标签的通知。如果用户已订阅该标签,则返回状态代码 304
。
POST /groups/:id/labels/:label_id/subscribe
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径 |
label_id |
integer or string | 是 | 群组标签的 ID 或标题。 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/9/subscribe"
示例响应:
{
"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
}
取消订阅群组标签
取消订阅经过身份验证的用户以不接收来自群组标签的通知。如果用户未订阅该标签,则返回状态代码 304
。
POST /groups/:id/labels/:label_id/unsubscribe
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径 |
label_id |
integer or string | 是 | 群组标签的 ID 或标题。 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/labels/9/unsubscribe"
示例响应:
{
"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
}