flexmeasures.api.v3_0.users
Classes
- class flexmeasures.api.v3_0.users.UserAPI
- get(id: int, user: User)
API endpoint to get a user.
This endpoint gets a user. Only admins or the members of the same account can use this endpoint.
Example response
{ 'account_id': 1, 'active': True, 'email': 'test_prosumer@seita.nl', 'flexmeasures_roles': [1, 3], 'id': 1, 'timezone': 'Europe/Amsterdam', 'username': 'Test Prosumer User' }
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 200:
PROCESSED
- Status 400:
INVALID_REQUEST, REQUIRED_INFO_MISSING, UNEXPECTED_PARAMS
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY
- index(account: Account, include_inactive: bool = False)
API endpoint to list all users of an account.
This endpoint returns all accessible users. By default, only active users are returned. The include_inactive query parameter can be used to also fetch inactive users. Accessible users are users in the same account as the current user. Only admins can use this endpoint to fetch users from a different account (by using the account_id query parameter).
Example response
An example of one user being returned:
[ { 'active': True, 'email': 'test_prosumer@seita.nl', 'account_id': 13, 'flexmeasures_roles': [1, 3], 'id': 1, 'timezone': 'Europe/Amsterdam', 'username': 'Test Prosumer User' } ]
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 200:
PROCESSED
- Status 400:
INVALID_REQUEST
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY
- patch(id: int, user: User, **user_data)
API endpoint to patch user data.
This endpoint sets data for an existing user. It has to be used by the user themselves, admins or account-admins (of the same account). Any subset of user fields can be sent. If the user is not an (account-)admin, they can only edit a few of their own fields.
- The following fields are not allowed to be updated at all:
id
account_id
Example request
{ "active": false, }
Example response
The following user fields are returned:
{ 'account_id': 1, 'active': True, 'email': 'test_prosumer@seita.nl', 'flexmeasures_roles': [1, 3], 'id': 1, 'timezone': 'Europe/Amsterdam', 'username': 'Test Prosumer User' }
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 200:
UPDATED
- Status 400:
INVALID_REQUEST, REQUIRED_INFO_MISSING, UNEXPECTED_PARAMS
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY
- reset_user_password(id: int, user: User)
API endpoint to reset the user’s current password, cookies and auth tokens, and to email a password reset link to the user.
Reset the user’s password, and send them instructions on how to reset the password. This endpoint is useful from a security standpoint, in case of worries the password might be compromised. It sets the current password to something random, invalidates cookies and auth tokens, and also sends an email for resetting the password to the user.
Users can reset their own passwords. Only admins can use this endpoint to reset passwords of other users.
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 200:
PROCESSED
- Status 400:
INVALID_REQUEST, REQUIRED_INFO_MISSING, UNEXPECTED_PARAMS
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY