Project Aliases API

原文:https://docs.gitlab.com/ee/api/project_aliases.html

Project Aliases API

Introduced in GitLab Premium 12.1.

所有方法都需要管理员授权.

List all project aliases

获取所有项目别名的列表:

  1. GET /project_aliases
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases"

响应示例:

  1. [ { "id": 1, "project_id": 1, "name": "gitlab-foss" }, { "id": 2, "project_id": 2, "name": "gitlab" } ]

Get project alias’ details

获取项目别名的详细信息:

  1. GET /project_aliases/:name
Attribute Type Required Description
name string yes 别名的名称
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"

响应示例:

  1. { "id": 1, "project_id": 1, "name": "gitlab" }

Create a project alias

为项目添加新的别名. 成功时回应 201,当验证错误时回应 400(例如别名已经存在):

  1. POST /project_aliases
Attribute Type Required Description
project_id integer/string yes 项目的 ID 或路径.
name string yes 别名的名称. 必须是唯一的.
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=1" --form "name=gitlab"

or

  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=gitlab-org/gitlab" --form "name=gitlab"

响应示例:

  1. { "id": 1, "project_id": 1, "name": "gitlab" }

Delete a project alias

删除项目别名. 存在项目别名时以 204 响应,如果不存在则以 404 响应:

  1. DELETE /project_aliases/:name
Attribute Type Required Description
name string yes 别名的名称
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"