模型仓库
列表和详情会确保当前租户默认仓库存在,并可能初始化工作空间。
limitBytes >= -1;-1 表示不限。新容量不能低于 usedBytes + reservedBytes,否则返回 409 capacity_too_small。容量修改还要求仓库容量管理权限及 Harbor 管理服务可用。
| 方法 | 路径(产品接口统一前缀 /api/v1) | 功能 |
|---|---|---|
| GET | /model-repositories | 查询模型仓库 |
| GET | /model-repositories/{id} | 获取模型仓库详情 |
| GET | /model-repositories/{id}/capacity | 查询仓库容量 |
| PUT | /model-repositories/{id}/capacity | 设置仓库容量 |
查询模型仓库
功能介绍
查询模型仓库。
访问要求:有效 Token;需要对应资源读权限,并受项目、所有者、公共或共享资源规则限制。
URI
GET /api/v1/model-repositories
查询参数
| 参数 | 类型 | 必选 | 描述 |
|---|---|---|---|
| page | integer | 否 | 页码,从 1 开始 |
| page_size | integer | 否 | 每页数量;建议显式传入,例如 20;省略时部分列表返回全部 |
请求消息
无请求体。
响应消息
| 参数 | 参数类型 | 描述 |
|---|---|---|
| items | array<modelrepository.Response> | 结果列表 |
| total | integer | 匹配总数 |
| page | integer | 页码,从 1 开始 |
| page_size | integer | 每页数量 |
请求示例
GET https://{endpoint}/api/v1/model-repositories?page=1&page_size=20
x-keystone-token: <Keystone Token>
正常响应示例
HTTP/1.1 200
Content-Type: application/json
{
"items": [
{
"id": "id-example",
"name": "示例资源",
"description": "",
"status": "ready",
"projectId": "projectId-example",
"ownerUserId": "ownerUserId-example",
"backend": {
"catalog": "",
"type": "",
"id": "id-example"
},
"summary": {},
"createdAt": "2026-09-21T00:00:00Z",
"updatedAt": "2026-09-21T00:00:00Z"
}
],
"total": 1,
"page": 1,
"page_size": 1
}
状态码与错误码
成功状态码:200。
| HTTP | error | 说明 |
|---|---|---|
| 500 | internal_error | failed to initialize public model repository |
| 401 | unauthorized | authentication required |
此外,认证/授权中间件可返回 401 / 403;后端错误与错误封装见调用方式。
获取模型仓库详情
功能介绍
获取模型仓库详情。
访问要求:有效 Token;需要对应资源读权限,并受项目、所有者、公共或共享资源规则限制。
URI
GET /api/v1/model-repositories/{id}
| 参数 | 类型 | 必选 | 描述 |
|---|---|---|---|
| id | string | 是 | 目标资源 ID |
请求消息
无请求体。
响应消息
| 参数 | 参数类型 | 描述 |
|---|---|---|
| id | string | 资源唯一标识 |
| name | string | 显示名称 |
| description | string | 描述 |
| status | string | 资源状态;具体取值见业务规则 |
| projectId | string | 所属项目 ID |
| ownerUserId | string | 创建者用户 ID |
| ownerName | string | 创建者名称;空值时可能省略 |
| labels | map<string, string> | 标签键值对;空值时可能省略 |
| backend | modelrepository.backendRef | 后端资源标识 |
| summary | modelrepository.Summary | 摘要信息 |
| createdAt | string(date-time) | 创建时间,RFC3339 |
| updatedAt | string(date-time) | 更新时间,RFC3339 |
请求示例
GET https://{endpoint}/api/v1/model-repositories/resource-id
x-keystone-token: <Keystone Token>
正常响应示例
HTTP/1.1 200
Content-Type: application/json
{
"id": "id-example",
"name": "示例资源",
"description": "",
"status": "ready",
"projectId": "projectId-example",
"ownerUserId": "ownerUserId-example",
"backend": {
"catalog": "",
"type": "",
"id": "id-example"
},
"summary": {},
"createdAt": "2026-09-21T00:00:00Z",
"updatedAt": "2026-09-21T00:00:00Z"
}
状态码与错误码
成功状态码:200。
| HTTP | error | 说明 |
|---|---|---|
| 500 | internal_error | failed to initialize public model repository |
| 401 | unauthorized | authentication required |
| 404 | not_found | model repository not found |
| 503 | backend_unavailable | harbor admin client is not configured |
| 502 | workspace_unavailable | failed to initialize workspace |
此外,认证/授权中间件可返回 401 / 403;后端错误与错误封装见调用方式。
查询仓库容量
功能介绍
查询仓库容量。
访问要求:有效 Token;需要对应资源读权限,并受项目、所有者、公共或共享资源规则限制。
URI
GET /api/v1/model-repositories/{id}/capacity
| 参数 | 类型 | 必选 | 描述 |
|---|---|---|---|
| id | string | 是 | 目标资源 ID |
请求消息
无请求体。
响应消息
| 参数 | 参数类型 | 描述 |
|---|---|---|
| usedBytes | int64 | 已使用容量,字节 |
| reservedBytes | int64 | 预留容量,字节 |
| limitBytes | int64 | 容量上限,字节;-1 表示不限 |
请求示例
GET https://{endpoint}/api/v1/model-repositories/resource-id/capacity
x-keystone-token: <Keystone Token>
正常响应示例
HTTP/1.1 200
Content-Type: application/json
{
"usedBytes": 0,
"reservedBytes": 0,
"limitBytes": 0
}
状态码与错误码
成功状态码:200。
| HTTP | error | 说明 |
|---|---|---|
| 401 | unauthorized | authentication required |
| 404 | not_found | model repository not found |
| 500 | internal_error | failed to get model repository |
| 503 | backend_unavailable | harbor admin client is not configured |
| 502 | backend_unavailable | failed to query repository capacity |
此外,认证/授权中间件可返回 401 / 403;后端错误与错误封装见调用方式。
设置仓库容量
功能介绍
设置仓库容量。
访问要求:有效 Token;需要对应资源写权限,并受项目、所有者、公共或共享资源规则限制。
URI
PUT /api/v1/model-repositories/{id}/capacity
| 参数 | 类型 | 必选 | 描述 |
|---|---|---|---|
| id | string | 是 | 目标资源 ID |
请求消息
Content-Type: application/json。
| 参数 | 参数类型 | 是否必选 | 描述 |
|---|---|---|---|
| limitBytes | int64 | 否 | 容量上限,字节;-1 表示不限 |
limitBytes >= -1;-1 表示不限。新容量不能低于 usedBytes + reservedBytes,否则返回 409 capacity_too_small。容量修改还要求仓库容量管理权限及 Harbor 管理服务可用。
响应消息
| 参数 | 参数类型 | 描述 |
|---|---|---|
| usedBytes | int64 | 已使用容量,字节 |
| reservedBytes | int64 | 预留容量,字节 |
| limitBytes | int64 | 容量上限,字节;-1 表示不限 |
请求示例
PUT https://{endpoint}/api/v1/model-repositories/resource-id/capacity
x-keystone-token: <Keystone Token>
Content-Type: application/json
{
"limitBytes": 107374182400
}
正常响应示例
HTTP/1.1 200
Content-Type: application/json
{
"usedBytes": 0,
"reservedBytes": 0,
"limitBytes": 0
}
状态码与错误码
成功状态码:200。
| HTTP | error | 说明 |
|---|---|---|
| 400 | invalid_request | limitBytes must be greater than or equal to -1 |
| 403 | forbidden | repository capacity permission required |
| 409 | capacity_too_small | capacity cannot be lower than current usage and task reservations |
| 503 | backend_unavailable | harbor admin client is not configured |
| 502 | backend_unavailable | failed to update repository capacity |
| 401 | unauthorized | authentication required |
| 404 | not_found | model repository not found |
| 500 | internal_error | failed to get model repository |
此外,认证/授权中间件可返回 401 / 403;后端错误与错误封装见调用方式。