代码片段仓库存储移动 API
- Tier: 基础版, 专业版, 旗舰版
- Offering: 私有化部署
片段库可以在不同的存储之间移动。例如,在迁移到 Gitaly 集群时,此 API 可以提供帮助。
随着片段库存储移动的处理,它们会经历不同的状态。state 的值为:
- initial: 记录已创建,但后台任务尚未被调度。
- scheduled: 后台任务已被调度。
- started: 片段库正在被复制到目标存储。
- replicated: 片段已被移动。
- failed: 片段库复制失败或校验和不匹配。
- finished: 片段已被移动,并且源存储上的库已被删除。
- cleanup failed: 片段已被移动,但源存储上的库无法被删除。
为了确保数据完整性,片段在移动期间被置于临时只读状态。在此期间,如果用户尝试推送新的提交,会收到 The repository is temporarily read-only. Please try again later. 的消息。
此 API 要求您以管理员身份进行身份验证。
有关其他库类型,请参阅:
检索所有片段库存储移动
plaintextGET /snippet_repository_storage_moves
默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的。
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/snippet_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 "snippet": { 9 "id": 65, 10 "title": "Test Snippet", 11 "description": null, 12 "visibility": "internal", 13 "updated_at": "2020-12-01T11:15:50.385Z", 14 "created_at": "2020-12-01T11:15:50.385Z", 15 "project_id": null, 16 "web_url": "https://gitlab.example.com/-/snippets/65", 17 "raw_url": "https://gitlab.example.com/-/snippets/65/raw", 18 "ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git", 19 "http_url_to_repo": "https://gitlab.example.com/snippets/65.git" 20 } 21 } 22]
检索片段的所有库存储移动
plaintextGET /snippets/:snippet_id/repository_storage_moves
默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的。
支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| snippet_id | integer | yes | 片段的 ID。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/snippets/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 "snippet": { 9 "id": 65, 10 "title": "Test Snippet", 11 "description": null, 12 "visibility": "internal", 13 "updated_at": "2020-12-01T11:15:50.385Z", 14 "created_at": "2020-12-01T11:15:50.385Z", 15 "project_id": null, 16 "web_url": "https://gitlab.example.com/-/snippets/65", 17 "raw_url": "https://gitlab.example.com/-/snippets/65/raw", 18 "ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git", 19 "http_url_to_repo": "https://gitlab.example.com/snippets/65.git" 20 } 21 } 22]
获取单个片段库存储移动
plaintextGET /snippet_repository_storage_moves/:repository_storage_id
支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| repository_storage_id | integer | yes | 片段库存储移动的 ID。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/snippet_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 "snippet": { 8 "id": 65, 9 "title": "Test Snippet", 10 "description": null, 11 "visibility": "internal", 12 "updated_at": "2020-12-01T11:15:50.385Z", 13 "created_at": "2020-12-01T11:15:50.385Z", 14 "project_id": null, 15 "web_url": "https://gitlab.example.com/-/snippets/65", 16 "raw_url": "https://gitlab.example.com/-/snippets/65/raw", 17 "ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git", 18 "http_url_to_repo": "https://gitlab.example.com/snippets/65.git" 19 } 20}
获取片段的单个库存储移动
plaintextGET /snippets/:snippet_id/repository_storage_moves/:repository_storage_id
支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| snippet_id | integer | yes | 片段的 ID。 |
| repository_storage_id | integer | yes | 片段库存储移动的 ID。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/snippets/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 "snippet": { 8 "id": 65, 9 "title": "Test Snippet", 10 "description": null, 11 "visibility": "internal", 12 "updated_at": "2020-12-01T11:15:50.385Z", 13 "created_at": "2020-12-01T11:15:50.385Z", 14 "project_id": null, 15 "web_url": "https://gitlab.example.com/-/snippets/65", 16 "raw_url": "https://gitlab.example.com/-/snippets/65/raw", 17 "ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git", 18 "http_url_to_repo": "https://gitlab.example.com/snippets/65.git" 19 } 20}
为片段调度库存储移动
plaintextPOST /snippets/:snippet_id/repository_storage_moves
支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| snippet_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"}' \ --url "https://gitlab.example.com/api/v4/snippets/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 "snippet": { 8 "id": 65, 9 "title": "Test Snippet", 10 "description": null, 11 "visibility": "internal", 12 "updated_at": "2020-12-01T11:15:50.385Z", 13 "created_at": "2020-12-01T11:15:50.385Z", 14 "project_id": null, 15 "web_url": "https://gitlab.example.com/-/snippets/65", 16 "raw_url": "https://gitlab.example.com/-/snippets/65/raw", 17 "ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git", 18 "http_url_to_repo": "https://gitlab.example.com/snippets/65.git" 19 } 20}
为存储分片上的所有片段调度库存储移动
为存储在源存储分片上的每个片段库调度库存储移动。此端点一次迁移所有片段。有关更多信息,请参阅移动所有片段。
plaintextPOST /snippet_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"}' \ --url "https://gitlab.example.com/api/v4/snippet_repository_storage_moves"
示例响应:
json{ "message": "202 Accepted" }