Skip to content

Commit

Permalink
Fix pagination handling on apps, groups, and users
Browse files Browse the repository at this point in the history
  • Loading branch information
smoy committed Nov 9, 2023
1 parent 7d2f834 commit 1015e47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion iambic/plugins/v0_1_0/okta/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@ async def list_all_apps(okta_organization: OktaOrganization) -> List[App]:
log.error("Error encountered when listing apps", error=str(err))
raise Exception("Error encountered when listing apps")
while resp.has_next():
# pagination handling
async with GlobalRetryController(
fn_identifier="okta.list_applications"
) as retry_controller:
next_apps, err = await retry_controller(handle_okta_fn, resp.next)
if err:
log.error("Error encountered when listing apps", error=str(err))
raise Exception("Error encountered when listing apps")
raw_apps.append(next_apps)
raw_apps.extend(next_apps)

if not raw_apps:
return []
Expand Down
6 changes: 4 additions & 2 deletions iambic/plugins/v0_1_0/okta/group/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ async def list_all_users(okta_organization: OktaOrganization) -> List[User]:
raise Exception(f"Error listing users: {str(err)}")

while resp.has_next():
# pagination handling
async with GlobalRetryController(
fn_identifier="okta.list_users"
) as retry_controller:
next_users, err = await retry_controller(handle_okta_fn, resp.next)
if err:
log.error("Error encountered when listing users", error=str(err))
raise Exception(f"Error listing users: {str(err)}")
users.append(next_users)
users.extend(next_users)

if not users:
return []
Expand Down Expand Up @@ -158,14 +159,15 @@ async def list_all_groups(okta_organization: OktaOrganization) -> List[Group]:
raise Exception(f"Error listing groups: {str(err)}")

while resp.has_next():
# pagination handling
async with GlobalRetryController(
fn_identifier="okta.list_groups"
) as retry_controller:
next_groups, err = await retry_controller(handle_okta_fn, resp.next)
if err:
log.error("Error encountered when listing groups", error=str(err))
raise Exception(f"Error listing groups: {str(err)}")
groups.append(next_groups)
groups.extend(next_groups)

if not groups:
log.info(
Expand Down

0 comments on commit 1015e47

Please sign in to comment.