1111
1212Authors: Lan
1313
14- Last modified: July 18, 2021
14+ Last modified: Feb 27 2024
1515"""
1616
1717import looker_sdk
18- from looker_sdk import models40
18+ from looker_sdk import models40 as models
1919sdk = looker_sdk .init40 (config_file = '../looker.ini' , section = 'Looker' )
2020
2121
@@ -41,25 +41,25 @@ def get_schedules(id, content, user_id=None, all_users=True):
4141
4242 def resume_schedules (id , content , enabled , user_id = None , all_users = True ):
4343
44- """ Pause or resume all schedules of a Look, or a dashboard
45-
46- Args:
47- id: id of the Looker content containing schedules
48- content(str): 'look', 'dashboard', or 'lookml_dashboard'
49- enabled (bool): set "True" to resume schedule, or "False" to pause schedule
50-
51- Notes: Schedules with "enabled = False" will disappear from Admin > Schedules in Looker UI but
52- their data can be retrived in Looker's System Activity. Once schedules are resumed with "enabled = True",
53- they will be sent once and reappear in Admin > Schedules
54- """
44+ """ Pause or resume all schedules of a Look, or a dashboard
45+
46+ Args:
47+ id: id of the Looker content containing schedules
48+ content(str): 'look', 'dashboard', or 'lookml_dashboard'
49+ enabled (bool): set "True" to resume schedule, or "False" to pause schedule
50+
51+ Notes: Schedules with "enabled = False" will disappear from Admin > Schedules in Looker UI but
52+ their data can be retrived in Looker's System Activity. Once schedules are resumed with "enabled = True",
53+ they will be sent once and reappear in Admin > Schedules
54+ """
5555
5656 "Get all schedules of a Looker content"
5757 schedules = get_schedules (id = id , content = content )
5858
5959 for i in range (0 , len (schedules )):
6060 sdk .update_scheduled_plan (
6161 scheduled_plan_id = schedules [i ]['id' ],
62- body = models40 .WriteScheduledPlan (
62+ body = models .WriteScheduledPlan (
6363 enabled = enabled
6464 ))
6565
@@ -70,16 +70,16 @@ def resume_schedules(id, content, enabled, user_id=None, all_users=True):
7070
7171 def copy_schedules (from_id , to_id , content , user_id = None , all_users = True ):
7272
73- """ Copy schedules from one Looker content to another content.
74- This script has only been tested for content of the same type (i.e.: look to look, dashboard to dashboard)
73+ """ Copy schedules from one Looker content to another content.
74+ This script has only been tested for content of the same type (i.e.: look to look, dashboard to dashboard)
7575
76- Args:
77- from_id: id of the Looker content containing schedules
78- to_id: id of the Looker content which schedules will be copied to
79- content(str): 'look', 'dashboard', or 'lookml_dashboard'
80- user_id(int, optional): If user_id is None then schedules owned by the user calling the API will be returned
81- all_users(bool, optional): If all_user is True then return schedules owned by all users
82- """
76+ Args:
77+ from_id: id of the Looker content containing schedules
78+ to_id: id of the Looker content which schedules will be copied to
79+ content(str): 'look', 'dashboard', or 'lookml_dashboard'
80+ user_id(int, optional): If user_id is None then schedules owned by the user calling the API will be returned
81+ all_users(bool, optional): If all_user is True then return schedules owned by all users
82+ """
8383
8484 "Get all schedules of a Looker content"
8585 schedules = get_schedules (id = from_id , content = content , user_id = user_id , all_users = all_users )
@@ -88,7 +88,7 @@ def copy_schedules(from_id, to_id, content, user_id=None, all_users=True):
8888 for i in range (0 , len (schedules )):
8989
9090 # Write the base schedule plans with all required fields
91- body = models40 .WriteScheduledPlan (
91+ body = models .WriteScheduledPlan (
9292
9393 # Required fields for all content type
9494 name = schedules [i ]['name' ],
@@ -110,7 +110,7 @@ def copy_schedules(from_id, to_id, content, user_id=None, all_users=True):
110110 elif content == 'lookml_dashboard' :
111111 body ['lookml_dashboard_id' ] = to_id
112112
113- """Additional parameters can be added in the models40 .WriteScheduledPlan() method for 'body',
113+ """Additional parameters can be added in the models .WriteScheduledPlan() method for 'body',
114114 or through Python's dictionary syntax: body[parameter] = value """
115115
116116
0 commit comments