Skip to content

Commit 9d02f68

Browse files
jorwoodsclaude
andauthored
docs: document views endpoint (#1756)
* docs: add missing Views methods to api-ref.md Adds documentation for methods not previously documented: - populate_excel (API 3.8) - update - populate_permissions / update_permissions / delete_permission (API 3.2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add views.add_tags, delete_tags, update_tags, delete, filter to api-ref.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f1bc11a commit 9d02f68

1 file changed

Lines changed: 310 additions & 0 deletions

File tree

docs/api-ref.md

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5701,6 +5701,316 @@ See [ViewItem class](#viewitem-class)
57015701
<br>
57025702
<br>
57035703

5704+
#### views.populate_excel
5705+
5706+
```py
5707+
views.populate_excel(view_item, req_options=None)
5708+
```
5709+
5710+
Populates the Excel content of the specified view.
5711+
5712+
After calling this method, the Excel data is available through the view's `excel` property.
5713+
5714+
REST API: [Download View Excel](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#download_view_excel){:target="_blank"}
5715+
5716+
**Parameters**
5717+
5718+
Name | Description
5719+
:--- | :---
5720+
`view_item` | The `ViewItem` to populate with Excel data.
5721+
`req_options` | (Optional) You can pass in request options to filter data or set the maximum age of the Excel content cached on the server. See [ExcelRequestOptions class](#excelrequestoptions-class) for more details.
5722+
5723+
**Returns**
5724+
5725+
None. The Excel content is added to the `view_item` and can be accessed by its `excel` field.
5726+
5727+
**Version**
5728+
5729+
Version 3.8 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
5730+
5731+
**Example**
5732+
5733+
```py
5734+
server.views.populate_excel(view_item)
5735+
with open('./view_data.xlsx', 'wb') as f:
5736+
f.write(view_item.excel)
5737+
```
5738+
5739+
<br>
5740+
<br>
5741+
5742+
#### views.update
5743+
5744+
```py
5745+
views.update(view_item)
5746+
```
5747+
5748+
Modifies the specified view. Use this method to change the owner of a view or update its settings.
5749+
5750+
**Parameters**
5751+
5752+
Name | Description
5753+
:--- | :---
5754+
`view_item` | The `ViewItem` with updated attributes.
5755+
5756+
**Returns**
5757+
5758+
Returns the updated `ViewItem`.
5759+
5760+
**Example**
5761+
5762+
```py
5763+
view = server.views.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
5764+
view.owner_id = 'new-owner-id'
5765+
updated_view = server.views.update(view)
5766+
```
5767+
5768+
<br>
5769+
<br>
5770+
5771+
#### views.populate_permissions
5772+
5773+
```py
5774+
views.populate_permissions(view_item)
5775+
```
5776+
5777+
Populates the permissions for the specified view.
5778+
5779+
**Parameters**
5780+
5781+
Name | Description
5782+
:--- | :---
5783+
`view_item` | The `ViewItem` to populate with permissions.
5784+
5785+
**Version**
5786+
5787+
Version 3.2 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
5788+
5789+
**Example**
5790+
5791+
```py
5792+
view = server.views.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
5793+
server.views.populate_permissions(view)
5794+
for permission in view.permissions:
5795+
print(permission.grantee_id, permission.capabilities)
5796+
```
5797+
5798+
<br>
5799+
<br>
5800+
5801+
#### views.update_permissions
5802+
5803+
```py
5804+
views.update_permissions(view_item, permission_item)
5805+
```
5806+
5807+
Adds or updates permissions for the specified view.
5808+
5809+
**Parameters**
5810+
5811+
Name | Description
5812+
:--- | :---
5813+
`view_item` | The `ViewItem` to update permissions for.
5814+
`permission_item` | A list of `PermissionsRule` objects representing the permissions to add or update.
5815+
5816+
**Version**
5817+
5818+
Version 3.2 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
5819+
5820+
<br>
5821+
<br>
5822+
5823+
#### views.delete_permission
5824+
5825+
```py
5826+
views.delete_permission(view_item, capability_item)
5827+
```
5828+
5829+
Removes a permission from the specified view.
5830+
5831+
**Parameters**
5832+
5833+
Name | Description
5834+
:--- | :---
5835+
`view_item` | The `ViewItem` to remove the permission from.
5836+
`capability_item` | The `PermissionsRule` object representing the permission to remove.
5837+
5838+
**Version**
5839+
5840+
Version 3.2 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
5841+
5842+
<br>
5843+
<br>
5844+
5845+
#### views.add_tags
5846+
5847+
```py
5848+
views.add_tags(item, tags)
5849+
```
5850+
5851+
Adds one or more tags to the specified view.
5852+
5853+
REST API: [Add Tags to View](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#add_tags_to_view)
5854+
5855+
**Parameters**
5856+
5857+
Name | Description
5858+
:--- | :---
5859+
`item` | The `ViewItem` or view ID to add tags to.
5860+
`tags` | A single tag string or iterable of tag strings to add.
5861+
5862+
**Returns**
5863+
5864+
Returns a `set[str]` of the tags added.
5865+
5866+
**Example**
5867+
5868+
```py
5869+
server.views.add_tags(view_item, ['finance', 'quarterly'])
5870+
```
5871+
5872+
<br>
5873+
<br>
5874+
5875+
#### views.delete_tags
5876+
5877+
```py
5878+
views.delete_tags(item, tags)
5879+
```
5880+
5881+
Removes one or more tags from the specified view.
5882+
5883+
REST API: [Delete Tags from View](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#delete_tags_from_view)
5884+
5885+
**Parameters**
5886+
5887+
Name | Description
5888+
:--- | :---
5889+
`item` | The `ViewItem` or view ID to remove tags from.
5890+
`tags` | A single tag string or iterable of tag strings to remove.
5891+
5892+
**Returns**
5893+
5894+
None.
5895+
5896+
**Example**
5897+
5898+
```py
5899+
server.views.delete_tags(view_item, 'finance')
5900+
```
5901+
5902+
<br>
5903+
<br>
5904+
5905+
#### views.update_tags
5906+
5907+
```py
5908+
views.update_tags(item)
5909+
```
5910+
5911+
Updates the tags on the server to match the tags on the specified view item. Changes to tags must be made on the `ViewItem.tags` attribute before calling this method.
5912+
5913+
REST API: [Add Tags to View](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#add_tags_to_view)
5914+
5915+
**Parameters**
5916+
5917+
Name | Description
5918+
:--- | :---
5919+
`item` | The `ViewItem` whose tags to synchronize to the server.
5920+
5921+
**Returns**
5922+
5923+
None.
5924+
5925+
**Example**
5926+
5927+
```py
5928+
view_item.tags.add('quarterly')
5929+
server.views.update_tags(view_item)
5930+
```
5931+
5932+
<br>
5933+
<br>
5934+
5935+
#### views.delete
5936+
5937+
```py
5938+
views.delete(view)
5939+
```
5940+
5941+
Deletes a view. If you delete the only view in a workbook, the workbook is also deleted. This can be used to remove hidden views when migrating content.
5942+
5943+
REST API: [Delete View](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#delete_view)
5944+
5945+
**Version**
5946+
5947+
This endpoint is available with REST API version 3.27 and up.
5948+
5949+
**Parameters**
5950+
5951+
Name | Description
5952+
:--- | :---
5953+
`view` | The `ViewItem` or view ID (str) to delete.
5954+
5955+
**Returns**
5956+
5957+
None.
5958+
5959+
**Example**
5960+
5961+
```py
5962+
server.views.delete(view_item.id)
5963+
```
5964+
5965+
<br>
5966+
<br>
5967+
5968+
#### views.filter
5969+
5970+
```py
5971+
views.filter(**kwargs)
5972+
```
5973+
5974+
Returns a list of views that match the specified filters. Fields and operators are passed as keyword arguments in the form `field_name=value` or `field_name__operator=value`.
5975+
5976+
**Supported fields and operators**
5977+
5978+
Field | Operators
5979+
:--- | :---
5980+
`caption` | `eq`, `in`
5981+
`content_url` | `eq`, `in`
5982+
`created_at` | `eq`, `gt`, `gte`, `lt`, `lte`
5983+
`favorites_total` | `eq`, `gt`, `gte`, `lt`, `lte`
5984+
`fields` | `eq`, `in`
5985+
`hits_total` | `eq`, `gt`, `gte`, `lt`, `lte`
5986+
`name` | `eq`, `in`
5987+
`owner_domain` | `eq`, `in`
5988+
`owner_email` | `eq`, `in`
5989+
`owner_name` | `eq`
5990+
`project_name` | `eq`, `in`
5991+
`sheet_number` | `eq`, `gt`, `gte`, `lt`, `lte`
5992+
`sheet_type` | `eq`, `in`
5993+
`tags` | `eq`, `in`
5994+
`title` | `eq`, `in`
5995+
`updated_at` | `eq`, `gt`, `gte`, `lt`, `lte`
5996+
`view_url_name` | `eq`, `in`
5997+
`workbook_description` | `eq`, `in`
5998+
`workbook_name` | `eq`, `in`
5999+
6000+
**Returns**
6001+
6002+
Returns a `QuerySet` of `ViewItem` objects.
6003+
6004+
**Example**
6005+
6006+
```py
6007+
matching_views = server.views.filter(project_name='Finance', sheet_type='story')
6008+
for view in matching_views:
6009+
print(view.name)
6010+
```
6011+
6012+
<br>
6013+
<br>
57046014

57056015
---
57066016
## Webhooks

0 commit comments

Comments
 (0)