mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 14:43:34 +00:00
limit namespaces based on id type, quote userinvitation emails
This commit is contained in:
@ -53,16 +53,6 @@ def print_policies():
|
|||||||
msg = f'{myarg} is not a valid argument to "gam print chromepolicy"'
|
msg = f'{myarg} is not a valid argument to "gam print chromepolicy"'
|
||||||
controlflow.system_error_exit(3, msg)
|
controlflow.system_error_exit(3, msg)
|
||||||
orgunit = _get_orgunit(orgunit)
|
orgunit = _get_orgunit(orgunit)
|
||||||
namespaces = [
|
|
||||||
'chrome.users',
|
|
||||||
# 'chrome.users.apps',
|
|
||||||
# 'chrome.devices',
|
|
||||||
# 'chrome.devices.managedGuest',
|
|
||||||
# 'chrome.devices.managedGuest.apps',
|
|
||||||
# 'chrome.devices.kiosk',
|
|
||||||
# 'chrome.devices.kiosk.apps',
|
|
||||||
'chrome.printers',
|
|
||||||
]
|
|
||||||
body = {
|
body = {
|
||||||
'policyTargetKey': {
|
'policyTargetKey': {
|
||||||
'targetResource': orgunit,
|
'targetResource': orgunit,
|
||||||
@ -70,8 +60,20 @@ def print_policies():
|
|||||||
}
|
}
|
||||||
if printer_id:
|
if printer_id:
|
||||||
body['policyTargetKey']['additionalTargetKeys'] = {'printer_id': printer_id}
|
body['policyTargetKey']['additionalTargetKeys'] = {'printer_id': printer_id}
|
||||||
|
namespaces = ['chrome.printers']
|
||||||
elif app_id:
|
elif app_id:
|
||||||
body['policyTargetKey']['additionalTargetKeys'] = {'app_id': app_id}
|
body['policyTargetKey']['additionalTargetKeys'] = {'app_id': app_id}
|
||||||
|
namespaces = ['chrome.users.apps',
|
||||||
|
'chrome.devices.managedGuest.apps',
|
||||||
|
'chrome.devices.kiosk.apps']
|
||||||
|
else:
|
||||||
|
namespaces = [
|
||||||
|
'chrome.users',
|
||||||
|
# Not yet implemented:
|
||||||
|
# 'chrome.devices',
|
||||||
|
# 'chrome.devices.managedGuest',
|
||||||
|
# 'chrome.devices.kiosk',
|
||||||
|
]
|
||||||
throw_reasons = [gapi_errors.ErrorReason.FOUR_O_O,]
|
throw_reasons = [gapi_errors.ErrorReason.FOUR_O_O,]
|
||||||
for namespace in namespaces:
|
for namespace in namespaces:
|
||||||
body['policySchemaFilter'] = f'{namespace}.*'
|
body['policySchemaFilter'] = f'{namespace}.*'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Methods related to Cloud Identity User Invitation API"""
|
"""Methods related to Cloud Identity User Invitation API"""
|
||||||
import sys
|
import sys
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
import googleapiclient
|
import googleapiclient
|
||||||
|
|
||||||
@ -26,7 +27,8 @@ def _generic_action(action):
|
|||||||
svc = gapi_cloudidentity.build('cloudidentity_beta')
|
svc = gapi_cloudidentity.build('cloudidentity_beta')
|
||||||
customer = _get_customerid()
|
customer = _get_customerid()
|
||||||
email = sys.argv[3].lower()
|
email = sys.argv[3].lower()
|
||||||
name = f'{customer}/userinvitations/{email}'
|
encoded_email = quote_plus(email)
|
||||||
|
name = f'{customer}/userinvitations/{encoded_email}'
|
||||||
action_map = {
|
action_map = {
|
||||||
'cancel': 'Cancelling',
|
'cancel': 'Cancelling',
|
||||||
'send': 'Sending'
|
'send': 'Sending'
|
||||||
@ -45,7 +47,8 @@ def _generic_get(get_type):
|
|||||||
svc = gapi_cloudidentity.build('cloudidentity_beta')
|
svc = gapi_cloudidentity.build('cloudidentity_beta')
|
||||||
customer = _get_customerid()
|
customer = _get_customerid()
|
||||||
email = sys.argv[3].lower()
|
email = sys.argv[3].lower()
|
||||||
name = f'{customer}/userinvitations/{email}'
|
encoded_email = quote_plus(email)
|
||||||
|
name = f'{customer}/userinvitations/{encoded_email}'
|
||||||
result = gapi.call(svc.customers().userinvitations(), get_type,
|
result = gapi.call(svc.customers().userinvitations(), get_type,
|
||||||
name=name)
|
name=name)
|
||||||
if 'name' in result:
|
if 'name' in result:
|
||||||
@ -69,7 +72,8 @@ def bulk_is_invitable(emails):
|
|||||||
rows = []
|
rows = []
|
||||||
throw_reasons = [gapi_errors.ErrorReason.FOUR_O_THREE]
|
throw_reasons = [gapi_errors.ErrorReason.FOUR_O_THREE]
|
||||||
for email in emails:
|
for email in emails:
|
||||||
name = f'{customer}/userinvitations/{email}'
|
encoded_email = quote_plus(email)
|
||||||
|
name = f'{customer}/userinvitations/{encoded_email}'
|
||||||
endpoint = svc.customers().userinvitations()
|
endpoint = svc.customers().userinvitations()
|
||||||
#if len(ebatch._order) == batch_size:
|
#if len(ebatch._order) == batch_size:
|
||||||
# ebatch.execute()
|
# ebatch.execute()
|
||||||
|
Reference in New Issue
Block a user