Do you have some step-by-step instructions for creating & using a data cache with Embedded Cloud’s Job API?
Do you have some step-by-step instructions for creating & using a data cache with Embedded Cloud’s Job API?
Best answer by James T
To use Embedded Cloud’s Job API to cache data, a PostgreSQL database will be needed. The cache database can provided by your end-user OR hosted within your application’s environment.
Note: all requests to Embedded Cloud APIs use Jason Web Tokens (JWT). Requests to the Job API require that a sub-account id is included in the JWT payload.
Creates a re-direct URL similar to the Connection API.
Prerequisite: The end-user has a publicly available PostgreSQL database with appropriate permissions.
A dedicated database or schema is recommended for best performance.
Request
POST https://cloud.cdata.com/api/job/cacheConnection/formLink
{ "redirectURL": "https://www.google.com" }
Response
A string containing the URL to redirect the user to. Users can then add their PostgreSQL connection information to this page.
HTTP 200 OK
{ "redirectURL": "https://cloud.cdata.com/oem/user/cacheConnection?token=[token value]&driver=PostgreSQL&redirectUrl=https%3A%2F%2Fwww.google.com&connectionName=OEMCacheConnection" }
Create/update the cache connection to OEM provided database using connection string.
Prerequisite: You have a PostgreSQL database with appropriate permissions.
To ensure multi-tenancy is preserved, separate databases OR schemas per sub-account should be used. Using the CData sub-account ID OR related externalID as the name of the database or schema is recommended.
Request
POST https://cloud.cdata.com/api/job/cacheConnection
{ "connectionString": "Server=<Server URL>;Port=5432;User=<Your User Name>;Password=<Your Password>;Database=<Database Name>;BrowsableSchema=<Schema Name>" }
Obtain the connectionConnection id & sourceName (aka catalog) via the Connection API (List Connections).
Obtain the sourceSchema & sourceTable via the Metadata API.
Request
POST https://cloud.cdata.com/api/job/create
{ "jobType": "Caching", "intervalUnit": "Hour", "intervalValue": "1", "logVerbosity": "1", "enabled": "true", "params": { "timeCheckColumn": "", "autoTruncateStrings": "false", "sourceConnection": "36b2c04f-70f4-44a1-876a-29e42237ee63", "sourceName": "OData1", "sourceSchema": "OData", "sourceTable": "Categories" } }
Payload Parameters
| Name | Description |
| jobType | The type of job that the user wants to run (Caching or ScheduledQuery). |
| intervalUnit | A string representing the time interval (Hour/Day/Week/Month). |
| intervalValue | An integer that represents how many of the selected frequency unit the job should wait before running again. |
| logVerbosity | An enum indicating the level of log verbosity (1-5). |
| enabled | A Boolean value indicating whether the job is enabled. The default value is true. |
| definedNextRun | An optional DateTime value that can be used to set the initial start time for the job. |
| params | An object containing job parameters. See example below. |
Response
HTTP 200 OK
{ "jobs": [/*job information shown below*/] }
| Name | Description |
| id | The job’s Id. |
| name | The job’s name. |
| enabled | A Boolean value indicating whether the job is enabled. |
| created | The date and time the job was created. |
| lastModified | The date and time the job was last modified. |
| nextRunTime | The date and time the job is scheduled to be run next. |
| intervalUnit | A string representing the interval unit for the job (Hour/Day/Week/Month). |
| intervalValue | An integer that represents how many of the selected interval unit the job should wait before running again. |
| logVerbosity | A number indicating the level of log verbosity (1-5), with 5 being the highest. For normal operation & best performance, levels 1 or 2 is recommended. |
| lastRun | The last run metrics for the job, including the date and time, duration, status, rows affected, and next run time. See example in documentation. |
| params | An object containing job parameters. See example in documentation. |
After you have created the Cache Job, you can sent a request to the List Jobs endpoint to return information about all Jobs for a sub-account.
Request GET https://cloud.cdata.com/api/job/list
Additional information, examples and endpoints (Describe Job, Update Job, Delete Job, Run Job & Stop Job) are available in the Embedded Cloud documentation: https://cloud.cdata.com/docs/Job-API.html
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.