gitlab-org--gitlab-foss/doc/api/project_aliases.md

106 lines
2.3 KiB
Markdown
Raw Normal View History

# Project Aliases API **[PREMIUM ONLY]**
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/3264) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.1.
2019-06-14 04:04:36 +00:00
All methods require administrator authorization.
## List all project aliases
Get a list of all project aliases:
2019-06-14 04:04:36 +00:00
```
GET /project_aliases
```
```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases"
```
Example response:
```json
[
{
"id": 1,
"project_id": 1,
"name": "gitlab-ce"
},
{
"id": 2,
"project_id": 2,
"name": "gitlab-ee"
}
]
```
## Get project alias' details
Get details of a project alias:
2019-06-14 04:04:36 +00:00
```
GET /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab-ee"
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab-ee"
}
```
## Create a project alias
2019-06-14 04:04:36 +00: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 04:04:36 +00:00
```
POST /project_aliases
```
| Attribute | Type | Required | Description |
|--------------|--------|----------|-----------------------------------------------|
| `project_id` | string | yes | The ID or URL-encoded path of the project. |
2019-06-14 04:04:36 +00:00
| `name` | string | yes | The name of the alias. Must be unique. |
```
curl --request POST "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=gitlab-org%2Fgitlab-ee" --form "name=gitlab-ee"
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab-ee"
}
```
## Delete a project alias
2019-06-14 04:04:36 +00:00
Removes a project aliases. Responds with a 204 when project alias
exists, 404 when it doesn't:
2019-06-14 04:04:36 +00:00
```
DELETE /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab-ee"
```