Added option addcsvdata <FieldName> <String> to 1print events`
Some checks failed
Push wiki / pushwiki (push) Has been cancelled
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.14-dev, ubuntu-24.04, 3.14-dev) (push) Has been cancelled
Build and test GAM / build (true, test, 18, Test Python 3.14-dev freethread, ubuntu-24.04, 3.14-dev) (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-01 16:03:32 -07:00
parent a0cd228110
commit fea94fcc1c
3 changed files with 118 additions and 71 deletions

View File

@@ -1932,12 +1932,12 @@ gam calendar|calendars <CalendarEntity> info events [<EventEntity>] [maxinstance
[formatjson] [formatjson]
gam calendar|calendars <CalendarEntity> show events [<EventEntity>] <EventDisplayProperty>* gam calendar|calendars <CalendarEntity> show events [<EventEntity>] <EventDisplayProperty>*
[fields <EventFieldNameList>] [showdayofweek] [fields <EventFieldNameList>] [showdayofweek]
[countsonly] [countsonly|formatjson]
[formatjson]
gam calendar|calendars <CalendarEntity> print events [<EventEntity>] <EventDisplayProperty>* gam calendar|calendars <CalendarEntity> print events [<EventEntity>] <EventDisplayProperty>*
[fields <EventFieldNameList>] [showdayofweek] [fields <EventFieldNameList>] [showdayofweek]
[countsonly [eventrowfilter]] (addcsvdata <FieldName> <String>)*
[formatjson [quotechar <Character>]] [todrive <ToDriveAttribute>*] [eventrowfilter]
[countsonly|(formatjson [quotechar <Character>])] [todrive <ToDriveAttribute>*]
gam calendar <CalendarEntity> addevent <EventAttribute>+ [<EventNotificationAttribute>] gam calendar <CalendarEntity> addevent <EventAttribute>+ [<EventNotificationAttribute>]
[showdayofweek] [showdayofweek]
@@ -3745,16 +3745,14 @@ gam print domaincontacts|peoplecontacts [todrive <ToDriveAttribute>*]
[sources <PeopleSourceName>] [sources <PeopleSourceName>]
[query <String>] [query <String>]
[mergesources <PeopleMergeSourceName>] [mergesources <PeopleMergeSourceName>]
[coountsonly]
[allfields|(fields <PeopleFieldNameList>)] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
[formatjson [quotechar <Character>]] [coountsonly|(formatjson [quotechar <Character>])]
gam show domaincontacts|peoplecontacts gam show domaincontacts|peoplecontacts
[sources <PeopleSourceName>] [sources <PeopleSourceName>]
[query <String>] [query <String>]
[mergesources <PeopleMergeSourceName>] [mergesources <PeopleMergeSourceName>]
[coountsonly]
[allfields|(fields <PeopleFieldNameList>)] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
[formatjson] [coountsonly|formatjson]
gam info people|peopleprofile <PeopleResourceNameEntity> gam info people|peopleprofile <PeopleResourceNameEntity>
[allfields|(fields <PeopleFieldNameList>)] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
@@ -3762,15 +3760,13 @@ gam info people|peopleprofile <PeopleResourceNameEntity>
gam print people|peopleprofile [todrive <ToDriveAttribute>*] gam print people|peopleprofile [todrive <ToDriveAttribute>*]
[query <String>] [query <String>]
[mergesources <PeopleMergeSourceName>] [mergesources <PeopleMergeSourceName>]
[coountsonly]
[allfields|(fields <PeopleFieldNameList>)] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
[formatjson [quotechar <Character>]] [coountsonly|(formatjson [quotechar <Character>])]
gam show people|peopleprofile gam show people|peopleprofile
[query <String>] [query <String>]
[mergesources <PeopleMergeSourceName>] [mergesources <PeopleMergeSourceName>]
[coountsonly]
[allfields|(fields <PeopleFieldNameList>)] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
[formatjson] [coountsonly|formatjson]
# Email Audit Monitor # Email Audit Monitor
@@ -6315,12 +6311,11 @@ gam <UserTypeEntity> info events <UserCalendarEntity> [<EventEntity>] [maxinstan
[formatjson] [formatjson]
gam <UserTypeEntity> show events <UserCalendarEntity> [<EventEntity>] <EventDisplayProperty>* gam <UserTypeEntity> show events <UserCalendarEntity> [<EventEntity>] <EventDisplayProperty>*
[fields <EventFieldNameList>] [showdayofweek] [fields <EventFieldNameList>] [showdayofweek]
[countsonly] [countsonly|formatjson]
[formatjson]
gam <UserTypeEntity> print events <UserCalendarEntity> [<EventEntity>] <EventDisplayProperty>* gam <UserTypeEntity> print events <UserCalendarEntity> [<EventEntity>] <EventDisplayProperty>*
[fields <EventFieldNameList>] [showdayofweek] [fields <EventFieldNameList>] [showdayofweek]
[countsonly [eventrowfilter]] [eventrowfilter]]
[formatjson [quotechar <Character>]] [todrive <ToDriveAttribute>*] [countsonly|(formatjson [quotechar <Character>])] [todrive <ToDriveAttribute>*]
gam <UserTypeEntity> update calattendees <UserCalendarEntity> <EventEntity> [anyorganizer] gam <UserTypeEntity> update calattendees <UserCalendarEntity> <EventEntity> [anyorganizer]
[<EventNotificationAttribute>] [splitupdate] [dryrun|doit] [<EventNotificationAttribute>] [splitupdate] [dryrun|doit]
@@ -8344,13 +8339,13 @@ gam <UserTypeEntity> info contacts
gam <UserTypeEntity> show contacts gam <UserTypeEntity> show contacts
<PeoplePrintShowUserContactSelection> <PeoplePrintShowUserContactSelection>
[orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending) [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending)
[countsonly|allfields|(fields <PeopleFieldNameList>)] [showgroups] [showmetadata] [allfields|(fields <PeopleFieldNameList>)] [showgroups] [showmetadata]
[formatjson] [countsonly|formatjson]
gam <UserTypeEntity> print contacts [todrive <ToDriveAttribute>*] gam <UserTypeEntity> print contacts [todrive <ToDriveAttribute>*]
<PeoplePrintShowUserContactSelection> <PeoplePrintShowUserContactSelection>
[orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending) [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending)
[countsonly|allfields|(fields <PeopleFieldNameList>)] [[showgroups|showgroupnameslist] showmetadata] [allfields|(fields <PeopleFieldNameList>)] [[showgroups|showgroupnameslist] showmetadata]
[formatjson [quotechar <Character>]] [countsonly|(formatjson [quotechar <Character>])]
<OtherContactsFieldName> ::= <OtherContactsFieldName> ::=
emailaddresses| emailaddresses|
@@ -8584,7 +8579,7 @@ gam <UserTypeEntity> info tasklist <TasklistEntity>
gam <UserTypeEntity> show tasklists gam <UserTypeEntity> show tasklists
[countsonly|formatjson] [countsonly|formatjson]
gam <UserTypeEntity> print tasklists [todrive <ToDriveAttribute>*] gam <UserTypeEntity> print tasklists [todrive <ToDriveAttribute>*]
[countsonly | (formatjson [quotechar <Character>])] [countsonly|(formatjson [quotechar <Character>])]
# Users - Shared Drives # Users - Shared Drives

View File

@@ -1,3 +1,15 @@
7.23.04
Added option `addcsvdata <FieldName> <String>` to `gam <UserTypeEntity> print events`
and `gam calendars <CalendarEntity> print events` that adds additional columns of data to the CSV file output.
An example would be to get the calendar name in addition to the calendar ID when printing events.
```
gam redirect csv ./Resources.csv print resources fields email,name
gam redirect csv ./ResourceEventCounts.csv multiprocess redirect stderr - multiprocess csv Resources.csv gam calendar "~resourceEmail" print events starttime -1y countsonly addcsvdata calendarName "~resourceName"
```
Upgraded to OpenSSL 3.6.0.
7.23.03 7.23.03
Upgraded to OpenSSL 3.5.4. Upgraded to OpenSSL 3.5.4.

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.23.03' __version__ = '7.23.04'
__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
@@ -7868,6 +7868,13 @@ class CSVPrintFile():
if title not in self.titlesSet: if title not in self.titlesSet:
self.AddTitle(title) self.AddTitle(title)
def InsertTitles(self, position, titles):
for title in titles if isinstance(titles, list) else [titles]:
if title not in self.titlesSet:
self.titlesSet.add(title)
self.titlesList.insert(position, title)
position += 1
def SetTitles(self, titles): def SetTitles(self, titles):
self.titlesSet = set() self.titlesSet = set()
self.titlesList = [] self.titlesList = []
@@ -22429,12 +22436,12 @@ def infoUserPeopleContacts(users):
# gam <UserTypeEntity> print contacts [todrive <ToDriveAttribute>*] <PeoplePrintShowUserContactSelection> # gam <UserTypeEntity> print contacts [todrive <ToDriveAttribute>*] <PeoplePrintShowUserContactSelection>
# [showgroups|showgroupnameslist] [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending) # [showgroups|showgroupnameslist] [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending)
# [countsonly|allfields|fields <PeopleFieldNameList>] [showmetadata] # [allfields|fields <PeopleFieldNameList>] [showmetadata]
# [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
# gam <UserTypeEntity> show contacts <PeoplePrintShowUserContactSelection> # gam <UserTypeEntity> show contacts <PeoplePrintShowUserContactSelection>
# [showgroups] [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending) # [showgroups] [orderby firstname|lastname|(lastmodified ascending)|(lastnodified descending)
# [countsonly|allfields|(fields <PeopleFieldNameList>)] [showmetadata] # [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
# [formatjson] # [countsonly|formatjson]
def printShowUserPeopleContacts(users): def printShowUserPeopleContacts(users):
entityType = Ent.USER entityType = Ent.USER
entityTypeName = Ent.Singular(entityType) entityTypeName = Ent.Singular(entityType)
@@ -22473,6 +22480,8 @@ def printShowUserPeopleContacts(users):
else: else:
FJQC.GetFormatJSONQuoteChar(myarg, True) FJQC.GetFormatJSONQuoteChar(myarg, True)
if countsOnly: if countsOnly:
if csvPF:
csvPF.SetFormatJSON(False)
fieldsList = ['emailAddresses'] fieldsList = ['emailAddresses']
if contactQuery['mainContacts']: if contactQuery['mainContacts']:
fields = _getPersonFields(PEOPLE_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters) fields = _getPersonFields(PEOPLE_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters)
@@ -22710,11 +22719,11 @@ def processUserPeopleOtherContacts(users):
Ind.Decrement() Ind.Decrement()
# gam <UserTypeEntity> print othercontacts [todrive <ToDriveAttribute>*] <OtherContactSelection> # gam <UserTypeEntity> print othercontacts [todrive <ToDriveAttribute>*] <OtherContactSelection>
# [countsonly|allfields|(fields <OtherContactFieldNameList>)] [showmetadata] # [allfields|(fields <OtherContactFieldNameList>)] [showmetadata]
# [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
# gam <UserTypeEntity> show othercontacts <OtherContactSelection> # gam <UserTypeEntity> show othercontacts <OtherContactSelection>
# [countsonly|allfields|(fields <OtherContactFieldNameList>)] [showmetadata] # [allfields|(fields <OtherContactFieldNameList>)] [showmetadata]
# [formatjson] # [countsonly|formatjson]
def printShowUserPeopleOtherContacts(users): def printShowUserPeopleOtherContacts(users):
entityType = Ent.USER entityType = Ent.USER
entityTypeName = Ent.Singular(entityType) entityTypeName = Ent.Singular(entityType)
@@ -22744,6 +22753,8 @@ def printShowUserPeopleOtherContacts(users):
else: else:
FJQC.GetFormatJSONQuoteChar(myarg, True) FJQC.GetFormatJSONQuoteChar(myarg, True)
if countsOnly: if countsOnly:
if csvPF:
csvPF.SetFormatJSON(False)
fieldsList = ['emailAddresses'] fieldsList = ['emailAddresses']
fields = _getPersonFields(PEOPLE_OTHER_CONTACTS_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters) fields = _getPersonFields(PEOPLE_OTHER_CONTACTS_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters)
i, count, users = getEntityArgument(users) i, count, users = getEntityArgument(users)
@@ -22813,6 +22824,8 @@ def _printShowPeople(source):
function = 'searchDirectoryPeople' function = 'searchDirectoryPeople'
else: else:
FJQC.GetFormatJSONQuoteChar(myarg, True) FJQC.GetFormatJSONQuoteChar(myarg, True)
if countsOnly and csvPF:
csvPF.SetFormatJSON(False)
fields = _getPersonFields(PEOPLE_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters) fields = _getPersonFields(PEOPLE_FIELDS_CHOICE_MAP, PEOPLE_CONTACTS_DEFAULT_FIELDS, fieldsList, parameters)
printGettingAllEntityItemsForWhom(peopleEntityType, GC.Values[GC.DOMAIN], query=kwargs.get('query')) printGettingAllEntityItemsForWhom(peopleEntityType, GC.Values[GC.DOMAIN], query=kwargs.get('query'))
try: try:
@@ -22850,29 +22863,24 @@ def doInfoDomainPeopleContacts():
# gam print people|peopleprofile [todrive <ToDriveAttribute>*] # gam print people|peopleprofile [todrive <ToDriveAttribute>*]
# [query <String>] # [query <String>]
# [mergesources <PeopleMergeSourceName>] # [mergesources <PeopleMergeSourceName>]
# [countsonly]
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata] # [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
# [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
# gam show people|peopleprofile # gam show people|peopleprofile
# [query <String>] # [query <String>]
# [mergesources <PeopleMergeSourceName>] # [mergesources <PeopleMergeSourceName>]
# [countsonly]
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata] # [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
# [formatjson] # [countsonlyformatjson]
# gam print domaincontacts|peoplecontacts [todrive <ToDriveAttribute>*] # gam print domaincontacts|peoplecontacts [todrive <ToDriveAttribute>*]
# [sources <PeopleSourceName>] # [sources <PeopleSourceName>]
# [query <String>] # [query <String>]
# [mergesources <PeopleMergeSourceName>] # [mergesources <PeopleMergeSourceName>]
# [countsonly]
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata] # [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
# [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
# gam show domaincontacts|peoplecontacts # gam show domaincontacts|peoplecontacts
# [sources <PeopleSourceName>] # [sources <PeopleSourceName>]
# [query <String>] # [query <String>]
# [mergesources <PeopleMergeSourceName>] # [mergesources <PeopleMergeSourceName>]
# [countsonly] # [countsonlyformatjson]
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
# [formatjson]
def doPrintShowDomainPeopleProfiles(): def doPrintShowDomainPeopleProfiles():
_printShowPeople('profile') _printShowPeople('profile')
@@ -40125,7 +40133,7 @@ def _createCalendarEvents(user, origCal, function, calIds, count, body, paramete
else: else:
if parameters['showDayOfWeek']: if parameters['showDayOfWeek']:
_getEventDaysOfWeek(event) _getEventDaysOfWeek(event)
_printCalendarEvent(user, calId, event, parameters['csvPF'], parameters['FJQC']) _printCalendarEvent(user, calId, event, parameters['csvPF'], parameters['FJQC'], {})
except (GAPI.invalid, GAPI.required, GAPI.timeRangeEmpty, GAPI.eventDurationExceedsLimit, except (GAPI.invalid, GAPI.required, GAPI.timeRangeEmpty, GAPI.eventDurationExceedsLimit,
GAPI.requiredAccessLevel, GAPI.participantIsNeitherOrganizerNorAttendee, GAPI.requiredAccessLevel, GAPI.participantIsNeitherOrganizerNorAttendee,
GAPI.malformedWorkingLocationEvent, GAPI.badRequest) as e: GAPI.malformedWorkingLocationEvent, GAPI.badRequest) as e:
@@ -40229,7 +40237,7 @@ def _updateCalendarEvents(origUser, user, origCal, calIds, count, calendarEventE
else: else:
if parameters['showDayOfWeek']: if parameters['showDayOfWeek']:
_getEventDaysOfWeek(event) _getEventDaysOfWeek(event)
_printCalendarEvent(user, calId, event, parameters['csvPF'], parameters['FJQC']) _printCalendarEvent(user, calId, event, parameters['csvPF'], parameters['FJQC'], {})
except (GAPI.notFound, GAPI.deleted) as e: except (GAPI.notFound, GAPI.deleted) as e:
if not checkCalendarExists(cal, calId, j, jcount): if not checkCalendarExists(cal, calId, j, jcount):
entityUnknownWarning(Ent.CALENDAR, calId, j, jcount) entityUnknownWarning(Ent.CALENDAR, calId, j, jcount)
@@ -40526,10 +40534,12 @@ def _showCalendarEvent(primaryEmail, calId, eventEntityType, event, k, kcount, F
showJSON(None, event, skipObjects) showJSON(None, event, skipObjects)
Ind.Decrement() Ind.Decrement()
def _printCalendarEvent(user, calId, event, csvPF, FJQC): def _printCalendarEvent(user, calId, event, csvPF, FJQC, addCSVData):
row = {'calendarId': calId, 'id': event['id']} row = {'calendarId': calId, 'id': event['id']}
if user: if user:
row['primaryEmail'] = user row['primaryEmail'] = user
if addCSVData:
row.update(addCSVData)
flattenJSON(event, flattened=row, timeObjects=EVENT_TIME_OBJECTS) flattenJSON(event, flattened=row, timeObjects=EVENT_TIME_OBJECTS)
if not FJQC.formatJSON: if not FJQC.formatJSON:
csvPF.WriteRowTitles(row) csvPF.WriteRowTitles(row)
@@ -40542,7 +40552,7 @@ def _printCalendarEvent(user, calId, event, csvPF, FJQC):
csvPF.WriteRowNoFilter(row) csvPF.WriteRowNoFilter(row)
def _printShowCalendarEvents(origUser, user, origCal, calIds, count, calendarEventEntity, def _printShowCalendarEvents(origUser, user, origCal, calIds, count, calendarEventEntity,
csvPF, FJQC, fieldsList): csvPF, FJQC, fieldsList, addCSVData):
i = 0 i = 0
for calId in calIds: for calId in calIds:
i += 1 i += 1
@@ -40568,7 +40578,7 @@ def _printShowCalendarEvents(origUser, user, origCal, calIds, count, calendarEve
for event in events: for event in events:
if calendarEventEntity['showDayOfWeek']: if calendarEventEntity['showDayOfWeek']:
_getEventDaysOfWeek(event) _getEventDaysOfWeek(event)
_printCalendarEvent(user, calId, event, csvPF, FJQC) _printCalendarEvent(user, calId, event, csvPF, FJQC, addCSVData)
elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT] and user: elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT] and user:
csvPF.WriteRowNoFilter({'calendarId': calId, 'primaryEmail': user, 'id': ''}) csvPF.WriteRowNoFilter({'calendarId': calId, 'primaryEmail': user, 'id': ''})
else: else:
@@ -40586,6 +40596,8 @@ def _printShowCalendarEvents(origUser, user, origCal, calIds, count, calendarEve
row = {'calendarId': calId} row = {'calendarId': calId}
if user: if user:
row['primaryEmail'] = user row['primaryEmail'] = user
if addCSVData:
row.update(addCSVData)
row['events'] = jcount row['events'] = jcount
if not calendarEventEntity['eventRowFilter']: if not calendarEventEntity['eventRowFilter']:
csvPF.WriteRow(row) csvPF.WriteRow(row)
@@ -40816,6 +40828,8 @@ def _getCalendarPrintShowEventOptions(calendarEventEntity, entityType):
csvPF = CSVPrintFile(['primaryEmail', 'calendarId', 'id'] if entityType == Ent.USER else ['calendarId', 'id'], 'sortall', indexedTitles=EVENT_INDEXED_TITLES) if Act.csvFormat() else None csvPF = CSVPrintFile(['primaryEmail', 'calendarId', 'id'] if entityType == Ent.USER else ['calendarId', 'id'], 'sortall', indexedTitles=EVENT_INDEXED_TITLES) if Act.csvFormat() else None
FJQC = FormatJSONQuoteChar(csvPF) FJQC = FormatJSONQuoteChar(csvPF)
fieldsList = [] fieldsList = []
addCSVData = {}
addCSVDataLoc = 2 if entityType == Ent.USER else 1
while Cmd.ArgumentsRemaining(): while Cmd.ArgumentsRemaining():
myarg = getArgument() myarg = getArgument()
if csvPF and myarg == 'todrive': if csvPF and myarg == 'todrive':
@@ -40824,6 +40838,9 @@ def _getCalendarPrintShowEventOptions(calendarEventEntity, entityType):
pass pass
elif myarg == 'fields': elif myarg == 'fields':
_getEventFields(fieldsList) _getEventFields(fieldsList)
elif csvPF and myarg == 'addcsvdata':
k = getString(Cmd.OB_STRING)
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
elif myarg == 'countsonly': elif myarg == 'countsonly':
calendarEventEntity['countsOnly'] = True calendarEventEntity['countsOnly'] = True
elif myarg == 'showdayofweek': elif myarg == 'showdayofweek':
@@ -40836,27 +40853,35 @@ def _getCalendarPrintShowEventOptions(calendarEventEntity, entityType):
fieldsList = ['id'] fieldsList = ['id']
if csvPF: if csvPF:
if calendarEventEntity['countsOnly']: if calendarEventEntity['countsOnly']:
csvPF.SetFormatJSON(False)
csvPF.RemoveTitles(['id']) csvPF.RemoveTitles(['id'])
if addCSVData:
csvPF.InsertTitles(addCSVDataLoc, sorted(addCSVData.keys()))
csvPF.AddTitles(['events']) csvPF.AddTitles(['events'])
csvPF.SetSortAllTitles()
calendarEventEntity['countsOnlyTitles'] = csvPF.titlesList[:] calendarEventEntity['countsOnlyTitles'] = csvPF.titlesList[:]
elif not FJQC.formatJSON and not fieldsList: else:
csvPF.AddSortTitles(EVENT_PRINT_ORDER) if addCSVData:
csvPF.InsertTitles(addCSVDataLoc, sorted(addCSVData.keys()))
if not FJQC.formatJSON and not fieldsList:
csvPF.AddTitles(EVENT_PRINT_ORDER)
csvPF.SetSortAllTitles()
_addEventEntitySelectFields(calendarEventEntity, fieldsList) _addEventEntitySelectFields(calendarEventEntity, fieldsList)
return (csvPF, FJQC, fieldsList) return (csvPF, FJQC, fieldsList, addCSVData)
# gam calendars <CalendarEntity> print events <EventEntity> <EventDisplayProperties>* # gam calendars <CalendarEntity> print events <EventEntity> <EventDisplayProperties>*
# [fields <EventFieldNameList>] [showdayofweek] # [fields <EventFieldNameList>] [showdayofweek]
# [countsonly [eventrowfilter]] # (addcsvdata <FieldName> <String>)*
# [formatjson [quotechar <Character>]] [todrive <ToDriveAttribute>*] # [eventrowfilter]
# [countsonly|(formatjson [quotechar <Character>])] [todrive <ToDriveAttribute>*]
# gam calendars <CalendarEntity> show events <EventEntity> <EventDisplayProperties>* # gam calendars <CalendarEntity> show events <EventEntity> <EventDisplayProperties>*
# [fields <EventFieldNameList>] [showdayofweek] # [fields <EventFieldNameList>] [showdayofweek]
# [countsonly] # [countsonly|formatjson]
# [formatjson]
def doCalendarsPrintShowEvents(calIds): def doCalendarsPrintShowEvents(calIds):
calendarEventEntity = getCalendarEventEntity() calendarEventEntity = getCalendarEventEntity()
csvPF, FJQC, fieldsList = _getCalendarPrintShowEventOptions(calendarEventEntity, Ent.CALENDAR) csvPF, FJQC, fieldsList, addCSVData = _getCalendarPrintShowEventOptions(calendarEventEntity, Ent.CALENDAR)
_printShowCalendarEvents(None, None, None, calIds, len(calIds), calendarEventEntity, _printShowCalendarEvents(None, None, None, calIds, len(calIds), calendarEventEntity,
csvPF, FJQC, fieldsList) csvPF, FJQC, fieldsList, addCSVData)
if csvPF: if csvPF:
if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']: if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']:
csvPF.SetTitles(calendarEventEntity['countsOnlyTitles']) csvPF.SetTitles(calendarEventEntity['countsOnlyTitles'])
@@ -48863,13 +48888,15 @@ def _doInfoCourses(courseIdList):
# gam info courses <CourseEntity> [owneraccess] # gam info courses <CourseEntity> [owneraccess]
# [owneremail] [alias|aliases] [show none|all|students|teachers] [countsonly] # [owneremail] [alias|aliases] [show none|all|students|teachers] [countsonly]
# [fields <CourseFieldNameList>] [skipfields <CourseFieldNameList>] [formatjson] # [fields <CourseFieldNameList>] [skipfields <CourseFieldNameList>]
# [formatjson]
def doInfoCourses(): def doInfoCourses():
_doInfoCourses(getEntityList(Cmd.OB_COURSE_ENTITY, shlexSplit=True)) _doInfoCourses(getEntityList(Cmd.OB_COURSE_ENTITY, shlexSplit=True))
# gam info course <CourseID> [owneraccess] # gam info course <CourseID> [owneraccess]
# [owneremail] [alias|aliases] [show none|all|students|teachers] [countsonly] # [owneremail] [alias|aliases] [show none|all|students|teachers] [countsonly]
# [fields <CourseFieldNameList>] [skipfields <CourseFieldNameList>] [formatjson] # [fields <CourseFieldNameList>] [skipfields <CourseFieldNameList>]
# [formatjson]
def doInfoCourse(): def doInfoCourse():
_doInfoCourses(getStringReturnInList(Cmd.OB_COURSE_ID)) _doInfoCourses(getStringReturnInList(Cmd.OB_COURSE_ID))
@@ -49187,7 +49214,7 @@ COURSE_ANNOUNCEMENTS_INDEXED_TITLES = ['materials']
# (orderby <CourseAnnouncementOrderByFieldName> [ascending|descending])*) # (orderby <CourseAnnouncementOrderByFieldName> [ascending|descending])*)
# [showcreatoremails|creatoremail] [fields <CourseAnnouncementFieldNameList>] # [showcreatoremails|creatoremail] [fields <CourseAnnouncementFieldNameList>]
# [timefilter creationtime|updatetime|scheduledtime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>] # [timefilter creationtime|updatetime|scheduledtime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>]
# [countsonly] [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
def doPrintCourseAnnouncements(): def doPrintCourseAnnouncements():
def _printCourseAnnouncement(course, courseAnnouncement, i, count): def _printCourseAnnouncement(course, courseAnnouncement, i, count):
if applyCourseItemFilter and not _courseItemPassesFilter(courseAnnouncement, courseItemFilter): if applyCourseItemFilter and not _courseItemPassesFilter(courseAnnouncement, courseItemFilter):
@@ -49243,6 +49270,8 @@ def doPrintCourseAnnouncements():
coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties) coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties)
if coursesInfo is None: if coursesInfo is None:
return return
if countsOnly:
csvPF.SetFormatJSON(False)
applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList) applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList)
if showCreatorEmail and fieldsList: if showCreatorEmail and fieldsList:
fieldsList.append('creatorUserId') fieldsList.append('creatorUserId')
@@ -49299,7 +49328,7 @@ COURSE_TOPICS_SORT_TITLES = ['courseId', 'courseName', 'topicId', 'name', 'updat
# (course|class <CourseEntity>)*|([teacher <UserItem>] [student <UserItem>] states <CourseStateList>]) # (course|class <CourseEntity>)*|([teacher <UserItem>] [student <UserItem>] states <CourseStateList>])
# [topicids <CourseTopicIDEntity>] # [topicids <CourseTopicIDEntity>]
# [timefilter updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>] # [timefilter updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>]
# [countsonly] [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
def doPrintCourseTopics(): def doPrintCourseTopics():
def _printCourseTopic(course, courseTopic): def _printCourseTopic(course, courseTopic):
if applyCourseItemFilter and not _courseItemPassesFilter(courseTopic, courseItemFilter): if applyCourseItemFilter and not _courseItemPassesFilter(courseTopic, courseItemFilter):
@@ -49340,6 +49369,8 @@ def doPrintCourseTopics():
coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties) coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties)
if coursesInfo is None: if coursesInfo is None:
return return
if countsOnly:
csvPF.SetFormatJSON(False)
applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList) applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList)
courseTopicIdsLists = courseTopicIds if isinstance(courseTopicIds, dict) else None courseTopicIdsLists = courseTopicIds if isinstance(courseTopicIds, dict) else None
i = 0 i = 0
@@ -49584,6 +49615,8 @@ def doPrintCourseWM(entityIDType, entityStateType):
coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties) coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties)
if coursesInfo is None: if coursesInfo is None:
return return
if countsOnly:
csvPF.SetFormatJSON(False)
applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList) applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList)
courseWMIds = courseWMSelectionParameters['courseWMIds'] courseWMIds = courseWMSelectionParameters['courseWMIds']
courseWMIdsLists = courseWMIds if isinstance(courseWMIds, dict) else {} courseWMIdsLists = courseWMIds if isinstance(courseWMIds, dict) else {}
@@ -49639,7 +49672,7 @@ def doPrintCourseWM(entityIDType, entityStateType):
# [showcreatoremails|creatoremail] [showtopicnames] [fields <CourseMaterialFieldNameList>] # [showcreatoremails|creatoremail] [showtopicnames] [fields <CourseMaterialFieldNameList>]
# [timefilter creationtime|updatetime|scheduledtime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>] # [timefilter creationtime|updatetime|scheduledtime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>]
# [oneitemperrow] # [oneitemperrow]
# [countsonly] [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
def doPrintCourseMaterials(): def doPrintCourseMaterials():
doPrintCourseWM(Ent.COURSE_MATERIAL_ID, Ent.COURSE_MATERIAL_STATE) doPrintCourseWM(Ent.COURSE_MATERIAL_ID, Ent.COURSE_MATERIAL_STATE)
@@ -49651,7 +49684,7 @@ def doPrintCourseMaterials():
# [showstudentsaslist [<Boolean>]] [delimiter <Character>] # [showstudentsaslist [<Boolean>]] [delimiter <Character>]
# [timefilter creationtime|updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>] # [timefilter creationtime|updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>]
# [oneitemperrow] # [oneitemperrow]
# [countsonly] [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
def doPrintCourseWork(): def doPrintCourseWork():
doPrintCourseWM(Ent.COURSE_WORK_ID, Ent.COURSE_WORK_STATE) doPrintCourseWM(Ent.COURSE_WORK_ID, Ent.COURSE_WORK_STATE)
@@ -49695,7 +49728,7 @@ def _gettingCourseSubmissionQuery(courseSubmissionStates, late, userId):
# (submissionids <CourseSubmissionIDEntity>)|((submissionstates <CourseSubmissionStateList>)*) [late|notlate] # (submissionids <CourseSubmissionIDEntity>)|((submissionstates <CourseSubmissionStateList>)*) [late|notlate]
# [fields <CourseSubmissionFieldNameList>] [showuserprofile] # [fields <CourseSubmissionFieldNameList>] [showuserprofile]
# [timefilter creationtime|updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>] # [timefilter creationtime|updatetime] [start|starttime <Date>|<Time>] [end|endtime <Date>|<Time>]
# [countsonly] [formatjson [quotechar <Character>]] # [countsonly|(formatjson [quotechar <Character>])]
def doPrintCourseSubmissions(): def doPrintCourseSubmissions():
def _printCourseSubmission(course, courseSubmission): def _printCourseSubmission(course, courseSubmission):
if applyCourseItemFilter and not _courseItemPassesFilter(courseSubmission, courseItemFilter): if applyCourseItemFilter and not _courseItemPassesFilter(courseSubmission, courseItemFilter):
@@ -49777,6 +49810,8 @@ def doPrintCourseSubmissions():
coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getOwnerId=True) coursesInfo = _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getOwnerId=True)
if coursesInfo is None: if coursesInfo is None:
return return
if countsOnly:
csvPF.SetFormatJSON(False)
applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList) applyCourseItemFilter = _setApplyCourseItemFilter(courseItemFilter, fieldsList)
courseWorkIds = courseWMSelectionParameters['courseWMIds'] courseWorkIds = courseWMSelectionParameters['courseWMIds']
courseWorkIdsLists = courseWorkIds if isinstance(courseWorkIds, dict) else {} courseWorkIdsLists = courseWorkIds if isinstance(courseWorkIds, dict) else {}
@@ -53523,16 +53558,16 @@ def infoCalendarEvents(users):
# gam <UserTypeEntity> print events <UserCalendarEntity> <EventEntity> <EventDisplayProperties>* # gam <UserTypeEntity> print events <UserCalendarEntity> <EventEntity> <EventDisplayProperties>*
# [fields <EventFieldNameList>] [showdayofweek] # [fields <EventFieldNameList>] [showdayofweek]
# [countsonly [eventrowfilter]] # (addcsvdata <FieldName> <String>)*
# [formatjson [quotechar <Character>]] [todrive <ToDriveAttribute>*] # [eventrowfilter]
# [countsonly|(formatjson [quotechar <Character>])] [todrive <ToDriveAttribute>*]
# gam <UserTypeEntity> show events <UserCalendarEntity> <EventEntity> <EventDisplayProperties>* # gam <UserTypeEntity> show events <UserCalendarEntity> <EventEntity> <EventDisplayProperties>*
# [fields <EventFieldNameList>] [showdayofweek] # [fields <EventFieldNameList>] [showdayofweek]
# [countsonly]] # ~[countsonly|formatjson]
# [formatjson]
def printShowCalendarEvents(users): def printShowCalendarEvents(users):
calendarEntity = getUserCalendarEntity() calendarEntity = getUserCalendarEntity()
calendarEventEntity = getCalendarEventEntity() calendarEventEntity = getCalendarEventEntity()
csvPF, FJQC, fieldsList = _getCalendarPrintShowEventOptions(calendarEventEntity, Ent.USER) csvPF, FJQC, fieldsList, addCSVData = _getCalendarPrintShowEventOptions(calendarEventEntity, Ent.USER)
i, count, users = getEntityArgument(users) i, count, users = getEntityArgument(users)
for user in users: for user in users:
i += 1 i += 1
@@ -53543,7 +53578,7 @@ def printShowCalendarEvents(users):
continue continue
Ind.Increment() Ind.Increment()
_printShowCalendarEvents(origUser, user, cal, calIds, jcount, calendarEventEntity, _printShowCalendarEvents(origUser, user, cal, calIds, jcount, calendarEventEntity,
csvPF, FJQC, fieldsList) csvPF, FJQC, fieldsList, addCSVData)
Ind.Decrement() Ind.Decrement()
if csvPF: if csvPF:
if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']: if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']:
@@ -53987,7 +54022,7 @@ def printShowStatusEvent(users, eventType):
for event in events: for event in events:
if showDayOfWeek: if showDayOfWeek:
_getEventDaysOfWeek(event) _getEventDaysOfWeek(event)
_printCalendarEvent(user, calId, event, csvPF, FJQC) _printCalendarEvent(user, calId, event, csvPF, FJQC, {})
if 'pdelta' in wlDate: if 'pdelta' in wlDate:
first = first.shift(**wlDate['pdelta']) first = first.shift(**wlDate['pdelta'])
last = last.shift(**wlDate['pdelta']) last = last.shift(**wlDate['pdelta'])
@@ -77238,7 +77273,7 @@ TASK_QUERY_STATE_MAP = {
# [updatedmin <Time>] # [updatedmin <Time>]
# [showcompleted [<Boolean>]] [showdeleted [<Boolean>]] [showhidden [<Boolean>]] [showall] # [showcompleted [<Boolean>]] [showdeleted [<Boolean>]] [showhidden [<Boolean>]] [showall]
# [orderby completed|due|updated] # [orderby completed|due|updated]
# [countsonly | (formatjson [quotechar <Character>])] # [countsonly|(formatjson [quotechar <Character>])]
def printShowTasks(users): def printShowTasks(users):
def _showTaskAndChildren(tasklist, taskId, k, compact): def _showTaskAndChildren(tasklist, taskId, k, compact):
if taskId in taskParentsProcessed: if taskId in taskParentsProcessed:
@@ -77305,8 +77340,11 @@ def printShowTasks(users):
csvPF.SetTitles(['User', CSVTitle]) csvPF.SetTitles(['User', CSVTitle])
else: else:
FJQC.GetFormatJSONQuoteChar(myarg, False) FJQC.GetFormatJSONQuoteChar(myarg, False)
if csvPF and FJQC.formatJSON: if csvPF:
csvPF.SetJSONTitles(['User', 'tasklistId', 'id', 'taskId', 'title', 'JSON']) if countsOnly:
csvPF.SetFormatJSON(False)
elif FJQC.formatJSON:
csvPF.SetJSONTitles(['User', 'tasklistId', 'id', 'taskId', 'title', 'JSON'])
i, count, users = getEntityArgument(users) i, count, users = getEntityArgument(users)
for user in users: for user in users:
i += 1 i += 1
@@ -77505,7 +77543,7 @@ def processTasklists(users):
# gam <UserTypeEntity> show tasklists # gam <UserTypeEntity> show tasklists
# [countsonly|formatjson] # [countsonly|formatjson]
# gam <UserTypeEntity> print tasklists [todrive <ToDriveAttribute>*] # gam <UserTypeEntity> print tasklists [todrive <ToDriveAttribute>*]
# [countsonly | (formatjson [quotechar <Character>])] # [countsonly|(formatjson [quotechar <Character>])]
def printShowTasklists(users): def printShowTasklists(users):
csvPF = CSVPrintFile(['User', 'id', 'title']) if Act.csvFormat() else None csvPF = CSVPrintFile(['User', 'id', 'title']) if Act.csvFormat() else None
if csvPF: if csvPF:
@@ -77523,6 +77561,8 @@ def printShowTasklists(users):
csvPF.SetTitles(['User', CSVTitle]) csvPF.SetTitles(['User', CSVTitle])
else: else:
FJQC.GetFormatJSONQuoteChar(myarg, True) FJQC.GetFormatJSONQuoteChar(myarg, True)
if countsOnly and csvPF:
csvPF.SetFormatJSON(False)
i, count, users = getEntityArgument(users) i, count, users = getEntityArgument(users)
for user in users: for user in users:
i += 1 i += 1