I am trying to obtain the number of groups per user domain. So I first get the user domains from the Directory APi.Users and the primaryEmail
field
and then obtain the number of groups per domain.
The first part of collecting domains gets the right results. The second part raises <class 'apiclient.errors.HttpError'>
with an exception.message = "group"
(not very useful indeed). The exception is only raised for some of the domains and not all.
Here's a snippet:
def groupsPerDomain():
#code that gets domains... omitted for brevity
#domain_stats = {domainName: <some group info>,...}
#service directory is a directory service instance
groups_sub = service_directory.groups()
for domain in domain_stats:
request = groups_sub.list(domain=domain,
fields="groups(directMembersCount,id,name)")
domain_groups_count = 0
while request != None:
groups_page = request.execute() #THE EXCEPTION IS RAISED HERE
#count groups per domain
domain_groups_count += len(groups_page["groups"])
request = groups_sub.list_next(request, groups_page)
#save counted groups per domain
domain_stats[domain]["group_count"] = domain_groups_count
return domain_stats
Thanks.