From 00cd6ae872c575139375477bd8f6d5de10d0a6ba Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 7 Apr 2021 20:27:36 -0700 Subject: [PATCH] Following Jay's lead, added additional columns to `gam print chromehistory`. --- src/GamUpdate.txt | 4 ++++ src/gam/__init__.py | 46 +++++++++++++++++++++++++++++++++---- src/gam/gamlib/glapi.py | 47 +++++++++++++++++++------------------- src/gam/gamlib/glclargs.py | 2 ++ 4 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 314bc0f2..8d85cbbf 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,7 @@ +6.01.07 + +Following Jay's lead, added additional columns to `gam print chromehistory`. + 6.01.06 Updated `gam whatis ` to check if `` is an unmanaged account diff --git a/src/gam/__init__.py b/src/gam/__init__.py index dde5b71b..d6a8149e 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -23,7 +23,7 @@ """ __author__ = 'Ross Scroggs ' -__version__ = '6.01.06' +__version__ = '6.01.07' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' import base64 @@ -20229,9 +20229,13 @@ def getRelativeMilestone(channel='stable', minus=0): } CHROME_VERSIONHISTORY_TITLES = { Ent.CHROME_PLATFORM: ['platformType'], - Ent.CHROME_CHANNEL: ['channelType'], - Ent.CHROME_VERSION: ['version'], - Ent.CHROME_RELEASE: ['version', 'fraction', 'serving.startTime', 'serving.endTime'] + Ent.CHROME_CHANNEL: ['platformType', 'channelType'], + Ent.CHROME_VERSION: ['platformType', 'channelType', 'version', + 'major_version', 'minor_version', 'build', 'patch'], + Ent.CHROME_RELEASE: ['platformType', 'channelType','version', + 'major_version', 'minor_version', 'build', 'patch', + 'fraction', 'serving.startTime', 'serving.endTime'] + } CHROME_VERSIONHISTORY_ITEMS = { Ent.CHROME_PLATFORM: 'platforms', @@ -20281,7 +20285,26 @@ def getRelativeMilestone(channel='stable', minus=0): # [formatjson] def doPrintShowChromeHistory(): + def addDetailFields(citem): + if 'channelType' not in citem: + channel_match = re.search(r"\/channels\/([^/]*)", citem['name']) + if channel_match: + try: + citem['channelType'] = channel_match.group(1) + except IndexError: + pass + if 'platformType' not in citem: + platform_match = re.search(r"\/platforms\/([^/]*)", citem['name']) + if platform_match: + try: + citem['platformType'] = platform_match.group(1) + except IndexError: + pass + if citem.get('version', '').count('.') == 3: + citem['major_version'], citem['minor_version'], citem['build'], citem['patch'] = citem['version'].split('.') + def _printItem(citem): + addDetailFields(citem) if FJQC.formatJSON: if (((not csvPF.rowFilter and not csvPF.rowDropFilter)) or csvPF.CheckRowTitles(flattenJSON(citem, timeObjects=CHROME_VERSIONHISTORY_TIMEOBJECTS[entityType]))): @@ -20292,6 +20315,7 @@ def _printItem(citem): csvPF.WriteRow(flattenJSON(citem, timeObjects=CHROME_VERSIONHISTORY_TIMEOBJECTS[entityType])) def _showItem(citem, i=0, count=0): + addDetailFields(citem) if FJQC.formatJSON: printLine(json.dumps(cleanJSON(citem), ensure_ascii=False, sort_keys=True)) else: @@ -20367,6 +20391,19 @@ def _showItem(citem, i=0, count=0): if csvPF: csvPF.writeCSVfile(Ent.Plural(entityType)) + +#def buildGAPIDataStudioServiceObject(): +# _, ds = buildGAPIServiceObject(API.DATASTUDIO, _getAdminEmail(), displayError=True) +# if not ds: +# sys.exit(GM.Globals[GM.SYSEXITRC]) +# return ds +# +#def doPrintShowDataStudio(): +# ds = buildGAPIDataStudioServiceObject() +# assets = callGAPIpages(ds.assets(), 'search', 'assets', +# fields='nextPageToken,assets)') +# print(assets) + # Mobile command utilities MOBILE_ACTION_CHOICE_MAP = { 'accountwipe': 'admin_account_wipe', @@ -52173,6 +52210,7 @@ def _printVacation(user, result, showDisabled): Cmd.ARG_COURSEWORK: doPrintCourseWork, Cmd.ARG_CROS: doPrintCrOSDevices, Cmd.ARG_CROSACTIVITY: doPrintCrOSActivity, +# Cmd.ARG_DATASTUDIO: doPrintShowDataStudio, Cmd.ARG_DATATRANSFER: doPrintShowDataTransfers, Cmd.ARG_DEVICE: doPrintCIDevices, Cmd.ARG_DEVICEUSER: doPrintCIDeviceUsers, diff --git a/src/gam/gamlib/glapi.py b/src/gam/gamlib/glapi.py index 802f343c..bb9e1d17 100644 --- a/src/gam/gamlib/glapi.py +++ b/src/gam/gamlib/glapi.py @@ -35,6 +35,7 @@ CLOUDRESOURCEMANAGER_V2 = 'cloudresourcemanager2' CONTACTS = 'contacts' CONTACTDELEGATION = 'contactdelegation' +DATASTUDIO = 'datastudio' DATATRANSFER = 'datatransfer' DIRECTORY = 'directory' DOCS = 'docs' @@ -113,6 +114,7 @@ 'cloudidentity.googleapis.com', 'cloudresourcemanager.googleapis.com', 'contacts.googleapis.com', + 'datastudio.googleapis.com', 'docs.googleapis.com', 'drive.googleapis.com', 'driveactivity.googleapis.com', @@ -146,6 +148,7 @@ CLOUDRESOURCEMANAGER_V2: {'name': 'Cloud Resource Manager API v2', 'version': 'v2', 'v2discovery': True, 'mappedAPI': 'cloudresourcemanager'}, CONTACTS: {'name': 'Contacts API', 'version': 'v3', 'v2discovery': False}, CONTACTDELEGATION: {'name': 'Contact Delegation API', 'version': 'v1', 'v2discovery': True, 'localjson': True}, + DATASTUDIO: {'name': 'Data Studio API', 'version': 'v1', 'v2discovery': True}, DATATRANSFER: {'name': 'Data Transfer API', 'version': 'datatransfer_v1', 'v2discovery': False, 'mappedAPI': 'admin'}, DIRECTORY: {'name': 'Directory API', 'version': 'directory_v1', 'v2discovery': False, 'mappedAPI': 'admin'}, DOCS: {'name': 'Docs API', 'version': 'v1', 'v2discovery': True}, @@ -182,30 +185,22 @@ 'api': CALENDAR, 'subscopes': READONLY, 'scope': 'https://www.googleapis.com/auth/calendar'}, - { - 'name': 'Chrome Browser Cloud Management API', - 'api': CBCM, - 'subscopes': READONLY, - 'scope': 'https://www.googleapis.com/auth/admin.directory.device.chromebrowsers', - }, - { - 'name': 'Chrome Management API - read only', - 'api': CHROMEMANAGEMENT, - 'subscopes': [], - 'scope': 'https://www.googleapis.com/auth/chrome.management.reports.readonly', - }, - { - 'name': 'Chrome Policy API', - 'api': CHROMEPOLICY, - 'subscopes': READONLY, - 'scope': 'https://www.googleapis.com/auth/chrome.management.policy', - }, - { - 'name': 'Chrome Version History API', - 'api': CHROMEVERSIONHISTORY, - 'subscopes': [], - 'scope': '', - }, + {'name': 'Chrome Browser Cloud Management API', + 'api': CBCM, + 'subscopes': READONLY, + 'scope': 'https://www.googleapis.com/auth/admin.directory.device.chromebrowsers',}, + {'name': 'Chrome Management API - read only', + 'api': CHROMEMANAGEMENT, + 'subscopes': [], + 'scope': 'https://www.googleapis.com/auth/chrome.management.reports.readonly',}, + {'name': 'Chrome Policy API', + 'api': CHROMEPOLICY, + 'subscopes': READONLY, + 'scope': 'https://www.googleapis.com/auth/chrome.management.policy',}, + {'name': 'Chrome Version History API', + 'api': CHROMEVERSIONHISTORY, + 'subscopes': [], + 'scope': '',}, {'name': 'Classroom API - Courses', 'api': CLASSROOM, 'subscopes': READONLY, @@ -425,6 +420,10 @@ 'api': CONTACTS, 'subscopes': [], 'scope': 'https://www.google.com/m8/feeds'}, +# {'name': 'Data Studio API', +# 'api': DATASTUDIO, +# 'subscopes': READONLY, +# 'scope': 'https://www.googleapis.com/auth/datastudio'}, {'name': 'Drive API', 'api': DRIVE3, 'subscopes': READONLY, diff --git a/src/gam/gamlib/glclargs.py b/src/gam/gamlib/glclargs.py index e528642e..a8bba6dc 100644 --- a/src/gam/gamlib/glclargs.py +++ b/src/gam/gamlib/glclargs.py @@ -410,6 +410,7 @@ class GamCLArgs(): ARG_CROSES = 'croses' ARG_CROSACTIVITY = 'crosactivity' ARG_CUSTOMER = 'customer' + ARG_DATASTUDIO = 'datastudio' ARG_DATATRANSFER = 'datatransfer' ARG_DATATRANSFERS = 'datatransfers' ARG_DELEGATE = 'delegate' @@ -605,6 +606,7 @@ class GamCLArgs(): OB_APP_ID = 'AppID' OB_ARGUMENT = 'argument' OB_ASP_ID_LIST = 'ASPIDList' + OB_ASSET_ID = 'AssetID' OB_BROWSER_ENROLLEMNT_TOKEN_ID = 'BrowserEnrollmentTokenID' OB_BROWSER_ENTITY = 'BrowserEntity' OB_BUILDING_ID = 'BuildingID'