invitation not invite

This commit is contained in:
Jay Lee
2021-03-17 14:43:01 -04:00
parent 338eeba944
commit 1df5662d4f

View File

@ -33,7 +33,7 @@ def _generic_action(action):
'send': 'Sending' 'send': 'Sending'
} }
print_action = action_map[action] print_action = action_map[action]
print(f'{print_action} user invite...') print(f'{print_action} user invitation...')
result = gapi.call(svc.customers().userinvitations(), action, result = gapi.call(svc.customers().userinvitations(), action,
name=name) name=name)
name = result.get('response', {}).get('name') name = result.get('response', {}).get('name')
@ -58,7 +58,7 @@ def _generic_get(get_type):
# Current serial implementation will be SLOW... # Current serial implementation will be SLOW...
def bulk_is_invitable(emails): def bulk_is_invitable(emails):
'''gam <users> check isinvitable''' '''gam <users> check isinvitable'''
def _invite_result(request_id, response, _): def _invitation_result(request_id, response, _):
if response.get('isInvitableUser'): if response.get('isInvitableUser'):
rows.append({'invitableUsers': request_id}) rows.append({'invitableUsers': request_id})
@ -66,7 +66,7 @@ def bulk_is_invitable(emails):
customer = _get_customerid() customer = _get_customerid()
todrive = False todrive = False
#batch_size = 1000 #batch_size = 1000
#ebatch = svc.new_batch_http_request(callback=_invite_result) #ebatch = svc.new_batch_http_request(callback=_invitation_result)
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:
@ -74,7 +74,7 @@ def bulk_is_invitable(emails):
endpoint = svc.customers().userinvitations() endpoint = svc.customers().userinvitations()
#if len(ebatch._order) == batch_size: #if len(ebatch._order) == batch_size:
# ebatch.execute() # ebatch.execute()
# ebatch = svc.new_batch_http_request(callback=_invite_result) # ebatch = svc.new_batch_http_request(callback=_invitation_result)
#req = endpoint.isInvitableUser(name=name) #req = endpoint.isInvitableUser(name=name)
#ebatch.add(req, request_id=email) #ebatch.add(req, request_id=email)
try: try:
@ -131,15 +131,15 @@ def print_():
else: else:
controlflow.invalid_argument_exit(sys.argv[i], controlflow.invalid_argument_exit(sys.argv[i],
'gam print userinvitations') 'gam print userinvitations')
invites = gapi.get_all_pages(svc.customers().userinvitations(), invitations = gapi.get_all_pages(svc.customers().userinvitations(),
'list', 'list',
'userInvitations', 'userInvitations',
parent=customer, parent=customer,
filter=filter_) filter=filter_)
for invite in invites: for invitation in invitations:
invite['name'] = _reduce_name(invite['name']) invitation['name'] = _reduce_name(invitation['name'])
row = {} row = {}
for key, val in invite.items(): for key, val in invitation.items():
if key not in titles: if key not in titles:
titles.append(key) titles.append(key)
row[key] = val row[key] = val