This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Customizing the solution
Hector Garcia Tellado edited this page Oct 31, 2017
·
1 revision
Note: only one simulation can be created, and cannot be modified. See the simulation API specs.
GET {Device Simulation endpoint}/devicetypes
Content-Type: application/json; charset=utf-8
{
Count: ...
"Items": [
{
"Id": "11110000-1111-0000-0000-000011110000",
"Name": "Elevator",
"Description": "Simulated Elevator with floor number sensor"
$metadata
},
{
"Id": "22220000-2222-0000-0000-000022220000",
"Name": "Chiller",
"Description": "Simulated Chiller with temperature and humidity sensors",
$metadata
}
]
"$metadata": {
$type: DeviceTypesList;1
$uri: {Device Simulation endpoint}/devicetypes
}
}
Use the above response to prepare a form for the user, e.g. the list of device types that can be simulated.
Allow the user to fill the form, entering name, description and logo, then proceed with creating the simulation and customizing the solution (in this order).
To create a standard simulation:
POST {Device Simulation endpoint}/simulations?template=default
Content-Type: application/json; charset=utf-8
{
"Enabled": true
}
To create a customized simulation:
POST {Device Simulation endpoint}/simulations
Content-Type: application/json; charset=utf-8
{
"Enabled": true,
"DeviceTypes": [
{
"Id": "11110000-1111-0000-0000-000011110000",
"Count": 3
},
{
"Id": "22220000-2222-0000-0000-000022220000",
"Count": 1
}
]
}
The simulation API returns the entire simulation object, that the UI doesn't need. In case of error, the UI should retry, before proceeding with the next step, or prompt the user.
PUT {UI Config endpoint}/styles/1
Content-Type: application/json; charset=utf-8
{
name
description
logo as base64
}
Notes:
- "styles" is the collection name, and "1" is the resource ID, so the API is consistent with other endpoints (e.g. the simulation API, which allows only 1 simulation). This design allows future extensions, e.g. allowing multiple styles.
- The payload should include all the styling details.
- The icon should be saved to a public folder, and the response should include the URL to the logo.
Content-Type: application/json; charset=utf-8
{
name
description
logo URL
etc.
}
GET {UI Config endpoint}/styles/1
Content-Type: application/json; charset=utf-8
{
name
description
logo URL
etc.
}