Added option addcsvdata <FieldName> <String> to gam report [usage] customers|users
Some checks failed
Build and test GAM / build (false, build, 1, Build Intel Ubuntu Jammy, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (false, build, 10, Build x86_64 macOS 15, macos-15-intel) (push) Has been cancelled
Build and test GAM / build (false, build, 11, Build Arm MacOS 26, macos-26) (push) Has been cancelled
Build and test GAM / build (false, build, 12, Build Intel Windows, windows-2025) (push) Has been cancelled
Build and test GAM / build (false, build, 13, Build Arm Windows, windows-11-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 2, Build Intel Ubuntu Noble, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (false, build, 3, Build Arm Ubuntu Noble, ubuntu-24.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 4, Build Arm Ubuntu Jammy, ubuntu-22.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 5, Build Intel StaticX Legacy, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 6, Build Arm StaticX Legacy, ubuntu-22.04-arm, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 7, Build Intel MacOS, macos-13) (push) Has been cancelled
Build and test GAM / build (false, build, 8, Build Arm MacOS 14, macos-14) (push) Has been cancelled
Build and test GAM / build (false, build, 9, Build Arm MacOS 15, macos-15) (push) Has been cancelled
Build and test GAM / build (false, test, 14, Test Python 3.10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (false, test, 15, Test Python 3.11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (false, test, 16, Test Python 3.12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (false, test, 17, Test Python 3.15-dev, ubuntu-24.04, 3.15-dev) (push) Has been cancelled
Build and test GAM / build (true, test, 18, Test Python 3.14 freethread, ubuntu-24.04, 3.14) (push) Has been cancelled
Build and test GAM / merge (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Check for Google Root CA Updates / check-certs (push) Has been cancelled

This commit is contained in:
Ross Scroggs
2025-10-30 15:47:35 -07:00
parent 213bf45942
commit 6b64879d56
2 changed files with 13 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
7.27.06 7.28.00
Added option `addcsvdata <FieldName> <String>` to `gam report customers|users` Added option `addcsvdata <FieldName> <String>` to `gam report [usage] customers|users`
that adds additional columns of data to the CSV file output. This will be most useful that adds additional columns of data to the CSV file output. This will be most useful
when reading a CSV of user information and you want to include some of the user information, when reading a CSV of user information and you want to include some of the user information,
e.g., orgUnitPath, in the output. e.g., orgUnitPath, in the output.

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
""" """
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>' __author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.27.06' __version__ = '7.28.00'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position #pylint: disable=wrong-import-position
@@ -13411,12 +13411,14 @@ REPORTS_PARAMETERS_SIMPLE_TYPES = ['intValue', 'boolValue', 'datetimeValue', 'st
# [skipdates <Date>[:<Date>](,<Date>[:<Date>])*] [skipdaysofweek <DayOfWeek>(,<DayOfWeek>)*] # [skipdates <Date>[:<Date>](,<Date>[:<Date>])*] [skipdaysofweek <DayOfWeek>(,<DayOfWeek>)*]
# [fields|parameters <String>)] # [fields|parameters <String>)]
# [convertmbtogb] # [convertmbtogb]
# (addcsvdata <FieldName> <String>)*
# gam report usage customer [todrive <ToDriveAttribute>*] # gam report usage customer [todrive <ToDriveAttribute>*]
# [([start|startdate <Date>] [end|enddate <Date>])|(range <Date> <Date>)| # [([start|startdate <Date>] [end|enddate <Date>])|(range <Date> <Date>)|
# thismonth|(previousmonths <Integer>)] # thismonth|(previousmonths <Integer>)]
# [skipdates <Date>[:<Date>](,<Date>[:<Date>])*] [skipdaysofweek <DayOfWeek>(,<DayOfWeek>)*] # [skipdates <Date>[:<Date>](,<Date>[:<Date>])*] [skipdaysofweek <DayOfWeek>(,<DayOfWeek>)*]
# [fields|parameters <String>)] # [fields|parameters <String>)]
# [convertmbtogb] # [convertmbtogb]
# (addcsvdata <FieldName> <String>)*
def doReportUsage(): def doReportUsage():
def usageEntitySelectors(): def usageEntitySelectors():
selectorChoices = Cmd.USER_ENTITY_SELECTORS+Cmd.USER_CSVDATA_ENTITY_SELECTORS selectorChoices = Cmd.USER_ENTITY_SELECTORS+Cmd.USER_CSVDATA_ENTITY_SELECTORS
@@ -13468,6 +13470,7 @@ def doReportUsage():
startEndTime = StartEndTime('startdate', 'enddate', 'date') startEndTime = StartEndTime('startdate', 'enddate', 'date')
skipDayNumbers = [] skipDayNumbers = []
skipDates = set() skipDates = set()
addCSVData = {}
while Cmd.ArgumentsRemaining(): while Cmd.ArgumentsRemaining():
myarg = getArgument() myarg = getArgument()
if csvPF and myarg == 'todrive': if csvPF and myarg == 'todrive':
@@ -13522,6 +13525,9 @@ def doReportUsage():
select = True select = True
elif myarg == 'convertmbtogb': elif myarg == 'convertmbtogb':
convertMbToGb = True convertMbToGb = True
elif myarg == 'addcsvdata':
k = getString(Cmd.OB_STRING)
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
else: else:
unknownArgumentExit() unknownArgumentExit()
if startEndTime.endDateTime is None: if startEndTime.endDateTime is None:
@@ -13555,6 +13561,8 @@ def doReportUsage():
titles.append('orgUnitPath') titles.append('orgUnitPath')
else: else:
pageMessage = None pageMessage = None
if addCSVData:
titles.extend(sorted(addCSVData.keys()))
csvPF.SetTitles(titles) csvPF.SetTitles(titles)
csvPF.SetSortAllTitles() csvPF.SetSortAllTitles()
parameters = ','.join(parameters) if parameters else None parameters = ','.join(parameters) if parameters else None
@@ -13589,6 +13597,8 @@ def doReportUsage():
row['orgUnitPath'] = userOrgUnits.get(row['user'], UNKNOWN) row['orgUnitPath'] = userOrgUnits.get(row['user'], UNKNOWN)
else: else:
row['user'] = UNKNOWN row['user'] = UNKNOWN
if addCSVData:
row.update(addCSVData)
for item in entity.get('parameters', []): for item in entity.get('parameters', []):
if 'name' not in item: if 'name' not in item:
continue continue