许可证

  • Tier: 基础版, 专业版, 旗舰版
  • Offering: 私有化部署

要与许可证端点交互,您需要以管理员身份进行身份验证。

获取当前许可证的信息#

plaintext
GET /license
json
1{ 2 "id": 2, 3 "plan": "ultimate", 4 "created_at": "2018-02-27T23:21:58.674Z", 5 "starts_at": "2018-01-27", 6 "expires_at": "2022-01-27", 7 "historical_max": 300, 8 "maximum_user_count": 300, 9 "expired": false, 10 "overage": 200, 11 "user_limit": 100, 12 "active_users": 300, 13 "licensee": { 14 "Name": "John Doe1", 15 "Email": "johndoe1@gitlab.com", 16 "Company": "GitLab" 17 }, 18 "add_ons": { 19 "GitLab_FileLocks": 1, 20 "GitLab_Auditor_User": 1 21 } 22}

获取所有许可证的信息#

plaintext
GET /licenses
json
1[ 2 { 3 "id": 1, 4 "plan": "premium", 5 "created_at": "2018-02-27T23:21:58.674Z", 6 "starts_at": "2018-01-27", 7 "expires_at": "2022-01-27", 8 "historical_max": 300, 9 "maximum_user_count": 300, 10 "expired": false, 11 "overage": 200, 12 "user_limit": 100, 13 "licensee": { 14 "Name": "John Doe1", 15 "Email": "johndoe1@gitlab.com", 16 "Company": "GitLab" 17 }, 18 "add_ons": { 19 "GitLab_FileLocks": 1 20 } 21 }, 22 { 23 "id": 2, 24 "plan": "ultimate", 25 "created_at": "2018-02-27T23:21:58.674Z", 26 "starts_at": "2018-01-27", 27 "expires_at": "2022-01-27", 28 "historical_max": 300, 29 "maximum_user_count": 300, 30 "expired": false, 31 "overage": 200, 32 "user_limit": 100, 33 "licensee": { 34 "Name": "Doe John", 35 "Email": "doejohn@gitlab.com", 36 "Company": "GitLab" 37 }, 38 "add_ons": { 39 "GitLab_FileLocks": 1 40 } 41 } 42]

超额是可计费用户数量与许可用户数量之间的差额。这根据许可证是否已过期而有所不同:

  • 如果许可证已过期,则使用历史最大可计费用户数 (historical_max)。
  • 如果许可证未过期,则使用当前可计费用户数。

返回:

  • 200 OK,响应包含 JSON 格式的许可证。如果没有许可证,则为一个空的 JSON 数组。
  • 403 Forbidden,如果当前用户无权读取许可证。

获取单个许可证的信息#

plaintext
GET /license/:id

支持的属性:

AttributeTypeRequiredDescription
idintegeryes极狐GitLab许可证的 ID。

返回以下状态代码:

  • 200 OK:响应包含 JSON 格式的许可证。
  • 404 Not Found:请求的许可证不存在。
  • 403 Forbidden:当前用户无权读取许可证。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id"

示例响应:

json
1{ 2 "id": 1, 3 "plan": "premium", 4 "created_at": "2018-02-27T23:21:58.674Z", 5 "starts_at": "2018-01-27", 6 "expires_at": "2022-01-27", 7 "historical_max": 300, 8 "maximum_user_count": 300, 9 "expired": false, 10 "overage": 200, 11 "user_limit": 100, 12 "active_users": 50, 13 "licensee": { 14 "Name": "John Doe1", 15 "Email": "johndoe1@gitlab.com", 16 "Company": "GitLab" 17 }, 18 "add_ons": { 19 "GitLab_FileLocks": 1, 20 "GitLab_Auditor_User": 1 21 } 22}

添加新许可证#

plaintext
POST /license
AttributeTypeRequiredDescription
licensestringyes许可证字符串
shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license?license=eyJkYXRhIjoiMHM5Q...S01Udz09XG4ifQ=="

示例响应:

json
1{ 2 "id": 1, 3 "plan": "ultimate", 4 "created_at": "2018-02-27T23:21:58.674Z", 5 "starts_at": "2018-01-27", 6 "expires_at": "2022-01-27", 7 "historical_max": 300, 8 "maximum_user_count": 300, 9 "expired": false, 10 "overage": 200, 11 "user_limit": 100, 12 "active_users": 300, 13 "licensee": { 14 "Name": "John Doe1", 15 "Email": "johndoe1@gitlab.com", 16 "Company": "GitLab" 17 }, 18 "add_ons": { 19 "GitLab_FileLocks": 1, 20 "GitLab_Auditor_User": 1 21 } 22}

返回:

  • 201 Created,如果许可证成功添加。
  • 400 Bad Request,如果许可证无法添加,并包含说明原因的错误消息。

删除许可证#

plaintext
DELETE /license/:id
AttributeTypeRequiredDescription
idintegeryes极狐GitLab许可证的 ID。
shell
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id"

返回:

  • 204 No Content,如果许可证成功删除。
  • 403 Forbidden,如果当前用户无权删除许可证。
  • 404 Not Found,如果找不到要删除的许可证。

触发可计费用户的重新计算#

plaintext
PUT /license/:id/refresh_billable_users
AttributeTypeRequiredDescription
idintegeryes极狐GitLab许可证的 ID。
shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id/refresh_billable_users"

示例响应:

json
{ "success": true }

返回:

  • 202 Accepted,如果成功启动刷新可计费用户的请求。
  • 403 Forbidden,如果当前用户无权为许可证刷新可计费用户。
  • 404 Not Found,如果找不到许可证。
AttributeTypeDescription
successboolean请求是否成功。

获取当前许可证的使用信息#

获取当前许可证的使用信息并以 CSV 格式导出。

plaintext
GET /license/usage_export.csv
shell
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/usage_export.csv"

示例响应:

plaintext
1License Key,"eyJkYXRhIjoib1EwRWZXU3RobDY2Yl= 2" 3Email,user@example.com 4License Start Date,2023-02-22 5License End Date,2024-02-22 6Company,Example Corp. 7Generated At,2023-09-05 06:56:23 8"","" 9Date,Billable User Count 102023-07-11 12:00:05,21 112023-07-13 12:00:06,21 122023-08-16 12:00:02,21 132023-09-04 12:00:12,21

返回:

  • 200 OK:响应包含 CSV 格式的许可证使用信息。
  • 403 Forbidden,如果当前用户无权查看许可证使用情况。