mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Add API to query collaborators permission for a repository (#18761)
Targeting #14936, #15332 Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository. ### Checks the repository permissions of a collaborator. `GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission` Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`. ```json { "permission": "admin", "role_name": "admin", "user": {} } ``` Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							e5c6c001c5
						
					
				
				
					commit
					ad6d08d155
				
			@@ -3129,6 +3129,52 @@
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "/repos/{owner}/{repo}/collaborators/{collaborator}/permission": {
 | 
			
		||||
      "get": {
 | 
			
		||||
        "produces": [
 | 
			
		||||
          "application/json"
 | 
			
		||||
        ],
 | 
			
		||||
        "tags": [
 | 
			
		||||
          "repository"
 | 
			
		||||
        ],
 | 
			
		||||
        "summary": "Get repository permissions for a user",
 | 
			
		||||
        "operationId": "repoGetRepoPermissions",
 | 
			
		||||
        "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": "username of the collaborator",
 | 
			
		||||
            "name": "collaborator",
 | 
			
		||||
            "in": "path",
 | 
			
		||||
            "required": true
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "responses": {
 | 
			
		||||
          "200": {
 | 
			
		||||
            "$ref": "#/responses/RepoCollaboratorPermission"
 | 
			
		||||
          },
 | 
			
		||||
          "403": {
 | 
			
		||||
            "$ref": "#/responses/forbidden"
 | 
			
		||||
          },
 | 
			
		||||
          "404": {
 | 
			
		||||
            "$ref": "#/responses/notFound"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "/repos/{owner}/{repo}/commits": {
 | 
			
		||||
      "get": {
 | 
			
		||||
        "produces": [
 | 
			
		||||
@@ -17451,6 +17497,24 @@
 | 
			
		||||
      },
 | 
			
		||||
      "x-go-package": "code.gitea.io/gitea/modules/structs"
 | 
			
		||||
    },
 | 
			
		||||
    "RepoCollaboratorPermission": {
 | 
			
		||||
      "description": "RepoCollaboratorPermission to get repository permission for a collaborator",
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "permission": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "x-go-name": "Permission"
 | 
			
		||||
        },
 | 
			
		||||
        "role_name": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "x-go-name": "RoleName"
 | 
			
		||||
        },
 | 
			
		||||
        "user": {
 | 
			
		||||
          "$ref": "#/definitions/User"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "x-go-package": "code.gitea.io/gitea/modules/structs"
 | 
			
		||||
    },
 | 
			
		||||
    "RepoCommit": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "title": "RepoCommit contains information of a commit in the context of a repository.",
 | 
			
		||||
@@ -19126,6 +19190,12 @@
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "RepoCollaboratorPermission": {
 | 
			
		||||
      "description": "RepoCollaboratorPermission",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "$ref": "#/definitions/RepoCollaboratorPermission"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "Repository": {
 | 
			
		||||
      "description": "Repository",
 | 
			
		||||
      "schema": {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user