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