Code examples
/
System APIs (g.sys.system, g.sys.cache)
System APIs from code
Your code calls every system API through g.sys.system and g.sys.cache, whatever the settings of the API say about HTTP callers. Each API has one page : the HTTP call first, then From code with the code in eight languages.
g.sys.system
Method
What it does
Page
encrypt, decrypt
Encrypt and decrypt a value with the transfer key of the secret, or your own
Encrypt · Decrypt
hash
The hash a hashed column stores, to look a row up
Hash data
getToken
The token of an API user, or of a person
Get token
getSecret
A key of a secret, or several
Get secret
executeQuery
A plain query of the database : SQL, or a command of MongoDB
Examples · Execute plain query
callExternalApi
Call another API over HTTP : one call, several in parallel or in sequence, files
Examples · Call external API
getTableMeta
The columns of a table, as its database has them
Get table meta
createIndexes, dropIndexes, getIndexes
Indexes in the same words on every database
Create · Drop · Get
emitEvent, emitEventWS
Run the listeners of an event, or tell WebSocket clients
Emit event · Emit WebSocket event
isValidDataForTable, isValidDataForCustomAPI
Check data against a schema, or the body of a custom API, before you use it
For a table · For a custom API
isValidConnectionString
Try a connection string before you save it
Is valid connection string
multiTenantInstanceUpdated
Tell every server that the connection of a tenant changed
Multi tenant instance updated
g.sys.cache
Method
What it does
Page
getKey, setKey, removeKey
Keys of your own in Redis, with a time to live
Get · Set · Remove
resetCacheDB, resetCacheCustomApis, resetCacheSystemApis
Drop the cached answers of a table, a custom API or a system API
Database · Custom API · System API
Good to know
A call answers data, and throws the errors : the caller of your API gets them. In the languages other than TypeScript, full gives the whole response envelope (g.sys.system.full in Python…) : see the page of your language .
Every call takes the request headers of its HTTP form, such as x-am-tenant-username.