@@ -349,8 +349,34 @@ def add(self, user_item: UserItem) -> UserItem:
349349
350350 # Add new users to site. This does not actually perform a bulk action, it's syntactic sugar
351351 @api (version = "2.0" )
352- def add_all (self , users : list [UserItem ]):
353- warnings .warn ("This method is deprecated, use bulk_add instead" , DeprecationWarning )
352+ def add_all (self , users : list [UserItem ]) -> tuple [list [UserItem ], list [UserItem ]]:
353+ """
354+ Syntactic sugar for calling users.add multiple times. This method has
355+ been deprecated in favor of using the bulk_add which accomplishes the
356+ same task in one API call.
357+
358+ .. deprecated:: v0.34.0
359+ `add_all` will be removed as its functionality is replicated via
360+ the `bulk_add` method.
361+
362+ Parameters
363+ ----------
364+ users: list[UserItem]
365+ A list of UserItem objects to add to the site. Each UserItem object
366+ will be passed to the `add` method individually.
367+
368+ Returns
369+ -------
370+ tuple[list[UserItem], list[UserItem]]
371+ The first element of the tuple is a list of UserItem objects that
372+ were successfully added to the site. The second element is a list
373+ of UserItem objects that failed to be added to the site.
374+
375+ Warnings
376+ --------
377+ This method is deprecated. Use the `bulk_add` method instead.
378+ """
379+ warnings .warn ("This method is deprecated, use bulk_add method instead." , DeprecationWarning )
354380 created = []
355381 failed = []
356382 for user in users :
@@ -387,6 +413,17 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
387413
388414 Details about administrator level and publishing capability are
389415 inferred from the site_role.
416+
417+ Parameters
418+ ----------
419+ users: Iterable[UserItem]
420+ An iterable of UserItem objects to add to the site. See above for
421+ what fields are required and optional.
422+
423+ Returns
424+ -------
425+ JobItem
426+ The job that is started for adding the users in bulk.
390427 """
391428 url = f"{ self .baseurl } /import"
392429 # Allow for iterators to be passed into the function
@@ -399,6 +436,22 @@ def bulk_add(self, users: Iterable[UserItem]) -> JobItem:
399436
400437 @api (version = "3.15" )
401438 def bulk_remove (self , users : Iterable [UserItem ]) -> None :
439+ """
440+ Remove multiple users from the site. The users are identified by their
441+ domain and name. The users are removed in bulk, so the server will not
442+ return a job item to track the progress of the operation nor a response
443+ for each user that was removed.
444+
445+ Parameters
446+ ----------
447+ users: Iterable[UserItem]
448+ An iterable of UserItem objects to remove from the site. Each
449+ UserItem object should have the domain and name attributes set.
450+
451+ Returns
452+ -------
453+ None
454+ """
402455 url = f"{ self .baseurl } /delete"
403456 csv_content = remove_users_csv (users )
404457 request , content_type = RequestFactory .User .delete_csv_req (csv_content )
@@ -407,6 +460,35 @@ def bulk_remove(self, users: Iterable[UserItem]) -> None:
407460
408461 @api (version = "2.0" )
409462 def create_from_file (self , filepath : str ) -> tuple [list [UserItem ], list [tuple [UserItem , ServerResponseError ]]]:
463+ """
464+ Syntactic sugar for calling users.add multiple times. This method has
465+ been deprecated in favor of using the bulk_add which accomplishes the
466+ same task in one API call.
467+
468+ .. deprecated:: v0.34.0
469+ `add_all` will be removed as its functionality is replicated via
470+ the `bulk_add` method.
471+
472+ Parameters
473+ ----------
474+ filepath: str
475+ The path to the CSV file containing the users to add to the site.
476+ The file is read in line by line and each line is passed to the
477+ `add` method.
478+
479+ Returns
480+ -------
481+ tuple[list[UserItem], list[tuple[UserItem, ServerResponseError]]]
482+ The first element of the tuple is a list of UserItem objects that
483+ were successfully added to the site. The second element is a list
484+ of tuples where the first element is the UserItem object that failed
485+ to be added to the site and the second element is the ServerResponseError
486+ that was raised when attempting to add the user.
487+
488+ Warnings
489+ --------
490+ This method is deprecated. Use the `bulk_add` method instead.
491+ """
410492 warnings .warn ("This method is deprecated, use bulk_add instead" , DeprecationWarning )
411493 created = []
412494 failed = []
@@ -632,6 +714,21 @@ def create_users_csv(users: Iterable[UserItem], identity_pool=None) -> bytes:
632714 - Admin Level
633715 - Publish capability
634716 - Email
717+
718+ Parameters
719+ ----------
720+ users: Iterable[UserItem]
721+ An iterable of UserItem objects to create the CSV from.
722+
723+ identity_pool: Optional[str]
724+ The identity pool to use when adding the users. This parameter is not
725+ yet supported in this version of the Tableau Server Client, and should
726+ be left as None.
727+
728+ Returns
729+ -------
730+ bytes
731+ A byte string containing the CSV data.
635732 """
636733 if identity_pool is not None :
637734 raise NotImplementedError ("Identity pool is not supported in this version" )
@@ -671,6 +768,35 @@ def create_users_csv(users: Iterable[UserItem], identity_pool=None) -> bytes:
671768
672769
673770def remove_users_csv (users : Iterable [UserItem ]) -> bytes :
771+ """
772+ Create a CSV byte string from an Iterable of UserItem objects. This function
773+ only consumes the domain and name attributes of the UserItem objects. The
774+ CSV will have space for the following columns, though only the first column
775+ will be populated, and no header row:
776+
777+ - Username
778+ - Password
779+ - Display Name
780+ - License
781+ - Admin Level
782+ - Publish capability
783+ - Email
784+
785+ Parameters
786+ ----------
787+ users: Iterable[UserItem]
788+ An iterable of UserItem objects to create the CSV from.
789+
790+ identity_pool: Optional[str]
791+ The identity pool to use when adding the users. This parameter is not
792+ yet supported in this version of the Tableau Server Client, and should
793+ be left as None.
794+
795+ Returns
796+ -------
797+ bytes
798+ A byte string containing the CSV data.
799+ """
674800 with io .StringIO () as output :
675801 writer = csv .writer (output , quoting = csv .QUOTE_MINIMAL )
676802 for user in users :
0 commit comments