tableauserverclient 0.36__py3-none-any.whl → 0.38__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 +6 -0
- tableauserverclient/bin/_version.py +3 -3
- tableauserverclient/helpers/strings.py +25 -1
- tableauserverclient/models/__init__.py +6 -1
- tableauserverclient/models/connection_item.py +3 -3
- tableauserverclient/models/datasource_item.py +218 -23
- tableauserverclient/models/extract_item.py +82 -0
- tableauserverclient/models/flow_item.py +2 -2
- tableauserverclient/models/group_item.py +11 -0
- tableauserverclient/models/interval_item.py +40 -0
- tableauserverclient/models/job_item.py +1 -0
- tableauserverclient/models/location_item.py +53 -0
- tableauserverclient/models/project_item.py +138 -27
- tableauserverclient/models/schedule_item.py +57 -0
- tableauserverclient/models/site_item.py +28 -0
- tableauserverclient/models/table_item.py +7 -3
- tableauserverclient/models/tableau_types.py +13 -1
- tableauserverclient/models/user_item.py +101 -1
- tableauserverclient/models/view_item.py +79 -5
- tableauserverclient/models/workbook_item.py +151 -1
- tableauserverclient/server/__init__.py +2 -0
- tableauserverclient/server/endpoint/databases_endpoint.py +101 -18
- tableauserverclient/server/endpoint/datasources_endpoint.py +562 -7
- tableauserverclient/server/endpoint/dqw_endpoint.py +16 -6
- tableauserverclient/server/endpoint/endpoint.py +39 -0
- tableauserverclient/server/endpoint/exceptions.py +4 -0
- tableauserverclient/server/endpoint/fileuploads_endpoint.py +1 -1
- tableauserverclient/server/endpoint/groupsets_endpoint.py +2 -2
- tableauserverclient/server/endpoint/jobs_endpoint.py +1 -1
- tableauserverclient/server/endpoint/schedules_endpoint.py +132 -2
- tableauserverclient/server/endpoint/sites_endpoint.py +18 -1
- tableauserverclient/server/endpoint/tables_endpoint.py +140 -17
- tableauserverclient/server/endpoint/users_endpoint.py +22 -5
- tableauserverclient/server/endpoint/views_endpoint.py +5 -1
- tableauserverclient/server/endpoint/workbooks_endpoint.py +24 -10
- tableauserverclient/server/query.py +36 -0
- tableauserverclient/server/request_factory.py +16 -5
- tableauserverclient/server/request_options.py +162 -2
- tableauserverclient/server/server.py +42 -0
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info}/METADATA +3 -2
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info}/RECORD +45 -43
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info}/WHEEL +1 -1
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info/licenses}/LICENSE +0 -0
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info/licenses}/LICENSE.versioneer +0 -0
- {tableauserverclient-0.36.dist-info → tableauserverclient-0.38.dist-info}/top_level.txt +0 -0
|
@@ -6,10 +6,11 @@ import os
|
|
|
6
6
|
|
|
7
7
|
from contextlib import closing
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import Optional, TYPE_CHECKING, Union
|
|
9
|
+
from typing import Literal, Optional, TYPE_CHECKING, Union, overload
|
|
10
10
|
from collections.abc import Iterable, Mapping, Sequence
|
|
11
11
|
|
|
12
12
|
from tableauserverclient.helpers.headers import fix_filename
|
|
13
|
+
from tableauserverclient.models.dqw_item import DQWItem
|
|
13
14
|
from tableauserverclient.server.query import QuerySet
|
|
14
15
|
|
|
15
16
|
if TYPE_CHECKING:
|
|
@@ -71,6 +72,28 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
71
72
|
# Get all datasources
|
|
72
73
|
@api(version="2.0")
|
|
73
74
|
def get(self, req_options: Optional[RequestOptions] = None) -> tuple[list[DatasourceItem], PaginationItem]:
|
|
75
|
+
"""
|
|
76
|
+
Returns a list of published data sources on the specified site, with
|
|
77
|
+
optional parameters for specifying the paging of large results. To get
|
|
78
|
+
a list of data sources embedded in a workbook, use the Query Workbook
|
|
79
|
+
Connections method.
|
|
80
|
+
|
|
81
|
+
Endpoint is paginated, and will return one page per call.
|
|
82
|
+
|
|
83
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#query_data_sources
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
req_options : Optional[RequestOptions]
|
|
88
|
+
Optional parameters for the request, such as filters, sorting, page
|
|
89
|
+
size, and page number.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
tuple[list[DatasourceItem], PaginationItem]
|
|
94
|
+
A tuple containing the list of datasource items and pagination
|
|
95
|
+
information.
|
|
96
|
+
"""
|
|
74
97
|
logger.info("Querying all datasources on site")
|
|
75
98
|
url = self.baseurl
|
|
76
99
|
server_response = self.get_request(url, req_options)
|
|
@@ -81,6 +104,21 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
81
104
|
# Get 1 datasource by id
|
|
82
105
|
@api(version="2.0")
|
|
83
106
|
def get_by_id(self, datasource_id: str) -> DatasourceItem:
|
|
107
|
+
"""
|
|
108
|
+
Returns information about a specific data source.
|
|
109
|
+
|
|
110
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#query_data_source
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
datasource_id : str
|
|
115
|
+
The unique ID of the datasource to retrieve.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
DatasourceItem
|
|
120
|
+
An object containing information about the datasource.
|
|
121
|
+
"""
|
|
84
122
|
if not datasource_id:
|
|
85
123
|
error = "Datasource ID undefined."
|
|
86
124
|
raise ValueError(error)
|
|
@@ -92,6 +130,20 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
92
130
|
# Populate datasource item's connections
|
|
93
131
|
@api(version="2.0")
|
|
94
132
|
def populate_connections(self, datasource_item: DatasourceItem) -> None:
|
|
133
|
+
"""
|
|
134
|
+
Retrieve connection information for the specificed datasource item.
|
|
135
|
+
|
|
136
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#query_data_source_connections
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
datasource_item : DatasourceItem
|
|
141
|
+
The datasource item to retrieve connections for.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
None
|
|
146
|
+
"""
|
|
95
147
|
if not datasource_item.id:
|
|
96
148
|
error = "Datasource item missing ID. Datasource must be retrieved from server first."
|
|
97
149
|
raise MissingRequiredFieldError(error)
|
|
@@ -116,6 +168,22 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
116
168
|
# Delete 1 datasource by id
|
|
117
169
|
@api(version="2.0")
|
|
118
170
|
def delete(self, datasource_id: str) -> None:
|
|
171
|
+
"""
|
|
172
|
+
Deletes the specified data source from a site. When a data source is
|
|
173
|
+
deleted, its associated data connection is also deleted. Workbooks that
|
|
174
|
+
use the data source are not deleted, but they will no longer work
|
|
175
|
+
properly.
|
|
176
|
+
|
|
177
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#delete_data_source
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
datasource_id : str
|
|
182
|
+
|
|
183
|
+
Returns
|
|
184
|
+
-------
|
|
185
|
+
None
|
|
186
|
+
"""
|
|
119
187
|
if not datasource_id:
|
|
120
188
|
error = "Datasource ID undefined."
|
|
121
189
|
raise ValueError(error)
|
|
@@ -133,6 +201,29 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
133
201
|
filepath: Optional[PathOrFileW] = None,
|
|
134
202
|
include_extract: bool = True,
|
|
135
203
|
) -> PathOrFileW:
|
|
204
|
+
"""
|
|
205
|
+
Downloads the specified data source from a site. The data source is
|
|
206
|
+
downloaded as a .tdsx file.
|
|
207
|
+
|
|
208
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#download_data_source
|
|
209
|
+
|
|
210
|
+
Parameters
|
|
211
|
+
----------
|
|
212
|
+
datasource_id : str
|
|
213
|
+
The unique ID of the datasource to download.
|
|
214
|
+
|
|
215
|
+
filepath : Optional[PathOrFileW]
|
|
216
|
+
The file path to save the downloaded datasource to. If not
|
|
217
|
+
specified, the file will be saved to the current working directory.
|
|
218
|
+
|
|
219
|
+
include_extract : bool, default True
|
|
220
|
+
If True, the extract is included in the download. If False, the
|
|
221
|
+
extract is not included.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
filepath : PathOrFileW
|
|
226
|
+
"""
|
|
136
227
|
return self.download_revision(
|
|
137
228
|
datasource_id,
|
|
138
229
|
None,
|
|
@@ -143,6 +234,28 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
143
234
|
# Update datasource
|
|
144
235
|
@api(version="2.0")
|
|
145
236
|
def update(self, datasource_item: DatasourceItem) -> DatasourceItem:
|
|
237
|
+
"""
|
|
238
|
+
Updates the owner, project or certification status of the specified
|
|
239
|
+
data source.
|
|
240
|
+
|
|
241
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#update_data_source
|
|
242
|
+
|
|
243
|
+
Parameters
|
|
244
|
+
----------
|
|
245
|
+
datasource_item : DatasourceItem
|
|
246
|
+
The datasource item to update.
|
|
247
|
+
|
|
248
|
+
Returns
|
|
249
|
+
-------
|
|
250
|
+
DatasourceItem
|
|
251
|
+
An object containing information about the updated datasource.
|
|
252
|
+
|
|
253
|
+
Raises
|
|
254
|
+
------
|
|
255
|
+
MissingRequiredFieldError
|
|
256
|
+
If the datasource item is missing an ID.
|
|
257
|
+
"""
|
|
258
|
+
|
|
146
259
|
if not datasource_item.id:
|
|
147
260
|
error = "Datasource item missing ID. Datasource must be retrieved from server first."
|
|
148
261
|
raise MissingRequiredFieldError(error)
|
|
@@ -171,6 +284,26 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
171
284
|
def update_connection(
|
|
172
285
|
self, datasource_item: DatasourceItem, connection_item: ConnectionItem
|
|
173
286
|
) -> Optional[ConnectionItem]:
|
|
287
|
+
"""
|
|
288
|
+
Updates the server address, port, username, or password for the
|
|
289
|
+
specified data source connection.
|
|
290
|
+
|
|
291
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#update_data_source_connection
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
datasource_item : DatasourceItem
|
|
296
|
+
The datasource item to update.
|
|
297
|
+
|
|
298
|
+
connection_item : ConnectionItem
|
|
299
|
+
The connection item to update.
|
|
300
|
+
|
|
301
|
+
Returns
|
|
302
|
+
-------
|
|
303
|
+
Optional[ConnectionItem]
|
|
304
|
+
An object containing information about the updated connection.
|
|
305
|
+
"""
|
|
306
|
+
|
|
174
307
|
url = f"{self.baseurl}/{datasource_item.id}/connections/{connection_item.id}"
|
|
175
308
|
|
|
176
309
|
update_req = RequestFactory.Connection.update_req(connection_item)
|
|
@@ -188,16 +321,51 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
188
321
|
|
|
189
322
|
@api(version="2.8")
|
|
190
323
|
def refresh(self, datasource_item: DatasourceItem, incremental: bool = False) -> JobItem:
|
|
324
|
+
"""
|
|
325
|
+
Refreshes the extract of an existing workbook.
|
|
326
|
+
|
|
327
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm#run_extract_refresh_task
|
|
328
|
+
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
workbook_item : WorkbookItem | str
|
|
332
|
+
The workbook item or workbook ID.
|
|
333
|
+
incremental: bool
|
|
334
|
+
Whether to do a full refresh or incremental refresh of the extract data
|
|
335
|
+
|
|
336
|
+
Returns
|
|
337
|
+
-------
|
|
338
|
+
JobItem
|
|
339
|
+
The job item.
|
|
340
|
+
"""
|
|
191
341
|
id_ = getattr(datasource_item, "id", datasource_item)
|
|
192
342
|
url = f"{self.baseurl}/{id_}/refresh"
|
|
193
|
-
|
|
194
|
-
refresh_req = RequestFactory.Empty.empty_req()
|
|
343
|
+
refresh_req = RequestFactory.Task.refresh_req(incremental, self.parent_srv)
|
|
195
344
|
server_response = self.post_request(url, refresh_req)
|
|
196
345
|
new_job = JobItem.from_response(server_response.content, self.parent_srv.namespace)[0]
|
|
197
346
|
return new_job
|
|
198
347
|
|
|
199
348
|
@api(version="3.5")
|
|
200
349
|
def create_extract(self, datasource_item: DatasourceItem, encrypt: bool = False) -> JobItem:
|
|
350
|
+
"""
|
|
351
|
+
Create an extract for a data source in a site. Optionally, encrypt the
|
|
352
|
+
extract if the site and workbooks using it are configured to allow it.
|
|
353
|
+
|
|
354
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_extract_and_encryption.htm#create_extract_for_datasource
|
|
355
|
+
|
|
356
|
+
Parameters
|
|
357
|
+
----------
|
|
358
|
+
datasource_item : DatasourceItem | str
|
|
359
|
+
The datasource item or datasource ID.
|
|
360
|
+
|
|
361
|
+
encrypt : bool, default False
|
|
362
|
+
Whether to encrypt the extract.
|
|
363
|
+
|
|
364
|
+
Returns
|
|
365
|
+
-------
|
|
366
|
+
JobItem
|
|
367
|
+
The job item.
|
|
368
|
+
"""
|
|
201
369
|
id_ = getattr(datasource_item, "id", datasource_item)
|
|
202
370
|
url = f"{self.baseurl}/{id_}/createExtract?encrypt={encrypt}"
|
|
203
371
|
empty_req = RequestFactory.Empty.empty_req()
|
|
@@ -207,11 +375,49 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
207
375
|
|
|
208
376
|
@api(version="3.5")
|
|
209
377
|
def delete_extract(self, datasource_item: DatasourceItem) -> None:
|
|
378
|
+
"""
|
|
379
|
+
Delete the extract of a data source in a site.
|
|
380
|
+
|
|
381
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_extract_and_encryption.htm#delete_extract_from_datasource
|
|
382
|
+
|
|
383
|
+
Parameters
|
|
384
|
+
----------
|
|
385
|
+
datasource_item : DatasourceItem | str
|
|
386
|
+
The datasource item or datasource ID.
|
|
387
|
+
|
|
388
|
+
Returns
|
|
389
|
+
-------
|
|
390
|
+
None
|
|
391
|
+
"""
|
|
210
392
|
id_ = getattr(datasource_item, "id", datasource_item)
|
|
211
393
|
url = f"{self.baseurl}/{id_}/deleteExtract"
|
|
212
394
|
empty_req = RequestFactory.Empty.empty_req()
|
|
213
395
|
self.post_request(url, empty_req)
|
|
214
396
|
|
|
397
|
+
@overload
|
|
398
|
+
def publish(
|
|
399
|
+
self,
|
|
400
|
+
datasource_item: DatasourceItem,
|
|
401
|
+
file: PathOrFileR,
|
|
402
|
+
mode: str,
|
|
403
|
+
connection_credentials: Optional[ConnectionCredentials] = None,
|
|
404
|
+
connections: Optional[Sequence[ConnectionItem]] = None,
|
|
405
|
+
as_job: Literal[False] = False,
|
|
406
|
+
) -> DatasourceItem:
|
|
407
|
+
pass
|
|
408
|
+
|
|
409
|
+
@overload
|
|
410
|
+
def publish(
|
|
411
|
+
self,
|
|
412
|
+
datasource_item: DatasourceItem,
|
|
413
|
+
file: PathOrFileR,
|
|
414
|
+
mode: str,
|
|
415
|
+
connection_credentials: Optional[ConnectionCredentials] = None,
|
|
416
|
+
connections: Optional[Sequence[ConnectionItem]] = None,
|
|
417
|
+
as_job: Literal[True] = True,
|
|
418
|
+
) -> JobItem:
|
|
419
|
+
pass
|
|
420
|
+
|
|
215
421
|
# Publish datasource
|
|
216
422
|
@api(version="2.0")
|
|
217
423
|
@parameter_added_in(connections="2.8")
|
|
@@ -225,6 +431,50 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
225
431
|
connections: Optional[Sequence[ConnectionItem]] = None,
|
|
226
432
|
as_job: bool = False,
|
|
227
433
|
) -> Union[DatasourceItem, JobItem]:
|
|
434
|
+
"""
|
|
435
|
+
Publishes a data source to a server, or appends data to an existing
|
|
436
|
+
data source.
|
|
437
|
+
|
|
438
|
+
This method checks the size of the data source and automatically
|
|
439
|
+
determines whether the publish the data source in multiple parts or in
|
|
440
|
+
one operation.
|
|
441
|
+
|
|
442
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#publish_data_source
|
|
443
|
+
|
|
444
|
+
Parameters
|
|
445
|
+
----------
|
|
446
|
+
datasource_item : DatasourceItem
|
|
447
|
+
The datasource item to publish. The fields for name and project_id
|
|
448
|
+
are required.
|
|
449
|
+
|
|
450
|
+
file : PathOrFileR
|
|
451
|
+
The file path or file object to publish.
|
|
452
|
+
|
|
453
|
+
mode : str
|
|
454
|
+
Specifies whether you are publishing a new datasource (CreateNew),
|
|
455
|
+
overwriting an existing datasource (Overwrite), or add to an
|
|
456
|
+
existing datasource (Append). You can also use the publish mode
|
|
457
|
+
attributes, for example: TSC.Server.PublishMode.Overwrite.
|
|
458
|
+
|
|
459
|
+
connection_credentials : Optional[ConnectionCredentials]
|
|
460
|
+
The connection credentials to use when publishing the datasource.
|
|
461
|
+
Mutually exclusive with the connections parameter.
|
|
462
|
+
|
|
463
|
+
connections : Optional[Sequence[ConnectionItem]]
|
|
464
|
+
The connections to use when publishing the datasource. Mutually
|
|
465
|
+
exclusive with the connection_credentials parameter.
|
|
466
|
+
|
|
467
|
+
as_job : bool, default False
|
|
468
|
+
If True, the publish operation is asynchronous and returns a job
|
|
469
|
+
item. If False, the publish operation is synchronous and returns a
|
|
470
|
+
datasource item.
|
|
471
|
+
|
|
472
|
+
Returns
|
|
473
|
+
-------
|
|
474
|
+
Union[DatasourceItem, JobItem]
|
|
475
|
+
The datasource item or job item.
|
|
476
|
+
|
|
477
|
+
"""
|
|
228
478
|
if isinstance(file, (os.PathLike, str)):
|
|
229
479
|
if not os.path.isfile(file):
|
|
230
480
|
error = "File path does not lead to an existing file."
|
|
@@ -329,6 +579,51 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
329
579
|
actions: Sequence[Mapping],
|
|
330
580
|
payload: Optional[FilePath] = None,
|
|
331
581
|
) -> JobItem:
|
|
582
|
+
"""
|
|
583
|
+
Incrementally updates data (insert, update, upsert, replace and delete)
|
|
584
|
+
in a published data source from a live-to-Hyper connection, where the
|
|
585
|
+
data source has multiple connections.
|
|
586
|
+
|
|
587
|
+
A live-to-Hyper connection has a Hyper or Parquet formatted
|
|
588
|
+
file/database as the origin of its data.
|
|
589
|
+
|
|
590
|
+
For all connections to Parquet files, and for any data sources with a
|
|
591
|
+
single connection generally, you can use the Update Data in Hyper Data
|
|
592
|
+
Source method without specifying the connection-id.
|
|
593
|
+
|
|
594
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#update_data_in_hyper_connection
|
|
595
|
+
|
|
596
|
+
Parameters
|
|
597
|
+
----------
|
|
598
|
+
datasource_or_connection_item : Union[DatasourceItem, ConnectionItem, str]
|
|
599
|
+
The datasource item, connection item, or datasource ID. Either a
|
|
600
|
+
DataSourceItem or a ConnectionItem. If the datasource only contains
|
|
601
|
+
a single connection, the DataSourceItem is sufficient to identify
|
|
602
|
+
which data should be updated. Otherwise, for datasources with
|
|
603
|
+
multiple connections, a ConnectionItem must be provided.
|
|
604
|
+
|
|
605
|
+
request_id : str
|
|
606
|
+
User supplied arbitrary string to identify the request. A request
|
|
607
|
+
identified with the same key will only be executed once, even if
|
|
608
|
+
additional requests using the key are made, for instance, due to
|
|
609
|
+
retries when facing network issues.
|
|
610
|
+
|
|
611
|
+
actions : Sequence[Mapping]
|
|
612
|
+
A list of actions (insert, update, delete, ...) specifying how to
|
|
613
|
+
modify the data within the published datasource. For more
|
|
614
|
+
information on the actions, see: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_how_to_update_data_to_hyper.htm#action-batch-descriptions
|
|
615
|
+
|
|
616
|
+
payload : Optional[FilePath]
|
|
617
|
+
A Hyper file containing tuples to be inserted/deleted/updated or
|
|
618
|
+
other payload data used by the actions. Hyper files can be created
|
|
619
|
+
using the Tableau Hyper API or pantab.
|
|
620
|
+
|
|
621
|
+
Returns
|
|
622
|
+
-------
|
|
623
|
+
JobItem
|
|
624
|
+
The job running on the server.
|
|
625
|
+
|
|
626
|
+
"""
|
|
332
627
|
if isinstance(datasource_or_connection_item, DatasourceItem):
|
|
333
628
|
datasource_id = datasource_or_connection_item.id
|
|
334
629
|
url = f"{self.baseurl}/{datasource_id}/data"
|
|
@@ -357,35 +652,179 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
357
652
|
|
|
358
653
|
@api(version="2.0")
|
|
359
654
|
def populate_permissions(self, item: DatasourceItem) -> None:
|
|
655
|
+
"""
|
|
656
|
+
Populates the permissions on the specified datasource item.
|
|
657
|
+
|
|
658
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_permissions.htm#query_data_source_permissions
|
|
659
|
+
|
|
660
|
+
Parameters
|
|
661
|
+
----------
|
|
662
|
+
item : DatasourceItem
|
|
663
|
+
The datasource item to populate permissions for.
|
|
664
|
+
|
|
665
|
+
Returns
|
|
666
|
+
-------
|
|
667
|
+
None
|
|
668
|
+
"""
|
|
360
669
|
self._permissions.populate(item)
|
|
361
670
|
|
|
362
671
|
@api(version="2.0")
|
|
363
672
|
def update_permissions(self, item: DatasourceItem, permission_item: list["PermissionsRule"]) -> None:
|
|
673
|
+
"""
|
|
674
|
+
Updates the permissions on the specified datasource item. This method
|
|
675
|
+
overwrites all existing permissions. Any permissions not included in
|
|
676
|
+
the list will be removed.
|
|
677
|
+
|
|
678
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_permissions.htm#replace_permissions_for_content
|
|
679
|
+
|
|
680
|
+
Parameters
|
|
681
|
+
----------
|
|
682
|
+
item : DatasourceItem
|
|
683
|
+
The datasource item to update permissions for.
|
|
684
|
+
|
|
685
|
+
permission_item : list[PermissionsRule]
|
|
686
|
+
The permissions to apply to the datasource item.
|
|
687
|
+
|
|
688
|
+
Returns
|
|
689
|
+
-------
|
|
690
|
+
None
|
|
691
|
+
"""
|
|
364
692
|
self._permissions.update(item, permission_item)
|
|
365
693
|
|
|
366
694
|
@api(version="2.0")
|
|
367
695
|
def delete_permission(self, item: DatasourceItem, capability_item: "PermissionsRule") -> None:
|
|
696
|
+
"""
|
|
697
|
+
Deletes a single permission rule from the specified datasource item.
|
|
698
|
+
|
|
699
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_permissions.htm#delete_data_source_permissionDatasourceItem
|
|
700
|
+
|
|
701
|
+
Parameters
|
|
702
|
+
----------
|
|
703
|
+
item : DatasourceItem
|
|
704
|
+
The datasource item to delete permissions from.
|
|
705
|
+
|
|
706
|
+
capability_item : PermissionsRule
|
|
707
|
+
The permission rule to delete.
|
|
708
|
+
|
|
709
|
+
Returns
|
|
710
|
+
-------
|
|
711
|
+
None
|
|
712
|
+
"""
|
|
368
713
|
self._permissions.delete(item, capability_item)
|
|
369
714
|
|
|
370
715
|
@api(version="3.5")
|
|
371
|
-
def populate_dqw(self, item):
|
|
716
|
+
def populate_dqw(self, item) -> None:
|
|
717
|
+
"""
|
|
718
|
+
Get information about the data quality warning for the database, table,
|
|
719
|
+
column, published data source, flow, virtual connection, or virtual
|
|
720
|
+
connection table.
|
|
721
|
+
|
|
722
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_metadata.htm#query_dqws
|
|
723
|
+
|
|
724
|
+
Parameters
|
|
725
|
+
----------
|
|
726
|
+
item : DatasourceItem
|
|
727
|
+
The datasource item to populate data quality warnings for.
|
|
728
|
+
|
|
729
|
+
Returns
|
|
730
|
+
-------
|
|
731
|
+
None
|
|
732
|
+
"""
|
|
372
733
|
self._data_quality_warnings.populate(item)
|
|
373
734
|
|
|
374
735
|
@api(version="3.5")
|
|
375
|
-
def update_dqw(self, item, warning):
|
|
736
|
+
def update_dqw(self, item: DatasourceItem, warning: "DQWItem") -> list["DQWItem"]:
|
|
737
|
+
"""
|
|
738
|
+
Update the warning type, status, and message of a data quality warning.
|
|
739
|
+
|
|
740
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_metadata.htm#update_dqw
|
|
741
|
+
|
|
742
|
+
Parameters
|
|
743
|
+
----------
|
|
744
|
+
item : DatasourceItem
|
|
745
|
+
The datasource item to update data quality warnings for.
|
|
746
|
+
|
|
747
|
+
warning : DQWItem
|
|
748
|
+
The data quality warning to update.
|
|
749
|
+
|
|
750
|
+
Returns
|
|
751
|
+
-------
|
|
752
|
+
DQWItem
|
|
753
|
+
The updated data quality warning.
|
|
754
|
+
"""
|
|
376
755
|
return self._data_quality_warnings.update(item, warning)
|
|
377
756
|
|
|
378
757
|
@api(version="3.5")
|
|
379
|
-
def add_dqw(self, item, warning):
|
|
758
|
+
def add_dqw(self, item: DatasourceItem, warning: "DQWItem") -> list["DQWItem"]:
|
|
759
|
+
"""
|
|
760
|
+
Add a data quality warning to a datasource.
|
|
761
|
+
|
|
762
|
+
The Add Data Quality Warning method adds a data quality warning to an
|
|
763
|
+
asset. (An automatically-generated monitoring warning does not count
|
|
764
|
+
towards this limit.) In Tableau Cloud February 2024 and Tableau Server
|
|
765
|
+
2024.2 and earlier, adding a data quality warning to an asset that
|
|
766
|
+
already has one causes an error.
|
|
767
|
+
|
|
768
|
+
This method is available if your Tableau Cloud site or Tableau Server is licensed with Data Management.
|
|
769
|
+
|
|
770
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_metadata.htm#add_dqw
|
|
771
|
+
|
|
772
|
+
Parameters
|
|
773
|
+
----------
|
|
774
|
+
item: DatasourceItem
|
|
775
|
+
The datasource item to add data quality warnings to.
|
|
776
|
+
|
|
777
|
+
warning: DQWItem
|
|
778
|
+
The data quality warning to add.
|
|
779
|
+
|
|
780
|
+
Returns
|
|
781
|
+
-------
|
|
782
|
+
DQWItem
|
|
783
|
+
The added data quality warning.
|
|
784
|
+
|
|
785
|
+
"""
|
|
380
786
|
return self._data_quality_warnings.add(item, warning)
|
|
381
787
|
|
|
382
788
|
@api(version="3.5")
|
|
383
|
-
def delete_dqw(self, item):
|
|
789
|
+
def delete_dqw(self, item: DatasourceItem) -> None:
|
|
790
|
+
"""
|
|
791
|
+
Delete a data quality warnings from an asset.
|
|
792
|
+
|
|
793
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_metadata.htm#delete_dqws
|
|
794
|
+
|
|
795
|
+
Parameters
|
|
796
|
+
----------
|
|
797
|
+
item: DatasourceItem
|
|
798
|
+
The datasource item to delete data quality warnings from.
|
|
799
|
+
|
|
800
|
+
Returns
|
|
801
|
+
-------
|
|
802
|
+
None
|
|
803
|
+
"""
|
|
384
804
|
self._data_quality_warnings.clear(item)
|
|
385
805
|
|
|
386
806
|
# Populate datasource item's revisions
|
|
387
807
|
@api(version="2.3")
|
|
388
808
|
def populate_revisions(self, datasource_item: DatasourceItem) -> None:
|
|
809
|
+
"""
|
|
810
|
+
Retrieve revision information for the specified datasource item.
|
|
811
|
+
|
|
812
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#get_data_source_revisions
|
|
813
|
+
|
|
814
|
+
Parameters
|
|
815
|
+
----------
|
|
816
|
+
datasource_item : DatasourceItem
|
|
817
|
+
The datasource item to retrieve revisions for.
|
|
818
|
+
|
|
819
|
+
Returns
|
|
820
|
+
-------
|
|
821
|
+
None
|
|
822
|
+
|
|
823
|
+
Raises
|
|
824
|
+
------
|
|
825
|
+
MissingRequiredFieldError
|
|
826
|
+
If the datasource item is missing an ID.
|
|
827
|
+
"""
|
|
389
828
|
if not datasource_item.id:
|
|
390
829
|
error = "Datasource item missing ID. Datasource must be retrieved from server first."
|
|
391
830
|
raise MissingRequiredFieldError(error)
|
|
@@ -413,6 +852,35 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
413
852
|
filepath: Optional[PathOrFileW] = None,
|
|
414
853
|
include_extract: bool = True,
|
|
415
854
|
) -> PathOrFileW:
|
|
855
|
+
"""
|
|
856
|
+
Downloads a specific version of a data source prior to the current one
|
|
857
|
+
in .tdsx format. To download the current version of a data source set
|
|
858
|
+
the revision number to None.
|
|
859
|
+
|
|
860
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#download_data_source_revision
|
|
861
|
+
|
|
862
|
+
Parameters
|
|
863
|
+
----------
|
|
864
|
+
datasource_id : str
|
|
865
|
+
The unique ID of the datasource to download.
|
|
866
|
+
|
|
867
|
+
revision_number : Optional[str]
|
|
868
|
+
The revision number of the data source to download. To determine
|
|
869
|
+
what versions are available, call the `populate_revisions` method.
|
|
870
|
+
Pass None to download the current version.
|
|
871
|
+
|
|
872
|
+
filepath : Optional[PathOrFileW]
|
|
873
|
+
The file path to save the downloaded datasource to. If not
|
|
874
|
+
specified, the file will be saved to the current working directory.
|
|
875
|
+
|
|
876
|
+
include_extract : bool, default True
|
|
877
|
+
If True, the extract is included in the download. If False, the
|
|
878
|
+
extract is not included.
|
|
879
|
+
|
|
880
|
+
Returns
|
|
881
|
+
-------
|
|
882
|
+
filepath : PathOrFileW
|
|
883
|
+
"""
|
|
416
884
|
if not datasource_id:
|
|
417
885
|
error = "Datasource ID undefined."
|
|
418
886
|
raise ValueError(error)
|
|
@@ -446,6 +914,28 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
446
914
|
|
|
447
915
|
@api(version="2.3")
|
|
448
916
|
def delete_revision(self, datasource_id: str, revision_number: str) -> None:
|
|
917
|
+
"""
|
|
918
|
+
Removes a specific version of a data source from the specified site.
|
|
919
|
+
|
|
920
|
+
The content is removed, and the specified revision can no longer be
|
|
921
|
+
downloaded using Download Data Source Revision. If you call Get Data
|
|
922
|
+
Source Revisions, the revision that's been removed is listed with the
|
|
923
|
+
attribute is_deleted=True.
|
|
924
|
+
|
|
925
|
+
REST API:https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#remove_data_source_revision
|
|
926
|
+
|
|
927
|
+
Parameters
|
|
928
|
+
----------
|
|
929
|
+
datasource_id : str
|
|
930
|
+
The unique ID of the datasource to delete.
|
|
931
|
+
|
|
932
|
+
revision_number : str
|
|
933
|
+
The revision number of the data source to delete.
|
|
934
|
+
|
|
935
|
+
Returns
|
|
936
|
+
-------
|
|
937
|
+
None
|
|
938
|
+
"""
|
|
449
939
|
if datasource_id is None or revision_number is None:
|
|
450
940
|
raise ValueError
|
|
451
941
|
url = "/".join([self.baseurl, datasource_id, "revisions", revision_number])
|
|
@@ -458,18 +948,83 @@ class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]
|
|
|
458
948
|
def schedule_extract_refresh(
|
|
459
949
|
self, schedule_id: str, item: DatasourceItem
|
|
460
950
|
) -> list["AddResponse"]: # actually should return a task
|
|
951
|
+
"""
|
|
952
|
+
Adds a task to refresh a data source to an existing server schedule on
|
|
953
|
+
Tableau Server.
|
|
954
|
+
|
|
955
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm#add_data_source_to_schedule
|
|
956
|
+
|
|
957
|
+
Parameters
|
|
958
|
+
----------
|
|
959
|
+
schedule_id : str
|
|
960
|
+
The unique ID of the schedule to add the task to.
|
|
961
|
+
|
|
962
|
+
item : DatasourceItem
|
|
963
|
+
The datasource item to add to the schedule.
|
|
964
|
+
|
|
965
|
+
Returns
|
|
966
|
+
-------
|
|
967
|
+
list[AddResponse]
|
|
968
|
+
"""
|
|
461
969
|
return self.parent_srv.schedules.add_to_schedule(schedule_id, datasource=item)
|
|
462
970
|
|
|
463
971
|
@api(version="1.0")
|
|
464
972
|
def add_tags(self, item: Union[DatasourceItem, str], tags: Union[Iterable[str], str]) -> set[str]:
|
|
973
|
+
"""
|
|
974
|
+
Adds one or more tags to the specified datasource item.
|
|
975
|
+
|
|
976
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#add_tags_to_data_source
|
|
977
|
+
|
|
978
|
+
Parameters
|
|
979
|
+
----------
|
|
980
|
+
item : Union[DatasourceItem, str]
|
|
981
|
+
The datasource item or ID to add tags to.
|
|
982
|
+
|
|
983
|
+
tags : Union[Iterable[str], str]
|
|
984
|
+
The tag or tags to add to the datasource item.
|
|
985
|
+
|
|
986
|
+
Returns
|
|
987
|
+
-------
|
|
988
|
+
set[str]
|
|
989
|
+
The updated set of tags on the datasource item.
|
|
990
|
+
"""
|
|
465
991
|
return super().add_tags(item, tags)
|
|
466
992
|
|
|
467
993
|
@api(version="1.0")
|
|
468
994
|
def delete_tags(self, item: Union[DatasourceItem, str], tags: Union[Iterable[str], str]) -> None:
|
|
995
|
+
"""
|
|
996
|
+
Deletes one or more tags from the specified datasource item.
|
|
997
|
+
|
|
998
|
+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#delete_tag_from_data_source
|
|
999
|
+
|
|
1000
|
+
Parameters
|
|
1001
|
+
----------
|
|
1002
|
+
item : Union[DatasourceItem, str]
|
|
1003
|
+
The datasource item or ID to delete tags from.
|
|
1004
|
+
|
|
1005
|
+
tags : Union[Iterable[str], str]
|
|
1006
|
+
The tag or tags to delete from the datasource item.
|
|
1007
|
+
|
|
1008
|
+
Returns
|
|
1009
|
+
-------
|
|
1010
|
+
None
|
|
1011
|
+
"""
|
|
469
1012
|
return super().delete_tags(item, tags)
|
|
470
1013
|
|
|
471
1014
|
@api(version="1.0")
|
|
472
1015
|
def update_tags(self, item: DatasourceItem) -> None:
|
|
1016
|
+
"""
|
|
1017
|
+
Updates the tags on the server to match the specified datasource item.
|
|
1018
|
+
|
|
1019
|
+
Parameters
|
|
1020
|
+
----------
|
|
1021
|
+
item : DatasourceItem
|
|
1022
|
+
The datasource item to update tags for.
|
|
1023
|
+
|
|
1024
|
+
Returns
|
|
1025
|
+
-------
|
|
1026
|
+
None
|
|
1027
|
+
"""
|
|
473
1028
|
return super().update_tags(item)
|
|
474
1029
|
|
|
475
1030
|
def filter(self, *invalid, page_size: Optional[int] = None, **kwargs) -> QuerySet[DatasourceItem]:
|