{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: 私有化部署
{{< /details >}}
要与许可证端点交互,您需要以管理员身份进行身份验证。
获取当前许可证的信息
GET /license
{
"id": 2,
"plan": "ultimate",
"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",
"Email": "johndoe1@gitlab.com",
"Company": "GitLab"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
获取所有许可证的信息
GET /licenses
[
{
"id": 1,
"plan": "premium",
"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",
"Email": "johndoe1@gitlab.com",
"Company": "GitLab"
},
"add_ons": {
"GitLab_FileLocks": 1
}
},
{
"id": 2,
"plan": "ultimate",
"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",
"Email": "doejohn@gitlab.com",
"Company": "GitLab"
},
"add_ons": {
"GitLab_FileLocks": 1
}
}
]
超额是可计费用户数量与许可用户数量之间的差额。这根据许可证是否已过期而有所不同:
- 如果许可证已过期,则使用历史最大可计费用户数 (
historical_max
)。 - 如果许可证未过期,则使用当前可计费用户数。
返回:
-
200 OK
,响应包含 JSON 格式的许可证。如果没有许可证,则为一个空的 JSON 数组。 -
403 Forbidden
,如果当前用户无权读取许可证。
获取单个许可证的信息
GET /license/:id
支持的属性:
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer | yes | 极狐GitLab许可证的 ID。 |
返回以下状态代码:
-
200 OK
:响应包含 JSON 格式的许可证。 -
404 Not Found
:请求的许可证不存在。 -
403 Forbidden
:当前用户无权读取许可证。
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id"
示例响应:
{
"id": 1,
"plan": "premium",
"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": 50,
"licensee": {
"Name": "John Doe1",
"Email": "johndoe1@gitlab.com",
"Company": "GitLab"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
添加新许可证
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": "ultimate",
"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",
"Email": "johndoe1@gitlab.com",
"Company": "GitLab"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
返回:
-
201 Created
,如果许可证成功添加。 -
400 Bad Request
,如果许可证无法添加,并包含说明原因的错误消息。
删除许可证
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"
返回:
-
204 No Content
,如果许可证成功删除。 -
403 Forbidden
,如果当前用户无权删除许可证。 -
404 Not Found
,如果找不到要删除的许可证。
触发可计费用户的重新计算
PUT /license/:id/refresh_billable_users
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer | yes | 极狐GitLab许可证的 ID。 |
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id/refresh_billable_users"
示例响应:
{
"success": true
}
返回:
-
202 Accepted
,如果成功启动刷新可计费用户的请求。 -
403 Forbidden
,如果当前用户无权为许可证刷新可计费用户。 -
404 Not Found
,如果找不到许可证。
Attribute | Type | Description |
---|---|---|
success |
boolean | 请求是否成功。 |
获取当前许可证的使用信息
获取当前许可证的使用信息并以 CSV 格式导出。
GET /license/usage_export.csv
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/usage_export.csv"
示例响应:
License Key,"eyJkYXRhIjoib1EwRWZXU3RobDY2Yl=
"
Email,user@example.com
License Start Date,2023-02-22
License End Date,2024-02-22
Company,Example Corp.
Generated At,2023-09-05 06:56:23
"",""
Date,Billable User Count
2023-07-11 12:00:05,21
2023-07-13 12:00:06,21
2023-08-16 12:00:02,21
2023-09-04 12:00:12,21
返回:
-
200 OK
:响应包含 CSV 格式的许可证使用信息。 -
403 Forbidden
,如果当前用户无权查看许可证使用情况。