API script - RapturePlatform/Rapture GitHub Wiki

Script API

The Scripting API is used to define and manage Reflex scripts that are used within Rapture.

createScript

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.

Function Parameters

Parameter Type Description
scriptURI String
language RaptureScriptLanguage
purpose RaptureScriptPurpose
script String

Return value

Type Description
RaptureScript
Types used in this function

RaptureScriptLanguage

One of the scripting languages compatible with Rapture.

Field Type
REFLEX String

RaptureScriptPurpose

Describes the script's functionality.

Field Type
INDEXGENERATOR String
MAP String
FILTER String
OPERATION String
PROGRAM String
LINK String

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)

createScriptLink

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.

Function Parameters

Parameter Type Description
fromScriptURI String
toScriptURI String

Return value

Type Description
void

removeScriptLink

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.

Function Parameters

Parameter Type Description
fromScriptURI String

Return value

Type Description
void

setScriptParameters

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.

Function Parameters

Parameter Type Description
scriptURI String
parameters List

Return value

Type Description
RaptureScript
Types used in this function

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)

doesScriptExist

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.

Function Parameters

Parameter Type Description
scriptURI String

Return value

Type Description
boolean

deleteScript

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.

Function Parameters

Parameter Type Description
scriptURI String

Return value

Type Description
void

getScriptNames

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.

Function Parameters

Parameter Type Description
scriptURI String

Return value

Type Description
List

getScript

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.

Function Parameters

Parameter Type Description
scriptURI String

Return value

Type Description
RaptureScript
Types used in this function

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)

putScript

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.

Function Parameters

Parameter Type Description
scriptURI String
script RaptureScript

Return value

Type Description
RaptureScript
Types used in this function

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)

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)

putRawScript

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.

Function Parameters

Parameter Type Description
scriptURI String
content String
language String
purpose String
param_types List
param_names List

Return value

Type Description
RaptureScript
Types used in this function

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)

runScript

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.

Function Parameters

Parameter Type Description
scriptURI String
parameters Map<String,String>

Return value

Type Description
String

runScriptExtended

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.

Function Parameters

Parameter Type Description
scriptURI String
parameters Map<String,String>

Return value

Type Description
ScriptResult
Types used in this function

ScriptResult

Returns the variable name and output of a given script.

Field Type
returnValue String
output List(String)

checkScript

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.

Function Parameters

Parameter Type Description
scriptURI String

Return value

Type Description
String

createREPLSession

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

Function Parameters

This function takes no parameters.

Return value

Type Description
String

destroyREPLSession

HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.destroyREPLSession(sessionId);
retVal = baseAPI.doScript_DestroyREPLSession(sessionId);

Entitlement: /script/exec

Kills an existing Reflex REPL session.

Function Parameters

Parameter Type Description
sessionId String

Return value

Type Description
void

evaluateREPL

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

Function Parameters

Parameter Type Description
sessionId String
line String

Return value

Type Description
String

archiveOldREPLSessions

HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.archiveOldREPLSessions(ageInMinutes);
retVal = baseAPI.doScript_ArchiveOldREPLSessions(ageInMinutes);

Entitlement: /admin/script

Archive/delete old REPL sessions

Function Parameters

Parameter Type Description
ageInMinutes Long

Return value

Type Description
void

createSnippet

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.

Function Parameters

Parameter Type Description
snippetURI String
snippet String

Return value

Type Description
RaptureSnippet
Types used in this function

RaptureSnippet

Defines a portion of a Rapture script.

Field Type
name String
authority String
snippet String

getSnippetChildren

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.

Function Parameters

Parameter Type Description
prefix String

Return value

Type Description
List

deleteSnippet

HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
void retVal = scriptApi.deleteSnippet(snippetURI);
retVal = baseAPI.doScript_DeleteSnippet(snippetURI);

Entitlement: /admin/snippet

Deletes a snippet by its URI.

Function Parameters

Parameter Type Description
snippetURI String

Return value

Type Description
void

getSnippet

HttpScriptApi scriptApi = new HttpScriptApi(loginApi);
RaptureSnippet retVal = scriptApi.getSnippet(snippetURI);
retVal = baseAPI.doScript_GetSnippet(snippetURI);

Entitlement: /admin/snippet

Retrieves a snippet by its URI.

Function Parameters

Parameter Type Description
snippetURI String

Return value

Type Description
RaptureSnippet
Types used in this function

RaptureSnippet

Defines a portion of a Rapture script.

Field Type
name String
authority String
snippet String

listScriptsByUriPrefix

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.

Function Parameters

Parameter Type Description
uriPrefix String
depth int

Return value

Type Description
Map<String,RaptureFolderInfo>

deleteScriptsByUriPrefix

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.

Function Parameters

Parameter Type Description
uriPrefix String

Return value

Type Description
List
⚠️ **GitHub.com Fallback** ⚠️