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

119 lines
2.8 KiB
Markdown
Raw Normal View History

---
stage: Create
group: Source Code
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
type: reference, api
---
# Project Aliases API **(PREMIUM SELF)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/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
```plaintext
2019-06-14 04:04:36 +00:00
GET /project_aliases
```
```shell
2019-06-14 04:04:36 +00:00
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-foss"
2019-06-14 04:04:36 +00:00
},
{
"id": 2,
"project_id": 2,
"name": "gitlab"
2019-06-14 04:04:36 +00:00
}
]
```
## Get project alias' details
Get details of a project alias:
2019-06-14 04:04:36 +00:00
```plaintext
2019-06-14 04:04:36 +00:00
GET /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
2019-06-14 04:04:36 +00:00
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab"
2019-06-14 04:04:36 +00:00
}
```
## Create a project alias
2019-06-14 04:04:36 +00:00
Add a new alias for a project. When successful, responds with `201 Created`.
When there are validation errors, for example, when the alias already exists, responds with `400 Bad Request`:
2019-06-14 04:04:36 +00:00
```plaintext
2019-06-14 04:04:36 +00:00
POST /project_aliases
```
| 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 04:04:36 +00:00
```shell
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
```shell
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 04:04:36 +00:00
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab"
2019-06-14 04:04:36 +00:00
}
```
## 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
```plaintext
2019-06-14 04:04:36 +00:00
DELETE /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```shell
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
2019-06-14 04:04:36 +00:00
```