From ac0ca7a7c73d4c473d9d3f3ff4f2ac881516ad7b Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Fri, 9 Feb 2018 16:28:02 +0100 Subject: [PATCH] Added users api --- .vscode/settings.json | 3 ++ API-Functions.md | 3 +- API-Users.md | 111 ++++++++++++++++++++++++++++++++++++++++++ _Sidebar.md | 3 +- 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 API-Users.md diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff30c44 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.tabSize": 2 +} \ No newline at end of file diff --git a/API-Functions.md b/API-Functions.md index cfb66a5..4533a29 100644 --- a/API-Functions.md +++ b/API-Functions.md @@ -30,4 +30,5 @@ This documentation documents the API in version 1. All URLs are relative to `/ap * [[Sessions | API Sessions]] * [[Domains | API Domains]] * [[Records | API Records]] - * [[Credentials | API Record Credentials]] \ No newline at end of file + * [[Credentials | API Record Credentials]] +* [[Users | API Users]] \ No newline at end of file diff --git a/API-Users.md b/API-Users.md new file mode 100644 index 0000000..90a8e10 --- /dev/null +++ b/API-Users.md @@ -0,0 +1,111 @@ +# Users + +Where not otherwise noted all calls in this section can only be used by admin users. + +## Get list of users +`GET /users?page=5&pagesize=10&query=foo&type=admin,user&sort=id-asc,name-desc,type-asc` + +| parameter | explanation | +| --- | --- | +| page | The page of the results to return, if ommited returns page 1 | +| pagesize | How many items should be on each page, if ommited page size is infinite therefore all results are returned | +| type | Types of the retrieved users comma separated | +| query | A search query | +| sort | A comma separated list of field names to sort (in this order) combined with the sort order (see example) | + +### Response +| code | result | +| --- | --- | +| 200 | Everything was successful | + +```json +{ + "paging": { + "page": 5, + "total": 20, + "pagesize": 10 + }, + "results": [ + { + "id": 1, + "name": "administrator", + "type": "admin" + } + ] +} +``` + +## Create new user +`POST /users` + +### Body +```json +{ + "name": "administrator", + "type": "admin", + "password": "supersecretpassword" +} +``` + +### Response +| code | result | +| --- | --- | +| 201 | Everything was successful, domain has been created | +| 409 | A user with that name already exists | +| 422 | One of the required fields is missing | + +```json +{ + "id": 21 + "name": "administrator", + "type": "admin", + "password": "supersecretpassword" +} +``` + +## Delete user +`DELETE /users/{id}` + +### Response +| code | result | +| --- | --- | +| 204 | Everything was successful, the answer body is therefore empty | +| 404 | The given user id does not exist | + +## Get single domain +`GET /users/{id}` + +### Response +| code | result | +| --- | --- | +| 200 | Call was successful | +| 404 | The given domain id does not exist | + +```json +{ + "id": 1, + "name": "administrator", + "type": "admin" +} +``` + +## Update user +`PUT /users/{id}` + +This call, other than the others in the `/users` section can also be accessed by non admin users. In this case only the `password` field can be set, all others must not be set. + +### Body +```json +{ + "name": "administrator", + "type": "admin", + "password": "supersecretpassword" +} +``` +### Response +| code | result | +| --- | --- | +| 204 | Everything was successful, the answer body is therefore empty | +| 404 | The given user id does not exist | +| 409 | A user with that name already exists | +| 422 | One of the required fields is missing | \ No newline at end of file diff --git a/_Sidebar.md b/_Sidebar.md index cb1e80e..08fb88a 100644 --- a/_Sidebar.md +++ b/_Sidebar.md @@ -3,4 +3,5 @@ * [[Sessions | API Sessions]] * [[Domains | API Domains]] * [[Records | API Records]] - * [[Credentials | API Record Credentials]] \ No newline at end of file + * [[Credentials | API Record Credentials]] + * [[Users | API Users]] \ No newline at end of file