Akumen Integration

Akumen Javascript API

Akumen API documentation is available by accessing the Cog in Akumen, then clicking Help, API Docs. A limited number of “convenience” functions have been created to reduce the time taken to create pages in Akumen, documented below.

Variables

Name Description
apiToken The api token key used to provide access to the Akumen API. Key is set based on the currently logged in user, not the user that created this page.
userName The currently logged in user, which can be used for some notification interactions
clientName The current client name, which can be used to automate API calls when switching between clients in the same Akumen instance

There is a javascript dictionary available with the Page configuration (set through properties) called configuration. For example, if the scenario configuration is set to {"test":"test"}, use javascript to get configuration["test"]

To support linking a “templated” external page to an application (with a selected application), there are some configuration parameters available, set through the properties of the page

{
    "ModelName": "Python Application",
    "ShowInModelBuilder": "true/false", // Shows as a link at the top of the model builder
    "ParameterConfiguration": {
         "tabular": { // The name of the parameter to apply page specific settings for
             "name": "Tabular Item", // An override for the parameter name
             "visible": "true/false", // Whether or not to show this input parameter on the page, by default all are shown
             "scope": "Model/Study/Scenario", // The scope of the parameter, ie at Model level, changing the parameter will affect all scenarios.  The default is Scenario
             "type": "spreadsheet" OR "fileupload" OR "inputs", only applicable to tabular inputs
             "name_column": "A", // Used when type = inputs - Becomes the name of the parameter, only applicable to tabular inputs
             "description_column": "B", // Used when type = inputs - Becomes the tooltip of the parameter, only applicable to tabular inputs
             "value_column": "C", // Used when type = inputs - Becomes the type of the parameter, only applicable to tabular inputs
             "value_type_column": "D", // Used when type = inputs - Can be int, float, string, date - The type of input to show, only applicable to tabular inputs
             "highlightEdits": "true/false", // When editing tabular, any changes by the user highlight the cell, which is then saved
         }
     },
     "ShowInAppBuilder": true // Optional flag indicating whether or not to show as a link at the top of the app builder,
     "Minimal": true/false // Optional flag indicating that this page is to run in minimal mode (no libraries are loaded - they must be done by the developer),
     "JSLibraries": [] // An array of javascript library urls to include - they will be rendered prior to your page loading as `<script src="url"></script>`
     "CSSLibraries": [] // An array of css libary urls to include - they will be rendered prior to your page loading as `<link rel="stylesheet" href="url" />`
}

General API Functions

akumenApi(apiPath, type, data, callbackFunction, errorCallbackFunction, api_version)

Constructs an AJAX call to the Akumen API, optionally executing the callback function with any returned data

  • apiPath - The path to the API, eg models/modelname
  • type - The AJAX type, eg GET, POST, DELETE
  • data - A JSON representation of the data
  • callbackFunction - The callback function to execute on a successful API call
  • api_version - The akumen api version to use, defaults to v1, options are v1 or v2

akumenFetchApi(apiPath, type, data, callbackFunction, errorCallbackFunction, api_version)

Constructs a fetch api call to the Akumen API, optionally executing the callback function with any returned data

  • apiPath - The path to the API, eg models/modelname
  • type - The type, eg GET, POST, DELETE
  • data - A JSON representation of the data
  • callbackFunction - The callback function to execute on a successful API call
  • api_version - The akumen api version to use, defaults to v1, options are v1 or v2

In addition to the above call to access the API, there are a number of “convenience” functions to provide easy access to Akumen"s API. All support a callbackFunction in the event of a successful API call. For each of the calls below there is the base call, and a fetch api call, just append Fetch to the function name For example, getModel would also have a getModelFetch call.

getModel(modelName, callbackFunction, errorCallbackFunction)

Gets an Akumen model by name, including it"s studies, scenarios and parameters

getStudy(modelName, studyName, callbackFunction, errorCallbackFunction)

Gets an Akumen study by name including it"s scenario

getScenario(modelName, studyName, scenarioName callbackFunction, errorCallbackFunction)

Gets an Akumen scenario by name

getInputParameters(modelName, studyName, scenarioName, callbackFunction, errorCallbackFunction)

Gets all the input parameters associated with a particular scenario

saveInputParameters(modelName, studyName, scenarioName, inputParameters, callbackFunction, scope, reset_run_status, errorCallbackFunction)

