diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index c1d287464..606656ac3 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,11 @@ +7.02.05 + +Updated `gam [] show shareddriveacls ... formatjson` to not display this line +which interferes with the JSON output. +``` +User: user@domain.com, Show N Shared Drives +``` + 7.02.04 Updated code to eliminate trap caused by bug introduced in 7.02.00 that occurs when an invalid domain or OU is specified. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 685f79d4f..94931c2c8 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -25,7 +25,7 @@ """ __author__ = 'GAM Team ' -__version__ = '7.02.04' +__version__ = '7.02.05' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' #pylint: disable=wrong-import-position @@ -23171,8 +23171,8 @@ def printShowContactDelegates(users): continue jcount = len(delegates) if not csvPF: - entityPerformActionNumItems([Ent.USER, user], jcount, Ent.CONTACT_DELEGATE, i, count) if not csvStyle: + entityPerformActionNumItems([Ent.USER, user], jcount, Ent.CONTACT_DELEGATE, i, count) Ind.Increment() j = 0 for delegate in delegates: @@ -65568,31 +65568,29 @@ def stripNonShowFields(shareddrive): else: matchedFeed = feed jcount = len(matchedFeed) + if jcount == 0: + setSysExitRC(NO_ENTITIES_FOUND_RC) if not csvPF: if not FJQC.formatJSON: entityPerformActionNumItems([Ent.USER, user], jcount, Ent.SHAREDDRIVE, i, count) - if jcount == 0: - setSysExitRC(NO_ENTITIES_FOUND_RC) + Ind.Increment() + j = 0 + for shareddrive in matchedFeed: + j += 1 + shareddrive = stripNonShowFields(shareddrive) + _showSharedDrive(user, shareddrive, j, jcount, FJQC) + Ind.Decrement() else: - if not csvPF: - Ind.Increment() - j = 0 - for shareddrive in matchedFeed: - j += 1 - shareddrive = stripNonShowFields(shareddrive) - _showSharedDrive(user, shareddrive, j, jcount, FJQC) - Ind.Decrement() - else: - for shareddrive in matchedFeed: - shareddrive = stripNonShowFields(shareddrive) - if FJQC.formatJSON: - row = {'User': user, 'id': shareddrive['id'], 'name': shareddrive['name']} - if not useDomainAdminAccess: - row['role'] = shareddrive['role'] if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[shareddrive['role']] - row['JSON'] = json.dumps(cleanJSON(shareddrive, timeObjects=SHAREDDRIVE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True) - csvPF.WriteRow(row) - else: - csvPF.WriteRowTitles(flattenJSON(shareddrive, flattened={'User': user}, timeObjects=SHAREDDRIVE_TIME_OBJECTS)) + for shareddrive in matchedFeed: + shareddrive = stripNonShowFields(shareddrive) + if FJQC.formatJSON: + row = {'User': user, 'id': shareddrive['id'], 'name': shareddrive['name']} + if not useDomainAdminAccess: + row['role'] = shareddrive['role'] if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[shareddrive['role']] + row['JSON'] = json.dumps(cleanJSON(shareddrive, timeObjects=SHAREDDRIVE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True) + csvPF.WriteRow(row) + else: + csvPF.WriteRowTitles(flattenJSON(shareddrive, flattened={'User': user}, timeObjects=SHAREDDRIVE_TIME_OBJECTS)) if csvPF: csvPF.writeCSVfile('SharedDrives') @@ -65651,29 +65649,27 @@ def _showOrgUnitSharedDrive(shareddrive, j, jcount, FJQC): customer=_getCustomersCustomerIdWithC(), filter="type == 'shared_drive'") jcount = len(sds) + if jcount == 0: + setSysExitRC(NO_ENTITIES_FOUND_RC) if not csvPF: if not FJQC.formatJSON: entityPerformActionNumItems([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], jcount, Ent.SHAREDDRIVE) - if jcount == 0: - setSysExitRC(NO_ENTITIES_FOUND_RC) + Ind.Increment() + j = 0 + for shareddrive in sds: + j += 1 + _getOrgUnitSharedDriveInfo(shareddrive) + _showOrgUnitSharedDrive(shareddrive, j, jcount, FJQC) + Ind.Decrement() else: - if not csvPF: - Ind.Increment() - j = 0 - for shareddrive in sds: - j += 1 - _getOrgUnitSharedDriveInfo(shareddrive) - _showOrgUnitSharedDrive(shareddrive, j, jcount, FJQC) - Ind.Decrement() - else: - for shareddrive in sds: - _getOrgUnitSharedDriveInfo(shareddrive) - if FJQC.formatJSON: - row = {'name': shareddrive['name']} - row['JSON'] = json.dumps(cleanJSON(shareddrive), ensure_ascii=False, sort_keys=True) - csvPF.WriteRow(row) - else: - csvPF.WriteRowTitles(flattenJSON(shareddrive)) + for shareddrive in sds: + _getOrgUnitSharedDriveInfo(shareddrive) + if FJQC.formatJSON: + row = {'name': shareddrive['name']} + row['JSON'] = json.dumps(cleanJSON(shareddrive), ensure_ascii=False, sort_keys=True) + csvPF.WriteRow(row) + else: + csvPF.WriteRowTitles(flattenJSON(shareddrive)) if csvPF: csvPF.writeCSVfile('OrgUnit {orgUnitPath} SharedDrives') @@ -65758,7 +65754,7 @@ def doCopySyncSharedDriveACLs(): # [oneitemperrow] [maxitems ] # [shownopermissionsdrives false|true|only] # [*|(fields )] -# [formatjsn] +# [formatjson] def printShowSharedDriveACLs(users, useDomainAdminAccess=False): def _printPermissionRow(baserow, permission): row = baserow.copy() @@ -65948,7 +65944,8 @@ def _printPermissionRow(baserow, permission): if jcount == 0: setSysExitRC(NO_ENTITIES_FOUND_RC) if not csvPF: - entityPerformActionNumItems([Ent.USER, user], jcount, Ent.SHAREDDRIVE, i, count) + if not FJQC.formatJSON: + entityPerformActionNumItems([Ent.USER, user], jcount, Ent.SHAREDDRIVE, i, count) Ind.Increment() j = 0 for shareddrive in matchFeed: