Skip to content

Commit 8089eb7

Browse files
committed
update samples
1 parent f5038db commit 8089eb7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

samples/create_extract_task.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def main():
2929
help="desired logging level (set to error by default)",
3030
)
3131
# Options specific to this sample:
32-
# This sample has no additional options, yet. If you add some, please add them here
32+
# Options specific to this sample
33+
parser.add_argument("resource_type", choices=["workbook", "datasource"])
34+
parser.add_argument("resource_id")
35+
parser.add_argument("--incremental", default=False)
3336

3437
args = parser.parse_args()
3538

@@ -45,6 +48,7 @@ def main():
4548
# Monthly Schedule
4649
# This schedule will run on the 15th of every month at 11:30PM
4750
monthly_interval = TSC.MonthlyInterval(start_time=time(23, 30), interval_value=15)
51+
print(monthly_interval)
4852
monthly_schedule = TSC.ScheduleItem(
4953
None,
5054
None,
@@ -53,9 +57,7 @@ def main():
5357
monthly_interval,
5458
)
5559

56-
# Default to using first workbook found in server - note that this workbook may not be valid
57-
all_workbook_items, pagination_item = server.workbooks.get()
58-
my_workbook: TSC.WorkbookItem = all_workbook_items[0]
60+
my_workbook: TSC.WorkbookItem = server.workbooks.get_by_id(args.resource_id)
5961

6062
target_item = TSC.Target(
6163
my_workbook.id, # the id of the workbook or datasource

samples/refresh.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ def main():
2727
# Options specific to this sample
2828
parser.add_argument("resource_type", choices=["workbook", "datasource"])
2929
parser.add_argument("resource_id")
30+
parser.add_argument("--incremental", default=False)
3031

3132
args = parser.parse_args()
3233

3334
# Set logging level based on user input, or error by default
3435
logging_level = getattr(logging, args.logging_level.upper())
3536
logging.basicConfig(level=logging_level)
3637

38+
refresh_type = "FullRefresh"
39+
incremental = False
40+
if args.incremental:
41+
refresh_type = "Incremental"
42+
incremental = True
43+
44+
3745
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
3846
server = TSC.Server(args.server, use_server_version=True)
3947
with server.auth.sign_in(tableau_auth):
@@ -42,7 +50,7 @@ def main():
4250
resource = server.workbooks.get_by_id(args.resource_id)
4351

4452
# trigger the refresh, you'll get a job id back which can be used to poll for when the refresh is done
45-
job = server.workbooks.refresh(args.resource_id)
53+
job = server.workbooks.refresh(args.resource_id, incremental=incremental)
4654
else:
4755
# Get the datasource by its Id to make sure it exists
4856
resource = server.datasources.get_by_id(args.resource_id)

0 commit comments

Comments
 (0)