From 53d1ce5ddb76c768970b9e42df11cc647b1554eb Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 19 Jan 2024 08:12:27 -0800 Subject: [PATCH] Updated `gam remove aliases user|group ` --- docs/Aliases.md | 2 +- docs/GamUpdates.md | 9 +++++++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Reseller.md | 6 ++++++ docs/Version-and-Help.md | 12 ++++++------ src/GamUpdate.txt | 9 +++++++++ src/gam/__init__.py | 23 ++++++++++++++--------- 7 files changed, 47 insertions(+), 18 deletions(-) diff --git a/docs/Aliases.md b/docs/Aliases.md index d99e98ec..75538ccb 100644 --- a/docs/Aliases.md +++ b/docs/Aliases.md @@ -85,7 +85,7 @@ gam delete aliases ``` ## Display aliases -Display a specific alise. +Display a specific alias. ``` gam info alias|aliases ``` diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index a25e9e63..12716bf3 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -11,6 +11,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.67.21 + +Updated `gam remove aliases user|group ` to give a more informative +error message when the target/alias combination does not exist. +``` +Old: User: testsimple@rdschool.org, User Alias: tsalias@rdschool.org, Remove Failed: Invalid Input: resource_id +New: User: testsimple@rdschool.org, User Alias: tsalias@rdschool.org, Remove Failed: Does not exist +``` + ### 6.67.20 Added option `onelicenseperrow|onelicenceperrow` to `gam print users ... licenses` that causes GAM to print diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 836f0ac4..4e69643f 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -334,7 +334,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.67.20 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -1002,7 +1002,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.67.20 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Reseller.md b/docs/Reseller.md index a4026fdb..b8ca6124 100644 --- a/docs/Reseller.md +++ b/docs/Reseller.md @@ -1,6 +1,7 @@ # Reseller - [API documentation](#api-documentation) - [Notes](#notes) +- [Manage Multiple Domains](#manage-multiple-domains) - [Definitions](#definitions) - [Manage Resold Customers](#manage-resold-customers) - [Display Resold Customers](#display-resold-customers) @@ -25,6 +26,11 @@ Prior to version 6.50.00, this is how the `seats ` which will be properly passed in the correct form to the API based on plan name. +## Manage Multiple Domains +Thanks to Duncan Isaksen-Loxton for a script to help manage multiple domains. + +* See: https://gist.github.com/65/b5e9cee9b5812b487b8ae3e8256e262b + ## Definitions ``` ::= diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index b6941789..e75ead58 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -4,7 +4,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.67.20 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -16,7 +16,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.67.20 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -28,7 +28,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.67.20 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -65,7 +65,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.67.20 + Latest: 6.67.21 echo $? 1 ``` @@ -73,7 +73,7 @@ echo $? Print the current version number without details ``` gam version simple -6.67.20 +6.67.21 ``` In Linux/MacOS you can do: ``` @@ -83,7 +83,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.67.20 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.67.21 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 3536d286..33c8a41d 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,15 @@ Merged GAM-Team version +6.67.21 + +Updated `gam remove aliases user|group ` to give a more informative +error message when the target/alias combination does not exist. +``` +Old: User: testsimple@rdschool.org, User Alias: tsalias@rdschool.org, Remove Failed: Invalid Input: resource_id +New: User: testsimple@rdschool.org, User Alias: tsalias@rdschool.org, Remove Failed: Does not exist +``` + 6.67.20 Added option `onelicenseperrow|onelicenceperrow` to `gam print users ... licenses` that causes GAM to print diff --git a/src/gam/__init__.py b/src/gam/__init__.py index dca3d437..2eb6b385 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -17591,8 +17591,10 @@ def doRemoveAliases(): GAPI.CONDITION_NOT_MET], userKey=targetEmail, alias=aliasEmail) entityActionPerformed([Ent.USER, targetEmail, Ent.USER_ALIAS, aliasEmail], i, count) - except (GAPI.userNotFound, GAPI.badRequest, GAPI.invalid, GAPI.forbidden, GAPI.invalidResource, GAPI.conditionNotMet) as e: + except (GAPI.userNotFound, GAPI.badRequest, GAPI.invalid, GAPI.forbidden, GAPI.conditionNotMet) as e: entityActionFailedWarning([Ent.USER, targetEmail, Ent.USER_ALIAS, aliasEmail], str(e), i, count) + except GAPI.invalidResource: + entityActionFailedWarning([Ent.USER, targetEmail, Ent.USER_ALIAS, aliasEmail], Msg.DOES_NOT_EXIST, i, count) else: try: for aliasEmail in entityList: @@ -17603,8 +17605,10 @@ def doRemoveAliases(): GAPI.CONDITION_NOT_MET], groupKey=targetEmail, alias=aliasEmail) entityActionPerformed([Ent.GROUP, targetEmail, Ent.GROUP_ALIAS, aliasEmail], i, count) - except (GAPI.groupNotFound, GAPI.userNotFound, GAPI.badRequest, GAPI.invalid, GAPI.forbidden, GAPI.invalidResource, GAPI.conditionNotMet) as e: + except (GAPI.groupNotFound, GAPI.userNotFound, GAPI.badRequest, GAPI.invalid, GAPI.forbidden, GAPI.conditionNotMet) as e: entityActionFailedWarning([Ent.GROUP, targetEmail, Ent.GROUP_ALIAS, aliasEmail], str(e), i, count) + except GAPI.invalidResource: + entityActionFailedWarning([Ent.GROUP, targetEmail, Ent.GROUP_ALIAS, aliasEmail], Msg.DOES_NOT_EXIST, i, count) def _addUserAliases(cd, user, aliasList, i, count): jcount = len(aliasList) @@ -40727,7 +40731,10 @@ class PasswordOptions(): elif self.b64DecryptPassword: if body[up].lower()[:5] in ['{md5}', '{sha}']: body[up] = body[up][5:] - body[up] = base64.b64decode(body[up]).hex() + try: + body[up] = base64.b64decode(body[up]).hex() + except Exception as e: + pass def AssignPassword(self, body, notify, notFoundBody, createIfNotFound): up = 'password' @@ -42837,9 +42844,10 @@ def doPrintUsers(entityList=None): csvPF.AddTitles(['Groups']) if printOptions['getLicenseFeed'] or printOptions['getLicenseFeedByUser']: if not oneLicensePerRow: - csvPF.AddTitles(['LicensesCount', 'Licenses', 'LicensesDisplay']) + licenseTitles = ['LicensesCount', 'Licenses', 'LicensesDisplay'] else: - csvPF.AddTitles(['License', 'LicenseDisplay']) + licenseTitles = ['License', 'LicenseDisplay'] + csvPF.AddTitles(licenseTitles) if printOptions['getLicenseFeed']: if skus is None and GM.Globals[GM.LICENSE_SKUS]: skus = GM.Globals[GM.LICENSE_SKUS] @@ -42979,10 +42987,7 @@ def doPrintUsers(entityList=None): else: csvPF.MoveTitlesToEnd(['Groups']+[f'Groups{GC.Values[GC.CSV_OUTPUT_SUBFIELD_DELIMITER]}{j}' for j in range(printOptions['maxGroups'])]) if printOptions['getLicenseFeed'] or printOptions['getLicenseFeedByUser']: - if not oneLicensePerRow: - csvPF.MoveTitlesToEnd(['LicensesCount', 'Licenses', 'LicensesDisplay']) - else: - csvPF.MoveTitlesToEnd(['License', 'LicenseDisplay']) + csvPF.MoveTitlesToEnd(licenseTitles) elif not FJQC.formatJSON: for domain, count in sorted(iter(domainCounts.items())): csvPF.WriteRowNoFilter({'domain': domain, 'count': count})