Skip to content
Merged
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
24 changes: 12 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ Manually fetch pages with the nextPageCursor

seam = Seam()

paginator = seam.create_paginator(seam.connected_accounts.list, {"limit": 20})
paginator = seam.create_paginator(seam.devices.list, {"limit": 20})

connected_accounts, pagination = paginator.first_page()
devices, pagination = paginator.first_page()

if pagination.has_next_page:
more_connected_accounts, _ = paginator.next_page(pagination.next_page_cursor)
more_devices, _ = paginator.next_page(pagination.next_page_cursor)

Resume pagination
^^^^^^^^^^^^^^^^^
Expand All @@ -302,17 +302,17 @@ Get the first page on initial load and store the state (e.g., in memory or a fil
seam = Seam()

params = {"limit": 20}
paginator = seam.create_paginator(seam.connected_accounts.list, params)
paginator = seam.create_paginator(seam.devices.list, params)

connected_accounts, pagination = paginator.first_page()
devices, pagination = paginator.first_page()

# Example: Store state for later use (e.g., in a file or database)
pagination_state = {
"params": params,
"next_page_cursor": pagination.next_page_cursor,
"has_next_page": pagination.has_next_page,
}
with open("/tmp/seam_connected_accounts_list.json", "w") as f:
with open("/tmp/seam_devices_list.json", "w") as f:
json.dump(pagination_state, f)

Get the next page at a later time using the stored state:
Expand All @@ -325,14 +325,14 @@ Get the next page at a later time using the stored state:
seam = Seam()

# Example: Load state from where it was stored
with open("/tmp/seam_connected_accounts_list.json", "r") as f:
with open("/tmp/seam_devices_list.json", "r") as f:
pagination_state = json.load(f)

if pagination_state.get("has_next_page"):
paginator = seam.create_paginator(
seam.connected_accounts.list, pagination_state["params"]
seam.devices.list, pagination_state["params"]
)
more_connected_accounts, _ = paginator.next_page(
more_devices, _ = paginator.next_page(
pagination_state["next_page_cursor"]
)

Expand All @@ -345,7 +345,7 @@ Iterate over all resources

seam = Seam()

paginator = seam.create_paginator(seam.connected_accounts.list, {"limit": 20})
paginator = seam.create_paginator(seam.devices.list, {"limit": 20})

for account in paginator.flatten():
print(account.account_type_display_name)
Expand All @@ -359,9 +359,9 @@ Return all resources across all pages as a list

seam = Seam()

paginator = seam.create_paginator(seam.connected_accounts.list, {"limit": 20})
paginator = seam.create_paginator(seam.devices.list, {"limit": 20})

all_connected_accounts = paginator.flatten_to_list()
all_devices = paginator.flatten_to_list()

Interacting with Multiple Workspaces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down