@@ -35,6 +35,28 @@ def apply_query_params(self, url):
35
35
36
36
37
37
class RequestOptions (RequestOptionsBase ):
38
+ """
39
+ This class is used to manage the options that can be used when querying content on the server.
40
+ Optionally initialize with a page number and page size to control the number of items returned.
41
+
42
+ Additionally, you can add sorting and filtering options to the request.
43
+
44
+ The `sort` and `filter` options are set-like objects, so you can only add a field once. If you add the same field
45
+ multiple times, only the last one will be used.
46
+
47
+ The list of fields that can be sorted on or filtered by can be found in the `Field`
48
+ class contained within this class.
49
+
50
+ Parameters
51
+ ----------
<
8000
/code>
52
+ pagenumber: int, optional
53
+ The page number to start the query on. Default is 1.
54
+
55
+ pagesize: int, optional
56
+ The number of items to return per page. Default is 100. Can also read
57
+ from the environment variable `TSC_PAGE_SIZE`
58
+ """
59
+
38
60
def __init__ (self , pagenumber = 1 , pagesize = None ):
39
61
self .pagenumber = pagenumber
40
62
self .pagesize = pagesize or config .PAGE_SIZE
@@ -199,13 +221,43 @@ def get_query_params(self):
199
221
200
222
def vf (self , name : str , value : str ) -> Self :
201
223
"""Apply a filter based on a column within the view.
202
- Note that when filtering on a boolean type field, the only valid values are 'true' and 'false'"""
224
+ Note that when filtering on a boolean type field, the only valid values are 'true' and 'false'
225
+
226
+ For more detail see: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm#Filter-query-views
227
+
228
+ Parameters
229
+ ----------
230
+ name: str
231
+ The name of the column to filter on
232
+
233
+ value: str
234
+ The value to filter on
235
+
236
+ Returns
237
+ -------
238
+ Self
239
+ The current object
240
+ """
203
241
self .view_filters .append ((name , value ))
204
242
return self
205
243
206
244
def parameter (self , name : str , value : str ) -> Self :
207
245
"""Apply a filter based on a parameter within the workbook.
208
- Note that when filtering on a boolean type field, the only valid values are 'true' and 'false'"""
246
+ Note that when filtering on a boolean type field, the only valid values are 'true' and 'false'
247
+
248
+ Parameters
249
+ ----------
250
+ name: str
251
+ The name of the parameter to filter on
252
+
253
+ value: str
254
+ The value to filter on
255
+
256
+ Returns
257
+ -------
258
+ Self
259
+ The current object
260
+ """
209
261
self .view_parameters .append ((name , value ))
210
262
return self
211
263
@@ -257,14 +309,60 @@ def get_query_params(self) -> dict:
257
309
258
310
259
311
class CSVRequestOptions (_DataExportOptions ):
312
+ """
313
+ Options that can be used when exporting a view to CSV. Set the maxage to control the age of the data exported.
314
+ Filters to the underlying data can be applied using the `vf` and `parameter` methods.
315
+
316
+ Parameters
317
+ ----------
318
+ maxage: int, optional
319
+ The maximum age of the data to export. Shortest possible duration is 1
320
+ minute. No upper limit. Default is -1, which means no limit.
321
+ """
322
+
260
323
extension = "csv"
261
324
262
325
263
326
class ExcelRequestOptions (_DataExportOptions ):
327
+ """
328
+ Options that can be used when exporting a view to Excel. Set the maxage to control the age of the data exported.
329
+ Filters to the underlying data can be applied using the `vf` and `parameter` methods.
330
+
331
+ Parameters
332
+ ----------
333
+ maxage: int, optional
334
+ The maximum age of the data to export. Shortest possible duration is 1
335
+ minute. No upper limit. Default is -1, which means no limit.
336
+ """
337
+
264
338
extension = "xlsx"
265
339
266
340
267
341
class ImageRequestOptions (_ImagePDFCommonExportOptions ):
342
+ """
343
+ Options that can be used when exporting a view to an image. Set the maxage to control the age of the data exported.
344
+ Filters to the underlying data can be applied using the `vf` and `parameter` methods.
345
+
346
+ Parameters
347
+ ----------
348
+ imageresolution: str, optional
349
+ The resolution of the image to export. Valid values are "high" or None. Default is None.
350
+ Image width and actual pixel density are determined by the display context
351
+ of the image. Aspect ratio is always preserved. Set the value to "high" to
352
+ ensure maximum pixel density.
353
+
354
+ maxage: int, optional
355
+ The maximum age of the data to export. Shortest possible duration is 1
356
+ 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
+
364
+ """
365
+
268
366
extension = "png"
269
367
270
368
# if 'high' isn't specified, the REST API endpoint returns an image with standard resolution
@@ -283,6 +381,29 @@ def get_query_params(self):
283
381
284
382
285
383
class PDFRequestOptions (_ImagePDFCommonExportOptions ):
384
+ """
385
+ Options that can be used when exporting a view to PDF. Set the maxage to control the age of the data exported.
386
+ Filters to the underlying data can be applied using the `vf` and `parameter` methods.
387
+
388
+ Parameters
389
+ ----------
390
+ page_type: str, optional
391
+ The page type of the PDF to export. Valid values are accessible via the `PageType` class.
392
+
393
+ orientation: str, optional
394
+ The orientation of the PDF to export. Valid values are accessible via the `Orientation` class.
395
+
396
+ maxage: int, optional
397
+ The maximum age of the data to export. Shortest possible duration is 1
398
+ minute. No upper limit. Default is -1, which means no limit.
399
+
400
+ viz_height: int, optional
401
+ The height of the viz in pixels. If specified, viz_width must also be specified.
402
+
403
+ viz_width: int, optional
404
+ The width of the viz in pixels. If specified, viz_height must also be specified.
405
+ """
406
+
286
407
class PageType :
287
408
A3 = "a3"
288
409
A4 = "a4"
0 commit comments