Skip to content

Commit f4a1003

Browse files
authored
docs: users.bulk_add and users.bulk_remove (#1753)
Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent d686ef6 commit f4a1003

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

docs/api-ref.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,6 +4925,117 @@ 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: [Import Users to Site from CSV ](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_users_and_groups.htm#import_users_to_site_from_csv)
4937+
4938+
**Version**
4939+
4940+
This endpoint is available with REST API version **3.27** 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`).
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`.
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.)
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.)
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+
4987+
4988+
#### users.bulk_remove
4989+
4990+
```py
4991+
users.bulk_remove(users)
4992+
```
4993+
4994+
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.
4995+
4996+
REST API: [Delete Users from Site with CSV](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_users_and_groups.htm#delete_users_from_site_with_csv)
4997+
4998+
**Version**
4999+
5000+
This endpoint is available with REST API version **3.27** and up.
5001+
5002+
**Parameters**
5003+
5004+
| Name | Description |
5005+
| :------ | :------------------------------------------------------------------------------------------------------------------- |
5006+
| `users` | An iterable of `UserItem` objects to remove from the site. Each `UserItem` should have `name` and `domain_name` set. |
5007+
5008+
**UserItem field notes**
5009+
5010+
* `name` **required** for each user being removed.
5011+
* `domain_name` **required** to disambiguate users when names may exist across domains (for example in AD setups).
5012+
* Users are matched by **(domain, name)**; you don't need the user `id` for this bulk method (unlike some other REST operations).
5013+
5014+
**Returns**
5015+
5016+
| Type | Description |
5017+
| :----- | :--------------------------------------------------------------- |
5018+
| `None` | No job handle or per-user status is returned by this TSC method. |
5019+
5020+
**Example**
5021+
5022+
```py
5023+
import tableauserverclient as TSC
5024+
5025+
server = TSC.Server("http://localhost")
5026+
# Sign in to the server
5027+
5028+
# Example: remove all users in a particular domain
5029+
example_users = server.users.filter(domain_name="example.com")
5030+
server.users.bulk_remove(example_users)
5031+
```
5032+
5033+
**Notes**
5034+
5035+
* The underlying REST endpoint is the "delete users from site via CSV" pattern.
5036+
* Removing a user from a site dissociates them from the site (and doesn't necessarily remove them from the server globally in all contexts).
5037+
5038+
49285039
#### users.get
49295040

49305041
```py

0 commit comments

Comments
 (0)