RegisterCustomFunction

(RESTServicesInterface library)

Description: A module that registers a custom function endpoint for the VTScada REST interface.
Returns: RESTResponseInfo Struct containing output from the registered function.
Usage: Script Only.
Function Groups: Database and Data Source, ODBC, REST Interface
Related to: RegisterCustomTable
Format: \RESTServicesInterface\RegisterCustomFunction(Name, CallbackObj)
Parameters:  
Name
Required. Name of the Function Module.
CallbackObj

Required. Entered as "Self()" (see below examples) after the Name parameter, this invokes the "DoAction" callback of this custom function, specifically.

Its parameters are as follows:

Parms A dictionary of parameters in HTTP request URL format.
PtrResults Required. A pointer to the RESTResponseInfo structure containing the function results.
Realm The name of the realm associated with the request.
Username The username associated with the request.

These parameters must be written in this order within the DoAction submodule, but they do not all need to be used or accessed.

Comments:

  HTTP Error codes will be consistent with established HTML error conventions, see 'VTScada Thin Client Server Error Messages' for more information.
  The user requires Remote Data Access privilege and access to the security realm containing the desired data in order to query it.
 

RESTResponseInfo Struct

The return value structure containing the function output. The fields are as follows:

results Output from the REST function.
returnCode Return code, 0 for executing successfully.
errorMessage Textual error message to describe the issue, if an error occurred.
nextPageToken A base64 encoded JSON token for pagination. Invalid indicates no more pages.
paginationStatus Statistics of the pagination progress.

The developer of the custom function is responsible for:

- Correctly handling the data passed to the callback module .
- Logging the actions caused by the customized REST script.
- Ensuring the custom REST APIs perform authentication and security checks when needed.
- Managing resource consumption of custom REST APIs.

For more information, refer to the "Security Guidelines Manual" included in the Documents folder at the root of your VTScada installation.

Examples

Function Registration examples, where both "Self()" and "CustomFuncObj" use DoAction callbacks:

\RESTServicesInterface.RegisterCustomFunction("CustomFunctionName", Self());
\RESTServicesInterface.RegisterCustomFunction("CustomFunctionName", CustomFuncObj);

See ' VTScada RESTInterface Module' for a detailed example of querying values with a custom function.