2017-09-28 12:49:42 -04:00
|
|
|
# Custom Attributes API
|
|
|
|
|
|
|
|
Every API call to custom attributes must be authenticated as administrator.
|
2017-09-18 11:07:38 -04:00
|
|
|
|
|
|
|
Custom attributes are currently available on users, groups, and projects,
|
|
|
|
which will be referred to as "resource" in this documentation.
|
2017-09-28 12:49:42 -04:00
|
|
|
|
|
|
|
## List custom attributes
|
|
|
|
|
2017-09-18 09:03:24 -04:00
|
|
|
Get all custom attributes on a resource.
|
2017-09-28 12:49:42 -04:00
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-09-28 12:49:42 -04:00
|
|
|
GET /users/:id/custom_attributes
|
2017-09-18 11:07:38 -04:00
|
|
|
GET /groups/:id/custom_attributes
|
2017-09-18 09:03:24 -04:00
|
|
|
GET /projects/:id/custom_attributes
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
2017-09-18 09:03:24 -04:00
|
|
|
| `id` | integer | yes | The ID of a resource |
|
2017-09-28 12:49:42 -04:00
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/users/42/custom_attributes
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"key": "location",
|
|
|
|
"value": "Antarctica"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "role",
|
|
|
|
"value": "Developer"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Single custom attribute
|
|
|
|
|
2017-09-18 09:03:24 -04:00
|
|
|
Get a single custom attribute on a resource.
|
2017-09-28 12:49:42 -04:00
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-09-28 12:49:42 -04:00
|
|
|
GET /users/:id/custom_attributes/:key
|
2017-09-18 11:07:38 -04:00
|
|
|
GET /groups/:id/custom_attributes/:key
|
2017-09-18 09:03:24 -04:00
|
|
|
GET /projects/:id/custom_attributes/:key
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
2017-09-18 09:03:24 -04:00
|
|
|
| `id` | integer | yes | The ID of a resource |
|
2017-09-28 12:49:42 -04:00
|
|
|
| `key` | string | yes | The key of the custom attribute |
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/users/42/custom_attributes/location
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"key": "location",
|
|
|
|
"value": "Antarctica"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Set custom attribute
|
|
|
|
|
2017-09-18 09:03:24 -04:00
|
|
|
Set a custom attribute on a resource. The attribute will be updated if it already exists,
|
2017-09-28 12:49:42 -04:00
|
|
|
or newly created otherwise.
|
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-09-28 12:49:42 -04:00
|
|
|
PUT /users/:id/custom_attributes/:key
|
2017-09-18 11:07:38 -04:00
|
|
|
PUT /groups/:id/custom_attributes/:key
|
2017-09-18 09:03:24 -04:00
|
|
|
PUT /projects/:id/custom_attributes/:key
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
2017-09-18 09:03:24 -04:00
|
|
|
| `id` | integer | yes | The ID of a resource |
|
2017-09-28 12:49:42 -04:00
|
|
|
| `key` | string | yes | The key of the custom attribute |
|
|
|
|
| `value` | string | yes | The value of the custom attribute |
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "value=Greenland" https://gitlab.example.com/api/v4/users/42/custom_attributes/location
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"key": "location",
|
|
|
|
"value": "Greenland"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete custom attribute
|
|
|
|
|
2017-09-18 09:03:24 -04:00
|
|
|
Delete a custom attribute on a resource.
|
2017-09-28 12:49:42 -04:00
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-09-28 12:49:42 -04:00
|
|
|
DELETE /users/:id/custom_attributes/:key
|
2017-09-18 11:07:38 -04:00
|
|
|
DELETE /groups/:id/custom_attributes/:key
|
2017-09-18 09:03:24 -04:00
|
|
|
DELETE /projects/:id/custom_attributes/:key
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
2017-09-18 09:03:24 -04:00
|
|
|
| `id` | integer | yes | The ID of a resource |
|
2017-09-28 12:49:42 -04:00
|
|
|
| `key` | string | yes | The key of the custom attribute |
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/users/42/custom_attributes/location
|
2017-09-28 12:49:42 -04:00
|
|
|
```
|