Skip to content

Commit 8f65568

Browse files
jorwoodsclaude
andcommitted
docs: add custom_views.download, publish, filter to api-ref.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f4a1003 commit 8f65568

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

docs/api-ref.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,115 @@ See [CustomViewItem class](#customviewitem-class)
652652
<br>
653653
<br>
654654

655+
#### custom_views.download
656+
657+
```py
658+
custom_views.download(view_item, file)
659+
```
660+
661+
Downloads the definition of a custom view as JSON to a file path or file object. The downloaded file may contain sensitive information.
662+
663+
**Version**
664+
665+
This endpoint is available with REST API version 3.21 and up.
666+
667+
**Parameters**
668+
669+
| Name | Description |
670+
| :---------- | :----------------------------------------------------------------------------------- |
671+
| `view_item` | The `CustomViewItem` to download. |
672+
| `file` | The file path (`str` or `Path`) or writable file object to write the definition to. |
673+
674+
**Returns**
675+
676+
Returns the file path or file object that the custom view definition was written to.
677+
678+
**Example**
679+
680+
```py
681+
custom_view = server.custom_views.get_by_id('d79634e1-6063-4ec9-95ff-50acbf609ff5')
682+
server.custom_views.download(custom_view, './my_custom_view.json')
683+
```
684+
685+
See [CustomViewItem class](#customviewitem-class)
686+
687+
<br>
688+
<br>
689+
690+
#### custom_views.publish
691+
692+
```py
693+
custom_views.publish(view_item, file)
694+
```
695+
696+
Publishes a custom view to Tableau Server from a JSON definition file previously downloaded with `custom_views.download`.
697+
698+
**Version**
699+
700+
This endpoint is available with REST API version 3.21 and up.
701+
702+
**Parameters**
703+
704+
| Name | Description |
705+
| :---------- | :------------------------------------------------------------------------------------ |
706+
| `view_item` | The `CustomViewItem` describing the custom view to publish. Must have a `name` set. |
707+
| `file` | The file path (`str` or `Path`) or readable file object containing the definition. |
708+
709+
**Exceptions**
710+
711+
| Error | Description |
712+
| :--------------------------- | :---------------------------------------------------------------------- |
713+
| `ValueError` | Raised if `file` is not a valid file path or file object. |
714+
| `MissingRequiredFieldError` | Raised if `view_item.name` is not set when passing a file object. |
715+
716+
**Returns**
717+
718+
Returns the published `CustomViewItem`, or `None`.
719+
720+
**Example**
721+
722+
```py
723+
new_view = TSC.CustomViewItem(name='My Custom View')
724+
published = server.custom_views.publish(new_view, './my_custom_view.json')
725+
print(published.id)
726+
```
727+
728+
See [CustomViewItem class](#customviewitem-class)
729+
730+
<br>
731+
<br>
732+
733+
#### custom_views.filter
734+
735+
```py
736+
custom_views.filter(**kwargs)
737+
```
738+
739+
Returns a list of custom views that match the specified filters. Fields and operators are passed as keyword arguments in the form `field_name=value`.
740+
741+
**Supported fields and operators**
742+
743+
Field | Operators
744+
:--- | :---
745+
`owner_id` | `eq`
746+
`view_id` | `eq`
747+
`workbook_id` | `eq`
748+
749+
**Returns**
750+
751+
Returns a `QuerySet` of `CustomViewItem` objects.
752+
753+
**Example**
754+
755+
```py
756+
my_views = server.custom_views.filter(owner_id=user_item.id)
757+
for view in my_views:
758+
print(view.name)
759+
```
760+
761+
<br>
762+
<br>
763+
655764
---
656765

657766
## Data Sources

0 commit comments

Comments
 (0)