Updated gam print|show businessprofileaccounts to svcacct access

This commit is contained in:
Ross Scroggs
2026-04-08 20:52:08 -07:00
parent 7798504282
commit ddda0593f2
4 changed files with 58 additions and 38 deletions

View File

@@ -3514,13 +3514,6 @@ gam print guardian|guardians [todrive <ToDriveAttribute>*] [accepted|invitations
[showstudentemails] [showstudentemails]
[formatjson [quotechar <Character>]] [formatjson [quotechar <Character>]]
# Business Profile Accounts
gam show businessprofileaccounts
[type locationgroup|organization|personal|usergroup]
gam print businessprofileaccounts [todrive <ToDriveAttribute>*]
[type locationgroup|organization|personal|usergroup]
# Classroom User Profiles # Classroom User Profiles
gam <UserTypeEntity> print classroomprofile [todrive <ToDriveAttribute>*] gam <UserTypeEntity> print classroomprofile [todrive <ToDriveAttribute>*]
@@ -6100,6 +6093,13 @@ gam <UserTypeEntity> show backupcodes|verificationcodes
gam <UserTypeEntity> print backupcodes|verificationcodes [todrive <ToDriveAttribute>*] gam <UserTypeEntity> print backupcodes|verificationcodes [todrive <ToDriveAttribute>*]
[delimiter <Character>] [countsonly] [delimiter <Character>] [countsonly]
# Users - Business Profile Accounts
gam <UserTypeEntity> show businessprofileaccounts
[type locationgroup|organization|personal|usergroup]
gam <UserTypeEntity> print businessprofileaccounts [todrive <ToDriveAttribute>*]
[type locationgroup|organization|personal|usergroup]
# Users - Calendars # Users - Calendars
<CalendarACLRole> ::= editor|freebusy|freebusyreader|owner|reader|writer <CalendarACLRole> ::= editor|freebusy|freebusyreader|owner|reader|writer

View File

@@ -1,3 +1,10 @@
7.40.00
Updated `gam print|show businessprofileaccounts` (client access) to
`gam <UserTypeEntity> print|show businessprofileaccounts` (service account access).
You'll need to run `gam user user@domain.com update serviceaccount` and
select `2) Business Account Management API`.
7.39.08 7.39.08
Fixed bug in `gam oauth create` that caused a trap when `0) Business Account Management API` was selected. Fixed bug in `gam oauth create` that caused a trap when `0) Business Account Management API` was selected.

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
""" """
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>' __author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.39.08' __version__ = '7.40.00'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
# pylint: disable=wrong-import-position # pylint: disable=wrong-import-position
@@ -49336,13 +49336,12 @@ PROFILE_ACCOUNT_TYPE_MAP = {
'usergroup': 'USER_GROUP', 'usergroup': 'USER_GROUP',
} }
# gam show businessprofileaccounts # gam <UserTypeEntity> show businessprofileaccounts
# [type locationgroup|organization|personal|usergroup] # [type locationgroup|organization|personal|usergroup]
# gam print businessprofileaccounts [todrive <ToDriveAttribute>*] # gam <UserTypeEntity> print businessprofileaccounts [todrive <ToDriveAttribute>*]
# [type locationgroup|organization|personal|usergroup] # [type locationgroup|organization|personal|usergroup]
def doPrintShowBusinessProfileAccounts(): def printShowBusinessProfileAccounts(users):
bp = buildGAPIObject(API.BUSINESSACCOUNTMANAGEMENT) csvPF = CSVPrintFile(['User', 'name', 'accountName']) if Act.csvFormat() else None
csvPF = CSVPrintFile(['name', 'accountName']) if Act.csvFormat() else None
kwargs = {} kwargs = {}
while Cmd.ArgumentsRemaining(): while Cmd.ArgumentsRemaining():
myarg = getArgument() myarg = getArgument()
@@ -49352,25 +49351,40 @@ def doPrintShowBusinessProfileAccounts():
kwargs['filter'] = f'type={getChoice(PROFILE_ACCOUNT_TYPE_MAP, mapChoice=True)}' kwargs['filter'] = f'type={getChoice(PROFILE_ACCOUNT_TYPE_MAP, mapChoice=True)}'
else: else:
unknownArgumentExit() unknownArgumentExit()
try: i, count, users = getEntityArgument(users)
accounts = callGAPIpages(bp.accounts(), 'list', 'accounts', for user in users:
throwReasons=[GAPI.PERMISSION_DENIED], i += 1
**kwargs) user, bp = buildGAPIServiceObject(API.BUSINESSACCOUNTMANAGEMENT, user, i, count)
except GAPI.permissionDenied as e: if not bp:
accessErrorExitNonDirectory(API.BUSINESSACCOUNTMANAGEMENT, str(e)) continue
if not csvPF: if csvPF:
count = len(accounts) printGettingAllEntityItemsForWhom(Ent.BUSINESS_PROFILE_ACCOUNT, user, i, count, query=kwargs.get('filter'))
i = 0 pageMessage = getPageMessageForWhom()
for account in sorted(accounts, key=lambda k: k['name']): else:
i += 1 pageMessage = None
printKeyValueListWithCount(['Account', account['name']], i, count) try:
accounts = callGAPIpages(bp.accounts(), 'list', 'accounts',
pageMessage=pageMessage,
throwReasons=[GAPI.PERMISSION_DENIED],
**kwargs)
except GAPI.permissionDenied as e:
accessErrorExitNonDirectory(API.BUSINESSACCOUNTMANAGEMENT, str(e))
if not csvPF:
jcount = len(accounts)
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.BUSINESS_PROFILE_ACCOUNT, i, count)
Ind.Increment() Ind.Increment()
showJSON(None, account) j = 0
for account in sorted(accounts, key=lambda k: k['name']):
j += 1
printKeyValueListWithCount(['Account', account['name']], j, jcount)
Ind.Increment()
showJSON(None, account)
Ind.Decrement()
Ind.Decrement() Ind.Decrement()
else: else:
for account in accounts: for account in accounts:
row = flattenJSON(account, flattened={'name': account['name'], 'accountName': account['accountName']}) row = flattenJSON(account, flattened={'User': user, 'name': account['name'], 'accountName': account['accountName']})
csvPF.WriteRowTitles(row) csvPF.WriteRowTitles(row)
if csvPF: if csvPF:
csvPF.writeCSVfile('Business Profile Accounts') csvPF.writeCSVfile('Business Profile Accounts')
@@ -80340,7 +80354,6 @@ MAIN_COMMANDS_WITH_OBJECTS = {
Cmd.ARG_BROWSER: doPrintShowBrowsers, Cmd.ARG_BROWSER: doPrintShowBrowsers,
Cmd.ARG_BROWSERTOKEN: doPrintShowBrowserTokens, Cmd.ARG_BROWSERTOKEN: doPrintShowBrowserTokens,
Cmd.ARG_BUILDING: doPrintShowBuildings, Cmd.ARG_BUILDING: doPrintShowBuildings,
Cmd.ARG_BUSINESSPROFILEACCOUNT: doPrintShowBusinessProfileAccounts,
Cmd.ARG_CAALEVEL: doPrintShowCAALevels, Cmd.ARG_CAALEVEL: doPrintShowCAALevels,
Cmd.ARG_CHANNELCUSTOMER: doPrintShowChannelCustomers, Cmd.ARG_CHANNELCUSTOMER: doPrintShowChannelCustomers,
Cmd.ARG_CHANNELCUSTOMERENTITLEMENT: doPrintShowChannelCustomerEntitlements, Cmd.ARG_CHANNELCUSTOMERENTITLEMENT: doPrintShowChannelCustomerEntitlements,
@@ -80479,7 +80492,6 @@ MAIN_COMMANDS_WITH_OBJECTS = {
Cmd.ARG_BROWSER: doPrintShowBrowsers, Cmd.ARG_BROWSER: doPrintShowBrowsers,
Cmd.ARG_BROWSERTOKEN: doPrintShowBrowserTokens, Cmd.ARG_BROWSERTOKEN: doPrintShowBrowserTokens,
Cmd.ARG_BUILDING: doPrintShowBuildings, Cmd.ARG_BUILDING: doPrintShowBuildings,
Cmd.ARG_BUSINESSPROFILEACCOUNT: doPrintShowBusinessProfileAccounts,
Cmd.ARG_CAALEVEL: doPrintShowCAALevels, Cmd.ARG_CAALEVEL: doPrintShowCAALevels,
Cmd.ARG_CHANNELCUSTOMER: doPrintShowChannelCustomers, Cmd.ARG_CHANNELCUSTOMER: doPrintShowChannelCustomers,
Cmd.ARG_CHANNELCUSTOMERENTITLEMENT: doPrintShowChannelCustomerEntitlements, Cmd.ARG_CHANNELCUSTOMERENTITLEMENT: doPrintShowChannelCustomerEntitlements,
@@ -80671,7 +80683,6 @@ MAIN_COMMANDS_OBJ_ALIASES = {
Cmd.ARG_BUCKET: Cmd.ARG_STORAGEBUCKET, Cmd.ARG_BUCKET: Cmd.ARG_STORAGEBUCKET,
Cmd.ARG_BUCKETS: Cmd.ARG_STORAGEBUCKET, Cmd.ARG_BUCKETS: Cmd.ARG_STORAGEBUCKET,
Cmd.ARG_BUILDINGS: Cmd.ARG_BUILDING, Cmd.ARG_BUILDINGS: Cmd.ARG_BUILDING,
Cmd.ARG_BUSINESSPROFILEACCOUNTS: Cmd.ARG_BUSINESSPROFILEACCOUNT,
Cmd.ARG_CAALEVELS: Cmd.ARG_CAALEVEL, Cmd.ARG_CAALEVELS: Cmd.ARG_CAALEVEL,
Cmd.ARG_CHATMEMBERS: Cmd.ARG_CHATMEMBER, Cmd.ARG_CHATMEMBERS: Cmd.ARG_CHATMEMBER,
Cmd.ARG_CHANNELCUSTOMERS: Cmd.ARG_CHANNELCUSTOMER, Cmd.ARG_CHANNELCUSTOMERS: Cmd.ARG_CHANNELCUSTOMER,
@@ -81415,6 +81426,7 @@ USER_COMMANDS_WITH_OBJECTS = {
Cmd.ARG_ANALYTICPROPERTY: printShowAnalyticProperties, Cmd.ARG_ANALYTICPROPERTY: printShowAnalyticProperties,
Cmd.ARG_ASP: printShowASPs, Cmd.ARG_ASP: printShowASPs,
Cmd.ARG_BACKUPCODE: printShowBackupCodes, Cmd.ARG_BACKUPCODE: printShowBackupCodes,
Cmd.ARG_BUSINESSPROFILEACCOUNT: printShowBusinessProfileAccounts,
Cmd.ARG_CALENDAR: printShowCalendars, Cmd.ARG_CALENDAR: printShowCalendars,
Cmd.ARG_CALENDARACL: printShowCalendarACLs, Cmd.ARG_CALENDARACL: printShowCalendarACLs,
Cmd.ARG_CALSETTINGS: printShowCalSettings, Cmd.ARG_CALSETTINGS: printShowCalSettings,
@@ -81532,6 +81544,7 @@ USER_COMMANDS_WITH_OBJECTS = {
Cmd.ARG_ANALYTICPROPERTY: printShowAnalyticProperties, Cmd.ARG_ANALYTICPROPERTY: printShowAnalyticProperties,
Cmd.ARG_ASP: printShowASPs, Cmd.ARG_ASP: printShowASPs,
Cmd.ARG_BACKUPCODE: printShowBackupCodes, Cmd.ARG_BACKUPCODE: printShowBackupCodes,
Cmd.ARG_BUSINESSPROFILEACCOUNT: printShowBusinessProfileAccounts,
Cmd.ARG_CALENDAR: printShowCalendars, Cmd.ARG_CALENDAR: printShowCalendars,
Cmd.ARG_CALENDARACL: printShowCalendarACLs, Cmd.ARG_CALENDARACL: printShowCalendarACLs,
Cmd.ARG_CALSETTINGS: printShowCalSettings, Cmd.ARG_CALSETTINGS: printShowCalSettings,
@@ -81755,6 +81768,7 @@ USER_COMMANDS_OBJ_ALIASES = {
Cmd.ARG_ANALYTICPROPERTIES: Cmd.ARG_ANALYTICPROPERTY, Cmd.ARG_ANALYTICPROPERTIES: Cmd.ARG_ANALYTICPROPERTY,
Cmd.ARG_ASPS: Cmd.ARG_ASP, Cmd.ARG_ASPS: Cmd.ARG_ASP,
Cmd.ARG_BACKUPCODES: Cmd.ARG_BACKUPCODE, Cmd.ARG_BACKUPCODES: Cmd.ARG_BACKUPCODE,
Cmd.ARG_BUSINESSPROFILEACCOUNTS: Cmd.ARG_BUSINESSPROFILEACCOUNT,
Cmd.ARG_CALENDARS: Cmd.ARG_CALENDAR, Cmd.ARG_CALENDARS: Cmd.ARG_CALENDAR,
Cmd.ARG_CALENDARACLS: Cmd.ARG_CALENDARACL, Cmd.ARG_CALENDARACLS: Cmd.ARG_CALENDARACL,
Cmd.ARG_CLASSIFICATIONLABEL: Cmd.ARG_DRIVELABEL, Cmd.ARG_CLASSIFICATIONLABEL: Cmd.ARG_DRIVELABEL,

View File

@@ -140,7 +140,6 @@ SCOPELESS_APIS = {
# Scopes not in the discovery doc that are still valid for the API. # Scopes not in the discovery doc that are still valid for the API.
EXTRA_SCOPES = { EXTRA_SCOPES = {
BUSINESSACCOUNTMANAGEMENT: ['https://www.googleapis.com/auth/business.manage'],
CLOUDRESOURCEMANAGER: ['https://www.googleapis.com/auth/cloudplatformfolders', CLOUDRESOURCEMANAGER: ['https://www.googleapis.com/auth/cloudplatformfolders',
'https://www.googleapis.com/auth/cloudplatformfolders.readonly', 'https://www.googleapis.com/auth/cloudplatformfolders.readonly',
'https://www.googleapis.com/auth/cloudplatformprojects', 'https://www.googleapis.com/auth/cloudplatformprojects',
@@ -318,10 +317,6 @@ _INFO = {
READONLY = ['readonly',] READONLY = ['readonly',]
_CLIENT_SCOPES = [ _CLIENT_SCOPES = [
{'name': 'Business Account Management API',
'api': BUSINESSACCOUNTMANAGEMENT,
'offByDefault': True,
'scope': EXTRA_SCOPES[BUSINESSACCOUNTMANAGEMENT]},
{'name': 'Calendar API', {'name': 'Calendar API',
'api': CALENDAR, 'api': CALENDAR,
'subscopes': READONLY, 'subscopes': READONLY,
@@ -568,6 +563,10 @@ _SVCACCT_SCOPES = [
{'name': 'Analytics Admin API - readonly', {'name': 'Analytics Admin API - readonly',
'api': ANALYTICS_ADMIN, 'api': ANALYTICS_ADMIN,
'scope': 'https://www.googleapis.com/auth/analytics.readonly'}, 'scope': 'https://www.googleapis.com/auth/analytics.readonly'},
{'name': 'Business Account Management API',
'api': BUSINESSACCOUNTMANAGEMENT,
'offByDefault': True,
'scope': 'https://www.googleapis.com/auth/business.manage'},
{'name': 'Calendar API', {'name': 'Calendar API',
'api': CALENDAR, 'api': CALENDAR,
'subscopes': READONLY, 'subscopes': READONLY,