tableauserverclient 0.32__py3-none-any.whl → 0.33__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tableauserverclient/__init__.py +10 -0
- tableauserverclient/_version.py +3 -3
- tableauserverclient/config.py +16 -4
- tableauserverclient/models/__init__.py +12 -0
- tableauserverclient/models/connection_item.py +4 -2
- tableauserverclient/models/database_item.py +6 -0
- tableauserverclient/models/flow_item.py +6 -6
- tableauserverclient/models/groupset_item.py +53 -0
- tableauserverclient/models/interval_item.py +27 -14
- tableauserverclient/models/job_item.py +18 -2
- tableauserverclient/models/linked_tasks_item.py +102 -0
- tableauserverclient/models/permissions_item.py +7 -4
- tableauserverclient/models/tableau_types.py +9 -7
- tableauserverclient/models/virtual_connection_item.py +77 -0
- tableauserverclient/server/endpoint/__init__.py +8 -0
- tableauserverclient/server/endpoint/auth_endpoint.py +3 -3
- tableauserverclient/server/endpoint/custom_views_endpoint.py +65 -4
- tableauserverclient/server/endpoint/databases_endpoint.py +21 -7
- tableauserverclient/server/endpoint/datasources_endpoint.py +105 -9
- tableauserverclient/server/endpoint/endpoint.py +32 -14
- tableauserverclient/server/endpoint/fileuploads_endpoint.py +2 -2
- tableauserverclient/server/endpoint/flow_runs_endpoint.py +44 -4
- tableauserverclient/server/endpoint/flows_endpoint.py +43 -6
- tableauserverclient/server/endpoint/groups_endpoint.py +82 -14
- tableauserverclient/server/endpoint/groupsets_endpoint.py +127 -0
- tableauserverclient/server/endpoint/jobs_endpoint.py +74 -7
- tableauserverclient/server/endpoint/linked_tasks_endpoint.py +45 -0
- tableauserverclient/server/endpoint/projects_endpoint.py +43 -0
- tableauserverclient/server/endpoint/resource_tagger.py +135 -3
- tableauserverclient/server/endpoint/tables_endpoint.py +19 -6
- tableauserverclient/server/endpoint/users_endpoint.py +39 -0
- tableauserverclient/server/endpoint/views_endpoint.py +94 -9
- tableauserverclient/server/endpoint/virtual_connections_endpoint.py +173 -0
- tableauserverclient/server/endpoint/workbooks_endpoint.py +91 -10
- tableauserverclient/server/pager.py +6 -7
- tableauserverclient/server/query.py +2 -1
- tableauserverclient/server/request_factory.py +178 -7
- tableauserverclient/server/request_options.py +4 -2
- tableauserverclient/server/server.py +8 -0
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/METADATA +15 -15
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/RECORD +45 -39
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/WHEEL +1 -1
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/LICENSE +0 -0
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/LICENSE.versioneer +0 -0
- {tableauserverclient-0.32.dist-info → tableauserverclient-0.33.dist-info}/top_level.txt +0 -0
tableauserverclient/__init__.py
CHANGED
|
@@ -17,10 +17,14 @@ from tableauserverclient.models import (
|
|
|
17
17
|
FlowRunItem,
|
|
18
18
|
FileuploadItem,
|
|
19
19
|
GroupItem,
|
|
20
|
+
GroupSetItem,
|
|
20
21
|
HourlyInterval,
|
|
21
22
|
IntervalItem,
|
|
22
23
|
JobItem,
|
|
23
24
|
JWTAuth,
|
|
25
|
+
LinkedTaskItem,
|
|
26
|
+
LinkedTaskStepItem,
|
|
27
|
+
LinkedTaskFlowRunItem,
|
|
24
28
|
MetricItem,
|
|
25
29
|
MonthlyInterval,
|
|
26
30
|
PaginationItem,
|
|
@@ -39,6 +43,7 @@ from tableauserverclient.models import (
|
|
|
39
43
|
TaskItem,
|
|
40
44
|
UserItem,
|
|
41
45
|
ViewItem,
|
|
46
|
+
VirtualConnectionItem,
|
|
42
47
|
WebhookItem,
|
|
43
48
|
WeeklyInterval,
|
|
44
49
|
WorkbookItem,
|
|
@@ -79,6 +84,7 @@ __all__ = [
|
|
|
79
84
|
"FlowRunItem",
|
|
80
85
|
"FileuploadItem",
|
|
81
86
|
"GroupItem",
|
|
87
|
+
"GroupSetItem",
|
|
82
88
|
"HourlyInterval",
|
|
83
89
|
"IntervalItem",
|
|
84
90
|
"JobItem",
|
|
@@ -116,4 +122,8 @@ __all__ = [
|
|
|
116
122
|
"Pager",
|
|
117
123
|
"Server",
|
|
118
124
|
"Sort",
|
|
125
|
+
"LinkedTaskItem",
|
|
126
|
+
"LinkedTaskStepItem",
|
|
127
|
+
"LinkedTaskFlowRunItem",
|
|
128
|
+
"VirtualConnectionItem",
|
|
119
129
|
]
|
tableauserverclient/_version.py
CHANGED
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-
|
|
11
|
+
"date": "2024-09-17T16:51:07-0700",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "0.
|
|
14
|
+
"full-revisionid": "4259316ef2e2656531b0c65c71d043708b37b4a9",
|
|
15
|
+
"version": "0.33"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
tableauserverclient/config.py
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
2
|
|
|
3
3
|
ALLOWED_FILE_EXTENSIONS = ["tds", "tdsx", "tde", "hyper", "parquet"]
|
|
4
4
|
|
|
5
5
|
BYTES_PER_MB = 1024 * 1024
|
|
6
6
|
|
|
7
|
-
# For when a datasource is over 64MB, break it into 5MB(standard chunk size) chunks
|
|
8
|
-
CHUNK_SIZE_MB = 5 * 10 # 5MB felt too slow, upped it to 50
|
|
9
|
-
|
|
10
7
|
DELAY_SLEEP_SECONDS = 0.1
|
|
11
8
|
|
|
12
9
|
# The maximum size of a file that can be published in a single request is 64MB
|
|
13
10
|
FILESIZE_LIMIT_MB = 64
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Config:
|
|
14
|
+
# For when a datasource is over 64MB, break it into 5MB(standard chunk size) chunks
|
|
15
|
+
@property
|
|
16
|
+
def CHUNK_SIZE_MB(self):
|
|
17
|
+
return int(os.getenv("TSC_CHUNK_SIZE_MB", 5 * 10)) # 5MB felt too slow, upped it to 50
|
|
18
|
+
|
|
19
|
+
# Default page size
|
|
20
|
+
@property
|
|
21
|
+
def PAGE_SIZE(self):
|
|
22
|
+
return int(os.getenv("TSC_PAGE_SIZE", 100))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
config = Config()
|
|
@@ -14,6 +14,7 @@ from tableauserverclient.models.fileupload_item import FileuploadItem
|
|
|
14
14
|
from tableauserverclient.models.flow_item import FlowItem
|
|
15
15
|
from tableauserverclient.models.flow_run_item import FlowRunItem
|
|
16
16
|
from tableauserverclient.models.group_item import GroupItem
|
|
17
|
+
from tableauserverclient.models.groupset_item import GroupSetItem
|
|
17
18
|
from tableauserverclient.models.interval_item import (
|
|
18
19
|
IntervalItem,
|
|
19
20
|
DailyInterval,
|
|
@@ -22,6 +23,11 @@ from tableauserverclient.models.interval_item import (
|
|
|
22
23
|
HourlyInterval,
|
|
23
24
|
)
|
|
24
25
|
from tableauserverclient.models.job_item import JobItem, BackgroundJobItem
|
|
26
|
+
from tableauserverclient.models.linked_tasks_item import (
|
|
27
|
+
LinkedTaskItem,
|
|
28
|
+
LinkedTaskStepItem,
|
|
29
|
+
LinkedTaskFlowRunItem,
|
|
30
|
+
)
|
|
25
31
|
from tableauserverclient.models.metric_item import MetricItem
|
|
26
32
|
from tableauserverclient.models.pagination_item import PaginationItem
|
|
27
33
|
from tableauserverclient.models.permissions_item import PermissionsRule, Permission
|
|
@@ -39,6 +45,7 @@ from tableauserverclient.models.target import Target
|
|
|
39
45
|
from tableauserverclient.models.task_item import TaskItem
|
|
40
46
|
from tableauserverclient.models.user_item import UserItem
|
|
41
47
|
from tableauserverclient.models.view_item import ViewItem
|
|
48
|
+
from tableauserverclient.models.virtual_connection_item import VirtualConnectionItem
|
|
42
49
|
from tableauserverclient.models.webhook_item import WebhookItem
|
|
43
50
|
from tableauserverclient.models.workbook_item import WorkbookItem
|
|
44
51
|
|
|
@@ -60,6 +67,7 @@ __all__ = [
|
|
|
60
67
|
"FlowItem",
|
|
61
68
|
"FlowRunItem",
|
|
62
69
|
"GroupItem",
|
|
70
|
+
"GroupSetItem",
|
|
63
71
|
"IntervalItem",
|
|
64
72
|
"JobItem",
|
|
65
73
|
"DailyInterval",
|
|
@@ -89,6 +97,10 @@ __all__ = [
|
|
|
89
97
|
"TaskItem",
|
|
90
98
|
"UserItem",
|
|
91
99
|
"ViewItem",
|
|
100
|
+
"VirtualConnectionItem",
|
|
92
101
|
"WebhookItem",
|
|
93
102
|
"WorkbookItem",
|
|
103
|
+
"LinkedTaskItem",
|
|
104
|
+
"LinkedTaskStepItem",
|
|
105
|
+
"LinkedTaskFlowRunItem",
|
|
94
106
|
]
|
|
@@ -66,12 +66,14 @@ class ConnectionItem(object):
|
|
|
66
66
|
for connection_xml in all_connection_xml:
|
|
67
67
|
connection_item = cls()
|
|
68
68
|
connection_item._id = connection_xml.get("id", None)
|
|
69
|
-
connection_item._connection_type = connection_xml.get("type", None)
|
|
69
|
+
connection_item._connection_type = connection_xml.get("type", connection_xml.get("dbClass", None))
|
|
70
70
|
connection_item.embed_password = string_to_bool(connection_xml.get("embedPassword", ""))
|
|
71
71
|
connection_item.server_address = connection_xml.get("serverAddress", None)
|
|
72
72
|
connection_item.server_port = connection_xml.get("serverPort", None)
|
|
73
73
|
connection_item.username = connection_xml.get("userName", None)
|
|
74
|
-
connection_item._query_tagging =
|
|
74
|
+
connection_item._query_tagging = (
|
|
75
|
+
string_to_bool(s) if (s := connection_xml.get("queryTagging", None)) else None
|
|
76
|
+
)
|
|
75
77
|
datasource_elem = connection_xml.find(".//t:datasource", namespaces=ns)
|
|
76
78
|
if datasource_elem is not None:
|
|
77
79
|
connection_item._datasource_id = datasource_elem.get("id", None)
|
|
@@ -44,6 +44,12 @@ class DatabaseItem(object):
|
|
|
44
44
|
|
|
45
45
|
self._tables = None # Not implemented yet
|
|
46
46
|
|
|
47
|
+
def __str__(self):
|
|
48
|
+
return "<Database {0} '{1}'>".format(self._id, self.name)
|
|
49
|
+
|
|
50
|
+
def __repr__(self):
|
|
51
|
+
return self.__str__() + " { " + ", ".join(" % s: % s" % item for item in vars(self).items()) + "}"
|
|
52
|
+
|
|
47
53
|
@property
|
|
48
54
|
def dqws(self):
|
|
49
55
|
if self._data_quality_warnings is None:
|
|
@@ -6,12 +6,12 @@ from typing import List, Optional, Set
|
|
|
6
6
|
from defusedxml.ElementTree import fromstring
|
|
7
7
|
|
|
8
8
|
from tableauserverclient.datetime_helpers import parse_datetime
|
|
9
|
-
from .connection_item import ConnectionItem
|
|
10
|
-
from .dqw_item import DQWItem
|
|
11
|
-
from .exceptions import UnpopulatedPropertyError
|
|
12
|
-
from .permissions_item import Permission
|
|
13
|
-
from .property_decorators import property_not_nullable
|
|
14
|
-
from .tag_item import TagItem
|
|
9
|
+
from tableauserverclient.models.connection_item import ConnectionItem
|
|
10
|
+
from tableauserverclient.models.dqw_item import DQWItem
|
|
11
|
+
from tableauserverclient.models.exceptions import UnpopulatedPropertyError
|
|
12
|
+
from tableauserverclient.models.permissions_item import Permission
|
|
13
|
+
from tableauserverclient.models.property_decorators import property_not_nullable
|
|
14
|
+
from tableauserverclient.models.tag_item import TagItem
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class FlowItem(object):
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from typing import Dict, List, Optional
|
|
2
|
+
import xml.etree.ElementTree as ET
|
|
3
|
+
|
|
4
|
+
from defusedxml.ElementTree import fromstring
|
|
5
|
+
|
|
6
|
+
from tableauserverclient.models.group_item import GroupItem
|
|
7
|
+
from tableauserverclient.models.reference_item import ResourceReference
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GroupSetItem:
|
|
11
|
+
tag_name: str = "groupSet"
|
|
12
|
+
|
|
13
|
+
def __init__(self, name: Optional[str] = None) -> None:
|
|
14
|
+
self.name = name
|
|
15
|
+
self.id: Optional[str] = None
|
|
16
|
+
self.groups: List["GroupItem"] = []
|
|
17
|
+
self.group_count: int = 0
|
|
18
|
+
|
|
19
|
+
def __str__(self) -> str:
|
|
20
|
+
name = self.name
|
|
21
|
+
id = self.id
|
|
22
|
+
return f"<{self.__class__.__qualname__}({name=}, {id=})>"
|
|
23
|
+
|
|
24
|
+
def __repr__(self) -> str:
|
|
25
|
+
return self.__str__()
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def from_response(cls, response: bytes, ns: Dict[str, str]) -> List["GroupSetItem"]:
|
|
29
|
+
parsed_response = fromstring(response)
|
|
30
|
+
all_groupset_xml = parsed_response.findall(".//t:groupSet", namespaces=ns)
|
|
31
|
+
return [cls.from_xml(xml, ns) for xml in all_groupset_xml]
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_xml(cls, groupset_xml: ET.Element, ns: Dict[str, str]) -> "GroupSetItem":
|
|
35
|
+
def get_group(group_xml: ET.Element) -> GroupItem:
|
|
36
|
+
group_item = GroupItem()
|
|
37
|
+
group_item._id = group_xml.get("id")
|
|
38
|
+
group_item.name = group_xml.get("name")
|
|
39
|
+
return group_item
|
|
40
|
+
|
|
41
|
+
group_set_item = cls()
|
|
42
|
+
group_set_item.name = groupset_xml.get("name")
|
|
43
|
+
group_set_item.id = groupset_xml.get("id")
|
|
44
|
+
group_set_item.group_count = int(count) if (count := groupset_xml.get("groupCount")) else 0
|
|
45
|
+
group_set_item.groups = [
|
|
46
|
+
get_group(group_xml) for group_xml in groupset_xml.findall(".//t:group", namespaces=ns)
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
return group_set_item
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def as_reference(id_: str) -> ResourceReference:
|
|
53
|
+
return ResourceReference(id_, GroupSetItem.tag_name)
|
|
@@ -246,21 +246,34 @@ class MonthlyInterval(object):
|
|
|
246
246
|
|
|
247
247
|
@interval.setter
|
|
248
248
|
def interval(self, interval_values):
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
|
|
249
|
+
# Valid monthly intervals strings can contain any of the following
|
|
250
|
+
# day numbers (1-31) (integer or string)
|
|
251
|
+
# relative day within the month (First, Second, ... Last)
|
|
252
|
+
# week days (Sunday, Monday, ... LastDay)
|
|
253
|
+
VALID_INTERVALS = [
|
|
254
|
+
"Sunday",
|
|
255
|
+
"Monday",
|
|
256
|
+
"Tuesday",
|
|
257
|
+
"Wednesday",
|
|
258
|
+
"Thursday",
|
|
259
|
+
"Friday",
|
|
260
|
+
"Saturday",
|
|
261
|
+
"LastDay",
|
|
262
|
+
"First",
|
|
263
|
+
"Second",
|
|
264
|
+
"Third",
|
|
265
|
+
"Fourth",
|
|
266
|
+
"Fifth",
|
|
267
|
+
"Last",
|
|
268
|
+
]
|
|
269
|
+
for value in range(1, 32):
|
|
270
|
+
VALID_INTERVALS.append(str(value))
|
|
271
|
+
VALID_INTERVALS.append(value)
|
|
272
|
+
|
|
254
273
|
for interval_value in interval_values:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
try:
|
|
259
|
-
if not (1 <= int(interval_value) <= 31):
|
|
260
|
-
raise ValueError(error)
|
|
261
|
-
except ValueError:
|
|
262
|
-
if interval_value != "LastDay":
|
|
263
|
-
raise ValueError(error)
|
|
274
|
+
if interval_value not in VALID_INTERVALS:
|
|
275
|
+
error = f"Invalid monthly interval: {interval_value}"
|
|
276
|
+
raise ValueError(error)
|
|
264
277
|
|
|
265
278
|
self._interval = interval_values
|
|
266
279
|
|
|
@@ -4,7 +4,7 @@ from typing import List, Optional
|
|
|
4
4
|
from defusedxml.ElementTree import fromstring
|
|
5
5
|
|
|
6
6
|
from tableauserverclient.datetime_helpers import parse_datetime
|
|
7
|
-
from .flow_run_item import FlowRunItem
|
|
7
|
+
from tableauserverclient.models.flow_run_item import FlowRunItem
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class JobItem(object):
|
|
@@ -33,6 +33,8 @@ class JobItem(object):
|
|
|
33
33
|
datasource_id: Optional[str] = None,
|
|
34
34
|
flow_run: Optional[FlowRunItem] = None,
|
|
35
35
|
updated_at: Optional[datetime.datetime] = None,
|
|
36
|
+
workbook_name: Optional[str] = None,
|
|
37
|
+
datasource_name: Optional[str] = None,
|
|
36
38
|
):
|
|
37
39
|
self._id = id_
|
|
38
40
|
self._type = job_type
|
|
@@ -47,6 +49,8 @@ class JobItem(object):
|
|
|
47
49
|
self._datasource_id = datasource_id
|
|
48
50
|
self._flow_run = flow_run
|
|
49
51
|
self._updated_at = updated_at
|
|
52
|
+
self._workbook_name = workbook_name
|
|
53
|
+
self._datasource_name = datasource_name
|
|
50
54
|
|
|
51
55
|
@property
|
|
52
56
|
def id(self) -> str:
|
|
@@ -117,6 +121,14 @@ class JobItem(object):
|
|
|
117
121
|
def updated_at(self) -> Optional[datetime.datetime]:
|
|
118
122
|
return self._updated_at
|
|
119
123
|
|
|
124
|
+
@property
|
|
125
|
+
def workbook_name(self) -> Optional[str]:
|
|
126
|
+
return self._workbook_name
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def datasource_name(self) -> Optional[str]:
|
|
130
|
+
return self._datasource_name
|
|
131
|
+
|
|
120
132
|
def __str__(self):
|
|
121
133
|
return (
|
|
122
134
|
"<Job#{_id} {_type} created_at({_created_at}) started_at({_started_at}) updated_at({_updated_at}) completed_at({_completed_at})"
|
|
@@ -148,8 +160,10 @@ class JobItem(object):
|
|
|
148
160
|
mode = element.get("mode", None)
|
|
149
161
|
workbook = element.find(".//t:workbook[@id]", namespaces=ns)
|
|
150
162
|
workbook_id = workbook.get("id") if workbook is not None else None
|
|
163
|
+
workbook_name = workbook.get("name") if workbook is not None else None
|
|
151
164
|
datasource = element.find(".//t:datasource[@id]", namespaces=ns)
|
|
152
165
|
datasource_id = datasource.get("id") if datasource is not None else None
|
|
166
|
+
datasource_name = datasource.get("name") if datasource is not None else None
|
|
153
167
|
flow_run = None
|
|
154
168
|
updated_at = parse_datetime(element.get("updatedAt", None))
|
|
155
169
|
for flow_job in element.findall(".//t:runFlowJobType", namespaces=ns):
|
|
@@ -172,6 +186,8 @@ class JobItem(object):
|
|
|
172
186
|
datasource_id,
|
|
173
187
|
flow_run,
|
|
174
188
|
updated_at,
|
|
189
|
+
workbook_name,
|
|
190
|
+
datasource_name,
|
|
175
191
|
)
|
|
176
192
|
|
|
177
193
|
|
|
@@ -206,7 +222,7 @@ class BackgroundJobItem(object):
|
|
|
206
222
|
self._subtitle = subtitle
|
|
207
223
|
|
|
208
224
|
def __str__(self):
|
|
209
|
-
return f"<{self.__class__.
|
|
225
|
+
return f"<{self.__class__.__qualname__} {self._id} {self._type}>"
|
|
210
226
|
|
|
211
227
|
def __repr__(self):
|
|
212
228
|
return self.__str__() + " { " + ", ".join(" % s: % s" % item for item in vars(self).items()) + "}"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from defusedxml.ElementTree import fromstring
|
|
5
|
+
|
|
6
|
+
from tableauserverclient.datetime_helpers import parse_datetime
|
|
7
|
+
from tableauserverclient.models.schedule_item import ScheduleItem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LinkedTaskItem:
|
|
11
|
+
def __init__(self) -> None:
|
|
12
|
+
self.id: Optional[str] = None
|
|
13
|
+
self.num_steps: Optional[int] = None
|
|
14
|
+
self.schedule: Optional[ScheduleItem] = None
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_response(cls, resp: bytes, namespace) -> List["LinkedTaskItem"]:
|
|
18
|
+
parsed_response = fromstring(resp)
|
|
19
|
+
return [
|
|
20
|
+
cls._parse_element(x, namespace)
|
|
21
|
+
for x in parsed_response.findall(".//t:linkedTasks[@id]", namespaces=namespace)
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def _parse_element(cls, xml, namespace) -> "LinkedTaskItem":
|
|
26
|
+
task = cls()
|
|
27
|
+
task.id = xml.get("id")
|
|
28
|
+
task.num_steps = int(xml.get("numSteps"))
|
|
29
|
+
task.schedule = ScheduleItem.from_element(xml, namespace)[0]
|
|
30
|
+
return task
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class LinkedTaskStepItem:
|
|
34
|
+
def __init__(self) -> None:
|
|
35
|
+
self.id: Optional[str] = None
|
|
36
|
+
self.step_number: Optional[int] = None
|
|
37
|
+
self.stop_downstream_on_failure: Optional[bool] = None
|
|
38
|
+
self.task_details: List[LinkedTaskFlowRunItem] = []
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def from_task_xml(cls, xml, namespace) -> List["LinkedTaskStepItem"]:
|
|
42
|
+
return [cls._parse_element(x, namespace) for x in xml.findall(".//t:linkedTaskSteps[@id]", namespace)]
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def _parse_element(cls, xml, namespace) -> "LinkedTaskStepItem":
|
|
46
|
+
step = cls()
|
|
47
|
+
step.id = xml.get("id")
|
|
48
|
+
step.step_number = int(xml.get("stepNumber"))
|
|
49
|
+
step.stop_downstream_on_failure = string_to_bool(xml.get("stopDownstreamTasksOnFailure"))
|
|
50
|
+
step.task_details = LinkedTaskFlowRunItem._parse_element(xml, namespace)
|
|
51
|
+
return step
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class LinkedTaskFlowRunItem:
|
|
55
|
+
def __init__(self) -> None:
|
|
56
|
+
self.flow_run_id: Optional[str] = None
|
|
57
|
+
self.flow_run_priority: Optional[int] = None
|
|
58
|
+
self.flow_run_consecutive_failed_count: Optional[int] = None
|
|
59
|
+
self.flow_run_task_type: Optional[str] = None
|
|
60
|
+
self.flow_id: Optional[str] = None
|
|
61
|
+
self.flow_name: Optional[str] = None
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def _parse_element(cls, xml, namespace) -> List["LinkedTaskFlowRunItem"]:
|
|
65
|
+
all_tasks = []
|
|
66
|
+
for flow_run in xml.findall(".//t:flowRun[@id]", namespace):
|
|
67
|
+
task = cls()
|
|
68
|
+
task.flow_run_id = flow_run.get("id")
|
|
69
|
+
task.flow_run_priority = int(flow_run.get("priority"))
|
|
70
|
+
task.flow_run_consecutive_failed_count = int(flow_run.get("consecutiveFailedCount"))
|
|
71
|
+
task.flow_run_task_type = flow_run.get("type")
|
|
72
|
+
flow = flow_run.find(".//t:flow[@id]", namespace)
|
|
73
|
+
task.flow_id = flow.get("id")
|
|
74
|
+
task.flow_name = flow.get("name")
|
|
75
|
+
all_tasks.append(task)
|
|
76
|
+
|
|
77
|
+
return all_tasks
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class LinkedTaskJobItem:
|
|
81
|
+
def __init__(self) -> None:
|
|
82
|
+
self.id: Optional[str] = None
|
|
83
|
+
self.linked_task_id: Optional[str] = None
|
|
84
|
+
self.status: Optional[str] = None
|
|
85
|
+
self.created_at: Optional[dt.datetime] = None
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def from_response(cls, resp: bytes, namespace) -> "LinkedTaskJobItem":
|
|
89
|
+
parsed_response = fromstring(resp)
|
|
90
|
+
job = cls()
|
|
91
|
+
job_xml = parsed_response.find(".//t:linkedTaskJob[@id]", namespaces=namespace)
|
|
92
|
+
if job_xml is None:
|
|
93
|
+
raise ValueError("No linked task job found in response")
|
|
94
|
+
job.id = job_xml.get("id")
|
|
95
|
+
job.linked_task_id = job_xml.get("linkedTaskId")
|
|
96
|
+
job.status = job_xml.get("status")
|
|
97
|
+
job.created_at = parse_datetime(job_xml.get("createdAt"))
|
|
98
|
+
return job
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def string_to_bool(s: str) -> bool:
|
|
102
|
+
return s.lower() == "true"
|
|
@@ -3,10 +3,11 @@ from typing import Dict, List, Optional
|
|
|
3
3
|
|
|
4
4
|
from defusedxml.ElementTree import fromstring
|
|
5
5
|
|
|
6
|
-
from .exceptions import UnknownGranteeTypeError, UnpopulatedPropertyError
|
|
7
|
-
from .group_item import GroupItem
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
6
|
+
from tableauserverclient.models.exceptions import UnknownGranteeTypeError, UnpopulatedPropertyError
|
|
7
|
+
from tableauserverclient.models.group_item import GroupItem
|
|
8
|
+
from tableauserverclient.models.groupset_item import GroupSetItem
|
|
9
|
+
from tableauserverclient.models.reference_item import ResourceReference
|
|
10
|
+
from tableauserverclient.models.user_item import UserItem
|
|
10
11
|
|
|
11
12
|
from tableauserverclient.helpers.logging import logger
|
|
12
13
|
|
|
@@ -142,6 +143,8 @@ class PermissionsRule:
|
|
|
142
143
|
grantee = UserItem.as_reference(grantee_id)
|
|
143
144
|
elif grantee_type == "group":
|
|
144
145
|
grantee = GroupItem.as_reference(grantee_id)
|
|
146
|
+
elif grantee_type == "groupSet":
|
|
147
|
+
grantee = GroupSetItem.as_reference(grantee_id)
|
|
145
148
|
else:
|
|
146
149
|
raise UnknownGranteeTypeError("No support for grantee type of {}".format(grantee_type))
|
|
147
150
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from typing import Union
|
|
2
2
|
|
|
3
|
-
from .datasource_item import DatasourceItem
|
|
4
|
-
from .flow_item import FlowItem
|
|
5
|
-
from .project_item import ProjectItem
|
|
6
|
-
from .view_item import ViewItem
|
|
7
|
-
from .workbook_item import WorkbookItem
|
|
8
|
-
from .metric_item import MetricItem
|
|
3
|
+
from tableauserverclient.models.datasource_item import DatasourceItem
|
|
4
|
+
from tableauserverclient.models.flow_item import FlowItem
|
|
5
|
+
from tableauserverclient.models.project_item import ProjectItem
|
|
6
|
+
from tableauserverclient.models.view_item import ViewItem
|
|
7
|
+
from tableauserverclient.models.workbook_item import WorkbookItem
|
|
8
|
+
from tableauserverclient.models.metric_item import MetricItem
|
|
9
|
+
from tableauserverclient.models.virtual_connection_item import VirtualConnectionItem
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class Resource:
|
|
@@ -18,12 +19,13 @@ class Resource:
|
|
|
18
19
|
Metric = "metric"
|
|
19
20
|
Project = "project"
|
|
20
21
|
View = "view"
|
|
22
|
+
VirtualConnection = "virtualConnection"
|
|
21
23
|
Workbook = "workbook"
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
# resource types that have permissions, can be renamed, etc
|
|
25
27
|
# todo: refactoring: should actually define TableauItem as an interface and let all these implement it
|
|
26
|
-
TableauItem = Union[DatasourceItem, FlowItem, MetricItem, ProjectItem, ViewItem, WorkbookItem]
|
|
28
|
+
TableauItem = Union[DatasourceItem, FlowItem, MetricItem, ProjectItem, ViewItem, WorkbookItem, VirtualConnectionItem]
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
def plural_type(content_type: Resource) -> str:
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
import json
|
|
3
|
+
from typing import Callable, Dict, Iterable, List, Optional
|
|
4
|
+
from xml.etree.ElementTree import Element
|
|
5
|
+
|
|
6
|
+
from defusedxml.ElementTree import fromstring
|
|
7
|
+
|
|
8
|
+
from tableauserverclient.datetime_helpers import parse_datetime
|
|
9
|
+
from tableauserverclient.models.connection_item import ConnectionItem
|
|
10
|
+
from tableauserverclient.models.exceptions import UnpopulatedPropertyError
|
|
11
|
+
from tableauserverclient.models.permissions_item import PermissionsRule
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class VirtualConnectionItem:
|
|
15
|
+
def __init__(self, name: str) -> None:
|
|
16
|
+
self.name = name
|
|
17
|
+
self.created_at: Optional[dt.datetime] = None
|
|
18
|
+
self.has_extracts: Optional[bool] = None
|
|
19
|
+
self._id: Optional[str] = None
|
|
20
|
+
self.is_certified: Optional[bool] = None
|
|
21
|
+
self.updated_at: Optional[dt.datetime] = None
|
|
22
|
+
self.webpage_url: Optional[str] = None
|
|
23
|
+
self._connections: Optional[Callable[[], Iterable[ConnectionItem]]] = None
|
|
24
|
+
self.project_id: Optional[str] = None
|
|
25
|
+
self.owner_id: Optional[str] = None
|
|
26
|
+
self.content: Optional[Dict[str, dict]] = None
|
|
27
|
+
self.certification_note: Optional[str] = None
|
|
28
|
+
|
|
29
|
+
def __str__(self) -> str:
|
|
30
|
+
return f"{self.__class__.__qualname__}(name={self.name})"
|
|
31
|
+
|
|
32
|
+
def __repr__(self) -> str:
|
|
33
|
+
return f"<{self!s}>"
|
|
34
|
+
|
|
35
|
+
def _set_permissions(self, permissions):
|
|
36
|
+
self._permissions = permissions
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def id(self) -> Optional[str]:
|
|
40
|
+
return self._id
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def permissions(self) -> List[PermissionsRule]:
|
|
44
|
+
if self._permissions is None:
|
|
45
|
+
error = "Workbook item must be populated with permissions first."
|
|
46
|
+
raise UnpopulatedPropertyError(error)
|
|
47
|
+
return self._permissions()
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def connections(self) -> Iterable[ConnectionItem]:
|
|
51
|
+
if self._connections is None:
|
|
52
|
+
raise AttributeError("connections not populated. Call populate_connections() first.")
|
|
53
|
+
return self._connections()
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_response(cls, response: bytes, ns: Dict[str, str]) -> List["VirtualConnectionItem"]:
|
|
57
|
+
parsed_response = fromstring(response)
|
|
58
|
+
return [cls.from_xml(xml, ns) for xml in parsed_response.findall(".//t:virtualConnection[@name]", ns)]
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_xml(cls, xml: Element, ns: Dict[str, str]) -> "VirtualConnectionItem":
|
|
62
|
+
v_conn = cls(xml.get("name", ""))
|
|
63
|
+
v_conn._id = xml.get("id", None)
|
|
64
|
+
v_conn.webpage_url = xml.get("webpageUrl", None)
|
|
65
|
+
v_conn.created_at = parse_datetime(xml.get("createdAt", None))
|
|
66
|
+
v_conn.updated_at = parse_datetime(xml.get("updatedAt", None))
|
|
67
|
+
v_conn.is_certified = string_to_bool(s) if (s := xml.get("isCertified", None)) else None
|
|
68
|
+
v_conn.certification_note = xml.get("certificationNote", None)
|
|
69
|
+
v_conn.has_extracts = string_to_bool(s) if (s := xml.get("hasExtracts", None)) else None
|
|
70
|
+
v_conn.project_id = p.get("id", None) if ((p := xml.find(".//t:project[@id]", ns)) is not None) else None
|
|
71
|
+
v_conn.owner_id = o.get("id", None) if ((o := xml.find(".//t:owner[@id]", ns)) is not None) else None
|
|
72
|
+
v_conn.content = json.loads(c.text or "{}") if ((c := xml.find(".//t:content", ns)) is not None) else None
|
|
73
|
+
return v_conn
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def string_to_bool(s: str) -> bool:
|
|
77
|
+
return s.lower() in ["true", "1", "t", "y", "yes"]
|
|
@@ -12,7 +12,9 @@ from tableauserverclient.server.endpoint.flow_runs_endpoint import FlowRuns
|
|
|
12
12
|
from tableauserverclient.server.endpoint.flows_endpoint import Flows
|
|
13
13
|
from tableauserverclient.server.endpoint.flow_task_endpoint import FlowTasks
|
|
14
14
|
from tableauserverclient.server.endpoint.groups_endpoint import Groups
|
|
15
|
+
from tableauserverclient.server.endpoint.groupsets_endpoint import GroupSets
|
|
15
16
|
from tableauserverclient.server.endpoint.jobs_endpoint import Jobs
|
|
17
|
+
from tableauserverclient.server.endpoint.linked_tasks_endpoint import LinkedTasks
|
|
16
18
|
from tableauserverclient.server.endpoint.metadata_endpoint import Metadata
|
|
17
19
|
from tableauserverclient.server.endpoint.metrics_endpoint import Metrics
|
|
18
20
|
from tableauserverclient.server.endpoint.projects_endpoint import Projects
|
|
@@ -21,9 +23,11 @@ from tableauserverclient.server.endpoint.server_info_endpoint import ServerInfo
|
|
|
21
23
|
from tableauserverclient.server.endpoint.sites_endpoint import Sites
|
|
22
24
|
from tableauserverclient.server.endpoint.subscriptions_endpoint import Subscriptions
|
|
23
25
|
from tableauserverclient.server.endpoint.tables_endpoint import Tables
|
|
26
|
+
from tableauserverclient.server.endpoint.resource_tagger import Tags
|
|
24
27
|
from tableauserverclient.server.endpoint.tasks_endpoint import Tasks
|
|
25
28
|
from tableauserverclient.server.endpoint.users_endpoint import Users
|
|
26
29
|
from tableauserverclient.server.endpoint.views_endpoint import Views
|
|
30
|
+
from tableauserverclient.server.endpoint.virtual_connections_endpoint import VirtualConnections
|
|
27
31
|
from tableauserverclient.server.endpoint.webhooks_endpoint import Webhooks
|
|
28
32
|
from tableauserverclient.server.endpoint.workbooks_endpoint import Workbooks
|
|
29
33
|
|
|
@@ -43,7 +47,9 @@ __all__ = [
|
|
|
43
47
|
"Flows",
|
|
44
48
|
"FlowTasks",
|
|
45
49
|
"Groups",
|
|
50
|
+
"GroupSets",
|
|
46
51
|
"Jobs",
|
|
52
|
+
"LinkedTasks",
|
|
47
53
|
"Metadata",
|
|
48
54
|
"Metrics",
|
|
49
55
|
"Projects",
|
|
@@ -53,9 +59,11 @@ __all__ = [
|
|
|
53
59
|
"Sites",
|
|
54
60
|
"Subscriptions",
|
|
55
61
|
"Tables",
|
|
62
|
+
"Tags",
|
|
56
63
|
"Tasks",
|
|
57
64
|
"Users",
|
|
58
65
|
"Views",
|
|
66
|
+
"VirtualConnections",
|
|
59
67
|
"Webhooks",
|
|
60
68
|
"Workbooks",
|
|
61
69
|
]
|
|
@@ -4,9 +4,9 @@ import warnings
|
|
|
4
4
|
|
|
5
5
|
from defusedxml.ElementTree import fromstring
|
|
6
6
|
|
|
7
|
-
from .endpoint import Endpoint, api
|
|
8
|
-
from .exceptions import ServerResponseError
|
|
9
|
-
from
|
|
7
|
+
from tableauserverclient.server.endpoint.endpoint import Endpoint, api
|
|
8
|
+
from tableauserverclient.server.endpoint.exceptions import ServerResponseError
|
|
9
|
+
from tableauserverclient.server.request_factory import RequestFactory
|
|
10
10
|
|
|
11
11
|
from tableauserverclient.helpers.logging import logger
|
|
12
12
|
|