Skip to content

Commit f9395cb

Browse files
committed
fix: remove vizHeight and vizWidth from ImageRequestOptions
Closes tableau#1564 Retrieving a view image does not support vizHeight and vizWidth serverside. Supporting it for images as well was a mistake.
1 parent 364f431 commit f9395cb

File tree

1 file changed

+36
-52
lines changed

1 file changed

+36
-52
lines changed

tableauserverclient/server/request_options.py

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -268,46 +268,6 @@ def _append_view_filters(self, params) -> None:
268268
params[name] = value
269269

270270

271-
class _ImagePDFCommonExportOptions(_DataExportOptions):
272-
def __init__(self, maxage=-1, viz_height=None, viz_width=None):
273-
super().__init__(maxage=maxage)
274-
self.viz_height = viz_height
275-
self.viz_width = viz_width
276-
277-
@property
278-
def viz_height(self):
279-
return self._viz_height
280-
281-
@viz_height.setter
282-
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
283-
def viz_height(self, value):
284-
self._viz_height = value
285-
286-
@property
287-
def viz_width(self):
288-
return self._viz_width
289-
290-
@viz_width.setter
291-
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
292-
def viz_width(self, value):
293-
self._viz_width = value
294-
295-
def get_query_params(self) -> dict:
296-
params = super().get_query_params()
297-
298-
# XOR. Either both are None or both are not None.
299-
if (self.viz_height is None) ^ (self.viz_width is None):
300-
raise ValueError("viz_height and viz_width must be specified together")
301-
302-
if self.viz_height is not None:
303-
params["vizHeight"] = self.viz_height
304-
305-
if self.viz_width is not None:
306-
params["vizWidth"] = self.viz_width
307-
308-
return params
309-
310-
311271
class CSVRequestOptions(_DataExportOptions):
312272
"""
313273
Options that can be used when exporting a view to CSV. Set the maxage to control the age of the data exported.
@@ -338,7 +298,7 @@ class ExcelRequestOptions(_DataExportOptions):
338298
extension = "xlsx"
339299

340300

341-
class ImageRequestOptions(_ImagePDFCommonExportOptions):
301+
class ImageRequestOptions(_DataExportOptions):
342302
"""
343303
Options that can be used when exporting a view to an image. Set the maxage to control the age of the data exported.
344304
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -354,13 +314,6 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
354314
maxage: int, optional
355315
The maximum age of the data to export. Shortest possible duration is 1
356316
minute. No upper limit. Default is -1, which means no limit.
357-
358-
viz_height: int, optional
359-
The height of the viz in pixels. If specified, viz_width must also be specified.
360-
361-
viz_width: int, optional
362-
The width of the viz in pixels. If specified, viz_height must also be specified.
363-
364317
"""
365318

366319
extension = "png"
@@ -369,8 +322,8 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
369322
class Resolution:
370323
High = "high"
371324

372-
def __init__(self, imageresolution=None, maxage=-1, viz_height=None, viz_width=None):
373-
super().__init__(maxage=maxage, viz_height=viz_height, viz_width=viz_width)
325+
def __init__(self, imageresolution=None, maxage=-1):
326+
super().__init__(maxage=maxage,)
374327
self.image_resolution = imageresolution
375328

376329
def get_query_params(self):
@@ -380,7 +333,7 @@ def get_query_params(self):
380333
return params
381334

382335

383-
class PDFRequestOptions(_ImagePDFCommonExportOptions):
336+
class PDFRequestOptions(_DataExportOptions):
384337
"""
385338
Options that can be used when exporting a view to PDF. Set the maxage to control the age of the data exported.
386339
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -425,12 +378,43 @@ class Orientation:
425378
Landscape = "landscape"
426379

427380
def __init__(self, page_type=None, orientation=None, maxage=-1, viz_height=None, viz_width=None):
428-
super().__init__(maxage=maxage, viz_height=viz_height, viz_width=viz_width)
381+
super().__init__(maxage=maxage,)
429382
self.page_type = page_type
430383
self.orientation = orientation
384+
self.viz_height = viz_height
385+
self.viz_width = viz_width
386+
387+
@property
388+
def viz_height(self):
389+
return self._viz_height
390+
391+
@viz_height.setter
392+
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
393+
def viz_height(self, value):
394+
self._viz_height = value
395+
396+
@property
397+
def viz_width(self):
398+
return self._viz_width
399+
400+
@viz_width.setter
401+
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
402+
def viz_width(self, value):
403+
self._viz_width = value
431404

432405
def get_query_params(self) -> dict:
433406
params = super().get_query_params()
407+
408+
# XOR. Either both are None or both are not None.
409+
if (self.viz_height is None) ^ (self.viz_width is None):
410+
raise ValueError("viz_height and viz_width must be specified together")
411+
412+
if self.viz_height is not None:
413+
params["vizHeight"] = self.viz_height
414+
415+
if self.viz_width is not None:
416+
params["vizWidth"] = self.viz_width
417+
434418
if self.page_type:
435419
params["type"] = self.page_type
436420

0 commit comments

Comments
 (0)