33import click
44
55from compiler_admin import RESULT_FAILURE , RESULT_SUCCESS
6- from compiler_admin .commands .user .alumni import alumni
6+ from compiler_admin .commands .user .deactivate import deactivate
77from compiler_admin .commands .user .delete import delete
88from compiler_admin .services .google import (
99 USER_ARCHIVE ,
1616
1717@click .command ()
1818@click .option ("-a" , "--alias" , help = "Another account to assign username as an alias." )
19+ @click .option ("-d" , "--delete" , "_delete" , is_flag = True , help = "Also delete the account." )
1920@click .option ("-f" , "--force" , is_flag = True , help = "Don't ask for confirmation." )
2021@click .option ("-n" , "--notify" , help = "An email address to send the new password notification." )
2122@click .argument ("username" )
2223@click .pass_context
23- def offboard (ctx : click .Context , username : str , alias : str = "" , force : bool = False , ** kwargs ):
24- """Fully offboard a user from Compiler.
25-
26- Args:
27- username (str): The user account to offboard.
24+ def offboard (ctx : click .Context , username : str , alias : str = "" , _delete : bool = False , force : bool = False , ** kwargs ):
25+ """
26+ Fully offboard a user from Compiler.
2827
29- alias (str): [Optional] account to assign username as an alias
30- Returns:
31- A value indicating if the operation succeeded or failed.
28+ Deactivate, back up email, transfer Calendar/Drive, and optionally delete.
3229 """
3330 account = user_account_name (username )
3431
@@ -49,8 +46,8 @@ def offboard(ctx: click.Context, username: str, alias: str = "", force: bool = F
4946
5047 click .echo (f"User exists, offboarding: { account } " )
5148
52- # call the alumni command
53- ctx .forward (alumni )
49+ # call the deactivate command
50+ ctx .forward (deactivate )
5451
5552 click .echo ("Backing up email" )
5653 CallGYBCommand (("--service-account" , "--email" , account , "--action" , "backup" ))
@@ -65,11 +62,14 @@ def offboard(ctx: click.Context, username: str, alias: str = "", force: bool = F
6562 CallGAMCommand (("show" , "transfers" , "olduser" , username ), stdout = stdout .name , stderr = "stdout" )
6663 status = " " .join (stdout .readlines ())
6764 stdout .seek (0 )
65+ click .echo ("Transfer complete" )
6866
67+ click .echo ("Deprovisioning POP/IMAP" )
6968 CallGAMCommand (("user" , account , "deprovision" , "popimap" ))
7069
7170 # call the delete command
72- ctx .forward (delete )
71+ if _delete :
72+ ctx .forward (delete )
7373
7474 if alias_account :
7575 click .echo (f"Adding an alias to account: { alias_account } " )
0 commit comments