288.md 4.9 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
# Group and project access requests API

> 原文:[https://docs.gitlab.com/ee/api/access_requests.html](https://docs.gitlab.com/ee/api/access_requests.html)

*   [Valid access levels](#valid-access-levels)
*   [List access requests for a group or project](#list-access-requests-for-a-group-or-project)
*   [Request access to a group or project](#request-access-to-a-group-or-project)
*   [Approve an access request](#approve-an-access-request)
*   [Deny an access request](#deny-an-access-request)

# Group and project access requests API[](#group-and-project-access-requests-api "Permalink")

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

## Valid access levels[](#valid-access-levels "Permalink")

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

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

## List access requests for a group or project[](#list-access-requests-for-a-group-or-project "Permalink")

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

```
GET /groups/:id/access_requests
GET /projects/:id/access_requests 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |

请求示例:

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

响应示例:

```
[  {  "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[](#request-access-to-a-group-or-project "Permalink")

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

```
POST /groups/:id/access_requests
POST /projects/:id/access_requests 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |

请求示例:

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

响应示例:

```
{  "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[](#approve-an-access-request "Permalink")

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

```
PUT /groups/:id/access_requests/:user_id/approve
PUT /projects/:id/access_requests/:user_id/approve 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `user_id` | integer | yes | 访问请求者的用户标识 |
| `access_level` | integer | no | 有效的访问级别(默认值: `30` ,开发人员访问级别) |

请求示例:

```
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"
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" 
```

响应示例:

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

## Deny an access request[](#deny-an-access-request "Permalink")

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

```
DELETE /groups/:id/access_requests/:user_id
DELETE /projects/:id/access_requests/:user_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `user_id` | integer | yes | 访问请求者的用户标识 |

请求示例:

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