From abe1d5381d475c78fceca009e3d18dcb47f0246e Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Mon, 11 Mar 2024 16:41:47 -0700 Subject: [PATCH] Added a command to update a Gmail label's settings by specifying it's ID rather than it's name. --- docs/GamUpdates.md | 11 ++++++++- docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Users-Gmail-Labels.md | 6 +++++ docs/Version-and-Help.md | 12 +++++----- src/GamCommands.txt | 4 ++++ src/GamUpdate.txt | 12 +++++++++- src/gam/__init__.py | 30 ++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 10 deletions(-) diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 8f72a8fa..b005aed9 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,7 +10,16 @@ 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.71.23 +### 6.71.14 + +Added a command to update a Gmail label's settings by specifying it's ID rather than it's name. +``` +gam update labelid [name ] + [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] + [backgroundcolor ] [textcolor ] +``` + +### 6.71.13 Updated `.location.buildingid ` to allow non-validated building IDs by specifying `nv:` at the beginning of ``; e.g., `nv:Building X' sets the building ID to `Building X`. diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index b9c78ef4..04fe07ac 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.71.13 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -1006,7 +1006,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.71.13 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Users-Gmail-Labels.md b/docs/Users-Gmail-Labels.md index 68208bb5..6b3e10e6 100644 --- a/docs/Users-Gmail-Labels.md +++ b/docs/Users-Gmail-Labels.md @@ -88,11 +88,17 @@ all parent labels are created as necessary. Example: `gam user user@domain.com add label "Top/Middle/Bottom" buildpath` ## Update a label's settings +The two commands are equivalent; in the first you specify a ``, in the second you specify a ``. ``` gam update labelsettings [name ] [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] [backgroundcolor "||custom:"] [textcolor "||custom:"] + +gam update labelid [name ] + [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] + [backgroundcolor "||custom:"] + [textcolor "||custom:"] ``` `` values should be enclosed in " to keep the command shell on MacOS and Linux from mis-interpreting them. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 1ef53e8d..e4a6a16e 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.71.13 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 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.71.13 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 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.71.13 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 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.71.13 + Latest: 6.71.14 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.71.13 +6.71.14 ``` 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.71.13 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.71.14 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 601c0978..8ca9bc14 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -6940,6 +6940,10 @@ gam create labellist [backgroundcolor "||custom:"] [textcolor "||custom:"] [buildpath []] +gam update labelid [name ] + [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] + [backgroundcolor "||custom:"] + [textcolor "||custom:"] gam update labelsettings [name ] [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] [backgroundcolor "||custom:"] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index c253aeca..8cd93aab 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,7 +2,17 @@ Merged GAM-Team version -6.71.23 +6.71.14 + +Added a command to update a Gmail label's settings by specifying it's ID rather than it's name. +``` +gam update labelid [name ] + [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] + [backgroundcolor "||custom:"] + [textcolor "||custom:"] +``` + +6.71.13 Updated `.location.buildingid ` to allow non-validated building IDs by specifying `nv:` at the beginning of ``; e.g., `nv:Building X' sets the building ID to `Building X`. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 9942a000..56425d81 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -65955,6 +65955,35 @@ def updateLabelSettings(users): entityActionFailedWarning([Ent.USER, user, Ent.LABEL, label_name], str(e), i, count) except (GAPI.serviceNotAvailable, GAPI.badRequest): entityServiceNotApplicableWarning(Ent.USER, user, i, count) + +# gam update labelid [name ] +# [messagelistvisibility hide|show] [labellistvisibility hide|show|showifunread] +# [backgroundcolor ] [textcolor ] +def updateLabelSettingsById(users): + labelId = getString(Cmd.OB_LABEL_ID) + body = {} + while Cmd.ArgumentsRemaining(): + myarg = getArgument() + if myarg == 'name': + body['name'] = getString(Cmd.OB_STRING) + else: + getLabelAttributes(myarg, body) + checkLabelColor(body) + i, count, users = getEntityArgument(users) + for user in users: + i += 1 + user, gmail = buildGAPIServiceObject(API.GMAIL, user, i, count) + if not gmail: + continue + try: + result = callGAPI(gmail.users().labels(), 'patch', + throwReasons=GAPI.GMAIL_THROW_REASONS+[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT], + userId='me', id=labelId, body=body, fields='name') + entityActionPerformed([Ent.USER, user, Ent.LABEL_ID, labelId, Ent.LABEL, result['name']], i, count) + except (GAPI.notFound, GAPI.invalidArgument) as e: + entityActionFailedWarning([Ent.USER, user, Ent.LABEL_ID, labelId], str(e), i, count) + except (GAPI.serviceNotAvailable, GAPI.badRequest): + entityServiceNotApplicableWarning(Ent.USER, user, i, count) # def cleanLabelQuery(labelQuery): for ch in '/ (){}': @@ -73762,6 +73791,7 @@ USER_COMMANDS_WITH_OBJECTS = { Cmd.ARG_FORM: updateForm, Cmd.ARG_GROUP: updateUserGroups, Cmd.ARG_LABEL: updateLabels, + Cmd.ARG_LABELID: updateLabelSettingsById, Cmd.ARG_LABELSETTINGS: updateLabelSettings, Cmd.ARG_LICENSE: updateLicense, Cmd.ARG_OTHERCONTACT: processUserPeopleOtherContacts,