更新企业标签¶
PUT /api/v8/enterprises/{enterprise_id}/label/{label_id}
用户调用此接口,进行更新企业标签操作。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
enterprise_id |
path | integer | 是 | 企业id |
label_id |
path | integer | 是 | 标签id |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
请求体为 application/json 格式,包含以下字段:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "标签名称",
"type": "string"
},
"color": {
"description": "标签的颜色,以6位16进制表示,前面带有'#'号",
"type": "string"
},
"description": {
"description": "标签描述",
"type": "string"
},
"expires_at": {
"description": "标签的过期日期",
"type": "string"
}
},
"required": ["name", "description"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 标签id |
name |
string | 是 | 否 | 标签名称 |
color |
string | 是 | 否 | 标签颜色 |
repository_id |
integer | 是 | 是 | 仓库id,更新接口中可能为 null |
url |
string | 是 | 是 | 标签url,更新接口中可能为 null |
created_at |
string | 是 | 是 | 创建时间,更新接口中可能为 null |
updated_at |
string | 是 | 是 | 更新时间,更新接口中可能为 null |
description |
string | 是 | 否 | 标签描述 |
失败响应¶
接口在参数校验失败、认证/权限校验失败或资源不存在时,返回 ApiErrorResp 结构的错误信息。
400 参数错误
{
"error_code": 400,
"error_code_name": "BAD_REQUEST",
"error_message": "Update enterprise label, name is required"
}
401 未认证
403 禁止访问
{
"error_code": 403,
"error_code_name": "FORBIDDEN",
"error_message": "The provided token lacks 'enterprise' scope. Please recreate or update your token with the required scope"
}
404 资源不存在
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
需要认证(Unauthorized) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not Found) |
429 |
请求过于频繁(Too Many Requests) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<enterprise_id>替换为企业id;<label_id>替换为标签id;<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X PUT 'https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label/<label_id>?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{"name": "bug", "color": "#f00000", "description": "缺陷标签"}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label/<label_id>?access_token=<token>", {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "bug",
color: "#f00000",
description: "缺陷标签",
}),
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.put(
"https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label/<label_id>",
params={"access_token": "<token>"},
json={
"name": "bug",
"color": "#f00000",
"description": "缺陷标签",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"id": 1,
"name": "bug",
"color": "#f00000",
"repository_id": null,
"url": null,
"created_at": null,
"updated_at": null,
"description": "缺陷标签"
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问(缺少权限) |
404 |
请求路径或资源不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc