更新仓库设置¶
PATCH /api/v5/repos/{owner}/{repo}
该接口用于更新指定仓库的设置,支持修改仓库名称、描述、主页地址、仓库路径、公开或私有状态、默认分支、是否启用 LFS 以及项目标签等信息,并返回更新后的仓库详情。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
请求体以 application/json 格式提交,用于描述需要更新的仓库设置项。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "仓库名称",
"type": "string"
},
"description": {
"description": "仓库描述",
"type": "string"
},
"homepage": {
"description": "项目地址(主页)",
"type": "string"
},
"path": {
"description": "更新仓库路径",
"type": "string"
},
"private": {
"description": "仓库公开或私有(true/false)",
"type": "boolean"
},
"default_branch": {
"description": "默认分支",
"type": "string"
},
"lfs_enabled": {
"description": "是否启动 LFS",
"type": "boolean"
},
"tags": {
"description": "项目标签",
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["name"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | ID |
full_name |
string | 是 | 是 | 完整名称 |
human_name |
string | 是 | 是 | 人类可读名称 |
url |
string | 是 | 是 | URL |
path |
string | 是 | 是 | 仓库路径 |
name |
string | 是 | 是 | 仓库名称 |
description |
string | 是 | 是 | 仓库描述 |
private |
boolean | 是 | 是 | 仓库是否私有 |
public |
boolean | 是 | 是 | 仓库是否公开 |
namespace |
object | 是 | 否 | 命名空间信息 |
empty_repo |
boolean | 是 | 是 | 是否空仓库 |
starred |
boolean | 是 | 是 | 是否已星标 |
visibility |
string | 是 | 是 | 可见性 |
owner |
object | 是 | 是 | 所有者信息 |
creator |
object | 是 | 是 | 创建者信息 |
forked_from_project |
object | 是 | 是 | Fork 自项目信息 |
item_type |
string | 是 | 是 | 项目类型 |
main_repository_language |
string[] | 是 | 是 | 主要仓库语言 |
homepage |
string | 是 | 是 | 主页 |
tags |
string[] | 否 | 是 | 项目标签 |
namespace 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
namespace.id |
integer | 是 | 否 | 命名空间 ID |
namespace.name |
string | 是 | 是 | 名称 |
namespace.path |
string | 是 | 是 | 路径 |
namespace.develop_mode |
string | 是 | 是 | 开发模式 |
namespace.region |
string | 是 | 是 | 区域 |
namespace.cell |
string | 是 | 是 | 单元 |
namespace.kind |
string | 是 | 是 | 种类 |
namespace.full_path |
string | 是 | 是 | 完整路径 |
namespace.full_name |
string | 是 | 是 | 完整名称 |
namespace.parent_id |
integer | 是 | 是 | 父命名空间 ID |
namespace.visibility_level |
integer | 是 | 是 | 可见性级别 |
namespace.enable_file_control |
boolean | 是 | 是 | 是否启用文件控制 |
namespace.owner_id |
integer | 是 | 是 | 所有者 ID |
owner、creator、forked_from_project 为可空对象,其内部结构以实际返回为准。
失败响应¶
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
请求路径不存在(Not found) |
405 |
请求方法不支持(Method not allowed) |
429 |
请求过于频繁(Rate limited) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"name": "test_create_project_2",
"description": "描述",
"private": false,
"default_branch": "master",
"lfs_enabled": false,
"tags": ["java", "web"]
}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>?access_token=<token>", {
method: "PATCH",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "test_create_project_2",
description: "描述",
private: false,
default_branch: "master",
lfs_enabled: false,
tags: ["java", "web"],
}),
});
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>",
params={"access_token": "<token>"},
headers={
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"name": "test_create_project_2",
"description": "描述",
"private": False,
"default_branch": "master",
"lfs_enabled": False,
"tags": ["java", "web"],
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"id": 34171993,
"full_name": "daming_1/test_create_project_2",
"human_name": "daming/test_create_project_2",
"url": "https://api.atomgit.com/api/v5/repos/daming_1/test_create_project_2",
"path": "test_create_project_2",
"name": "test_create_project_2",
"description": "描述",
"private": false,
"public": true,
"namespace": {
"id": 74962,
"name": "group1111",
"path": "group11111",
"develop_mode": "normal",
"region": null,
"cell": "default",
"kind": "group",
"full_path": "group11111",
"full_name": "group1111",
"parent_id": null,
"visibility_level": 20,
"enable_file_control": false,
"owner_id": null
},
"empty_repo": null,
"starred": null,
"visibility": "public",
"owner": null,
"creator": null,
"forked_from_project": null,
"item_type": null,
"main_repository_language": null,
"homepage": "http://www.baidi.com"
}
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc