mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 12:51:36 +00:00
info user cleanup and rename to vfe
This commit is contained in:
80
gam.py
80
gam.py
@@ -3847,6 +3847,20 @@ def doUpdateUser(users):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
body[u'relations'] = [relation,]
|
body[u'relations'] = [relation,]
|
||||||
i += 1
|
i += 1
|
||||||
|
elif sys.argv[i].lower() == u'otheremail':
|
||||||
|
do_update_user = True
|
||||||
|
an_email = dict()
|
||||||
|
i += 1
|
||||||
|
an_email[u'type'] = sys.argv[i]
|
||||||
|
if an_email[u'type'].lower() not in [u'custom', u'home', u'other', u'work']:
|
||||||
|
an_email[u'type'] = u'custom'
|
||||||
|
an_email[u'customType'] = sys.argv[i]
|
||||||
|
i += 1
|
||||||
|
an_email[u'address'] = sys.argv[i]
|
||||||
|
if u'emails' not in body:
|
||||||
|
body[u'emails'] = list()
|
||||||
|
body[u'emails'].append(an_email)
|
||||||
|
i += 1
|
||||||
elif sys.argv[i].lower() == u'externalid':
|
elif sys.argv[i].lower() == u'externalid':
|
||||||
do_update_user = True
|
do_update_user = True
|
||||||
externalid = dict()
|
externalid = dict()
|
||||||
@@ -3875,11 +3889,14 @@ def doUpdateUser(users):
|
|||||||
user = user[4:]
|
user = user[4:]
|
||||||
elif user.find(u'@') == -1:
|
elif user.find(u'@') == -1:
|
||||||
user = u'%s@%s' % (user, domain)
|
user = u'%s@%s' % (user, domain)
|
||||||
if body[u'primaryEmail'][:4].lower() == u'vfe@':
|
if u'primaryEmail' in body and body[u'primaryEmail'][:4].lower() == u'vfe@':
|
||||||
if user.find(u'@') == -1:
|
user_primary = callGAPI(service=cd.users(), function=u'get', userKey=user, fields=u'primaryEmail,id')
|
||||||
body[u'primaryEmail'] = u'vfe.%s.%05d@%s' % (user, random.randint(1,99999), domain)
|
user = user_primary[u'id']
|
||||||
else:
|
user_primary = user_primary[u'primaryEmail']
|
||||||
body[u'primaryEmail'] = u'vfe.%s.%05d@%s' % (user[:user.find(u'@')], random.randint(1,99999), user[user.find(u'@')+1:])
|
user_name = user_primary[:user_primary.find(u'@')]
|
||||||
|
user_domain = user_primary[user_primary.find(u'@')+1:]
|
||||||
|
body[u'primaryEmail'] = u'vfe.%s.%05d@%s' % (user_name, random.randint(1,99999), user_domain)
|
||||||
|
body[u'emails'] = [{u'type': u'custom', u'customType': u'former_employee', u'primary': False, u'address': user_primary}]
|
||||||
sys.stderr.write(u'updating user %s...\n' % user)
|
sys.stderr.write(u'updating user %s...\n' % user)
|
||||||
if do_update_user:
|
if do_update_user:
|
||||||
result = callGAPI(service=cd.users(), function=u'patch', soft_errors=True, userKey=user, body=body)
|
result = callGAPI(service=cd.users(), function=u'patch', soft_errors=True, userKey=user, body=body)
|
||||||
@@ -4341,40 +4358,46 @@ def doGetUserInfo(user_email=None):
|
|||||||
print u'Photo URL: %s\n' % user[u'thumbnailPhotoUrl']
|
print u'Photo URL: %s\n' % user[u'thumbnailPhotoUrl']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
if u'ims' in user:
|
||||||
print u'IMs:'
|
print u'IMs:'
|
||||||
try:
|
|
||||||
for im in user[u'ims']:
|
for im in user[u'ims']:
|
||||||
for key in im.keys():
|
for key in im.keys():
|
||||||
print u' %s: %s' % (key, im[key])
|
print u' %s: %s' % (key, im[key])
|
||||||
print u''
|
print u''
|
||||||
except KeyError:
|
if u'addresses' in user:
|
||||||
pass
|
|
||||||
print u'Addresses:'
|
print u'Addresses:'
|
||||||
try:
|
|
||||||
for address in user[u'addresses']:
|
for address in user[u'addresses']:
|
||||||
for key in address.keys():
|
for key in address.keys():
|
||||||
print u' %s: %s' % (key, address[key])
|
print u' %s: %s' % (key, address[key])
|
||||||
print ''
|
print ''
|
||||||
except KeyError:
|
if u'organizations' in user:
|
||||||
pass
|
|
||||||
print u'Organizations:'
|
print u'Organizations:'
|
||||||
try:
|
|
||||||
for org in user[u'organizations']:
|
for org in user[u'organizations']:
|
||||||
for key in org.keys():
|
for key in org.keys():
|
||||||
print u' %s: %s' % (key, org[key])
|
print u' %s: %s' % (key, org[key])
|
||||||
print u''
|
print u''
|
||||||
except KeyError:
|
if u'phones' in user:
|
||||||
pass
|
|
||||||
print u'Phones:'
|
print u'Phones:'
|
||||||
try:
|
|
||||||
for phone in user[u'phones']:
|
for phone in user[u'phones']:
|
||||||
for key in phone.keys():
|
for key in phone.keys():
|
||||||
print u' %s: %s' % (key, phone[key])
|
print u' %s: %s' % (key, phone[key])
|
||||||
print u''
|
print u''
|
||||||
except KeyError:
|
if u'emails' in user:
|
||||||
pass
|
if len(user[u'emails']) > 1:
|
||||||
|
print u'Other Emails:'
|
||||||
|
for an_email in user[u'emails']:
|
||||||
|
if an_email[u'address'].lower() == user[u'primaryEmail'].lower():
|
||||||
|
continue
|
||||||
|
for key in an_email.keys():
|
||||||
|
if key == u'type' and an_email[key] == u'custom':
|
||||||
|
continue
|
||||||
|
if key == u'customType':
|
||||||
|
print u' type: %s' % an_email[key]
|
||||||
|
else:
|
||||||
|
print u' %s: %s' % (key, an_email[key])
|
||||||
|
print u''
|
||||||
|
if u'relations' in user:
|
||||||
print u'Relations:'
|
print u'Relations:'
|
||||||
try:
|
|
||||||
for relation in user[u'relations']:
|
for relation in user[u'relations']:
|
||||||
for key in relation.keys():
|
for key in relation.keys():
|
||||||
if key == u'type' and relation[key] == u'custom':
|
if key == u'type' and relation[key] == u'custom':
|
||||||
@@ -4384,10 +4407,8 @@ def doGetUserInfo(user_email=None):
|
|||||||
else:
|
else:
|
||||||
print u' %s: %s' % (key, relation[key])
|
print u' %s: %s' % (key, relation[key])
|
||||||
print u''
|
print u''
|
||||||
except KeyError:
|
if u'externalIds' in user:
|
||||||
pass
|
|
||||||
print u'External IDs:'
|
print u'External IDs:'
|
||||||
try:
|
|
||||||
for id in user[u'externalIds']:
|
for id in user[u'externalIds']:
|
||||||
for key in id.keys():
|
for key in id.keys():
|
||||||
if key == u'type' and id[key] == u'custom':
|
if key == u'type' and id[key] == u'custom':
|
||||||
@@ -4397,31 +4418,22 @@ def doGetUserInfo(user_email=None):
|
|||||||
else:
|
else:
|
||||||
print u' %s: %s' % (key, id[key])
|
print u' %s: %s' % (key, id[key])
|
||||||
print u''
|
print u''
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
if getAliases:
|
if getAliases:
|
||||||
|
if u'aliases' in user:
|
||||||
print u'Email Aliases:'
|
print u'Email Aliases:'
|
||||||
try:
|
|
||||||
for alias in user[u'aliases']:
|
for alias in user[u'aliases']:
|
||||||
print u' ' + alias
|
print u' %s' % alias
|
||||||
except KeyError:
|
if u'nonEditableAliases' in user:
|
||||||
pass
|
|
||||||
print u'Non-Editable Aliases:'
|
print u'Non-Editable Aliases:'
|
||||||
try:
|
|
||||||
for alias in user[u'nonEditableAliases']:
|
for alias in user[u'nonEditableAliases']:
|
||||||
print u' ' + alias
|
print u' ' + alias
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
if getGroups:
|
if getGroups:
|
||||||
groups = callGAPI(service=cd.groups(), function=u'list', userKey=user_email)
|
groups = callGAPI(service=cd.groups(), function=u'list', userKey=user_email)
|
||||||
|
if u'groups' in groups:
|
||||||
print u'Groups:'
|
print u'Groups:'
|
||||||
try:
|
|
||||||
for group in groups[u'groups']:
|
for group in groups[u'groups']:
|
||||||
print u' %s <%s>' % (group[u'name'], group[u'email'])
|
print u' %s <%s>' % (group[u'name'], group[u'email'])
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
if getLicenses:
|
if getLicenses:
|
||||||
print
|
|
||||||
print u'Licenses:'
|
print u'Licenses:'
|
||||||
lic = buildGAPIObject(api='licensing')
|
lic = buildGAPIObject(api='licensing')
|
||||||
for sku in [u'Google-Apps', u'Google-Apps-For-Business', u'Google-Apps-Unlimited', u'Google-Apps-For-Postini',
|
for sku in [u'Google-Apps', u'Google-Apps-For-Business', u'Google-Apps-Unlimited', u'Google-Apps-For-Postini',
|
||||||
|
|||||||
Reference in New Issue
Block a user