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

The loading of the Scenario and running of the Scenario will be taken care of by GMUS.


Note: 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


If you are not connected to the internet, in that case, please log in to the GenRocket Web platform, Go to Options Menu and Click on Generator and Receiver Help Library.

{
    "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"
          } 
        }
        {"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"
            }
        }
    ]
}