6
6
from defusedxml .ElementTree import fromstring
7
7
8
8
from tableauserverclient .datetime_helpers import parse_datetime
9
+ from tableauserverclient .helpers .strings import nullable_str_to_bool , nullable_str_to_int
9
10
from tableauserverclient .models .connection_item import ConnectionItem
10
11
from tableauserverclient .models .exceptions import UnpopulatedPropertyError
11
12
from tableauserverclient .models .permissions_item import PermissionsRule
13
+ from tableauserverclient .models .project_item import ProjectItem
12
14
from tableauserverclient .models .property_decorators import (
13
15
property_not_nullable ,
14
16
property_is_boolean ,
15
17
property_is_enum ,
16
18
)
17
19
from tableauserverclient .models .revision_item import RevisionItem
18
20
from tableauserverclient .models .tag_item import TagItem
21
+ from tableauserverclient .models .user_item import UserItem
19
22
20
23
21
24
class DatasourceItem :
@@ -40,6 +43,9 @@ class DatasourceItem:
40
43
specified, it will default to SiteDefault. See REST API Publish
41
44
Datasource for more information about ask_data_enablement.
42
45
46
+ connected_workbooks_count : Optional[int]
47
+ The number of workbooks connected to the datasource.
48
+
43
49
connections : list[ConnectionItem]
44
50
The list of data connections (ConnectionItem) for the specified data
45
51
source. You must first call the populate_connections method to access
@@ -67,6 +73,12 @@ class DatasourceItem:
67
73
A Boolean value to determine if a datasource should be encrypted or not.
68
74
See Extract and Encryption Methods for more information.
69
75
76
+ favorites_total : Optional[int]
77
+ The number of users who have marked the data source as a favorite.
78
+
79
+ has_alert : Optional[bool]
80
+ A Boolean value that indicates whether the data source has an alert.
81
+
70
82
has_extracts : Optional[bool]
71
83
A Boolean value that indicates whether the datasource has extracts.
72
84
@@ -75,20 +87,32 @@ class DatasourceItem:
75
87
specific data source or to delete a data source with the get_by_id and
76
88
delete methods.
77
89
90
+ is_published : Optional[bool]
91
+ A Boolean value that indicates whether the data source is published.
92
+
78
93
name : Optional[str]
79
94
The name of the data source. If not specified, the name of the published
80
95
data source file is used.
81
96
97
+ owner: Optional[UserItem]
98
+ The owner of the data source.
99
+
82
100
owner_id : Optional[str]
83
101
The identifier of the owner of the data source.
84
102
103
+ project : Optional[ProjectItem]
104
+ The project that the data source belongs to.
105
+
85
106
project_id : Optional[str]
86
107
The identifier of the project associated with the data source. You must
87
108
provide this identifier when you create an instance of a DatasourceItem.
88
109
89
110
project_name : Optional[str]
90
111
The name of the project associated with the data source.
91
112
113
+ server_name : Optional[str]
114
+ The name of the server where the data source is published.
115
+
92
116
tags : Optional[set[str]]
93
117
The tags (list of strings) that have been added to the data source.
94
118
@@ -143,6 +167,13 @@ def __init__(self, project_id: Optional[str] = None, name: Optional[str] = None)
143
167
self .owner_id : Optional [str ] = None
144
168
self .project_id : Optional [str ] = project_id
145
169
self .tags : set [str ] = set ()
170
+ self ._connected_workbooks_count : Optional [int ] = None
171
+ self ._favorites_total : Optional [int ] = None
172
+ self ._has_alert : Optional [bool ] = None
173
+ self ._is_published : Optional [bool ] = None
174
+ self ._server_name : Optional [str ] = None
175
+ self ._project : Optional [ProjectItem ] = None
176
+ self ._owner : Optional [UserItem ] = None
146
177
147
178
self ._permissions = None
148
179
self ._data_quality_warnings = None
@@ -274,14 +305,42 @@ def revisions(self) -> list[RevisionItem]:
274
305
def size (self ) -> Optional [int ]:
275
306
return self ._size
276
307
308
+ @property
309
+ def connected_workbooks_count (self ) -> Optional [int ]:
310
+ return self ._connected_workbooks_count
311
+
312
+ @property
313
+ def favorites_total (self ) -> Optional [int ]:
314
+ return self ._favorites_total
315
+
316
+ @property
317
+ def has_alert (self ) -> Optional [bool ]:
318
+ return self ._has_alert
319
+
320
+ @property
321
+ def is_published (self ) -> Optional [bool ]:
322
+ return self ._is_published
323
+
324
+ @property
325
+ def server_name (self ) -> Optional [str ]:
326
+ return self ._server_name
327
+
328
+ @property
329
+ def project (self ) -> Optional [ProjectItem ]:
330
+ return self ._project
331
+
332
+ @property
333
+ def owner (self ) -> Optional [UserItem ]:
334
+ return self ._owner
335
+
277
336
def _set_connections (self , connections ) -> None :
278
337
self ._connections = connections
279
338
280
339
def _set_permissions (self , permissions ):
281
340
self ._permissions = permissions
282
341
283
- def _set_data_quality_warnings (self , dqws ):
284
- self ._data_quality_warnings = dqws
342
+ def _set_data_quality_warnings (self , dqw ):
343
+ self ._data_quality_warnings = dqw
285
344
286
345
def _set_revisions (self , revisions ):
287
346
self ._revisions = revisions
@@ -310,6 +369,13 @@ def _parse_common_elements(self, datasource_xml, ns):
310
369
use_remote_query_agent ,
311
370
webpage_url ,
312
371
size ,
372
+ connected_workbooks_count ,
373
+ favorites_total ,
374
+ has_alert ,
375
+ is_published ,
376
+ server_name ,
377
+ project ,
378
+ owner ,
313
379
) = self ._parse_element (datasource_xml , ns )
314
380
self ._set_values (
315
381
ask_data_enablement ,
@@ -331,6 +397,13 @@ def _parse_common_elements(self, datasource_xml, ns):
331
397
use_remote_query_agent ,
332
398
webpage_url ,
333
399
size ,
400
+ connected_workbooks_count ,
401
+ favorites_total ,
402
+ has_alert ,
403
+ is_published ,
404
+ server_name ,
405
+ project ,
406
+ owner ,
334
407
)
335
408
return self
336
409
@@ -355,6 +428,13 @@ def _set_values(
355
428
use_remote_query_agent ,
356
429
webpage_url ,
357
430
size ,
431
+ connected_workbooks_count ,
432
+ favorites_total ,
433
+ has_alert ,
434
+ is_published ,
435
+ server_name ,
436
+ project ,
437
+ owner ,
358
438
):
359
439
if ask_data_enablement is not None :
360
440
self ._ask_data_enablement = ask_data_enablement
@@ -394,6 +474,20 @@ def _set_values(
394
474
self ._webpage_url = webpage_url
395
475
if size is not None :
396
476
self ._size = int (size )
477
+ if connected_workbooks_count is not None :
478
+ self ._connected_workbooks_count = connected_workbooks_count
479
+ if favorites_total is not None :
480
+ self ._favorites_total = favorites_total
481
+ if has_alert is not None :
482
+ self ._has_alert = has_alert
483
+ if is_published is not None :
484
+ self ._is_published = is_published
485
+ if server_name is not None :
486
+ self ._server_name = server_name
487
+ if project is not None :
488
+ self ._project = project
489
+ if owner is not None :
490
+ self ._owner = owner
397
491
398
492
@classmethod
399
493
def from_response (cls , resp : str , ns : dict ) -> list ["DatasourceItem" ]:
@@ -428,6 +522,11 @@ def _parse_element(datasource_xml: ET.Element, ns: dict) -> tuple:
428
522
use_remote_query_agent = datasource_xml .get ("useRemoteQueryAgent" , None )
429
523
webpage_url = datasource_xml .get ("webpageUrl" , None )
430
524
size = datasource_xml .get ("size" , None )
525
+ connected_workbooks_count = nullable_str_to_int (datasource_xml .get ("connectedWorkbooksCount" , None ))
526
+ favorites_total = nullable_str_to_int (datasource_xml .get ("favoritesTotal" , None ))
527
+ has_alert = nullable_str_to_bool (datasource_xml .get ("hasAlert" , None ))
528
+ is_published = nullable_str_to_bool (datasource_xml .get ("isPublished" , None ))
529
+ server_name = datasource_xml .get ("serverName" , None )
431
530
432
531
tags = None
433
532
tags_elem = datasource_xml .find (".//t:tags" , namespaces = ns )
@@ -438,12 +537,14 @@ def _parse_element(datasource_xml: ET.Element, ns: dict) -> tuple:
438
537
project_name = None
439
538
project_elem = datasource_xml .find (".//t:project" , namespaces = ns )
440
539
if project_elem is not None :
540
+ project = ProjectItem .from_xml (project_elem , ns )
441
541
project_id = project_elem .get ("id" , None )
442
542
project_name = project_elem .get ("name" , None )
443
543
444
544
owner_id = None
445
545
owner_elem = datasource_xml .find (".//t:owner" , namespaces = ns )
446
546
if owner_elem is not None :
547
+ owner = UserItem .from_xml (owner_elem , ns )
447
548
owner_id = owner_elem .get ("id" , None )
448
549
449
550
ask_data_enablement = None
@@ -471,4 +572,11 @@ def _parse_element(datasource_xml: ET.Element, ns: dict) -> tuple:
471
572
use_remote_query_agent ,
472
573
webpage_url ,
473
574
size ,
575
+ connected_workbooks_count ,
576
+ favorites_total ,
577
+ has_alert ,
578
+ is_published ,
579
+ server_name ,
580
+ project ,
581
+ owner ,
474
582
)
0 commit comments