RETRIEVE EXISTING SCHEDULE(S)
In order to find the existing schedule(s) on any Datastream, first perform a GET call:
curl -X GET \
https://YOUR_STACK.datatap.adverity.com/api/datastreams/DATASTREAM_ID/ \
-H 'Authorization: Token TOKEN_VALUE' \
Example: If you were to perform a GET request for a Datastream with a schedule that was set as follows within the UI:
Result: (cropped for relevant section)
"schedules": [
{
"id": SCHEDULE_ID,
"cron_preset": "CRON_EVERY_2_WEEKS",
"cron_type": "week",
"cron_interval": 2,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 8,
"time_range_preset_label": "Previous Week",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": null,
"fixed_end": null,
"offset_days": 0
}
],
LIST POSSIBLE EDIT ACTIONS
In order to edit a schedule, first make an OPTIONS call to find the variable options.
curl -X OPTIONS \
https://YOUR_STACK.datatap.adverity.com/api/datastreams/DATASTREAM_ID/ \
-H 'Authorization: Token TOKEN_VALUE' \
Result: (cropped for 2 potential options of the variable "time_range_preset")
"time_range_preset": {
"type": "choice",
"required": false,
"read_only": false,
"label": "Time range preset",
"help_text": "Select one of the time range presets.",
"choices": [
{
"display_name": "Fixed Time Range",
"value": 0
},
{
"display_name": "Yesterday",
"value": 13
},
EDIT A SCHEDULE
After running an OPTIONS call to establish the accepted parameters for each variable field, you can then edit them with a PATCH call.
Example:
curl -X PATCH \
https://YOUR_STACK.datatap.adverity.com/api/datastreams/DATASTREAM_ID/ \
-H 'Authorization: Token TOKEN_VALUE' \
-H 'Content-Type: application/json' \
-d '{"time_range_preset": 13}'
CREATE A NEW SCHEDULE
Creating a new schedule requires you to send a PATCH request that includes all required variables for a fetch schedule (potential values can be found using the OPTIONS call described above):
curl -X PATCH 'https://YOUR_STACK.adverity.com/api/datastreams/DATASTREAM_ID/' \
-H 'Authorization: Token TOKEN VALUE' \
-H 'Content-Type: application/json' \
-D '{
"schedules": [
{
"cron_preset": "CRON_EVERY_DAY",
"cron_type": "day",
"cron_interval": 1,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 0,
"time_range_preset_label": "Fixed Time Range",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": "2020-03-01",
"fixed_end": "2020-03-02",
"offset_days": 0
},
]
}'
MULTI-SCHEDULING
Creating multiple schedules can be achieved through the same PATCH call as above, but providing two unique sets of variables:
curl -X PATCH 'https://YOUR_STACK.datatap.adverity.com/api/datastreams/DATASTREAM_ID/' \
-H 'Authorization: Token TOKEN_VALUE' \
-H 'Content-Type: application/json' \
-d '{
"schedules":
[
{
"cron_preset": "CRON_EVERY_DAY",
"cron_type": "day",
"cron_interval": 1,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 0,
"time_range_preset_label": "Fixed Time Range",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": "2020-03-01",
"fixed_end": "2020-03-02",
"offset_days": 0
},
{
"cron_preset": "CRON_EVERY_WEEK",
"cron_type": "day",
"cron_interval": 1,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 0,
"time_range_preset_label": "Fixed Time Range",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": "2020-03-01",
"fixed_end": "2020-03-03",
"offset_days": 7
}
]
}'
Result:
"schedules": [
{
"id": SCHEDULE_ID,
"cron_preset": "CRON_EVERY_DAY",
"cron_type": "day",
"cron_interval": 1,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 0,
"time_range_preset_label": "Fixed Time Range",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": "2020-03-01",
"fixed_end": "2020-03-02",
"offset_days": 0
},
{
"id": SCHEDULE_ID,
"cron_preset": "CRON_EVERY_WEEK",
"cron_type": "week",
"cron_interval": 1,
"cron_start_of_day": "00:00:00",
"cron_interval_start": 1,
"time_range_preset": 0,
"time_range_preset_label": "Fixed Time Range",
"delta_type": 1,
"delta_interval": 1,
"delta_start_of_day": "00:00:00",
"delta_interval_start": 1,
"fixed_start": "2020-03-01",
"fixed_end": "2020-03-03",
"offset_days": 7
}
],
Comments
0 comments
Article is closed for comments.