@@ -85,17 +85,6 @@ def get(self, req_options: Optional["RequestOptions"] = None) -> tuple[list[Work
85
85
-------
86
86
Tuple containing one page's worth of workbook items and pagination
87
87
information.
88
-
89
- Examples
90
- --------
91
- >>> import tableauserverclient as TSC
92
- >>> tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
93
- >>> server = TSC.Server('https://servername')
94
-
95
- >>> with server.auth.sign_in(tableau_auth):
96
- >>> all_workbooks_items, pagination_item = server.workbooks.get()
97
- >>> # print names of first 100 workbooks
98
- >>> print([workbook.name for workbook in all_workbooks_items])
99
88
"""
100
89
logger .info ("Querying all workbooks on site" )
101
90
url = self .baseurl
@@ -119,11 +108,6 @@ def get_by_id(self, workbook_id: str) -> WorkbookItem:
119
108
-------
120
109
WorkbookItem
121
110
The workbook item.
122
-
123
- Examples
124
- --------
125
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
126
- >>> print(workbook.name)
127
111
"""
128
112
if not workbook_id :
129
113
error = "Workbook ID undefined."
@@ -147,21 +131,6 @@ def refresh(self, workbook_item: Union[WorkbookItem, str]) -> JobItem:
147
131
-------
148
132
JobItem
149
133
The job item.
150
-
151
- Examples
152
- --------
153
- >>> import tableauserverclient as TSC
154
- >>> tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
155
- >>> server = TSC.Server('https://servername')
156
-
157
- >>> with server.auth.sign_in(tableau_auth):
158
-
159
- >>> # get the workbook item from the site
160
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
161
-
162
- >>> # call the update method
163
- >>> workbook = server.workbooks.refresh(workbook)
164
- >>> print("\n The data of workbook {0} is refreshed.".format(workbook.name))
165
134
"""
166
135
id_ = getattr (workbook_item , "id" , workbook_item )
167
136
url = f"{ self .baseurl } /{ id_ } /refresh"
@@ -205,10 +174,6 @@ def create_extract(
205
174
-------
206
175
JobItem
207
176
The job item for the extract creation.
208
-
209
- Examples
210
- --------
211
-
212
177
"""
213
178
id_ = getattr (workbook_item , "id" , workbook_item )
214
179
url = f"{ self .baseurl } /{ id_ } /createExtract?encrypt={ encrypt } "
@@ -243,10 +208,6 @@ def delete_extract(self, workbook_item: WorkbookItem, includeAll: bool = True, d
243
208
Returns
244
209
-------
245
210
JobItem
246
-
247
- Examples
248
- --------
249
-
250
211
"""
251
212
id_ = getattr (workbook_item , "id" , workbook_item )
252
213
url = f"{ self .baseurl } /{ id_ } /deleteExtract"
@@ -269,10 +230,6 @@ def delete(self, workbook_id: str) -> None:
269
230
Returns
270
231
-------
271
232
None
272
-
273
- Examples
274
- --------
275
- >>> server.workbooks.delete('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
276
233
"""
277
234
if not workbook_id :
278
235
error = "Workbook ID undefined."
@@ -311,26 +268,6 @@ def update(
311
268
-------
312
269
WorkbookItem
313
270
The updated workbook item.
314
-
315
- Examples
316
- --------
317
-
318
- >>> import tableauserverclient as TSC
319
- >>> tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
320
- >>> server = TSC.Server('https://servername')
321
-
322
- >>> with server.auth.sign_in(tableau_auth):
323
-
324
- >>> # get the workbook item from the site
325
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
326
- >>> print("\n Update {0} workbook. Project was {1}".format(workbook.name, workbook.project_name))
327
-
328
- >>> # make an change, for example a new project ID
329
- >>> workbook.project_id = '1f2f3e4e-5d6d-7c8c-9b0b-1a2a3f4f5e6e'
330
-
331
- >>> # call the update method
332
- >>> workbook = server.workbooks.update(workbook)
333
- >>> print("\n Updated {0} workbook. Project is now {1}".format(workbook.name, workbook.project_name))
334
271
"""
335
272
if not workbook_item .id :
336
273
error = "Workbook item missing ID. Workbook must be retrieved from server first."
@@ -373,20 +310,6 @@ def update_connection(self, workbook_item: WorkbookItem, connection_item: Connec
373
310
-------
374
311
ConnectionItem
375
312
The updated connection item.
376
-
377
- Examples
378
- --------
379
- >>> # query for workbook connections
380
- >>> server.workbooks.populate_connections(workbook)
381
-
382
- >>> # update the connection
383
- >>> connection = workbook.connections[0]
384
- >>> connection.username = 'new_username'
385
- >>> connection.password = 'new_password'
386
-
387
- >>> # call the update method
388
- >>> connection = server.workbooks.update_connection(workbook, connection)
389
-
390
313
"""
391
314
url = f"{ self .baseurl } /{ workbook_item .id } /connections/{ connection_item .id } "
392
315
update_req = RequestFactory .Connection .update_req (connection_item )
@@ -432,10 +355,6 @@ def download(
432
355
------
433
356
ValueError
434
357
If the workbook ID is not defined.
435
-
436
- Examples
437
- --------
438
- >>> filepath = server.workbooks.download('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
439
358
"""
440
359
441
360
return self .download_revision (
@@ -477,24 +396,6 @@ def populate_views(self, workbook_item: WorkbookItem, usage: bool = False) -> No
477
396
------
478
397
MissingRequiredFieldError
479
398
If the workbook item is missing an ID.
480
-
481
- Examples
482
- --------
483
- >>> # import tableauserverclient as TSC
484
-
485
- >>> # server = TSC.Server('https://SERVERURL')
486
- >>> # ...
487
-
488
- >>> # get the workbook item
489
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
490
-
491
-
492
- >>> # get the view information
493
- >>> server.workbooks.populate_views(workbook)
494
-
495
- >>> # print information about the views for the work item
496
- >>> print("\n The views for {0}: ".format(workbook.name))
497
- >>> print([view.name for view in workbook.views])
498
399
"""
499
400
if not workbook_item .id :
500
401
error = "Workbook item missing ID. Workbook must be retrieved from server first."
@@ -550,24 +451,6 @@ def populate_connections(self, workbook_item: WorkbookItem) -> None:
550
451
------
551
452
MissingRequiredFieldError
552
453
If the workbook item is missing an ID.
553
-
554
- Examples
555
- --------
556
- >>> # import tableauserverclient as TSC
557
-
558
- >>> # server = TSC.Server('https://SERVERURL')
559
- >>> # ...
560
-
561
- >>> # get the workbook item
562
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
563
-
564
-
565
- >>> # get the connection information
566
- >>> server.workbooks.populate_connections(workbook)
567
-
568
- >>> # print information about the data connections for the workbook item
569
- >>> print("\n The connections for {0}: ".format(workbook.name))
570
- >>> print([connection.id for connection in workbook.connections])
571
454
"""
572
455
if not workbook_item .id :
573
456
error = "Workbook item missing ID. Workbook must be retrieved from server first."
@@ -617,12 +500,6 @@ def populate_pdf(self, workbook_item: WorkbookItem, req_options: Optional["Reque
617
500
------
618
501
MissingRequiredFieldError
619
502
If the workbook item is missing an ID.
620
-
621
- Examples
622
- --------
623
- >>> server.workbooks.populate_pdf(workbook)
624
- >>> with open("workbook.pdf", "wb") as f:
625
- >>> f.write(workbook.pdf)
626
503
"""
627
504
if not workbook_item .id :
628
505
error = "Workbook item missing ID."
@@ -671,12 +548,6 @@ def populate_powerpoint(self, workbook_item: WorkbookItem, req_options: Optional
671
548
------
672
549
MissingRequiredFieldError
673
550
If the workbook item is missing an ID.
674
-
675
- Examples
676
- --------
677
- >>> server.workbooks.populate_powerpoint(workbook)
678
- >>> with open("workbook.pptx", "wb") as f:
679
- >>> f.write(workbook.pptx)
680
551
"""
681
552
if not workbook_item .id :
682
553
error = "Workbook item missing ID."
@@ -716,18 +587,6 @@ def populate_preview_image(self, workbook_item: WorkbookItem) -> None:
716
587
------
717
588
MissingRequiredFieldError
718
589
If the workbook item is missing an ID.
719
-
720
- Examples
721
- --------
722
- >>> # import tableauserverclient as TSC
723
- >>> # server = TSC.Server('https://SERVERURL')
724
- >>> # ...
725
-
726
- >>> # get the workbook item
727
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
728
-
729
- >>> # get the preview image
730
- >>> server.workbooks.populate_preview_image(workbook)
731
590
"""
732
591
if not workbook_item .id :
733
592
error = "Workbook item missing ID. W
179B
orkbook must be retrieved from server first."
@@ -760,11 +619,6 @@ def populate_permissions(self, item: WorkbookItem) -> None:
760
619
Returns
761
620
-------
762
621
None
763
-
764
- Examples
765
- --------
766
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
767
- >>> server.workbooks.populate_permissions(workbook)
768
622
"""
769
623
self ._permissions .populate (item )
770
624
@@ -789,14 +643,6 @@ def update_permissions(self, resource: WorkbookItem, rules: list[PermissionsRule
789
643
-------
790
644
list[PermissionsRule]
791
645
The updated permissions rules.
792
-
793
- Examples
794
- --------
795
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
796
- >>> server.workbooks.populate_permissions(workbook)
797
- >>> rules = workbook.permissions
798
- >>> rules[0].capabilities |= {TSC.PermissionRule.Capability.Read: TSC.PermissionRule.Mode.Allow}
799
- >>> server.workbooks.update_permissions(workbook, rules)
800
646
"""
801
647
return self ._permissions .update (resource , rules )
802
648
@@ -818,13 +664,6 @@ def delete_permission(self, item: WorkbookItem, capability_item: PermissionsRule
818
664
Returns
819
665
-------
820
666
None
821
-
822
- Examples
823
- --------
824
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
825
- >>> server.workbooks.populate_permissions(workbook)
826
- >>> rule = workbook.permissions[0]
827
- >>> server.workbooks.delete_permission(workbook, rule)
828
667
"""
829
668
return self ._permissions .delete (item , capability_item )
830
669
@@ -917,20 +756,6 @@ def publish(
917
756
-------
918
757
WorkbookItem | JobItem
919
758
The workbook item or job item that was published.
920
-
921
- Examples
922
- --------
923
- >>> import tableauserverclient as TSC
924
- >>> tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
925
- >>> server = TSC.Server('https://servername')
926
-
927
- >>> with server.auth.sign_in(tableau_auth):
928
- >>> # create a workbook item
929
- >>> wb_item = TSC.WorkbookItem(name='Sample', project_id='1f2f3e4e-5d6d-7c8c-9b0b-1a2a3f4f5e6e')
930
- >>> # set hidden views
931
- >>> wb_item.hidden_views = ['Sheet1', 'Sheet2']
932
- >>> # call the publish method with the workbook item
933
- >>> wb_item = server.workbooks.publish(wb_item, 'SampleWB.twbx', 'Overwrite')
934
759
"""
935
760
if isinstance (file , (str , os .PathLike )):
936
761
if not os .path .isfile (file ):
@@ -1059,13 +884,6 @@ def populate_revisions(self, workbook_item: WorkbookItem) -> None:
1059
884
------
1060
885
MissingRequiredFieldError
1061
886
If the workbook item is missing an ID.
1062
-
1063
- Examples
1064
- --------
1065
- >>> workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
1066
- >>> server.workbooks.populate_revisions(workbook)
1067
- >>> print([revision.revision_number for revision in workbook.revisions])
1068
-
1069
887
"""
1070
888
if not workbook_item .id :
1071
889
error = "Workbook item missing ID. Workbook must be retrieved from server first."
@@ -1126,10 +944,6 @@ def download_revision(
1126
944
------
1127
945
ValueError
1128
946
If the workbook ID is not defined.
1129
-
1130
- Examples
1131
- --------
1132
- >>> filepath = server.workbooks.download('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d', '5')
1133
947
"""
1134
948
1135
949
if not workbook_id :
@@ -1186,10 +1000,6 @@ def delete_revision(self, workbook_id: str, revision_number: str) -> None:
1186
1000
------
1187
1001
ValueError
1188
1002
If the workbook ID or revision number is not defined.
1189
-
1190
- Examples
1191
- --------
1192
- >>> server.workbooks.delete_revision('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d', '5')
1193
1003
"""
1194
1004
if workbook_id is None or revision_number is None :
1195
1005
raise ValueError
@@ -1220,10 +1030,6 @@ def schedule_extract_refresh(
1220
1030
-------
1221
1031
list[AddResponse]
1222
1032
The response from the server.
1223
-
1224
- Examples
1225
- --------
1226
- >>> server.workbooks.schedule_extract_refresh('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d', workbook)
1227
1033
"""
1228
1034
return self .parent_srv .schedules .add_to_schedule (schedule_id , workbook = item )
1229
1035
@@ -1248,11 +1054,6 @@ def add_tags(self, item: Union[WorkbookItem, str], tags: Union[Iterable[str], st
1248
1054
-------
1249
1055
set[str]
1250
1056
The set of tags added to the workbook.
1251
-
1252
- Examples
1253
- --------
1254
- >>> server.workbooks.add_tags(workbook, 'tag1')
1255
- >>> server.workbooks.add_tags(workbook, ['tag1', 'tag2'])
1256
1057
"""
1257
1058
return super ().add_tags (item , tags )
1258
1059
@@ -1275,11 +1076,6 @@ def delete_tags(self, item: Union[WorkbookItem, str], tags: Union[Iterable[str],
1275
1076
Returns
1276
1077
-------
1277
1078
None
1278
-
1279
- Examples
1280
- --------
1281
- >>> server.workbooks.delete_tags(workbook, 'tag1')
1282
- >>> server.workbooks.delete_tags(workbook, ['tag1', 'tag2'])
1283
1079
"""
1284
1080
return super ().delete_tags (item , tags )
1285
1081
0 commit comments