Custom Attributes API

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

Custom Attributes API

每个对自定义属性的 API 调用都必须经过管理员身份验证.

自定义属性当前可用于用户,组和项目,在本文档中将其称为"资源".

List custom attributes

获取资源上的所有自定义属性.

GET /users/:id/custom_attributes
GET /groups/:id/custom_attributes
GET /projects/:id/custom_attributes 
Attribute Type Required Description
id integer yes 资源的 ID
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes" 

响应示例:

[  {  "key":  "location",  "value":  "Antarctica"  },  {  "key":  "role",  "value":  "Developer"  }  ] 

Single custom attribute

在资源上获取单个自定义属性.

GET /users/:id/custom_attributes/:key
GET /groups/:id/custom_attributes/:key
GET /projects/:id/custom_attributes/:key 
Attribute Type Required Description
id integer yes 资源的 ID
key string yes 自定义属性的键
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location" 

响应示例:

{  "key":  "location",  "value":  "Antarctica"  } 

Set custom attribute

在资源上设置自定义属性. 如果该属性已经存在,则将对其进行更新;否则,将重新创建该属性.

PUT /users/:id/custom_attributes/:key
PUT /groups/:id/custom_attributes/:key
PUT /projects/:id/custom_attributes/:key 
Attribute Type Required Description
id integer yes 资源的 ID
key string yes 自定义属性的键
value string yes 自定义属性的值
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "value=Greenland" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location" 

响应示例:

{  "key":  "location",  "value":  "Greenland"  } 

Delete custom attribute

删除资源上的自定义属性.

DELETE /users/:id/custom_attributes/:key
DELETE /groups/:id/custom_attributes/:key
DELETE /projects/:id/custom_attributes/:key 
Attribute Type Required Description
id integer yes 资源的 ID
key string yes 自定义属性的键
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location" 
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2021-03-27 13:48:25

results matching ""

    No results matching ""