{ "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}/-/settings/branch-protections": { "get": { "security": [ { "BearerAuth": [] } ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "查询仓库保护分支规则列表。List branch protection rules.", "operationId": "ListBranchProtections", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { "$ref": "#/definitions/api.BranchProtection" } } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:r" }, "post": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "新增仓库保护分支规则。Create branch protection rule.", "operationId": "PostBranchProtection", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "description": "Branch Protection Form", "name": "branch_protection_form", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.BranchProtection" } } ], "responses": { "201": { "description": "Created" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" } }, "/{repo}/-/settings/branch-protections/{id}": { "get": { "security": [ { "BearerAuth": [] } ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "查询仓库保护分支规则。Get branch protection rule.", "operationId": "GetBranchProtection", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "type": "string", "description": "保护分支规则唯一标识符。", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.BranchProtection" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:r" }, "delete": { "security": [ { "BearerAuth": [] } ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "删除仓库保护分支规则。 Delete branch protection rule.", "operationId": "DeleteBranchProtection", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "type": "string", "description": "保护分支规则唯一标识符。", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" }, "patch": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "更新仓库保护分支规则。Update branch protection rule.", "operationId": "PatchBranchProtection", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "type": "string", "description": "保护分支规则唯一标识符。", "name": "id", "in": "path", "required": true }, { "description": "Branch Protection Form", "name": "branch_protection_form", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.BranchProtection" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" } }, "/{repo}/-/settings/cloud-native-build": { "get": { "security": [ { "BearerAuth": [] } ], "produces": [], "tags": [ "GitSettings" ], "summary": "查询仓库云原生构建设置。List pipeline settings.", "operationId": "GetPipelineSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.PipelineSettings" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:r" }, "put": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "更新仓库云原生构建设置。Update pipeline settings.", "operationId": "PutPipelineSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "description": "Cloud Native Build Form", "name": "pipeline_form", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.PipelineSettings" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" } }, "/{repo}/-/settings/pull-request": { "get": { "security": [ { "BearerAuth": [] } ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "查询仓库合并请求设置。List pull request settings.", "operationId": "GetPullRequestSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.PullRequestSettings" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:r" }, "put": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "更新仓库合并请求设置。Set pull request settings.", "operationId": "PutPullRequestSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "description": "Pull Request Form", "name": "pull_request_form", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.PullRequestSettings" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" } }, "/{repo}/-/settings/push-limit": { "get": { "security": [ { "BearerAuth": [] } ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "查询仓库推送设置。List push limit settings.", "operationId": "GetPushLimitSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.PushLimitSettings" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:r" }, "put": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "GitSettings" ], "summary": "设置仓库推送设置。Set push limit settings.", "operationId": "PutPushLimitSettings", "parameters": [ { "type": "string", "description": "不带.git后缀的仓库名称。格式:`组织名称/仓库名称`", "name": "repo", "in": "path", "required": true }, { "description": "Push Limit Form", "name": "push_limit_form", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.PushLimitSettings" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/die.WebError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/die.WebError" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-manage:rw" } } }, "definitions": { "api.BranchProtection": { "type": "object", "properties": { "allow_creation": { "description": "是否允许所有人创建保护分支。", "type": "boolean" }, "allow_deletions": { "description": "是否允许所有人删除保护分支。", "type": "boolean" }, "allow_force_pushes": { "description": "是否允许所有人强制推送。", "type": "boolean" }, "allow_master_creation": { "description": "是否仅允许仓库管理员及负责人创建保护分支。", "type": "boolean" }, "allow_master_deletions": { "description": "是否仅允许仓库管理员及负责人删除保护分支。", "type": "boolean" }, "allow_master_force_pushes": { "description": "是否仅允许仓库管理员及负责人强制推送。", "type": "boolean" }, "allow_master_manual_merge": { "description": "是否允许仓库管理员及负责人手动合并到目标分支。", "type": "boolean" }, "allow_master_pushes": { "description": "是否仅允许仓库管理员及负责人推送代码到保护分支中。", "type": "boolean" }, "allow_pushes": { "description": "是否允许所有人推送代码到保护分支中。", "type": "boolean" }, "id": { "description": "保护分支规则唯一标识符。", "type": "string" }, "required_approved_review_count": { "description": "需要的代码评审者数量。格式:`评审者数量 ∈ [1,5]`", "type": "integer" }, "required_approved_review_ratio": { "description": "需要的评审通过率。格式:`通过率 ∈ [1, 100]`", "type": "integer" }, "required_linear_history": { "description": "是否仅允许线性提交。", "type": "boolean" }, "required_master_approve": { "description": "是否需至少一个仓库管理员批准。", "type": "boolean" }, "required_must_auto_merge": { "description": "是否仅允许自动合并。", "type": "boolean" }, "required_must_push_via_pull_request": { "description": "是否必须通过合并请求推送代码到此规则匹配分支中。", "type": "boolean" }, "required_pull_request_reviews": { "description": "保护分支的合并请求是否需要代码评审。", "type": "boolean" }, "required_status_checks": { "description": "是否需要通过状态检查。", "type": "boolean" }, "rule": { "description": "保护分支规则名称,支持通配符。", "type": "string" } } }, "die.WebError": { "type": "object", "properties": { "errcode": { "type": "integer" }, "errmsg": { "type": "string" }, "errparam": { "type": "object", "additionalProperties": {} } } }, "api.PipelineSettings": { "type": "object", "properties": { "auto_trigger": { "description": "是否允许仓库按照.cnb.yml配置自动触发云原生构建。", "type": "boolean" }, "forked_repo_auto_trigger": { "description": "是否允许本仓Fork出来的仓库按照.cnb.yml配置自动触发云原生构建。", "type": "boolean" } } }, "api.PullRequestSettings": { "type": "object", "properties": { "allow_merge_commit_merge": { "description": "是否允许直接提交合并。", "type": "boolean" }, "allow_rebase_merge": { "description": "是否允许变基合并。", "type": "boolean" }, "allow_squash_merge": { "description": "是否允许压缩合并。", "type": "boolean" }, "master_auto_as_reviewer": { "description": "是否允许自动添加仓库管理员为评审者。", "type": "boolean" }, "merge_commit_message_style": { "description": "直接提交合并操作时默认生成的提交信息内容。可选值:`default`,`pull_request_title`,`pull_request_title_with_body`", "type": "string" }, "squash_commit_message_style": { "description": "压缩合并操作时默认生成的提交信息内容。可选值:`default`,`pull_request_title`,`pull_request_title_with_body`", "type": "string" } } }, "api.PushLimitSettings": { "type": "object", "properties": { "allow_single_push_number": { "description": "允许单次推送最多允许更新分支和标签的个数数量。", "type": "integer" }, "check_single_push_number": { "description": "是否开启单次更新分支和标签的个数限制。", "type": "boolean" }, "only_master_can_push_tag": { "description": "是否仅允许负责人和管理员推送或删除标签、创建或删除版本。", "type": "boolean" }, "push_commit_must_be": { "description": "推送提交到仓库,对提交作者和提交人进行检查。可选值:`any`,`registered`,`pusher`", "type": "string" } } } } }