Skip to content

Commit

Permalink
docs: add examples to docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jorwoods committed Oct 11, 2024
1 parent dec6989 commit 7f9da2c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tableauserverclient/server/endpoint/users_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
-------
JobItem
The job that is started for adding the users in bulk.
Examples
--------
>>> import tableauserverclient as TSC
>>> server = TSC.Server('http://localhost')
>>> # Login to the server
>>> # Create a list of UserItem objects to add to the site
>>> users = [
>>> TSC.UserItem(name="user1", site_role="Unlicensed"),
>>> TSC.UserItem(name="user2", site_role="Explorer"),
>>> TSC.UserItem(name="user3", site_role="Creator"),
>>> ]
>>> # Set the domain name for the users
>>> for user in users:
>>> user.domain_name = "example.com"
>>> # Add the users to the site
>>> job = server.users.bulk_add(users)
"""
url = f"{self.baseurl}/import"
# Allow for iterators to be passed into the function
Expand Down Expand Up @@ -191,6 +212,16 @@ def bulk_remove(self, users: Iterable[UserItem]) -> None:
Returns
-------
None
Examples
--------
>>> import tableauserverclient as TSC
>>> server = TSC.Server('http://localhost')
>>> # Login to the server
>>> # Find the users to remove
>>> example_users = server.users.filter(domain_name="example.com")
>>> server.users.bulk_remove(example_users)
"""
url = f"{self.baseurl}/delete"
csv_content = remove_users_csv(users)
Expand Down

0 comments on commit 7f9da2c

Please sign in to comment.