8000 refactor request_options, add language param (#1481) · TrimPeachu/server-client-python@89e1ddf · GitHub
[go: up one dir, main page]

Skip to content

Commit 89e1ddf

Browse files
authored
refactor request_options, add language param (tableau#1481)
* refactor request_options, add language param I have refactored the classes to separate options that can be used in querying content, and options that can be used for exporting data. "language" is only available for data exporting.
1 parent f8728b2 commit 89e1ddf

File tree

5 files changed

+129
-144
lines changed

5 files changed

+129
-144
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
4343
check_untyped_defs = false
4444
disable_error_code = [
4545
'misc',
46-
# tableauserverclient\server\endpoint\datasources_endpoint.py:48: error: Cannot assign multiple types to name "FilePath" without an explicit "Type[...]" annotation [misc]
4746
'annotation-unchecked' # can be removed when check_untyped_defs = true
4847
]
4948
files = ["tableauserverclient", "test", "samples"]
5049
show_error_codes = true
5150
ignore_missing_imports = true # defusedxml library has no types
5251
no_implicit_reexport = true
52+
implicit_optional = true
5353

5454
[tool.pytest.ini_options]
5555
testpaths = ["test"]

samples/export.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def main():
3737
"--csv", dest="type", action="store_const", const=("populate_csv", "CSVRequestOptions", "csv", "csv")
3838
)
3939
# other options shown in explore_workbooks: workbook.download, workbook.preview_image
40-
40+
parser.add_argument(
41+
"--language", help="Text such as 'Average' will appear in this language. Use values like fr, de, es, en"
42+
)
4143
parser.add_argument("--workbook", action="store_true")
4244

4345
parser.add_argument("--file", "-f", help="filename to store the exported data")
@@ -74,16 +76,18 @@ def main():
7476
populate = getattr(server.workbooks, populate_func_name)
7577

7678
option_factory = getattr(TSC, option_factory_name)
79+
options: TSC.PDFRequestOptions = option_factory()
7780

7881
if args.filter:
79-
options = option_factory().vf(*args.filter.split(":"))
80-
else:
81-
options = None
82+
options = options.vf(*args.filter.split(":"))
83+
84+
if args.language:
85+
options.language = args.language
8286

8387
if args.file:
8488
filename = args.file
8589
else:
86-
filename = f"out.{extension}"
90+
filename = f"out-{options.language}.{extension}"
8791

8892
populate(item, options)
8993
with open(filename, "wb") as f:

tableauserverclient/__init__.py

Lines changed: 26 additions & 22 deletions
685C
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232
PermissionsRule,
3333
PersonalAccessTokenAuth,
3434
ProjectItem,
35+
Resource,
3536
RevisionItem,
3637
ScheduleItem,
3738
SiteItem,
3839
ServerInfoItem,
3940
SubscriptionItem,
41+
TableauItem,
4042
TableItem,
4143
TableauAuth,
4244
Target,
@@ -66,66 +68,68 @@
6668
)
6769

6870
__all__ = [
69-
"get_versions",
70-
"DEFAULT_NAMESPACE",
7171
"BackgroundJobItem",
7272
"BackgroundJobItem",
7373
"ColumnItem",
7474
"ConnectionCredentials",
7575
"ConnectionItem",
76+
"CSVRequestOptions",
7677
"CustomViewItem",
77-
"DQWItem",
7878
"DailyInterval",
7979
"DataAlertItem",
8080
"DatabaseItem",
8181
"DataFreshnessPolicyItem",
8282
"DatasourceItem",
83+
"DEFAULT_NAMESPACE",
84+
"DQWItem",
85+
"ExcelRequestOptions",
8386
"FailedSignInError",
8487
"FavoriteItem",
88+
"FileuploadItem",
89+
"Filter",
8590
"FlowItem",
8691
"FlowRunItem",
87-
"FileuploadItem",
92+
"get_versions",
8893
"GroupItem",
8994
"GroupSetItem",
9095
"HourlyInterval",
96+
"ImageRequestOptions",
9197
"IntervalItem",
9298
"JobItem",
9399
"JWTAuth",
100+
"LinkedTaskFlowRunItem",
101+
"LinkedTaskItem",
102+
"LinkedTaskStepItem",
94103
"MetricItem",
104+
"MissingRequiredFieldError",
95105
"MonthlyInterval",
106+
"NotSignedInError",
107+
"Pager",
96108
"PaginationItem",
109+
"PDFRequestOptions",
97110
"Permission",
98111
"PermissionsRule",
99112
"PersonalAccessTokenAuth",
100113
"ProjectItem",
114+
"RequestOptions",
115+
"Resource",
101116
"RevisionItem",
102117
"ScheduleItem",
103-
"SiteItem",
118+
"Server",
104119
"ServerInfoItem",
120+
"ServerResponseError",
121+
"SiteItem",
122+
"Sort",
105123
"SubscriptionItem",
106-
"TableItem",
107124
"TableauAuth",
125+
"TableauItem",
126+
"TableItem",
108127
"Target",
109128
"TaskItem",
110129
"UserItem",
111130
"ViewItem",
131+
"VirtualConnectionItem",
112132
"WebhookItem",
113133
"WeeklyInterval",
114134
"WorkbookItem",
115-
"CSVRequestOptions",
116-
"ExcelRequestOptions",
117-
"ImageRequestOptions",
118-
"PDFRequestOptions",
119-
"RequestOptions",
120-
"MissingRequiredFieldError",
121-
"NotSignedInError",
122-
"ServerResponseError",
123-
"Filter",
124-
"Pager",
125-
"Server",
126-
"Sort",
127-
"LinkedTaskItem",
128-
"LinkedTaskStepItem",
129-
"LinkedTaskFlowRunItem",
130-
"VirtualConnectionItem",
131135
]

0 commit comments

Comments
 (0)
0