flexmeasures.api.v3_0.assets
Classes
- class flexmeasures.api.v3_0.assets.AssetAPI
This API view exposes generic assets. Under development until it replaces the original Asset API.
- delete(id: int, asset: GenericAsset)
Delete an asset given its identifier.
This endpoint deletes an existing asset, as well as all sensors and measurements recorded for it.
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 204:
DELETED
- Status 400:
INVALID_REQUEST, REQUIRED_INFO_MISSING, UNEXPECTED_PARAMS
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY
- fetch_one(id, asset)
Fetch a given asset.
This endpoint gets an asset.
Example response
{ "generic_asset_type_id": 2, "name": "Test battery", "id": 1, "latitude": 10, "longitude": 100, "account_id": 1, }
- 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_chart(id: int, asset: GenericAsset, **kwargs)
GET from /assets/<id>/chart
- get_chart_data(id: int, asset: GenericAsset, **kwargs)
GET from /assets/<id>/chart_data
Data for use in charts (in case you have the chart specs already).
- index(account: Account)
List all assets owned by a certain account.
This endpoint returns all accessible assets for the account of the user. The account_id query parameter can be used to list assets from a different account.
Example response
An example of one asset being returned:
[ { "id": 1, "name": "Test battery", "latitude": 10, "longitude": 100, "account_id": 2, "generic_asset_type_id": 1 } ]
- 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(asset_data: dict, id: int, db_asset: GenericAsset)
Update an asset given its identifier.
This endpoint sets data for an existing asset. Any subset of asset fields can be sent.
The following fields are not allowed to be updated: - id - account_id
Example request
{ "latitude": 11.1, "longitude": 99.9, }
Example response
The whole asset is returned in the response:
{ "generic_asset_type_id": 2, "id": 1, "latitude": 11.1, "longitude": 99.9, "name": "Test battery", "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
- post(asset_data: dict)
Create new asset.
This endpoint creates a new asset.
Example request
{ "name": "Test battery", "generic_asset_type_id": 2, "account_id": 2, "latitude": 40, "longitude": 170.3, }
The newly posted asset is returned in the response.
- Reqheader Authorization:
The authentication token
- Reqheader Content-Type:
application/json
- Resheader Content-Type:
application/json
- Status 201:
CREATED
- Status 400:
INVALID_REQUEST
- Status 401:
UNAUTHORIZED
- Status 403:
INVALID_SENDER
- Status 422:
UNPROCESSABLE_ENTITY
- public()
Return all public assets.
This endpoint returns all public assets.
- 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 422:
UNPROCESSABLE_ENTITY