Skip to content

Commit

Permalink
Following Jay's lead, added additional columns to `gam print chromehi…
Browse files Browse the repository at this point in the history
…story`.
  • Loading branch information
taers232c committed Apr 8, 2021
1 parent 936990f commit 00cd6ae
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 28 deletions.
4 changes: 4 additions & 0 deletions src/GamUpdate.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.01.07

Following Jay's lead, added additional columns to `gam print chromehistory`.

6.01.06

Updated `gam whatis <EmailItem>` to check if `<EmailItem>` is an unmanaged account
Expand Down
46 changes: 42 additions & 4 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

__author__ = 'Ross Scroggs <[email protected]>'
__version__ = '6.01.06'
__version__ = '6.01.07'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'

import base64
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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]))):
Expand All @@ -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:
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
47 changes: 23 additions & 24 deletions src/gam/gamlib/glapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
CLOUDRESOURCEMANAGER_V2 = 'cloudresourcemanager2'
CONTACTS = 'contacts'
CONTACTDELEGATION = 'contactdelegation'
DATASTUDIO = 'datastudio'
DATATRANSFER = 'datatransfer'
DIRECTORY = 'directory'
DOCS = 'docs'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/gam/gamlib/glclargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 00cd6ae

Please sign in to comment.