mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Improved output of gam info|show chromeschemas
This commit is contained in:
@@ -2725,6 +2725,7 @@ gam print chromschemas [todrive <ToDriveAttribute>*]
|
|||||||
<ChromePolicySchemaFieldName>* [fields <ChromePolicySchemaFieldNameList>]
|
<ChromePolicySchemaFieldName>* [fields <ChromePolicySchemaFieldNameList>]
|
||||||
[[formatjson [quotechar <Character>]]
|
[[formatjson [quotechar <Character>]]
|
||||||
|
|
||||||
|
gam info chromeschema std <SchemaName>
|
||||||
gam show chromeschemas std
|
gam show chromeschemas std
|
||||||
[filter <String>]
|
[filter <String>]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
7.09.02
|
||||||
|
|
||||||
|
Added command `gam info chromeschema std <SchemaName>` to display a Chrome policy schema in the same format as Legacy GAM.
|
||||||
|
|
||||||
|
Improved output of `gam show chromeschemas [std]` and `gam info chromeschema [std]` to more accurately display the schemas.
|
||||||
|
|
||||||
7.09.01
|
7.09.01
|
||||||
|
|
||||||
Fixed bug in `gam <UserTypeEntity> print diskusage` where the `ownedByMe` column was
|
Fixed bug in `gam <UserTypeEntity> print diskusage` where the `ownedByMe` column was
|
||||||
|
|||||||
@@ -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.09.01'
|
__version__ = '7.09.02'
|
||||||
__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
|
||||||
@@ -25947,7 +25947,7 @@ def exitIfChatNotConfigured(chat, kvList, errMsg, i, count):
|
|||||||
if (('No bot associated with this project.' in errMsg) or
|
if (('No bot associated with this project.' in errMsg) or
|
||||||
('Invalid project number.' in errMsg) or
|
('Invalid project number.' in errMsg) or
|
||||||
('Google Chat app not found.' in errMsg)):
|
('Google Chat app not found.' in errMsg)):
|
||||||
systemErrorExit(API_ACCESS_DENIED_RC, Msg.TO_SET_UP_GOOGLE_CHAT.format(setupChatURL(chat)))
|
systemErrorExit(API_ACCESS_DENIED_RC, Msg.TO_SET_UP_GOOGLE_CHAT.format(setupChatURL(chat), GM.Globals[GM.OAUTH2SERVICE_JSON_DATA]['project_id']))
|
||||||
entityActionFailedWarning(kvList, errMsg, i, count)
|
entityActionFailedWarning(kvList, errMsg, i, count)
|
||||||
|
|
||||||
def _getChatAdminAccess(adminAPI, userAPI):
|
def _getChatAdminAccess(adminAPI, userAPI):
|
||||||
@@ -28119,7 +28119,9 @@ def simplifyChromeSchema(schema):
|
|||||||
}
|
}
|
||||||
fieldDescriptions = schema['fieldDescriptions']
|
fieldDescriptions = schema['fieldDescriptions']
|
||||||
savedSettingName = ''
|
savedSettingName = ''
|
||||||
|
savedTypeName = ''
|
||||||
for mtype in schema['definition']['messageType']:
|
for mtype in schema['definition']['messageType']:
|
||||||
|
numSettings = len(mtype['field'])
|
||||||
for setting in mtype['field']:
|
for setting in mtype['field']:
|
||||||
setting_name = setting['name']
|
setting_name = setting['name']
|
||||||
setting_dict = {'name': setting_name,
|
setting_dict = {'name': setting_name,
|
||||||
@@ -28127,9 +28129,9 @@ def simplifyChromeSchema(schema):
|
|||||||
'descriptions': [],
|
'descriptions': [],
|
||||||
'type': setting['type'],
|
'type': setting['type'],
|
||||||
}
|
}
|
||||||
if setting_dict['type'] == 'TYPE_INT64' and savedSettingName:
|
if mtype['name'] == savedTypeName and numSettings == 1:
|
||||||
setting_dict['name'] = savedSettingName
|
setting_dict['name'] = savedSettingName
|
||||||
savedSettingName = ''
|
savedTypeName = ''
|
||||||
if setting_dict['type'] == 'TYPE_STRING' and setting.get('label') == 'LABEL_REPEATED':
|
if setting_dict['type'] == 'TYPE_STRING' and setting.get('label') == 'LABEL_REPEATED':
|
||||||
setting_dict['type'] = 'TYPE_LIST'
|
setting_dict['type'] = 'TYPE_LIST'
|
||||||
if setting_dict['type'] == 'TYPE_ENUM':
|
if setting_dict['type'] == 'TYPE_ENUM':
|
||||||
@@ -28152,6 +28154,7 @@ def simplifyChromeSchema(schema):
|
|||||||
break
|
break
|
||||||
elif setting_dict['type'] == 'TYPE_MESSAGE':
|
elif setting_dict['type'] == 'TYPE_MESSAGE':
|
||||||
savedSettingName = setting_name
|
savedSettingName = setting_name
|
||||||
|
savedTypeName = setting['typeName']
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
setting_dict['enums'] = None
|
setting_dict['enums'] = None
|
||||||
@@ -28928,7 +28931,7 @@ def _showChromePolicySchema(schema, FJQC, i=0, count=0):
|
|||||||
return
|
return
|
||||||
printEntity([Ent.CHROME_POLICY_SCHEMA, schema['name']], i, count)
|
printEntity([Ent.CHROME_POLICY_SCHEMA, schema['name']], i, count)
|
||||||
Ind.Increment()
|
Ind.Increment()
|
||||||
showJSON(None, schema)
|
showJSON(None, schema, dictObjectsKey={'messageType': 'name', 'field': 'name'})
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
|
|
||||||
CHROME_POLICY_SCHEMA_FIELDS_CHOICE_MAP = {
|
CHROME_POLICY_SCHEMA_FIELDS_CHOICE_MAP = {
|
||||||
@@ -28951,6 +28954,9 @@ CHROME_POLICY_SCHEMA_FIELDS_CHOICE_MAP = {
|
|||||||
# [formatjson]
|
# [formatjson]
|
||||||
def doInfoChromePolicySchemas():
|
def doInfoChromePolicySchemas():
|
||||||
cp = buildGAPIObject(API.CHROMEPOLICY)
|
cp = buildGAPIObject(API.CHROMEPOLICY)
|
||||||
|
if checkArgumentPresent('std'):
|
||||||
|
doInfoChromePolicySchemasStd(cp)
|
||||||
|
return
|
||||||
FJQC = FormatJSONQuoteChar()
|
FJQC = FormatJSONQuoteChar()
|
||||||
fieldsList = []
|
fieldsList = []
|
||||||
name = _getChromePolicySchemaName()
|
name = _getChromePolicySchemaName()
|
||||||
@@ -28979,7 +28985,7 @@ def doInfoChromePolicySchemas():
|
|||||||
# [filter <String>]
|
# [filter <String>]
|
||||||
# <ChromePolicySchemaFieldName>* [fields <ChromePolicySchemaFieldNameList>]
|
# <ChromePolicySchemaFieldName>* [fields <ChromePolicySchemaFieldNameList>]
|
||||||
# [[formatjson [quotechar <Character>]]
|
# [[formatjson [quotechar <Character>]]
|
||||||
def doPrintShowChromeSchemas():
|
def doPrintShowChromePolicySchemas():
|
||||||
def _printChromePolicySchema(schema):
|
def _printChromePolicySchema(schema):
|
||||||
row = flattenJSON(schema)
|
row = flattenJSON(schema)
|
||||||
if not FJQC.formatJSON:
|
if not FJQC.formatJSON:
|
||||||
@@ -28993,10 +28999,12 @@ def doPrintShowChromeSchemas():
|
|||||||
row['JSON'] = json.dumps(cleanJSON(schema), ensure_ascii=False, sort_keys=True)
|
row['JSON'] = json.dumps(cleanJSON(schema), ensure_ascii=False, sort_keys=True)
|
||||||
csvPF.WriteRowNoFilter(row)
|
csvPF.WriteRowNoFilter(row)
|
||||||
|
|
||||||
if checkArgumentPresent('std'):
|
|
||||||
doShowChromeSchemasStd()
|
|
||||||
return
|
|
||||||
cp = buildGAPIObject(API.CHROMEPOLICY)
|
cp = buildGAPIObject(API.CHROMEPOLICY)
|
||||||
|
if checkArgumentPresent('std'):
|
||||||
|
if not Act.csvFormat():
|
||||||
|
doShowChromePolicySchemasStd(cp)
|
||||||
|
return
|
||||||
|
unknownArgumentExit()
|
||||||
parent = _getCustomersCustomerIdWithC()
|
parent = _getCustomersCustomerIdWithC()
|
||||||
csvPF = CSVPrintFile(['name', 'schemaName', 'policyDescription',
|
csvPF = CSVPrintFile(['name', 'schemaName', 'policyDescription',
|
||||||
'policyApiLifecycle.policyApiLifecycleStage',
|
'policyApiLifecycle.policyApiLifecycleStage',
|
||||||
@@ -29056,28 +29064,10 @@ def doPrintShowChromeSchemas():
|
|||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('Chrome Policy Schemas')
|
csvPF.writeCSVfile('Chrome Policy Schemas')
|
||||||
|
|
||||||
# gam show chromeschemas std [filter <String>]
|
def _showChromePolicySchemaStd(schema):
|
||||||
def doShowChromeSchemasStd():
|
printKeyValueList([f'{schema.get("name")}', f'{schema.get("description")}'])
|
||||||
cp = buildGAPIObject(API.CHROMEPOLICY)
|
|
||||||
sfilter = None
|
|
||||||
while Cmd.ArgumentsRemaining():
|
|
||||||
myarg = getArgument()
|
|
||||||
if myarg == 'filter':
|
|
||||||
sfilter = getString(Cmd.OB_STRING)
|
|
||||||
else:
|
|
||||||
unknownArgumentExit()
|
|
||||||
parent = _getCustomersCustomerIdWithC()
|
|
||||||
result = callGAPIpages(cp.customers().policySchemas(), 'list', 'policySchemas',
|
|
||||||
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
||||||
parent=parent, filter=sfilter)
|
|
||||||
schemas = {}
|
|
||||||
for schema in result:
|
|
||||||
schema_name, schema_dict = simplifyChromeSchema(schema)
|
|
||||||
schemas[schema_name.lower()] = schema_dict
|
|
||||||
for _, value in sorted(iter(schemas.items())):
|
|
||||||
printKeyValueList([f'{value.get("name")}', f'{value.get("description")}'])
|
|
||||||
Ind.Increment()
|
Ind.Increment()
|
||||||
for val in value['settings'].values():
|
for val in schema['settings'].values():
|
||||||
vtype = val.get('type')
|
vtype = val.get('type')
|
||||||
printKeyValueList([f'{val.get("name")}', f'{vtype}'])
|
printKeyValueList([f'{val.get("name")}', f'{vtype}'])
|
||||||
Ind.Increment()
|
Ind.Increment()
|
||||||
@@ -29101,6 +29091,41 @@ def doShowChromeSchemasStd():
|
|||||||
printKeyValueList([f'{description[0]}'])
|
printKeyValueList([f'{description[0]}'])
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
|
|
||||||
|
# gam info chromeschema std <SchemaName>
|
||||||
|
def doInfoChromePolicySchemasStd(cp):
|
||||||
|
name = _getChromePolicySchemaName()
|
||||||
|
checkForExtraneousArguments()
|
||||||
|
try:
|
||||||
|
schema = callGAPI(cp.customers().policySchemas(), 'get',
|
||||||
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
||||||
|
name=name)
|
||||||
|
_, schema_dict = simplifyChromeSchema(schema)
|
||||||
|
_showChromePolicySchemaStd(schema_dict)
|
||||||
|
except GAPI.notFound:
|
||||||
|
entityUnknownWarning(Ent.CHROME_POLICY_SCHEMA, name)
|
||||||
|
except (GAPI.badRequest, GAPI.forbidden):
|
||||||
|
accessErrorExit(None)
|
||||||
|
|
||||||
|
# gam show chromeschemas std [filter <String>]
|
||||||
|
def doShowChromePolicySchemasStd(cp):
|
||||||
|
sfilter = None
|
||||||
|
while Cmd.ArgumentsRemaining():
|
||||||
|
myarg = getArgument()
|
||||||
|
if myarg == 'filter':
|
||||||
|
sfilter = getString(Cmd.OB_STRING)
|
||||||
|
else:
|
||||||
|
unknownArgumentExit()
|
||||||
|
parent = _getCustomersCustomerIdWithC()
|
||||||
|
result = callGAPIpages(cp.customers().policySchemas(), 'list', 'policySchemas',
|
||||||
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
|
parent=parent, filter=sfilter)
|
||||||
|
schemas = {}
|
||||||
|
for schema in result:
|
||||||
|
schema_name, schema_dict = simplifyChromeSchema(schema)
|
||||||
|
schemas[schema_name.lower()] = schema_dict
|
||||||
|
for _, schema in sorted(iter(schemas.items())):
|
||||||
|
_showChromePolicySchemaStd(schema)
|
||||||
printBlankLine()
|
printBlankLine()
|
||||||
|
|
||||||
# gam create chromenetwork
|
# gam create chromenetwork
|
||||||
@@ -76137,7 +76162,7 @@ MAIN_COMMANDS_WITH_OBJECTS = {
|
|||||||
Cmd.ARG_CHROMENEEDSATTN: doPrintShowChromeNeedsAttn,
|
Cmd.ARG_CHROMENEEDSATTN: doPrintShowChromeNeedsAttn,
|
||||||
Cmd.ARG_CHROMEPOLICY: doPrintShowChromePolicies,
|
Cmd.ARG_CHROMEPOLICY: doPrintShowChromePolicies,
|
||||||
Cmd.ARG_CHROMEPROFILE: doPrintShowChromeProfiles,
|
Cmd.ARG_CHROMEPROFILE: doPrintShowChromeProfiles,
|
||||||
Cmd.ARG_CHROMESCHEMA: doPrintShowChromeSchemas,
|
Cmd.ARG_CHROMESCHEMA: doPrintShowChromePolicySchemas,
|
||||||
Cmd.ARG_CHROMESNVALIDITY: doPrintChromeSnValidity,
|
Cmd.ARG_CHROMESNVALIDITY: doPrintChromeSnValidity,
|
||||||
Cmd.ARG_CHROMEVERSIONS: doPrintShowChromeVersions,
|
Cmd.ARG_CHROMEVERSIONS: doPrintShowChromeVersions,
|
||||||
Cmd.ARG_CIGROUP: doPrintCIGroups,
|
Cmd.ARG_CIGROUP: doPrintCIGroups,
|
||||||
@@ -76269,7 +76294,7 @@ MAIN_COMMANDS_WITH_OBJECTS = {
|
|||||||
Cmd.ARG_CHROMENEEDSATTN: doPrintShowChromeNeedsAttn,
|
Cmd.ARG_CHROMENEEDSATTN: doPrintShowChromeNeedsAttn,
|
||||||
Cmd.ARG_CHROMEPOLICY: doPrintShowChromePolicies,
|
Cmd.ARG_CHROMEPOLICY: doPrintShowChromePolicies,
|
||||||
Cmd.ARG_CHROMEPROFILE: doPrintShowChromeProfiles,
|
Cmd.ARG_CHROMEPROFILE: doPrintShowChromeProfiles,
|
||||||
Cmd.ARG_CHROMESCHEMA: doPrintShowChromeSchemas,
|
Cmd.ARG_CHROMESCHEMA: doPrintShowChromePolicySchemas,
|
||||||
Cmd.ARG_CHROMEVERSIONS: doPrintShowChromeVersions,
|
Cmd.ARG_CHROMEVERSIONS: doPrintShowChromeVersions,
|
||||||
Cmd.ARG_CIGROUPMEMBERS: doShowCIGroupMembers,
|
Cmd.ARG_CIGROUPMEMBERS: doShowCIGroupMembers,
|
||||||
Cmd.ARG_CIPOLICY: doPrintShowCIPolicies,
|
Cmd.ARG_CIPOLICY: doPrintShowCIPolicies,
|
||||||
|
|||||||
Reference in New Issue
Block a user