Skip to content

Commit 7f9da2c

Browse files
committed
docs: add examples to docstrings
1 parent dec6989 commit 7f9da2c

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
@@ -164,6 +164,27 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
164164
-------
165165
JobItem
166166
The job that is started for adding the users in bulk.
167+
168+
Examples
169+
--------
170+
>>> import tableauserverclient as TSC
171+
>>> server = TSC.Server('http://localhost')
172+
>>> # Login to the server
173+
174+
>>> # Create a list of UserItem objects to add to the site
175+
>>> users = [
176+
>>> TSC.UserItem(name="user1", site_role="Unlicensed"),
177+
>>> TSC.UserItem(name="user2", site_role="Explorer"),
178+
>>> TSC.UserItem(name="user3", site_role="Creator"),
179+
>>> ]
180+
181+
>>> # Set the domain name for the users
182+
>>> for user in users:
183+
>>> user.domain_name = "example.com"
184+
185+
>>> # Add the users to the site
186+
>>> job = server.users.bulk_add(users)
187+
167188
"""
168189
url = f"{self.baseurl}/import"
169190
# Allow for iterators to be passed into the function
@@ -191,6 +212,16 @@ def bulk_remove(self, users: Iterable[UserItem]) -> None:
191212
Returns
192213
-------
193214
None
215+
216+
Examples
217+
--------
218+
>>> import tableauserverclient as TSC
219+
>>> server = TSC.Server('http://localhost')
220+
>>> # Login to the server
221+
222+
>>> # Find the users to remove
223+
>>> example_users = server.users.filter(domain_name="example.com")
224+
>>> server.users.bulk_remove(example_users)
194225
"""
195226
url = f"{self.baseurl}/delete"
196227
csv_content = remove_users_csv(users)

0 commit comments

Comments
 (0)