API script - RapturePlatform/Rapture GitHub Wiki
The Scripting API is used to define and manage Reflex scripts that are used within Rapture.
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureScript retVal = scriptApi.createScript(scriptURI, language, purpose, script);retVal = baseAPI.doScript_CreateScript(scriptURI, language, purpose, script);Entitlement: /script/write/$f(scriptURI)
Creates a script in the system.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| language | RaptureScriptLanguage | |
| purpose | RaptureScriptPurpose | |
| script | String |
| Type | Description |
|---|---|
| RaptureScript |
One of the scripting languages compatible with Rapture.
| Field | Type |
|---|---|
| REFLEX | String |
Describes the script's functionality.
| Field | Type |
|---|---|
| INDEXGENERATOR | String |
| MAP | String |
| FILTER | String |
| OPERATION | String |
| PROGRAM | String |
| LINK | String |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.createScriptLink(fromScriptURI, toScriptURI);retVal = baseAPI.doScript_CreateScriptLink(fromScriptURI, toScriptURI);Entitlement: /script/write/$f(fromScriptURI)
Creates a symbolic link to a script in the system.
| Parameter | Type | Description |
|---|---|---|
| fromScriptURI | String | |
| toScriptURI | String |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.removeScriptLink(fromScriptURI);retVal = baseAPI.doScript_RemoveScriptLink(fromScriptURI);Entitlement: /script/write/$f(fromScriptURI)
Removes a symbolic link to a script in the system.
| Parameter | Type | Description |
|---|---|---|
| fromScriptURI | String |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureScript retVal = scriptApi.setScriptParameters(scriptURI, parameters);retVal = baseAPI.doScript_SetScriptParameters(scriptURI, parameters);Entitlement: /script/write/$f(scriptURI)
Sets the parameters that should be used for a script. Parameters are the names of the arguments that should be passed in, not the argument values themselves.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| parameters | List |
| Type | Description |
|---|---|
| RaptureScript |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
boolean retVal = scriptApi.doesScriptExist(scriptURI);retVal = baseAPI.doScript_DoesScriptExist(scriptURI);Entitlement: /script/read/$f(scriptURI)
Returns true the given script was found.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String |
| Type | Description |
|---|---|
| boolean |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.deleteScript(scriptURI);retVal = baseAPI.doScript_DeleteScript(scriptURI);Entitlement: /script/write/$f(scriptURI)
Removes the script from the system.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
List<String> retVal = scriptApi.getScriptNames(scriptURI);retVal = baseAPI.doScript_GetScriptNames(scriptURI);Entitlement: /script/read/$f(scriptURI)
Retrieves all of the scripts within a authority.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String |
| Type | Description |
|---|---|
| List |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureScript retVal = scriptApi.getScript(scriptURI);retVal = baseAPI.doScript_GetScript(scriptURI);Entitlement: /script/read/$f(scriptURI)
Retrieves the contents of a script.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String |
| Type | Description |
|---|---|
| RaptureScript |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureScript retVal = scriptApi.putScript(scriptURI, script);retVal = baseAPI.doScript_PutScript(scriptURI, script);Entitlement: /script/write/$f(scriptURI)
Stores a script in the system using a RaptureScript object. TODO is there really any point in passing the URI? The storage location is based on RaptureScript. All we do is extract the Authority from the URI; the caller can do that.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| script | RaptureScript |
| Type | Description |
|---|---|
| RaptureScript |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureScript retVal = scriptApi.putRawScript(scriptURI, content, language, purpose, param_types, param_names);retVal = baseAPI.doScript_PutRawScript(scriptURI, content, language, purpose, param_types, param_names);Entitlement: /script/write/$f(scriptURI)
Store a script in the system using raw inputs. Most users will want the value PROGRAM for purpose.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| content | String | |
| language | String | |
| purpose | String | |
| param_types | List | |
| param_names | List |
| Type | Description |
|---|---|
| RaptureScript |
Defines a script used to run a Rapture job.
| Field | Type |
|---|---|
| name | String |
| script | String |
| language | RaptureScriptLanguage |
| purpose | RaptureScriptPurpose |
| authority | String |
| parameters | List(RaptureParameter) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
String retVal = scriptApi.runScript(scriptURI, parameters);retVal = baseAPI.doScript_RunScript(scriptURI, parameters);Entitlement: /script/exec/$f(scriptURI)
Run a script in the Rapture environment.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| parameters | Map<String,String> |
| Type | Description |
|---|---|
| String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
ScriptResult retVal = scriptApi.runScriptExtended(scriptURI, parameters);retVal = baseAPI.doScript_RunScriptExtended(scriptURI, parameters);Entitlement: /script/exec/$f(scriptURI)
Runs a script in the Rapture environment.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String | |
| parameters | Map<String,String> |
| Type | Description |
|---|---|
| ScriptResult |
Returns the variable name and output of a given script.
| Field | Type |
|---|---|
| returnValue | String |
| output | List(String) |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
String retVal = scriptApi.checkScript(scriptURI);retVal = baseAPI.doScript_CheckScript(scriptURI);Entitlement: /script/read/$f(scriptURI)
Parses the script and returns any error messages from the parsing process. If the String returned is empty the script is valid Reflex.
| Parameter | Type | Description |
|---|---|---|
| scriptURI | String |
| Type | Description |
|---|---|
| String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
String retVal = scriptApi.createREPLSession();retVal = baseAPI.doScript_CreateREPLSession();Entitlement: /script/exec
Creates a Reflex REPL session that can be written to. These sessions eventually die if not used or killed
This function takes no parameters.
| Type | Description |
|---|---|
| String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.destroyREPLSession(sessionId);retVal = baseAPI.doScript_DestroyREPLSession(sessionId);Entitlement: /script/exec
Kills an existing Reflex REPL session.
| Parameter | Type | Description |
|---|---|---|
| sessionId | String |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
String retVal = scriptApi.evaluateREPL(sessionId, line);retVal = baseAPI.doScript_EvaluateREPL(sessionId, line);Entitlement: /script/exec
Adds a line to the current Reflex session, returns back what the parser/evaluator says
| Parameter | Type | Description |
|---|---|---|
| sessionId | String | |
| line | String |
| Type | Description |
|---|---|
| String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.archiveOldREPLSessions(ageInMinutes);retVal = baseAPI.doScript_ArchiveOldREPLSessions(ageInMinutes);Entitlement: /admin/script
Archive/delete old REPL sessions
| Parameter | Type | Description |
|---|---|---|
| ageInMinutes | Long |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureSnippet retVal = scriptApi.createSnippet(snippetURI, snippet);retVal = baseAPI.doScript_CreateSnippet(snippetURI, snippet);Entitlement: /admin/snippet
Creates a code snippet and stores it in Rapture.
| Parameter | Type | Description |
|---|---|---|
| snippetURI | String | |
| snippet | String |
| Type | Description |
|---|---|
| RaptureSnippet |
Defines a portion of a Rapture script.
| Field | Type |
|---|---|
| name | String |
| authority | String |
| snippet | String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
List<RaptureFolderInfo> retVal = scriptApi.getSnippetChildren(prefix);retVal = baseAPI.doScript_GetSnippetChildren(prefix);Entitlement: /admin/snippet
Returns all children snippets with a given prefix.
| Parameter | Type | Description |
|---|---|---|
| prefix | String |
| Type | Description |
|---|---|
| List |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.deleteSnippet(snippetURI);retVal = baseAPI.doScript_DeleteSnippet(snippetURI);Entitlement: /admin/snippet
Deletes a snippet by its URI.
| Parameter | Type | Description |
|---|---|---|
| snippetURI | String |
| Type | Description |
|---|---|
| void |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureSnippet retVal = scriptApi.getSnippet(snippetURI);retVal = baseAPI.doScript_GetSnippet(snippetURI);Entitlement: /admin/snippet
Retrieves a snippet by its URI.
| Parameter | Type | Description |
|---|---|---|
| snippetURI | String |
| Type | Description |
|---|---|
| RaptureSnippet |
Defines a portion of a Rapture script.
| Field | Type |
|---|---|
| name | String |
| authority | String |
| snippet | String |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
Map<String,RaptureFolderInfo> retVal = scriptApi.listScriptsByUriPrefix(uriPrefix, depth);retVal = baseAPI.doScript_ListScriptsByUriPrefix(uriPrefix, depth);Entitlement: /script/read/$f(uriPrefix)
Returns full pathnames for an entire subtree as a map of path to RFI.
| Parameter | Type | Description |
|---|---|---|
| uriPrefix | String | |
| depth | int |
| Type | Description |
|---|---|
| Map<String,RaptureFolderInfo> |
HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
List<String> retVal = scriptApi.deleteScriptsByUriPrefix(uriPrefix);retVal = baseAPI.doScript_DeleteScriptsByUriPrefix(uriPrefix);Entitlement: /script/write/$f(uriPrefix)
Removes a folder and its contents recursively, including empty subfolders. Returns a list of the scripts and folders removed.
| Parameter | Type | Description |
|---|---|---|
| uriPrefix | String |
| Type | Description |
|---|---|
| List |