Files
cnb/docs/api-groups/badge/api.json
2026-01-16 13:03:57 +08:00

265 lines
7.0 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"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": {
"/{repo}/-/badge/git/{sha}/{badge}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Badge"
],
"summary": "获取徽章 svg 或 JSON 数据。Get badge svg or JSON data.",
"operationId": "GetBadge",
"parameters": [
{
"type": "string",
"description": "仓库完整路径",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "latest 或 commit 8 位短 hash例如 89d48c07",
"name": "sha",
"in": "path",
"required": true
},
{
"type": "string",
"description": "徽章名,例如 pr 事件徽章名为ci/status/pull_request, 如需获取 JSON 数据,可加上 .json 后缀ci/status/pull_request.json",
"name": "badge",
"in": "path",
"required": true
},
{
"description": "GetBadge params",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.GetBadgeReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.GetBadgeResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:r"
}
},
"/{repo}/-/badge/list": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Badge"
],
"summary": "获取徽章列表数据。List badge data",
"operationId": "ListBadge",
"parameters": [
{
"type": "string",
"description": "仓库完整路径",
"name": "repo",
"in": "path",
"required": true
},
{
"description": "ListBadge params",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.ListBadgeReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.ListBadgeResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:r"
}
},
"/{repo}/-/badge/upload": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Badge"
],
"summary": "上传徽章数据。Upload badge data",
"operationId": "UploadBadge",
"parameters": [
{
"type": "string",
"description": "仓库完整路径",
"name": "repo",
"in": "path",
"required": true
},
{
"description": "UploadBadge params",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UploadBadgeReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.UploadBadgeResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:rw"
}
}
},
"definitions": {
"dto.GetBadgeReq": {
"type": "object",
"properties": {
"branch": {
"description": "分支名例如main。不传则为默认分支获取默认分支最新徽章。传了分支名则获取该分支最新提交记录对应的徽章。",
"type": "string"
}
}
},
"dto.GetBadgeResult": {
"type": "object",
"properties": {
"color": {
"description": "徽章颜色",
"type": "string"
},
"label": {
"description": "徽章左侧显示内容",
"type": "string"
},
"link": {
"description": "徽章链接",
"type": "string"
},
"links": {
"description": "徽章链接列表",
"type": "array",
"items": {
"type": "string"
}
},
"message": {
"description": "徽章右侧显示内容",
"type": "string"
}
}
},
"dto.ListBadgeReq": {
"type": "object"
},
"dto.ListBadgeResult": {
"type": "object",
"properties": {
"badges": {
"description": "徽章列表",
"type": "array",
"items": {
"$ref": "#/definitions/dto.Badge"
}
}
}
},
"dto.UploadBadgeReq": {
"type": "object",
"properties": {
"key": {
"description": "徽章 key。目前允许上传的 key 包括security/tca",
"type": "string"
},
"latest": {
"description": "是否上传 latest 徽章。默认为 false不上传 latest仅上传 commitid 对应的徽章true上传 latest 和 commitid 对应的徽章",
"type": "boolean"
},
"link": {
"description": "点击徽章右侧的跳转链接",
"type": "string"
},
"message": {
"description": "徽章右侧显示内容",
"type": "string"
},
"sha": {
"description": "commit id",
"type": "string"
},
"value": {
"description": "徽章数值,不传默认用 message 代替",
"type": "integer"
}
}
},
"dto.UploadBadgeResult": {
"type": "object",
"properties": {
"latest_url": {
"description": "latest 对应的徽章 url 地址。如果没有传 latest: true则该字段为空字符串",
"type": "string"
},
"url": {
"description": "commitid 对应的徽章 url 地址",
"type": "string"
}
}
}
}
}