mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-03 22:01:39 +00:00
Added variable developer_preview_apis to gam.cfg
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
7.33.00
|
||||
|
||||
Added variable `developer_preview_apis` to `gam.cfg` that is a comma separated list of APIs requiring a Developer Preview key.
|
||||
Currently, `chat` is the only API that requires a Developer Preview key; it is required for the User Sections commands.
|
||||
* See: https://github.com/GAM-team/GAM/wiki/Users-Chat#introduction
|
||||
* See: https://github.com/GAM-team/GAM/wiki/Users-Chat#manage-chat-user-sections
|
||||
|
||||
7.32.07
|
||||
|
||||
Added option `includepermissionsforview published` to `gam <UserTypeEntity> print filelist` and
|
||||
|
||||
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
||||
"""
|
||||
|
||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||
__version__ = '7.32.07'
|
||||
__version__ = '7.33.00'
|
||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
@@ -3752,6 +3752,15 @@ def SetGlobalVariables():
|
||||
if (productId, sku) not in GM.Globals[GM.LICENSE_SKUS]:
|
||||
GM.Globals[GM.LICENSE_SKUS].append((productId, sku))
|
||||
|
||||
def _validateDeveloperPreviewAPIs(sectionName, itemName, apiList):
|
||||
GM.Globals[GM.DEVELOPER_PREVIEW_APIS] = set()
|
||||
validAPIs = API.getAPIsList()
|
||||
for api in apiList.split(','):
|
||||
if api in validAPIs:
|
||||
GM.Globals[GM.DEVELOPER_PREVIEW_APIS].add(api)
|
||||
else:
|
||||
_printValueError(sectionName, itemName, api, f'{Msg.EXPECTED}: {",".join(sorted(validAPIs))}')
|
||||
|
||||
def _getCfgString(sectionName, itemName):
|
||||
value = _stripStringQuotes(GM.Globals[GM.PARSER].get(sectionName, itemName))
|
||||
if itemName == GC.DOMAIN:
|
||||
@@ -3760,6 +3769,8 @@ def SetGlobalVariables():
|
||||
if ((minLen is None) or (len(value) >= minLen)) and ((maxLen is None) or (len(value) <= maxLen)):
|
||||
if itemName == GC.LICENSE_SKUS and value:
|
||||
_validateLicenseSKUs(sectionName, itemName, value)
|
||||
elif itemName == GC.DEVELOPER_PREVIEW_APIS and value:
|
||||
_validateDeveloperPreviewAPIs(sectionName, itemName, value.lower())
|
||||
return value
|
||||
_printValueError(sectionName, itemName, f'"{value}"', f'{Msg.EXPECTED}: {integerLimits(minLen, maxLen, Msg.STRING_LENGTH)}')
|
||||
return ''
|
||||
@@ -4820,11 +4831,12 @@ def getService(api, httpObj):
|
||||
triesLimit = 3
|
||||
for n in range(1, triesLimit+1):
|
||||
try:
|
||||
if api not in {API.CHAT} or not GC.Values[GC.DEVELOPER_PREVIEW_API_KEY]:
|
||||
if api not in GM.Globals[GM.DEVELOPER_PREVIEW_APIS] or not GC.Values[GC.DEVELOPER_PREVIEW_API_KEY]:
|
||||
discoveryServiceUrl = DISCOVERY_URIS[v2discovery]
|
||||
developerKey = ''
|
||||
else:
|
||||
discoveryServiceUrl = DEVELOPER_PREVIEW_DISCOVERY_URI
|
||||
developerKey = GC.Values[GC.DEVELOPER_PREVIEW_API_KEY]
|
||||
developerKey = GC.Values[GC.DEVELOPER_PREVIEW_API_KEY]
|
||||
service = googleapiclient.discovery.build(api, version, http=httpObj, cache_discovery=False,
|
||||
discoveryServiceUrl=discoveryServiceUrl, developerKey=developerKey, static_discovery=False)
|
||||
GM.Globals[GM.CURRENT_API_SERVICES].setdefault(api, {})
|
||||
@@ -27063,6 +27075,8 @@ def createUpdateChatSection(users):
|
||||
except GAPI.failedPrecondition:
|
||||
userChatServiceNotEnabledWarning(user, i, count)
|
||||
continue
|
||||
except AttributeError:
|
||||
systemErrorExit(GOOGLE_API_ERROR_RC, Msg.DEVELOPER_PREVIEW_REQUIRED)
|
||||
|
||||
# gam <UserTypeEntity> delete chatsection <ChatSection>
|
||||
def deleteChatSection(users):
|
||||
@@ -27093,6 +27107,8 @@ def deleteChatSection(users):
|
||||
except GAPI.failedPrecondition:
|
||||
userChatServiceNotEnabledWarning(user, i, count)
|
||||
continue
|
||||
except AttributeError:
|
||||
systemErrorExit(GOOGLE_API_ERROR_RC, Msg.DEVELOPER_PREVIEW_REQUIRED)
|
||||
|
||||
# gam <UserTypeEntity> show chatsections
|
||||
# [formatjson]
|
||||
@@ -27127,6 +27143,8 @@ def printShowChatSections(users):
|
||||
except GAPI.failedPrecondition:
|
||||
userChatServiceNotEnabledWarning(user, i, count)
|
||||
continue
|
||||
except AttributeError:
|
||||
systemErrorExit(GOOGLE_API_ERROR_RC, Msg.DEVELOPER_PREVIEW_REQUIRED)
|
||||
jcount = len(sections)
|
||||
if jcount == 0:
|
||||
setSysExitRC(NO_ENTITIES_FOUND_RC)
|
||||
@@ -27181,6 +27199,8 @@ def moveShowChatSectionItem(users):
|
||||
except GAPI.failedPrecondition:
|
||||
userChatServiceNotEnabledWarning(user, i, count)
|
||||
continue
|
||||
except AttributeError:
|
||||
systemErrorExit(GOOGLE_API_ERROR_RC, Msg.DEVELOPER_PREVIEW_REQUIRED)
|
||||
|
||||
# gam <UserTypeEntity> show chatsectionitems <ChatSection>
|
||||
# [space <ChatSpace>]
|
||||
@@ -27252,6 +27272,8 @@ def printShowChatSectionItems(users):
|
||||
except GAPI.failedPrecondition:
|
||||
userChatServiceNotEnabledWarning(user, i, count)
|
||||
continue
|
||||
except AttributeError:
|
||||
systemErrorExit(GOOGLE_API_ERROR_RC, Msg.DEVELOPER_PREVIEW_REQUIRED)
|
||||
jcount = len(sectionItems)
|
||||
if jcount == 0:
|
||||
setSysExitRC(NO_ENTITIES_FOUND_RC)
|
||||
|
||||
@@ -812,6 +812,12 @@ def getVersion(api):
|
||||
api = _INFO[api].get('mappedAPI', api)
|
||||
return (api, version, v2discovery)
|
||||
|
||||
def getAPIsList():
|
||||
apisList = set()
|
||||
for api, value in _INFO.items():
|
||||
apisList.add(value.get('mappedAPI', api))
|
||||
return apisList
|
||||
|
||||
def getClientScopesSet(api):
|
||||
return {scope['scope'] for scope in _CLIENT_SCOPES if scope['api'] == api}
|
||||
|
||||
|
||||
@@ -151,6 +151,8 @@ CUSTOMER_ID = 'customer_id'
|
||||
DEBUG_LEVEL = 'debug_level'
|
||||
# redact sensitive credentials from debug output
|
||||
DEBUG_REDACTION = 'debug_redaction'
|
||||
# Developer Preview APIs
|
||||
DEVELOPER_PREVIEW_APIS = 'developer_preview_apis'
|
||||
# Developer Preview API Key
|
||||
DEVELOPER_PREVIEW_API_KEY = 'developer_preview_api_key'
|
||||
# When retrieving lists of ChromeOS devices from API, how many should be retrieved in each chunk
|
||||
@@ -385,6 +387,7 @@ Defaults = {
|
||||
CUSTOMER_ID: MY_CUSTOMER,
|
||||
DEBUG_LEVEL: '0',
|
||||
DEBUG_REDACTION: TRUE,
|
||||
DEVELOPER_PREVIEW_APIS: '',
|
||||
DEVELOPER_PREVIEW_API_KEY: '',
|
||||
DEVICE_MAX_RESULTS: '200',
|
||||
DOMAIN: '',
|
||||
@@ -557,6 +560,7 @@ VAR_INFO = {
|
||||
CUSTOMER_ID: {VAR_TYPE: TYPE_STRING, VAR_ENVVAR: 'CUSTOMER_ID', VAR_LIMITS: (0, None)},
|
||||
DEBUG_LEVEL: {VAR_TYPE: TYPE_INTEGER, VAR_SIGFILE: 'debug.gam', VAR_LIMITS: (0, None), VAR_SFFT: ('0', '4')},
|
||||
DEBUG_REDACTION: {VAR_TYPE: TYPE_BOOLEAN},
|
||||
DEVELOPER_PREVIEW_APIS: {VAR_TYPE: TYPE_STRING, VAR_LIMITS: (0, None)},
|
||||
DEVELOPER_PREVIEW_API_KEY: {VAR_TYPE: TYPE_STRING, VAR_LIMITS: (0, None)},
|
||||
DEVICE_MAX_RESULTS: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 200)},
|
||||
DOMAIN: {VAR_TYPE: TYPE_STRING, VAR_ENVVAR: 'GA_DOMAIN', VAR_LIMITS: (0, None)},
|
||||
|
||||
@@ -111,6 +111,8 @@ DEBUG_LEVEL = 'dbgl'
|
||||
DEBUG_REDACTION = 'dbrd'
|
||||
# Decoded ID token
|
||||
DECODED_ID_TOKEN = 'didt'
|
||||
# Developer Preview APIs
|
||||
DEVELOPER_PREVIEW_APIS = 'dapi'
|
||||
# Index of start of <UserTypeEntity> in command line
|
||||
ENTITY_CL_DELAY_START = 'ecld'
|
||||
ENTITY_CL_START = 'ecls'
|
||||
@@ -267,6 +269,7 @@ Globals = {
|
||||
DEBUG_LEVEL: 0,
|
||||
DEBUG_REDACTION: True,
|
||||
DECODED_ID_TOKEN: None,
|
||||
DEVELOPER_PREVIEW_APIS: set(),
|
||||
ENTITY_CL_DELAY_START: 1,
|
||||
ENTITY_CL_START: 1,
|
||||
EXTRA_ARGS_LIST: [],
|
||||
|
||||
@@ -236,6 +236,7 @@ DATA_TRANSFER_COMPLETED = 'Data Transfer completed: {0}\n'
|
||||
DATA_UPLOADED_TO_DRIVE_FILE = 'Data uploaded to Drive File'
|
||||
DEFAULT_SMIME = 'Default S/MIME'
|
||||
DELETED = 'Deleted'
|
||||
DEVELOPER_PREVIEW_REQUIRED = 'Developer Preview is required for this command\n'
|
||||
DEVICE_LIST_BUG = 'GAM hit Google internal bug 237397223. Please file a Google Support ticket stating that you are encountering this bug.'
|
||||
DEVICE_LIST_BUG_WORKAROUND_NOT_POSSIBLE = 'GAM workaround for this issue only works if orderby argument is not used and query does not contain \'register\'.'
|
||||
DEVICE_LIST_BUG_ATTEMPTING_WORKAROUND = 'GAM is attempting to work around the bug by filtering for devices created on or after the newest we\'ve seen ({0})...\n'
|
||||
|
||||
Reference in New Issue
Block a user