On this page
It is possible to simulate Teamwork Cloud projects on the server by using REST API. The topics below describe all available REST API requests and provide examples how to use them.
Prerequisites
Before starting simulation, make sure you have prepared your environment and projects for server-side simulation as described in the following topics:
You can use the following REST API requests to simulate Teamwork Cloud projects on the server:
- GET /webapp/api/simulation/start/project/<project>/branch/<branch>/element/<element_id>/config/<config>
- GET /webapp/api/simulation/status/<simulation_id>
- GET /webapp/api/simulation/results/<simulation_id>
- GET /webapp/api/simulation/running
- GET /webapp/api/simulation/terminate/<simulation_id>
- GET /webapp/api/simulation/hasConfigs/project/<project>/branch/<branch>
- GET /webapp/api/simulation/configs/project/<project>/branch/<branch>/element/<element_id>
Start simulation
GET /webapp/api/simulation/start/project/<project>/branch/<branch>/element/<element_id>/config/<config>
This REST API request starts the simulation. It connects to Teamwork Cloud, finds the element to execute, and starts simulation if the element exists. After the simulation is complete, the request constructs and returns a unique ID (per application) for the given execution.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
project | path | required | The Teamwork Cloud project name or ID. |
branch | path | optional | The project branch name or ID. If the branch is omitted, the trunk is used instead. |
element_id | path | optional | The server ID of the Instance Specification to be executed. |
config | path | required | The Simulation Configuration name or server ID. |
?resultAsJson | query | optional | This key can be written at the end of the REST API request to return CSV export results in the JSON format. Simulation results are returned according to the CSVExport configuration that is assigned to the Simulation Configuration. Available values are true or false (default). If there is more than one CSVExport then the data is returned according to the first assigned CSVExport. |
/webapp/api/simulation/start/project/SpacecraftMassRollup/branch/2/element/519701b0-bec8-4f51-aad5-152a5411d60b/config/spacecraft mass analysis?resultAsJson=true { "simulationId": "c7944233-a1cb-4310-a62f-48bce07dd71c" } /webapp/api/simulation/start/project/CarBrakingAnalysis/config/Vehicle Analysis no Matlab { "simulationId": "cf83877b-86cc-466c-89a1-af97619a9a86" } /webapp/api/simulation/start/project/8715fcfa-fd34-4928-8480-13f4439cec3d/element/519701b0-bec8-4f51-aad5-152a5411d60b/config/7915fcfa-fd88-4910-8560-13f4439cec3d { "simulationId": "b7bdf933-f58d-4e7e-b73b-8370c60485cd" }
Get simulation status
GET /webapp/api/simulation/status/<simulation_id>
This REST API request gets the status and elapsed time for a specific simulation. It returns the actual elapsed time of the simulation thread and the simulation state: RUNNING, COMPLETED, TERMINATED, ERROR.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
simulation_id | path | required | The ID of a specific simulation. |
/webapp/api/simulation/status/ce8c8215-0515-43fd-9d34-92d1d7a95d87 { "state": "COMPLETED", "userId": "Administrator", "elapsedTime": 8078 }
Get simulation results
GET /webapp/api/simulation/result/<simulation_id>
This REST API returns the results of the specified simulation. In the start REST API body, you can specify what output parameters should be returned. If output parameters are not specified, all output parameters are obtained. In addition, if the CSV export results are available, they are returned in JSON format.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
simulation_id | path | required | The ID of the running simulation. |
/webapp/api/simulation/results/ce8c8215-0515-43fd-9d34-92d1d7a95d87 { "outputs": { "me": 98.0, "propulsion.me": 68.0, "propulsion.tank.me": 38.0, "propulsion.thruster.me": 30.0, "telecom.me": 30.0, "telecom.antenna.me": 10.0, "telecom.amplifier.me": 20.0 }, "csv exports": { "'SpaceCraftResults' csv export": "me,propulsion.me,propulsion.tank.me,propulsion.thruster.me,telecom.me,telecom.amplifier.me,telecom.antenna.me\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n" } }
Get the list of running simulations
GET /webapp/api/simulation/running
This REST API request gets the list of all currently running simulations that you have started.
/webapp/api/simulation/running ["9bc18e3e-b544-4652-9bdb-6da1d75f7ea1"]
Terminate simulation
GET /webapp/api/simulation/terminate/<simulation_id>
This REST API request terminates the specified simulation.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
simulation_id | path | required | The ID of a specific simulation. |
/webapp/api/simulation/terminate/4e35bc60-2c66-48e8-96e2-80f5270c08cf /webapp/api/simulation/status/4e35bc60-2c66-48e8-96e2-80f5270c08cf { "state": "TERMINATED", "userId": "Administrator", "elapsedTime": 11702 }
Check for Simulation Configurations
GET /webapp/api/simulation/hasConfigs/project/<project>/branch/<branch>
This REST API checks if the project has any Simulation Configurations.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
project | path | required | The Teamwork Cloud project name or ID. |
branch | path | optional | The project branch name or ID. If the branch is omitted, the trunk is used instead. |
/webapp/api/simulation/hasConfigs/project/SpacecraftMassRollup { "hasConfigs": true }
Get Simulation Configurations
GET /webapp/api/simulation/configs/project/<project>/branch/<branch>/element/<element_id>
This REST API request retrieves element IDs, names, and descriptions of the Simulation Configurations available for the given executable element.
If the executable element is an Instance Specification, the method returns the Simulation Configurations:
- Whose execution target is the classifier of the executable element.
- Whose execution target is the Instance Specification having at least one classifier matching those of the executable element.
The following table describes the parameters used in the REST API request:
Parameter | In | Required or optional | Description |
---|---|---|---|
project | path | required | The Teamwork Cloud project name or ID. |
branch | path | optional | The project branch name or ID. If the branch is omitted, the trunk is used instead. |
element_id | path | optional | The server ID of the Instance Specification to be executed. |
/webapp/api/simulation/configs/project/SpacecraftMassRollup { "configId": "7915fcfa-fd88-4910-8560-13f4439cec3d", "configName": "spacecraft mass analysis", "documentation": "" }