Added option oneitemperrow to gam <UserTypeEntity> print calendars ... permissions

This commit is contained in:
Ross Scroggs
2025-11-26 11:40:08 -08:00
parent a08865b0cd
commit e9c11f8b8d
2 changed files with 40 additions and 15 deletions

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.29.00' __version__ = '7.29.01'
__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
@@ -53051,7 +53051,7 @@ CALENDAR_EXCLUDE_DOMAINS = {
# gam <UserTypeEntity> print calendars <UserCalendarEntity> [todrive <ToDriveAttribute>*] # gam <UserTypeEntity> print calendars <UserCalendarEntity> [todrive <ToDriveAttribute>*]
# [primary] <CalendarSelectProperty>* [noprimary] [nogroups] [noresources] [nosystem] [nousers] # [primary] <CalendarSelectProperty>* [noprimary] [nogroups] [noresources] [nosystem] [nousers]
# [fields <CalendarFieldList>] [permissions] # [fields <CalendarFieldList>] [permissions] [oneitemperrow]
# [formatjson [quotechar <Character>]] [delimiter <Character>] # [formatjson [quotechar <Character>]] [delimiter <Character>]
# gam <UserTypeEntity> show calendars <UserCalendarEntity> # gam <UserTypeEntity> show calendars <UserCalendarEntity>
# [primary] <CalendarSelectProperty>* [noprimary] [nogroups] [noresources] [nosystem] [nousers] # [primary] <CalendarSelectProperty>* [noprimary] [nogroups] [noresources] [nosystem] [nousers]
@@ -53059,7 +53059,7 @@ CALENDAR_EXCLUDE_DOMAINS = {
# [formatjson] # [formatjson]
def printShowCalendars(users): def printShowCalendars(users):
acls = [] acls = []
getCalPermissions = noPrimary = primaryOnly = False getCalPermissions = oneItemPerRow = noPrimary = primaryOnly = False
excludes = set() excludes = set()
excludeDomains = set() excludeDomains = set()
csvPF = CSVPrintFile(['primaryEmail', 'calendarId'], 'sortall') if Act.csvFormat() else None csvPF = CSVPrintFile(['primaryEmail', 'calendarId'], 'sortall') if Act.csvFormat() else None
@@ -53073,6 +53073,8 @@ def printShowCalendars(users):
csvPF.GetTodriveParameters() csvPF.GetTodriveParameters()
elif myarg in [Cmd.ARG_ACLS, Cmd.ARG_CALENDARACLS, Cmd.ARG_PERMISSIONS]: elif myarg in [Cmd.ARG_ACLS, Cmd.ARG_CALENDARACLS, Cmd.ARG_PERMISSIONS]:
getCalPermissions = True getCalPermissions = True
elif myarg == 'oneitemperrow':
oneItemPerRow = True
elif myarg == 'allcalendars': elif myarg == 'allcalendars':
pass pass
elif myarg == 'primary': elif myarg == 'primary':
@@ -53148,17 +53150,35 @@ def printShowCalendars(users):
Ind.Decrement() Ind.Decrement()
else: else:
if calendars: if calendars:
for calendar in calendars: if not getCalPermissions or not oneItemPerRow:
row = {'primaryEmail': user, 'calendarId': calendar['id']} for calendar in calendars:
if getCalPermissions: row = {'primaryEmail': user, 'calendarId': calendar['id']}
flattenJSON({'permissions': _getCalendarPermissions(cal, calendar)}, flattened=row) if getCalPermissions:
flattenJSON(calendar, flattened=row, simpleLists=CALENDAR_SIMPLE_LISTS, delimiter=delimiter) calPerms = _getCalendarPermissions(cal, calendar)
if not FJQC.formatJSON: flattenJSON({'permissions': calPerms}, flattened=row)
row.pop('id') flattenJSON(calendar, flattened=row, simpleLists=CALENDAR_SIMPLE_LISTS, delimiter=delimiter)
csvPF.WriteRowTitles(row) if not FJQC.formatJSON:
elif csvPF.CheckRowTitles(row): row.pop('id')
csvPF.WriteRowNoFilter({'primaryEmail': user, 'calendarId': calendar['id'], csvPF.WriteRowTitles(row)
'JSON': json.dumps(cleanJSON(calendar), ensure_ascii=False, sort_keys=True)}) elif csvPF.CheckRowTitles(row):
if getCalPermissions:
calendar.update({'permissions': calPerms})
csvPF.WriteRowNoFilter({'primaryEmail': user, 'calendarId': calendar['id'],
'JSON': json.dumps(cleanJSON(calendar), ensure_ascii=False, sort_keys=True)})
else:
for calendar in calendars:
baserow = {'primaryEmail': user, 'calendarId': calendar['id']}
flattenJSON(calendar, flattened=baserow, simpleLists=CALENDAR_SIMPLE_LISTS, delimiter=delimiter)
for permission in _getCalendarPermissions(cal, calendar):
row = baserow.copy()
flattenJSON({'permission': permission}, flattened=row)
if not FJQC.formatJSON:
row.pop('id')
csvPF.WriteRowTitles(row)
elif csvPF.CheckRowTitles(row):
calendar.update({'permission': permission})
csvPF.WriteRowNoFilter({'primaryEmail': user, 'calendarId': calendar['id'],
'JSON': json.dumps(cleanJSON(calendar), ensure_ascii=False, sort_keys=True)})
elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT]: elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT]:
csvPF.WriteRowNoFilter({'primaryEmail': user}) csvPF.WriteRowNoFilter({'primaryEmail': user})
if csvPF: if csvPF:
@@ -53630,7 +53650,7 @@ def emptyCalendarTrash(users):
# gam <UserTypeEntity> update calattendees <UserCalendarEntity> <EventEntity> [anyorganizer] # gam <UserTypeEntity> update calattendees <UserCalendarEntity> <EventEntity> [anyorganizer]
# [<EventNotificationAttribute>] [splitupdate] [doit] # [<EventNotificationAttribute>] [splitupdate] [doit]
# (<CSVFileSelector>) # (csv|csvfile <CSVFileInput> endcsv)
# (delete <EmailAddress>)* # (delete <EmailAddress>)*
# (deleteentity <EmailAddressEntity>)* # (deleteentity <EmailAddressEntity>)*
# (add <EmailAddress>)* # (add <EmailAddress>)*

View File

@@ -10,6 +10,11 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads-Installs-GAM7](https://github.com/GAM-team/GAM/wiki/Downloads-Installs) for Windows or other options, including manual installation See [Downloads-Installs-GAM7](https://github.com/GAM-team/GAM/wiki/Downloads-Installs) for Windows or other options, including manual installation
### 7.29.01
Added option `oneitemperrow` to `gam <UserTypeEntity> print calendars ... permissions` to have each of a
calendar's permissions displayed on a separate row with all of the other calendar fields.
### 7.29.00 ### 7.29.00
Added options `mappermissionsemail <EmailAddress> <EmailAddress>` and ` mappermissionsemailfile <CSVFileInput> endcsv` Added options `mappermissionsemail <EmailAddress> <EmailAddress>` and ` mappermissionsemailfile <CSVFileInput> endcsv`