8000 added info about view filters · SnarkyPapi/server-client-python@756bef6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 756bef6

Browse files
author
Chris Shin
committed
added info about view filters
1 parent 6aec8ba commit 756bef6

File tree

1 file changed

+80
-7
lines changed

1 file changed

+80
-7
lines changed

docs/api-ref.md

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,23 +1540,48 @@ Name | Description
15401540
`Asc` | Sets the sort direction to ascending (`TSC.RequestOptions.Direction.Asc`)
15411541
`Desc` | Sets the sort direction to descending (`TSC.RequestOptions.Direction.Desc`).
15421542

1543+
<br>
1544+
<br>
1545+
1546+
### CSVRequestOptions class
1547+
1548+
```py
1549+
CSVRequestOptions()
1550+
```
1551+
Use this class to specify view filters to be applied when the CSV data is generated. See `views.populate_csv`.
1552+
1553+
**Example**
1554+
1555+
```py
1556+
# import tableauserverclient as TSC
1557+
# server = TSC.Server('http://MY-SERVER')
1558+
# sign in, get a specific view, etc.
15431559

1560+
# set view filters
1561+
csv_req_option = TSC.CSVRequestOptions()
1562+
csv_req_option.vf('Region', 'South')
1563+
csv_req_option.vf('Category', 'Furniture')
1564+
1565+
# retrieve the csv data for the view
1566+
server.views.populate_csv(view_item, csv_req_option)
1567+
```
15441568

15451569
### ImageRequestOptions class
15461570

15471571
```py
15481572
ImageRequestOptions(imageresolution=None)
1549-
15501573
```
1551-
Use this class to specify the resolution of the view returned as an image. See `views.populate_view`.
1574+
Use this class to specify the resolution of the view returned as an image. You can also use this class to specify view filters to be applied when the image is generated. See `views.populate_image`.
15521575

15531576
**Attributes**
15541577

15551578
Name | Description
15561579
:--- | :---
1557-
`imageresolution` | The resolution of the view returned as an image. You set this option with the `Resolution` class. If unspecified, the `views.populate_view` method returns an image with standard resolution (the width of the returned image is 784 pixels). If you set this parameter value to high (`Resolution.High`), the width of the returned image is 1568 pixels. For both resolutions, the height varies to preserve the aspect ratio of the view.
1580+
`imageresolution` | The resolution of the view returned as an image. You set this option with the `Resolution` class. If unspecified, the `views.populate_image` method returns an image with standard resolution (the width of the returned image is 784 pixels). If you set this parameter value to high (`Resolution.High`), the width of the returned image is 1568 pixels. For both resolutions, the height varies to preserve the aspect ratio of the view.
15581581

1582+
**View Filters**
15591583

1584+
You can use the `vf('filter_name', 'filter_value')` method to add view filters. When the image is generated, the specified filters will be applied to the view.
15601585

15611586
**Example**
15621587

@@ -1568,6 +1593,9 @@ Name | Description
15681593
# set the image request option
15691594
image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High)
15701595

1596+
# (optional) set a view filter
1597+
image_req_option.vf('Category', 'Furniture')
1598+
15711599
# retrieve the image for the view
15721600
server.views.populate_image(view_item, image_req_option)
15731601

@@ -1577,7 +1605,6 @@ server.views.populate_image(view_item, image_req_option)
15771605

15781606
```py
15791607
PDFRequestOptions(page_type=None, orientation=None)
1580-
15811608
```
15821609
Use this class to specify the format of the PDF that is returned for the view. See `views.populate_pdf`.
15831610

@@ -1588,6 +1615,8 @@ Name | Description
15881615
`page_type` | The type of page returned in PDF format for the view. The page_type is set using the `PageType` class: <br> `PageType.A3`<br> `PageType.A4`<br> `PageType.A5`<br> `PageType.B5`<br> `PageType.Executive`<br> `PageType.Folio`<br> `PageType.Ledger`<br> `PageType.Legal`<br> `PageType.Letter`<br> `PageType.Note`<br> `PageType.Quarto`<br> `PageType.Tabloid`
15891616
`orientation` | The orientation of the page. The options are portrait and landscape. The options are set using the `Orientation` class: <br>`Orientation.Portrait`<br> `Orientation.Landscape`
15901617

1618+
**View Filters**
1619+
You can use the `vf('filter_name', 'filter_value')` method to add view filters. When the PDF is generated, the specified filters will be applied to the view.
15911620

15921621
**Example**
15931622

@@ -1599,6 +1628,9 @@ Name | Description
15991628
# set the PDF request options
16001629
pdf_req_option = TSC.PDFRequestOptions(page_type=TSC.PDFRequestOptions.PageType.A4, orientation=TSC.PDFRequestOptions.Orientation.Landscape)
16011630

