330.md 4.3 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
# Licenses API

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

*   [List license templates](#list-license-templates)
*   [Single license template](#single-license-template)

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

在 GitLab 中,有一个 API 端点可用于处理各种开源许可证模板. 有关各种许可条款的更多信息,请访问[此站点](https://choosealicense.com/)或在线提供的许多其他资源.

## List license templates[](#list-license-templates "Permalink")

获取所有许可证模板.

```
GET /templates/licenses 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `popular` | boolean | no | 如果通过,则仅返回常用许​​可证 |

```
curl https://gitlab.example.com/api/v4/templates/licenses?popular=1 
```

响应示例:

```
[  {  "key":  "apache-2.0",  "name":  "Apache License 2.0",  "nickname":  null,  "featured":  true,  "html_url":  "http://choosealicense.com/licenses/apache-2.0/",  "source_url":  "http://www.apache.org/licenses/LICENSE-2.0.html",  "description":  "A permissive license that also provides an express grant of patent rights from contributors to users.",  "conditions":  [  "include-copyright",  "document-changes"  ],  "permissions":  [  "commercial-use",  "modifications",  "distribution",  "patent-use",  "private-use"  ],  "limitations":  [  "trademark-use",  "no-liability"  ],  "content":  "                                 Apache License\n Version 2.0, January 2004\n [...]"  },  {  "key":  "gpl-3.0",  "name":  "GNU General Public License v3.0",  "nickname":  "GNU GPLv3",  "featured":  true,  "html_url":  "http://choosealicense.com/licenses/gpl-3.0/",  "source_url":  "http://www.gnu.org/licenses/gpl-3.0.txt",  "description":  "The GNU GPL is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license.",  "conditions":  [  "include-copyright",  "document-changes",  "disclose-source",  "same-license"  ],  "permissions":  [  "commercial-use",  "modifications",  "distribution",  "patent-use",  "private-use"  ],  "limitations":  [  "no-liability"  ],  "content":  "                    GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n [...]"  },  {  "key":  "mit",  "name":  "MIT License",  "nickname":  null,  "featured":  true,  "html_url":  "http://choosealicense.com/licenses/mit/",  "source_url":  "http://opensource.org/licenses/MIT",  "description":  "A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.",  "conditions":  [  "include-copyright"  ],  "permissions":  [  "commercial-use",  "modifications",  "distribution",  "private-use"  ],  "limitations":  [  "no-liability"  ],  "content":  "The MIT License (MIT)\n\nCopyright (c) [year] [fullname]\n [...]"  }  ] 
```

## Single license template[](#single-license-template "Permalink")

获取单个许可证模板. 您可以传递参数来替换许可证占位符.

```
GET /templates/licenses/:key 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string | yes | 许可证模板的密钥 |
| `project` | string | no | 受版权保护的项目名称 |
| `fullname` | string | no | 著作权人的全名 |

> **注意:**如果省略`fullname`参数但对请求进行身份验证,则将使用经过身份验证的用户名来替换版权所有者占位符.

```
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/templates/licenses/mit?project=My+Cool+Project 
```

响应示例:

```
{  "key":  "mit",  "name":  "MIT License",  "nickname":  null,  "featured":  true,  "html_url":  "http://choosealicense.com/licenses/mit/",  "source_url":  "http://opensource.org/licenses/MIT",  "description":  "A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.",  "conditions":  [  "include-copyright"  ],  "permissions":  [  "commercial-use",  "modifications",  "distribution",  "private-use"  ],  "limitations":  [  "no-liability"  ],  "content":  "The MIT License (MIT)\n\nCopyright (c) 2016 John Doe\n [...]"  } 
```