Help us learn about your current experience with the documentation. Take the survey.

项目关系导出 API

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

项目关系导出 API 会将项目的结构部分导出为每个顶级关系的单独文件(例如里程碑、问题和标签)。

项目关系导出 API 主要用于 group migration,不能与 project import and export API 一起使用。

安排新的导出

开始新的项目关系导出:

POST /projects/:id/export_relations
属性 类型 必需 描述
id integer/string 项目的 ID。
batched boolean 是否分批导出。
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/export_relations"
{
  "message": "202 Accepted"
}

导出状态

查看关系导出的状态:

GET /projects/:id/export_relations/status
属性 类型 必需 描述
id integer/string 项目的 ID。
relation string 要查看的项目顶级关系的名称。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/export_relations/status"

状态可能是以下之一:

  • 0 - 已开始
  • 1 - 已完成
  • -1 - 失败
[
  {
    "relation": "project_badges",
    "status": 1,
    "error": null,
    "updated_at": "2021-05-04T11:25:20.423Z",
    "batched": true,
    "batches_count": 1,
    "batches": [
      {
        "status": 1,
        "batch_number": 1,
        "objects_count": 1,
        "error": null,
        "updated_at": "2021-05-04T11:25:20.423Z"
      }
    ]
  },
  {
    "relation": "boards",
    "status": 1,
    "error": null,
    "updated_at": "2021-05-04T11:25:20.085Z",
    "batched": false,
    "batches_count": 0
  }
]

导出下载

下载完成的关系导出:

GET /projects/:id/export_relations/download
属性 类型 必需 描述
id integer/string 项目的 ID。
relation string 要下载的项目顶级关系的名称。
batched boolean 导出是否分批。
batch_number integer 要下载的导出批次的编号。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --remote-header-name \
  --remote-name \
  --url "https://gitlab.example.com/api/v4/projects/1/export_relations/download?relation=labels"
ls labels.ndjson.gz
labels.ndjson.gz

相关主题