更新 Git 仓库资源的 authorization_token。只能更新凭据;url、mount_path、checkout 不可修改。
前提
已完成 Endpoint 与鉴权配置,详见API 总览与认证。会话中已挂载 Git 仓库资源。
接口
POST /sessions/{session_id}/resources/{resource_id}
路径参数
session_id string(必选)
会话 ID,格式 sesn_<ULID>。
resource_id string(必选)
Git 仓库资源 ID,格式 sesrsc_<ULID>。
请求体
authorization_token string(必选)
新的访问令牌或密码,不能为空字符串。公开仓库可在创建会话时省略凭据;该接口只用于替换已有令牌。
接口只接受
authorization_token。携带 url、mount_path、checkout 等其他字段会返回 400 invalid_parameter。请求示例
curl
响应字段
id string
资源 ID,格式 sesrsc_<ULID>。
type string
固定为 git_repository。
url string
Git 仓库的 HTTPS 地址,不含凭据。
mount_path string
仓库在会话沙箱中的实际挂载路径。
checkout object / null
创建时指定的检出目标,包含 type 与 name(分支)或 sha(提交);省略时为 null。
created_at / updated_at string
资源创建与最近更新时间,ISO 8601。更新凭据后 updated_at 会变化。
request_id string
本次请求的唯一标识。
响应示例
错误码
| 状态码 | 错误码 | 说明 |
|---|---|---|
| 400 | invalid_parameter | authorization_token 为空或格式不合法,返回 Invalid authorization_token |
| 400 | invalid_parameter | 携带了不可更新字段,返回 Only authorization_token can be updated |
| 404 | not_found | 会话或资源不存在 |
| 401 | InvalidApiKey | API Key 无效 |