{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: 私有化部署
{{< /details >}}
项目仓库,包括 wiki 和设计仓库,可以在存储之间移动。此 API 可以在您迁移到 Gitaly 集群时提供帮助。
随着项目仓库存储移动的处理,它们会经历不同的状态。state
的值为:
-
initial
: 记录已创建,但后台任务尚未安排。 -
scheduled
: 后台任务已安排。 -
started
: 项目仓库正在被复制到目标存储。 -
replicated
: 项目已移动。 -
failed
: 项目仓库复制失败或校验和不匹配。 -
finished
: 项目已移动,源存储上的仓库已删除。 -
cleanup failed
: 项目已移动,但无法删除源存储上的仓库。
为了确保数据完整性,项目在移动期间被置于临时只读状态。在此期间,如果用户尝试推送新的提交,将会收到 The repository is temporarily read-only. Please try again later.
消息。
此 API 要求您以管理员身份进行身份验证。
有关其他仓库类型,请参阅:
检索所有项目仓库存储移动
GET /project_repository_storage_moves
默认情况下,GET
请求一次返回 20 个结果,因为 API 结果是分页的。
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_repository_storage_moves"
示例响应:
[
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}
]
检索项目的所有仓库存储移动
GET /projects/:project_id/repository_storage_moves
默认情况下,GET
请求一次返回 20 个结果,因为 API 结果是分页的。
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
project_id |
integer | yes | 项目的 ID |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/repository_storage_moves"
示例响应:
[
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}
]
获取单个项目仓库存储移动
GET /project_repository_storage_moves/:repository_storage_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
repository_storage_id |
integer | yes | 项目仓库存储移动的 ID |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_repository_storage_moves/1"
示例响应:
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}
获取项目的单个仓库存储移动
GET /projects/:project_id/repository_storage_moves/:repository_storage_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
project_id |
integer | yes | 项目的 ID |
repository_storage_id |
integer | yes | 项目仓库存储移动的 ID |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/repository_storage_moves/1"
示例响应:
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}
为项目安排仓库存储移动
POST /projects/:project_id/repository_storage_moves
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
project_id |
integer | yes | 项目的 ID |
destination_storage_name |
string | no | 目标存储分片的名称。如果未提供,则根据存储权重自动选择存储 |
示例请求:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" \
--data '{"destination_storage_name":"storage2"}' \
"https://gitlab.example.com/api/v4/projects/1/repository_storage_moves"
示例响应:
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}
为存储分片上的所有项目安排仓库存储移动
为存储在源存储分片上的每个项目仓库安排仓库存储移动。此端点一次迁移所有项目。有关更多信息,请参阅移动所有项目。
POST /project_repository_storage_moves
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
source_storage_name |
string | yes | 源存储分片的名称。 |
destination_storage_name |
string | no | 目标存储分片的名称。如果未提供,则根据存储权重自动选择存储。 |
示例请求:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" \
--data '{"source_storage_name":"default"}' \
"https://gitlab.example.com/api/v4/project_repository_storage_moves"
示例响应:
{
"message": "202 Accepted"
}