Trillo Workbench Java SDK

Introduction

This document describes Java APIs for writing serverless functions. This document uses class and table for the same concept.

Terminology

Trillo data layer is designed to be generic and independent of the type of database such as relational, document, graph, etc. Therefore, some of the API use generic terms from UML (Unified Modelling Language). In the context of particular database technology, a UML concept may not support all the features for simplicity. The following table describes the mapping of common terms (they may be used interchangeably).

Equivalent Terms Concept
data source It corresponds to a database.Trillo workbench creates two default data sources common and vault.The corresponding database names are cloud_common and cloud_vault.
table,class,collection Represents a structure with attributes.In a relational DB,it is a table.
column,attribute A column of a table,an attribute of a class,a property of an object,etc.
association,relation Relationship between tables or association between classes.
object,record An instance of a class or a database record.
The following note is very important for the use of API.

When you create a class (using Trillo Workbench), it corresponds to a DB table. The table name is by default _tbl (i.e. the name of class suffixed by _tbl).

In APIs, the className is used as parameter.

Schema

If the database type is Microsoft SQL or Postgres, Trillo Workbench permits creation of schema under data source. Its logical-name is a valid identifier. Like - data source, the logical name may be different than name in the database.

Class

A class corresponds to a table. It is created under a data source (MySQL) or schema (Postgres, Microsoft SQL). Its logical-name is a valid identifier. Like data - source, the logical name may be different than name in the database.

Similarly, the term attribute is used for a column.

Fully Qualified Names

Trillo Workbench API uses name of data source, schema and class name in APIs. Since two different databases can have a table with the same name. The class name needs to be fully qualified name in APIs. A fully qualified class name is give by dot (.) notation as follows.

...

Example 1, shared.finance.finance schema.Invoice: Invoice table of finance schema of finance data source. (Postgres and Microsoft SQL).

Example 2, shared.common.Audit log: Audit log table of common data source (MySql)

The following 3 APIs can be used to extract application name, data source name, class name.

Default Databases

Trillo Workbench by default provisions Cloud SQL in Google Cloud (MySQL). It uses it for storing data, metadata. It can also used for the new tables. By default it creates the following two databases:

Result Class

Several Trillo Workbench APIs return object of a class Result. The actual API response is wrapped inside it. It is useful since, in case of error its status can indicate failure and its other attributes have details of failure. There are a few APIs that return the response directly (without wrapping in Result).

  1. data: this is the actual response of API. In case of success it contains a valid JSON (object or list).

  2. _rtag: It is always set to r. Its presence can be used to infer that the response if of Result type.

public class Result {
  public static final String SUCCESS = "success";
  public static final String FAILED = "failed";
  public static final String UNKNOWN = "unknown";
  private String status = UNKNOWN; // see other values above
  private String message = null; // error or success message
  private Map props = null; // functions may use for
more info
  private Object data = null; // In case of success it is the actual
value of API
  private int code = 0; // HTTP code when applicable
  private String _rtag = "_r_"; // a flag indicating result object
(useful for JS)
  private boolean failed = false; // true if failed else false
  private boolean success = true; // true if success else false
}
"failed" and "success" are redundant. They are provided for
convenience.

Sample Example

The sample application used for the lesson is an order management application.

The following are the main classes/tables of the application.

  1. Customer: A custom in the order management system.

  2. Order: A customerʼs order.

  3. Line item: Items included in the order.

  4. Customer to Order is 1 to many.

  5. Order to Line item is 1 to many.

In addition to these, we will refer to several classes provided by Trillo Workbench (called System classes).

  1. User

  2. Folder

  3. File

BaseApi (Basic APIs)

as json pretty string

Convert a map object to a json formatted string.

BaseApi.as json pretty string(Object obj)
Parameters
obj:   the object (can be a hashmap)
Sample Code
Map product = new HashMap<>();
product.put("productId", "11");
String strJson = BaseApi.as json pretty string(product);
Returns
the formatted string

as json string

Convert map object to a json string without formatting.

BaseApi.as json string(Object obj)
Parameters
obj:  object
Sample Code
Map product = new HashMap<>();
product.put("productId", "11");
String strJson = BaseApi.as json string(product);
Returns
the json string

from json string

Convert a json string to a map object.

BaseApi.from json string(String json)
Parameters
json:     string representation of json
Sample Code
String json string = "{\n" +
      "    \"productId\": \"abc\"\n" +
      "}";
Map map = BaseApi.from json string(json string);
Returns
constructed hashmap

from json string as array

Convert a json string as a linked hashmap. The map can be interpreted later on.

BaseApi.from json string as array(String json)
Parameters
json:    string representation of json
Sample Code
String json string = "[\n" +
      "    {\n" +
      "    \"product\": \"abc\"\n" +
      "    }\n" +
      "]";
List> mapList =
BaseApi.from json string as array(json string);
Returns
the array of json objects

read json

Read the JSON from a file name located in a specific directory. It is converted into an map object.

BaseApi.read json(String dir, String fileName)
Parameters
dir:    the directory
fileName:  name of the file
Sample Code
Map map = BaseApi.read json("/tmp/folder1",
"file.json");
Returns
json document object

write json

Write a map object into a file located on a specific directory.
BaseApi.write json(String dir, String fileName, Object obj)
Parameters
dir:         directory
fileName:    name of the file
obj:         json document object
Sample Code
    String json string = "[\n" +
      "    {\n" +
      "    \"product\": \"abc\"\n" +
      "    }\n" +
      "]";
    BaseApi.write json("/tmp/folder1", "file.json", json string);
Returns
result of the operation

write pretty json

Write a map object into a file located on a specific directory. The JSON information is a formatted inside the file.

BaseApi.write pretty json(String dir, String fileName, Object obj)
Parameters
dir:          directory
fileName:     name of the file
obj:          json formatted document
Sample Code
    String json string = "[\n" +
      "    {\n" +
      "    \"product\": \"abc\"\n" +
      "    }\n" +
      "]";
    BaseApi.write pretty json("/tmp/folder1", "file.json", json string);
Returns
result of the operation

success result

Build and return a successful result map object.

BaseApi.success result()
or
BaseApi.success result(String msg)
or
BaseApi.success result(String msg, Object data)
Parameters
msg        message to be sent
data
Sample Code
BaseApi.success result("Successfully added records");
Returns
result of the operation

error result

Build and return an error result map object.
BaseApi.error result(String msg)
or
BaseApi.error result(String msg, int code)
Parameters
msg:     message to be sent
code:    return code
Sample Code
BaseApi.error result("Failed to process records");
Returns
the result of the operation

extract message

Extract the message from the result object . The result object has a detailed message in it therefore it will be returned.

BaseApi.extract message(Object obj)
Parameters
obj:     object as a hashmap
Returns
message string

is result

Checking whether the object is a result object .

BaseApi.is result(Object obj)
Parameters
obj:    the object as a hashmap
Sample Code
Result res = Result.get success result("success");
boolean is result = BaseApi.is result(res);
Returns
status of the result

is result or null

Checking if result object is a valid one or a just a NuLL

BaseApi.is result or null(Object obj)
Parameters
obj:    the object as a hashmap
Sample Code
Result res = Result.get success result("success");
boolean is result = BaseApi.is result or null(res);
Returns
the status of the result

UUID

Generate a UUID sequence.

BaseApi.UUID()
Parameters
none
Sample Code
String uuid = BaseApi.UUID();
Returns
the uuid

uid to classname

Extract class name from an input string.

BaseApi.uid to classname(String uid)
Parameters
uid:    the className id
Returns
the class name

uidToId

Extract an long id number from a string UID.

BaseApi.uidToId(String uid)
Parameters
uid:
Returns
gives id

uid to id str

Retrieves the ID as a string from uid.

BaseApi.uid to id str(String uid)
Parameters
uid:
Returns
gives id in str

wait for millis

Wait for certain MS given as a long number. It is a blocking function call.

BaseApi.wait for millis(long tm)
Parameters
tm:
Sample Code
Result res = BaseApi.wait for millis(10);
Returns
waits for given time

remote call

// Basic Description //

Parameters
java class name
java methodname
Sample Code
Object res = remote call("DSApi", "get", "shared.common.product", "12);
Returns
execute the call

remote callas result

// Description //
BaseApi.remote callas result(String java class name, String java methodname,
Object... args)
Parameters
java class name
java methodname
Sample Code
Result res = remote callas result("Big query api", "executeQuery", "SELECT
ID FROM product_tbl");
Returns
// Some code

remote callas map

// Description //

BaseApi.remote callas map(String java class name, String java methodname,
Object... args)
Parameters
java class name
java methodname
Sample Code
Map res =  remote callas map("UMApi", "get current user");
Returns
// Some code

remote callas string

// Description //
BaseApi.remote callas string(String java class name, String java methodname,
Object... args)
Parameters
java class name
java methodname
Sample Code
String res = remote callas string("GCP rest api", "get project id");
Returns
// Some code

remote callas list

// Description //
BaseApi.remote callas list(String java class name, String java methodname,
Object... args)
Parameters
java class name
java methodname
Returns
// Some code

remote callas list of maps

// Description //
BaseApi.remote callas list of maps(String java class name, String
java methodname, Object... args)
Parameters
java class name
java methodname
Returns
// Some code

LogApi (Logging APIs)

set loglevel

Sets the log level. The valid values are debug, info(default), warning or error

LogApi.set loglevel(String logLevel)
Parameters
logLevel:    level
Returns
result of operation

disable audit log

Disables the audit log, which is used for logging to Trillo DB. By default it is enabled

LogApi.disable audit log()
Parameters
none
Returns
result of the operation

enable audit log

Enables the audit log. This is the default option and is used for logging into Trillo DB. Helps in isolating errors per task

LogApi.enable audit log()
Parameters
none
Returns
result of the operation

disable logs collection

Disable log collections for the thread. Logs are collected for ac all and sent back to the client in the result. This is useful in debugging. By default it is disabled

LogApi.disable logs collection()
Parameters
none
Returns
result of the operation

enable logs collection

Enable log collections for the thread

LogApi.enable logs collection()
Parameters
none
Returns
result of the operation

log debug

logging of the debug and verbose messages.

LogApi.log debug(String msg)
Parameters
msg:   message string
Returns
result of the operation

logInfo

logging an informational and occasional message .

LogApi. logInfo(String msg)
Parameters
msg:  message
Returns
result of the operation

logWarn

Provides a warning message

LogApi.logWarn(String msg)
Parameters
msg: message
Returns
result of the operation

log error

Provides an error message

LogApi.log error(String msg)
Parameters
msg: message
Returns
result of the operation

is loglevel on

Describes if the log level is on and returns a boolean.

LogApi.is loglevel on(String type)
Parameters
type:   type of the logging
Returns
result of the operation

audit log

Sends an audit message to the workbench. It can be viewed under the task logs.

LogApi.audit log(Map log object)
or
LogApi.audit log(String type, String summary, String ...args)
Parameters
Map: hashmap
log object: object representing hashmap
summary:  a sentence with tokens
...args: arguments to be replaced
type:  type of the log
Returns
result of the operation

_audit log

// Description //
LogApi._audit log(String type, String summary, String detail, String
json, String action, String source uid)
Parameters
summary
detail
json
action
source uid
Returns
// Some code

audit loginfo

This provides the information stored in the Audit log object which includes detailed log message, any associated json object, action and the parent id.

LogApi.audit loginfo(String summary, String ...args)
Parameters
summary: a sentence with tokens
...args:  the value of the tokens
Returns
result of the operation

audit log error

Provides information about the error in the Audit log object

LogApi.audit log error(String summary, String ...args)
Parameters
summary:
...args:
Returns

can audit log

For a given logging type, checks whether audit messages can be recorded

LogApi.can audit log(String type)
Parameters
type: logging type
Returns

log to console

Logs the appropriate messages to the console

LogApi.log to console(String type, String msg)

Parameters

type:
msg:
Returns

DSApi (Database APIs)

This section described database APIs. Each database API is a static method of a Java class called DSApi.

Some database APIs take a special parameter called audit msg. It is optional. It is used to create an audit-log of database operations. When it is provided its behavior is as follows:

Each database API is a static method of a special Java class called DSApi.

Primary Key

Each table created using Trillo Workbench creates the following columns. Each column except the id column is optional (can be removed). The column id is required for all newly created tables. Its type is BigInteger and it is auto-assigned by the database.

The list of columns (attributes assigned to the class) automatically created for a table is as follows:

Name Type Description
id BigInteger The primary key of record,auto-assigned
created at BigInteger The time of the creation ofthe record in UTC(epoch)
updated at BigInteger The time the record was updated last.
deleted Boolean Trillo APIs"delete"do not delete a record.They markthe record as deleted.APIsA flag to indicate this record is logically deleted.It will be opaque in all queries andAPI unless a special flag isused to included deleted items.
deleted at BigInteger The time the record was deleted.

Overview

Database and Order Management:
1. Customer:
2. Product:
3. Orders:

Retrieve APIs

This page describes different Java APIs to retrieve a record (also referred to as object) by primary key, queries.

In the following APIs description when the Result class object is returned, buy default it means the result of failed API invocation. If the Result returns success, it will be noted.

Get

Gets an object of the given class by its primary key (id).

DSApi.get(String className, String id)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
id: primary key (pass stringified value of the BigInteger/ long value)
Sample Code
//fetch product information from the product table
String className = "shared.common.product";
String id = "12";
Object res = DSApi.get(className, id);
Returns
If the object is found then it return a Java Map,
else Result with failed status and message.

query one - where clause (include deleted)

Gets an object of the given class by the condition provided in the where clause (constructed with the columns of the same table. For complex SQL queries, use the API with SQL query as a parameter). If multiple are found then the first is returned.

DSApi.query one(String className, String where clause)
or
DSApi.query one(String className, String where clause, boolean
include deleted)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
where clause: where-clause of the SQL query.
include deleted: consider records marked deleted if a value of 'true is
passed.
Sample Code
//fetch one product information from the product table using where
filter
String className = "shared.common.product";
String where clause = "prices is not null";
Boolean include deleted = true;
Object res = DSApi.query one(className, where clause);
Object res2 = DSApi.query one(className, where clause, include deleted);
Returns
If the object is found then it return a Java Map,
else Result.

- query one sqlQuery

Gets an object using SQL query. If multiple are found then the first is returned.

DSApi.query one(String sqlQuery)
Parameters
sqlQuery: SQL statement. In an SQL statement, actual table name is
specified
(it is typically _tbl). When in doubt, check it using the
workbench
API.
Sample Code
//fetch top 1 product information from the product table using query
String sqlQuery = "Select id, prices from product_tbl where prices is
not null";
Object res2 = DSApi.query one(String sqlQuery)
Returns
If the object is found then it return a Java Map,
else Result.

query many - where clause (include deleted)

Gets all objects of the given class by the condition provided in the where clause.

DSApi.query many(String className, String where clause)
or
DSApi.query many(String className, String where clause, boolean
include deleted)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
where clause: where-clause of the SQL query.
include deleted: consider records marked deleted if a value of 'true is
passed.
Sample Code
//fetch all product information from the product table using query
String className = "shared.common.product";
String where clause = "prices is not null";
Boolean include deleted = true;
Object res = DSApi.query many(className, where clause);
Object res2 = DSApi.query many(className, where clause, include deleted);
Returns
Returns a list of objects including zero length error.
If there is an error in the SQL object or any other system error,
Result object is returned.

query many (SQL)

Gets all objects returned by the SQL query. This API should be used when you expect the result to be small (up to a few thousand). For a larger data set, use the Data iterator.

DSApi.query many(String sqlQuery)
Parameters
sqlQuery: SQL statement.
Sample Code
//fetch many product information from the product table using query
String sqlQuery = "Select id, prices from product_tbl where prices is
not null";
Object res2 = DSApi.query many(String sqlQuery)
Returns
Returns a list of objects including zero length error.
If there is an error in the SQL object or any other system error,
Result object is returned.

tenant by name

Retrieve the tenant details by searching its name.
DSApi.tenant by name(String tenant name)
Parameters
tenant name: name of the tenant
Sample Code
//fetch tenant results based on tenant name
String tenant name = "";
Object res2 = DSApi.tenant by name(String tenant name)
Returns
the object representing the details

tenant by query

get the tenant details by executing a query.

DSApi.tenant by name(String query)
Parameters
query: query to be executed
Sample Code
//fetch results based on tenant name
String tenant name = "";
Object res2 = DSApi.tenant by name(String tenant name)
Returns
 tenant details

getUser

Returns user information by its ID

DSApi.getUser(String id)
Parameters
id: id of the user
Sample Code
//fetch user details using id of user
String id = "abc";
Object res = DSApi.getUser(String id)
Returns
user object

user by email

Returns the user information with associated email
DSApi.user by email(String email)
Parameters
email: email of the user
Sample Code
//fetch user details using email
String email = "abc@gmail.com";
Object res = DSApi.user by email(String email)

Returns

 user object

user by userid

Returns the user with the ID

DSApi.user by userid(String userId)
Parameters
userId:
Sample Code
//get user details using the userId
String userId = "{ID_OF_USER}";
Object res = DSApi.user by userid(String userId);
Returns
user object

value by key

Returns the value of the key associated with the provided type

DSApi.value by key(String key, String type)

Parameters

key:
type:
Sample Code
//fetch value associated with a provided type
String key = "{KEY}";
String type = "{TYPE}";
Object res = DSApi.value by key(key, type);
Returns
the object as a hashmap

Create and Update API

save

Saves the entity passed as input to the database

 DSApi.save(String className, Object entity)
 or
 DSApi.save(String className, Object entity, String audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
entity:
audit msg:
Sample Code
String className = "shared.common.product";
Map entity = new HashMap<>();
entity.put("product name", "table");
entity.put("description", "foldable table");
entity.put("prices", 620);
Object res = DSApi.save(className, entity);
Returns
If the object is found then it return a Java Map,
else Result with failed status and message.

save many

Saves the list of entities to the database
 DSApi.save many(String className, Iterable entities)
 or
 DSApi.save many(String className, Iterable entities, String
audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
entity:
Sample Code
String className = "shared.common.product";
ArrayList> entities = new ArrayList<>();
Map entity = new HashMap<>();
entity.put("product name", "table");
entity.put("description", "foldable table");
entity.put("price", 620);
entities.add(entity);
Object res = DSApi.save(className, entities);
Returns
If the object is found then it return a Java Map,
else Result with failed status and message.

Update

Updates the attribute name with the provided value

DSApi.update(String className, String id, String attrName, Object
value)
 or
DSApi.update(String className, String id, String attrName, Object
value, String audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
id:
attrName:
value:
audit msg:
Sample Code
String className = "shared.common.product";
String id = "12";
String attrName = "price";
Integer value = 700;
Object res = DSApi.update(className, id, attrName, value);
Returns

Update many

Update many records at a time. The class name is provided that indirectly represents a table.

DSApi.update many(String className, List ids, String attrName,
Object value)
or
DSApi.update many(String className, List ids, String attrName,
Object value, String audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
ids: rows needed to be modified
attrName: the name of the column
value:     the value of inside the column for the specific row
audit msg: any informational message
Sample Code
String className = "shared.common.product";
List ids = new ArrayList<>();
ids.add("12");
ids.add("15");
String attrName = "price";
Integer value = 700;
Object res = DSApi.update many(className, ids, attrName, value);
Returns

Update by query

Update by executing a query on the table. it takes partial query which is the embellished with where clauses.

DSApi.update by query(String className, String query, Map
update attrs)
or
DSApi.update by query(String className, String query, Map
update attrs, String audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
query:     represents the filtering criteria
update attrs:  update map for the attributes
audit msg:   informational message
Sample Code
String className = "shared.common.product";
Map update param = new HashMap<>();
update param.put("deleted", true);
Object res = DSApi.update by query(className, "", update param);
Returns

execute sql write statement

Execute a stored procedure or SQL string. The statement is prepared for execution. ' Use this method when you re specifying the full statement.

DSApi.execute sql write statement(String dsName, String sql statement,
      Map params)
Parameters
dsName:  the name of the data source
sql statement:  SQL String
params:  parameter values to be replaced inside the string
Returns
Success or Failed depending on the execution status of the statement

Delete APIs

delete

Delete a record from the table. It can be made permanent or temporary. A delete flag is updated when it is handled as temporary.

DSApi.delete(String className, String id, boolean permanent)
or
DSApi.delete(String className, String id, boolean permanent, String
audit msg)
Parameters
className: the name of the table
id:        the record number
permanent:   permanent or temporary
audit msg:    any message
Sample Code
    String className = "shared.common.product";
    boolean permanent = true;
    String id = "12";
    Object res = DSApi.delete(className, id, permanent);
Returns

delete many

Delete many records at a time. The list is provided which represents the record numbers .

DSApi.delete many(String className, Iterable ids, boolean
permanent)
or
DSApi.delete many(String className, Iterable ids, boolean
permanent, String audit msg)
Parameters
className: the name of the table
ids:        list of the regards
permanent:   either flagged or permanent
audit msg:    any message
Sample Code
    String className = "shared.common.product";
    boolean permanent = true;
    Iterable ids = Arrays.asList(new String[]{"12", "13"});
    Object res = DSApi.delete many(className, ids, permanent);
Returns

delete by query

Delete a record (s) by executing a query.

DSApi.delete by query(String className, String query, boolean permanent)
or
DSApi.delete by query(String className, String query, boolean permanent,
String audit msg)
Parameters
className: name of the table
query:     query
permanent: flagged or permanent
Sample Code
    String className = "shared.common.product";
    boolean permanent = true;
    String query = "Select first_name from product_tbl where
price>100";
    Object res = DSApi.delete by query(className, query, permanent);
Returns

Empty Table

empty table

Empty a specific table . All records are removed.

DSApi.empty table(String className)
or
DSApi.empty table(String className, String audit msg)
Parameters
className:  name of the table
audit msg:    any message
Sample Code
    String className = "shared.common.product";
    Object res = DSApi.empty table(className);
Return

Sample Functions Using API

Function - Add customer record.java

import com.collage r.trillo.pojo.Result;
import com.collage r.trillo.pojo.Script parameter;
import com.collage r.trillo.util.DSApi;
import com.collage r.trillo.util.Log gable;
import com.collage r.trillo.util.Trillo function;
import java.util.HashMap;
import java.util.Map;
public class Add customer record implements Log gable, Trillo function {
  public Object handle(Script parameter script parameter) {
    // do the implementation inside _handle()
    try {
      return _handle(script parameter);
    } catch (Exception e) {
      log().error("Failed", e);
      return Result.get failed result(e.get message());
    }
  }
  @Suppress warnings("unchecked")
  private Object _handle(Script parameter script parameter) {
    String className = "shared.common.customer";
    Map entity = new HashMap<>();
    entity.put("name", "Sam");
    entity.put("email", "sam@gmail.com");
    entity.put("address", "45, park view, NY");
    entity.put("phone number", "+16463704660");
    Object res = DSApi.save(className, entity);
    return res;
  }
}

Function - Update customer address.java

import com.collage r.trillo.pojo.Result;
import com.collage r.trillo.pojo.Script parameter;
import com.collage r.trillo.util.DSApi;
import com.collage r.trillo.util.Log gable;
import com.collage r.trillo.util.Trillo function;
public class Update customer address implements Log gable, Trillo function
{
  public Object handle(Script parameter script parameter) {
    // do the implementation inside _handle()
    try {
      return _handle(script parameter);
    } catch (Exception e) {
      log().error("Failed", e);
      return Result.get failed result(e.get message());
    }
  }
  @Suppress warnings("unchecked")
  private Object _handle(Script parameter script parameter) {
    String className = "shared.common.customer";
    String id = "1";
    String attrName = "address";
    String value = "7, woodland street, NY";
    Object res = DSApi.update(className, id, attrName, value);
    return res;
  }
}

FuncApi (Function APIs)

execute function

Execute a specific Trillo function by providing its parameters.

FuncApi.execute function(String function name, Map params)
or
FuncApi.execute function(String appName, String function name,
Map params)
parameters:
function name: name of the function
params:   hashmap representing the parameters
appName
Sample Code
Map function parameters = new Linked hashmap();

Returns:
object values returned by the called function

execute function with method

Description...

FuncApi.execute function with method(String function name, String
methodName,
Map params)
or
FuncApi.execute function with method(String appName, String function name,
String methodName,
Map params)
Parameters
function name
methodName
params
appName
Sample Code
Map function parameters = new Linked hashmap();

Returns
// Some code

execute ssh

Execute a remote ssh command on a server whose keys are known to the workbench. Generally the SSH server is a companion server of the workbench.

FuncApi.execute ssh(String hostName, String command)
or
FuncApi.execute ssh(String hostName, String command, boolean async)
or
FuncApi.execute ssh(String command, boolean async)
parameters:
hostName: the name of the companion server
command:   the command needed to be executed
async:     execute command immediately and wait or run it in the
background
Returns:
the result of the ssh command

ping task

Ping an asynchronous task by id and returns it's last time stamp

FuncApi.ping task(String id)
parameters:
id: task name
Sample Code

Returns:
the value of the timestamp

create task

Description...
FuncApi.create task(String task name, String task type, String
function name, Map params)
or
FuncApi.create task(String task name, String task type, String appName,
String function name,
Map params)
Parameters
task name
task type
function name
params
appName
Sample Code

Returns
// Some code

create task by source uid

Description...
FuncApi.create task by source uid(String task name, String task type, String
source uid, String function name,
Map params)
or
FuncApi.create task by source uid(String task name, String task type,
 String source uid, String appName, String function name, Map params)
Parameters
task name
task type
source uid
function name
params
appName
Sample Code

Returns
// Some code

TaskApi (Task APIs)

get task id

Description...

TaskApi.get task id()
Parameters
None
Returns
Task ID

cancel tasks

Description...

TaskApi.cancel tasks(List ids)
Parameters
ids
Returns
Cancels the tasks and returns status in the form of an Object

cancel task

Description...

TaskApi.cancel task(String taskId)
Parameters
taskId
Returns
Cancels the task

is my execution cancelled

Description...

TaskApi.is my execution cancelled()
Parameters
None
Returns
Boolean

is my flow cancelled

Description...

TaskApi.is my flow cancelled()
Parameters
None
Returns
Boolean

is my task cancelled

Description...

TaskApi.is my task cancelled()
Parameters
None
Returns
Boolean

is my task failed

Description...

TaskApi.is my task failed()
Parameters
None
Returns
Boolean

cancel remote request

Description...

TaskApi.cancel remote request(String requestId)
Parameters
requestId
Returns

None. Cancels the request for the provided Request ID

enqueue svc request

Description...

TaskApi.enqueue svc request(String queueId, String svcUrl, String
svc token,String service name, String callback function name, String
methodName, Map service request body,
      Map context)
Parameters
queueId
svcUrl
svc token
service name
callback function name
methodName
service request body
context
Returns
// Some code

Cache api (Memory Cache APIs)

Delete APIs

remove

Removes from the cache by providing the key.

Cache api.remove(String cache name, String key)
Parameters
cache name: name of the cache
key:       name of the identifier
Returns
 result object

remove no lock

Removes from the cache without locking it. The key is provided as an argument

Cache.remove no lock(String cache name, String key)
Parameters
cache name: name of the cache
key:       the identifier
Returns
 result object

clear

Description ...
Cache api.clear(String cache name)
Parameters
cache name
Returns
None

Create and Update API

put

update cache
Cache api.put(String cache name, String key, Object value)
Parameters
cache name
key
value
Returns
None

put no lock

update no lock

Cache.put no lock(String cache name, String key, Object value)
Parameters
cache name
key
value
Returns
None

publish message

Description...

Cache.publish message(String topic, String message)
Parameters
topic
message
Returns
long

Retrieve APIs

get memory cache

Get memory cache

Cache api.get memory cache()
Parameters
no parameters
Returns
In memory cache

get

Get cache by key

Cache api.get(String cache name, String key)
Parameters
cache name
key
Returns
Object

get no lock

Get No Lock
Cache.get no lock(String cache name, String key)
Parameters
cache name
key
Returns
Object

Storage api

get file path

Description...

Storage api.get file path(String fileId)
Parameters
fileId
Returns
The file path for the input File ID

get fileid by path

Description...

Storage api.get fileid by path(String absolute file path)
Parameters
absolute file path
Returns
The File ID using file path

get folder path

This API provides the folder path

Storage api.get folder path(String folder id)
Parameters
folder id
Returns
Folder path for the input folder ID

get signed url

Description...

Storage api.get signed url(String file path)
or
Storage api.get signed url(String file path, long duration, Time unit unit)
or
Storage api.get signed url(String bucket name, String file path)
or
Storage api.get signed url(String bucket name, String file path, long
duration, Time unit unit)
Parameters
file path
duration
unit
bucket name
Returns
String signed URL

copy file to bucket

Copy file to bucket

Storage api.copy file to bucket(String source file path, String
target file path)
or
Storage api.copy file to bucket(String bucket name, String source file path,
String target file path)
or
Storage api.copy file to bucket(String bucket name, String
service account propname,
      String source file path, String target file path)
Parameters
source file path
target file path
bucket name
service account propname
Returns
Result

copy file from bucket

Copy file from bucket

Storage api.copy file from bucket(String source file path, String
target file path)
or
Storage api.copy file from bucket(String bucket name, String source file path,
String target file path)
or
Storage api.copy file from bucket(String bucket name, String
service account propname,
      String source file path, String target file path)
Parameters
source file path
target file path
bucket name
service account propname
Returns
Result

copy file within bucket

Copy file to new location within bucket

Storage api.copy file within bucket(String source file path, String
target file path)
or
Storage api.copy file within bucket(String source file path, String
target file path, boolean make copy)
or
Storage api.copy file within bucket(String bucket name, String
source file path, String target file path)
or
Storage api.copy file within bucket(String bucket name, String
source file path, String target file path, boolean make copy)
Parameters
source file path
target file path
make copy
bucket name
Returns
Result

write to bucket

Write data to bucket

Storage api.write to bucket(byte[] bytes, String target file path, String
content type)
or
Storage api.write to bucket(String bucket name, byte[] bytes, String
target file path, String content type)
Parameters
bytes
target file path
content type
bucket name
Returns
Result

read from bucket

Read file from bucket

Storage api.read from bucket(String source file path)
or
Storage api.read from bucket(String bucket name, String source file path)
Parameters
source file path
bucket name
Returns
Result

list files

Get list of file names for the bucket folder.

Storage api.list files(String pathName, Boolean versioned)
or
Storage api.list files(String bucket name, String pathName, Boolean
versioned)
or
Storage api.list files(String bucket name, String pathName,
      Boolean versioned, String page token, Integer pageSize)
Parameters
pathName
versioned
bucket name
page token
pageSize
Returns
Result

save file object

Save file object

Storage api.save file object(Map file object)
Parameters
file object
Returns
Object

exists

Check if file exists.

Storage api.exists(String file path)
Parameters
file path
Returns
Boolean

get file list

Get list of files in folder

Storage api.get file list(long folder id, String orderBy)
Parameters
folder id
orderBy
Returns
List>

get files pages

Get files pages
Storage api.get files page(String bucket name, String pathName,
      Boolean versioned)
or
Storage api.get files page(String bucket name, String pathName,
                      Boolean versioned, String page token, Integer
pageSize)
Parameters
bucket name
pathName
versioned
page token
pageSize
Returns
Files page

get bucket name

Get default bucket name.

Storage api.get bucket name()
Parameters
None
Returns
String

share with tenants

Share with tenants

Storage api.share with tenants(Map params)
Parameters
params
Returns
Object

copy large file to bucket

copy large file to bucket

Storage api.copy large file to bucket(String source file path, String
target file path)
or
Storage api.copy large file to bucket(String bucket name, String
source file path,
      String target file path)
or
Storage api.copy large file to bucket((String bucket name, String
service account propname,
      String source file path, String target file path)
Parameters
source file path
target file path
bucket name
service account propname
Returns
Result

make public

make a file public

Storage api.make public(String bucket name, String file path)
or
Storage api.make public(String bucket name, String service account propname,
      String file path)
Parameters
bucket name
file path
service account propname
Returns
Result

get content

Get content of a doc

Storage api.get content(Map doc)
Parameters
doc
Returns
Object

get bucket path

Get bucket path using file object

Storage api.get bucket path(Map file object)
Parameters
file object
Returns
String

get bucket path

Get path using fileId

Storage api.get bucket path(String fileId)
Parameters
fileId
Returns
String

Call logger (Logging Level APIs)

is debug on

Checks if debug logging is enabled

Call logger.is debug on()
Parameters
None
Returns
boolean

setdebug level

Sets the debug logging level

Call logger.setdebug level(boolean debugOn)
Parameters
debugOn
Returns
// Some code

is info on

Checks if info logging is enabled

Call logger.is info on()
Parameters
None
Returns
boolean

set info level

Sets the info logging level

Call logger.set info level(boolean infoOn)
Parameters
infoOn
Returns
None

is warning on

Checks if warning logging is enabled

Call logger.is warning on()
Parameters
None
Returns
boolean

set warning level

Sets the warning logging level.

Call logger.set warning level(boolean warning on)
Parameters
warning on
Returns
None

is error on

Checks if error logging is enabled

Call logger.is error on()
Parameters
None
Returns
boolean

set errorlevel

Sets the error logging level

Call logger.set errorlevel(boolean errorOn)
Parameters
errorOn
Returns
None

a

Call logger.
Parameters

Returns
None

debug

Logs a debug message if debug logging is enabled

debug(String msg)
Parameters
msg
Returns
None

info

Logs an info message if info logging is enabled

Call logger.info(String msg)
Parameters
msg
Returns
None

warn

Logs an warning message if warning logging is enabled

Call logger.warn(String msg)
Parameters
msg
Returns
None

error

Logs an error message if error logging is enabled.

Call logger.error(String msg)
Parameters
msg
Returns
None

critical

Logs a critical message

Call logger.critical(String msg)
Parameters
msg
Returns
None

getLogs

Retrieves the list of logs

Call logger.getLogs()
Parameters
None
Returns
List

set loglevel

Sets the logging level based on a specified string

Call logger.set loglevel(String logLevel)
Parameters
logLevel
Returns
None

is collect call logs

Checks if call logs collection is enabled

Call logger.is collect call logs()
Parameters
None
Returns
boolean

set collect call logs

Sets the flag to enable or disable call logs collection

Call logger.set collect call logs(boolean collect call logs)
Parameters
collect call logs
Returns
None

Command api

run os cmd

Run OS command
Command api.run os cmd(List argList)
or
Command api.run os cmd(String command)
Parameters
argList
command
Returns
Result

OAuth1Api

get

Make a GET call
OAuth1Api.get(String client key, String client secret, String token,
String token secret, String realm, String restUtl)
or
OAuth1Api.get(String client key, String client secret, String token,
String token secret, String realm, String restUtl, Map
headers)
Parameters
client key
client secret
token
token secret
realm
restUtl
headers
Returns
Result

post

Make a POST call
OAuth1Api.post(String client key, String client secret, String token,
String token secret, String realm, String restUtl, Object body)
or
OAuth1Api.post(String client key, String client secret, String token,
String token secret, String realm, String restUtl, Object body,
Map headers)
Parameters
client key
client secret
token
token secret
realm
restUtl
body
headers
Returns
Result

post soap

Make a POST Soap call
OAuth1Api.post soap(String client key, String client secret, String token,
      String token secret, String realm, String url, String body)
or
OAuth1Api.post soap(String client key, String client secret, String token,
      String token secret, String realm, String url, String body,
Map headers)
Parameters
client key
client secret
token
token secret
realm
url
body
headers
Returns
Result

post soap as xml

Make a POST Soap as XML call
OAuth1Api.post soap as xml(String client key, String client secret, String
token,
      String token secret, String realm, String url, String body)
or
OAuth1Api.post soap as xml(String client key, String client secret, String
token,
      String token secret, String realm, String url, String body,
Map headers)
Parameters
client key
client secret
token
token secret
realm
url
body
headers
Returns
Result

Google Cloud APIs

Big query api (Big query APIs)

create table

Create a new table in the data set identified by a table name and its schema.

Big query api.create table(String dataset name, String tableName, Schema
schema)
or
Big query api.create table(String dataset name, String tableName,
List> class attrs)
or
Big query api.create table(String dataset name, String tableName,
      List> csv schema, List>
class attrs, List> mappings)
parameters:
dataset name: dataset name
tableName:   table name
schema:       schema object
class attrs:   class attributes
csv schema:     csv representation object
mappings:     mappings object
Return : result
the result object

get bq datasets

Get the list of all dataset names.

Big query api.get bq datasets()
parameters:
none

Return:

list of objects

get bq tables

List the tables in a specific data set.

Big query api.get bq tables(String dataset name)
parameters:
dataset name: name of the data set
Return:
the list of the tables

get table

Retrieves table information from the data set.

Big query api.get table(String dataset name, String tableName)
or
Big query api.get table(String dataset and tablename)
parameters:
dataset name:  name of the data set
tableName:    name of the table
dataset and tablename

Return:

detail information of the table

get table fields

// Description //

Big query api.get table fields(String dataset and tablename)
or
Big query api.get table fields(String dataset name, String tableName)
Parameters
dataset and tablename
dataset name
tableName
Returns
List

executeQuery

Executes a query in a specific data set and return the results.

Big query api.executeQuery(String query string)
parameters:
query string: query

Return:

the result object representing the query outcome.

get big query iterator

Get an iterator over table query.

Big query api.get big query iterator(String query, int start index, int
pageSize)
parameters:
query:      table query
start index: index start
pageSize:    page size

Return:

iterator object

insert rows

Insert a list of rows into the table.

Big query api.insert rows(
      String dataset name, String tableName, List>
list)
parameters:
dataset name:   dataset name
tableName:     table in the data set
list:          records to be inserted
Return:
the result of the insertion

import csv into table

Import data from CSV file to the dataset table . The header in the CSV file can be skipped if needed.

Big query api.import csv into table(String dataset name, String tableName,
String path to file,
      List> csv schema, List>
class attrs, List> mappings, int number of rows to skip)
or
Big query api.import csv into table(String dataset name, String tableName,
String path to file, Schema schema, int number of rows to skip)
or
Big query api.import csv into table(String dataset name, String tableName,
String path, String fileName, Schema schema, int number of rows to skip)
parameters:
dataset name:   name of the dataset
tableName:     name of the table in the data set
path to file:    absolute path to the file on the system
csv schema:     the csv schema
class attrs:    attributes
mappings:      mapping of attributes with schema
number of rows to skip:   if skipping rows from the top of the csv file
fileName:      the name of the file
schema:         the schema
Return:
the result of the operation

import csv by uri into table

Same as above but using the URI for CSV file location.
Big query api.import csv by uri into table(String dataset name, String
tableName, String source uri, Schema schema, int number of rows to skip)
parameters:
dataset name:     name of the data set
tableName:       name of the table in the dataset
source uri:       the uri of source file
schema:           the scheme of the csv
number of rows to skip:   csv line to skip from the start
Return:
result of the operation

export table to csv

Exports dataset table into a CSV file.

Big query api.export table to csv(
      String dataset name,
      String tableName,
      String path to file)
or
Big query api.export table to csv(
      String dataset name,
      String tableName,
      String path, String fileName)

parameters:

dataset name:   name of the data set
tableName:     name of the table in the data set
path to file:    path to the CSV file
path:          same as above
fileName:      name of the file
Return:
the result of the operation

export table to csv by uri

Same as above but using the URI for the csv file location

Big query api.export table to csv by uri(
      String dataset name,
      String tableName,
      String destination uri)
parameters:
dataset name:   name of the data set
tableName:     name of the table in the data set
destination uri:   the destination uri of csv file
Return:
the result of the operation

export table

Export a table of the dataset to a file type with the destination uri provided.

Big query api.export table(
      String dataset name,
      String tableName,
      String destination uri,
      String data format)
parameters:
dataset name:   name of the dataset
tableName:     name of the table in the dataset
destination uri:   destination uri
data format:    format of the exported data
Return:
result of the operation

big query to csv

export data set table with specific columns to a CSV.

Big query api.big query to csv(String file path, String[] column names, String
dataset name, String bq tablename,
      String query)
or
Big query api.big query to csv(String file path, String[] column names, String
dataset name, String bq tablename,
        String query, String function name)
parameters:
file path:       the path of the CSV file
column names:    table column names
dataset name:    name of the data set
bq tablename:    name of table
query:          query to run
function name:   extra function to be called
Return:
the result of the operation

getpage

Get page details
Big query api.getPage(String query, long start, long size)
Parameters
query
start
size
Returns
Object

create table from csv

Create table from CSV
Big query api.create table from csv(String dataset name, String tableName,
String bucket filename)
or

Parameters
dataset name
tableName
bucket filename
bucket name
Returns
Result

import json by uri into table

import JSON by URI into table

Big query api.import json by uri into table(String dataset name, String
tableName,
                                               String source uri)
or
Big query api.import json by uri into table(String dataset name, String
tableName,
                                                String source uri,
Schema schema)
Parameters
dataset name
tableName
source uri
schema
Returns
Result

big query to csv with script

Get page details

Big query api.big query to csv with script(String file path, String[]
column names,
      String dataset name, String bq tablename, String query, String
script, String script flavor)
Parameters
file path
column names
dataset name
bq tablename
query
script
script flavor
Returns
int

GCSApi (Cloud Storage APIs)

get trillo gcs bucket

Get the cloud storage bucket name being used by the workbench.

GCSApi.get trillo gcs bucket()
parameters:
none
Return:
the name of the bucket as String

get trillo gcs bucket uri

same as above but returns a URI of storage bucket.

GCSApi.get trillo gcs bucket uri()
parameters:
none
Return:
uri of the bucket as String

get gcs file uri

Get the file URI path from the cloud storage bucket.

GCSApi.get gcs file uri(String path to file)
or
Big query api.get gcs file uri(String path, String fileName)

parameters:

path to file: path to the file
path:       same as above
fileName:   name of the file

Return:

uri of bucket file path as String

get local path

Cloud storage bucket is mapped locally by the workbench so its path is available.

GCSApi.get local path (String bucket path)

parameters:

bucket name and path

Return:

the locally mapped path name  as String

get gcs path

Get cloud storage bucket path from the app Data path provided.

GCSApi.get gcs path(String app data path)

parameters:

app data path

Return:

the path as String

get gcs temp path

Get the temporary path on the cloud storage bucket being used by the workbench

GCSApi.get gcs temp path()

parameters:

none

Return:

temporary path

get default root folder

Get the default root path on the storage bucket.

GCSApi.get default root folder()

parameters:

none

Return:

the root path

GCP auth api

get token info

Description...

GCP auth api.get token info(String authentication path)
Parameters
authentication path
Returns
// Some code

refresh access token

Description...

GCP auth api.refresh access token(String refresh token, String clientId,
String client secret)
Parameters
refresh token
clientId
client secret
Returns
// Some code

GCP rest api

get

Make GET call for GCP rest api.

GCP rest api.get(String request url)
or
GCP rest api.get(String request url, String service account key propname,
String authentication path)
or
GCP rest api.get(String request url, String refresh token, String clientId,
String client secret)
Parameters
request url
service account key propname
authentication path
refresh token
clientId
client secret
Returns
Object

post

Make POST call for GCP rest api.

GCP rest api.post(String request url, Object body)
or
GCP rest api.post(String request url, Object body, Map
headers)
or
GCP rest api.post(String request url, Object body, String
service account key propname,
String authentication path)
or
GCP rest api.post(String request url, Object body, String refresh token,
String clientId,
String client secret)
or
GCP rest api.post(String request url, Object body, Map
headers,
      String refresh token, String clientId, String client secret)
or
GCP rest api.post(String request url, Object body, Map
headers,
      String service account key propname, String authentication path)
Parameters
request url
body
service account key propname
authentication path
refresh token
clientId
clientId
headers
Returns
Object

put

Make PUT call for GCP rest api.
GCP rest api.put(String request url, Object body)
or
GCP rest api.put(String request url, Object body, String
service account key propname,
String authentication path)
or
GCP rest api.put(String request url, Object body, String refresh token,
String clientId,
String client secret)
Parameters
request url
body
service account key propname
authentication path
refresh token
clientId
client secret
Returns
Object

delete

Make DELETE call for GCP rest api.

GCP rest api.delete(String request url, Object body)
or
GCP rest api.delete(String request url, Object body, String
service account key propname,
String authentication path)
or
GCP rest api.delete(String request url, Object body, String refresh token,
String clientId,
String client secret)
Parameters
request url
body
service account key propname
authentication path
refresh token
clientId
client secret
Returns
Object

patch

Make PATCH call for GCP rest api.

GCP rest api.patch(String request url, Object body)
or
GCP rest api.patch(String request url, Object body, String
service account key propname,
                           String authentication path)
or
GCP rest api.patch(String request url, Object body, String refresh token,
String clientId,
                           String client secret)
Parameters
request url
body
service account key propname
authentication path
refresh token
clientId
client secret
Returns
Object

publish

publish message
GCP rest api.publish(String topicId, Object message)
Parameters
topicId
message
Returns
Result

subscribe

subscribe message

GCP rest api.subscribe(String subscription id, Message receiver receiver)
Parameters
subscription id
receiver
Returns
Result

unsubscribe

unsubscribe message

GCP rest api.service account key to token(String service account key propname,
      String authentication path)
Parameters
service account key propname
authentication path
Returns
GCP token info

GCP token info

get project id

get project id

GCP token info.get project id()
Parameters
None
Returns
String

set project id

set project id

GCP token info.set project id(String project id)
Parameters
project id
Returns
None

get token value

get token value

GCP token info.get token value()
Parameters
None
Returns
String

set token value

set token value

GCP token info.set token value()
Parameters
token value
Returns
String

get expiration time

get expiration time

GCP token info.get expiration time()
Parameters
None
Returns
long

set expiration time

set expiration time

GCP token info.set expiration time()
Parameters
None
Returns
None

get authentication type

get authentication type

GCP token info.get authentication type()
Parameters
None
Returns
String

set authentication type

set authentication type

GCP token info.set authentication type(String authentication type)
Parameters
authentication type
Returns
None

isError

is error

GCP token info.isError()
Parameters
None
Returns
boolean

set error

set error

GCP token info.set error(boolean error)
Parameters
error
Returns
None

get message

get message

GCP token info.get message()
Parameters
None
Returns
String

set message

set message

GCP token info.set message(String message)
Parameters
message
Returns
None

Metadata API (MetaApi)

Create and Update API

make class from data

Variation-1: Builds a class object from given name, primary key and the data. The class is generated from the data. This is equivalent to generating a class from the data.

MetaApi.make class from data (String className, String pk attrname,
Map data)
Parameters
className:   name of the class object
pk attrname:  which attribute is the primary key
data:        the data hashmap
Returns
A Map representation of newly created class
Object make class from data(String className, String tableName, String
pk attrname, Map data)
Parameters
className:   name of the class object
tableName:   name of the table in the database
pk attrname:  which attribute is the primary key
data:        the data hashmap

Variation-3: Builds a class object from chosen name, primary key, data and data Types.

make class from data(String className, String pk attrname, Map data, Map attrtype by names)
Parameters
className:   name of the class object
tableName:   name of the table in the database
pk attrname:  which attribute is the primary key
data:        data hashmap
attrtype by names: columns types and names

Variation-4: Builds a class object from chosen name, primary key, data and data Types and either create a DB table or just keep in memory. When you pass the data it is the stored only in memory when the skipping is enabled. When it is stored in the database it becomes much more restrictive but where as in the memory it is flexible. You can save this class after modifications and it will not be rejected.

make class from data(String className, String pk attrname, Map data, Map attrtype by names), boolean skip saving
Parameters
className:   name of the class object
tableName:   name of the table in the database
pk attrname:  which attribute is the primary key
data:        data hashmap
attrtype by names: columns types and names
skip saving: true create the table only in memory

create metadata

create metadata

MetaApi.create metadata(Map md)
Parameters
md
Returns
Object

save metadata

save metadata
MetaApi.save metadata(String appName, String dsName, String schemaName,
ClassM clsM)
or
MetaApi.save metadata(Map md)
Parameters
md
appName
dsName
schemaName
clsM
Returns
Object

get app datadir

Locate and get the application data directory

MetaApi.get app datadir()
Parameters
no parameters.
Returns
application data directory

save class

save class

MetaApi.save class(String className, ClassM clsM)
Parameters
className
clsM
Returns
Object

update class visibility

update Class Visibility

MetaApi.update class visibility(String className, String visibility)
Parameters
className
visibility
Returns
Object

create function sys task

create Function Sys Task

MetaApi.create function sys task(String mdId)
or
MetaApi.create function sys task(String orgName, String name)
Parameters
mdId
orgName
name
Returns
Result

- All Retrieve Only

get app datadir

Locate and get the application data directory

MetaApi.get app datadir()
Parameters
no parameters.
Returns
application data directory

getclass m

Get the object representing the class

MetaApi.getclass m(String className)
Parameters
className: name of the class
Returns
the object representing the class

get schema for data studio

Get class schema for the data studio

MetaApi.get schema for data studio(String className, boolean
include all sys attrs)
Parameters
className:          name of the class
include all sys attrs:  include all system attributes
Returns
the schema object for the data studio

get domain file as map

get domain file as a hashmap.

MetaApi.get domain file as map(String fileName)
Parameters
fileName:    name of the file
Returns
hashmap of the file

getMetadata

get metadata from id
MetaApi.getMetadata(String id)
or
MetaApi.getMetadata(String model classname, String folder, String name)
Parameters
id
Returns
Object

get classes

get classes
MetaApi.get classes(String filter)
or
MetaApi.get classes(String dsName, String filter)
or
MetaApi.get classes(String dsName, String schemaName, String filter)
or
MetaApi.get classes(String appName, String dsName, String schemaName,
String filter)
Parameters
filter
dsName
schemaName
appName
Returns
Object

get class names

get classes
MetaApi.get class names(String filter)
or
MetaApi.get class names(String dsName, String filter)
or
MetaApi.get class names(String dsName, String schemaName, String filter)
or
MetaApi. get class names(String appName, String dsName, String
schemaName, String filter)
Parameters
filter
dsName
schemaName
appName
Returns
List

get data source names

get data source names

MetaApi.get data source names(String filter)
or
MetaApi.get data source names(String appName, String filter)
Parameters
filter
appName
Returns
List

get data sources

get data sources

MetaApi.get data sources(String filter)
or
MetaApi.get data sources(String appName, String filter)
Parameters
filter
appName

Returns

List

UMApi (User, Tenant, Roles APIs)

get current user

Get the current login user.

UMApi.get current user()
Parameters
None
Returns
Map

get current userid

Get the current user id

UMApi.get current userid()
Parameters
None
Returns
String

getid of current user

Get the current user id as a number

UMApi.getid of current user()
Parameters
None
Returns
String

getid of current user as long

Get the current user id as a long number.

UMApi.getid of current user as long()
Parameters
None
Returns
long

is numeric

Check if i string number is numeric.

UMApi.is numeric(String strNum)
Parameters
strNum:     number
Returns

result as a boolean

switch to privileged mode

The privileged mode has a superuser access and is able to override logged in user to perform an internal workbench operation e.g., database access.

UMApi.switch to privileged mode()
Parameters
none
Returns
none

reset privileged mode

Remove the privileged mode thereby restoring everything to normal.

UMApi.reset privileged mode()
Parameters
none
Returns
none

is privileged mode

Check if privileged mode is active.

UMApi.is privileged mode()
Parameters
none
Returns
result as a boolean

switch to privileged user mode

Switch into the privileged user mode.

UMApi.switch to privileged user mode()
Parameters
none
Returns
none

reset privileged user mode

Reset the privileged user mode.

UMApi.reset privileged user mode()
Parameters
none
Returns
none

is privileged user mode

Check if privileged user mode is active

UMApi.is privileged user mode()
Parameters
none
Returns
boolean status

get current user tenant id

get current user tenant id

UMApi.get current user tenant id()
Parameters
none
Returns
long

get tenant id

get tenant id

UMApi.get tenant id()
Parameters
none
Returns
String

getuser by userid

get user by userid

UMApi.getuser by userid(String userId)
Parameters
userId
Returns
Object

getUser

get user using id

UMApi.getUser(String id)
Parameters
id
Returns
Object

HttpApi (HTTP APIs)

get

Retrieve a json result using HTTP get.

HttpApi.get(String request url)
or
HttpApi.get(String request url, Map headers)
or
HttpApi.get(String request url, Map headers, Integer
retry count, Integer wait time)
or
HttpApi.get with retry(String request url, Map headers)
Parameters
request url
headers
retry count
wait time
Returns
result of the operation

post

HTTP Post with the body and optionally headers and retrieve returning object.

HttpApi.post(String request url, Map body)
or
HttpApi.post(String request url, Map body, Map headers)
or
HttpApi.post as string(String request url, Object body)
or
HttpApi.post as string(String request url, Object body, Map headers)
or
HttpApi.post form data(String request url, Map body,
Map headers)
or
HttpApi.post form data as string(String request url, Map
body, Map headers)
or
HttpApi.post soap(String soapUrl, String body, Map
headers)
Parameters
request url:    requested URL
body:          body of the request
headers:       headers
Returns
the result of the operation

put

Execute HTTP put with a given body and a header to the requested URL.
HttpApi.put(String request url, Map body)
or
HttpApi.put(String request url, Map body, Map headers)
Parameters
request url:    requested url
body:          payload
headers:       headers
Returns
result of the operation

patch

Execute HTTP patch with the requested body and header to a URL.

HttpApi.patch(String request url, Map body)
or
HttpApi.patch(String request url, Map body, Map headers)
Parameters
request url:     requested url
body:           payload
headers:        headers
Returns
the result of the operation

delete

Execute HTTP delete with a body and a header to a requested URL.

HttpApi.delete(String request url, Map body)
or
HttpApi.delete(String request url, Map body, Map headers)
Parameters
request url:      requested url
body:             body of the request
headers:         headers
Returns
the result of the operation

get as string

Description...
HttpApi.get as string(String request url, String content type, Object body)
or
HttpApi.get as string(String request url, String content type, Object body,
Map headers)
or
HttpApi.get as string(String request url, String content type)
or
HttpApi.get as string(String request url, String content type, Map headers)
Parameters
request url
body
content type
headers
Returns
Result

post as string

Description...

HttpApi.post as string(String request url, Object body)
or
HttpApi.post as string(String request url, Object body,
Map headers)
Parameters
request url
body
headers
Returns
Result

putas string

Description...

HttpApi.putas string(String request url, Object body)
or
HttpApi.putas string(String request url, Object body,
Map headers)
Parameters
request url
body
headers
Returns
Result

patch as string

Description...

HttpApi.patch as string(String request url, Object body)
or
HttpApi.patch as string(String request url, Object body,
Map headers)
Parameters
request url
body
headers
Returns
Result

delete as string

Description...

HttpApi.delete as string(String request url, Object body)
or
HttpApi.delete as string(String request url, Object body,
Map headers)
Parameters
request url
body
headers
Returns
Result

read file as json

Description...

HttpApi.read file as json(String url,
Map header map)
or
HttpApi.read file as json(String url, Charset encoding, Map header map)
Parameters
url
header map
encoding
Returns
Result

read file as string

Description...

HttpApi.read file as string(String url, Map header map)
or
HttpApi.read file as string(String url, Charset encoding,
Map header map)
Parameters
url
header map
encoding
Returns
Result

read file as bytes

Description...

HttpApi.read file as bytes(String url,
Map header map)
Parameters
url
header map
Returns
Result

writeFile

Description...

HttpApi.writeFile(String url, String file path, String file field name,
Map header map)
or
HttpApi.writeFile(String url, String file path, String file field name,
Map header map,
Map additional fields)
Parameters
url
file path
file field name
header map
additional fields
Returns
Result

writefile bytes

Description...

HttpApi.writefile bytes(String url,String fileName,
byte[] file content, String file field name,
Map header map)
or
HttpApi.writefile bytes(String url,String fileName, byte[] file content,
String file field name, Map header map,
Map additional fields)
or
HttpApi.writefile bytes(String url, String fileName,
String file content as string, String file field name, Map header map)
or
HttpApi.writefile bytes(String url, String fileName, String
file content as string,
String file field name, Map header map, Map additional fields)
Parameters
url
fileName
file content
file field name
header map
additional fields
file content as string
Returns
Result

writefile bytes

Description...
HttpApi.http method as string(String request url, Http method method, String
content type, Object body,
      Map headers)
Parameters
request url
method
content type
body
headers
Returns
Result

SFTPApi

get

Description...
SFTPApi.get(String server, String userName, String password,
      String remote file, String local file)
or
SFTPApi.get(String server, int port, String userName, String password,
      String remote file, String local file)
Parameters
server
userName
password
remote file
local file
port
Returns
Result

put

Description...

SFTPApi.put(String server, String userName, String password,
      String remote file, String local file)
or
SFTPApi.put(String server, int port, String userName, String password,
      String remote file, String local file)
Parameters
server
userName
password
remote file
local file
port
Returns
Result

ls

Description...

SFTPApi.ls(String server, String userName, String password,
      String remote folder) {
or
SFTPApi.ls(String server, int port, String userName, String password,
      String remote folder)
or
SFTPApi.ls(String server, String userName, String password,
      String remote folder, String extensions)
or
SFTPApi.ls(String server, int port, String userName, String password,
      String remote folder, String extensions)
Parameters
server
userName
password
remote folder
port
extensions
Returns
Result

File util

get file extension

Description...

File util.get file extension(String fileName)
Parameters
fileName
Returns
String

copy file

Description...

File util.copy file(File in, File out)
Parameters
in
out
Returns
None

rename to

Description...

rename to.rename to(File from file, File toFile)
Parameters
from file
toFile
Returns
None

readFile

Scans through a file and reads all the lines

File util.readFile(File file, int number of lines)
Parameters
file
number of lines
Returns
StringBuilder

writeFile

Description...

File util.writeFile(File file, String buf)
or
File util.writeFile(File file, byte[] bytes)
Parameters
file
buf
bytes
Returns
None

get file timestamp

Description...

File util.get file timestamp(File f)
Parameters
input file
Returns
long

is file modified before

Checks if the file was modified before the provided timestamp

File util.is file modified before(File f, long ts)
Parameters
input file
Timestamp
Parameters
True if the file was modified or False otherwise

is file modified before delta

Description...

File util.is file modified before delta(File f, long ts, long delta)
Parameters
input file
Timestamp
delta
Returns
boolean

get file bufferedreader

Description...

File util.get file bufferedreader(File file)
Parameters
input file
Returns
BufferedReader

get unique filename

Description...

File util.get unique filename(String dirName, String fileName)
or
File util.(String dirName, String filename prefix, String ext)
Parameters
dirName
fileName
filename prefix
ext
Returns
String

get file list

Description...

File util.get file list(String path, String file extensions)
Parameters
path
file extensions
Returns
List

get file list nonrecursive

Description...

File util.get file list nonrecursive(String path, String[] extensions)
Parameters
path
extensions
Returns
List

getFile

Description...

File util.getFile(File file)
Parameters
file
Returns
Resource

copy text file

Description...

File util.copy text file(File file1, File file2)
Parameters
file1
file2
Returns
None

is resizable image file

Description...

File util.is resizable image file(String fileName)
Parameters
fileName
Returns
boolean

get supported file types

Description...

File util.get supported file types()
Parameters
None
Returns
String

Remove temp

Description...

File util.Remove temp(File workDir)
Parameters
workDir
Returns
boolean

Remove temp

Description...

File util.Remove temp(File workDir)
Parameters
workDir
Returns
boolean

Remove temp

Description...

File util.Remove temp(File workDir)
Parameters
workDir
Returns
boolean

take off bom

Description...

File util.take off bom(String str)
Parameters
str
Returns
String

list directory

Description...

File util.list directory(String repo root, File directory,
      int time limit)
Parameters
repo root
directory
time limit
Returns
List>

list directory

Description...

File util.validate file path(File file)
Parameters
file
Returns
None

validate file path

Description...

Parameters
parent
file
Returns
None

validate file path

Description...

validate file path(String parent dir, File file)
Parameters
parent dir
file
Returns
None

CSVApi

csv get all rows

Description...
CSVApi.csv get all rows(String file path)
or
CSVApi.csv get all rows(String file path, String separator)
or
CSVApi.csv get all rows(String file path, String separator, String[]
column names)
or
CSVApi.csv get all rows(String file path, String separator, String[]
column names, int column name line)
Parameters
file path
separator
column names
column name line
Returns
List>

csv get page

Description...

CSVApi.csv get page(String fileName, String separator str,
      List column names, int column name line, String query, int
start index, int pageSize)
or
CSVApi.csv get page(String fileName, char separator char,
      List column names, int column name line, String query, int
start index, int pageSize)
Parameters
fileName
separator char
column names
column name line
query
start index
pageSize
Returns
List>

get csv iterator

Description...

CSVApi.get csv iterator(String fileName, int start index, int pageSize)
or
CSVApi.get csv iterator(String fileName, String query, int start index,
int pageSize)
or
CSVApi.get csv iterator(String fileName, char separator char, String
query, int start index, int pageSize)
or
CSVApi.get csv iterator(String fileName, List column names, String
query, int start index, int pageSize)
or
CSVApi.get csv iterator(String fileName, char separator char, List
column names, String query, int start index, int pageSize)
or
CSVApi.get csv iterator(String fileName, List column names, int
column name line, String query, int start index, int pageSize)
or
CSVApi.get csv iterator(String fileName, char separator char, List
column names, int column name line, String query, int start index, int
pageSize)
Parameters
fileName
start index
pageSize
query
separator char
column names
column name line
Returns
Csv iterator

get csv iterator

Description...
CSVApi.get csv writer(String fileName, Field list fl)
or
CSVApi.get csv writer(String fileName, List column names)
or
CSVApi.get csv writer(String fileName, char separator char, Field list fl)
or
CSVApi.get csv writer(String fileName, char separator char,
      List column names)
or
CSVApi.get csv writer(String fileName, char separator char, Field list fl,
      int column name line)
or
CSVApi.get csv writer(String fileName, char separator char,
      List column names, int column name line)
Parameters
fileName
fl
separator char
column names
column name line
Returns
Csv writer

get csv iterator

Description...

CSVApi.get csv writer(String fileName, Field list fl)
or
CSVApi.get csv writer(String fileName, List column names)
or
CSVApi.get csv writer(String fileName, char separator char, Field list fl)
or
CSVApi.get csv writer(String fileName, char separator char,
      List column names)
or
CSVApi.get csv writer(String fileName, char separator char, Field list fl,
      int column name line)
or
CSVApi.get csv writer(String fileName, char separator char,
      List column names, int column name line)
Parameters
fileName
fl
separator char
column names
column name line
Returns
Csv writer

get csv iterator

Description...

CSVApi.get csv import iterator(String id, int limit)
or
CSVApi.get csv import iterator(String id, int limit,
      List> mappings)
or
CSVApi.get csv import iterator(String id, String model classname, int
limit,
      List> mappings)
Parameters
id
limit
mappings
model classname
Returns
Object

get csv iterator

Description...
CSVApi.csv writefile(String fileName, String separator str, List
column names,
      int column name line, List> rows)
or
CSVApi.csv writefile(String fileName, char separator char, List
column names,
      int column name line, List> rows)
Parameters
fileName
separator str
separator char
column names
column name line
rows
Returns
Result

Email api (Email APIs)

send email

Send email to recipient via the internally provision gateway of the workbench.

Email api.send email(String appName, String email, String subject, String
content,
      String template, String from alias, Map
template params)
or
Email api.send email(String appName, String email, String subject, String
content,
      String template, String from alias, Map
template params, String sender email)
or
Email api.send email(final String toEmail, final String subject, String
content)
or
Email api.send email(final String toEmail, final String template,
      final Map email params, final String subject)
parameters:
appName:     name of the internal application
email:       email of the sender
subject:     subject of a email
content:     contents
template:    template to be used
from alias:   alias name
template params:   template parameters
sender email:      sender email
toEmail:     to email
email params : email params
Return:
result of the operation

send email markdown content

Send email with markdown contents.

Email api.send email markdown content(String mailTo, String body, String
subject)
parameters:
mailTo:    recipient address
body:      body with markdown
subject:   subject of the email

Return:

result of the operation

send email using function

Send email using the function

Email api.send email using function(String function name,
      Map email params)
parameters:
function name
email params
Return:
boolean

get subject

Get subject

Email api.get subject(String template name, String default subject,
      Map email params)
parameters:
template name
default subject
email params
Return:
String

get processed email content from template

get processed email content from template

Email api.get processed email content from template(String template name,
      Map email params)
parameters:
template name
email params
Return:
String

email template exists

check if the email template exits

Email api.email template exists(String template name)

parameters:

template name

Return:

boolean

get email props

get email props

Email api.get email props(String template name)

parameters:

template name

Return:

Map

get servername

get server name

Email api.get servername()
parameters:
None

Return:

String