summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2020-02-13 00:19:35 +0100
committerGitHub <noreply@github.com>2020-02-12 23:19:35 +0000
commit9ff4e1d2d9636ea8aa328427f1d31c962221263e (patch)
treeb0df096e3885a6f05c26959f784cca0ce6a9763c /templates
parent908f8952be3ba7a4e4c32b0fd0dab5eb08ca8dd4 (diff)
downloadgitea-9ff4e1d2d9636ea8aa328427f1d31c962221263e.tar.gz
gitea-9ff4e1d2d9636ea8aa328427f1d31c962221263e.zip
Add API branch protection endpoint (#9311)
* add API branch protection endpoint * lint * Change to use team names instead of ids. * Status codes. * fix * Fix * Add new branch protection options (BlockOnRejectedReviews, DismissStaleApprovals, RequireSignedCommits) * Do xorm query directly * fix xorm GetUserNamesByIDs * Add some tests * Improved GetTeamNamesByID * http status created for CreateBranchProtection * Correct status code in integration test Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'templates')
-rw-r--r--templates/swagger/v1_json.tmpl551
1 files changed, 550 insertions, 1 deletions
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index e6a5189928..b52145a0a9 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -1797,6 +1797,227 @@
}
}
},
+ "/repos/{owner}/{repo}/branch_protections": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "List branch protections for a repository",
+ "operationId": "repoListBranchProtection",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "$ref": "#/responses/BranchProtectionList"
+ }
+ }
+ },
+ "post": {
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Create a branch protections for a repository",
+ "operationId": "repoCreateBranchProtection",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "name": "body",
+ "in": "body",
+ "schema": {
+ "$ref": "#/definitions/CreateBranchProtectionOption"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "$ref": "#/responses/BranchProtection"
+ },
+ "403": {
+ "$ref": "#/responses/forbidden"
+ },
+ "404": {
+ "$ref": "#/responses/notFound"
+ },
+ "422": {
+ "$ref": "#/responses/validationError"
+ }
+ }
+ }
+ },
+ "/repos/{owner}/{repo}/branch_protections/{name}": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Get a specific branch protection for the repository",
+ "operationId": "repoGetBranchProtection",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of protected branch",
+ "name": "name",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "$ref": "#/responses/BranchProtection"
+ },
+ "404": {
+ "$ref": "#/responses/notFound"
+ }
+ }
+ },
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Delete a specific branch protection for the repository",
+ "operationId": "repoDeleteBranchProtection",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of protected branch",
+ "name": "name",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "$ref": "#/responses/empty"
+ },
+ "404": {
+ "$ref": "#/responses/notFound"
+ }
+ }
+ },
+ "patch": {
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Edit a branch protections for a repository. Only fields that are set will be changed",
+ "operationId": "repoEditBranchProtection",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of protected branch",
+ "name": "name",
+ "in": "path",
+ "required": true
+ },
+ {
+ "name": "body",
+ "in": "body",
+ "schema": {
+ "$ref": "#/definitions/EditBranchProtectionOption"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "$ref": "#/responses/BranchProtection"
+ },
+ "404": {
+ "$ref": "#/responses/notFound"
+ },
+ "422": {
+ "$ref": "#/responses/validationError"
+ }
+ }
+ }
+ },
"/repos/{owner}/{repo}/branches": {
"get": {
"produces": [
@@ -9394,6 +9615,10 @@
"commit": {
"$ref": "#/definitions/PayloadCommit"
},
+ "effective_branch_protection_name": {
+ "type": "string",
+ "x-go-name": "EffectiveBranchProtectionName"
+ },
"enable_status_check": {
"type": "boolean",
"x-go-name": "EnableStatusCheck"
@@ -9429,6 +9654,117 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
+ "BranchProtection": {
+ "description": "BranchProtection represents a branch protection for a repository",
+ "type": "object",
+ "properties": {
+ "approvals_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistTeams"
+ },
+ "approvals_whitelist_username": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistUsernames"
+ },
+ "block_on_rejected_reviews": {
+ "type": "boolean",
+ "x-go-name": "BlockOnRejectedReviews"
+ },
+ "branch_name": {
+ "type": "string",
+ "x-go-name": "BranchName"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time",
+ "x-go-name": "Created"
+ },
+ "dismiss_stale_approvals": {
+ "type": "boolean",
+ "x-go-name": "DismissStaleApprovals"
+ },
+ "enable_approvals_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableApprovalsWhitelist"
+ },
+ "enable_merge_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableMergeWhitelist"
+ },
+ "enable_push": {
+ "type": "boolean",
+ "x-go-name": "EnablePush"
+ },
+ "enable_push_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnablePushWhitelist"
+ },
+ "enable_status_check": {
+ "type": "boolean",
+ "x-go-name": "EnableStatusCheck"
+ },
+ "merge_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistTeams"
+ },
+ "merge_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistUsernames"
+ },
+ "push_whitelist_deploy_keys": {
+ "type": "boolean",
+ "x-go-name": "PushWhitelistDeployKeys"
+ },
+ "push_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistTeams"
+ },
+ "push_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistUsernames"
+ },
+ "require_signed_commits": {
+ "type": "boolean",
+ "x-go-name": "RequireSignedCommits"
+ },
+ "required_approvals": {
+ "type": "integer",
+ "format": "int64",
+ "x-go-name": "RequiredApprovals"
+ },
+ "status_check_contexts": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "StatusCheckContexts"
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "x-go-name": "Updated"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"Comment": {
"description": "Comment represents a comment on a commit or issue",
"type": "object",
@@ -9634,6 +9970,107 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
+ "CreateBranchProtectionOption": {
+ "description": "CreateBranchProtectionOption options for creating a branch protection",
+ "type": "object",
+ "properties": {
+ "approvals_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistTeams"
+ },
+ "approvals_whitelist_username": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistUsernames"
+ },
+ "block_on_rejected_reviews": {
+ "type": "boolean",
+ "x-go-name": "BlockOnRejectedReviews"
+ },
+ "branch_name": {
+ "type": "string",
+ "x-go-name": "BranchName"
+ },
+ "dismiss_stale_approvals": {
+ "type": "boolean",
+ "x-go-name": "DismissStaleApprovals"
+ },
+ "enable_approvals_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableApprovalsWhitelist"
+ },
+ "enable_merge_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableMergeWhitelist"
+ },
+ "enable_push": {
+ "type": "boolean",
+ "x-go-name": "EnablePush"
+ },
+ "enable_push_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnablePushWhitelist"
+ },
+ "enable_status_check": {
+ "type": "boolean",
+ "x-go-name": "EnableStatusCheck"
+ },
+ "merge_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistTeams"
+ },
+ "merge_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistUsernames"
+ },
+ "push_whitelist_deploy_keys": {
+ "type": "boolean",
+ "x-go-name": "PushWhitelistDeployKeys"
+ },
+ "push_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistTeams"
+ },
+ "push_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistUsernames"
+ },
+ "require_signed_commits": {
+ "type": "boolean",
+ "x-go-name": "RequireSignedCommits"
+ },
+ "required_approvals": {
+ "type": "integer",
+ "format": "int64",
+ "x-go-name": "RequiredApprovals"
+ },
+ "status_check_contexts": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "StatusCheckContexts"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"CreateEmailOption": {
"description": "CreateEmailOption options when creating email addresses",
"type": "object",
@@ -10318,6 +10755,103 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
+ "EditBranchProtectionOption": {
+ "description": "EditBranchProtectionOption options for editing a branch protection",
+ "type": "object",
+ "properties": {
+ "approvals_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistTeams"
+ },
+ "approvals_whitelist_username": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "ApprovalsWhitelistUsernames"
+ },
+ "block_on_rejected_reviews": {
+ "type": "boolean",
+ "x-go-name": "BlockOnRejectedReviews"
+ },
+ "dismiss_stale_approvals": {
+ "type": "boolean",
+ "x-go-name": "DismissStaleApprovals"
+ },
+ "enable_approvals_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableApprovalsWhitelist"
+ },
+ "enable_merge_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnableMergeWhitelist"
+ },
+ "enable_push": {
+ "type": "boolean",
+ "x-go-name": "EnablePush"
+ },
+ "enable_push_whitelist": {
+ "type": "boolean",
+ "x-go-name": "EnablePushWhitelist"
+ },
+ "enable_status_check": {
+ "type": "boolean",
+ "x-go-name": "EnableStatusCheck"
+ },
+ "merge_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistTeams"
+ },
+ "merge_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "MergeWhitelistUsernames"
+ },
+ "push_whitelist_deploy_keys": {
+ "type": "boolean",
+ "x-go-name": "PushWhitelistDeployKeys"
+ },
+ "push_whitelist_teams": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistTeams"
+ },
+ "push_whitelist_usernames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "PushWhitelistUsernames"
+ },
+ "require_signed_commits": {
+ "type": "boolean",
+ "x-go-name": "RequireSignedCommits"
+ },
+ "required_approvals": {
+ "type": "integer",
+ "format": "int64",
+ "x-go-name": "RequiredApprovals"
+ },
+ "status_check_contexts": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "StatusCheckContexts"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"EditDeadlineOption": {
"description": "EditDeadlineOption options for creating a deadline",
"type": "object",
@@ -12880,6 +13414,21 @@
}
}
},
+ "BranchProtection": {
+ "description": "BranchProtection",
+ "schema": {
+ "$ref": "#/definitions/BranchProtection"
+ }
+ },
+ "BranchProtectionList": {
+ "description": "BranchProtectionList",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/BranchProtection"
+ }
+ }
+ },
"Comment": {
"description": "Comment",
"schema": {
@@ -13410,7 +13959,7 @@
"parameterBodies": {
"description": "parameterBodies",
"schema": {
- "$ref": "#/definitions/EditReactionOption"
+ "$ref": "#/definitions/EditBranchProtectionOption"
}
},
"redirect": {