Save the array of input parameters, optionally setting the scope and resetting the run status.

saveInputParameter(modelName, studyName, scenarioName, inputParameter, callbackFunction, scope, reset_run_status, errorCallbackFunction)

Save an individual input parameter, optionally setting the scope and resetting the run status.

cloneStudy(modelName, studyName, callbackFunction, errorCallbackFunction)

Clones a study, including all it"s scenarios, inputs etc

deleteStudy(modelName, studyName, callbackFunction, errorCallbackFunction)

Deletes a study and all of it"s related data

cloneScenario(modelName, studyName, scenarioName, callbackFunction, errorCallbackFunction)

Clones a scenario, and all of it"s inputs

deleteScenario(modelName, studyName, scenarioName, callbackFunction, errorCallbackFunction)

Deletes a scenario and all of it"s related data

createRequiredFieldValidator(container, message)

Creates an instance of a required field validator, attached to the container jquery object. Also sets the message

executeStudy(modelName, studyName, scenarioNames)

Executes a given study in a model, optionally passing in a list of scenarios that can be executed within the study

execute(modelName, inputParameters, callbackFunction)

Executes a model with the given list of inputParameters

getViews(modelName, callbackFunction, errorCallbackFunction)

Get the views created as part of an R or Python execution

getResults(modelName, studyName, viewName, query, sorts, fields, callbackFunction)

Gets the results for the study and view, passing through the appropriate query, sorts and fields.

  • Query is a string using SQL syntax (eg ScenarioName like “%Scen%”), can be empty
  • Sorts is an array of objects where each object is in the following format { “column_name”: “string”, “direction”: “string” }, can be empty, and will use a default sort
  • Fields is an array of fields to return from the dataset, can be empty

getOutputs(modelName, studyName, scenarioName, callbackFunction)

Gets Akumen internal outputs for the given scenario, such as those available in Akumen Internal Reporting

getRoles(callbackFunction, errorCallbackFunction)

Gets the list of rolenames the user belongs to. This allows the page developer to customise the page based on role name.

There are additional html functions to be able to attach additional HTML and Image files to the page

attachHtmlToDiv(filePath, div)

  • filePath - The path to the file in the editing treeview
  • div - The id of the div element to insert the contents of the html file into

attachImageToDiv(filePath, div)

  • filePath - The path to the file in the editing treeview
  • div - The id of the div to attach the image to

Popup notifications popup a small notification in the bottom right corner

NotifyPopupDefault(message)

NotifyPopupSuccess(message)

NotifyPopupError(message)

NotifyPopupWarning(message)

progressIndicator(state)

Displays a progress indicator on the screen. Must be turned on by passing in true, and off by passing in false after asynchronous calls have completed

Akumen Notifications

Akumen provides a number of notifications that can be subscribed to, using the function below.

subscribeToEvent(eventName, callbackFunction)

Subscribes to one of Akumen"s notifications

  • eventName - The name of the event
  • callbackFunction - The callback function to execute if an event is fired

Additionally, a number of “convenience” notification functions are available to subscribe to. These require access to the ModelId, which can be fetched using the getModel(…) API call

subscribeToStudyExecutionCommenced(modelId, callbackFunction)

Occurs when execution of a study in the model commences. Returns the StudyId of the study that was commenced

subscribeToStudyExecutionComplete(modelId, callbackFunction)

Occurs when execution of a study in the model completes. Returns the StudyId of the study that was completed

subscribeToScenarioCollectionChange(modelId, callbackFunction)

Occurs when the scenario/study collection of a model is changed (eg new scenarios, scenarios updated etc)

subscribeToGeneralMessage(modelId, callbackFunction)

Occurs when a general message from execution of a model occurs

subscribeToGeneralError(modelId, callbackFunction)

Occurs when a general error occurs during execution

subscribeToInputParameterChange(modelId, callbackFunction)

Occurs when a change is made to input parameters for a model

subscribeToDatabaseTableInserted(table, callbackFunction)

Occurs when data is inserted via API call to the specified table

subscribeToDatabaseTableUpdated(table, callbackFunction)

Occurs when data is updated via API call in the specified table

subscribeToDatabaseTableDeleted(table, callbackFunction)

Occurs when data is deleted via API call from the specified table