From 6964f10aa3ee3c9489f0ca185287ac859ec0f0c8 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 21 Jun 2024 20:48:36 -0700 Subject: [PATCH] Cleanup --- docs/GamUpdates.md | 9 +++++++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Version-and-Help.md | 12 ++++++------ src/GamCommands.txt | 5 ++--- src/GamUpdate.txt | 9 +++++++++ src/gam/__init__.py | 25 +++++++++++++----------- 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index bf88c61d..98c18333 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,15 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.77.01 + +Thanks to Jay, added column `verificationCodesCount` to `gam print backupcodes` +that displays the number of available backup codes in addtion to the codes. + +Added option `countsonly` that displays only the number of available backup codes but not the codes themselves. + +Thanks to Jay, added option `nokey` to `gam create project` that creates a project with no service account key, `oauth2service.json`. + ### 6.77.00 Added option `individualstudentassignments copy|delete|maptoall` to `gam create|update course ... copyfrom` diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index da0b1ce9..cf2c11c3 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -335,7 +335,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -1009,7 +1009,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 93b9a07c..79ed3fac 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -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 -GAMADV-XTD3 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -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 -GAMADV-XTD3 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.77.00 + Latest: 6.77.01 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.77.00 +6.77.01 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.77.00 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.77.01 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 4d2e3988..cf86da38 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -1346,7 +1346,7 @@ gam create project [admin ] [project ] [(algorithm KEY_ALG_RSA_1024|KEY_ALG_RSA_2048)| (localkeysize 1024|2048|4096 [validityhours ])| (yubikey yubikey_pin yubikey_slot AUTHENTICATION|SIGNATURE yubikey_serialnumber )| - (nokey)] + nokey] gam use project [] [] gam use project [admin ] [project ] [saname ] [sadisplayname ] @@ -5628,8 +5628,7 @@ gam update backupcodes|verificationcodes gam delete backupcodes|verificationcodes gam show backupcodes|verificationcodes gam print backupcodes|verificationcodes [todrive *] - [delimiter ] - [countsonly] + [delimiter ] [countsonly] # Users - Calendars diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 2b5e51a3..1805d8aa 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,15 @@ Merged GAM-Team version +6.77.01 + +Thanks to Jay, added column `verificationCodesCount` to `gam print backupcodes` +that displays the number of available backup codes in addtion to the codes. + +Added option `countsonly` that displays only the number of available backup codes but not the codes themselves. + +Thanks to Jay, added option `nokey` to `gam create project` that creates a project with no service account key, `oauth2service.json`. + 6.77.00 Added option `individualstudentassignments copy|delete|maptoall` to `gam create|update course ... copyfrom` diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 1919f16a..c0cc975a 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -11213,8 +11213,10 @@ def _createOauth2serviceJSON(httpObj, projectInfo, svcAcctInfo, create_key=True) entityActionFailedWarning([Ent.PROJECT, projectInfo['projectId'], Ent.SVCACCT, svcAcctInfo['name']], str(e)) return False GM.Globals[GM.SVCACCT_SCOPES_DEFINED] = False - if create_key and not doProcessSvcAcctKeys(mode='retainexisting', iam=iam, projectId=service_account['projectId'], - clientEmail=service_account['email'], clientId=service_account['uniqueId']): + if create_key and not doProcessSvcAcctKeys(mode='retainexisting', iam=iam, + projectId=service_account['projectId'], + clientEmail=service_account['email'], + clientId=service_account['uniqueId']): return False sa_email = service_account['name'].rsplit('/', 1)[-1] _grantRotateRights(iam, projectInfo['projectId'], sa_email, sa_email) @@ -11231,7 +11233,6 @@ def setGAMProjectConsentScreen(httpObj, projectId, appInfo): pass def _createClientSecretsOauth2service(httpObj, login_hint, appInfo, projectInfo, svcAcctInfo, create_key=True): - def _checkClientAndSecret(csHttpObj, client_id, client_secret): post_data = {'client_id': client_id, 'client_secret': client_secret, 'code': 'ThisIsAnInvalidCodeOnlyBeingUsedToTestIfClientAndSecretAreValid', @@ -11391,7 +11392,7 @@ def _getLoginHintProjectInfo(createCmd): svcAcctInfo = {'name': '', 'displayName': '', 'description': ''} if not Cmd.PeekArgumentPresent(['admin', 'appname', 'supportemail', 'project', 'parent', 'projectname', 'saname', 'sadisplayname', 'sadescription', - 'algorithm', 'localkeysize', 'validityhours', 'yubikey']): + 'algorithm', 'localkeysize', 'validityhours', 'yubikey', 'nokey']): login_hint = getString(Cmd.OB_EMAIL_ADDRESS, optional=True) if login_hint and login_hint.find('@') == -1: Cmd.Backup() @@ -11611,7 +11612,7 @@ def doCreateGCPFolder(): # [(algorithm KEY_ALG_RSA_1024|KEY_ALG_RSA_2048)| # (localkeysize 1024|2048|4096 [validityhours ])| # (yubikey yubikey_pin yubikey_slot AUTHENTICATION yubikey_serialnumber )| -# (nokey)] +# nokey] def doCreateProject(): _checkForExistingProjectFiles([GC.Values[GC.OAUTH2SERVICE_JSON], GC.Values[GC.CLIENT_SECRETS_JSON]]) sys.stdout.write(Msg.TRUST_GAM_CLIENT_ID.format(GAM_PROJECT_CREATION, GAM_PROJECT_CREATION_CLIENT_ID)) @@ -45118,7 +45119,7 @@ class CourseAttributes(): } COURSE_WORK_INDIVIDUAL_STUDENT_ASSIGNMENTS_OPTIONS = {'copy', 'delete', 'maptoall'} - + def GetAttributes(self): while Cmd.ArgumentsRemaining(): myarg = getArgument() @@ -48587,11 +48588,12 @@ def deleteBackupCodes(users): entityActionNotPerformedWarning([Ent.USER, user, Ent.BACKUP_VERIFICATION_CODES, None], Msg.IS_SUSPENDED_NO_BACKUPCODES, i, count) -# gam print backupcodes|verificationcodes [todrive *] [delimiter ] [countsonly] +# gam print backupcodes|verificationcodes [todrive *] +# [delimiter ] [countsonly] # gam show backupcodes|verificationcodes def printShowBackupCodes(users): cd = buildGAPIObject(API.DIRECTORY) - csvPF = CSVPrintFile(['User', 'verificationCodes', 'verificationCodesCount']) if Act.csvFormat() else None + csvPF = CSVPrintFile(['User', 'verificationCodesCount', 'verificationCodes']) if Act.csvFormat() else None delimiter = GC.Values[GC.CSV_OUTPUT_FIELD_DELIMITER] counts_only = False while Cmd.ArgumentsRemaining(): @@ -48604,12 +48606,13 @@ def printShowBackupCodes(users): counts_only = True else: unknownArgumentExit() - i, count, users = getEntityArgument(users) # if we're only getting counts, we don't want actual codes pulled down if counts_only: - fields = 'items(etag)' + csvPF.RemoveTitles('verificationCodes') + fields = 'items(etag)' else: - fields = 'items(verificationCode)' + fields = 'items(verificationCode)' + i, count, users = getEntityArgument(users) for user in users: i += 1 user = normalizeEmailAddressOrUID(user)