Web API for Scripts
Scripts API is used to start and stop script runs and get the current or last completed script run log.
Script Entity
The scripts API is based on the script entity, which has the following properties: - Id (integer): Script id - ProjectId (integer): project id (if empty, script belongs to system level) - Name (string): name - Description (string): description - Code (string): code
Methods
The scripts API has the following methods.
Start script run
POST api/scripts/run/{scriptId}
Starts to run script with given id. Returns id of the started script run operation. Returns immediately without waiting for a script run to be finished. Returns 0 if the script is already running. Requires the global RunScript permission. Returns NotFound if a script does not exist, or Forbidden if current user has no access to the script.
End script run
POST api/scripts/end/{scriptId}
Terminates run of script with given id. Returns id of the terminated script run operation. Returns immediately without waiting for a script run to be aborted. Returns 0 if the script is not running. Requires the global RunScript permission. Returns NotFound if a script does not exist, or Forbidden if current user has no access to the script.
Get current run log
GET api/scripts/runlog/current/{scriptId}
Gets the current run log for script with given id, i.e. a run that is currently in progress. Returns the object with the following fields: Log, Exceptions, AdditionalData, OperationId. Returns null if the script is not running. Requires the global RunScript permission. Returns NotFound if a script does not exist, or Forbidden if current user has no access to the script.
Get last run log
GET api/scripts/runlog/last/{scriptId}
Gets the last completed run log for script with given id. Returns the object with the following fields: Log, Exceptions, AdditionalData, OperationId. Returns null if the script is has never been run yet. Requires the global RunScript permission. Returns NotFound if a script does not exist, or Forbidden if current user has no access to the script.
Create script
POST api/scripts
Creates a new script. Takes the script object in the body (id is ignored if specified). Returns the created script id. Returns Forbidden if script cannot be created.
Edit script
PUT api/scripts
Updates an existing script. Takes the script object in the body. Returns NotFound error if script does not exist. Returns Forbidden if script cannot be modified.
Delete script
DELETE api/scripts/{id}
Deletes a script with given id. Returns NotFound error if script does not exist. Returns Forbidden if script cannot be deleted.