Skip to content

restaflib introduction

Deva Kumar edited this page Aug 3, 2020 · 7 revisions

restaflib

restaflib is a helper library built on top of restaf to simplify very common scenarios.

  • Executing single cas actions
  • Scripting multiple cas actions on the CAS server using casl
  • Scoring with a model in a CAS server
  • Scoring with a model published to a CAS destination
  • Scoring with a model published to MAS(MicroAnalytic Service)
  • Browsing thru a CAS Table
  • Executing a SAS program using compute Service and retrieving the results.
  • Upload data to CAS

These scenarios are discussed in this section.

casActionRun ⇒ object

Calls cas server and returns the results(async)

Returns: object - returns results from cas

Param Type Description
store object restaf store
session object cas session
parameters object parameters for the action

casFetchData ⇒ object

Fetch rows from cas Tables

Returns: object - see doc. {pagination: {prev: pagePrev, next: pageNext, count: count}, data: {schema: co The prev and next are as follows: Either it is -1 to indicate EOF or a number to start the next obs no to start the fetc from

Param Type Description
store object restaf store
session object cas session
table object table {caslib: x, name: y} to read from
control object what to read {from: n, count:n , format: true

caslRunBase ⇒ object

Calls cas server and returns the results(async)

Returns: object - returns results from cas

Param Type Description
store object restaf store
session object cas session
src object casl src statements
args object user input args

caslRunBase ⇒ object

Calls cas server and returns the results(async)

Returns: object - standard return value from apiCall

Param Type Description
store object restaf store
session object cas session
src object casl src statements
args object arguments to pass to on to CAS as args

caslScore ⇒ object

Score data in casl

Returns: object - returns the scores as an object

Param Type Description
store object restaf store
session object cas session
scenario object scenario values

casSetup ⇒ object

Calls cas server and returns the results(async)

Returns: object - returns an object {session: xxx, servers: yyy}

Param Type Description
store object restaf store
logonPayload object if not null, then use this logon to Viya

casUpload⇒ object

Calls cas server and returns the results(async)

Returns: object - returns an object {session: xxx, servers: yyy}

Param Type Description
store object restaf store
session object cas session
source string path to source data
output string caslib.name
save boolean if true save data, default is false
altSrc string string(text or binary) with data to be uploaded

casTableToJson ⇒ object

Converts a cas table to JSON

Returns: object - - the new json version

Param Type Description
result object the raf object retrned from a call to cas
table string the name of the table

computeFetchData ⇒ object

Fetch data from a SAS Table

Returns: object - - {columns: , rows: , scrollOptions: }

Param Type Description
store object restaf store
computeSummary object Summary object created by computeSummary method
table string name of the table
direction string null

computeResults ⇒ object | string

Return Log|listing|ODS|list of tables in the compute service job

Returns: object | string - - string for all except tables(array)

Param Type Description
store object restaf store
computeSummary object computeSummary object
type string type of result( log

computeRun ⇒ object

Prepare data for runCompute(@async)

Returns: object - computeSummary object

Param Type Description
store object restaf store
session object current compute service session
src string code to execute
args object args to be passed on as macros

computeRunBase ⇒ object

Reduce compute service to an consummable form(async)

Returns: object - computeSummary Object

Param Type Description
store object restaf store
session object compute service session
code code SAS code to be executed

computeSetup ⇒ object

Setup access to compute service

Returns: object - - returns a compute session

Param Type Description
store object restaf store
contextName string name of the context( if null the first context in the list is used)
payload object logon payload - If null assumes that logon was done earlier.

computeSummary ⇒ object

Reduce the job information into consummable form(async)

Returns: object - - the computeSummary object for easy handling of logs,listing,ods, tables

Param Type Description
store object restaf store
job object rafObject representing the compute service job

findReport ⇒ object

Search for a named report(async)

Returns: object - - either null or rafObject for the report

Param Type Description
store object restaf store
name string name of the VA report

getReportImage ⇒ string

Return the svg of the specified report(async)

Returns: string - - the svg of the report

Param Type Description
store object restaf store
name string name of the report

getReportUrl ⇒ string

Generate url for report(async)

Returns: string - url for the report

Param Type Description
store object restaf store
name string name of report

getSASTableRows ⇒ object

Convert table to object of the form {var1: value, var2: value,...},....

Returns: object - - resulting json

Param Type Description
store object restaf store
computeSummary object computeSummary
tableName string name of the table

jsonToDict ⇒ string

Produce a string with casl dictionary suitable for inclusion in casl code

Returns: string - returns the string containing the casl dictionary

Param Type Description
obj object the JS object of interest
name string the name to assign to the dictionary

Example

obj = {x: 1, b:2, c: ['a','b']};
 name ='_appEnv_';
 result is a string _appEnv_ = {x=2, b=3, c={"a', "b"}}

masRun ⇒ object

Score using MAS

Returns: object - - return results {name: value, name: value}

Param Type Description
store object store
masControl object object from masSetup
modelName string name of model to be executed
stepName string if not specified it will default to the first step

masSetup ⇒ object

setup access to MAS

Returns: object - - masControl used in masRun

Param Type Description
store object restaf store
models object an array of model names
logonPayload object restaf logon payload(set to null if already authenticated)
Clone this wiki locally