{ "swagger": "2.0", "info": { "title": "CNB OPENAPI", "contact": { "name": "Open API Support", "url": "https://docs.cnb.cool/", "email": "cnb@tencent.com" }, "version": "1.0" }, "paths": { "/workspace/delete": { "post": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Workspace" ], "summary": "删除我的云原生开发环境。Delete my workspace.", "operationId": "DeleteWorkspace", "parameters": [ { "description": "params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.WorkspaceDeleteReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.WorkspaceDeleteResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \naccount-engage:rw" } }, "/workspace/list": { "get": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Workspace" ], "summary": "获取我的云原生开发环境列表。List my workspaces.", "operationId": "ListWorkspaces", "parameters": [ { "type": "string", "description": "Git branch name, e.g. \"main\"", "name": "branch", "in": "query" }, { "type": "string", "description": "查询结束时间。Query end time. format YYYY-MM-DD HH:mm:ssZZ, e.g. 2024-12-01 00:00:00+0800", "name": "end", "in": "query" }, { "type": "integer", "description": "Pagination page number, default(1)", "name": "page", "in": "query" }, { "type": "integer", "description": "Pagination page size, default(20), max(100)", "name": "pageSize", "in": "query" }, { "type": "string", "description": "Repository path, e.g. \"groupname/reponame\"", "name": "slug", "in": "query" }, { "type": "string", "description": "查询开始时间。Query start time. format YYYY-MM-DD HH:mm:ssZZ, e.g. 2024-12-01 00:00:00+0800", "name": "start", "in": "query" }, { "type": "string", "description": "开发环境状态,running: 开发环境已启动,closed:开发环境已关闭。Workspace status: \"running\" for started, \"closed\" for stopped.", "name": "status", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.WorkspaceListResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \naccount-engage:r" } }, "/workspace/stop": { "post": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Workspace" ], "summary": "停止/关闭我的云原生开发环境。Stop/close my workspace.", "operationId": "WorkspaceStop", "parameters": [ { "description": "params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.WorkspaceStopReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.WorkspaceStopResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \naccount-engage:rw" } }, "/{repo}/-/workspace/detail/{sn}": { "get": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Workspace" ], "summary": "根据流水线sn查询云原生开发访问地址。Query cloud-native development access address by pipeline SN.", "operationId": "GetWorkspaceDetail", "parameters": [ { "type": "string", "description": "Repo path", "name": "repo", "in": "path", "required": true }, { "type": "string", "description": "SN", "name": "sn", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.WorkspaceDetailResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-detail:r" } }, "/{repo}/-/workspace/start": { "post": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Workspace" ], "summary": "启动云原生开发环境,已存在环境则直接打开,否则重新创建开发环境。Start cloud-native dev. Opens existing env or creates a new one.", "operationId": "StartWorkspace", "parameters": [ { "type": "string", "description": "仓库完整路径", "name": "repo", "in": "path", "required": true }, { "description": "StartWorkspace params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.StartWorkspaceReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.StartWorkspaceResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:rw" } } }, "definitions": { "dto.WorkspaceDeleteReq": { "type": "object", "properties": { "pipelineId": { "description": "表示要删除的开发环境流水线 id,sn 和 pipelineId 二选一,优先使用 pipelineId", "type": "string" }, "sn": { "description": "表示要删除的开发环境流水线构建号,sn 和 pipelineId 二选一,优先使用 pipelineId", "type": "string" } } }, "dto.WorkspaceDeleteResult": { "type": "object", "properties": { "code": { "description": "返回码,0 表示成功,1 表示失败", "type": "integer" }, "message": { "description": "描述", "type": "string" } } }, "dto.WorkspaceListResult": { "type": "object", "properties": { "hasMore": { "description": "是否有更多数据", "type": "boolean" }, "list": { "description": "云原生开发环境列表", "type": "array", "items": { "$ref": "#/definitions/dto.WorkspaceInfo" } }, "pageInfo": { "description": "分页信息", "allOf": [ { "$ref": "#/definitions/dto.WorkspacePageInfo" } ] }, "total": { "description": "总数", "type": "integer" } } }, "dto.WorkspaceStopReq": { "type": "object", "properties": { "pipelineId": { "description": "表示要停止的开发环境的流水线 id,sn 和 pipelineId 二选一,优先使用 pipelineId", "type": "string" }, "sn": { "description": "表示要停止的开发环境流水线构建号,sn 和 pipelineId 二选一,优先使用 pipelineId", "type": "string" } } }, "dto.WorkspaceStopResult": { "type": "object", "properties": { "buildLogUrl": { "description": "表示停止的开发环境流水线日志地址", "type": "string" }, "message": { "description": "表示操作结果提示信息", "type": "string" }, "sn": { "description": "表示停止的开发环境流水线构建号", "type": "string" } } }, "dto.WorkspaceDetailResult": { "type": "object", "properties": { "codebuddy": { "description": "CodeBuddy 国际版客户端 remote-ssh 访问 schema 地址", "type": "string" }, "codebuddycn": { "description": "CodeBuddy 国内版客户端 remote-ssh 访问 schema 地址", "type": "string" }, "cursor": { "description": "Cursor 客户端 remote-ssh 访问 schema 地址", "type": "string" }, "jetbrains": { "description": "jetbrains 系列 ide 的 jetbrains gateway 访问 schema 地址,环境内有安装 JetBrains 系列 ide 才会有", "type": "object", "additionalProperties": { "type": "string" } }, "jumpUrl": { "description": "选择入口页面 url", "type": "string" }, "remoteSsh": { "description": "remote-ssh 连接地址", "type": "string" }, "ssh": { "description": "ssh 登录命令", "type": "string" }, "vscode": { "description": "VSCode 客户端 remote-ssh 访问 schema 地址", "type": "string" }, "vscode-insiders": { "description": "Vscode 预览版客户端 remote-ssh 访问 schema 地址", "type": "string" }, "webide": { "description": "WebIDE 访问 url", "type": "string" } } }, "dto.StartWorkspaceReq": { "type": "object", "properties": { "branch": { "description": "分支名或 tag 名,例如:main 或 v1.0.0。", "type": "string" }, "ref": { "description": "Git ref,例如,refs/heads/main 或 refs/tags/v1.0.0。不传 ref 时默认基于分支启动", "type": "string" } } }, "dto.StartWorkspaceResult": { "type": "object", "properties": { "buildLogUrl": { "description": "仅新创建开发环境时返回,表示创建开发环境的流水线日志地址", "type": "string" }, "message": { "description": "仅新创建开发环境时返回,表示创建开发环境的提示信息", "type": "string" }, "sn": { "description": "仅新创建开发环境时返回,表示创建开发环境的流水线 sn", "type": "string" }, "url": { "description": "如果存在开发环境,则返回 WebIDE 访问 url;如果不存在开发环境,则返回启动云原生开发的 loading 页面 url 地址", "type": "string" } } } } }