Skip to content

Commit fcb1fb0

Browse files
committed
docs: users.bulk_add and users.bulk_remove
1 parent d686ef6 commit fcb1fb0

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

docs/api-ref.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,6 +4925,118 @@ Returns the new `UserItem` object.
49254925

49264926
```
49274927

4928+
#### users.bulk_add
4929+
4930+
```py
4931+
users.bulk_add(users)
4932+
```
4933+
4934+
When adding users in bulk, the server creates an asynchronous job. This method returns the `JobItem` you can use to track progress.
4935+
4936+
REST API: Add User to Site. ([Tableau Help][1])
4937+
4938+
**Version**
4939+
4940+
This endpoint is available with REST API version **3.15** and up.
4941+
4942+
**Parameters**
4943+
4944+
| Name | Description |
4945+
| :------ | :------------------------------------------------------------------------------------------ |
4946+
| `users` | An iterable of `UserItem` objects to add to the site. Each `UserItem` must have `name` set. |
4947+
4948+
**UserItem field notes**
4949+
4950+
* `name` **required**. If using Active Directory and the username isn’t unique across domains, include the domain-qualified form (for example `example\\Adam` or `adam@example.com`). ([Tableau Help][1])
4951+
* `fullname` is used as the user’s display name (TSC reads the display name from `fullname`).
4952+
* `email` optional, but if provided it must be a valid email address; it is included in the REST payload as `email`. ([Tableau Help][1])
4953+
* `auth_setting` optional. If not provided and `idp_configuration_id` is `None`, the default is `ServerDefault`. (REST supports `authSetting` and `idpConfigurationId` as user creation attributes.) ([Tableau Help][1])
4954+
* `site_role` optional. If not provided, defaults to `Unlicensed`.
4955+
* `password` optional and only used when the server is using **local authentication**; do not provide a password for other auth types.
4956+
* Admin level and publishing capability are inferred from `site_role`.
4957+
* If the user belongs to a different IdP configuration, set `UserItem.idp_configuration_id` to that configuration’s ID. (REST supports `idpConfigurationId` when adding a user.) ([Tableau Help][1])
4958+
4959+
**Returns**
4960+
4961+
| Type | Description |
4962+
| :-------- | :-------------------------------------------- |
4963+
| `JobItem` | The job started for adding the users in bulk. |
4964+
4965+
**Example**
4966+
4967+
```py
4968+
import tableauserverclient as TSC
4969+
4970+
server = TSC.Server("http://localhost")
4971+
# Sign in to the server
4972+
4973+
users = [
4974+
TSC.UserItem(name="user1", site_role="Unlicensed"),
4975+
TSC.UserItem(name="user2", site_role="Explorer"),
4976+
TSC.UserItem(name="user3", site_role="Creator"),
4977+
]
4978+
4979+
# If needed (Active Directory / non-unique names across domains), set the domain info
4980+
for user in users:
4981+
user.domain_name = "example.com"
4982+
4983+
job = server.users.bulk_add(users)
4984+
```
4985+
4986+
[1]: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_users_and_groups.htm "Users and Groups Methods - Tableau"
4987+
4988+
4989+
#### users.bulk_remove
4990+
4991+
```py
4992+
users.bulk_remove(users)
4993+
```
4994+
4995+
Remove multiple users from the current site in a single bulk operation. Users are identified by **domain** and **name** (not by user ID). This call is "fire-and-forget" in TSC: it does **not** return a `JobItem`, and it does not provide per-user results.
4996+
4997+
REST API: **Delete Users from Site with CSV** (`POST /sites/{site-id}/users/delete`). ([Tableau Help][1])
4998+
4999+
**Version**
5000+
5001+
This endpoint is available with REST API version **3.15** and up. ([Tableau Help][2])
5002+
5003+
**Parameters**
5004+
5005+
| Name | Description |
5006+
| :------ | :------------------------------------------------------------------------------------------------------------------- |
5007+
| `users` | An iterable of `UserItem` objects to remove from the site. Each `UserItem` should have `name` and `domain_name` set. |
5008+
5009+
**UserItem field notes**
5010+
5011+
* `name` **required** for each user being removed.
5012+
* `domain_name` **required** to disambiguate users when names may exist across domains (for example in AD setups).
5013+
* Users are matched by **(domain, name)**; you don't need the user `id` for this bulk method (unlike some other REST operations).
5014+
5015+
**Returns**
5016+
5017+
| Type | Description |
5018+
| :----- | :--------------------------------------------------------------- |
5019+
| `None` | No job handle or per-user status is returned by this TSC method. |
5020+
5021+
**Example**
5022+
5023+
```py
5024+
import tableauserverclient as TSC
5025+
5026+
server = TSC.Server("http://localhost")
5027+
# Sign in to the server
5028+
5029+
# Example: remove all users in a particular domain
5030+
example_users = server.users.filter(domain_name="example.com")
5031+
server.users.bulk_remove(example_users)
5032+
```
5033+
5034+
**Notes**
5035+
5036+
* The underlying REST endpoint is the "delete users from site via CSV" pattern.
5037+
* Removing a user from a site dissociates them from the site (and doesn't necessarily remove them from the server globally in all contexts).
5038+
5039+
49285040
#### users.get
49295041

49305042
```py

0 commit comments

Comments
 (0)