Commit beb00af0c16c5b28b60043a6d42e09517ecd2c08

Authored by Sebastian Ziebell
1 parent 99739a58

API documentation extended with snippets, tags and commits

Documentation is updated with information how to handle snippets or how to access tags
and commits. Nearly all project specific functions are now described in the documentation.
A few previous entries have been updated with status codes, e.g. `401 Unauthorized`.
Showing 1 changed file with 153 additions and 1 deletions   Show diff stats
doc/api/projects.md
@@ -197,8 +197,9 @@ Parameters: @@ -197,8 +197,9 @@ Parameters:
197 197
198 Return Values: 198 Return Values:
199 199
200 -+ `200 Ok` on success and the added user, even if the user is already team member 200 ++ `201 Created` on success and the added user is returned, even if the user is already team member
201 + `400 Bad Request` if the required attribute access_level is not given 201 + `400 Bad Request` if the required attribute access_level is not given
  202 ++ `401 Unauthorized` if the user is not allowed to add a new team member
202 + `404 Not Found` if a resource can not be found, e.g. project with ID not available 203 + `404 Not Found` if a resource can not be found, e.g. project with ID not available
203 + `422 Unprocessable Entity` if an unknown access_level is given 204 + `422 Unprocessable Entity` if an unknown access_level is given
204 205
@@ -221,6 +222,7 @@ Return Values: @@ -221,6 +222,7 @@ Return Values:
221 222
222 + `200 Ok` on succes and the modified team member 223 + `200 Ok` on succes and the modified team member
223 + `400 Bad Request` if the required attribute access_level is not given 224 + `400 Bad Request` if the required attribute access_level is not given
  225 ++ `401 Unauthorized` if the user is not allowed to modify a team member
224 + `404 Not Found` if a resource can not be found, e.g. project with ID not available 226 + `404 Not Found` if a resource can not be found, e.g. project with ID not available
225 + `422 Unprocessable Entity` if an unknown access_level is given 227 + `422 Unprocessable Entity` if an unknown access_level is given
226 228
@@ -241,6 +243,7 @@ Parameters: @@ -241,6 +243,7 @@ Parameters:
241 Return Values: 243 Return Values:
242 244
243 + `200 Ok` on success 245 + `200 Ok` on success
  246 ++ `401 Unauthorized` if user is not allowed to remove a team member
244 + `404 Not Found` if either project or user can not be found 247 + `404 Not Found` if either project or user can not be found
245 248
246 This method is idempotent and can be called multiple times with the same parameters. 249 This method is idempotent and can be called multiple times with the same parameters.
@@ -266,6 +269,7 @@ Parameters: @@ -266,6 +269,7 @@ Parameters:
266 Return values: 269 Return values:
267 270
268 + `200 Ok` on success with a list of hooks 271 + `200 Ok` on success with a list of hooks
  272 ++ `401 Unauthorized` if user is not allowed to get list of hooks
