Skip to content

Commit 80a38ff

Browse files
committed
docs: add examples to docstrings
1 parent d13539e commit 80a38ff

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tableauserverclient/server/endpoint/users_endpoint.py

+31
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,27 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
424424
-------
425425
JobItem
426426
The job that is started for adding the users in bulk.
427+
428+
Examples
429+
--------
430+
>>> import tableauserverclient as TSC
431+
>>> server = TSC.Server('http://localhost')
432+
>>> # Login to the server
433+
434+
>>> # Create a list of UserItem objects to add to the site
435+
>>> users = [
436+
>>> TSC.UserItem(name="user1", site_role="Unlicensed"),
437+
>>> TSC.UserItem(name="user2", site_role="Explorer"),
438+
>>> TSC.UserItem(name="user3", site_role="Creator"),
439+
>>> ]
440+
441+
>>> # Set the domain name for the users
442+
>>> for user in users:
443+
>>> user.domain_name = "example.com"
444+
445+
>>> # Add the users to the site
446+
>>> job = server.users.bulk_add(users)
447+
427448
"""
428449
url = f"{self.baseurl}/import"
429450
# Allow for iterators to be passed into the function
@@ -451,6 +472,16 @@ def bulk_remove(self, users: Iterable[UserItem]) -> None:
451472
Returns
452473
-------
453474
None
475+
476+
Examples
477+
--------
478+
>>> import tableauserverclient as TSC
479+
>>> server = TSC.Server('http://localhost')
480+
>>> # Login to the server
481+
482+
>>> # Find the users to remove
483+
>>> example_users = server.users.filter(domain_name="example.com")
484+
>>> server.users.bulk_remove(example_users)
454485
"""
455486
url = f"{self.baseurl}/delete"
456487
csv_content = remove_users_csv(users)

0 commit comments

Comments
 (0)