Skip to content

Support creation of orgs for tenants with greater than 500 #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/py42/services/orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def org_id_map(self):
"""Map org guids to ids."""
if not self._org_id_map:
self._org_id_map = {}
page = self.get_page()
for org in page["orgs"]:
self._org_id_map[org["orgId"]] = org["orgGuid"]
pages = self.get_all()
for page in pages:
for org in page.data["orgs"]:
self._org_id_map[org["orgId"]] = org["orgGuid"]
return self._org_id_map

def create_org(self, org_name, org_ext_ref=None, notes=None, parent_org_uid=None):
Expand Down Expand Up @@ -287,13 +288,12 @@ def _get_guid_by_id(self, org_id, id_key="orgId"):
# Use additional lookup to prevent breaking changes.

if id_key != "orgId":
guid = ""
page = self.get_page()
for org in page["orgs"]:
if org[id_key] == org_id:
return org["orgGuid"]
if not guid:
raise Py42Error(f"Couldn't find an Org with ID '{org_id}'.")
pages = self.get_all()
for page in pages:
for org in page.data["orgs"]:
if org[id_key] == org_id:
return org["orgGuid"]
raise Py42Error(f"Couldn't find an Org with {id_key} '{org_id}'.")
else:
try:
return self.org_id_map[org_id]
Expand Down