@@ -89,8 +89,34 @@ def add(self, user_item: UserItem) -> UserItem:
8989
9090 # Add new users to site. This does not actually perform a bulk action, it's syntactic sugar
9191 @api (version = "2.0" )
92- def add_all (self , users : list [UserItem ]):
93- warnings .warn ("This method is deprecated, use bulk_add instead" , DeprecationWarning )
92+ def add_all (self , users : list [UserItem ]) -> tuple [list [UserItem ], list [UserItem ]]:
93+ """
94+ Syntactic sugar for calling users.add multiple times. This method has
95+ been deprecated in favor of using the bulk_add which accomplishes the
96+ same task in one API call.
97+
98+ .. deprecated:: v0.34.0
99+ `add_all` will be removed as its functionality is replicated via
100+ the `bulk_add` method.
101+
102+ Parameters
103+ ----------
104+ users: list[UserItem]
105+ A list of UserItem objects to add to the site. Each UserItem object
106+ will be passed to the `add` method individually.
107+
108+ Returns
109+ -------
110+ tuple[list[UserItem], list[UserItem]]
111+ The first element of the tuple is a list of UserItem objects that
112+ were successfully added to the site. The second element is a list
113+ of UserItem objects that failed to be added to the site.
114+
115+ Warnings
116+ --------
117+ This method is deprecated. Use the `bulk_add` method instead.
118+ """
119+ warnings .warn ("This method is deprecated, use bulk_add method instead." , DeprecationWarning )
94120 created = []
95121 failed = []
96122 for user in users :
@@ -127,6 +153,17 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
127153
128154 Details about administrator level and publishing capability are
129155 inferred from the site_role.
156+
157+ Parameters
158+ ----------
159+ users: Iterable[UserItem]
160+ An iterable of UserItem objects to add to the site. See above for
161+ what fields are required and optional.
162+
163+ Returns
164+ -------
165+ JobItem
166+ The job that is started for adding the users in bulk.
130167 """
131168 url = f"{ self .baseurl } /import"
132169 # Allow for iterators to be passed into the function
@@ -139,6 +176,22 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
139176
140177 @api (version = "3.15" )
141178 def bulk_remove (self , users : Iterable [UserItem ]) -> None :
179+ """
180+ Remove multiple users from the site. The users are identified by their
181+ domain and name. The users are removed in bulk, so the server will not
182+ return a job item to track the progress of the operation nor a response
183+ for each user that was removed.
184+
185+ Parameters
186+ ----------
187+ users: Iterable[UserItem]
188+ An iterable of UserItem objects to remove from the site. Each
189+ UserItem object should have the domain and name attributes set.
190+
191+ Returns
192+ -------
193+ None
194+ """
142195 url = f"{ self .baseurl } /delete"
143196 csv_content = remove_users_csv (users )
144197 request , content_type = RequestFactory .User .delete_csv_req (csv_content )
@@ -147,6 +200,35 @@ def bulk_remove(self, users: Iterable[UserItem]) -> None:
147200
148201 @api (version = "2.0" )
149202 def create_from_file (self , filepath : str ) -> tuple [list [UserItem ], list [tuple [UserItem , ServerResponseError ]]]:
203+ """
204+ Syntactic sugar for calling users.add multiple times. This method has
205+ been deprecated in favor of using the bulk_add which accomplishes the
206+ same task in one API call.
207+
208+ .. deprecated:: v0.34.0
209+ `add_all` will be removed as its functionality is replicated via
210+ the `bulk_add` method.
211+
212+ Parameters
213+ ----------
214+ filepath: str
215+ The path to the CSV file containing the users to add to the site.
216+ The file is read in line by line and each line is passed to the
217+ `add` method.
218+
219+ Returns
220+ -------
221+ tuple[list[UserItem], list[tuple[UserItem, ServerResponseError]]]
222+ The first element of the tuple is a list of UserItem objects that
223+ were successfully added to the site. The second element is a list
224+ of tuples where the first element is the UserItem object that failed
225+ to be added to the site and the second element is the ServerResponseError
226+ that was raised when attempting to add the user.
227+
228+ Warnings
229+ --------
230+ This method is deprecated. Use the `bulk_add` method instead.
231+ """
150232 warnings .warn ("This method is deprecated, use bulk_add instead" , DeprecationWarning )
151233 created = []
152234 failed = []
@@ -268,6 +350,21 @@ def create_users_csv(users: Iterable[UserItem], identity_pool=None) -> bytes:
268350 - Admin Level
269351 - Publish capability
270352 - Email
353+
354+ Parameters
355+ ----------
356+ users: Iterable[UserItem]
357+ An iterable of UserItem objects to create the CSV from.
358+
359+ identity_pool: Optional[str]
360+ The identity pool to use when adding the users. This parameter is not
361+ yet supported in this version of the Tableau Server Client, and should
362+ be left as None.
363+
364+ Returns
365+ -------
366+ bytes
367+ A byte string containing the CSV data.
271368 """
272369 if identity_pool is not None :
273370 raise NotImplementedError ("Identity pool is not supported in this version" )
@@ -307,6 +404,35 @@ def create_users_csv(users: Iterable[UserItem], identity_pool=None) -> bytes:
307404
308405
309406def remove_users_csv (users : Iterable [UserItem ]) -> bytes :
407+ """
408+ Create a CSV byte string from an Iterable of UserItem objects. This function
409+ only consumes the domain and name attributes of the UserItem objects. The
410+ CSV will have space for the following columns, though only the first column
411+ will be populated, and no header row:
412+
413+ - Username
414+ - Password
415+ - Display Name
416+ - License
417+ - Admin Level
418+ - Publish capability
419+ - Email
420+
421+ Parameters
422+ ----------
423+ users: Iterable[UserItem]
424+ An iterable of UserItem objects to create the CSV from.
425+
426+ identity_pool: Optional[str]
427+ The identity pool to use when adding the users. This parameter is not
428+ yet supported in this version of the Tableau Server Client, and should
429+ be left as None.
430+
431+ Returns
432+ -------
433+ bytes
434+ A byte string containing the CSV data.
435+ """
310436 with io .StringIO () as output :
311437 writer = csv .writer (output , quoting = csv .QUOTE_MINIMAL )
312438 for user in users :
0 commit comments