-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command
gam print addresses [todrive <ToDriveAttribute>*]
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
""" | ||
|
||
__author__ = 'Ross Scroggs <[email protected]>' | ||
__version__ = '6.00.05' | ||
__version__ = '6.00.06' | ||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' | ||
|
||
import base64 | ||
|
@@ -13769,6 +13769,54 @@ def doPrintAliases(): | |
csvPF.WriteRow({'NonEditableAlias': alias, 'Target': group['email'], 'TargetType': 'Group'}) | ||
csvPF.writeCSVfile('Aliases') | ||
|
||
# gam print addresses [todrive <ToDriveAttribute>*] | ||
def doPrintAddresses(): | ||
cd = buildGAPIObject(API.DIRECTORY) | ||
csvPF = CSVPrintFile() | ||
titlesList = ['Type', 'Email'] | ||
userFields = ['primaryEmail', 'aliases', 'suspended'] | ||
groupFields = ['email', 'aliases'] | ||
while Cmd.ArgumentsRemaining(): | ||
myarg = getArgument() | ||
if myarg == 'todrive': | ||
csvPF.GetTodriveParameters() | ||
else: | ||
unknownArgumentExit() | ||
csvPF.SetTitles(titlesList) | ||
printGettingAllAccountEntities(Ent.USER) | ||
try: | ||
entityList = callGAPIpages(cd.users(), 'list', 'users', | ||
pageMessage=getPageMessage(showFirstLastItems=True), messageAttribute='primaryEmail', | ||
throwReasons=[GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN, GAPI.BAD_REQUEST], | ||
customer=GC.Values[GC.CUSTOMER_ID], orderBy='email', | ||
fields=f'nextPageToken,users({",".join(userFields)})', | ||
maxResults=GC.Values[GC.USER_MAX_RESULTS]) | ||
except (GAPI.resourceNotFound, GAPI.forbidden, GAPI.badRequest): | ||
accessErrorExit(cd) | ||
for user in entityList: | ||
csvPF.WriteRow({'Type': 'User' if not user['suspended'] else 'SuspendedUser', 'Email': user['primaryEmail']}) | ||
for alias in user.get('aliases', []): | ||
csvPF.WriteRow({'Type': 'UserAlias', 'Email': alias}) | ||
for alias in user.get('nonEditableAliases', []): | ||
csvPF.WriteRow({'Type': 'UserNEAlias', 'Email': alias}) | ||
printGettingAllAccountEntities(Ent.GROUP) | ||
try: | ||
entityList = callGAPIpages(cd.groups(), 'list', 'groups', | ||
pageMessage=getPageMessage(showFirstLastItems=True), messageAttribute='email', | ||
throwReasons=GAPI.GROUP_LIST_THROW_REASONS, | ||
customer=GC.Values[GC.CUSTOMER_ID], orderBy='email', | ||
fields=f'nextPageToken,groups({",".join(groupFields)})') | ||
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.forbidden, GAPI.badRequest): | ||
accessErrorExit(cd) | ||
for group in entityList: | ||
csvPF.WriteRow({'Type': 'Group', 'Email': group['email']}) | ||
for alias in group.get('aliases', []): | ||
csvPF.WriteRow({'Type': 'GroupAlias', 'Email': alias}) | ||
for alias in group.get('nonEditableAliases', []): | ||
csvPF.WriteRow({'Type': 'GroupNEAlias', 'Email': alias}) | ||
csvPF.SortRowsTwoTitles('Type', 'Email', False) | ||
csvPF.writeCSVfile('Addresses') | ||
|
||
# Contact commands utilities | ||
# | ||
CONTACT_JSON = 'JSON' | ||
|
@@ -51428,7 +51476,8 @@ def _printVacation(user, result, showDisabled): | |
), | ||
'print': | ||
(Act.PRINT, | ||
{Cmd.ARG_ADMINROLE: doPrintShowAdminRoles, | ||
{Cmd.ARG_ADDRESSES: doPrintAddresses, | ||
Cmd.ARG_ADMINROLE: doPrintShowAdminRoles, | ||
Cmd.ARG_ADMIN: doPrintShowAdmins, | ||
Cmd.ARG_ALERT: doPrintShowAlerts, | ||
Cmd.ARG_ALERTFEEDBACK: doPrintShowAlertFeedback, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters