Skip to content

Commit cf707f0

Browse files
jacalataclaude
andauthored
Fix the populate_excel example and the user domain_name docs (#1911)
* Fix the populate_excel example and the user domain_name docs view_item.excel is a generator, so join its chunks before writing. domain_name is read-only and its meaning differs between Tableau Server and Tableau Cloud; the bulk_add example now uses the domain-qualified name instead of setting it. Co-Authored-By: Claude Code <noreply@anthropic.com> * Note where the domain ends up for users created from a CSV file Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent 60f7165 commit cf707f0

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎docs/api-ref.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8088,7 +8088,7 @@ The `UserItem` class contains the members or attributes for the view resources o
80888088
Name | Description
80898089
:--- | :---
80908090
`auth_setting` | This is a required attribute and is only for Tableau Cloud. The new authentication type for the user - see **User Auth** below for values.
8091-
`domain_name` | The name of the site.
8091+
`domain_name` | On Tableau Server, the domain of the user: the name of the Active Directory domain, or `local` if the user uses local authentication. On Tableau Cloud, the authentication type of the user. `users.get` and `users.get_by_id` populate it. It is read-only, so a `UserItem` that you create yourself has no domain; include the domain in the `name` instead.
80928092
`external_auth_user_id` | Represents ID stored in Tableau's single sign-on (SSO) system. The `externalAuthUserId` value is returned for Tableau Cloud. For other server configurations, this field contains null.
80938093
`id` | The id of the user on the site.
80948094
`last_login` | The date and time the user last logged in.
@@ -8239,16 +8239,14 @@ import tableauserverclient as TSC
82398239
server = TSC.Server("http://localhost")
82408240
# Sign in to the server
82418241

8242+
# If needed (Active Directory / non-unique names across domains), use the domain-qualified
8243+
# form of the name. `domain_name` is read-only, so it cannot be set on a UserItem.
82428244
users = [
8243-
TSC.UserItem(name="user1", site_role="Unlicensed"),
8244-
TSC.UserItem(name="user2", site_role="Explorer"),
8245-
TSC.UserItem(name="user3", site_role="Creator"),
8245+
TSC.UserItem(name="example.com\\user1", site_role="Unlicensed"),
8246+
TSC.UserItem(name="example.com\\user2", site_role="Explorer"),
8247+
TSC.UserItem(name="example.com\\user3", site_role="Creator"),
82468248
]
82478249

8248-
# If needed (Active Directory / non-unique names across domains), set the domain info
8249-
for user in users:
8250-
user.domain_name = "example.com"
8251-
82528250
job = server.users.bulk_add(users)
82538251
```
82548252

@@ -8272,7 +8270,7 @@ This endpoint is available with REST API version **3.27** and up.
82728270

82738271
| Name | Description |
82748272
| :------ | :------------------------------------------------------------------------------------------------------------------- |
8275-
| `users` | An iterable of `UserItem` objects to remove from the site. Each `UserItem` should have `name` and `domain_name` set. |
8273+
| `users` | An iterable of `UserItem` objects to remove from the site. Each `UserItem` should have `name` and `domain_name` set, as items returned by `users.get` or `users.filter` do. |
82768274

82778275
**UserItem field notes**
82788276

@@ -8678,6 +8676,8 @@ Adds users from a CSV file to the site. The CSV file format matches the format u
86788676
The CSV file should have the following column format (header row optional):
86798677
`Username, Password, Display Name, License Level, Admin Level, Publishing Access`
86808678

8679+
The whole `Username` value becomes the `name` of the `UserItem`, and `domain_name` is not set. To add a user from an Active Directory domain, include the domain in the username (for example `example\Adam`).
8680+
86818681
**Parameters**
86828682

86838683
Name | Description
@@ -9092,7 +9092,7 @@ views.populate_excel(view_item, req_options=None)
90929092

90939093
Populates the Excel content of the specified view.
90949094

9095-
After calling this method, the Excel data is available through the view's `excel` property.
9095+
After calling this method, the Excel data is available through the view's `excel` property. The property is a generator that yields the file in chunks, so join the chunks with `b''.join(view_item.excel)` to get the file content as bytes.
90969096

90979097
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"}
90989098

@@ -9105,7 +9105,7 @@ Name | Description
91059105

91069106
**Returns**
91079107

9108-
None. The Excel content is added to the `view_item` and can be accessed by its `excel` field.
9108+
None. The Excel content is added to the `view_item` and can be accessed by its `excel` field, which is a generator of `bytes` chunks.
91099109

91109110
**Version**
91119111

@@ -9116,7 +9116,7 @@ Version 3.8 and later. See [REST API versions](https://help.tableau.com/current/
91169116
```py
91179117
server.views.populate_excel(view_item)
91189118
with open('./view_data.xlsx', 'wb') as f:
9119-
f.write(view_item.excel)
9119+
f.write(b''.join(view_item.excel))
91209120
```
91219121

91229122
<br>

0 commit comments

Comments
 (0)