mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-08 13:43:35 +00:00
Add "gam print roles"
This commit is contained in:
20
src/gam.py
20
src/gam.py
@ -1604,6 +1604,24 @@ def doCreateAdmin():
|
|||||||
callGAPI(service=cd.roleAssignments(), function=u'insert',
|
callGAPI(service=cd.roleAssignments(), function=u'insert',
|
||||||
customer=GC_Values[GC_CUSTOMER_ID], body=body)
|
customer=GC_Values[GC_CUSTOMER_ID], body=body)
|
||||||
|
|
||||||
|
def doPrintAdminRoles():
|
||||||
|
cd = buildGAPIObject(u'directory')
|
||||||
|
roles = callGAPIpages(service=cd.roles(), function=u'list', items=u'items',
|
||||||
|
customer=GC_Values[GC_CUSTOMER_ID])
|
||||||
|
roles_attrib = [{}]
|
||||||
|
for role in roles:
|
||||||
|
role_attrib = {}
|
||||||
|
for key, value in role.items():
|
||||||
|
if key in [u'kind', u'etag', u'etags']:
|
||||||
|
continue
|
||||||
|
if not isinstance( value, (str, unicode, bool)):
|
||||||
|
continue
|
||||||
|
if key not in roles_attrib[0]:
|
||||||
|
roles_attrib[0][key] = key
|
||||||
|
role_attrib[key] = value
|
||||||
|
roles_attrib.append(role_attrib)
|
||||||
|
output_csv(roles_attrib, roles_attrib[0], u'Admin Roles', False)
|
||||||
|
|
||||||
def doPrintAdmins():
|
def doPrintAdmins():
|
||||||
cd = buildGAPIObject(u'directory')
|
cd = buildGAPIObject(u'directory')
|
||||||
roleId = None
|
roleId = None
|
||||||
@ -9271,6 +9289,8 @@ try:
|
|||||||
doPrintDomains()
|
doPrintDomains()
|
||||||
elif sys.argv[2].lower() in [u'admins']:
|
elif sys.argv[2].lower() in [u'admins']:
|
||||||
doPrintAdmins()
|
doPrintAdmins()
|
||||||
|
elif sys.argv[2].lower() in [u'roles', u'adminroles']:
|
||||||
|
doPrintAdminRoles()
|
||||||
else:
|
else:
|
||||||
print u'ERROR: %s is not a valid argument for "gam print"' % sys.argv[2]
|
print u'ERROR: %s is not a valid argument for "gam print"' % sys.argv[2]
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
Reference in New Issue
Block a user