License

原文:https://docs.gitlab.com/ee/api/license.html

License

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

Retrieve information about the current license

  1. GET /license
  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, "active_users": 300, "licensee": { "Name": "John Doe1" }, "add_ons": { "GitLab_FileLocks": 1, "GitLab_Auditor_User": 1 } }

Retrieve information about all licenses

  1. GET /licenses
  1. [ { "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

  1. POST /license
Attribute Type Required Description
license string yes 许可证字符串
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license?license=eyJkYXRhIjoiMHM5Q...S01Udz09XG4ifQ=="

响应示例:

  1. { "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

  1. DELETE /license/:id
Attribute Type Required Description
id integer yes GitLab 许可证的 ID.
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/license/:id"

响应示例:

  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": "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 .