2.9. Users¶
Admins can list, create and delete users from the system.
2.9.1. List/Query Users¶
A list of matching user may be queried by the system. The optional query parameters are as follows:
Name | Value Description |
---|---|
text | text to search for in the username, first name and/or last name |
reverse | true to get the oldest users first; false (default) to get newest first |
offset | offset into list of users for paging |
limit | limit to show for paging. The maximum number of users to display is 1000. |
To query for users, add query parameters after the sensors URL as follows:
URL | http://wotkit.sensetecnic.com/api/users?{query} |
Privacy | Admin |
Format | json |
Method | GET |
Returns | On error, an appropriate HTTP status code; On success, OK 200 and a list of users matching the query. |
2.9.2. Viewing a Single User¶
To view a single user, query by username or id as follows:
URL | http://wotkit.sensetecnic.com/api/users/{username} |
Privacy | Admin |
Format | json |
Method | GET |
Returns | Appropriate HTTP status code; OK 200 - if successful |
example
curl --user {id}:{password} "http://wotkit.sensetecnic.com/api/users/1"
Output:
{
'id': 1,
'username': 'sensetecnic',
'email': 'info@sensetecnic.com',
'firstname': 'Sense',
'lastname': 'Tecnic',
'enabled': True,
'accountNonExpired': True,
'accountNonLocked': True,
'credentialsNonExpired': True
}
2.9.3. Creating/Registering a User¶
To register a user, you POST a user resource to the url /users.
- The user resources is a JSON object.
- The “username”, “firstname”, “lastname”, “email”, and “password” fields are required when creating a user.
- The “timeZone” field is optional and defaults to UTC.
- The username must be at least 4 characters long.
To create a user:
URL | http://wotkit.sensetecnic.com/api/users |
Privacy | Admin |
Format | json |
Method | POST |
Returns | HTTP status code; Created 201 if successful; Bad Request 400 if user is invalid; Conflict 409 if user with the same username already exists |
2.9.4. Updating a User¶
- You may only update the following fields: “firstname”, “lastname”, “email”, “timeZone” and “password”.
- Only fields that will be present in the JSON object will be updated. The rest will remain unchanged.
To update a user:
URL | http://wotkit.sensetecnic.com/api/users/{username} |
Privacy | Admin |
Format | json |
Method | PUT |
Returns | HTTP status code; No Content 204 if successful |
2.9.5. Deleting a User¶
Deleting a user is done by deleting the user resource.
To delete a user:
URL | http://wotkit.sensetecnic.com/api/users/{username} |
Privacy | Admin |
Format | not applicable |
Method | DELETE |
Returns | HTTP status code; No Response 204 if successful |