2019-07-08 04:50:38 -04:00
|
|
|
# Project Aliases API **(PREMIUM ONLY)**
|
2019-06-16 23:56:59 -04:00
|
|
|
|
2020-05-21 02:08:25 -04:00
|
|
|
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/3264) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.1.
|
2019-06-14 00:04:36 -04:00
|
|
|
|
|
|
|
All methods require administrator authorization.
|
|
|
|
|
|
|
|
## List all project aliases
|
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
Get a list of all project aliases:
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```plaintext
|
2019-06-14 00:04:36 -04:00
|
|
|
GET /project_aliases
|
|
|
|
```
|
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```shell
|
2019-06-14 00:04:36 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases"
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"project_id": 1,
|
2019-09-18 14:06:14 -04:00
|
|
|
"name": "gitlab-foss"
|
2019-06-14 00:04:36 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 2,
|
|
|
|
"project_id": 2,
|
2019-09-18 14:06:14 -04:00
|
|
|
"name": "gitlab"
|
2019-06-14 00:04:36 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Get project alias' details
|
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
Get details of a project alias:
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```plaintext
|
2019-06-14 00:04:36 -04:00
|
|
|
GET /project_aliases/:name
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
|-----------|--------|----------|-----------------------|
|
|
|
|
| `name` | string | yes | The name of the alias |
|
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```shell
|
2019-09-18 14:06:14 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
|
2019-06-14 00:04:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"project_id": 1,
|
2019-09-18 14:06:14 -04:00
|
|
|
"name": "gitlab"
|
2019-06-14 00:04:36 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
## Create a project alias
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
Add a new alias for a project. Responds with a 201 when successful,
|
|
|
|
400 when there are validation errors (e.g. alias already exists):
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```plaintext
|
2019-06-14 00:04:36 -04:00
|
|
|
POST /project_aliases
|
|
|
|
```
|
|
|
|
|
2019-07-03 02:55:29 -04:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
|--------------|----------------|----------|----------------------------------------|
|
|
|
|
| `project_id` | integer/string | yes | The ID or path of the project. |
|
|
|
|
| `name` | string | yes | The name of the alias. Must be unique. |
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```shell
|
2019-09-18 14:06:14 -04:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=1" --form "name=gitlab"
|
2019-07-03 02:55:29 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```shell
|
2019-09-18 14:06:14 -04:00
|
|
|
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"
|
2019-06-14 00:04:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"project_id": 1,
|
2019-09-18 14:06:14 -04:00
|
|
|
"name": "gitlab"
|
2019-06-14 00:04:36 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
## Delete a project alias
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2019-06-16 23:56:59 -04:00
|
|
|
Removes a project aliases. Responds with a 204 when project alias
|
|
|
|
exists, 404 when it doesn't:
|
2019-06-14 00:04:36 -04:00
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```plaintext
|
2019-06-14 00:04:36 -04:00
|
|
|
DELETE /project_aliases/:name
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
|-----------|--------|----------|-----------------------|
|
|
|
|
| `name` | string | yes | The name of the alias |
|
|
|
|
|
2020-02-27 19:09:08 -05:00
|
|
|
```shell
|
2019-09-18 14:06:14 -04:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
|
2019-06-14 00:04:36 -04:00
|
|
|
```
|