更新仓库的权限模式¶
PUT /api/v5/repos/{owner}/{repo}/transition
更新指定仓库的成员权限管理模式(继承模式 / 独立模式),仅支持拥有仓库管理权限的用户调用。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
mode 为必填字段,指定更新后的成员权限管理模式。请求体以 JSON 格式提交,需携带 Content-Type: application/json。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"mode": {
"description": "成员权限管理模式:1(继承模式),2(独立模式);不接受设置混合模式",
"type": "integer",
"enum": [1, 2]
}
},
"required": ["mode"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
msg |
string | 是 | 否 | 操作结果信息,成功时为 success |
code |
integer | 是 | 否 | 结果码,成功时为 1 |
失败响应¶
当请求失败时,接口返回错误响应体,字段采用 snake_case 命名,字段名以后端实际返回为准:
{
"error_code": 400,
"error_code_name": "BAD_REQUEST",
"error_message": "参数错误",
"trace_id": "xxxx"
}
403 禁止访问
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not Found) |
429 |
请求过于频繁(Too Many Requests) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/transition?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"mode": 1}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/transition?access_token=<token>",
{
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({ mode: 1 }),
}
);
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/v5/repos/<owner>/<repo>/transition",
params={"access_token": "<token>"},
headers={"Content-Type": "application/json", "Accept": "application/json"},
json={"mode": 1},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问(如系统正在进行成员权限模型升级) |
404 |
请求路径或资源不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc