- Group and project members API
- Group and project members API
- Valid access levels
- List all members of a group or project
- List all members of a group or project including inherited members
- Get a member of a group or project
- Get a member of a group or project, including inherited members
- Add a member to a group or project
- Edit a member of a group or project
- Remove a member from a group or project
- Give a group access to a project
Group and project members API
- Valid access levels
- List all members of a group or project
- List all members of a group or project including inherited members
- Get a member of a group or project
- Get a member of a group or project, including inherited members
- Add a member to a group or project
- Edit a member of a group or project
- Remove a member from a group or project
- Give a group access to a project
Group and project members API
Valid access levels
访问级别在Gitlab::Access
模块中定义. 当前,这些级别被认可:
- 无法访问(
0
) - 宾客(
10
) - 记者(
20
) - 显影剂(
30
) - 养护者(
40
) - 所有者(
50
)-仅对组有效
注意:由于存在问题 ,个人名称空间中的项目将不会显示所有者( 50
)所有者的权限.
List all members of a group or project
获取可通过身份验证的用户查看的组或项目成员的列表. 仅返回直接成员,而不返回通过祖先组继承的成员.
此函数使用分页参数page
和per_page
来限制用户列表.
GET /groups/:id/members
GET /projects/:id/members
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
query |
string | no | 查询字符串以搜索成员 |
user_ids |
整数数组 | no | 根据给定的用户 ID 过滤结果 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members"
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members"
响应示例:
[ { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30, "group_saml_identity": null }, { "id": 2, "username": "john_doe", "name": "John Doe", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30, "email": "john@example.com", "group_saml_identity": { "extern_uid":"ABC-1234567890", "provider": "group_saml", "saml_provider_id": 10 } } ]
List all members of a group or project including inherited members
获取可通过身份验证的用户查看的组或项目成员的列表,包括通过祖先组继承的成员. 当用户是项目/组和一个或多个祖先组的成员时,仅以项目access_level
(如果存在)或用户所属项目组中第一个组的用户的access_level
返回一次祖先链.
此函数使用分页参数page
和per_page
来限制用户列表.
GET /groups/:id/members/all
GET /projects/:id/members/all
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
query |
string | no | 查询字符串以搜索成员 |
user_ids |
整数数组 | no | 根据给定的用户 ID 过滤结果 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members/all"
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members/all"
响应示例:
[ { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30, "group_saml_identity": null }, { "id": 2, "username": "john_doe", "name": "John Doe", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30 "email": "john@example.com", "group_saml_identity": { "extern_uid":"ABC-1234567890", "provider": "group_saml", "saml_provider_id": 10 } }, { "id": 3, "username": "foo_bar", "name": "Foo bar", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-11-22T14:13:35Z", "access_level": 30, "group_saml_identity": null } ]
Get a member of a group or project
获取组或项目的成员. 仅返回直接成员,而不返回通过祖先组继承的成员.
GET /groups/:id/members/:user_id
GET /projects/:id/members/:user_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members/:user_id"
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members/:user_id"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "access_level": 30, "expires_at": null, "group_saml_identity": null }
Get a member of a group or project, including inherited members
在 GitLab 12.4 中引入 .
获取组或项目的成员,包括通过祖先组继承的成员. 有关详细信息,请参见相应的端点以列出所有继承的成员 .
GET /groups/:id/members/all/:user_id
GET /projects/:id/members/all/:user_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members/all/:user_id"
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members/all/:user_id"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "access_level": 30, "expires_at": null, "group_saml_identity": null }
Add a member to a group or project
将成员添加到组或项目.
POST /groups/:id/members
POST /projects/:id/members
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
user_id |
integer | yes | 新成员的用户标识 |
access_level |
integer | yes | 有效的访问级别 |
expires_at |
string | no | 日期格式为 YEAR-MONTH-DAY 的日期字符串 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --data "user_id=1&access_level=30" "https://gitlab.example.com/api/v4/groups/:id/members"
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --data "user_id=1&access_level=30" "https://gitlab.example.com/api/v4/projects/:id/members"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 30, "group_saml_identity": null }
Edit a member of a group or project
更新组或项目的成员.
PUT /groups/:id/members/:user_id
PUT /projects/:id/members/:user_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
access_level |
integer | yes | 有效的访问级别 |
expires_at |
string | no | 日期格式为 YEAR-MONTH-DAY 的日期字符串 |
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members/:user_id?access_level=40"
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members/:user_id?access_level=40"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 40, "group_saml_identity": null }
Set override flag for a member of a group
在 GitLab 13.0 中引入 .
默认情况下,LDAP 组成员的访问级别设置为 LDAP 通过组同步指定的值. 您可以通过调用此端点来允许访问级别替代.
POST /groups/:id/members/:user_id/override
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 认证用户拥有的组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/:id/members/:user_id/override"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 40, "override": true }
Remove override for a member of a group
在 GitLab 13.0 中引入 .
将替代标志设置为 false,并允许 LDAP 组同步将访问级别重置为 LDAP 指定的值.
DELETE /groups/:id/members/:user_id/override
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 认证用户拥有的组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/:id/members/:user_id/override"
响应示例:
{ "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", "web_url": "http://192.168.1.8:3000/root", "expires_at": "2012-10-22T14:13:35Z", "access_level": 40, "override": false }
Remove a member from a group or project
从组或项目中删除用户.
DELETE /groups/:id/members/:user_id
DELETE /projects/:id/members/:user_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目或组的 ID 或URL 编码路径 |
user_id |
integer | yes | 成员的用户标识 |
unassign_issuables |
boolean | false | 标志,指示是否应从给定的组或项目内取消分配任何问题或合并请求的已删除成员 |
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/members/:user_id"
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/members/:user_id"