GitLab 订阅内部 API
GitLab 订阅内部 API 由 CustomersDot 应用程序使用,其他消费者无法使用。本文档面向参与 GitLab 和 CustomersDot 代码库开发的人员。
添加新端点
API 端点默认应可外部访问,并具备适当的身份验证和授权。在添加新的内部端点前,请考虑该 API 是否能为更广泛的 GitLab 社区带来益处,并可以转为外部访问。
对于 GitLab 订阅门户,当需要在没有用户上下文的情况下更新 GitLab 时,我们可能会选择使用内部 API。这意味着我们无法访问用户的访问令牌,而是以 CustomersDot 应用程序的身份进行更新。
身份验证
CustomersDot JWT
所有端点均使用来自 CustomersDot 的 JWT 身份验证进行认证。
客户端使用 JWT 进行身份验证的步骤:
- 从凭证中读取签名密钥的内容
- 使用签名密钥生成 JSON Web Token (
JWT) - 在
X-CUSTOMERS-DOT-INTERNAL-TOKEN头部传递 JWT
Admin 个人访问令牌 (PAT)
此身份验证方法已被弃用,因为 Cells 架构不支持它。它将在未来版本中被移除。请改用 JWT 身份验证。
要以管理员身份进行身份验证,为管理员生成具有 api 和 admin_mode 范围的个人访问令牌。此令牌可在 PRIVATE-TOKEN 头部中提供。
内部端点
命名空间
获取群组所有者
使用 GET 命令获取命名空间的直接所有者。CustomersDot 使用此端点查找需要通知计费事件的用户。
GET /internal/gitlab_subscriptions/namespaces/:id/owners示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/owners"示例响应:
[
{
"user": {
"id": 1,
"username": "john_smith",
"name": "John Smith"
},
"access_level": 50,
"notification_email": "[email protected]"
}
]根据 ID 获取命名空间
用于获取命名空间信息。
GET /internal/gitlab_subscriptions/namespaces/:id参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer/string | yes | ID 或 命名空间的 URL 编码路径 |
示例请求:
curl --request GET --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1"示例响应:
{
"id": 1,
"name": "group1",
"path": "group1",
"kind": "group",
"full_path": "group1",
"parent_id": null,
"avatar_url": null,
"web_url": "https://gitlab.example.com/groups/group1",
"members_count_with_descendants": 2,
"billable_members_count": 2,
"max_seats_used": 0,
"seats_in_use": 0,
"plan": "default",
"end_date": null,
"trial_ends_on": null,
"trial": false,
"root_repository_size": 100,
"projects_count": 3
}更新命名空间
使用 PUT 命令更新现有命名空间。
PUT /internal/gitlab_subscriptions/namespaces/:id参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer/string | yes | ID 或 命名空间的 URL 编码路径 |
shared_runners_minutes_limit |
integer | no | 计算分钟配额 |
extra_shared_runners_minutes_limit |
integer | no | 额外计算分钟数 |
additional_purchased_storage_size |
integer | no | 额外存储大小 |
additional_purchased_storage_ends_on |
date | no | 额外购买存储到期日 |
gitlab_subscription_attributes |
hash | no | 包含 GitLab 订阅属性的哈希对象。接受 seats、max_seats_used、plan_code、end_date、auto_renew、trial、trial_ends_on、trial_starts_on、trial_extension_type |
示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1 --data '{"shared_runners_minutes_limit":1000}'"示例响应:
{
"id": 1,
"name": "group1",
"path": "group1",
"kind": "group",
"full_path": "group1",
"parent_id": null,
"avatar_url": null,
"web_url": "https://gitlab.example.com/groups/group1",
"members_count_with_descendants": 2,
"billable_members_count": 2,
"max_seats_used": 0,
"seats_in_use": 0,
"plan": "default",
"end_date": null,
"trial_ends_on": null,
"trial": false,
"root_repository_size": 100,
"projects_count": 3
}预配命名空间
用于为根命名空间预配订阅相关资源,包括基础产品、存储、计算分钟数和附加购买。该端点独立处理资源 - 如果某个资源预配失败,其他资源仍会继续预配。
您可以根据提供的参数在单个请求中预配一个或多个资源。
POST /internal/gitlab_subscriptions/namespaces/:id/provision参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer | yes | 要预配的命名空间 ID |
该端点支持在 provision 根键下嵌套的每个资源的参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
base_product |
hash | no | 包含 GitLab 订阅属性的哈希对象 |
storage |
hash | no | 包含存储属性的哈希对象 |
compute_minutes |
hash | no | 包含计算分钟属性的哈希对象 |
add_on_purchases |
hash | no | 包含附加购买属性的哈希对象 |
基础产品支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
plan_code |
string | no | 订阅层级代码 |
start_date |
date | no | 订阅开始日期 |
end_date |
date | no | 订阅结束日期 |
seats |
integer | no | 订阅中的座位数 |
max_seats_used |
integer | no | 当前订阅期内计费用户的最高数量 |
auto_renew |
boolean | no | 订阅是否在到期日自动续费 |
trial |
boolean | no | 订阅是否为试用期 |
trial_starts_on |
date | no | 试用期开始日期。如果试用为 true 则为必需 |
trial_ends_on |
date | no | 试用期结束日期 |
存储支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
additional_purchased_storage_size |
integer | no | 额外存储大小 |
additional_purchased_storage_ends_on |
date | no | 额外购买存储到期日 |
计算分钟支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
shared_runners_minutes_limit |
integer | no | 计算分钟配额 |
extra_shared_runners_minutes_limit |
integer | no | 额外计算分钟数 |
附加购买支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
quantity |
integer | No | 订阅附加购买的单元数量。必须是非负整数。(例如:Duo Pro 附加购买的座位数) |
started_on |
date | Yes | 订阅附加购买可用日期 |
expires_on |
date | Yes | 订阅附加购买到期日期 |
purchase_xid |
string | No | 订阅附加购买的标识符(例如:Duo Pro 附加购买的订阅名称) |
trial |
boolean | No | 附加购买是否为试用 |
示例请求:
curl --request POST --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1/provision" \
--data '{
"provision": {
"base_product": {
"plan_code": "ultimate",
"seats": 30,
"start_date": "2024-01-01",
"end_date": "2025-01-01",
"max_seats_used": 10,
"auto_renew": true,
"trial": false,
"trial_starts_on": null,
"trial_ends_on": null
},
"storage": {
"additional_purchased_storage_size": 100,
"additional_purchased_storage_ends_on": "2025-01-01"
},
"compute_minutes": {
"extra_shared_runners_minutes_limit": 90,
"shared_runners_minutes_limit": 100
},
"add_on_purchases": {
"duo_enterprise": [{
"started_on": "2024-01-01",
"expires_on": "2025-01-01",
"purchase_xid": "A-S00001",
"quantity": 1,
"trial": false
}]
}
}
}'响应状态码:
- 200 OK - 命名空间预配成功(空响应)
- 400 Bad Request - 无效参数或非根命名空间
- 401 Unauthorized - 无效令牌
- 404 Not Found - 命名空间不存在
- 422 Unprocessable Entity - 预配期间验证错误
订阅
订阅端点由 CustomersDot (customers.gitlab.com) 使用,用于将订阅(包括试用和附加购买)应用到 GitLab.com 上的个人命名空间或顶级群组。
获取订阅
使用 GET 命令查看现有订阅。
GET /internal/gitlab_subscriptions/namespaces/:id/gitlab_subscription示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/gitlab_subscription"示例响应:
{
"plan": {
"code": "premium",
"name": "premium",
"trial": false,
"auto_renew": null,
"upgradable": false,
"exclude_guests": false
},
"usage": {
"seats_in_subscription": 80,
"seats_in_use": 82,
"max_seats_used": 82,
"seats_owed": 2
},
"billing": {
"subscription_start_date": "2020-07-15",
"subscription_end_date": "2021-07-15",
"trial_ends_on": null
}
}创建订阅
使用 POST 命令创建订阅。
POST /internal/gitlab_subscriptions/namespaces/:id/gitlab_subscription| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
start_date |
date | yes | 订阅开始日期 |
end_date |
date | no | 订阅结束日期 |
plan_code |
string | no | 订阅层级代码 |
seats |
integer | no | 订阅中的座位数 |
max_seats_used |
integer | no | 当前订阅期内计费用户的最高数量 |
auto_renew |
boolean | no | 订阅是否在到期日自动续费 |
trial |
boolean | no | 订阅是否为试用期 |
trial_starts_on |
date | no | 试用期开始日期 |
trial_ends_on |
date | no | 试用期结束日期 |
示例请求:
curl --request POST --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/gitlab_subscription?start_date="2020-07-15"&plan="premium"&seats=10"示例响应:
{
"plan": {
"code":"premium",
"name":"premium",
"trial":false,
"auto_renew":null,
"upgradable":false
},
"usage": {
"seats_in_subscription":10,
"seats_in_use":1,
"max_seats_used":0,
"seats_owed":0
},
"billing": {
"subscription_start_date":"2020-07-15",
"subscription_end_date":null,
"trial_ends_on":null
}
}更新订阅
使用 PUT 命令更新现有订阅。
PUT /internal/gitlab_subscriptions/namespaces/:id/gitlab_subscription| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
start_date |
date | no | 订阅开始日期 |
end_date |
date | no | 订阅结束日期 |
plan_code |
string | no | 订阅层级代码 |
seats |
integer | no | 订阅中的座位数 |
max_seats_used |
integer | no | 当前订阅期内计费用户的最高数量 |
auto_renew |
boolean | no | 订阅是否在到期日自动续费 |
trial |
boolean | no | 订阅是否为试用期 |
trial_starts_on |
date | no | 试用期开始日期。如果试用为 true 则为必需。 |
trial_ends_on |
date | no | 试用期结束日期 |
示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/gitlab_subscription?max_seats_used=0"示例响应:
{
"plan": {
"code":"premium",
"name":"premium",
"trial":false,
"auto_renew":null,
"upgradable":false
},
"usage": {
"seats_in_subscription":80,
"seats_in_use":82,
"max_seats_used":0,
"seats_owed":2
},
"billing": {
"subscription_start_date":"2020-07-15",
"subscription_end_date":"2021-07-15",
"trial_ends_on":null
}
}即将对账
upcoming_reconciliations 端点由 CustomersDot (customers.gitlab.com) 用于更新命名空间的即将对账。
更新即将对账
PUT /internal/gitlab_subscriptions/namespaces/:namespace_id/upcoming_reconciliations| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
namespace_id |
ID | yes | 具有即将对账的命名空间 ID |
next_reconciliation_date |
date | yes | 对账将发生的日期 |
display_alert_from |
date | yes | 开始显示即将对账警报的日期 |
示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" --header "Content-Type: application/json" \
--data '{"upcoming_reconciliations": [{"next_reconciliation_date": "12 Jun 2021", "display_alert_from": "05 Jun 2021"}]}' \
"https://gitlab.com/api/v4/internal/gitlab_subscriptions/129/upcoming_reconciliations"示例响应:
200删除即将对账
使用 DELETE 命令删除 upcoming_reconciliation。
DELETE /internal/gitlab_subscriptions/namespaces/:namespace_id/upcoming_reconciliations示例请求:
curl --request DELETE \
--url "http://localhost:3000/api/v4/internal/gitlab_subscriptions/namespaces/22/upcoming_reconciliations" \
--header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>"示例响应:
204用户
检索用户
使用 GET 命令根据用户 ID 获取用户对象。
GET /internal/gitlab_subscriptions/users/:id示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/users/:id"示例响应:
{
"id": 1,
"username": "john_smith",
"name": "John Smith",
"web_url": "http://localhost:3000/john_smith"
}获取命名空间中的用户权限
使用 GET 命令获取用户在命名空间中的权限。
GET /internal/gitlab_subscriptions/namespaces/:namespace_id/user_permissions/:user_id示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/:namespace_id/user_permissions/:user_id"示例响应:
{
"edit_billing": true
}更新信用卡验证
使用 PUT 命令更新用户的信用卡验证
PUT /internal/gitlab_subscriptions/users/:user_id/credit_card_validation示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" \
--data '{"credit_card_validated_at": "2020-01-01 00:00:00 UTC", "credit_card_expiration_year": "2010", "credit_card_expiration_month": "12", "credit_card_holder_name": "John Smith", "credit_card_type": "American Express", "credit_card_mask_number": "1111", "zuora_payment_method_xid": "abc123", "stripe_setup_intent_xid": "seti_abc123", "stripe_payment_method_xid": "pm_abc123", "stripe_card_fingerprint": "card123"}' \
"https://gitlab.com/api/v4/internal/gitlab_subscriptions/users/:user_id/credit_card_validation"示例响应:
{
"success": {}
}附加购买
此 API 由 CustomersDot 用于管理附加购买,不包括计算分钟数和存储包。
创建多个订阅附加购买(内部)
使用 POST 命令创建、更新和取消预配多个订阅附加购买。可能的附加类型为 duo_pro、duo_enterprise 和 product_analytics。
POST /internal/gitlab_subscriptions/namespaces/:id/subscription_add_on_purchases支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
quantity |
integer | No | 订阅附加购买的单元数量。必须是非负整数。(例如:Duo Pro 附加购买的座位数) |
started_on |
date | Yes | 订阅附加购买可用日期 |
expires_on |
date | Yes | 订阅附加购买到期日期 |
purchase_xid |
string | No | 订阅附加购买的标识符(例如:代码建议附加购买的订阅名称) |
trial |
boolean | No | 附加购买是否为试用 |
如果成功,返回 201 和以下响应属性:
| 属性 | 类型 | 描述 |
|---|---|---|
namespace_id |
integer | 与购买关联的命名空间唯一标识符 |
namespace_name |
string | 与购买关联的命名空间名称 |
add_on |
integer | 与购买相关的附加类型。可能的附加类型为 Code Suggestions(Duo Pro 别名)、Duo Enterprise 和 Product Analytics |
quantity |
integer | 订阅附加购买的单元数量 |
started_on |
date | 订阅附加购买激活日期 |
expires_on |
date | 订阅附加购买到期日期 |
purchase_xid |
string | 订阅附加购买唯一标识符 |
trial |
boolean | 指示附加购买是否为试用 |
创建/更新示例请求:
curl --request POST \
--header --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" \
--header "Content-Type: application/json" \
--data '{ "add_on_purchases": { "duo_pro": [{ "quantity": 1, "started_on": "<YYYY-MM-DD>", "expires_on": "<YYYY-MM-DD>", "purchase_xid": "C-00123456", "trial": false }] } }' \
"https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/subscription_add_on_purchases"取消预配示例请求:
curl --request POST \
--header --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" \
--header "Content-Type: application/json" \
--data '{ "add_on_purchases": { "duo_pro": [{ "started_on": "<YYYY-MM-DD>", "expires_on": "<YYYY-MM-DD>" }] } }' \
"https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/subscription_add_on_purchases"日期应反映请求前一天(即昨天)的日期。
示例响应:
[
{
"namespace_id": 1234,
"namespace_name": "namespace-name",
"add_on": "Code Suggestions",
"quantity": 1,
"started_on": "2024-01-01",
"expires_on": "2024-12-31",
"purchase_xid": "C-00123456",
"trial": false
}
]获取订阅附加购买
使用 GET 命令查看现有订阅附加购买。
GET /internal/gitlab_subscriptions/namespaces/:id/subscription_add_on_purchases/:add_on_name示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/subscription_add_on_purchases/code_suggestions"示例响应:
{
"namespace_id":1234,
"namespace_name":"A Namespace Name",
"add_on":"Code Suggestions",
"quantity":15,
"started_on":"2024-06-15",
"expires_on":"2024-07-15",
"purchase_xid":"C-00123456",
"trial":true
}计算分钟数预配
计算分钟数端点由 CustomersDot (customers.gitlab.com) 用于将额外的计算分钟包应用到 GitLab.com 上的个人命名空间或顶级群组。
创建额外包
使用 POST 命令创建额外包。
POST /internal/gitlab_subscriptions/namespaces/:id/minutes| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
packs |
array | yes | 已购买的计算包数组 |
packs[expires_at] |
date | yes | 已购买包的到期日期 |
packs[number_of_minutes] |
integer | yes | 额外计算分钟数 |
packs[purchase_xid] |
string | yes | 购买的唯一 ID |
示例请求:
curl --request POST \
--url "http://localhost:3000/api/v4/internal/gitlab_subscriptions/namespaces/123/minutes" \
--header 'Content-Type: application/json' \
--header 'X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>' \
--data '{
"packs": [
{
"number_of_minutes": 10000,
"expires_at": "2022-01-01",
"purchase_xid": "C-00123456"
}
]
}'示例响应:
[
{
"namespace_id": 123,
"expires_at": "2022-01-01",
"number_of_minutes": 10000,
"purchase_xid": "C-00123456"
}
]移动额外包
使用 PATCH 命令将额外包从一个命名空间移动到另一个命名空间。
PATCH /internal/gitlab_subscriptions/namespaces/:id/minutes/move/:target_id| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
string | yes | 要转移包的源命名空间 ID |
target_id |
string | yes | 要转移包的目标命名空间 ID |
示例请求:
curl --request PATCH \
--url "http://localhost:3000/api/v4/internal/gitlab_subscriptions/namespaces/123/minutes/move/321" \
--header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>"示例响应:
{
"message": "202 Accepted"
}已弃用端点
这些端点已迁移到内部端点。现在它们已被弃用,并将在未来版本中被移除。
附加购买(已弃用)
此 API 由 CustomersDot 用于管理附加购买,不包括计算分钟数和存储包。
创建订阅附加购买(已弃用)
使用 POST 命令创建订阅附加购买。
POST /namespaces/:id/subscription_add_on_purchase/:add_on_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
quantity |
integer | yes | 订阅附加购买的单元数量(例如:代码建议附加购买的座位数) |
started_on |
date | yes | 订阅附加购买可用日期 |
expires_on |
date | yes | 订阅附加购买到期日期 |
purchase_xid |
string | yes | 订阅附加购买的标识符(例如:代码建议附加购买的订阅名称) |
trial |
boolean | no | 附加购买是否为试用 |
示例请求:
curl --request POST --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/namespaces/1234/subscription_add_on_purchase/code_suggestions?&quantity=10&started_on="2024-06-15"&expires_on="2024-07-15"&purchase_xid="C-00123456"&trial=true"示例响应:
{
"namespace_id":1234,
"namespace_name":"A Namespace Name",
"add_on":"Code Suggestions",
"quantity":10,
"started_on":"2024-06-15",
"expires_on":"2024-07-15",
"purchase_xid":"C-00123456",
"trial":true
}更新订阅附加购买(已弃用)
使用 PUT 命令更新现有订阅附加购买。
PUT /namespaces/:id/subscription_add_on_purchase/:add_on_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
quantity |
integer | no | 订阅附加购买的单元数量(例如:代码建议附加购买的座位数) |
started_on |
date | yes | 订阅附加购买可用日期 |
expires_on |
date | yes | 订阅附加购买到期日期 |
purchase_xid |
string | no | 订阅附加购买的标识符(例如:代码建议附加购买的订阅名称) |
trial |
boolean | no | 附加购买是否为试用 |
示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/namespaces/1234/subscription_add_on_purchase/code_suggestions?&quantity=15&started_on="2024-06-15"&expires_on="2024-07-15"&purchase_xid="C-00123456"&trial=true"示例响应:
{
"namespace_id":1234,
"namespace_name":"A Namespace Name",
"add_on":"Code Suggestions",
"quantity":15,
"started_on":"2024-06-15",
"expires_on":"2024-07-15",
"purchase_xid":"C-00123456",
"trial":true
}获取订阅附加购买(已弃用)
使用 GET 命令查看现有订阅附加购买。
GET /namespaces/:id/subscription_add_on_purchase/:add_on_name示例请求:
curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/namespaces/1234/subscription_add_on_purchase/code_suggestions"示例响应:
{
"namespace_id":1234,
"namespace_name":"A Namespace Name",
"add_on":"Code Suggestions",
"quantity":15,
"started_on":"2024-06-15",
"expires_on":"2024-07-15",
"purchase_xid":"C-00123456",
"trial":true
}计算配额预配(已弃用)
计算配额端点由 CustomersDot (customers.gitlab.com) 用于将额外的计算分钟包应用到 GitLab.com 上的个人命名空间或顶级群组。
创建额外包(已弃用)
使用 POST 命令创建额外包。
POST /namespaces/:id/minutes| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
packs |
array | yes | 已购买的计算包数组 |
packs[expires_at] |
date | yes | 已购买包的到期日期 |
packs[number_of_minutes] |
integer | yes | 额外计算分钟数 |
packs[purchase_xid] |
string | yes | 购买的唯一 ID |
示例请求:
curl --request POST \
--url "http://localhost:3000/api/v4/namespaces/123/minutes" \
--header 'Content-Type: application/json' \
--header 'X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>' \
--data '{
"packs": [
{
"number_of_minutes": 10000,
"expires_at": "2022-01-01",
"purchase_xid": "C-00123456"
}
]
}'示例响应:
[
{
"namespace_id": 123,
"expires_at": "2022-01-01",
"number_of_minutes": 10000,
"purchase_xid": "C-00123456"
}
]移动额外包(已弃用)
使用 PATCH 命令将额外包从一个命名空间移动到另一个命名空间。
PATCH /namespaces/:id/minutes/move/:target_id| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
string | yes | 要转移包的源命名空间 ID |
target_id |
string | yes | 要转移包的目标命名空间 ID |
示例请求:
curl --request PATCH \
--url "http://localhost:3000/api/v4/namespaces/123/minutes/move/321" \
--header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>"示例响应:
{
"message": "202 Accepted"
}订阅(已弃用)
订阅端点由 CustomersDot (customers.gitlab.com) 用于将订阅(包括试用)应用到 GitLab.com 上的个人命名空间或顶级群组。
创建订阅(已弃用)
使用 POST 命令创建订阅。
POST /namespaces/:id/gitlab_subscription| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
start_date |
date | yes | 订阅开始日期 |
end_date |
date | no | 订阅结束日期 |
plan_code |
string | no | 订阅层级代码 |
seats |
integer | no | 订阅中的座位数 |
max_seats_used |
integer | no | 上月活跃用户最高数量 |
auto_renew |
boolean | no | 订阅是否在到期日自动续费 |
trial |
boolean | no | 订阅是否为试用期 |
trial_starts_on |
date | no | 试用期开始日期 |
trial_ends_on |
date | no | 试用期结束日期 |
示例请求:
curl --request POST --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/namespaces/1234/gitlab_subscription?start_date="2020-07-15"&plan="premium"&seats=10"示例响应:
{
"plan": {
"code":"premium",
"name":"premium",
"trial":false,
"auto_renew":null,
"upgradable":false
},
"usage": {
"seats_in_subscription":10,
"seats_in_use":1,
"max_seats_used":0,
"seats_owed":0
},
"billing": {
"subscription_start_date":"2020-07-15",
"subscription_end_date":null,
"trial_ends_on":null
}
}更新订阅(已弃用)
使用 PUT 命令更新现有订阅。
PUT /namespaces/:id/gitlab_subscription| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
start_date |
date | no | 订阅开始日期 |
end_date |
date | no | 订阅结束日期 |
plan_code |
string | no | 订阅层级代码 |
seats |
integer | no | 订阅中的座位数 |
max_seats_used |
integer | no | 上月活跃用户最高数量 |
auto_renew |
boolean | no | 订阅是否在到期日自动续费 |
trial |
boolean | no | 订阅是否为试用期 |
trial_starts_on |
date | no | 试用期开始日期。如果试用为 true 则为必需。 |
trial_ends_on |
date | no | 试用期结束日期 |
示例请求:
curl --request PUT --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: <json-web-token>" "https://gitlab.com/api/v4/namespaces/1234/gitlab_subscription?max_seats_used=0"示例响应:
{
"plan": {
"code":"premium",
"name":"premium",
"trial":false,
"auto_renew":null,
"upgradable":false
},
"usage": {
"seats_in_subscription":80,
"seats_in_use":82,
"max_seats_used":0,
"seats_owed":2
},
"billing": {
"subscription_start_date":"2020-07-15",
"subscription_end_date":"2021-07-15",
"trial_ends_on":null
}
}获取订阅(已弃用)
使用 GET 命令查看现有订阅。
GET /namespaces/:id/gitlab_subscription示例请求:
curl --header "TOKEN: <admin_access_token>" "https://gitlab.com/api/v4/namespaces/1234/gitlab_subscription"示例响应:
{
"plan": {
"code":"premium",
"name":"premium",
"trial":false,
"auto_renew":null,
"upgradable":false,
"exclude_guests":false
},
"usage": {
"seats_in_subscription":80,
"seats_in_use":82,
"max_seats_used":82,
"seats_owed":2
},
"billing": {
"subscription_start_date":"2020-07-15",
"subscription_end_date":"2021-07-15",
"trial_ends_on":null
}
}