From d8da1038094bff429f574522abd9ed89af2b0ab9 Mon Sep 17 00:00:00 2001 From: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:14:19 -0500 Subject: [PATCH] docs: add examples to docstrings --- .../server/endpoint/users_endpoint.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tableauserverclient/server/endpoint/users_endpoint.py b/tableauserverclient/server/endpoint/users_endpoint.py index f684b884..f0c60c32 100644 --- a/tableauserverclient/server/endpoint/users_endpoint.py +++ b/tableauserverclient/server/endpoint/users_endpoint.py @@ -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 @@ -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)