Skip to content
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

Fix okta pagination handling on apps, groups, and users #652

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
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
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