10000 Improve docs and short examples around Schedules support (#1161) · tableau/server-client-python@0cda220 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cda220

Browse files
authored
Improve docs and short examples around Schedules support (#1161)
Fixes #1152 We also have #755 to review and potentially add more around Schedules
1 parent e408234 commit 0cda220

File tree

1 file changed

+95
-44
lines changed

1 file changed

+95
-44
lines changed

docs/api-ref.md

Lines changed: 95 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ REST API: [Create Schedule](https://help.tableau.com/current/api/rest_api/en-us/
27472747

27482748
Name | Description
27492749
:--- | :---
2750-
`schedule_item` | The settings for the schedule that you want to create. You need to create an instance of `schedule_item` and pass it to the `create` method. The `schedule_item` includes the `interval_item` which specifies the frequency, or interval, that the schedule should run. See `ScheduleItem` and `IntervalItem`.
2750+
`schedule_item` | The settings for the schedule that you want to create. You need to create an instance of `ScheduleItem` and pass it to the `create` method. The `ScheduleItem` includes the `IntervalItem` which specifies the frequency, or interval, that the schedule should run.
27512751

27522752

27532753
**Returns**
@@ -2765,15 +2765,21 @@ Error | Description
27652765

27662766
```py
27672767
import tableauserverclient as TSC
2768+
from datetime import time
2769+
27682770
# sign in, etc.
2769-
# Create an interval to run every 2 hours between 2:30AM and 11:00PM
2770-
hourly_interval = TSC.HourlyInterval(start_time=time(2, 30),
2771-
end_time=time(23, 0),
2772-
interval_value=2)
2773-
# Create schedule item
2774-
hourly_schedule = TSC.ScheduleItem("Hourly-Schedule", 50, TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Parallel, hourly_interval)
2775-
# Create schedule
2776-
hourly_schedule = server.schedules.create(hourly_schedule)
2771+
# Create an interval to run every 2 hours between 2:30AM and 11:00PM
2772+
hourly_interval = TSC.HourlyInterval(start_time=time(2, 30),
2773+
end_time=time(23, 0),
2774+
interval_value=2)
2775+
# Create schedule item
2776+
hourly_schedule = TSC.ScheduleItem("Hourly-Schedule",
2777+
50,
2778+
TSC.ScheduleItem.Type.Extract,
2779+
TSC.ScheduleItem.ExecutionOrder.Parallel,
2780+
hourly_interval)
2781+
# Create schedule
2782+
hourly_schedule = server.schedules.create(hourly_schedule)
27772783
```
27782784
<br>
27792785
<br>
@@ -2813,7 +2819,7 @@ Error | Description
28132819
#### schedules.get
28142820

28152821
```py
2816-
schedules.get([req_options=None])
2822+
schedules.get()
28172823
```
28182824

28192825
Returns all schedule items from the server.
@@ -2822,6 +2828,18 @@ Returns all schedule items from the server.
28222828
REST API: [Query Schedules](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_schedules)
28232829

28242830

2831+
#### schedules.get_by_id
2832+
2833+
```py
2834+
schedules.get_by_id(schedule_id)
2835+
```
2836+
2837+
Returns the specified schedule.
2838+
2839+
2840+
REST API: [Get Schedule](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get-schedule)
2841+
2842+
28252843

28262844
**Parameters**
28272845

@@ -2831,68 +2849,101 @@ Name | Description
28312849

28322850
#### schedules.update
28332851

2852+
```py
2853+
schedules.update(schedule_item)
2854+
```
2855+
2856+
**Parameters**
2857+
2858+
Name | Description
2859+
:--- | :---
2860+
`schedule_item` | The settings for the schedule that you want to update. You need to fetch an existing instance of `ScheduleItem` from the `get` method, make your changes, and then pass it to the `update` method to update the schedule on the server. The `ScheduleItem` includes the `IntervalItem` which specifies the frequency, or interval, that the schedule should run.
2861+
2862+
2863+
REST API: [Update Schedules](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#update_schedule)
2864+
28342865
<br>
28352866
<br>
28362867

28372868

28382869
**Hourly schedule example**
28392870
```py
28402871
import tableauserverclient as TSC
2872+
from datetime import time
28412873
# sign in, etc.
2842-
# Create an interval to run every 2 hours between 2:30AM and 11:00PM
2843-
hourly_interval = TSC.HourlyInterval(start_time=time(2, 30),
2844-
end_time=time(23, 0),
2845-
interval_value=2)
2846-
# Create schedule item
2847-
hourly_schedule = TSC.ScheduleItem("Hourly-Schedule", 50, TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Parallel, hourly_interval)
2848-
# Create schedule
2849-
hourly_schedule = server.schedules.create(hourly_schedule)
2874+
2875+
# Create an interval to run every 2 hours between 2:30AM and 11:00PM
2876+
hourly_interval = TSC.HourlyInterval(start_time=time(2, 30),
2877+
end_time=time(23, 0),
2878+
interval_value=2)
2879+
2880+
# Create schedule item
2881+
hourly_schedule = TSC.ScheduleItem("Hourly-Schedule",
2882+
50,
2883+
TSC.ScheduleItem.Type.Extract,
2884+
TSC.ScheduleItem.ExecutionOrder.Parallel,
2885+
hourly_interval)
2886+
2887+
# Create schedule
2888+
hourly_schedule = server.schedules.create(hourly_schedule)
28502889
```
28512890

28522891
**Daily schedule example**
28532892
```py
28542893
import tableauserverclient as TSC
2894+
from datetime import time
28552895
# sign in, etc.
2856-
# Create a daily interval to run every day at 12:30AM
2857-
Daily_interval = TSC.DailyInterval(start_time=time(0, 30))
2858-
# Create schedule item using daily interval
2859-
daily_schedule = TSC.ScheduleItem("Daily-Schedule", 60, TSC.ScheduleItem.Type.Subscription, TSC.ScheduleItem.ExecutionOrder.Serial, daily_interval)
2860-
# Create daily schedule
2861-
daily_schedule = server.schedules.create(daily_schedule)
28622896

2897+
# Create a daily interval to run every day at 12:30AM
2898+
daily_interval = TSC.DailyInterval(start_time=time(0, 30))
2899+
2900+
# Create schedule item using daily interval
2901+
daily_schedule = TSC.ScheduleItem("Daily-Schedule",
2902+
60,
2903+
TSC.ScheduleItem.Type.Subscription,
2904+
TSC.ScheduleItem.ExecutionOrder.Serial,
2905+
daily_interval)
2906+
2907+
# Create daily schedule
2908+
daily_schedule = server.schedules.create(daily_schedule)
28632909
```
28642910

28652911
**Weekly schedule example**
28662912
```py
28672913
import tableauserverclient as TSC
2914+
from datetime import time
28682915
# sign in, etc.
2869-
# Create a weekly interval to run every Monday, Wednesday, and Friday at 7:15PM
2870-
weekly_interval = TSC.WeeklyInterval(time(19, 15),
2871-
TSC.IntervalItem.Day.Monday,
2872-
TSC.IntervalItem.Day.Wednesday,
2873-
TSC.IntervalItem.Day.Friday)
2874-
# Create schedule item using weekly interval
2875-
weekly_schedule = TSC.ScheduleItem("Weekly-Schedule", 70,
2876-
TSC.ScheduleItem.Type.Extract,
2877-
TSC.ScheduleItem.ExecutionOrder.Serial, weekly_interval)
2878-
# Create weekly schedule
2879-
weekly_schedule = server.schedules.create(weekly_schedule)
28802916

2917+
# Create a weekly interval to run every Monday, Wednesday, and Friday at 7:15PM
2918+
weekly_interval = TSC.WeeklyInterval(time(19, 15),
2919+
TSC.IntervalItem.Day.Monday,
2920+
TSC.IntervalItem.Day.Wednesday,
2921+
TSC.IntervalItem.Day.Friday)
2922+
# Create schedule item using weekly interval
2923+
weekly_schedule = TSC.ScheduleItem("Weekly-Schedule", 70,
2924+
TSC.ScheduleItem.Type.Extract,
2925+
TSC.ScheduleItem.ExecutionOrder.Serial,
2926+
weekly_interval)
2927+
# Create weekly schedule
2928+
weekly_schedule = server.schedules.create(weekly_schedule)
28812929
```
28822930

28832931
**Monthly schedule example**
28842932
```py
28852933
import tableauserverclient as TSC
2934+
from datetime import time
28862935
# sign in, etc.
2887-
# Create a monthly interval to run on the 15th of every month at 11:30PM
2888-
monthly_interval = TSC.MonthlyInterval(start_time=time(23, 30),
2889-
interval_value=15)
2890-
# Create schedule item using monthly interval
2891-
monthly_schedule = TSC.ScheduleItem("Monthly-Schedule", 80,
2892-
TSC.ScheduleItem.Type.Subscription
2893-
TSC.ScheduleItem.ExecutionOrder.Parallel, monthly_interval)
2894-
# Create monthly schedule
2895-
monthly_schedule = server.schedules.create(monthly_schedule)
2936+
2937+
# Create a monthly interval to run on the 15th of every month at 11:30PM
2938+
monthly_interval = TSC.MonthlyInterval(start_time=time(23, 30),
2939+
interval_value=15)
2940+
# Create schedule item using monthly interval
2941+
monthly_schedule = TSC.ScheduleItem("Monthly-Schedule",
2942+
80,
2943+
TSC.ScheduleItem.Type.Subscription
2944+
TSC.ScheduleItem.ExecutionOrder.Parallel, monthly_interval)
2945+
# Create monthly schedule
2946+
monthly_schedule = server.schedules.create(monthly_schedule)
28962947
```
28972948

28982949

0 commit comments

Comments
 (0)
0