Users¶
API endpoint for manage users.
Data management¶
/api/users
¶
-
GET
/storekeeper/api/users
¶ List users (for administrators only)
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – user has not enough rights
Example request:
GET /storekeeper/api/users HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "admin": true, "disabled": false, "email": "admin@test.com", "id": 1, "username": "admin" }, { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" } ]
-
POST
/storekeeper/api/users
¶ Create user (for administrators only)
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – user has not enough rights
- 422 Unprocessable Entity – {original} / user is already exist
Example request:
POST /storekeeper/api/users HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "email": "foo@bar.com", "password": "bar", "username": "foo" }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" }
/api/users/<id>
¶
-
GET
/storekeeper/api/users/
(int: id)¶ Get user
Parameters: - id – ID of selected user for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no user
Example request:
GET /storekeeper/api/users/2 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" }
-
PUT
/storekeeper/api/users/
(int: id)¶ Update user
Parameters: - id – ID of selected user for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – user can not modify other users
- 404 Not Found – there is no user
- 422 Unprocessable Entity – {original} / user is already exist
Example request:
PUT /storekeeper/api/users/2 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "email": "foo@bar.com", "password": "bar", "username": "new_foo" }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "new_foo" }
-
DELETE
/storekeeper/api/users/
(int: id)¶ Delete user (for administrators only)
Parameters: - id – ID of selected user for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – user can not remove itself
- 404 Not Found – there is no user
Example request:
DELETE /storekeeper/api/users/2 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null
Config management¶
/api/users/<id>/config
¶
-
GET
/storekeeper/api/users/
(int: id)/config
¶ List user items.
Parameters: - id – ID of user
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no item
Example request:
GET /storekeeper/api/users/2/config HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "name": "lang", "value": "hu" }, { "name": "fruits", "value": "[\"apple\", \"orange\", \"banana\"]" } ]
-
POST
/storekeeper/api/users/
(int: id)/config
¶ Create user item
Parameters: - id – ID of user
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no item
- 422 Unprocessable Entity – there is wrong type / missing field / can not add one item twice
Example request:
POST /storekeeper/api/users/2/config HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "name": "lang", "value": "hu" }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "name": "lang", "value": "hu" }
/api/users/<id>/config/<id>
¶
-
GET
/storekeeper/api/users/
(int: id)/config/
(string: name)¶ Get user item
Parameters: - id – ID of user
- name – Name of selected user config value for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no user item
Example request:
GET /storekeeper/api/users/2/config/lang HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "name": "lang", "value": "hu" }
-
PUT
/storekeeper/api/users/
(int: id)/config/
(string: name)¶ Update user item
Parameters: - id – ID of user
- name – Name of selected user config value for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no user item
- 422 Unprocessable Entity – there is wrong type / missing field / can not use one config name twice
Example request:
PUT /storekeeper/api/users/2/config/lang HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "name": "lang", "value": "hu" }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "name": "lang", "value": "hu" }
-
DELETE
/storekeeper/api/users/
(int: id)/config/
(string: name)¶ Delete user item
Parameters: - id – ID of user
- name – Name of selected user config value for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no user item
Example request:
DELETE /storekeeper/api/users/2/config/lang HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null