269 + `404 Not Found` if project can not be found 273 + `404 Not Found` if project can not be found
270 274
271 275
@@ -437,3 +441,151 @@ Return values: @@ -437,3 +441,151 @@ Return values:
437 441
438 + `200 Ok` on success 442 + `200 Ok` on success
439 + `404 Not Found` if either project or branch could not be found 443 + `404 Not Found` if either project or branch could not be found
  444 +
  445 +
  446 +### List tags
  447 +
  448 +Lists all tags of a project.
  449 +
  450 +```
  451 +GET /projects/:id/repository/tags
  452 +```
  453 +
  454 +Parameters:
  455 +
  456 ++ `id` (required) - The ID of the project
  457 +
  458 +Return values:
  459 +
  460 ++ `200 Ok` on success and a list of tags
  461 ++ `404 Not Found` if project with id not found
  462 +
  463 +
  464 +### List commits
  465 +
  466 +Lists all commits with pagination. If the optional `ref_name` name is not given the commits of
  467 +the default branch (usually master) are returned.
  468 +
  469 +```
  470 +GET /projects/:id/repository/commits
  471 +```
  472 +
  473 +Parameters:
  474 +
  475 ++ `id` (required) - The Id of the project
  476 ++ `ref_name` (optional) - The name of a repository branch or tag
  477 ++ `page` (optional) - The page of commits to return (`0` default)
  478 ++ `per_page` (optional) - The number of commits per page (`20` default)
  479 +
  480 +Returns values:
  481 +
  482 ++ `200 Ok` on success and a list with commits
  483 ++ `404 Not Found` if project with id or the branch with `ref_name` not found
  484 +
  485 +
  486 +## Snippets
  487 +
  488 +### List snippets
  489 +
  490 +Lists the snippets of a project.
  491 +
  492 +```
  493 +GET /projects/:id/snippets
  494 +```
  495 +
  496 +Parameters:
  497 +
  498 ++ `id` (required) - The ID of the project
  499 +
  500 +Return values:
  501 +
  502 ++ `200 Ok` on success and the list of snippets
  503 ++ `404 Not Found` if project with id not found
  504 +
  505 +
  506 +### List single snippet
  507 +
  508 +Lists a single snippet of a project
  509 +
  510 +```
  511 +GET /projects/:id/snippets/:snippet_id
  512 +```
  513 +
  514 +Parameters:
  515 +
  516 ++ `id` (required) - The ID of the project
  517 ++ `snippet_id` (required) - The ID of the snippet
  518 +
  519 +Return values:
  520 +
  521 ++ `200 Ok` on success and the project snippet
  522 ++ `404 Not Found` if project ID or snippet ID not found
  523 +
  524 +
  525 +### Create snippet
  526 +
  527 +Creates a new project snippet.
  528 +
  529 +```
  530 +POST /projects/:id/snippets
  531 +```
  532 +
  533 +Parameters:
  534 +
  535 ++ `id` (required) - The ID of the project
  536 ++ `title` (required) - The title of the new snippet
  537 ++ `file_name` (required) - The file name of the snippet
  538 ++ `code` (required) - The content of the snippet
  539 ++ `lifetime` (optional) - The expiration date of a snippet
  540 +
  541 +Return values:
  542 +
  543 ++ `201 Created` on success and the new snippet
  544 ++ `400 Bad Request` if one of the required attributes is missing
  545 ++ `401 Unauthorized` if it is not allowed to post a new snippet
  546 ++ `404 Not Found` if the project ID is not found
  547 +
  548 +
  549 +### Update snippet
  550 +
  551 +Updates an existing project snippet.
  552 +
  553 +```
  554 +PUT /projects/:id/snippets/:snippet_id
  555 +```
  556 +
  557 +Parameters:
  558 +
  559 ++ `id` (required) - The ID of the project
  560 ++ `snippet_id` (required) - The id of the project snippet
  561 ++ `title` (optional) - The new title of the project snippet
  562 ++ `file_name` (optional) - The new file name of the project snippet
  563 ++ `lifetime` (optional) - The new expiration date of the snippet
  564 ++ `code` (optional) - The content of the snippet
  565 +
  566 +Return values:
  567 +
  568 ++ `200 Ok` on success and the content of the updated snippet
  569 ++ `401 Unauthorized` if the user is not allowed to modify the snippet
  570 ++ `404 Not Found` if project ID or snippet ID is not found
  571 +
  572 +
  573 +## Delete snippet
  574 +
  575 +Deletes a project snippet. This is an idempotent function call and returns `200 Ok`
  576 +even if the snippet with the id is not available.
  577 +
  578 +```
  579 +DELETE /projects/:id/snippets/:snippet_id
  580 +```
  581 +
  582 +Paramaters:
  583 +
  584 ++ `id` (required) - The ID of the project
  585 ++ `snippet_id` (required) - The ID of the snippet
  586 +
  587 +Return values:
  588 +
  589 ++ `200 Ok` on success, if the snippet got deleted it is returned, if not available then an empty JSON response
  590 ++ `401 Unauthorized` if the user is not allowed to remove the snippet
  591 ++ `404 Not Found` if the project ID not found