diff --git a/src/GamCommands.txt b/src/GamCommands.txt index d6367a38..5a4b9759 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -653,7 +653,8 @@ Specify a collection of ChromeOS devices by directly specifying them (crosfile )| (croscsvfile :)| (crosquery )| - (crosqueries ) + (crosqueries )| + (cros_ou|cros_ou_and_children ) ## Collections of Users @@ -1331,7 +1332,7 @@ gam print Summary of printing: gam print cros Prints a header row and deviceId for all CrOS devices. -gam print cros +gam print Prints no header row and deviceId for specified CrOS devices. gam print cros ... basic|full Prints a header row and selected fields for specified CrOS devices. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index fc2b4c34..4ab0d64f 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -7854,14 +7854,13 @@ def doCreateOrRotateServiceAccountKeys(iam=None, body={'publicKeyData': publicKeyData}) break except googleapiclient.errors.HttpError as err: - if hasattr(err, 'error_details') and \ - err.error_details == 'The given public key already exists.': - print('WARNING: that key already exists.') - result = {'name': oldPrivateKeyId} - break - elif hasattr(err, 'error_details'): - controlflow.system_error_exit( - 4, err.error_details) + if hasattr(err, 'error_details'): + if err.error_details == 'The given public key already exists.': + print('WARNING: that key already exists.') + result = {'name': oldPrivateKeyId} + break + controlflow.system_error_exit( + 4, err.error_details) else: controlflow.system_error_exit( 4, err) @@ -8169,7 +8168,7 @@ def printShowSharedDrives(users, csvFormat): todrive = False useDomainAdminAccess = False q = None - get_orgunits = True + get_orgunits = True i = 5 while i < len(sys.argv): myarg = sys.argv[i].lower().replace('_', '') @@ -8191,7 +8190,7 @@ def printShowSharedDrives(users, csvFormat): tds = [] titles = [] if get_orgunits and useDomainAdminAccess: - ou_map = gapi_directory_orgunits.orgid_to_org_map() + ou_map = gapi_directory_orgunits.orgid_to_org_map() for user in users: sys.stderr.write(f'Getting Shared Drives for {user}\n') user, drive = buildDrive3GAPIObject(user) @@ -10294,8 +10293,13 @@ def getUsersToModify(entity_type=None, elif entity_type == 'cros': users = entity.replace(',', ' ').split() entity = 'cros' - elif entity_type in ['crosquery', 'crosqueries', 'cros_sn']: - if entity_type == 'cros_sn': + elif entity_type in ['crosquery', 'crosqueries', 'cros_sn', 'cros_ou', 'cros_ou_and_children']: + orgUnitPath = includeChildOrgunits = None + if entity_type in {'cros_ou', 'cros_ou_and_children'}: + orgUnitPath = entity + includeChildOrgunits = entity_type == 'cros_ou_and_children' + queries = [None] + elif entity_type == 'cros_sn': queries = [f'id:{sn}' for sn in shlexSplitList(entity)] elif entity_type == 'crosqueries': queries = shlexSplitList(entity) @@ -10312,9 +10316,11 @@ def getUsersToModify(entity_type=None, 'list', 'chromeosdevices', page_message=page_message, + query=query, customerId=GC_Values[GC_CUSTOMER_ID], - fields='nextPageToken,chromeosdevices(deviceId)', - query=query) + orgUnitPath=orgUnitPath, + includeChildOrgunits=includeChildOrgunits, + fields='nextPageToken,chromeosdevices(deviceId)') for member in members: deviceId = member['deviceId'] if deviceId not in usersSet: diff --git a/src/gam/var.py b/src/gam/var.py index 4f550e9b..79c70941 100644 --- a/src/gam/var.py +++ b/src/gam/var.py @@ -31,7 +31,8 @@ usergroup_types = [ 'ou_and_child', 'ou_and_children_ns', 'ou_and_child_ns', 'ou_and_children_susp', 'ou_and_child_susp', 'query', 'queries', 'license', 'licenses', 'licence', 'licences', 'file', 'csv', 'csvfile', 'all', 'cros', - 'cros_sn', 'crosquery', 'crosqueries', 'crosfile', 'croscsv', 'croscsvfile' + 'cros_sn', 'crosquery', 'crosqueries', 'crosfile', 'croscsv', 'croscsvfile', + 'cros_ou', 'cros_ou_and_children' ] ERROR_PREFIX = 'ERROR: ' WARNING_PREFIX = 'WARNING: '