Currently, there is no native solution within the UI to temporarily disable/resume schedules in Looker. However, we do have three workarounds listed in this article. This article provides two sample scripts with Python to interact with update_schedule_plan().
METHOD 1: Using Python’s requests module to interact with Looker API
Here is the link to Google Colab if you want to run as a one-off task.
import requests
import json
def login(instance, credential):
""" Return an access token to be used in subsequent API calls
An access token is only valid for 60 minutes and can not be extended"""
instance = instance
credential = credential
access_token = requests.post(instance+'/login', data=credential).json()
headers = {'Authorization': 'token ' + access_token['access_token']}
return headers
def update_schedule(look_id = 321, enabled = True):
""" Pause a schedule plan (enabled = False) or resume a schedule plan (enabled = True)
Args:
look_id (int): id of a look (https://company.looker.com/look/id)
enabled (boolean): set to "True" to resume schedule, and "False" to pause schedule
Returns: "Successfully updated all schedules for look id " (str)
Notes: Schedules with "enabled = False" will disappear from Admin > Schedules but its data
can be retrived in System Activity. Once schedules are resumed with "enabled = True", they
will appear in Admin > Schedules
"""
headers = login(instance = instance, credential = credential)
""" Change to <schedule_plans/dashboard/> or <schedule_plans/lookml_dashboard>
to retrieve schedule_plan_id for these two contents """
get_url = instance + '/api/4.0/scheduled_plans/look/' + str(look_id)
schedule_plans = requests.get(get_url,headers=headers).json()
""" Execute through loops for all schedule plans belonging to one Looker type (look or dashboards)"""
for i in range(0, len(schedule_plans)):
schedule_plan = schedule_plans
*schedule_plan['enabled'] = enabled*
*data = json.dumps(schedule_plan)*
*update_url = instance + '/scheduled_plans/' + str(schedule_plan['id'])*
*requests.patch(update_url, headers = headers, data = data)*
*return "Successfully updated all schedules for look id " + str(look_id)*
*# Put in look_id and change the enabled parameter*
*instance = 'https://yourcompany.looker.com:19999'*
*credential = {*
*'client_id': 'foo',*
*'client_secret': 'bar'*
*}*
*update_schedule(look_id = 321, enabled = False)*