企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# License > 原文:[https://docs.gitlab.com/ee/api/license.html](https://docs.gitlab.com/ee/api/license.html) * [Retrieve information about the current license](#retrieve-information-about-the-current-license) * [Retrieve information about all licenses](#retrieve-information-about-all-licenses) * [Add a new license](#add-a-new-license) * [Delete a license](#delete-a-license) # License[](#license-core-only "Permalink") 为了与许可证端点进行交互,您需要以管理员身份进行身份验证. ## Retrieve information about the current license[](#retrieve-information-about-the-current-license "Permalink") ``` GET /license ``` ``` { "id": 2, "plan": "gold", "created_at": "2018-02-27T23:21:58.674Z", "starts_at": "2018-01-27", "expires_at": "2022-01-27", "historical_max": 300, "maximum_user_count": 300, "expired": false, "overage": 200, "user_limit": 100, "active_users": 300, "licensee": { "Name": "John Doe1" }, "add_ons": { "GitLab_FileLocks": 1, "GitLab_Auditor_User": 1 } } ``` ## Retrieve information about all licenses[](#retrieve-information-about-all-licenses "Permalink") ``` GET /licenses ``` ``` [ { "id": 1, "plan": "silver", "created_at": "2018-02-27T23:21:58.674Z", "starts_at": "2018-01-27", "expires_at": "2022-01-27", "historical_max": 300, "maximum_user_count": 300, "expired": false, "overage": 200, "user_limit": 100, "licensee": { "Name": "John Doe1" }, "add_ons": { "GitLab_FileLocks": 1, "GitLab_Auditor_User": 1 } }, { "id": 2, "plan": "gold", "created_at": "2018-02-27T23:21:58.674Z", "starts_at": "2018-01-27", "expires_at": "2022-01-27", "historical_max": 300, "maximum_user_count": 300, "expired": false, "overage": 200, "user_limit": 100, "licensee": { "Name": "Doe John" }, "add_ons": { "GitLab_FileLocks": 1, } } ] ``` 超出数是活动用户数与许可用户数之差. 根据许可证是否已过期,计算方法会有所不同. * 如果许可证已过期,则使用历史最大活动用户数( `historical_max` ). * 如果许可证尚未过期,则使用当前活动用户数. Returns: * `200 OK` ,响应包含 JSON 格式的许可证. 如果没有许可证,这将是一个空的 JSON 数组. * `403 Forbidden`如果当前用户不允许阅读许可证, `403 Forbidden` . ## Add a new license[](#add-a-new-license "Permalink") ``` POST /license ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `license` | string | yes | 许可证字符串 | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license?license=eyJkYXRhIjoiMHM5Q...S01Udz09XG4ifQ==" ``` 响应示例: ``` { "id": 1, "plan": "gold", "created_at": "2018-02-27T23:21:58.674Z", "starts_at": "2018-01-27", "expires_at": "2022-01-27", "historical_max": 300, "maximum_user_count": 300, "expired": false, "overage": 200, "user_limit": 100, "active_users": 300, "licensee": { "Name": "John Doe1" }, "add_ons": { "GitLab_FileLocks": 1, "GitLab_Auditor_User": 1 } } ``` Returns: * `201 Created`如果成功添加许可证,则`201 Created` . * `400 Bad Request`如果无法添加许可证),并附有一条错误消息,说明原因. ## Delete a license[](#delete-a-license "Permalink") ``` DELETE /license/:id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer | yes | GitLab 许可证的 ID. | ``` curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id" ``` 响应示例: ``` { "id": 2, "plan": "gold", "created_at": "2018-02-27T23:21:58.674Z", "starts_at": "2018-01-27", "expires_at": "2022-01-27", "historical_max": 300, "maximum_user_count": 300, "expired": false, "overage": 200, "user_limit": 100, "licensee": { "Name": "John Doe" }, "add_ons": { "GitLab_FileLocks": 1, "GitLab_Auditor_User": 1 } } ``` Returns: * `204 No Content`如果成功删除了许可证,则`204 No Content` . * `403 Forbidden`如果当前用户不允许删除许可证,则禁止. * 如果`404 Not Found`删除许可证,则`404 Not Found` .