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