From af7565b26bb63326b754b20cae390cebe4e146ce Mon Sep 17 00:00:00 2001 From: Eric Lyons <53839634+eric-lyons@users.noreply.github.com> Date: Thu, 22 Jul 2021 09:51:34 -0400 Subject: [PATCH 1/3] Create simple_schedule_plan.py Many people have come on chat about creating schedules with the sdk and I just wanted to create a barebones example, so we can direct them to a public example. --- examples/python/simple_schedule_plan.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/python/simple_schedule_plan.py diff --git a/examples/python/simple_schedule_plan.py b/examples/python/simple_schedule_plan.py new file mode 100644 index 000000000..8e2188828 --- /dev/null +++ b/examples/python/simple_schedule_plan.py @@ -0,0 +1,15 @@ +from looker_sdk import methods, models40 +import looker_sdk +import exceptions +sdk = looker_sdk.init40("../looker.ini") + + +def create_simple_schedule(dashboard_id:int,user_id:int,schedule_title:str, format:str, email:str,type:str, message:str, crontab:str): + ### For more information on the Params accepted https://github.com/looker-open-source/sdk-codegen/blob/master/python/looker_sdk/sdk/api31/methods.py#L2144 + ### And for schedule destination go: https://github.com/looker-open-source/sdk-codegen/blob/master/python/looker_sdk/sdk/api31/models.py#L4601 + ### Supported formats vary by destination, but include: "txt", "csv", "inline_json", "json", "json_detail", "xlsx", "html", "wysiwyg_pdf", "assembled_pdf", "wysiwyg_png" + ### type: Type of the address ('email', 'webhook', 's3', or 'sftp') + schedule = sdk.create_scheduled_plan( + body=models40.WriteScheduledPlan(name=schedule_title, dashboard_id=dashboard_id, user_id=user_id, run_as_recipient= True, crontab=crontab, scheduled_plan_destination = [models40.ScheduledPlanDestination(format=format, apply_formatting=True, apply_vis=True, address=email, type=type, message=message)])) +create_simple_schedule(1234,453,"This is an automated test", "assembled_pdf", "test@looker.com", "email", "Hi Looker User!", "0 1 * * *") + From 4023d75a7d11c22a7846a355a5b23c8d217d15cb Mon Sep 17 00:00:00 2001 From: Eric Lyons <53839634+eric-lyons@users.noreply.github.com> Date: Thu, 22 Jul 2021 09:53:24 -0400 Subject: [PATCH 2/3] Update README.md Updated readme to point at simple_schedule_plan example --- examples/python/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/python/README.md b/examples/python/README.md index 6991d68ed..2266c054c 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -30,6 +30,7 @@ The full details of all Looker API endpoints are listed in Looker Docs: [Version - [Transfer all schedules of a user to another user](transfer_all_schedules.py) - [Pause/Resume or Copy Schedules](manage_schedules.py) +- [Create a Simple Schedule Plan](simple_schedule_plan.py) ## User : Manage Users From 13029e89653fb8374805412d6c18dbe228a2994d Mon Sep 17 00:00:00 2001 From: Eric Lyons <53839634+eric-lyons@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:16:08 -0400 Subject: [PATCH 3/3] Update README.md Update readme to link to new example of adding users to a group from a CSV. --- examples/python/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/python/README.md b/examples/python/README.md index 2266c054c..87b8bf687 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -36,6 +36,7 @@ The full details of all Looker API endpoints are listed in Looker Docs: [Version ## User : Manage Users - [Disable all active user sessions](logout_all_users.py) +- [Add a list of users to a group from a CSV](add_users_to_group_from_csv.py)