Skip to content

Commit

Permalink
Update all user calendar commands to disable falling back to client a…
Browse files Browse the repository at this point in the history
…ccess if service account authorization has never been performed.
  • Loading branch information
taers232c committed Oct 11, 2024
1 parent ae67319 commit f707c83
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 52 deletions.
5 changes: 5 additions & 0 deletions docs/GamUpdates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 7.00.17

Update all user calendar commands to disable falling back to client access if service account
authorization has never been performed.

### 7.00.16

Updated `gam <UserTypeEntity> claim|transfer ownership` to show `Got N Drive Files/Folders that matched query` messages
Expand Down
4 changes: 2 additions & 2 deletions docs/How-to-Upgrade-Legacy-GAM-to-GAM7.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin$ gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAM 7.00.16 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.17 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
MacOS Sonoma 14.5 x86_64
Expand Down Expand Up @@ -923,7 +923,7 @@ writes the credentials into the file oauth2.txt.
C:\>del C:\GAMConfig\oauth2.txt
C:\>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAM7 7.00.16 - https://github.com/GAM-team/GAM - pythonsource
GAM7 7.00.17 - https://github.com/GAM-team/GAM - pythonsource
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
Windows-10-10.0.17134 AMD64
Expand Down
12 changes: 6 additions & 6 deletions docs/Version-and-Help.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Print the current version of Gam with details
```
gam version
GAM 7.00.16 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.17 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
MacOS Sonoma 14.5 x86_64
Expand All @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00
Print the current version of Gam with details and time offset information
```
gam version timeoffset
GAM 7.00.16 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.17 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
MacOS Sonoma 14.5 x86_64
Expand All @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second
Print the current version of Gam with extended details and SSL information
```
gam version extended
GAM 7.00.16 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.17 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
MacOS Sonoma 14.5 x86_64
Expand Down Expand Up @@ -64,15 +64,15 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gam7
Version Check:
Current: 5.35.08
Latest: 7.00.16
Latest: 7.00.17
echo $?
1
```

Print the current version number without details
```
gam version simple
7.00.16
7.00.17
```
In Linux/MacOS you can do:
```
Expand All @@ -82,7 +82,7 @@ echo $VER
Print the current version of Gam and address of this Wiki
```
gam help
GAM 7.00.16 - https://github.com/GAM-team/GAM
GAM 7.00.17 - https://github.com/GAM-team/GAM
GAM Team <google-apps-manager@googlegroups.com>
Python 3.13.0 64-bit final
MacOS Sonoma 14.5 x86_64
Expand Down
5 changes: 5 additions & 0 deletions src/GamUpdate.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
7.00.17

Update all user calendar commands to disable falling back to client access if service account
authorization has never been performed.

7.00.16

Updated `gam <UserTypeEntity> claim|transfer ownership` to show `Got N Drive Files/Folders that matched query` messages
Expand Down
91 changes: 47 additions & 44 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.00.16'
__version__ = '7.00.17'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'

#pylint: disable=wrong-import-position
Expand Down Expand Up @@ -6056,7 +6056,7 @@ def checkGroupExists(cd, ci, ciGroupsAPI, group, i=0, count=0):

