Group and project access requests API

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

Group and project access requests API

注意:此功能是在 GitLab 8.11 中引入的

Valid access levels

访问级别在Gitlab::Access模块中定义. 当前,这些级别被认可:

  • 无法访问( 0
  • 宾客( 10
  • 记者( 20
  • 显影剂( 30
  • 养护者( 40
  • 所有者( 50 )-仅对组有效

List access requests for a group or project

获取认证用户可见的访问请求列表.

  1. GET /groups/:id/access_requests
  2. GET /projects/:id/access_requests
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径

请求示例:

  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/access_requests"
  2. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/access_requests"

响应示例:

  1. [ { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" }, { "id": 2, "username": "john_doe", "name": "John Doe", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" } ]

Request access to a group or project

请求已验证用户访问组或项目.

  1. POST /groups/:id/access_requests
  2. POST /projects/:id/access_requests
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径

请求示例:

  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/access_requests"
  2. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/access_requests"

响应示例:

  1. { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" }

Approve an access request

批准给定用户的访问请求.

  1. PUT /groups/:id/access_requests/:user_id/approve
  2. PUT /projects/:id/access_requests/:user_id/approve
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
user_id integer yes 访问请求者的用户标识
access_level integer no 有效的访问级别(默认值: 30 ,开发人员访问级别)

请求示例:

  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/access_requests/:user_id/approve?access_level=20"
  2. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/access_requests/:user_id/approve?access_level=20"

响应示例:

  1. { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "access_level": 20 }

Deny an access request

拒绝给定用户的访问请求.

  1. DELETE /groups/:id/access_requests/:user_id
  2. DELETE /projects/:id/access_requests/:user_id
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
user_id integer yes 访问请求者的用户标识

请求示例:

  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/access_requests/:user_id"
  2. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/access_requests/:user_id"