Added users api

Lukas Metzger 2018-02-09 16:28:02 +01:00
parent 5d09352730
commit ac0ca7a7c7
4 changed files with 118 additions and 2 deletions

3
.vscode/settings.json vendored Normal file

@ -0,0 +1,3 @@
{
"editor.tabSize": 2
}

@ -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]]
* [[Credentials | API Record Credentials]]
* [[Users | API Users]]

111
API-Users.md Normal file

@ -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 |

@ -3,4 +3,5 @@
* [[Sessions | API Sessions]]
* [[Domains | API Domains]]
* [[Records | API Records]]
* [[Credentials | API Record Credentials]]
* [[Credentials | API Record Credentials]]
* [[Users | API Users]]