# Turn the entity into a list of Users/CrOS devices
def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isArchived=None,
groupMemberType=Ent.TYPE_USER, noListConversion=False):
groupMemberType=Ent.TYPE_USER, noListConversion=False, recursive=False, noCLArgs=False):
def _incrEntityDoesNotExist(entityType):
entityError['entityType'] = entityType
entityError[ENTITY_ERROR_DNE] += 1
Expand Down Expand Up @@ -6227,32 +6227,33 @@ def _addCIGroupUsersToUsers(groupName, groupEmail, recursive):
isSuspended = True
cd = buildGAPIObject(API.DIRECTORY)
groups = convertEntityToList(entity)
includeDerivedMembership = recursive = False
includeDerivedMembership = False
domains = []
rolesSet = set()
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if myarg in GROUP_ROLES_MAP:
rolesSet.add(GROUP_ROLES_MAP[myarg])
elif myarg == 'primarydomain':
domains.append(GC.Values[GC.DOMAIN])
elif myarg == 'domains':
domains.extend(getEntityList(Cmd.OB_DOMAIN_NAME_ENTITY))
elif myarg == 'recursive':
recursive = True
includeDerivedMembership = False
elif myarg == 'includederivedmembership':
includeDerivedMembership = True
recursive = False
elif entityType == Cmd.ENTITY_GROUP_USERS_SELECT and myarg in SUSPENDED_ARGUMENTS:
isSuspended = _getIsSuspended(myarg)
elif entityType == Cmd.ENTITY_GROUP_USERS_SELECT and myarg in ARCHIVED_ARGUMENTS:
isArchived = _getIsArchived(myarg)
elif myarg == 'end':
break
else:
Cmd.Backup()
missingArgumentExit('end')
if not noCLArgs:
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if myarg in GROUP_ROLES_MAP:
rolesSet.add(GROUP_ROLES_MAP[myarg])
elif myarg == 'primarydomain':
domains.append(GC.Values[GC.DOMAIN])
elif myarg == 'domains':
domains.extend(getEntityList(Cmd.OB_DOMAIN_NAME_ENTITY))
elif myarg == 'recursive':
recursive = True
includeDerivedMembership = False
elif myarg == 'includederivedmembership':
includeDerivedMembership = True
recursive = False
elif entityType == Cmd.ENTITY_GROUP_USERS_SELECT and myarg in SUSPENDED_ARGUMENTS:
isSuspended = _getIsSuspended(myarg)
elif entityType == Cmd.ENTITY_GROUP_USERS_SELECT and myarg in ARCHIVED_ARGUMENTS:
isArchived = _getIsArchived(myarg)
elif myarg == 'end':
break
else:
Cmd.Backup()
missingArgumentExit('end')
if rolesSet:
memberRoles = ','.join(sorted(rolesSet))
for group in groups:
Expand Down Expand Up @@ -6293,19 +6294,19 @@ def _addCIGroupUsersToUsers(groupName, groupEmail, recursive):
elif entityType in {Cmd.ENTITY_CIGROUP_USERS}:
ci = buildGAPIObject(API.CLOUDIDENTITY_GROUPS)
groups = convertEntityToList(entity)
recursive = False
rolesSet = set()
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if myarg in GROUP_ROLES_MAP:
rolesSet.add(GROUP_ROLES_MAP[myarg])
elif myarg == 'recursive':
recursive = True
elif myarg == 'end':
break
else:
Cmd.Backup()
missingArgumentExit('end')
if not noCLArgs:
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if myarg in GROUP_ROLES_MAP:
rolesSet.add(GROUP_ROLES_MAP[myarg])
elif myarg == 'recursive':
recursive = True
elif myarg == 'end':
break
else:
Cmd.Backup()
missingArgumentExit('end')
if rolesSet:
memberRoles = ','.join(sorted(rolesSet))
for group in groups:
Expand Down Expand Up @@ -37028,11 +37029,13 @@ def checkCalendarExists(cal, calId, showMessage=False):
entityActionFailedWarning([Ent.CALENDAR, calId], str(e))
return None

def validateCalendar(calId, i=0, count=0):
def validateCalendar(calId, i=0, count=0, noClientAccess=False):
cal = None
if not calId.endswith('.calendar.google.com'):
calId, cal = buildGAPIServiceObject(API.CALENDAR, calId, i, count, displayError=False)
calId, cal = buildGAPIServiceObject(API.CALENDAR, calId, i, count, displayError=noClientAccess)
if not cal:
if noClientAccess:
return (calId, None)
cal = buildGAPIObject(API.CALENDAR)
try:
callGAPI(cal.calendars(), 'get',
Expand Down Expand Up @@ -49759,7 +49762,7 @@ def _validateUserGetCalendarIds(user, i, count, calendarEntity,
calIds = calendarEntity['dict'][user][:]
else:
calIds = calendarEntity['list'][:]
user, cal = validateCalendar(user, i, count)
user, cal = validateCalendar(user, i, count, noClientAccess=True)
if not cal:
return (user, None, None, 0)
if calendarEntity['resourceIds']:
Expand Down Expand Up @@ -50178,7 +50181,7 @@ def printShowCalendars(users):
i, count, users = getEntityArgument(users)
for user in users:
i += 1
user, cal = validateCalendar(user, i, count)
user, cal = validateCalendar(user, i, count, noClientAccess=True)
if not cal:
continue
if csvPF:
Expand Down Expand Up @@ -50278,7 +50281,7 @@ def printShowCalSettings(users):
i, count, users = getEntityArgument(users)
for user in users:
i += 1
user, cal = validateCalendar(user, i, count)
user, cal = validateCalendar(user, i, count, noClientAccess=True)
if not cal:
continue
try:
Expand Down Expand Up @@ -50438,7 +50441,7 @@ def transferCalendars(users):
_getCalendarAttributes(targetListBody, returnOnUnknownArgument=True)
else:
unknownArgumentExit()
targetUser, targetCal = validateCalendar(targetUser)
targetUser, targetCal = validateCalendar(targetUser, noClientAccess=True)
if not targetCal:
return
colorRgbFormat = 'backgroundColor' in targetListBody or 'foregroundColor' in targetListBody
Expand Down

0 comments on commit f707c83

Please sign in to comment.