mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-08 13:43:35 +00:00
Better error on user delete pre-condition.
This commit is contained in:
@ -9445,13 +9445,6 @@ def doDeprovUser(users):
|
|||||||
print(f'Done deprovisioning {user}')
|
print(f'Done deprovisioning {user}')
|
||||||
|
|
||||||
|
|
||||||
def doDeleteUser():
|
|
||||||
cd = buildGAPIObject('directory')
|
|
||||||
user_email = normalizeEmailAddressOrUID(sys.argv[3])
|
|
||||||
print(f'Deleting account for {user_email}')
|
|
||||||
gapi.call(cd.users(), 'delete', userKey=user_email)
|
|
||||||
|
|
||||||
|
|
||||||
def doUndeleteUser():
|
def doUndeleteUser():
|
||||||
cd = buildGAPIObject('directory')
|
cd = buildGAPIObject('directory')
|
||||||
user = normalizeEmailAddressOrUID(sys.argv[3])
|
user = normalizeEmailAddressOrUID(sys.argv[3])
|
||||||
@ -11626,7 +11619,7 @@ def ProcessGAMCommand(args):
|
|||||||
elif command == 'delete':
|
elif command == 'delete':
|
||||||
argument = sys.argv[2].lower()
|
argument = sys.argv[2].lower()
|
||||||
if argument == 'user':
|
if argument == 'user':
|
||||||
doDeleteUser()
|
gapi_directory_users.delete()
|
||||||
elif argument == 'group':
|
elif argument == 'group':
|
||||||
gapi_directory_groups.delete()
|
gapi_directory_groups.delete()
|
||||||
elif argument == 'device':
|
elif argument == 'device':
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import gam
|
import gam
|
||||||
|
from gam import display
|
||||||
from gam import gapi
|
from gam import gapi
|
||||||
from gam.gapi import directory as gapi_directory
|
from gam.gapi import directory as gapi_directory
|
||||||
from gam.gapi import errors as gapi_errors
|
from gam.gapi import errors as gapi_errors
|
||||||
|
|
||||||
|
|
||||||
|
def delete():
|
||||||
|
cd = gapi_directory.build()
|
||||||
|
user_email = gam.normalizeEmailAddressOrUID(sys.argv[3])
|
||||||
|
print(f'Deleting account for {user_email}')
|
||||||
|
try:
|
||||||
|
gapi.call(cd.users(),
|
||||||
|
'delete',
|
||||||
|
userKey=user_email,
|
||||||
|
throw_reasons=[gapi_errors.ErrorReason.CONDITION_NOT_MET])
|
||||||
|
except gam.gapi.errors.GapiConditionNotMetError as err:
|
||||||
|
display.print_error(
|
||||||
|
f'{err} The user {user_email} may be (or have recently been) on Google Vault Hold and thus not eligible for deletion. You can check holds with "gam user <email> show vaultholds".'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_primary(email):
|
def get_primary(email):
|
||||||
'''returns primary email of user or empty if email is not a user primary or
|
'''returns primary email of user or empty if email is not a user primary or
|
||||||
alias address.'''
|
alias address.'''
|
||||||
|
Reference in New Issue
Block a user