mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
update orgunit commands to support IDs
This commit is contained in:
42
gam.py
42
gam.py
@@ -5210,26 +5210,14 @@ def doGetOrgInfo():
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
if name == u'/':
|
if name == u'/':
|
||||||
print u"Organization Unit: /"
|
orgs = callGAPI(service=cd.orgunits(), function=u'list',
|
||||||
print u"Description: Root OU"
|
customerId=customerId, type=u'children',
|
||||||
print u"Parent Org: <none>"
|
fields=u'organizationUnits/parentOrgUnitId')
|
||||||
print u"Full Org Path: /"
|
name = orgs[u'organizationUnits'][0][u'parentOrgUnitId']
|
||||||
print u"Block Inheritance: False"
|
|
||||||
else:
|
|
||||||
if len(name) > 1 and name[0] == u'/':
|
if len(name) > 1 and name[0] == u'/':
|
||||||
name = name[1:]
|
name = name[1:]
|
||||||
result = callGAPI(service=cd.orgunits(), function=u'get', customerId=customerId, orgUnitPath=name)
|
result = callGAPI(service=cd.orgunits(), function=u'get', customerId=customerId, orgUnitPath=name)
|
||||||
print u'Organization Unit: %s' % result[u'name']
|
print_json(None, result)
|
||||||
try:
|
|
||||||
print u'Description: %s' % result[u'description']
|
|
||||||
except KeyError:
|
|
||||||
print u'Description: '
|
|
||||||
print u'Parent Org: %s' % result[u'parentOrgUnitPath']
|
|
||||||
print u'Full Org Path: %s' % result[u'orgUnitPath']
|
|
||||||
try:
|
|
||||||
print u'Block Inheritance: %s' % result[u'blockInheritance']
|
|
||||||
except KeyError:
|
|
||||||
print u'Block Inheritance: False'
|
|
||||||
if get_users:
|
if get_users:
|
||||||
if name != u'/':
|
if name != u'/':
|
||||||
name = u'/%s' % name
|
name = u'/%s' % name
|
||||||
@@ -6157,12 +6145,14 @@ def doPrintOrgs():
|
|||||||
printname = printdesc = printparent = printinherit = todrive = False
|
printname = printdesc = printparent = printinherit = todrive = False
|
||||||
type = u'all'
|
type = u'all'
|
||||||
orgUnitPath = u"/"
|
orgUnitPath = u"/"
|
||||||
org_attributes = []
|
org_attributes = [{}]
|
||||||
org_attributes.append({u'Path': u'Path'})
|
|
||||||
fields = u'organizationUnits(orgUnitPath)'
|
fields = u'organizationUnits(orgUnitPath)'
|
||||||
titles = [u'Path']
|
titles = []
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
if sys.argv[i].lower() == u'name':
|
if sys.argv[i].lower() == u'allfields':
|
||||||
|
fields = None
|
||||||
|
i += 1
|
||||||
|
elif sys.argv[i].lower() == u'name':
|
||||||
printname = True
|
printname = True
|
||||||
org_attributes[0].update(Name=u'Name')
|
org_attributes[0].update(Name=u'Name')
|
||||||
fields += u',organizationUnits(name)'
|
fields += u',organizationUnits(name)'
|
||||||
@@ -6198,6 +6188,9 @@ def doPrintOrgs():
|
|||||||
else:
|
else:
|
||||||
showUsage()
|
showUsage()
|
||||||
exit(8)
|
exit(8)
|
||||||
|
if fields:
|
||||||
|
org_attributes[0][u'Path'] = u'Path'
|
||||||
|
titles.append(u'Path')
|
||||||
cd = buildGAPIObject(u'directory')
|
cd = buildGAPIObject(u'directory')
|
||||||
sys.stderr.write(u"Retrieving All Organizational Units for your account (may take some time on large domain)...")
|
sys.stderr.write(u"Retrieving All Organizational Units for your account (may take some time on large domain)...")
|
||||||
orgs = callGAPI(service=cd.orgunits(), function=u'list', customerId=customerId, fields=fields, type=type, orgUnitPath=orgUnitPath)
|
orgs = callGAPI(service=cd.orgunits(), function=u'list', customerId=customerId, fields=fields, type=type, orgUnitPath=orgUnitPath)
|
||||||
@@ -6207,6 +6200,13 @@ def doPrintOrgs():
|
|||||||
return
|
return
|
||||||
for org_vals in orgs[u'organizationUnits']:
|
for org_vals in orgs[u'organizationUnits']:
|
||||||
orgUnit = {}
|
orgUnit = {}
|
||||||
|
if not fields:
|
||||||
|
orgUnit = flatten_json(org_vals)
|
||||||
|
for row in orgUnit:
|
||||||
|
if row not in titles:
|
||||||
|
titles.append(row)
|
||||||
|
org_attributes[0][row] = row
|
||||||
|
else:
|
||||||
orgUnit.update({u'Path': org_vals[u'orgUnitPath']})
|
orgUnit.update({u'Path': org_vals[u'orgUnitPath']})
|
||||||
if printname:
|
if printname:
|
||||||
name = org_vals[u'name']
|
name = org_vals[u'name']
|
||||||
|
|||||||
Reference in New Issue
Block a user