更新仓库里程碑¶
PATCH /api/v5/repos/{owner}/{repo}/milestones/{number}
该接口用于更新指定仓库中的里程碑信息,可修改里程碑的标题、状态、具体描述及截止日期,并返回更新后的里程碑详情。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址path) |
repo |
path | string | 是 | 仓库路径(path) |
number |
path | integer | 是 | 里程碑序列号(number) |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"title": {
"description": "里程碑标题",
"type": "string"
},
"state": {
"description": "里程碑状态",
"type": "string",
"enum": ["open", "closed", "all"],
"default": "open"
},
"description": {
"description": "里程碑具体描述",
"type": "string"
},
"due_on": {
"description": "里程碑的截止日期",
"type": "string"
}
},
"required": ["title", "due_on"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
closed_issues |
integer | 是 | — | 已关闭的 issue 数量 |
created_at |
string | 是 | — | 里程碑创建时间 |
description |
string | 是 | — | 里程碑具体描述 |
due_on |
string | 是 | — | 里程碑的截止日期 |
number |
integer | 是 | — | 里程碑序列号(number) |
open_issues |
integer | 是 | — | 进行中的 issue 数量 |
repository_id |
integer | 是 | — | 仓库 id |
state |
string | 是 | — | 里程碑状态 |
title |
string | 是 | — | 里程碑标题 |
updated_at |
string | 是 | — | 里程碑更新时间 |
url |
string | 是 | — | 里程碑地址 |
失败响应¶
只有
200/成功响应是不够的:调用方需要知道失败长什么样才能写错误处理。
400 参数错误
401 未认证
错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误或请求无法解析 |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
里程碑或仓库不存在 |
500 |
系统内部错误 |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(企业、组织或个人的地址path);<repo>替换为仓库路径(path);<number>替换为里程碑序列号(number);<token>替换为你的 AtomGit 用户访问令牌;<title>替换为里程碑标题;<due_on>替换为里程碑的截止日期。
cURL¶
curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/milestones/<number>?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{"title": "<title>", "state": "open", "description": "<description>", "due_on": "<due_on>"}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/milestones/<number>?access_token=<token>", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
title: "<title>",
state: "open",
description: "<description>",
due_on: "<due_on>",
}),
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.patch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/milestones/<number>",
params={"access_token": "<token>"},
json={
"title": "<title>",
"state": "open",
"description": "<description>",
"due_on": "<due_on>",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"closed_issues": 0,
"created_at": "2024-10-08T10:58:16+08:00",
"description": "你好中国",
"due_on": "2024-11-08",
"number": 4914,
"open_issues": 0,
"repository_id": 4066481,
"state": "open",
"title": "你好中国",
"updated_at": "2024-10-08T10:58:16+08:00",
"url": "https://api.atomgit.com/dengmengmian/oneapi/milestones/1"
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问 |
404 |
请求路径不存在或资源不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc