Trillo Workbench Python SDK

Introduction

This document describes Python 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.

class Result:
    # Constants for status values
    SUCCESS = "success"
    FAILED = "failed"
    UNKNOWN = "unknown"
    def __init__(self):
        # Default status is UNKNOWN
        self.status = self.UNKNOWN
        # Message holds error or success message
        self.message = None
        # Props can hold additional information (not used in this
example)
        self.props = None
        # Data holds the actual value of API in case of success
        self.data = None
        # HTTP code when applicable
        self.code = 0
        # A flag indicating result object (useful for JS)
        self._rtag = "_r_"
        # Flag to indicate if the operation failed
        self.failed = False
        # Flag to indicate if the operation was successful
        self.success = True

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

Transform an object into a neatly formatted JSON string.

BaseApi.as json pretty string(obj)
Parameters
obj: the object that needs to be converted to JSON string (can be a
dict)
Sample Code
# Create a dictionary to hold product information
product = {"productId": "11"}
str_json = BaseApi.as json pretty string(product)
Returns
This endpoint will return the formatted string of the dictionary, with
indentation         and sorted keys, for better readability and
understanding.

as json string

Transform an object into a non-formatted JSON string.

BaseApi.as json string(obj)

Parameters

obj:  the object that needs to be converted to JSON string (can be a
dict)
Sample Code
product = {
    "productId": "11"
}
str_json = BaseApi.as json string(product)
Returns
This method returns the string representation of the object in JSON
format, without formatting, for improved readability and comprehension.

from json string

Parse a JSON-formatted string and convert it into a Map object.
BaseApi.from json string(json string)
Parameters
json string:     A string representing a valid JSON structure.
Sample Code
json string = "{\n" + \
            "    \"productId\": \"abc\"\n" + \
            "}"
map = BaseApi.from json string(json string)
Returns
A constructed dict represents the key-value pairs extracted from the
provided JSON string.

from json string as array

Convert a json string as a dictionary.

BaseApi.from json string as array(json string)
Parameters
json string:    string representation of json
Sample Code
json_string = '[\n' + \
    '    {\n' + \
    '    "product": "abc"\n' + \
    '    }\n' + \
    ']'
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 a dictionary

BaseApi.read json(dir, fileName)
Parameters
dir:    the directory as str
fileName:  name of the file as str
Sample Code
map = BaseApi.read json('/tmp/folder1', 'file.json')
Returns
json document object as dictionary

write json

Write a dictionary object into a file located on a specific directory.

BaseApi.write json(dir, fileName, obj)
Parameters
dir:         directory as str
fileName:    name of the file as str
obj:         json document object
Sample Code
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 dictionary object into a file located on a specific directory. The JSON information is a formatted inside the file.

BaseApi.write pretty json(dir, fileName, obj)
Parameters
dir:          directory as str
fileName:     name of the file as str
obj:          json formatted document
Sample Code
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 dictionary object.

BaseApi.success result()
or
BaseApi.success result(msg)
or
BaseApi.success result(msg, data)
Parameters
msg  :  message to be sent as str
data :  Object
Sample Code
BaseApi.success result('Successfully added records')
Returns
This method returns a success Result object. If provided, the message
and data are encapsulated within the result.

error result

Build and return an error result dictionary object.

BaseApi.error result(msg)
or
BaseApi.error result(msg, code)
Parameters
msg:     message to be sent (str)
code:    return code (int)
Sample Code
BaseApi.error result('Failed to process records')
Returns
This method returns an error Result object with the specified message
and, optionally, a code.

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(obj)
Parameters
obj: object as a dictionary
Returns
This method extracts the message from a Result object if the object is
a Result; otherwise, it returns "Unknown".

is result

Checking whether the object is a result object .

BaseApi.is result(obj)
Parameters
obj:    the object as a dictionary
Sample Code
res = Result.get success result('success')
is result = BaseApi.is result(res)
Returns
This method returns True if the provided object is an instance of
Result; otherwise, it returns False.

is result or null

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

BaseApi.is result or null(obj)
Parameters
obj:    the object as a dictionary

Sample Code

res = Result.get success result('success')
is result = BaseApi.is result or null(res)
Returns
This method returns True if the provided object is either an instance
of Result or None; otherwise, it returns False.

UUID

Generate a universally unique identifier (UUID) string.
BaseApi.UUID()
Parameters
none
Sample Code
uuid = BaseApi.UUID()
Returns
This method returns a string representing a randomly generated UUID.

uid to classname

Extract class name from an input string.

BaseApi.uid to classname(uid)
Parameters
uid:    the className id as str
Returns
This method returns a class name string derived from the provided UID.

uidToId

Extract an long id number from a string UID.

BaseApi.uidToId(uid)
Parameters
uid: str
Returns
This method returns an integer ID extracted from the provided UID
string.

uid to id str

Retrieves the ID as a string from uid.

BaseApi.uid to id str(uid)
Parameters
uid: str
Returns
This method returns a string representation of the ID extracted from
the provided UID.

wait for millis

Pause execution for the specified number of milliseconds.

BaseApi.wait for millis(tm)
Parameters
tm: long
Sample Code
res = BaseApi.wait for millis(10)
Returns
This method returns a Result indicating the success or failure of the
wait operation.

remote call

Perform a remote method call.

Parameters
java class name: str
java methodname: str
Sample Code
res = remote call('DSApi', 'get', 'shared.common.product', '12')
Returns
This method returns the result of the remote method call.

remote callas result

Perform a remote method call and return the result as a Result object.

BaseApi.remote callas result(java class name, java methodname, *args)
Parameters
java class name: str
java methodname: str
Sample Code
res = remote callas result('Big query api', 'executeQuery', 'SELECT ID FROM
product_tbl')
Returns
This method returns the result of the remote method call encapsulated
within a Result object.

remote callas map

Perform a remote method call and return the result as a dictionary.

BaseApi.remote callas map(java class name, java methodname, *args)
Parameters
java class name: str
java methodname: str
Sample Code
res =  remote callas map('UMApi', 'get current user')
Returns
This method returns the result of the remote method call as a
dictionary.

remote callas string

Perform a remote method call and return the result as a string.

BaseApi.remote callas string(java class name, java methodname, *args)
Parameters
java class name: str
java methodname: str
Sample Code
res = remote callas string('GCP rest api', 'get project id')
Returns
This method returns the result of the remote method call as a string.

remote callas list

Perform a remote method call and return the result as a list.
BaseApi.remote callas list(java class name, java methodname, *args)
Parameters
java class name: str
java methodname: str
Returns
This method returns the result of the remote method call as a list.

remote callas list of maps

Perform a remote method call and return the result as a list of dictionaries.

BaseApi.remote callas list of maps(java class name, java methodname, *args)
Parameters
java class name: str
java methodname: str
Returns
This method returns the result of the remote method call as a list of
dictionaries.

LogApi (Logging APIs)

set loglevel

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

LogApi.set loglevel(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(msg)
Parameters
msg:   message string
Returns
result of the operation

logInfo

logging an informational and occasional message .

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

logWarn

Provides a warning message

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

log error

Provides an error message

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

is loglevel on

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

LogApi.is loglevel on(type)
Parameters
type:   type string 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(log object)
or
LogApi.audit log(String type, String summary, String ...args)
Parameters
log object: object representing dictionary
summary:  a string sentence with tokens
...args: arguments of type string to be replaced
type:  type string of the log
Returns
result of the operation

_audit log

// Description //
LogApi._audit log(type, summary, detail, json, action, source uid)
Parameters
summary: string
detail: string
json: string
action: string
source uid: string
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(summary, ...args)
Parameters
summary: a string sentence with tokens
...args:  the string values 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(summary, ...args)
Parameters
summary: string
...args: string

Returns

can audit log

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

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

log to console

Logs the appropriate messages to the console

LogApi.log to console(type, msg)
Parameters
type: string
msg: string
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(className, id)
Parameters
className: the str 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
className = 'shared.common.product'
id = '12'
res = DSApi.get(className, id)
Returns
A dictionary containing the retrieved data.

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(className, where clause)
or
DSApi.query one(className, where clause, include deleted)
Parameters
className: the str 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
className = 'shared.common.product'
where clause = 'prices is not null'
include deleted = True
res = DSApi.query one(className, where clause)
res2 = DSApi.query one(className, where clause, include deleted)
Returns
A dictionary containing the queried record.

- query one sqlQuery

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

DSApi.query one(sqlQuery)
Parameters
sqlQuery: str type 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
sqlQuery = 'Select id, prices from product_tbl where prices is not
null'
res2 = DSApi.query one(String sqlQuery)
Returns
A dictionary containing the queried record.

query many - where clause (include deleted)

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

DSApi.query many(className, where clause)
or
DSApi.query many(className, where clause, include deleted)
Parameters
className: the str name of class as created using the workbench
            (correspond to the table)
where clause: where-clause of the SQL query as str.
include deleted: boolean type. consider records marked deleted if a
value of 'true is passed.
Sample Code
# fetch all product information from the product table using query
className = 'shared.common.product'
where clause = 'prices is not null'
include deleted = True
res = DSApi.query many(className, where clause)
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(sqlQuery)
Parameters
sqlQuery: SQL statement as str type.
Sample Code
# fetch many product information from the product table using query
sqlQuery = 'Select id, prices from product_tbl where prices is not
null'
res2 = DSApi.query many(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(tenant name)
Parameters
tenant name: str name of the tenant
Sample Code
# fetch tenant results based on tenant name
tenant name = ''
res2 = DSApi.tenant by name(tenant name)
Returns
A Result object containing the tenant information.

tenant by query

get the tenant details by executing a query.

DSApi.tenant by name(query)
Parameters
query: str query to be executed
Sample Code
# fetch results based on tenant name
tenant name = ''
res2 = DSApi.tenant by name(tenant name)
Returns
A Result object containing the tenant information.

getUser

Returns user information by its ID

DSApi.getUser(id)

Parameters

id: str id of the user
Sample Code
# fetch user details using id of user
id = 'abc'
res = DSApi.getUser(id)
Returns
A dictionary containing the user information.

user by email

Returns the user information with associated email

DSApi.user by email(email)
Parameters
email: email of the user as str
Sample Code
# fetch user details using email
email = 'abc@gmail.com'
res = DSApi.user by email(email)
Returns
A dictionary containing the user information.

user by userid

Returns the user with the ID

DSApi.user by userid(userId)
Parameters
userId: str
Sample Code
# get user details using the userId
userId = '{ID_OF_USER}'
res = DSApi.user by userid(userId)
Returns
A dictionary containing the user information.

value by key

Returns the value of the key associated with the provided type
DSApi.value by key(key, type)
Parameters
key: str
type: str
Sample Code
# fetch value associated with a provided type
key = '{KEY}'
type = '{TYPE}'
res = DSApi.value by key(key, type)

Returns

A dictionary containing the value.

Create and Update API

save

Saves the entity passed as input to the database

 DSApi.save(className, entity)
 or
 DSApi.save(className, entity, audit msg)
Parameters
className: the str name of class as created using the workbench
            (correspond to the table)
entity:  dictionary
audit msg: str
Sample Code
className = "shared.common.product"
entity = {"product name" : "table", "description" : "foldable table",
"prices" : 620}
res = DSApi.save(className, entity)
Returns
A Result object indicating the success or failure of the save
operation.

save many

Saves the list of entities to the database

 DSApi.save many(className, entities)
 or
 DSApi.save many(className, entities, audit msg)
Parameters
className: the str name of class as created using the workbench
            (correspond to the table)
entity: Iterable
Sample Code
className = 'shared.common.product'
entities = []
entity = {"product name" : "table", "description" : "foldable table",
"prices" : 620}
entities.append(entity)
res = DSApi.save(className, entities)
Returns
A Result object indicating the success or failure of the save
operation.

Update

Updates the attribute name with the provided value

DSApi.update(className, id, attrName, value)
 or
DSApi.update(className, id, attrName, value, audit msg)
Parameters
className: the name of class as created using the workbench
            (correspond to the table)
id: str
attrName: str
value: obj
audit msg: str
Sample Code
className = "shared.common.product"
id = "12"
attrName = "price"
value = 700
res = DSApi.update(className, id, attrName, value)
Returns
A Result object indicating the success or failure of the update
operation.

Update many

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

DSApi.update many(className, ids, attrName, value)
or
DSApi.update many(className, ids, attrName, value, audit msg)
Parameters
className: the str name of class as created using the workbench
            (correspond to the table)
ids: List rows needed to be modified
attrName: the name of the column as str
value:     the Object value of inside the column for the specific row
audit msg: any informational message as str
Sample Code
className = "shared.common.product"
ids = ["12", "15"]
attrName = "price"
value = 700
res = DSApi.update many(className, ids, attrName, value)
Returns
A Result object indicating the success or failure of the update
operation.

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(className, query, update attrs)
or
DSApi.update by query(className, query, update attrs, audit msg)
Parameters
className: the str name of class as created using the workbench
            (correspond to the table)
query:     the str type query represents the filtering criteria
update attrs:  update dictionary for the attributes
audit msg:   a str type informational message
Sample Code
className = "shared.common.product"
update param = {"deleted": True}
res = DSApi.update by query(className, "", update param)
Returns
A Result object indicating the success or failure of the update
operation.

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(dsName, sql statement, params)
Parameters
dsName:  the name of the data source
sql statement:  SQL String
params:  parameter values to be replaced inside the string
Returns
 A Result object containing the execution result.

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(className, id, permanent)
or
DSApi.delete(className, id, permanent, audit msg)
Parameters
className: the str name of the table
id:        the record number as str
permanent:   permanent or temporary. a boolean
audit msg:    any message as str
Sample Code
className = "shared.common.product"
permanent = True
id = "12"
res = DSApi.delete(className, id, permanent)
Returns
A Result object indicating the success or failure of the deletion
operation.

delete many

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

DSApi.delete many(className, ids, boolean permanent)
or
DSApi.delete many(String className, Iterable ids, boolean
permanent, String audit msg)
Parameters
className: the str name of the table
ids:        list of the regards
permanent:   either flagged or permanent. a boolean
audit msg:    any message as str
Sample Code
className = "shared.common.product"
permanent = True
ids = ["12", "13"]
res = DSApi.delete many(className, ids, permanent)
Returns
A Result object indicating the success or failure of the deletion
operation.

delete by query

Delete a record (s) by executing a query.

DSApi.delete by query (className, query, permanent)
or
DSApi.delete by query(className, query, permanent, audit msg)
Parameters
className: str name of the table
query:     query as str
permanent: flagged or permanent as boolean
Sample Code
className = "shared.common.product"
permanent = True
query = "Select first_name from product_tbl where price>100"
res = DSApi.delete by query(className, query, permanent)
Returns
A Result object indicating the success or failure of the deletion
operation.

Empty Table

empty table

Empty a specific table . All records are removed.

DSApi.empty table(className)
or
DSApi.empty table(className, audit msg)
Parameters
className:  str name of the table
audit msg:    any message as boolean
Sample Code
className = "shared.common.product"
res = DSApi.empty table(className)
Return
A Result object indicating the success or failure of the operation.

Sample Functions Using API

Function - Add customer record.py

from src.collage r.util import DSApi
 def _handle(parameter):
    className = "shared.common.customer"
    entity = {
        "name": "Sam",
        "email": "sam@gmail.com",
        "address": "45, park view, NY",
        "phone number": "+16463704660"
    }
    res = DSApi.save(className, entity)
    return res

Function - Update customer address.py

from src.collage r.util import DSApi
def _handle(parameter):
    className = "shared.common.customer"
    id = "1"
    attrName = "address"
    value = "7, woodland street, NY"
    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(function name, params)
or
FuncApi.execute function(appName, function name, params)
parameters:
function name: name of the function as str
params:   dictionary representing the parameters
appName: str
Sample Code
function parameters = {}
result = FuncApi.execute function("FUNCTION_NAME", function parameters)
Returns:
Dictionary containing the result of the function execution.

execute function with method

Executes a function with a specific method and parameters.

FuncApi.execute function with method(function name, methodName, params)
or
FuncApi.execute function with method(appName, function name, methodName,
params)
Parameters
function name: str
methodName: str
params: dictionary
appName: str
Sample Code
function parameters = {}

Returns
Dictionary containing the result of the function execution with method.

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(hostName, command)
or
FuncApi.execute ssh(hostName, command, async)
or
FuncApi.execute ssh(command, async)
parameters:
hostName: the str name of the companion server
command:   the command needed to be executed as str
async:     execute command immediately and wait or run it in the
background
Returns:
Dictionary containing the result of the SSH command execution.

ping task

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

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

Returns:
Dictionary containing the result of the ping operation.

create task

Creates a task for a function.

FuncApi.create task(task name, task type, function name, params)
or
FuncApi.create task(task name, task type, appName, function name, params)
Parameters
task name: str
task type: str
function name: str
params: dictionary
appName: str
Sample Code

Returns
Dictionary containing the result of the task creation.

create task by source uid

Creates a task for a function using source UID.

FuncApi.create task by source uid(task name, task type, source uid,
function name, params)
or
FuncApi.create task by source uid(task name, task type, source uid, appName,
function name, params)
Parameters
task name: str
task type: str
source uid: str
function name: str
params: dictionary
appName: str
Sample Code

Returns
Dictionary containing the result of the task creation.

TaskApi (Task APIs)

get task id

Description...

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

cancel tasks

Description...

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

cancel task

Description...

TaskApi.cancel task(taskId)
Parameters
taskId: string
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(requestId)
Parameters
requestId: string
Returns

None. Cancels the request for the provided Request ID

enqueue svc request

Description...

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

Cache api (Memory Cache APIs)

Delete APIs

remove

Removes from the cache by providing the key.

Cache api.remove(cache name, 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(cache name, key)
Parameters
cache name: name of the cache
key:       the identifier
Returns
A Result object indicating the success or failure of the operation.

clear

Clear all entries from the cache.

Cache api.clear(cache name)
Parameters
cache name
Returns
A Result object indicating the success or failure of the operation.

Create and Update API

put

Cache api.put(cache name, key, value)
Parameters
cache name: string
key: string
value: object
Returns
A Result object indicating the success or failure of the operation.

put no lock

Cache.put no lock(cache name, key, value)
Parameters
cache name: string
key: string
value: object
Returns
A Result object indicating the success or failure of the operation.

publish message

Publish a message to a specified topic.

Cache.publish message(topic, message)
Parameters
topic: string
message: string
Returns
A Result object indicating the success or failure of the operation.

Retrieve APIs

get memory cache

Get memory cache

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

get

Retrieve a value from the cache by providing the cache name and key.

Cache api.get(cache name, key)
Parameters
cache name: string
key: string
Returns
The value associated with the provided key in the cache.

get no lock

Retrieve a value from the cache without acquiring a lock.

Cache.get no lock(cache name, key)
Parameters
cache name: string
key: string
Returns
A Result object indicating the success or failure of the operation.

Storage api

get file path

For GCP cloud storage bucket Get the file path based on the file ID.

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

get fileid by path

For GCP cloud storage bucket Get the file ID based on the absolute file path.

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

get folder path

For GCP cloud storage bucket Get the folder path based on the folder ID.

Storage api.get folder path(folder id)
Parameters
folder id: string
Returns
Folder path.

get signed url

For GCP cloud storage bucket Get a signed URL for accessing a file.

Storage api.get signed url(file path)
or
Storage api.get signed url(file path, duration, unit)
or
Storage api.get signed url(bucket name, file path)
or
Storage api.get signed url(bucket name, file path, duration, unit)
Parameters
file path: string
duration: int
unit: string
bucket name: string
Returns
Signed URL for accessing the file.

copy file to bucket

For GCP cloud storage bucket Copy a file to the specified bucket.

Storage api.copy file to bucket(source file path, target file path)
or
Storage api.copy file to bucket(bucket name, source file path, target file path)
or
Storage api.copy file to bucket(bucket name, service account propname,
      source file path, target file path)
Parameters
source file path: string
target file path: string
bucket name: string
service account propname: string
Returns
Response from the server.

copy file from bucket

For GCP cloud storage bucket Copy a file from the specified bucket.

Storage api.copy file from bucket(source file path, target file path)
or
Storage api.copy file from bucket(bucket name, source file path,
target file path)
or
Storage api.copy file from bucket(bucket name, service account propname,
      source file path, target file path)
Parameters
source file path: string
target file path: string
bucket name: string
service account propname: string
Returns
Response from the server.

copy file within bucket

For GCP cloud storage bucket Copy a file within the same bucket.

Storage api.copy file within bucket(source file path, target file path)
or
Storage api.copy file within bucket(source file path, target file path,
make copy)
or
Storage api.copy file within bucket(bucket name, source file path,
target file path)
or
Storage api.copy file within bucket(bucket name, source file path,
target file path, make copy)
Parameters
source file path: string
target file path: string
make copy: bool
bucket name: string
Returns
Response from the server.

write to bucket

For GCP cloud storage bucket Write data to a file in the specified bucket.

Storage api.write to bucket(bytes, target file path, content type)
or
Storage api.write to bucket(bucket name, bytes, target file path,
content type)
Parameters
bytes: bytes[]
target file path: string
content type: string
bucket name: string
Returns
Response from the server.

read from bucket

For GCP cloud storage bucket Read the content of a file from the specified bucket.

Storage api.read from bucket(source file path)
or
Storage api.read from bucket(bucket name, source file path)
Parameters
source file path: string
bucket name: string
Returns
Content of the file.

list files

For GCP cloud storage bucket List files in the specified path.

Storage api.list files(pathName, versioned)
or
Storage api.list files(bucket name, pathName, versioned)
or
Storage api.list files(bucket name, pathName,
      versioned, page token, pageSize)
Parameters
pathName: string
versioned: bool
bucket name: string
page token: string
pageSize: int
Returns
List of dictionaries containing file details.

save file object

For GCP cloud storage bucket Save a file object.

Storage api.save file object(file object)
Parameters
file object: dictionary
Returns
Response from the server.

exists

Check if file exists.

Storage api.exists(file path)
Parameters
file path: string
Returns
True if the file exists, False otherwise.

get file list

Get list of files in folder

Storage api.get file list(folder id, orderBy)
Parameters
folder id: int
orderBy: string
Returns
List

get files pages

Get files pages
Storage api.get files page(bucket name, pathName,
      versioned)
or
Storage api.get files page(bucket name, pathName,
                      versioned, page token, pageSize)
Parameters
bucket name: string
pathName: string
versioned; bool
page token: string
pageSize: int
Returns
Files page

get bucket name

Get default bucket name.

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

share with tenants

For GCP cloud storage bucket Share a file with tenants.

Storage api.share with tenants(params)
Parameters
params: dictionary
Returns
Response from the server.

copy large file to bucket

For GCP cloud storage bucket Copy a large file to the specified bucket

Storage api.copy large file to bucket(source file path, target file path)
or
Storage api.copy large file to bucket(bucket name, source file path,
      target file path)
or
Storage api.copy large file to bucket((bucket name, service account propname,
      source file path, target file path)
Parameters
source file path: string
target file path: string
bucket name: string
service account propname: string
Returns
Response from the server.

make public

make a file public

Storage api.make public(bucket name, file path)
or
Storage api.make public(bucket name, service account propname,
      file path)
Parameters
bucket name: string
file path: string
service account propname: string
Returns
Response from the server.

get content

Get content of a doc

Storage api.get content(doc)
Parameters
doc: dictionary
Returns
Object

get bucket path

Get bucket path using file object

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

get bucket path

Get path using fileId

Storage api.get bucket path(fileId)
Parameters
fileId: string
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(debugOn)
Parameters
debugOn: bool
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(infoOn)
Parameters
infoOn: bool
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(warning on)
Parameters
warning on: bool
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(errorOn)
Parameters
errorOn: bool
Returns
None

a

Call logger.
Parameters

Returns
None

debug

Logs a debug message if debug logging is enabled

debug(msg)
Parameters
msg: string
Returns
None

info

Logs an info message if info logging is enabled

Call logger.info(msg)
Parameters
msg: string
Returns
None

warn

Logs an warning message if warning logging is enabled

Call logger.warn(msg)
Parameters
msg: string
Returns
None

error

Logs an error message if error logging is enabled.

Call logger.error(msg)
Parameters
msg: string
Returns
None

critical

Logs a critical message

Call logger.critical(msg)
Parameters
msg: string
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(logLevel)
Parameters
logLevel: string
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(collect call logs)
Parameters
collect call logs: bool
Returns
None

Command api

run os cmd

Run OS command
Command api.run os cmd(argList)
or
Command api.run os cmd(command)
Parameters
argList: List of strings
command: string
Returns
Result

OAuth1Api

get

Make a GET call
OAuth1Api.get(client key, client secret, token, token secret, realm,
restUtl)
or
OAuth1Api.get(client key, client secret, token, token secret, realm,
restUtl, headers)
Parameters
client key: string
client secret: string
token: string
token secret: string
realm; string
restUtl: string
headers: dictionary
Returns
Result

post

Make a POST call

OAuth1Api.post(client key, client secret, token, token secret, realm,
restUtl, body)
or
OAuth1Api.post(client key, client secret, token, token secret, realm,
restUtl, body, headers)
Parameters
client key: string
client secret: string
token: string
token secret: string
realm: string
restUtl: string
body: object
headers: dictionary
Returns
Result

post soap

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

post soap as xml

Make a POST Soap as XML call

OAuth1Api.post soap as xml(client key, client secret, token,
      token secret, realm, url, body)
or
OAuth1Api.post soap as xml(client key, client secret, token,
      token secret, realm, url, body, headers)
Parameters
client key: string
client secret: string
token: string
token secret: string
realm: string
url: string
body: string
headers: dictionary
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(dataset name, tableName, schema)
or
Big query api.create table(dataset name, tableName, class attrs)
or
Big query api.create table(dataset name, tableName,
      csv schema, class attrs, mappings)
parameters:
dataset name: dataset name (string)
tableName:   table name (string)
schema:       schema object (string)
class attrs:   class attributes (List of dictionaries)
csv schema:     csv representation object (List of dictionaries)
mappings:     mappings object (List of dictionaries)
Return : result
A Result object indicating the success or failure of the table creation
operation.

get bq datasets

Get the list of all dataset names.

Big query api.get bq datasets()
parameters:
none
Return:
A Result object containing the list of Big query datasets.

get bq tables

List the tables in a specific data set.

Big query api.get bq tables(dataset name)
parameters:
dataset name: name of the data set (string)
Return:
A Result object containing the list of tables within the specified
dataset.

get table

Retrieves table information from the data set.

Big query api.get table(dataset name, tableName)
or
Big query api.get table(dataset and tablename)
parameters:
dataset name:  name of the data set (string)
tableName:    name of the table (string)
dataset and tablename: (string)
Return:
A Result object containing information about the specified table.

get table fields

Retrieve field information for a table from Big query.

Big query api.get table fields(dataset and tablename)
or
Big query api.get table fields(dataset name, tableName)
Parameters
dataset and tablename: (string)
dataset name: (string)
tableName: (string)
Returns
A Result object containing field information for the specified table.

executeQuery

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

Big query api.executeQuery(query string)
parameters:
query string: query (string)
Return:
A Result object containing the query execution result.

get big query iterator

Get an iterator over table query.

Big query api.get big query iterator(query, start index, pageSize)
parameters:
query:      table query (string)
start index: index start (int)
pageSize:    page size (int)
Return:
A Result object containing the Big query iterator.

insert rows

Insert a list of rows into the table.

Big query api.insert rows(
      dataset name, tableName, list)
parameters:
dataset name:   dataset name (string)
tableName:     table in the data set (string)
list:          records to be inserted (List of dictionaries)
Return:
A Result object indicating the success or failure of the insert
operation.

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(dataset name, tableName, path to file,
      csv schema, class attrs, mappings, number of rows to skip)
or
Big query api.import csv into table(dataset name, tableName, path to file,
schema, number of rows to skip)
or
Big query api.import csv into table(dataset name, tableName, path, fileName,
schema, number of rows to skip)
parameters:
dataset name:   name of the dataset (string)
tableName:     name of the table in the data set (string)
path to file:    absolute path to the file on the system (string)
csv schema:     the csv schema (List of dictionaries)
class attrs:    attributes (List of dictionaries)
mappings:      mapping of attributes with schema (List of dictionaries)
number of rows to skip:   if skipping rows from the top of the csv file
(int)
fileName:      the name of the file (string)
schema:         the schema (Dictionary)
Return:
A Result object indicating the success or failure of the import
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(dataset name, tableName, source uri,
schema, number of rows to skip)
parameters:
dataset name:     name of the data set (string)
tableName:       name of the table in the dataset (string)
source uri:       the uri of source file (string)
schema:           the scheme of the csv (Dictionary)
number of rows to skip:   csv line to skip from the start
Return:
A Result object indicating the success or failure of the import
operation.

export table to csv

Exports dataset table into a CSV file.

Big query api.export table to csv(
      dataset name,
      tableName,
      path to file)
or
Big query api.export table to csv(
      dataset name,
      tableName,
      String ath, fileName)
parameters:
dataset name:   name of the data set (string)
tableName:     name of the table in the data set (string)
path to file:    path to the CSV file (string)
path:          same as above (string)
fileName:      name of the file (string)
Return:
A Result object indicating the success or failure of the export
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(
      dataset name,
      tableName,
      destination uri)
parameters:
dataset name:   name of the data set (string)
tableName:     name of the table in the data set (string)
destination uri:   the destination uri of csv file (string)
Return:
A Result object indicating the success or failure of the export
operation.

export table

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

Big query api.export table(
      dataset name,
      tableName,
      destination uri,
      data format)
parameters:
dataset name:   name of the dataset (string)
tableName:     name of the table in the dataset (string)
destination uri:   destination uri (string)
data format:    format of the exported data (string)
Return:
A Result object indicating the success or failure of the export
operation.

big query to csv

export data set table with specific columns to a CSV.
Big query api.big query to csv(file path, column names, dataset name,
bq tablename,
      query)
or
Big query api.big query to csv(file path, column names, dataset name,
bq tablename,
        query, function name)
parameters:
file path:       the path of the CSV file (string)
column names:    table column names (list of strings)
dataset name:    name of the data set (string)
bq tablename:    name of table (string)
query:          query to run (string)
function name:   extra function to be called (string)
Return:
A Result object indicating the success or failure of the export
operation.

getpage

Retrieve a page of data from Big query.
Big query api.getPage(query, start, size)
Parameters
query (string)
start (int)
size (int)
Returns
A Result object containing the requested page of data.

create table from csv

Create table from CSV

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

Parameters
dataset name (string)
tableName (string)
bucket filename (string)
bucket name (string)
Returns
A Result object indicating the success or failure of the table creation
operation.

import json by uri into table

import JSON by URI into table

Big query api.import json by uri into table(dataset name, tableName,
                                               source uri)
or
Big query api.import json by uri into table(dataset name, tableName,
                                                source uri, schema)
Parameters
dataset name (string)
tableName (string)
source uri (string)
schema (list)
Returns
A Result object indicating the success or failure of the import
operation.

big query to csv with script

Export data from Big query to a CSV file using a custom script.

Big query api.big query to csv with script(file path, column names,
      dataset name, bq tablename, query, script, script flavor)
Parameters
file path (string)
column names (list of strings)
dataset name (string)
bq tablename (string)
query (string)
script (string)
script flavor (string)
Returns
An integer indicating the success or failure of the export operation.

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 Trillo GCS bucket.

get trillo gcs bucket uri

same as above but returns a URI of storage bucket.

GCSApi.get trillo gcs bucket uri()
parameters:
none

Return:

The URI of the Trillo GCS bucket.

get gcs file uri

Get the file URI path from the cloud storage bucket.

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

parameters:

path to file: path to the file (string)
path:       same as above (string)
fileName:   name of the file (string)

Return:

The URI of the GCS file.

get local path

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

GCSApi.get local path (bucket path)

parameters:

bucket name and path (string)

Return:

The local path corresponding to the bucket path.

get gcs path

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

GCSApi.get gcs path(app data path)

parameters:

app data path (string)

Return:

The GCS path corresponding to the app data path.

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:
The temporary GCS path.

get default root folder

Get the default root path on the storage bucket.

GCSApi.get default root folder()

parameters:

none

Return:

The default root folder.

GCP auth api

get token info

Description...

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

refresh access token

Description...

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

GCP rest api

get

Make GET call for GCP rest api.

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

post

Make POST call for GCP rest api.

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

put

Make PUT call for GCP rest api.

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

delete

Make DELETE call for GCP rest api.

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

patch

Make PATCH call for GCP rest api.

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

publish

publish message
GCP rest api.publish(topicId, message)
Parameters
topicId (string)
message (object)
Returns
Result

subscribe

subscribe message

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

unsubscribe

unsubscribe message

GCP rest api.service account key to token(service account key propname,
      authentication path)
Parameters
service account key propname (string)
authentication path (string)
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(project id)
Parameters
project id (string)
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(authentication type)
Parameters
authentication type (string)
Returns
None

isError

is error

GCP token info.isError()
Parameters
None
Returns
boolean

set error

set error

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

get message

get message

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

set message

set message

GCP token info.set message(message)
Parameters
message (string)
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 (className, pk attrname, data)
Parameters
className:   name of the class object (string)
pk attrname:  which attribute is the primary key (string)
data:        the data hashmap (dictionary)
Returns
A dictionary representation of newly created class
Object make class from data(className, tableName, pk attrname, data)
Parameters
className:   name of the class object (string)
tableName:   name of the table in the database (string)
pk attrname:  which attribute is the primary key (string)
data:        the data hashmap (dictionary)

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

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

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(className, pk attrname, data, attrtype by names),
skip saving
Parameters
className:   name of the class object (string)
pk attrname:  which attribute is the primary key (string)
data:        data hashmap (dictionary)
attrtype by names: columns types and names (dictionary)
skip saving: true create the table only in memory (bool)

create metadata

create metadata
MetaApi.create metadata(md)
Parameters
md (dictionary)
Returns
Response from the server.

save metadata

save metadata

MetaApi.save metadata(md)
Parameters
md (dictionary)
Returns
Response from the server.

get app datadir

Locate and get the application data directory

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

save class

Save class details.
MetaApi.save class(className, clsM)
Parameters
className (string)
clsM (ClassM)
Returns
Response from the server.

update class visibility

update Class Visibility
MetaApi.update class visibility(className, visibility)
Parameters
className (string)
visibility (string)
Returns
Response from the server.

create function sys task

Create a function system task.

MetaApi.create function sys task(mdId)
or
MetaApi.create function sys task(orgName, name)
Parameters
mdId (string)
orgName (string)
name (string)
Returns
Response from the server.

- All Retrieve Only

get app datadir

Locate and get the application data directory

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

getclass m

Get the object representing the class

MetaApi.getclass m(className)
Parameters
className: name of the class (string)

Returns

Class metadata.

get schema for data studio

Get class schema for the data studio

MetaApi.get schema for data studio(className, include all sys attrs)
Parameters
className:          name of the class (string)
include all sys attrs:  include all system attributes (bool)
Returns
List of dictionaries containing schema details.

get domain file as map

get domain file as a hashmap.

MetaApi.get domain file as map(fileName)
Parameters
fileName:    name of the file (string)
Returns
Content of the domain file as a dictionary.

getMetadata

Get metadata based on the ID.

MetaApi.getMetadata(id)
or
MetaApi.getMetadata(model classname, folder, name)
Parameters
id (string)
model classname (string)
folder (string)
name (string)
Returns
Metadata details.

get classes

Get classes based on the provided filter.

MetaApi.get classes(filter)
or
MetaApi.get classes(dsName, filter)
or
MetaApi.get classes(dsName, schemaName, filter)
or
MetaApi.get classes(appName, dsName, schemaName, filter)
Parameters
filter (string)
dsName (string)
schemaName (string)
appName (string)
Returns
List of classes.

get class names

Get class names based on the provided filter.

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

get data source names

Get data source names based on the provided filter.

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

get data sources

Get data sources based on the provided filter.

MetaApi.get data sources(filter)
or
MetaApi.get data sources(appName, filter)
Parameters
filter (string)
appName (string)
Returns
List of data sources.

UMApi (User, Tenant, Roles APIs)

get current user

Get the current login user.

UMApi.get current user()
Parameters
None
Returns
dictionary

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
int

is numeric

Check if i string number is numeric.

UMApi.is numeric(strNum)
Parameters
strNum: number (string)
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
int

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(userId)
Parameters
userId (string)
Returns
Object

getUser

get user using id

UMApi.getUser(id)
Parameters
id (string)
Returns
Object

HttpApi (HTTP APIs)

get

Retrieve a json result using HTTP get.

HttpApi.get(request url)
or
HttpApi.get(request url, headers)
or
HttpApi.get(request url, headers, retry count, wait time)
or
HttpApi.get with retry(request url, headers)
Parameters
request url (string)
headers (dictionary)
retry count (int)
wait time (int)
Returns
The response object from the GET request.

post

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

HttpApi.post(request url, body)
or
HttpApi.post(request url, body, headers)
or
HttpApi.post as string(request url, body)
or
HttpApi.post as string(request url, body, headers)
or
HttpApi.post form data(request url, body, headers)
or
HttpApi.post form data as string(request url, body, headers)
or
HttpApi.post soap(soapUrl, body, headers)
Parameters
request url:    requested URL  (string)
body:          body of the request (dictionary)
headers:       headers (dictionary)
Returns
The response object from the POST request.

put

Execute HTTP put with a given body and a header to the requested URL.
HttpApi.put(request url, body)
or
HttpApi.put(request url, body, headers)
Parameters
request url:    requested url (string)
body:          payload (dictionary)
headers:       headers (dictionary)
Returns
The response object from the PUT request.

patch

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

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

delete

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

HttpApi.delete(request url, body)
or
HttpApi.delete(request url, body, headers)

Parameters

request url:      requested url  (string)
body:             body of the request (dictionary)
headers:         headers (dictionary)
Returns
the result of the operation

get as string

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

post as string

Description...

HttpApi.post as string(request url, body)
or
HttpApi.post as string(request url, body, headers)
Parameters
request url (string)
body (object)
headers (dictionary)
Returns
Result

putas string

Description...

HttpApi.putas string(request url, body)
or
HttpApi.putas string(request url, body, headers)
Parameters
request url (string)
body (object)
headers (dictionary)
Returns
Result

patch as string

Description...

HttpApi.patch as string(request url, body)
or
HttpApi.patch as string(request url, body, headers)
Parameters
request url (string)
body (object)
headers (dictionary)
Returns
Result

delete as string

Description...

HttpApi.delete as string(request url, body)
or
HttpApi.delete as string(request url, body, headers)
Parameters
request url (string)
body (object)
headers (dictionary)
Returns
Result

read file as json

Description...

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

read file as string

Description...

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

read file as bytes

Description...

HttpApi.read file as bytes(url, header map)
Parameters
url (string)
header map (dictionary)
Returns
Result

writeFile

Description...

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

writefile bytes

Description...
HttpApi.writefile bytes(url,fileName, file content, file field name,
header map)
or
HttpApi.writefile bytes(url,fileName, file content, file field name,
header map,
 additional fields)
or
HttpApi.writefile bytes(url, fileName, file content as string,
file field name, header map)
or
HttpApi.writefile bytes(url, fileName, file content as string,
file field name, header map,
additional fields)
Parameters
url (string)
fileName (string)
file content (List of bytes)
file field name (string)
header map (dictionary)
additional fields (dictionary)
file content as string (string)
Returns
Result

writefile bytes

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

SFTPApi

get

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

put

Description...

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

ls

Description...

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

File util

get file extension

Returns the extension of the file.

File util.get file extension(fileName)
Parameters
fileName (string)
Returns
The extension of the file.

copy file

Copies a file from the source path to the destination path while preserving the metadata.

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

rename to

Renames a file or directory.

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

readFile

Scans through a file and reads all the lines

File util.readFile(file, number of lines)
Parameters
file (File)
number of lines (int)
Returns
The content of the file.

writeFile

Writes content to a file.

File util.writeFile(file, buf)
or
File util.writeFile(file, bytes)
Parameters
file (File)
buf (string)
bytes (List of bytes)
Returns
None

get file timestamp

Gets the timestamp of the last modification of a file.

File util.get file timestamp(f)
Parameters
f (File)
Returns
The timestamp of the last modification of the file.

is file modified before

Checks if the file was modified before the provided timestamp

File util.is file modified before(f, ts)
Parameters
f (File)
ts (float)
Returns
True if the file has been modified before the specified timestamp;
otherwise, False.

is file modified before delta

Checks if a file has been modified before a specified timestamp with a given delta.

File util.is file modified before delta(f, ts, delta)
Parameters
input file (File)
Timestamp (float)
delta (float)
Returns
True if the file has been modified before the specified timestamp with
a difference greater than the delta; otherwise, False.

get file bufferedreader

Description...

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

get unique filename

Generates a unique file name by appending a numerical suffix to the given prefix.

File util.get unique filename(dirName, fileName)
or
File util.(dirName, filename prefix, ext)
Parameters
dirName (string)
fileName (string)
filename prefix (string)
ext (string)
Returns
A unique file name within the specified directory.

get file list

Description...

File util.get file list(path, file extensions)
Parameters
path (string)
file extensions (string)
Returns
List of files

get file list nonrecursive

Description...

File util.get file list nonrecursive(path, extensions)
Parameters
path (string)
extensions (List of strings)
Returns
List of files

getFile

Description...

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

copy text file

Copies a text file from the source path to the destination path.

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

is resizable image file

Description...

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

get supported file types

Description...

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

Remove temp

Description...

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

Remove temp

Description...

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

Remove temp

Description...

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

take off bom

Description...

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

list directory

Description...

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

list directory

Description...

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

validate file path

Description...

Parameters
parent (string)
file (File)
Returns
None

validate file path

Description...

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

CSVApi

csv get all rows

Retrieve all rows from a CSV file.

CSVApi.csv get all rows(file path)
or
CSVApi.csv get all rows(file path, separator)
or
CSVApi.csv get all rows(file path, separator, column names)
or
CSVApi.csv get all rows(file path, separator, column names, column name line)
Parameters
file path (string)
separator (string)
column names (List of strings)
column name line (int)
Returns
A list of dictionaries representing the rows in the CSV file.

csv get page

Retrieve a page of data from a CSV file based on query parameters.

CSVApi.csv get page(fileName, separator str,
      column names, column name line, query, start index, pageSize)
or
CSVApi.csv get page(fileName, separator char,
      column names, column name line, query, start index, pageSize)
Parameters
fileName (string)
separator char (string)
column names (List of string)
column name line (int)
query (string)
start index (int)
pageSize (int)
Returns
A list of dictionaries representing the requested page of data from the
CSV file.

get csv iterator

Description...

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

get csv iterator

Description...

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

get csv iterator

Description...

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

get csv iterator

Description...

CSVApi.get csv import iterator(id, limit)
or
CSVApi.get csv import iterator(id, limit,
      mappings)
or
CSVApi.get csv import iterator(id, model classname, limit,
      mappings)
Parameters
id (string)
limit (int)
mappings (list of dictionaries)
model classname (string)
Returns
Object

get csv iterator

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

Email api (Email APIs)

send email

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

Email api.send email(appName, email, subject, content,
      template, from alias, template params)
or
Email api.send email(appName, email, subject, content,
      template, from alias, template params, sender email)
or
Email api.send email(toEmail, subject, content)
or
Email api.send email(toEmail, template,
      email params, subject)
parameters:
appName:     name of the internal application (string)
email:       email of the sender (string)
subject:     subject of a email (string)
content:     contents (string)
template:    template to be used  (string)
from alias:   alias name   (string)
template params:   template parameters (dictionary)
sender email:      sender email (string)
toEmail:     to email (string)
email params : email params (dictionary)
Return:
A Result object indicating the success or failure of the email sending
operation.

send email markdown content

Send email with markdown contents.

Email api.send email markdown content(mailTo, body, subject)
parameters:
mailTo:    recipient address (string)
body:      body with markdown (string)
subject:   subject of the email (string)
Return:
A Result object indicating the success or failure of the email sending
operation.

send email using function

Send email using the function

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

get subject

Get subject

Email api.get subject(template name, default subject,
      email params)
parameters:
template name (string)
default subject (string)
email params (dictionary)

Return:

String

get processed email content from template

get processed email content from template

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

email template exists

check if the email template exits

Email api.email template exists(template name)

parameters:

template name (string)

Return:

boolean

get email props

get email props

Email api.get email props(template name)

parameters:

template name (string)

Return:

Dictionary

get servername

get server name

Email api.get servername()
parameters:
None

Return:

String

DLPApi

inspect

Perform data inspection to identify sensitive information in text

DLPApi.inspect(text, information types)
Parameters
text: Text to be inspected for sensitive information as str.
information types: List of information types to search for in the text.
Returns
A Result object indicating the success or failure of the inspection
operation.

redact image

Redact sensitive information from an image.

DLPApi.redact image(byte image, image type, information type)
Parameters
byte image: Byte data representing the image to be redacted.
image type: Type of the image (e.g., IMAGE_JPEG, IMAGE_PNG).
information type: Type of information to redact from the image.

Returns

A Result object indicating the success or failure of the redaction
operation.

redact pii

Redact Personally Identifiable Information (PII) from text.

DLPApi.redact pii(text)
Parameters
text: Text containing PII to be redacted as str.
Returns
A Result object indicating the success or failure of the redaction
operation.

DocApi

get folders

Retrieve a list of all document folders.

DocApi.get folders()
Parameters
None
Returns
A list of dictionaries representing document folders.

get doc folder and doc list

Retrieve documents and subfolders within a specified folder.

DocApi.get doc folder and doc list(folder id, orderBy, deleted)
Parameters
folder id: The ID of the folder as str.
orderBy: Sorting order for the documents and subfolders as str.
deleted: Flag indicating whether to include deleted items as str.
Returns
A dictionary containing documents and subfolders information.

list hit l docs

DocApi.list hit l docs(folder id, orderBy, deleted)
Parameters
folder id: The ID of the folder as str.
orderBy: Sorting order for the documents as str.
deleted: Flag indicating whether to include deleted documents as str.
Returns
A dictionary containing HITL document information.

get doc folder list

Retrieve a list of subfolders within a specified folder.

DocApi.get doc folder list(folder id, orderBy)
Parameters
folder id: The ID of the folder int.
orderBy: Sorting order for the subfolders str.
Returns
A list of dictionaries representing subfolders.

get doc folder parents

Retrieve the parent folders of a specified folder.

DocApi.get doc folder parents(folder id)
Parameters
folder id: The ID of the folder as str.
Returns
A dictionary containing parent folder information.

get home folder files

Retrieve documents within the home folder.

DocApi.get home folder files(folder id, orderBy)
Parameters
folder id: The ID of the home folder as str.
orderBy: Sorting order for the documents as str.
Returns
A list of dictionaries representing documents in the home folder.

get do cai schema

Retrieve the schema for document AI processing.

DocApi.get do cai schema(schema displayname)
Parameters
schema displayname: Display name of the document AI schema as str.
Returns
A dictionary containing document AI schema information.

create doc folder

Create a new document folder.

DocApi.create doc folder(folder)
Parameters
folder: Dictionary representing the folder to be created as dict.
Returns
A Result object indicating the success or failure of the folder
creation.

update folder

Update an existing document folder.

DocApi.update folder(folder)
Parameters
folder: Dictionary representing the folder to be updated.
Returns
A Result object indicating the success or failure of the folder update.

update doc folder properties

Update properties of a document folder.

DocApi.update doc folder properties(params)
Parameters
params: Dictionary containing folder properties to be updated.
Returns
A Result object indicating the success or failure of the folder
properties update.

rename doc folder

Rename a document folder.

DocApi.rename doc folder(folder id, newName)
Parameters
folder id: The ID of the folder to be renamed as str.
newName: The new name for the folder as str.
Returns
A Result object indicating the success or failure of the folder
renaming.

move doc folder

Move a document folder to a new parent folder.

DocApi.move doc folder(folder id, new parentid)
Parameters
folder id: The ID of the folder to be moved as str.
new parentid: The ID of the new parent folder as str.
Returns
A Result object indicating the success or failure of the folder
movement.

delete doc folder

Delete a document folder.

DocApi.delete doc folder(folder id)
Parameters
folder id: The ID of the folder to be deleted as str.
Returns
A Result object indicating the success or failure of the folder
deletion.

create upload signed url

Create a signed URL for uploading files to a document folder.

DocApi.create upload signed url(folder id: str, duration: int) -> Result
Parameters
folder id: The ID of the folder for uploading.
duration: Duration of the signed URL validity in seconds.
Returns
A Result object containing the signed URL for upload.

create download signed url

Create a signed URL for downloading files from a document folder.

DocApi.create download signed url(folder id: str, duration: int) -> Result
Parameters
folder id: The ID of the folder for downloading.
duration: Duration of the signed URL validity in seconds.
Returns
A Result object containing the signed URL for download.

rename doc

Rename a document.
DocApi.rename doc(docId: str, newName: str) -> Result
Parameters
docId: The ID of the document to be renamed.
newName: The new name for the document.
Returns
A Result object indicating the success or failure of the document
renaming.

moveDoc

Move a document to a new parent folder.

DocApi.moveDoc(docId: str, new parent folder id: str) -> Result
Parameters
docId: The ID of the document to be moved.
new parent folder id: The ID of the new parent folder.
Returns
A Result object indicating the success or failure of the document
movement.

delete doc

Delete a document.
DocApi.delete doc(docId: str) -> Result
Parameters
docId: The ID of the document to be deleted.
Returns
A Result object indicating the success or failure of the document
deletion.

delete many docs

Delete multiple documents.

DocApi.delete many docs(ids: list, permanent: bool) -> Result
Parameters
ids: List of document IDs to be deleted.
permanent: Flag indicating whether to permanently delete the documents.
Returns
A Result object indicating the success or failure of the document
deletion.

restore many docs

Restore multiple deleted documents.

DocApi.restore many docs(ids: list) -> Result
Parameters
List of document IDs to be restored.
Returns
A Result object indicating the success or failure of the document
restoration.

copyDoc

Copy a document to a new parent folder with a new name.

DocApi.copyDoc(docId: str, new parent folder id: str, newName: str) ->
Result
Parameters
docId: The ID of the document to be copied.
new parent folder id: The ID of the new parent folder.
newName: The new name for the copied document.
Returns
A Result object indicating the success or failure of the document
copying.

save doc object

Save document object.

DocApi.save doc object(params: dict) -> Result
Parameters
params: Dictionary containing document object to be saved.
Returns
A Result object indicating the success or failure of the document
object saving.

update doc properties

Update properties of a document.

DocApi.update doc properties(params: dict) -> Result
Parameters
params: Dictionary containing document properties to be updated.
Returns
A Result object indicating the success or failure of the document
properties update.

retrieve signed url

Retrieve a signed URL for accessing a document.

DocApi.retrieve signed url(docId: str, content type: str, as attachment:
bool, duration: int) -> Result
Parameters
docId: The ID of the document.
content type: MIME type of the document.
as attachment: Flag indicating whether to treat the document as an
attachment.
duration: Duration of the signed URL validity in seconds.

Returns

A Result object containing the signed URL for document access.

retrieve upload signed url

Retrieve a signed URL for uploading a document to a folder.

DocApi.retrieve upload signed url(folder id: str, fileName: str,
content type: str) -> Result
Parameters
folder id: The ID of the folder for uploading.
fileName: Name of the file to be uploaded.
content type: MIME type of the document.
Returns
A Result object containing the signed URL for upload.

save doc get signed url

Save document object and retrieve a signed URL.

DocApi.save doc get signed url(params: dict) -> Result
Parameters
params: Dictionary containing document object to be saved.

Returns

A Result object containing the saved document object and a signed URL.

autoComplete

Perform auto-completion.

DocApi.autoComplete(params: dict) -> Result
Parameters
params: Dictionary containing parameters for auto-completion.
Returns
A Result object containing the auto-completion result.

execute workflow

Execute a document workflow.
DocApi.execute workflow(params: dict) -> Result
Parameters
params: Dictionary containing parameters for the document workflow
execution.
Returns
A Result object indicating the success or failure of the workflow
execution.

extract entities

Extract entities from a document.

DocApi.extract entities(params: dict) -> Result
Parameters
params: Dictionary containing parameters for entity extraction.
Returns
A Result object containing the extracted entities.

chat

Perform document chat operation.

DocApi.chat(params: dict) -> Result
Parameters
params: Dictionary containing parameters for document chat.
Returns
A Result object containing the chat result.

generate json

Generate JSON from a document.

DocApi.generate json(params: dict) -> Result
Parameters
params: Dictionary containing parameters for JSON generation.
Returns
A Result object containing the generated JSON.

bulk upload

Perform bulk upload of documents.

DocApi.bulk upload(params: dict) -> Result
Parameters
params: Dictionary containing parameters for bulk upload.
Returns
A Result object indicating the success or failure of the bulk upload.

delete do cai schema

Delete a document AI schema.

DocApi.delete do cai schema(schema displayname: str) -> Result
Parameters
schema displayname: Display name of the document AI schema.
Returns
A Result object indicating the success or failure of the schema
deletion.

Folder api

get full folder tree

Retrieves the full folder tree.

Folder api.get full folder tree(orderBy) -> List[Dict]
Parameters
orderBy: Specifies the ordering of the folders.
Returns
List of dictionaries representing the full folder tree.

get home folder tree

Retrieves the home folder tree.

Folder api.get home folder tree(orderBy) -> Dict
Parameters
orderBy: Specifies the ordering of the folders.
Returns
Dictionary representing the home folder tree.

get home subfolder tree

Retrieves the subfolders of the home folder.

Folder api.get home subfolder tree(orderBy) -> List[Dict]
Parameters
orderBy: Specifies the ordering of the folders.

Returns

List of dictionaries representing the subfolders of the home folder.

get folder and files

Retrieves the contents of a folder including subfolders and files.

Folder api.get folder and files(folder id, orderBy, deleted) -> Dict
Parameters
folder id: The ID of the folder to retrieve contents from.
orderBy: Specifies the ordering of the contents.
deleted: Indicates whether to include deleted items.
Returns
Dictionary containing the folder and its files.

get subfolders

Retrieves the subfolders of a folder.

Folder api.get subfolders(folder id, orderBy) -> Dict
Parameters
folder id: The ID of the folder to retrieve subfolders from.
orderBy: Specifies the ordering of the subfolders.
Returns
Dictionary containing the subfolders of the specified folder.

get folder parents

Retrieves the parent folders of a folder.

Folder api.get folder parents(folder id) -> Dict
Parameters
folder id: The ID of the folder to retrieve parent folders for.
Returns
Dictionary containing the parent folders of the specified folder.

get home folder files

Retrieves the files in the home folder.

Folder api.get home folder files(orderBy) -> Dict
Parameters
orderBy: Specifies the ordering of the files.
Returns
Dictionary containing the files in the home folder.

get folder task

Retrieves the task associated with a folder.

Folder api.get folder task(folder id) -> Dict
Parameters
folder id: The ID of the folder to retrieve the task for.
Returns
Dictionary containing the task associated with the folder.

create folder

Creates a new folder.

Folder api.create folder(folder) -> Dict
Parameters
folder: Dictionary representing the folder to be created.

Returns

Dictionary containing the result of the folder creation operation.

update folder

Updates an existing folder.

Folder api.update folder(folder) -> Dict
Parameters
folder: Dictionary representing the folder to be updated.
Returns
Dictionary containing the result of the folder update operation.

rename folder

Renames a folder.

Folder api.rename folder(folder id, newName) -> Dict
Parameters
folder id: The ID of the folder to be renamed.
newName: The new name for the folder.
Returns
Dictionary containing the result of the folder rename operation.

move folder

Moves a folder to a new parent folder.
Folder api.move folder(folder id, new parentid) -> Dict
Parameters
folder id: The ID of the folder to be moved.
new parentid: The ID of the new parent folder.
Returns
Dictionary containing the result of the folder move operation.

delete folder

Deletes a folder.

Folder api.delete folder(folder id) -> Dict
Parameters
folder id: The ID of the folder to be deleted.
Returns
Dictionary containing the result of the folder deletion operation.

delete group

Deletes a group.

Folder api.delete group(groupId) -> Dict
Parameters
groupId: The ID of the group to be deleted.
Returns
Dictionary containing the result of the group deletion operation.

create upload signed url

Creates a signed URL for uploading files to a folder.

Folder api.create upload signed url(folder id, duration=None) -> Dict
Parameters
folder id: The ID of the folder where files will be uploaded.
duration: The duration for which the signed URL is valid (optional).
Returns
Dictionary containing the signed URL for uploading files.

create download signed url

Creates a signed URL for downloading files.

Folder api.create download signed url(id, baseUri=None, duration=None) ->
Dict
Parameters
id: The ID of the file to be downloaded.
baseUri: The base URI for downloading the file (optional).
duration: The duration for which the signed URL is valid (optional).
Returns
Dictionary containing the signed URL for downloading files.

rename file

Renames a file.

Folder api.rename file(fileId, newName) -> Dict
Parameters
fileId: The ID of the file to be renamed.
newName: The new name for the file.
Returns
Dictionary containing the result of the file rename operation.

move file

Moves a file to a new parent folder.

Folder api.move file(fileId, new parent folder id) -> Dict
Parameters
fileId: The ID of the file to be moved.
new parent folder id: The ID of the new parent folder.
Returns
Dictionary containing the result of the file move operation.

delete file

Deletes a file.

Folder api.delete file(fileId) -> Dict
Parameters
fileId: The ID of the file to be deleted.
Returns
Dictionary containing the result of the file deletion operation.

delete file2

Deletes a file with additional folder name.

Folder api.delete file2(fileId, folder name) -> Dict
Parameters
fileId: The ID of the file to be deleted.
folder name: The name of the folder containing the file.
Returns
Dictionary containing the result of the file deletion operation.

delete many files

Deletes multiple files.

Folder api.delete many files(ids) -> Dict
Parameters
ids: List of IDs of files to be deleted.
Returns
Dictionary containing the result of the file deletion operation.

restore many files

Restores multiple files from the trash.

Folder api.restore many files(ids, keepId) -> Dict
Parameters
ids: List of IDs of files to be restored.
keepId: Indicates whether to keep the original IDs.
Returns
Dictionary containing the result of the file restoration operation.

copy file

Copies a file to a new location.

Folder api.copy file(fileId, new parent folder id, newName) -> Dict
Parameters
fileId: The ID of the file to be copied.
new parent folder id: The ID of the destination folder.
newName: The new name for the copied file.
Returns
Dictionary containing the result of the file copy operation.

share file

Shares a file with a user.

Folder api.share file(fileId, target folder path, id of user to share with) ->
Dict
Parameters
fileId: The ID of the file to be shared.
target folder path: The path of the folder where the file will be shared.
id of user to share with: The ID of the user to share the file with.
Returns
Dictionary containing the result of the file sharing operation.

assign file

Assigns a file to a user.

Folder api.assign file(fileId, id of user to assign) -> Dict
Parameters
fileId: The ID of the file to be assigned.
id of user to assign: The ID of the user to assign the file to.
Returns
Dictionary containing the result of the file assignment operation.

update status

Updates the status of a file.

Folder api.update status(fileId, status) -> Dict
Parameters
fileId: The ID of the file to update the status for.
status: The new status of the file.
Returns
Dictionary containing the result of the status update operation.

save file object

Saves a file object.

Folder api.save file object(params) -> Dict
Parameters
params: Parameters to save the file object.
Returns
Dictionary containing the result of the file object saving operation.

save file object with task

Saves a file object with a task.

Folder api.save file object with task(params) -> Dict
Parameters
params: Parameters to save the file object with task.
Returns
Dictionary containing the result of the file object saving operation
with task.

save file object with function

Saves a file object with a function.

Folder api.save file object with function(params) -> Dict
Parameters
params: Parameters to save the file object with function.
Returns
Dictionary containing the result of the file object saving operation
with function.

retrieve signed url

Retrieves a signed URL for a file.

Folder api.retrieve signed url(params) -> Dict
Parameters
params: Parameters to retrieve the signed URL.
Returns
Dictionary containing the signed URL for the file.

save file get signed url

Saves a file and retrieves a signed URL.

Folder api.save file get signed url(params) -> Dict
Parameters
params: Parameters to save the file and retrieve the signed URL.
Returns
Dictionary containing the result of the file saving operation and the
signed URL.

retrieve signed url public

Retrieves a signed URL for a public file.

Folder api.retrieve signed url public(params) -> Dict
Parameters
params: Parameters to retrieve the signed URL for a public file.
Returns
Dictionary containing the signed URL for the public file.

save folder task

Saves a folder task.

Folder api.save folder task(params) -> Dict
Parameters
params: Parameters to save the folder task.
Returns
Dictionary containing the result of the folder task saving operation.

search

Searches for items based on provided parameters.

Folder api.search(params) -> Dict
Parameters
params: Parameters for the search operation.
Returns
Dictionary containing the search results.

autoComplete

Provides auto-completion based on provided parameters.

Folder api.autoComplete(params) -> Dict
Parameters
params: Parameters for the auto-completion operation.
Returns
Dictionary containing the auto-completion results.

isBusy

Checks if a provider is busy.

Folder api.isBusy(provider name) -> Dict
Parameters
provider name: The name of the provider to check.
Returns
Dictionary containing the result of the provider busy check.

start full sync task

Starts a full synchronization task for a provider.

Folder api.start full sync task(provider name) -> Dict
Parameters
provider name: The name of the provider to start the full sync task for.

Returns

Dictionary containing the result of the full sync task start operation.

sync folder

Synchronizes a folder.

Folder api.sync folder(folder id) -> Dict
Parameters
folder id: The ID of the folder to synchronize.
Returns
Dictionary containing the result of the folder synchronization
operation.

get create group folder with files

Retrieves or creates a group folder with files.

Folder api.get create group folder with files(path) -> Dict
Parameters
path: The path of the group folder.
Returns
Dictionary containing the result of the group folder retrieval or
creation operation.

retrieve many upload signed urls

Retrieves many signed URLs for uploading files.

Folder api.retrieve many upload signed urls(bucket name, folder name,
subFolder, folder id, fileNames, content type, duration, function name,
function params) -> Dict
Parameters
bucket name: The name of the bucket.
folder name: The name of the folder.
subFolder: The subfolder within the folder.
folder id: The ID of the folder.
fileNames: List of file names.
content type: The content type of the files.
duration: The duration for which the signed URL is valid.
function name: The name of the function.
function params: The parameters for the function.

Returns

Dictionary containing the result of the signed URL retrieval operation.

retrieve signed url (multimethod)

Retrieves a signed URL for a file using different parameters.
Folder api.retrieve signed url(fileId, bucket name, folder name, subFolder,
folder id, fileName, content type, method, as attachment, duration,
public share) -> Dict
Parameters
fileId: The ID of the file.
bucket name: The name of the bucket.
folder name: The name of the folder.
subFolder: The subfolder within the folder.
folder id: The ID of the folder.
fileName: The name of the file.
content type: The content type of the file.
method: The method for retrieving the signed URL.
as attachment: Indicates whether to treat the file as an attachment.
duration: The duration for which the signed URL is valid.
public share: Indicates whether the file is publicly shared.
Returns
Dictionary containing the signed URL for the file.

GCP gen api

chat

Perform a chat operation using parameters.

GCP gen api.chat(params: Dict[str, Union[str, int]]) -> object
Parameters
params: A dictionary containing parameters for the chat operation.
Returns
An object representing the chat result.

summarize text

Summarize the given text.

GCP gen api.summarize text(text: str) -> 'Result'
Parameters
text: The text to be summarized.
Returns
A 'Result' object representing the summarized text.

classify text

Classify the given text based on input classes.

GCP gen api.classify text(input classes: List[str], text: str) -> 'Result'
Parameters
input classes: List of classes for classification.
text: The text to be classified.
Returns
A 'Result' object representing the classification result.

ams

Perform AMS (Answer Matching System) operation on the given text.

GCP gen api.ams(text: str) -> 'Result'
Parameters
text: The text for AMS operation.
Returns
A 'Result' object representing the AMS result.

generate embedding

Generate embedding for the given text.

GCP gen api.generate embedding(text: str) -> 'Result'
Parameters
text: The text for which embedding needs to be generated.
Returns
A 'Result' object representing the embedding.

generate image in bucket

Generate image in a GCS bucket based on the prompt.

GCP gen api.generate image in bucket(prompt: str, image count: int,
output gcs uri folder: str) -> 'Result'
Parameters
prompt: The prompt for image generation.
image count: The number of images to generate.
output gcs uri folder: The output folder URI in GCS.
Returns
A 'Result' object representing the image generation result.

generate image as byte

Generate image as bytes based on the prompt.

GCP gen api.generate image as byte(prompt: str, image count: int) -> 'Result'
Parameters
prompt: The prompt for image generation.
image count: The number of images to generate.
Returns
A 'Result' object representing the image generation result.

generate code

Generate code based on the prompt.

GCP gen api.generate code(prompt: str) -> 'Result'
Parameters
prompt: The prompt for code generation.
Returns
A 'Result' object representing the code generation result.

text

Generate text based on the prompt.

GCP gen api.text(prompt: str) -> 'Result'
Parameters
prompt: The prompt for text generation.
Returns
A 'Result' object representing the text generation result.

extract entities from text list

Extract entities from a list of texts based on the prompt.

GCP gen api.extract entities from text list(prompt: str, texts: List[str]) ->
'Result'
Parameters
prompt: The prompt for entity extraction.
texts: List of texts from which entities need to be extracted.
Returns
A 'Result' object representing the entity extraction result.

extract entities from text

Extract entities from a single text based on the prompt.

GCP gen api.extract entities from text(prompt: str, text: str) -> 'Result'
Parameters
prompt: The prompt for entity extraction.
text: The text from which entities need to be extracted.
Returns
A 'Result' object representing the entity extraction result.

vertex a i get answer

Get an answer from Vertex AI based on the question and datastore ID.

GCP gen api.vertex a i get answer(question: str, datastore id: str) ->
'Object'
Parameters
question: The question for which an answer is needed.
datastore id: The ID of the datastore.
Returns
An object representing the answer from Vertex AI.

Util

as json pretty string

Convert an object to a pretty-printed JSON string.

Util.as json pretty string(obj: Any) -> str
Parameters
obj: Object to convert.
Returns
A pretty-printed JSON string representation of the object.

convert to result

Convert a response to a Result object if possible.

Util.convert to result(r) -> Result or None
Parameters
r: Response object to convert.
Returns
Result object if conversion is successful, otherwise None.

as json string

Convert an object to a JSON string.

Util.as json string(obj: Any) -> str
Parameters
obj: Object to convert.
Returns
JSON string representation of the object.

from json string

Convert a JSON string to an object of the specified class.

Util.from json string(json_str: str, cls: Any) -> Any
Parameters
json_str: JSON string to convert.
cls: Class of the object to create.
Returns
Object created from the JSON string

from json string as map

Convert a JSON string to a dictionary.

Util.from json string as map(json_str: str) -> Dict[str, Any]
Parameters
json_str: JSON string to convert.

Returns

Dictionary created from the JSON string.

save as json string

Save an object as JSON to a file.

Util.save as json string(file_path: str, obj: Any) -> None
Parameters
file_path: Path of the file to save.
obj: Object to save as JSON.
Returns
None.

from string to date

Convert a string to a datetime object.

Util.from string to date(date, format="%Y-%m-%d %H:%M:%S") -> datetime
Parameters
date: String representing the date.
format: Format of the date string (default is "%Y-%m-%d %H:%M:%S").
Returns
Datetime object.

from date tostring

Convert a datetime object to a string.

Util.from date tostring(date: datetime, format: str = "%Y-%m-%d
%H:%M:%S") -> str
Parameters
date: Datetime object to convert.
format: Format of the output string (default is "%Y-%m-%d %H:%M:%S").
Returns
String representing the datetime.

gen random alphanum

Generate a random alphanumeric string of specified length.

Util.gen random alphanum(length: int) -> str
Parameters
length: Length of the generated string.
Returns
Random alphanumeric string.

map by display names

Map objects by display names.

Util.map by display names(input_map: Dict[str, Any], names: List[str],
display names: List[str]) -> Dict[str, Any]
Parameters
input_map: Input map to process.
names: List of names.
display names: List of display names.
Returns
Mapped dictionary.

list by display names

List objects by display names.

Util.list by display names(input_list: List[Dict[str, Any]], names:
List[str], display names: List[str]) -> List[Dict[str, Any]]
Parameters
input_list: Input list to process.
names: List of names.
display names: List of display names.
Returns
List of dictionaries.

deepCopy

Create a deep copy of a dictionary.

Util.deepCopy(input_map: Dict[str, Any]) -> Dict[str, Any]
Parameters
input_map: Input dictionary to copy.

Returns

Deep copy of the dictionary.

convert to list of dict

Convert input object to a list of dictionaries.

Util.convert to list of dict(input_object) -> List[Dict[str, Any]]
Parameters
input_object: Input object to convert.

Returns

List of dictionaries.

convert to list

Convert input object to a list.

Util.convert to list(input_object) -> List[Any]
Parameters
input_object: Input object to convert.

Returns

List.

convert to int

Convert input object to an integer.

Util.convert to int(input_object) -> int
Parameters
input_object: Input object to convert.
Returns
Integer.

convert to dict

Convert input object to a dictionary.

Util.convert to dict(input_object) -> Dict[str, Any]
Parameters
input_object: Input object to convert.
Returns
Dictionary.

convert to bool

Convert input object to a boolean.

Util.convert to bool(input_object) -> bool
Parameters
input_object: Input object to convert.
Returns
Boolean.

uid to classname

Extract class name from UID.

Util.uid to classname(uid) -> str or None
Parameters
uid: UID string.
Returns
Class name extracted from the UID.

uidToId

Extract ID from UID.

Util.uidToId(uid) -> int
Parameters
uid: UID string.

Returns

ID extracted from the UID.

uid to id str

Extract ID as string from UID.

Util.uid to id str(uid) -> str or None
Parameters
uid: UID string.
Returns
ID as string extracted from the UID.

validate json

Validate JSON string.

Util.validate json(json_str) -> bool
Parameters
json_str: JSON string to validate.

Returns

True if valid JSON, False otherwise.

to pretty json string

Convert JSON string to pretty-printed JSON string.

Util.to pretty json string(json_str) -> str
Parameters
json_str: JSON string to convert.

Returns

Pretty-printed JSON string.

get current language

Get the current language.

Util.get current language() -> str
Parameters
None.
Returns
Current language.

asUid

Convert class name and ID to UID.

Util.asUid(className, _id=None) -> str
Parameters
className: Class name.
_id: ID (optional).
Returns
UID.

addobject by path

Add object to dictionary by path.

Util.addobject by path(map_, path, value)
Parameters
map_: Dictionary to add the object to.
path: Path to the object.
value: Object to add.
Returns
None.

remove leading chars

Remove leading characters from a string.

Util.remove leading chars(s, c) -> str
Parameters
s: Input string.
c: Character to remove.
Returns
String with leading characters removed.

remove lastchar if matches

Remove last character from a string if it matches a specified character.

Util.remove lastchar if matches(s, c) -> str
Parameters
s: Input string.
c: Character to match.
Returns
String with last character removed if it matches the specified
character.

round double

Round a floating-point number to specified decimal places.

Util.round double(value: float, places: int) -> float
Parameters
value: Floating-point number to round.
places: Number of decimal places.
Returns
Rounded floating-point number.

urlEncode

URL-encode a string.

Util.urlEncode(s: str) -> str
Parameters
s: String to encode.

Returns

URL-encoded string.

urlDecode

URL-decode a string.

Util.urlDecode(s: str) -> str
Parameters
s: String to decode.

Returns

URL-decoded string.