Use the API to Modify a Scenario Before Execution
The GMUS can modify any Scenario, in real time, prior to its execution, by adding GenRocket API commands to the request payload. The following example adds API sub-elements to the request payload to take the following actions on the loaded Scenario before execution:
- scenarioClear
- domainAdd
- attributeAdd
- generatorAdd
- receiverAdd
- domainSetLoopCount
Note: The loading of the Scenario and running of the Scenario will be taken care of by GMUS.
In This Article
- Ensure Generator / Receiver Libraries are in .genrocket Folder
- Additional Steps When Not Connected to the Internet
- Modifying Generator or Receiver Parameters in the Request Payload
- Sample Request Payload
Ensure Generator / Receiver Libraries are in .genrocket Folder
Using API requires Generator and Receiver libraries in the .genrocket folder of the User's HOME directory. To download the libraries, you can run the following command:
genrocket -lib
Additional Steps When Not Connected to the Internet
If you are not connected to the internet, please log in to the GenRocket Web platform and complete the following steps to download the Generator and Receiver help libraries.
- Go to the Options Menu.
- Click on Generator Help Library and Receiver Help Library.
Modifying Generator or Receiver Parameters in the Request Payload
In the Request Payload, users will need the Generator or Receiver name when adding a Generator or Receiver and modifying their Parameters.
Generator Example
Where Is This Information?
This information can be found in the GenRocket web platform by completing these steps:
- Go to the Help Menu.
- Select Generator List or Receiver List.
- Select a Generator or Receiver.
Sample Request Payload
Note: For Windows machines, the scenarioPath should have two slashes: C:\\Users\\jDoe\\Downloads\\output.
{ "clientAppId": "XXXXXXXX-487e-41e2-8245-XXXXXXXXXXXX", "clientUserId": "XXXXXXXX-0777-426f-be33-XXXXXXXXXXXX", "username": "jane.doe@gmail.com", "scenario": "UserScenario.grs", "scenarioPath": "/home/UserName/Downloads/output", "inMemory": false, "api": [ { "resources": { "resource.output.directory": "/home/johndoe/Desktop/output" }, "organizationVariables": { "org.database.name": "staging_db" } }, {"methodName": "scenarioClear"}, { "methodName": "domainAdd", "parameters": { "domainName": "User", "primary": true } }, { "methodName": "attributeAdd", "parameters": {"attributeName": "User.ssn"} }, { "methodName": "generatorAdd", "parameters": { "attributeName": "User.ssn", "generatorName": "com.genRocket.generator.RangeConstantGen", "requiredGeneratorParameters": { "suffix": "firstName", "prefix": "#{User.id}" } } }, { "methodName": "receiverAdd", "parameters": { "domainName": "User", "canonicalName": "com.genRocket.receiver.XMLFileReceiver", "receiverName": "XMLFileReceiver", "parameterMap": { "path": "#{resource.output.directory}", "fileName": "User.xml" } } }, { "methodName": "domainSetLoopCount", "parameters": { "domainName": "User", "loopCount": "100000" } } ] }