GitLab wurde erfolgreich aktualisiert. Durch regelmäßige Updates bleibt das THM GitLab sicher. Danke für Ihre Geduld.

Commit 39114d25 authored by Sebastian Ziebell's avatar Sebastian Ziebell

API: documentation contains infos to status codes in README file.

All the info to return codes from the API functions are available in the `README.md` file as suggested.
parent b5ef6d22
......@@ -27,6 +27,42 @@ curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" "http://example.com/api/v3/p
The API uses JSON to serialize data. You don't need to specify `.json` at the end of API URL.
## Status codes
API requests return different status codes according to
The API is designed to provide status codes according to the context and how the request
is handled. For example if a `GET` request is successful a status code `200 Ok`
is returned. The API is designed to be RESTful.
The following list gives an overview of how the API functions are designed.
API request types:
* `GET` requests access one or more resources and return the result as JSON
* `POST` requests return `201 Created` if the resource is successfully created and return the newly created resource as JSON
* `GET`, `PUT` and `DELETE` return `200 Ok` if the resource is accessed, modified or deleted successfully, the (modified) result is returned as JSON
* `DELETE` requests are designed to be idempotent, meaning a request a resource still returns `200 Ok` even it was deleted before or is not available. The reasoning behind it is the user is not really interested if the resource existed before or not.
The following list shows the possible return codes for API requests.
Return values:
* `200 Ok` - The `GET`, `PUT` or `DELETE` request was successful, the resource(s) itself is returned as JSON
* `201 Created` - The `POST` request was successful and the resource is returned as JSON
* `400 Bad Request` - A required attribute of the API request is missing, e.g. the title of an issue is not given
* `401 Unauthorized` - The user is not authenticated, a valid user token is necessary, see above
* `403 Forbidden` - The request is not allowed, e.g. the user is not allowed to delete a project
* `404 Not Found` - A resource could not be accessed, e.g. an ID for a resource could not be found
* `405 Method Not Allowed` - The request is not supported
* `409 Conflict` - A conflicting resource already exists, a project with same name already exists
* `500 Server Error` - While handling the request something went wrong on the server side
#### Pagination
When listing resources you can pass the following parameters:
......
......@@ -17,12 +17,6 @@ GET /groups
]
```
Return values:
+ `200 Ok` on success and list of groups
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if something fails
## Details of a group
......@@ -36,12 +30,6 @@ Parameters:
+ `id` (required) - The ID of a group
Return values:
+ `200 Ok` on success and the details of a group
+ `401 Unauthorized` if user not authenticated
+ `404 Not Found` if group ID not found
## New group
......@@ -56,10 +44,3 @@ Parameters:
+ `name` (required) - The name of the group
+ `path` (required) - The path of the group
Return valueS:
+ `201 Created` on success and the newly created group
+ `400 Bad Request` if one of the required attributes not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if something fails
......@@ -69,13 +69,6 @@ GET /issues
]
```
Return values:
+ `200 Ok` on success and the list of issues
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if something fails
## List project issues
......@@ -90,12 +83,6 @@ Parameters:
+ `id` (required) - The ID of a project
Return values:
+ `200 Ok` on success and the list of project issues
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Single issue
......@@ -150,12 +137,6 @@ Parameters:
}
```
Return values:
+ `200 Ok` on success and the list of project issues
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or issue ID not found
## New issue
......@@ -174,13 +155,6 @@ Parameters:
+ `milestone_id` (optional) - The ID of a milestone to assign issue
+ `labels` (optional) - Comma-separated label names for an issue
Return values:
+ `201 Created` on success and the newly created project issue
+ `400 Bad Request` if the required attribute title is not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Edit issue
......@@ -201,12 +175,6 @@ Parameters:
+ `labels` (optional) - Comma-separated label names for an issue
+ `closed` (optional) - The state of an issue (0 = false, 1 = true)
Return values:
+ `200 Ok` on success and the update project issue
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or issue ID not found
## Delete existing issue (**Deprecated**)
......@@ -223,6 +191,3 @@ Parameters:
+ `id` (required) - The project ID
+ `issue_id` (required) - The ID of the issue
Return values:
+ `405 Method Not Allowed` is always returned, because the function is deprecated
......@@ -41,12 +41,6 @@ Parameters:
]
```
Return values:
+ `200 Ok` on success and the list of merge requests
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Get single MR
......@@ -89,12 +83,6 @@ Parameters:
}
```
Return values:
+ `200 Ok` on success and the single merge request
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or merge request ID not found
## Create MR
......@@ -140,14 +128,6 @@ Parameters:
}
```
Return values:
+ `201 Created` on success and the created merge request
+ `400 Bad Request` if one of the required attributes is missing
+ `401 Unauthorize` if user is not authenticated or not allowed
+ `403 Forbidden` if user is not allowed to create a merge request
+ `404 Not Found` if project ID not found or something else fails
## Update MR
......@@ -196,13 +176,6 @@ Parameters:
}
```
Return values:
+ `200 Ok` on success and the updated merge request
+ `401 Unauthorize` if user is not authenticated or not allowed
+ `403 Forbidden` if user is not allowed to update the merge request
+ `404 Not Found` if project ID or merge request ID not found
## Post comment to MR
......@@ -232,10 +205,3 @@ Parameters:
"note":"text1"
}
```
Return values:
+ `201 Created` on success and the new comment
+ `400 Bad Request` if the required attribute note is not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or merge request ID not found
......@@ -10,12 +10,6 @@ Parameters:
+ `id` (required) - The ID of a project
Return values:
+ `200 Ok` on success and the list of project milestones
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Get single milestone
......@@ -30,12 +24,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `milestone_id` (required) - The ID of a project milestone
Return values:
+ `200 Ok` on success and the single milestone
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Create new milestone
......@@ -52,13 +40,6 @@ Parameters:
+ `description` (optional) - The description of the milestone
+ `due_date` (optional) - The due date of the milestone
Return values:
+ `201 Created` on success and the new milestone
+ `400 Bad Request` if the required attribute title is not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID not found
## Edit milestone
......@@ -77,8 +58,3 @@ Parameters:
+ `due_date` (optional) - The due date of the milestone
+ `closed` (optional) - The status of the milestone
Return values:
+ `200 Ok` on success and the updated milestone
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or milestone ID not found
......@@ -30,11 +30,6 @@ Parameters:
+ `id` (required) - The ID of a project
Return values:
+ `200 Ok` on success and a list of notes
+ `401 Unauthorized` if user is not authorized to access this page
### Get single wall note
......@@ -49,12 +44,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `note_id` (required) - The ID of a wall note
Return values:
+ `200 Ok` on success and the wall note (see example at `GET /projects/:id/notes`)
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if note ID not found
### Create new wall note
......@@ -69,14 +58,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `body` (required) - The content of a note
Return values:
+ `201 Created` on success and the new wall note
+ `400 Bad Request` if attribute body is not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if something else fails
## Issues
......@@ -93,12 +74,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `issue_id` (required) - The ID of an issue
Return values:
+ `200 Ok` on success and a list of notes for a single issue
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or issue ID not found
### Get single issue note
......@@ -114,12 +89,6 @@ Parameters:
+ `issue_id` (required) - The ID of a project issue
+ `note_id` (required) - The ID of an issue note
Return values:
+ `200 Ok` on success and the single issue note
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID, issue ID or note ID is not found
### Create new issue note
......@@ -135,14 +104,6 @@ Parameters:
+ `issue_id` (required) - The ID of an issue
+ `body` (required) - The content of a note
Return values:
+ `201 Created` on succes and the created note
+ `400 Bad Request` if the required attribute body is not given
+ `401 Unauthorized` if the user is not authenticated
+ `404 Not Found` if the project ID or the issue ID not found
## Snippets
......@@ -159,12 +120,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `snippet_id` (required) - The ID of a project snippet
Return values:
+ `200 Ok` on success and a list of notes for a single snippet
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or issue ID not found
### Get single snippet note
......@@ -180,12 +135,6 @@ Parameters:
+ `snippet_id` (required) - The ID of a project snippet
+ `note_id` (required) - The ID of an snippet note
Return values:
+ `200 Ok` on success and the single snippet note
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID, snippet ID or note ID is not found
### Create new snippet note
......@@ -201,14 +150,6 @@ Parameters:
+ `snippet_id` (required) - The ID of an snippet
+ `body` (required) - The content of a note
Return values:
+ `201 Created` on success and the new snippet note
+ `400 Bad Request` if the required attribute body not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or snippet ID not found
## Merge Requests
......@@ -225,12 +166,6 @@ Parameters:
+ `id` (required) - The ID of a project
+ `merge_request_id` (required) - The ID of a project merge request
Return values:
+ `200 Ok` on success and a list of notes for a single merge request
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or merge request ID not found
### Get single merge request note
......@@ -246,12 +181,6 @@ Parameters:
+ `merge_request_id` (required) - The ID of a project merge request
+ `note_id` (required) - The ID of a merge request note
Return values:
+ `200 Ok` on success and the single merge request note
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID, merge request ID or note ID is not found
### Create new merge request note
......@@ -267,10 +196,3 @@ Parameters:
+ `merge_request_id` (required) - The ID of a merge request
+ `body` (required) - The content of a note
Return values:
+ `201 Created` on success and the new merge request note
+ `400 Bad Request` if the required attribute body not given
+ `401 Unauthorized` if user is not authenticated
+ `404 Not Found` if project ID or merge request ID not found
......@@ -57,11 +57,6 @@ GET /projects
]
```
Return values:
+ `200 Ok` on success and a list of projects
+ `401 Unauthorized` if the user is not allowed to access projects
### Get single project
......@@ -101,11 +96,6 @@ Parameters:
}
```
Return Values:
+ `200 Ok` if the project with given ID is found and the JSON response
+ `404 Not Found` if no project with ID found
### Create project
......@@ -125,13 +115,6 @@ Parameters:
+ `merge_requests_enabled` (optional) - enabled by default
+ `wiki_enabled` (optional) - enabled by default
Return values:
+ `201 Created` on success with the project data (see example at `GET /projects/:id`)
+ `400 Bad Request` if the required attribute name is not given
+ `403 Forbidden` if the user is not allowed to create a project, e.g. reached the project limit already
+ `404 Not Found` if something else fails
## Project access levels
......@@ -159,11 +142,6 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `query` - Query string
Return Values:
+ `200 Ok` on success and a list of found team members
+ `404 Not Found` if project with ID not found
## Team members
......@@ -192,11 +170,6 @@ Parameters:
}
```
Return Values:
+ `200 Ok` on success and the team member, see example
+ `404 Not Found` if either the project or the team member could not be found
### Add project team member
......@@ -214,14 +187,6 @@ Parameters:
+ `user_id` (required) - The ID of a user to add
+ `access_level` (required) - Project access level
Return Values:
+ `201 Created` on success and the added user is returned, even if the user is already team member
+ `400 Bad Request` if the required attribute access_level is not given
+ `401 Unauthorized` if the user is not allowed to add a new team member
+ `404 Not Found` if a resource can not be found, e.g. project with ID not available
+ `422 Unprocessable Entity` if an unknown access_level is given
### Edit project team member
......@@ -237,14 +202,6 @@ Parameters:
+ `user_id` (required) - The ID of a team member
+ `access_level` (required) - Project access level
Return Values:
+ `200 Ok` on succes and the modified team member
+ `400 Bad Request` if the required attribute access_level is not given
+ `401 Unauthorized` if the user is not allowed to modify a team member
+ `404 Not Found` if a resource can not be found, e.g. project with ID not available
+ `422 Unprocessable Entity` if an unknown access_level is given
### Remove project team member
......@@ -259,12 +216,6 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `user_id` (required) - The ID of a team member
Return Values:
+ `200 Ok` on success
+ `401 Unauthorized` if user is not allowed to remove a team member
+ `404 Not Found` if 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
......@@ -285,12 +236,6 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
Return values:
+ `200 Ok` on success with a list of hooks
+ `401 Unauthorized` if user is not allowed to get list of hooks
+ `404 Not Found` if project can not be found
### Get project hook
......@@ -313,11 +258,6 @@ Parameters:
}
```
Return values:
+ `200 Ok` on sucess and the hook with the given ID
+ `404 Not Found` if the hook can not be found
### Add project hook
......@@ -332,13 +272,6 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `url` (required) - The hook URL
Return values:
+ `201 Created` on success and the newly created hook
+ `400 Bad Request` if url is not given
+ `404 Not Found` if project with ID not found
+ `422 Unprocessable Entity` if the url is invalid (must begin with `http` or `https`)
### Edit project hook
......@@ -354,13 +287,6 @@ Parameters:
+ `hook_id` (required) - The ID of a project hook
+ `url` (required) - The hook URL
Return values:
+ `200 Ok` on success and the modified hook (see JSON response above)
+ `400 Bad Request` if the url attribute is not given
+ `404 Not Found` if project or hook can not be found
+ `422 Unprocessable Entity` if the url is invalid (must begin with `http` or `https`)
### Delete project hook
......@@ -376,12 +302,6 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `hook_id` (required) - The ID of hook to delete
Return values:
+ `200 Ok` on succes
+ `403 Forbidden` if user is not allowed to delete a hook
+ `404 Not Found` if 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.
......@@ -400,11 +320,6 @@ Parameters:
+ `id` (required) - The ID of the project
Return values:
+ `200 Ok` on success and a list of branches
+ `404 Not Found` if project is not found
### List single branch
......@@ -419,11 +334,6 @@ Parameters:
+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.
Return values:
+ `200 Ok` on success
+ `404 Not Found` if either project with ID or branch could not be found
### Protect single branch
......@@ -438,11 +348,6 @@ Parameters:
+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.
Return values:
+ `200 Ok` on success
+ `404 Not Found` if either project or branch could not be found
### Unprotect single branch
......@@ -457,11 +362,6 @@ Parameters:
+ `id` (required) - The ID of the project.
+ `branch` (required) - The name of the branch.
Return values:
+ `200 Ok` on success
+ `404 Not Found` if either project or branch could not be found
### List tags
......@@ -475,11 +375,6 @@ Parameters:
+ `id` (required) - The ID of the project
Return values:
+ `200 Ok` on success and a list of tags
+ `404 Not Found` if project with id not found
### List commits
......@@ -517,11 +412,6 @@ Parameters:
+ `id` (required) - The ID of the project
Return values:
+ `200 Ok` on success and the list of snippets
+ `404 Not Found` if project with id not found
### List single snippet
......@@ -536,11 +426,6 @@ Parameters:
+ `id` (required) - The ID of the project
+ `snippet_id` (required) - The ID of the snippet
Return values:
+ `200 Ok` on success and the project snippet
+ `404 Not Found` if project ID or snippet ID not found
### Create snippet
......@@ -558,13 +443,6 @@ Parameters:
+ `code` (required) - The content of the snippet
+ `lifetime` (optional) - The expiration date of a snippet
Return values:
+ `201 Created` on success and the new snippet
+ `400 Bad Request` if one of the required attributes is missing
+ `401 Unauthorized` if it is not allowed to post a new snippet
+ `404 Not Found` if the project ID is not found
### Update snippet
......@@ -583,12 +461,6 @@ Parameters:
+ `lifetime` (optional) - The new expiration date of the snippet
+ `code` (optional) - The content of the snippet
Return values:
+ `200 Ok` on success and the content of the updated snippet
+ `401 Unauthorized` if the user is not allowed to modify the snippet
+ `404 Not Found` if project ID or snippet ID is not found
## Delete snippet
......@@ -604,8 +476,3 @@ Paramaters:
+ `id` (required) - The ID of the project
+ `snippet_id` (required) - The ID of the snippet
Return values:
+ `200 Ok` on success, if the snippet got deleted it is returned, if not available then an empty JSON response
+