Define a Live Sync
To use live sync, a sync job must be defined first:
Method: POST Path: /context-sql-sync/syncjob Authorization header: Bearer [access_token] Body { "datasourceId": "1", "queryId": "2", "externalIdPrefix": "prefix", "syncJobInterval": "10", "chunkSize":1440 }
Parameter | Description |
---|---|
datasourceId | The id of the datasource against which to run the sync. |
queryId | The id of the query to be used for the sync. |
externalIdPrefix | The prefix that will be prepended to the id obtained from the database in order to produce the external id of the context item. This prefix allows supporting same external IDs for different data sources. |
syncJobInterval | The interval (expressed in minutes) between subsequent job executions. |
chunkSize | The sync interval will be split into subintervals with length specified by this value (expressed in minutes). |
The result will contain the id of the newly created sync job. This id can be used to start and stop the job. Sync job will run for the entire interval from last_sync_date till the current time. The sync jobs should be used only with queries which support parameters – positional or named.
Note
Currently last_sync_date can be determined only by checking the job’s settings in Postgres database.
To start the job:
Method: POST Path: /context-sql-sync/syncjob/{id}/start Authorization header: Bearer [access_token]
To stop a job:
Method: POST Path: /context-sql-sync/syncjob/{id}/stop Authorization header: Bearer [access_token]
After the job is started, the first time it is executed is calculated based on the syncJobInterval value. For example, if the job has syncJobInterval=10 and the job is started at 15:12, the initial job execution will happen at 15:20.
To get a list of all currently defined sync jobs:
Method: GET Path: /context-sql-sync/syncjob Authorization header: Bearer [access_token]
A sync job is started if its “scheduled” field is true.