The API documentation for projects now is structured into major sections that describe the different aspects when dealing with projects, e.g. hooks, branches, team members etc. All described methods now contain a list of possible status codes the method can return. A few methods have extra sample JSON responses and a description if a method is idempotent. Idempotent methods can be called multiple times while returning the same status code.
7.6 KiB
Projects
List projects
Get a list of projects owned by the authenticated user.
GET /projects
[
{
"id": 3,
"name": "rails",
"description": null,
"default_branch": "master",
"owner": {
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"blocked": false,
"created_at": "2012-05-23T08:00:58Z"
},
"private": true,
"path": "rails",
"path_with_namespace": "rails/rails",
"issues_enabled": false,
"merge_requests_enabled": false,
"wall_enabled": true,
"wiki_enabled": true,
"created_at": "2012-05-23T08:05:02Z"
},
{
"id": 5,
"name": "gitlab",
"description": null,
"default_branch": "api",
"owner": {
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"blocked": false,
"created_at": "2012-05-23T08:00:58Z"
},
"private": true,
"path": "gitlab",
"path_with_namespace": "randx/gitlab",
"issues_enabled": true,
"merge_requests_enabled": true,
"wall_enabled": true,
"wiki_enabled": true,
"created_at": "2012-05-30T12:49:20Z"
}
]
Get single project
Get a specific project, identified by project ID, which is owned by the authentication user.
GET /projects/:id
Parameters:
id(required) - The ID of a project
{
"id": 5,
"name": "gitlab",
"description": null,
"default_branch": "api",
"owner": {
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"blocked": false,
"created_at": "2012-05-23T08:00:58Z"
},
"private": true,
"path": "gitlab",
"path_with_namespace": "randx/gitlab",
"issues_enabled": true,
"merge_requests_enabled": true,
"wall_enabled": true,
"wiki_enabled": true,
"created_at": "2012-05-30T12:49:20Z"
}
Return Values:
200 Okif the project with given ID is found and the JSON response404 Not Foundif no project with ID found
Create project
Creates new project owned by user.
POST /projects
Parameters:
name(required) - new project namedescription(optional) - short project descriptiondefault_branch(optional) - 'master' by defaultissues_enabled(optional) - enabled by defaultwall_enabled(optional) - enabled by defaultmerge_requests_enabled(optional) - enabled by defaultwiki_enabled(optional) - enabled by default
Return values:
201 Createdon success with the project data (see example atGET /projects/:id)400 Bad Requestif the required attribute name is not given403 Forbiddenif the user is not allowed to create a project, e.g. reached the project limit already404 Not Foundif something else fails
List project members
Get a list of project team members.
GET /projects/:id/members
Parameters:
id(required) - The ID of a projectquery- Query string
Return Values:
200 Okon success and a list of found team members404 Not Foundif project with ID not found
Team members
Get project team member
Get a project team member.
GET /projects/:id/members/:user_id
Parameters:
id(required) - The ID of a projectuser_id(required) - The ID of a user
{
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"blocked": false,
"created_at": "2012-05-23T08:00:58Z",
"access_level": 40
}
Return Values:
200 Okon success and the team member, see example404 Not Foundif either the project or the team member could not be found
Add project team member
Adds a user to a project team. This is an idempotent method and can be called multiple times with the same parameters. Adding team membership to a user that is already a member does not affect the membership.
POST /projects/:id/members
Parameters:
id(required) - The ID of a projectuser_id(required) - The ID of a user to addaccess_level(required) - Project access level
Return Values:
200 Okon success and the added user, even if the user is already team member400 Bad Requestif the required attribute access_level is not given404 Not Foundif a resource can not be found, e.g. project with ID not available422 Unprocessable Entityif an unknown access_level is given
Edit project team member
Update project team member to specified access level.
PUT /projects/:id/members/:user_id
Parameters:
id(required) - The ID of a projectuser_id(required) - The ID of a team memberaccess_level(required) - Project access level
Return Values:
200 Okon succes and the modified team member400 Bad Requestif the required attribute access_level is not given404 Not Foundif a resource can not be found, e.g. project with ID not available422 Unprocessable Entityif an unknown access_level is given
Remove project team member
Removes user from project team.
DELETE /projects/:id/members/:user_id
Parameters:
id(required) - The ID of a projectuser_id(required) - The ID of a team member
Return Values:
200 Okon success404 Not Foundif either project or user can not be found
This method is idempotent and can be called multiple times with the same parameters. Revoking team membership for a user who is not currently a team member is considered success. Please note that the returned JSON currently differs slightly. Thus you should not rely on the returned JSON structure.
Hooks
List project hooks
Get list of project hooks.
GET /projects/:id/hooks
Parameters:
id(required) - The ID of a project
Return values:
200 Okon success with a list of hooks404 Not Foundif project can not be found
Get project hook
Get a specific hook for project.
GET /projects/:id/hooks/:hook_id
Parameters:
id(required) - The ID of a projecthook_id(required) - The ID of a project hook
{
"id": 1,
"url": "http://example.com/hook",
"created_at": "2012-10-12T17:04:47Z"
}
Return values:
200 Okon sucess and the hook with the given ID404 Not Foundif the hook can not be found
Add project hook
Adds a hook to project.
POST /projects/:id/hooks
Parameters:
id(required) - The ID of a projecturl(required) - The hook URL
Return values:
201 Createdon success and the newly created hook400 Bad Requestif url is not given404 Not Foundif project with ID not found422 Unprocessable Entityif the url is invalid (must begin withhttporhttps)
Edit project hook
Edits a hook for project.
PUT /projects/:id/hooks/:hook_id
Parameters:
id(required) - The ID of a projecthook_id(required) - The ID of a project hookurl(required) - The hook URL
Return values:
200 Okon success and the modified hook (see JSON response above)400 Bad Requestif the url attribute is not given404 Not Foundif project or hook can not be found422 Unprocessable Entityif the url is invalid (must begin withhttporhttps)
Delete project hook
Removes a hook from project. This is an idempotent method and can be called multiple times. Either the hook is available or not.
DELETE /projects/:id/hooks
Parameters:
id(required) - The ID of a projecthook_id(required) - The ID of hook to delete
Return values:
200 Okon succes404 Not Foundif the project can not be found
Note the JSON response differs if the hook is available or not. If the project hook is available before it is returned in the JSON response or an empty response is returned.