flexmeasures.api.v3_0.accounts
Classes
- class flexmeasures.api.v3_0.accounts.AccountAPI
- auditlog(id: int, account: Account)
API endpoint to get history of account actions. Example response
- 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
- get(id: int, account: Account)
API endpoint to get an account.
This endpoint retrieves an account, given its id. Only admins, consultants and users belonging to the account itself can use this endpoint.
Example response
{ 'id': 1, 'name': 'Test Account' 'account_roles': [1, 3], 'consultancy_account_id': 2, }
- 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(page: int | None = None, per_page: int | None = None, filter: list[str] | None = None, sort_by: str | None = None, sort_dir: str | None = None)
API endpoint to list all accounts accessible to the current user.
This endpoint returns all accessible accounts. Accessible accounts are your own account and accounts you are a consultant for, or all accounts for admins.
The endpoint supports pagination of the asset list using the page and per_page query parameters.
If the page parameter is not provided, all assets are returned, without pagination information. The result will be a list of assets.
If a page parameter is provided, the response will be paginated, showing a specific number of assets per page as defined by per_page (default is 10).
If a search ‘filter’ such as ‘solar “ACME corp”’ is provided, the response will filter out assets where each search term is either present in their name or account name. The response schema for pagination is inspired by https://datatables.net/manual/server-side#Returned-data
Example response
An example of one account being returned:
- {
- “data”[
- {
‘id’: 1, ‘name’: ‘Test Account’ ‘account_roles’: [1, 3], ‘consultancy_account_id’: 2, ‘primary_color’: ‘#1a3443’ ‘secondary_color’: ‘#f1a122’ ‘logo_url’: ‘https://example.com/logo.png’
}
], “num-records” : 1, “filtered-records” : 1
}
If no pagination is requested, the response only consists of the list under the “data” key.
- 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(account_data: dict, id: int, account: Account)
Update an account given its identifier.
This endpoint sets data for an existing account.
The following fields are not allowed to be updated: - id
The following fields are only editable if user role is admin: - consultancy_account_id
Example request
{ 'name': 'Test Account' 'primary_color': '#1a3443' 'secondary_color': '#f1a122' 'logo_url': 'https://example.com/logo.png' 'consultancy_account_id': 2, }
Example response
The whole account is returned in the response:
{ 'id': 1, 'name': 'Test Account' 'account_roles': [1, 3], 'primary_color': '#1a3443' 'secondary_color': '#f1a122' 'logo_url': 'https://example.com/logo.png' 'consultancy_account_id': 2, }
- 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