Macro Resource¶
Macros can be defined as a sequence of Rulex Platform REST API calls saved in a code form which are executed as a whole in a single trigger command.
This is extremely useful when you need to automate complex processes composed by several computations of flows and tasks.
Tip
Together with computations command, import/export, delete/creation of resources and tasks, reset of precedent computation and modification of options and histories can also be saved in a macro code.
Macro code¶
To represent a sequence of Rulex Platform REST API calls in a code, we use the CLI general approach.
As explained here, any REST API call can be expressed as a command line code. The same representation is used in any macro code.
Example
The following code:
compute -a compute -c flow -rs '/RulexDesktop/Test/Robotic Data Correction' -rtp flow -q mode=selected -b '{"compute_params": {"inmemory": 0}, "taskList": ["corrections"]}'
session -a delete -c taskhistoryrows -rs '/RulexDesktop/Test/Robotic Data Correction' -rtp flow -q task=corrections -b '{}'
session -a set -c resetflow -rs '/RulexDesktop/Test/Robotic Data Correction' -rtp flow -q mode=soft -b '{"taskList": ["fromtask4", "fromtask7", "fromtask3", "fromtask1", "fromtask5"]}'
compute -a compute -c flow -rs '/RulexDesktop/Test/Robotic Data Correction' -rtp flow -q mode=upto -b '{"compute_params": {"inmemory": 0, "inputdata": null}, "taskList": ["corrections"]}'
performs this actions in a sequence:
Computes the task corrections in the flow Robotic Data Correction into environment Test.
Modifies history of the same task corrections by deleting all the rows.
Performs a reset soft on tasks fromtask4, fromtask7, fromtask3, fromtask1, fromtask5 in the same flow.
Computes all the tasks up to task corrections as final operations.
Using macros¶
To create a macro resource, you need to open the Explorer (for more information refer to this page) and follow this:
Procedure
Click the Explore resources icon to open the Explorer pane.
Toggle off the primary resource filter by clicking on the Primary filter on the upper right side of the Explorer panel to add general resources.
Hover over the Plus button.
Select Add new Macro and a dedicated window will appear on the screen.
Insert a unique name for the new resource.
Insert the Macro code in the corresponding box.
Click Create: the new Filesystem resource will now be added to the list.
Once the macro resource is created it can be computed at any time by right-clicking on it and by selecting the dedicated Execute Macro entry.
See also
Macro code can also be recorded from Rulex Factory stage toolbar.
See also
Saved Macro resources can be related to flow events to prevent not allowed user to modify the internal code.