From 438656a5492f6b91174e8fffb21a259ee25a022c Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Sat, 29 Jul 2023 09:17:12 -0700 Subject: [PATCH] Improved create shareddrive retries --- docs/GamUpdates.md | 15 +++- docs/How-to-Upgrade-from-Standard-GAM.md | 4 +- docs/Shared-Drives.md | 23 ++++-- docs/Users-Drive-Copy-Move.md | 2 +- docs/Users-Drive-Files-Manage.md | 4 +- docs/Users-Forms.md | 2 +- docs/Users-Shared-Drives.md | 20 +++-- docs/Version-and-Help.md | 12 +-- docs~ | 94 ++++++++++++++++++++++++ src/GamCommands.txt | 80 +++++++++++--------- src/GamUpdate.txt | 11 +++ src/gam/__init__.py | 36 ++++++--- 12 files changed, 229 insertions(+), 74 deletions(-) create mode 100644 docs~ diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index d2ce51ee..f82ced12 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,7 +10,18 @@ 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.61.17 +### 6.61.18 + +Added the following options to `gam [] create shareddrive` to allow better control +of the create/update process when attributes other than `themeid` are specified. +``` +errorretries - Number of create/update error retries; default value 5, range 0-10 +updateinitialdelay - Initial delay after create before update: default value 10, range 0-60 +updateretrydelay - Retry delay when update fails; default value 10, range 0-60 +``` +* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Shared-Drives#create-a-shared-drive + +### 6.61.17 Updated `gam print|show vaultexports|vaultholds|vaultqueries` to not set a non-zero return code when a vault matter changes state from `OPEN` to `CLOSED|DELETED` while the command is being processed. @@ -21,7 +32,7 @@ ERROR: 403: permissionDenied - Request had insufficient authentication scopes. ``` It's not clear what causes the error. -6.61.16 +### 6.61.16 Added the following license SKUs. ``` diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index fb3dc16f..5c4ada88 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -329,7 +329,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.61.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.10.8 64-bit final MacOS High Sierra 10.13.6 x86_64 @@ -969,7 +969,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.61.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.11.4 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Shared-Drives.md b/docs/Shared-Drives.md index db894e78..5b9937da 100644 --- a/docs/Shared-Drives.md +++ b/docs/Shared-Drives.md @@ -206,6 +206,7 @@ gam [] create teamdrive ([customtheme ] [color ])] ( )* [hide ] [ou|org|orgunit ] + [errorretries ] [updateinitialdelay ] [updateretrydelay ] [(csv [todrive *] (addcsvdata )*) | returnidonly] [adminaccess|asadmin] ``` @@ -218,14 +219,20 @@ gam [] create teamdrive * ` ` - Set Shared Drive Restrictions * `hide ` - Set Shared Drive visibility -This option is only available when the command is run as an administrator. -* `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html - If any attributes other than `themeid` are specified, GAM must create the Drive and then update the Drive attributes. Even though the Create API returns success, the Update API fails and reports that the Drive does not exist. -For this reason, GAM waits 30 seconds after the create before attempting the update. GAM repeats the update -with waits of 15, 30, and 45 seconds if the Update API continues to fail. This is acceptable when creating -a single Shared Drive, for bulk Shared Drive creation see [Bulk Create Shared Drives](#bulk-create-shared-drives). +* `errorretries ` - Number of create/update error retries; default value 5, range 0-10 +* `updateinitialdelay ` - Initial delay after create before update: default value 10, range 0-60 +* `updateretrydelay ` - Retry delay when update fails; default value 10, range 0-60 + +For this reason, GAM waits `updateinitialdelay ` seconds after the create before attempting the update. +GAM repeats the update `errorretries ` times waiting `updateretrydelay ` between tries +if the Update API continues to fail. + +This is acceptable when creating a single Shared Drive, for bulk Shared Drive creation see [Bulk Create Shared Drives](#bulk-create-shared-drives). + +This option is only available when the command is run as an administrator. +* `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html By default, the Google Administrator and Shared Drive name and ID values are displayed on stdout. * `csv [todrive *]` - Write Google Administrator, Shared Drive name and ID values to a CSV file. @@ -236,9 +243,9 @@ When either of these options is chosen, no infomation about Shared Drive restric To retrieve the Shared Drive ID with `returnidonly`: ``` Linux/MacOS -teamDriveId=`gam create teamdrive ... returnidonly` +teamDriveId=$(gam create teamdrive ... returnidonly) Windows PowerShell -$teamDriveId = & gam create teamdrive ... returnidonly` +$teamDriveId = & gam create teamdrive ... returnidonly ``` ## Bulk Create Shared Drives diff --git a/docs/Users-Drive-Copy-Move.md b/docs/Users-Drive-Copy-Move.md index 9391b3e3..d6a3a07a 100644 --- a/docs/Users-Drive-Copy-Move.md +++ b/docs/Users-Drive-Copy-Move.md @@ -308,7 +308,7 @@ When copying folders, the option is only useful when copying a folder without re To retrieve the file ID with `returnidonly`: ``` Linux/MacOS -fileId=gam user user@domain.com copy drivefile ... returnidonly +fileId=$(gam user user@domain.com copy drivefile ... returnidonly) Windows PowerShell $fileId = & gam user user@domain.com copy drivefile ... returnidonly ``` diff --git a/docs/Users-Drive-Files-Manage.md b/docs/Users-Drive-Files-Manage.md index 8779324a..a2cc5659 100644 --- a/docs/Users-Drive-Files-Manage.md +++ b/docs/Users-Drive-Files-Manage.md @@ -213,7 +213,7 @@ Alternatively, you can direct the output to a CSV file: To retrieve the file ID with `returnidonly`: ``` Linux/MacOS -fileId=`gam user user@domain.com create drivefile ... returnidonly` +fileId=$(gam user user@domain.com create drivefile ... returnidonly) Windows PowerShell $fileId = & gam user user@domain.com create drivefile ... returnidonly ``` @@ -511,7 +511,7 @@ By default, the user, file name, updated file name and id values are displayed o To retrieve the file ID with `returnidonly`: ``` Linux/MacOS -fileId=`gam user user@domain.com update drivefile copy ... returnidonly` +fileId=$(gam user user@domain.com update drivefile copy ... returnidonly) Windows PowerShell $fileId = & gam user user@domain.com update drivefile copy ... returnidonly ``` diff --git a/docs/Users-Forms.md b/docs/Users-Forms.md index 8f392606..c9042dff 100644 --- a/docs/Users-Forms.md +++ b/docs/Users-Forms.md @@ -60,7 +60,7 @@ By default, the user, form title and file name/ID values are displayed on stdout To retrieve the file ID with `returnidonly`: ``` Linux/MacOS -fileId=`gam user user@domain.com create form title "xyz" ... returnidonly` +fileId=$(gam user user@domain.com create form title "xyz" ... returnidonly) Windows PowerShell $fileId = & gam user user@domain.com create form title "xyz" ... returnidonly ``` diff --git a/docs/Users-Shared-Drives.md b/docs/Users-Shared-Drives.md index 8d99deb7..593e464a 100644 --- a/docs/Users-Shared-Drives.md +++ b/docs/Users-Shared-Drives.md @@ -181,6 +181,7 @@ gam create teamdrive ([customtheme ] [color ])] ( )* [hide ] [ou|org|orgunit ] + [errorretries ] [updateinitialdelay ] [updateretrydelay ] [(csv [todrive *] (addcsvdata )*) | returnidonly] ``` * `themeid` - a Shared Drive themeId obtained from `show teamdrivethemes` @@ -191,12 +192,21 @@ gam create teamdrive * `color` - set the Shared Drive color * ` ` - Set Shared Drive Restrictions * `hide ` - Set Shared Drive visibility -* `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html If any attributes other than `themeid` are specified, GAM must create the Drive and then update the Drive attributes. Even though the Create API returns success, the Update API fails and reports that the Drive does not exist. -For this reason, GAM waits 30 seconds after the create before attempting the update. GAM repeats the update -with waits of 15, 30, and 45 seconds if the Update API continues to fail. +* `errorretries ` - Number of create/update error retries; default value 5, range 0-10 +* `updateinitialdelay ` - Initial delay after create before update: default value 10, range 0-60 +* `updateretrydelay ` - Retry delay when update fails; default value 10, range 0-60 + +For this reason, GAM waits `updateinitialdelay ` seconds after the create before attempting the update. +GAM repeats the update `errorretries ` times waiting `updateretrydelay ` between tries +if the Update API continues to fail. + +This is acceptable when creating a single Shared Drive, for bulk Shared Drive creation see [Bulk Create Shared Drives](#bulk-create-shared-drives). + +This option is only available when the command is run as an administrator. +* `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html By default, the user and Shared Drive name and ID values are displayed on stdout. * `csv [todrive *]` - Write user, Shared Drive name and ID values to a CSV file. @@ -207,9 +217,9 @@ When either of these options is chosen, no infomation about Shared Drive restric To retrieve the Shared Drive ID with `returnidonly`: ``` Linux/MacOS -teamDriveId=`gam user user@domain.com create teamdrive ... returnidonly` +teamDriveId=$(gam user user@domain.com create teamdrive ... returnidonly) Windows PowerShell -$teamDriveId = & gam user user@domain.com create teamdrive ... returnidonly` +$teamDriveId = & gam user user@domain.com create teamdrive ... returnidonly ``` ## Bulk Create Shared Drives diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 358bd4c3..5da6dc04 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.61.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.11.4 64-bit final MacOS Monterey 12.6.6 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.61.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.11.4 64-bit final MacOS Monterey 12.6.6 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.61.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.11.4 64-bit final MacOS Monterey 12.6.6 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.61.14 + Latest: 6.61.18 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.61.14 +6.61.18 ``` 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.61.14 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.11.4 64-bit final MacOS Monterey 12.6.6 x86_64 diff --git a/docs~ b/docs~ new file mode 100644 index 00000000..5da6dc04 --- /dev/null +++ b/docs~ @@ -0,0 +1,94 @@ +# Version and Help + +Print the current version of Gam with details +``` +gam version +GAMADV-XTD3 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +Ross Scroggs +Python 3.11.4 64-bit final +MacOS Monterey 12.6.6 x86_64 +Path: /Users/Admin/bin/gamadv-xtd3 +Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain.com +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.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +Ross Scroggs +Python 3.11.4 64-bit final +MacOS Monterey 12.6.6 x86_64 +Path: /Users/Admin/bin/gamadv-xtd3 +Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain.com +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.61.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +Ross Scroggs +Python 3.11.4 64-bit final +MacOS Monterey 12.6.6 x86_64 +Path: /Users/Admin/bin/gamadv-xtd3 +Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain.com +Time: 2023-06-02T21:10:00-07:00 +Your system time differs from admin.googleapis.com by less than 1 second +OpenSSL 3.1.1 30 May 2023 +cryptography 41.0.1 +filelock 3.12.0 +google-api-python-client 2.88.0 +google-auth-httplib2 0.1.0 +google-auth-oauthlib 1.0.0 +google-auth 2.19.1 +httplib2 0.22.0 +passlib 1.7.4 +python-dateutil 2.8.2 +yubikey-manager 5.1.1 +admin.googleapis.com connects using TLSv1.3 TLS_AES_256_GCM_SHA384 +``` + +Print the current and latest versions of Gam and: +* set the return code to 0 if the current version is the latest version +* set the return code to 1 if the current version is not the latest +``` +gam version checkrc +GAM 5.35.08 - https://github.com/taers232c/GAMADV-XTD3 +Ross Scroggs +Python 3.8.1 64-bit final +google-api-python-client 2.77.0 +httplib2 0.16.0 +oauth2client 4.1.3 +MacOS High Sierra 10.13.6 x86_64 +Path: /Users/Admin/bin/gamadv-xtd3 +Version Check: + Current: 5.35.08 + Latest: 6.61.18 +echo $? +1 +``` + +Print the current version number without details +``` +gam version simple +6.61.18 +``` +In Linux/MacOS you can do: +``` +VER=`gam version simple` +echo $VER +``` +Print the current version of Gam and address of this Wiki +``` +gam help +GAM 6.61.18 - https://github.com/taers232c/GAMADV-XTD3 +Ross Scroggs +Python 3.11.4 64-bit final +MacOS Monterey 12.6.6 x86_64 +Path: /Users/Admin/bin/gamadv-xtd3 +Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain.com +Time: 2023-06-02T21:10:00-07:00 +Help: Syntax in file /Users/Admin/bin/gamadv-xtd3/GamCommands.txt +Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki +``` diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 736661de..ae16f943 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -290,14 +290,18 @@ If an item contains spaces, it should be surrounded by ". wsbizplus | workspacebusinessplus | 1010020025 | wsbizplusarchived | workspacebusinessplusarchived | 1010340003 | wsbizstan | workspacebusinessstandard | 1010020028 | + wsbizstanarchived | workspacebusinessstandardarchived | 1010340006 | wsbizstarter | workspacebusinessstarter | wsbizstart | 1010020027 | + wsbizstarterarchived | workspacebusinessstarterarchived | 1010340005 | wsentess | workspaceenterpriseessentials | 1010060003 | wsentplus | workspaceenterpriseplus | gae | gse | enterprise | gsuiteenterprise | 1010020020 | wsentstan | workspaceenterprisestandard | 1010020026 | wsentstanarchived | workspaceenterprisestandardarchived | 1010340004 | wsentstarter | workspaceenterprisestarter | 1010020029 | wes | wsess | workspaceesentials | gsuiteessentials | essentials | d4e | driveenterprise | drive4enterprise | 1010060001 | - wsflw | workspacefrontline | workspacefrontlineworker | 1010020030 + wsessplus | workspaceessentialsplus | 1010060005 | + wsflw | workspacefrontline | workspacefrontlineworker | 1010020030 | + wsflwstan | workspacefrontlinestan | workspacefrontlineworkerstan | 1010020031 ## Items built from primitives @@ -4410,7 +4414,7 @@ gam [] info siteacls gam [] show siteacls gam [] print siteacls [todrive *] -# Shared Drives +# Shared Drives - Administrator ::= backgroundimagefile| @@ -4442,30 +4446,31 @@ sharingfoldersrequiresorganizerpermission true In these commands, the Google administrator named in oauth2.txt is used. -gam show teamdrivethemes -gam create|add teamdrive +gam show shareddrivethemes +gam create shareddrive [(theme|themeid ) | ([customtheme ] [color ])] ( )* [hide|hidden ] [ou|org|orgunit ] + [errorretries ] [updateinitialdelay ] [updateretrydelay ] [(csv [todrive *] (addcsvdata )*) | returnidonly] -gam update teamdrive [name ] +gam update shareddrive [name ] [(theme|themeid ) | ([customtheme ] [color ])] ( )* [hide|hidden ] [ou|org|orgunit ] -gam delete teamdrive +gam delete shareddrive [adminaccess|asadmin] [allowitemdeletion] -gam hide teamdrive -gam unhide teamdrive -gam info teamdrive [fields ] +gam hide shareddrive +gam unhide shareddrive +gam info shareddrive [fields ] [formatjson] -gam show teamdriveinfo [fields ] +gam show shareddriveinfo [fields ] [formatjson] -gam print teamdrives [todrive *] +gam print shareddrives [todrive *] [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [noorgunits []] [formatjson [quotechar ]] -gam show teamdrives +gam show shareddrives [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [noorgunits []] @@ -4480,24 +4485,29 @@ gam show oushareddrives In these commands, you specify an administrator and then indicate that you want domain administrator access with the adminaccess option. -gam create|add teamdrive adminaccess +gam create shareddrive adminaccess [(theme|themeid ) | ([customtheme ] [color ])] ( )* - [hide ] + [hide|hidden ] [ou|org|orgunit ] + [errorretries ] [updateinitialdelay ] [updateretrydelay ] [(csv [todrive *] (addcsvdata )*) | returnidonly] -gam delete teamdrive +gam update shareddrive asadmin [name ] + [(theme|themeid ) | ([customtheme ] [color ])] + ( )* + [hide|hidden ] [ou|org|orgunit ] +gam delete shareddrive adminaccess [allowitemdeletion] -gam info teamdrive adminaccess [fields ] +gam info shareddrive adminaccess [fields ] [formatjson] -gam show teamdriveinfo adminaccess [fields ] +gam show shareddriveinfo adminaccess [fields ] [formatjson] -gam print teamdrives [todrive *] +gam print shareddrives [todrive *] adminaccess [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] (role|roles )* [fields ] [formatjson [quotechar ]] -gam show teamdrives +gam show shareddrives adminaccess [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] (role|roles )* @@ -7355,7 +7365,7 @@ gam show tasklists gam print tasklists [todrive *] [countsonly | (formatjson [quotechar ])] -# Users - Team Drives +# Users - Shared Drives ::= adminmanagedrestrictions| @@ -7373,32 +7383,32 @@ sharingfoldersrequiresorganizerpermission false allowcontentmanagerstosharefolders false sharingfoldersrequiresorganizerpermission true -gam show teamdrivethemes -gam create|add teamdrive [adminaccess|asadmin] +gam show shareddrivethemes +gam create shareddrive [(theme|themeid ) | ([customtheme ] [color ])] ( )* - [hide|hidden ] [ou|org|orgunit ] -gam update teamdrive [adminaccess|asadmin] [name ] + [hide|hidden ] + [errorretries ] [updateinitialdelay ] [updateretrydelay ] + [(csv [todrive *] (addcsvdata )*) | returnidonly] +gam update shareddrive [name ] [(theme|themeid ) | ([customtheme ] [color ])] ( )* - [hide|hidden ] [ou|org|orgunit ] -gam delete teamdrive - [adminaccess|asadmin] [allowitemdeletion] -gam hide teamdrive -gam unhide teamdrive -gam info teamdrive [fields ] + [hide|hidden ] +gam delete shareddrive + [allowitemdeletion] +gam hide shareddrive +gam unhide shareddrive +gam info shareddrive [fields ] [formatjson] -gam info teamdrive [fields ] +gam show shareddriveinfo [fields ] [formatjson] -gam show teamdriveinfo [fields ] - [formatjson] -gam print teamdrives [todrive *] +gam print shareddrives [todrive *] [adminaccess|asadmin [teamdriveadminquery|query ]] [matchname ] [orgunit|org|ou ] (role|roles )* [fields ] [noorgunits []] [formatjson [quotechar ]] -gam show teamdrives +gam show shareddrives [adminaccess|asadmin [teamdriveadminquery|query ]] [matchname ] [orgunit|org|ou ] (role|roles )* diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 0f0b97a7..5cc33023 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,17 @@ Merged GAM-Team version +6.61.18 + +Added the following options to `gam [] create shareddrive` to allow better control +of the create/update process when attributes other than `themeid` are specified. +``` +errorretries - Number of create/update error retries; default value 5, range 0-10 +updateinitialdelay - Initial delay after create before update: default value 10, range 0-60 +updateretrydelay - Retry delay when update fails; default value 10, range 0-60 +``` +* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Shared-Drives#create-a-shared-drive + 6.61.17 Updated `gam print|show vaultexports|vaultholds|vaultqueries` to not set a non-zero return code diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 098e2824..b19e1788 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -59201,7 +59201,7 @@ def _getSharedDriveRestrictions(myarg, body): return True return False -def _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci=None): +def _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci, returnIdOnly): action = Act.Get() name = f'orgUnits/-/memberships/shared_drive;{driveId}' if ci is None: @@ -59211,8 +59211,9 @@ def _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci=None): try: callGAPI(ci.orgUnits().memberships(), 'move', name=name, body=cibody) - Act.Set(Act.MOVE) - entityModifierNewValueActionPerformed([Ent.SHAREDDRIVE, driveId], Act.MODIFIER_TO, f'{Ent.Singular(Ent.ORGANIZATIONAL_UNIT)}: {orgUnit}', i, count) + if not returnIdOnly: + Act.Set(Act.MOVE) + entityModifierNewValueActionPerformed([Ent.SHAREDDRIVE, driveId], Act.MODIFIER_TO, f'{Ent.Singular(Ent.ORGANIZATIONAL_UNIT)}: {orgUnit}', i, count) except (GAPI.notFound, GAPI.forbidden, GAPI.badRequest, GAPI.internalError, GAPI.noManageTeamDriveAdministratorPrivilege) as e: entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count) @@ -59225,10 +59226,11 @@ def _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci=None): # [(theme|themeid ) | ([customtheme ] [color ])] # ( )* # [hide|hidden ] [ou|org|orgunit ] +# [errorretries ] [updateinitialdelay ] [updateretrydelay ] # [(csv [todrive *] (addcsvdata )*) | returnidonly] def createSharedDrive(users, useDomainAdminAccess=False): def waitingForCreationToComplete(sleep_time): - writeStdout(Ind.Spaces()+Msg.WAITING_FOR_SHARED_DRIVE_CREATION_TO_COMPLETE_SLEEPING.format(sleep_time)) + writeStderr(Ind.Spaces()+Msg.WAITING_FOR_SHARED_DRIVE_CREATION_TO_COMPLETE_SLEEPING.format(sleep_time)) time.sleep(sleep_time) requestId = str(uuid.uuid4()) @@ -59238,6 +59240,9 @@ def createSharedDrive(users, useDomainAdminAccess=False): addCSVData = {} hide = returnIdOnly = False orgUnit = orgUnitId = ci = None + errorRetries = 5 + updateInitialDelay = 10 + updateRetryDelay = 10 while Cmd.ArgumentsRemaining(): myarg = getArgument() if _getSharedDriveTheme(myarg, body): @@ -59259,6 +59264,12 @@ def createSharedDrive(users, useDomainAdminAccess=False): addCSVData[k] = getString(Cmd.OB_STRING, minLen=0) elif myarg in ADMIN_ACCESS_OPTIONS: useDomainAdminAccess = True + elif myarg == 'errorretries': + errorRetries = getInteger(minVal=0, maxVal=10) + elif myarg == 'updateinitialdelay': + updateInitialDelay = getInteger(minVal=0, maxVal=60) + elif myarg == 'updateretrydelay': + updateRetryDelay = getInteger(minVal=0, maxVal=60) else: unknownArgumentExit() if csvPF: @@ -59299,7 +59310,7 @@ def createSharedDrive(users, useDomainAdminAccess=False): break except (GAPI.transientError, GAPI.teamDriveAlreadyExists) as e: retry += 1 - if retry > 3: + if retry > errorRetries: entityActionFailedWarning([Ent.USER, user, Ent.REQUEST_ID, requestId], str(e), i, count) break requestId = str(uuid.uuid4()) @@ -59313,7 +59324,8 @@ def createSharedDrive(users, useDomainAdminAccess=False): userSvcNotApplicableOrDriveDisabled(user, str(e), i, count) break if doUpdate and (updateBody or hide or orgUnit): - waitingForCreationToComplete(30) + if updateBody or hide: + waitingForCreationToComplete(updateInitialDelay) try: if updateBody: Act.Set(Act.UPDATE) @@ -59332,10 +59344,10 @@ def createSharedDrive(users, useDomainAdminAccess=False): break except GAPI.notFound as e: retry += 1 - if retry > 3: + if retry > errorRetries: entityActionFailedWarning([Ent.USER, user, Ent.REQUEST_ID, requestId], str(e), i, count) break - waitingForCreationToComplete(retry*15) + waitingForCreationToComplete(updateRetryDelay) except (GAPI.badRequest, GAPI.internalError, GAPI.permissionDenied) as e: entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count) break @@ -59357,12 +59369,12 @@ def createSharedDrive(users, useDomainAdminAccess=False): break except GAPI.notFound as e: retry += 1 - if retry > 3: + if retry > errorRetries: entityActionFailedWarning([Ent.USER, user, Ent.REQUEST_ID, requestId], str(e), i, count) break - time.sleep(retry*retry) + waitingForCreationToComplete(updateRetryDelay) if orgUnit: - ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci) + ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci, returnIdOnly) except (GAPI.forbidden, GAPI.badRequest, GAPI.noManageTeamDriveAdministratorPrivilege) as e: entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count) except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e: @@ -59431,7 +59443,7 @@ def updateSharedDrive(users, useDomainAdminAccess=False): driveId=driveId) entityActionPerformed([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], i, count) if orgUnit: - ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci) + ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci, False) except (GAPI.notFound, GAPI.forbidden, GAPI.badRequest, GAPI.internalError, GAPI.noManageTeamDriveAdministratorPrivilege) as e: entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)