Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 17 additions & 11 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1621,25 +1621,31 @@ def lro(


def pagination(client, response):

responses = []
response_json = response.json()
responses.append(response_json)

# Check for pagination
continuation_token = response_json.get("continuationToken")
continuation_uri = response_json.get("continuationUri")

# Loop to handle pagination
while continuation_token is not None:
response = client.get(continuation_uri)
while True:
response_json = response.json()
responses.append(response_json)

# Update the continuation token and URI for the next iteration
continuation_token = response_json.get("continuationToken")
continuation_uri = response_json.get("continuationUri")

# Stop when no more pages
if not continuation_token:
break

try:
response = client.get(continuation_uri)

except Exception as e:
# Handle FabricHTTPException (404)
if hasattr(e, "response") and e.response is not None:
if e.response.status_code == 404:
return responses

# If it's something else, re-raise
raise FabricHTTPException(e.response) if hasattr(e, "response") else e
Comment thread
m-kovalsky marked this conversation as resolved.
Outdated

return responses


Expand Down
2 changes: 2 additions & 0 deletions src/sempy_labs/admin/_basic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def list_workspaces(
"state": "State",
"type": "Type",
"capacityId": "Capacity Id",
"tags": "Tags",
"domainId": "Domain Id",
},
inplace=True,
)
Expand Down
Loading