333.md 4.4 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
# Managed Licenses API

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

*   [List managed licenses](#list-managed-licenses)
*   [Show an existing managed license](#show-an-existing-managed-license)
*   [Create a new managed license](#create-a-new-managed-license)
*   [Delete a managed license](#delete-a-managed-license)
*   [Edit an existing managed license](#edit-an-existing-managed-license)

# Managed Licenses API[](#managed-licenses-api-ultimate "Permalink")

## List managed licenses[](#list-managed-licenses "Permalink")

获取给定项目的所有托管许可证.

```
GET /projects/:id/managed_licenses 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |

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

响应示例:

```
[  {  "id":  1,  "name":  "MIT",  "approval_status":  "approved"  },  {  "id":  3,  "name":  "ISC",  "approval_status":  "blacklisted"  }  ] 
```

## Show an existing managed license[](#show-an-existing-managed-license "Permalink")

显示现有的托管许可证.

```
GET /projects/:id/managed_licenses/:managed_license_id 
```

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

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6" 
```

响应示例:

```
{  "id":  1,  "name":  "MIT",  "approval_status":  "blacklisted"  } 
```

## Create a new managed license[](#create-a-new-managed-license "Permalink")

使用给定的名称和批准状态为给定的项目创建一个新的托管许可证.

```
POST /projects/:id/managed_licenses 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `name` | string | yes | 托管许可证的名称 |
| `approval_status` | string | yes | 批准状态. "批准"或"列入黑名单" |

```
curl --data "name=MIT&approval_status=blacklisted" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses" 
```

响应示例:

```
{  "id":  1,  "name":  "MIT",  "approval_status":  "approved"  } 
```

## Delete a managed license[](#delete-a-managed-license "Permalink")

删除具有给定 ID 的托管许可证.

```
DELETE /projects/:id/managed_licenses/:managed_license_id 
```

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

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4" 
```

成功后,它将以 HTTP 204 响应进行回复.

## Edit an existing managed license[](#edit-an-existing-managed-license "Permalink")

使用新的批准状态更新现有的托管许可证.

```
PATCH /projects/:id/managed_licenses/:managed_license_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `managed_license_id` | integer/string | yes | 属于项目的许可证的 ID 或 URL 编码名称 |
| `approval_status` | string | yes | 批准状态. "批准"或"列入黑名单" |

```
curl --request PATCH --data "approval_status=blacklisted" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6" 
```

响应示例:

```
{  "id":  1,  "name":  "MIT",  "approval_status":  "blacklisted"  } 
```