1631+
# (optional) set a view filter
1632+
pdf_req_option.vf('Region', 'West')
1633+
16021634
# retrieve the PDF for a view
16031635
server.views.populate_pdf(view_item, pdf_req_option)
16041636

@@ -3138,11 +3170,20 @@ Error | Description
31383170
`View item missing ID or workbook ID` | Raises an error if the ID of the view or workbook is missing.
31393171

31403172

3141-
31423173
**Returns**
31433174

31443175
None. The preview image is added to `view_item` and can be accessed by its `preview_image` field.
31453176

3177+
**Example**
3178+
```py
3179+
# Sign in, get view, etc.
3180+
3181+
# Populate and save the preview image as 'view_preview_image.png'
3182+
server.views.populate_preview_image(view_item)
3183+
with open('./view_preview_image.png', 'wb') as f:
3184+
f.write(view_item.preview_image)
3185+
```
3186+
31463187
See [ViewItem class](#viewitem-class)
31473188

31483189
<br>
@@ -3169,7 +3210,7 @@ This endpoint is available with REST API version 2.5 and up.
31693210
Name | description
31703211
:--- | :---
31713212
`view_item` | Specifies the view to populate.
3172-
`req_options` | (Optional) You can pass in a request object to specify a high resolution image. By default, the image will be in low resolution. See [ImageRequestOptions class](#imagerequestoptions-class) for more details.
3213+
`req_options` | (Optional) You can pass in a request object to specify a high resolution image. By default, the image will be in low resolution. You can also specify view filters to be applied when the image is generated. See [ImageRequestOptions class](#imagerequestoptions-class) for more details.
31733214

31743215
**Exceptions**
31753216

@@ -3181,6 +3222,16 @@ Error | Description
31813222

31823223
None. The image is added to the `view_item` and can be accessed by its `image` field.
31833224

3225+
**Example**
3226+
```py
3227+
# Sign in, get view, etc.
3228+
3229+
# Populate and save the view image as 'view_image.png'
3230+
server.views.populate_image(view_item)
3231+
with open('./view_image.png', 'wb') as f:
3232+
f.write(view_item.image)
3233+
```
3234+
31843235
See [ViewItem class](#viewitem-class)
31853236

31863237
<br>
@@ -3206,6 +3257,7 @@ This endpoint is available with REST API version 2.7 and up.
32063257
Name | description
32073258
:--- | :---
32083259
`view_item` | Specifies the view to populate.
3260+
`req_options` | (Optional) You can pass in a request object to specify view filters to be applied when the CSV data is generated. See [CSVRequestOptions class](#csvrequestoptions-class) for more details.
32093261

32103262
**Exceptions**
32113263

@@ -3217,6 +3269,17 @@ Error | Description
32173269

32183270
None. The CSV data is added to the `view_item` and can be accessed by its `csv` field.
32193271

3272+
**Example**
3273+
```py
3274+
# Sign in, get view, etc.
3275+
3276+
# Populate and save the CSV data as 'view_csv.csv'
3277+
server.views.populate_csv(view_item)
3278+
with open('./view_csv.csv', 'wb') as f:
3279+
# Perform byte join on the CSV data
3280+
f.write(b''.join(view_item.csv))
3281+
```
3282+
32203283
See [ViewItem class](#viewitem-class)
32213284

32223285
<br>
@@ -3242,7 +3305,7 @@ This endpoint is available with REST API version 2.7 and up.
32423305
Name | description
32433306
:--- | :---
32443307
`view_item` | Specifies the view to populate.
3245-
AFED `req_options` | (Optional) You can pass in a request object to specify the page type and orientation of the PDF content. If not specified, PDF content will have default page type and orientation. See [PDFRequestOptions class](#pdfrequestoptions-class) for more details.
3308+
`req_options` | (Optional) You can pass in a request object to specify the page type and orientation of the PDF content. If not specified, PDF content will have default page type and orientation. You can also specify view filters to be applied when the PDF is generated. See [PDFRequestOptions class](#pdfrequestoptions-class) for more details.
32463309

32473310
**Exceptions**
32483311

@@ -3254,6 +3317,16 @@ Error | Description
32543317

32553318
None. The PDF content is added to the `view_item` and can be accessed by its `pdf` field.
32563319

3320+
**Example**
3321+
```py
3322+
# Sign in, get view, etc.
3323+
3324+
# Populate and save the view pdf as 'view_pdf.pdf'
3325+
server.views.populate_pdf(view_item)
3326+
with open('./view_pdf.pdf', 'wb') as f:
3327+
f.write(view_item.pdf)
3328+
```
3329+
32573330
See [ViewItem class](#viewitem-class)
32583331

32593332
<br>

0 commit comments

Comments
 (0)
0