CLI REST-API

set-macro

set-macro [file]
The "set-macro" command allows to change the value of a group of objects with one single API call
using predefined JSON structures stored on the device. As a parameter, the name of the
file containing the macro definition must be provided in the url (/api/set-macro?file=xyz).

Please note that the macro definition must be stored in /etc/rest-api on the system.
For a set-macro definition, the file must contain a JSON structure with all objects and attributes
that should be changed and of course their new value.

You can set optional variables in the url (/api/set-macro?file=xyz&var_p1=clock).
These variables will be applied in the JSON structure.
  "name": "${p1:meinberg}" -> "name": "clock"
If a variable isn't set, it will take its default-value.
  "name": "${p1:meinberg}" -> "name": "meinberg"

The command will detect, which filetype the file is.
Alternative you can use --json or --list to set the filetype.
--json   - expects a json-file
--list   - expects a file containing list of objects with the value that needs to set

Example: If you create a file /etc/rest-api/changeurl.json

"configuration": {
  "system": {
    "firmware": {
      "autoupdate": {
        "server-url": "http://lbe-server:81/7.05/testing"
      }
    }
  }
}

You can apply it by using the API call /api/set-macro?file=changeurl.json and it will
set the value for /configuration/system/firmware/autoupdate/server-url to "http://lbe-server:81/7.05/testing".
NameValueDescriptionExample
filechangeurl.json
See also:
add-offset: adds the time to the clocks.
alias: adds an alias.
alias-delete: deletes an alias.
alias-list: lists all aliases.
cancel-token: cancels the auth token.
changes: lists changed configuration parameters in different formats.
commit: applies all configuration changes.
commit-to: pushes configuration changes to a remote system or a group of remote systems.
diff: shows differences between the system- and the "startup"-configuration set.
edit: opens a file to edit.
exec: executes all CLI commands in the specified file.
exit: exits the current sub-menu / quits the program if main-menu.
export: exports all objects.
fdm-stream: listen and receives data from fdm.
find: find elements.
get-macro: allows to get a group of objects with one single API call.
get-token: gets the auth token.
goto-config: goes into same menu-path beginning with configuration.
goto-status: goes into same menu-path beginning with status.
help: lists all global commands.
import: reads a previously exported data structure into the system configuration.
job-status: gets the job state.
job-stop: stops the job entry.
list: lists all objects inside a menu.
lock: locks an element.
main: return to the main menu/top level of the menu hierarchy.
monitor: monitor system states.
monitor-alarms: lists all currently active alarms and then updates its output continously.
monitor-object: prints and checks the name and value of a specified object.
monitor-view: prints and checks all objects inside a menu.
no: disables an object.
ping: check connectivity to a network node.
protect: protects an object.
quit: quits the CLI.
read: loads a package configuration from the configuration database.
reboot: schedules a system reboot.
remote-get-object: read the current value of a single object from a remote host.
remote-run-command: execute a CLI command on a remote host.
remote-set-object: change the value of a configuration parameter on a remote host.
rollback: discards all parameter changes made in this CLI session.
run-script: runs a script from /etc/syncteam/scripts directory.
service: allows the control of a service
set-clk-time: manually sets the time to a clock.
setvar: allows to set a custom variable.
show: show system states.
show-alarms: lists all currently active alarms.
show-locks: prints a list of locks.
show-object: prints the name and value of a single specified object.
traceroute: print the network path used to reach the node.
unlock: unlocks an element.
unprotect: unprotects an object.
update-values: updates all objects of the specified menu/submenu.
uptime: print the current uptime of the server.
validate-configuration: shows configuration errors.
version: shows the current lt_cli version.
view: shows all objects and submenus inside a menu.
write: saves a package configuration to the configuration database.

REST-API Support:


This command is supported by the REST API:

Method: PUT
URL: /api/set-macro

Example using curl:
curl -X PUT /api/set-macro