ReportScheduler API
The report scheduler enables the generation of different types of reports with or without recurrence and informs a set of users of their creation and availability. Typical use cases include periodic reports (e.g., daily, weekly, monthly, etc.) and asynchronous report generation.
Creating a ScheduledReport
A scheduled job is created by sending a POST request
/api/scheduler/reports
using content-type JSON.
An overview of the available reports can be found on this page. Success is indicated by the status code 201. The object is returned with its unique identifier. In the event of a malformed user request, the response will be an empty body and status code 400.
Scheduling a report is done by sending a JSON object containing the configuration to the scheduling service.
JSON payload for adding a new job
{
"id": 13, // both id and version are only needed when updating a job, and should be left out when creating a new job
"version":1, // version is to be incremented when updating an already scheduled job
"name":"My new scheduled job",
"description":"This job will send me an OTS report every day.",
"scheduledStart": 1478696400000, // this contains the timestamp of the first run, in milliseconds since epoch
"report": {
"reportType": "pig.ots", // the identifier of the report
"reportParameters": {} // optional report parameters
},
"dateRange": { // the date period that defines the contents this report will hold, in this example we create a report that will contain results from 30 days before the day it is running, up till midnight
"type":"variableInterval",
"relativeBoundary":"startOfTheDay",
"amount":-30,
"unit":"day"
},
"frequency": { // the frequency for running this report, in this example: every day
"amount":1,
"timeUnit":"day"
},
"recipientIds": [1], // the adhese user id's of the users that will recieve this report
"mailTrigger": "always" //
}
DateRange object
DateRange contains five possible attributes: type, lowerBound, upperBound, relativeBoundary, amount, and unit.
The available values for type are "fixedInterval," "fixedSemiInterval," "variableInterval," and "variableSemiInterval."
- For objects with type "fixedInterval", a value for "lowerBound" and "upperBound" is obligatory. These values will be used as from and till dates.
- For objects with the type "fixedSemiInterval", a value for "lowerBound" is obligatory. These values will be used as a from date.
- For objects with type "variableInterval", the attributes "amount", "unit" and "relativeBoundary" are needed. "relativeBoundary" can contain one of these values: "now", "startOfTheHour", "startOfTheDay", "yesterday", "startOfTheWeek", "startOfTheMonth", "startOfTheQuarter", "startOfTheYear" and "lastWeek". Unit can be one of these: "day", "hour".
- For objects with type "variableSemiInterval", the attribute "relativeBoundary" is needed and will be used as lower boundary. "timeUnit" can contain one of these values: "now", "startOfTheHour", "startOfTheDay", "yesterday", "startOfTheWeek", "startOfTheMonth", "startOfTheQuarter", "startOfTheYear" and "lastWeek".
Frequency attribute
Example request:
POST /api/scheduler/reports Content-Type: application/json Body: { "reportType": "plain.dailySlotContacts", "name": "new report ", "description": "yet another report", "scheduledStart": 1490933621000, "mailTrigger": "never", "recipientIds": [1] }
Successful response:
Status: 201 CREATED Content-Type: application/json Body: { "id": 3, "versionId": 0, "name": "new report ", "description": "yet another report", "reportType": "plain.dailySlotContacts", "campaignId": null, "scheduledStart": 1490933621000, "frequency": null, "mailTrigger": "never", "dateRange": null, "recipientIds": [ 1 ], "recipients": [ { "id": 1, "name": "User Adhese" } ] }
Retrieving a list of all ScheduledReports of which the user is the owner
A list of all scheduled reports owned by the current user available can be retrieved by sending a GET request
/api/scheduler/reports
The response is of content-type JSON and will contain a list of scheduled reports.
If no scheduled reports are owned by the current user, an empty list will be returned.
GET /api/scheduler/reports
Successful response:
Status: 200 OK Content-Type: application/json Body: [ { "id": 2, "versionId": 0, "name": "new report ", "description": "yet another report", "reportType": "plain.dailySlotContacts", "campaignId": null, "scheduledStart": 1490933621000, "frequency": null, "mailTrigger": "never", "dateRange": null, "recipientIds": [], "recipients": [] }, { "id": 3, "versionId": 0, "name": "new report ", "description": "yet another report", "reportType": "plain.dailySlotContacts", "campaignId": null, "scheduledStart": 1490933621000, "frequency": null, "mailTrigger": "never", "dateRange": null, "recipientIds": [ 1 ], "recipients": [ { "id": 1, "name": "User Adhese" } ] } ]
Retrieving a list of all ScheduledReports of which the user is a recipient
A list of all scheduled reports which have the current user as a recipient can be retrieved by sending a GET request
/api/scheduler/reports/bcc
The response is of content-type JSON and will contain a list of scheduled reports.
If the current user is not a recipient of any scheduled report, an empty list will be returned.
GET /api/scheduler/reports/bcc
Successful response:
Status: 200 OK Content-Type: application/json Body: [ { "id": 3, "versionId": 0, "name": "new report ", "description": "yet another report", "reportType": "plain.dailySlotContacts", "campaignId": null, "scheduledStart": 1490933621000, "frequency": null, "mailTrigger": "never", "dateRange": null, "recipientIds": [ 1 ], "recipients": [ { "id": 1, "name": "User Adhese" } ] } ]