Skip to content

Commit

Permalink
refactor: change example to use a for loop rather than direct access
Browse files Browse the repository at this point in the history
Helps show the correlation_id use
  • Loading branch information
ewanharris committed Dec 18, 2024
1 parent dc671ec commit 36f5016
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions example/example1/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async def main():
relation="viewer",
object="document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
context=dict(ViewCount=100),
correlation_id=anne_cor_id,
correlation_id=anne_cor_id, # correlation_id is an optional parameter, the SDK will insert a value if not provided.
),
ClientBatchCheckItem(
user="user:bob",
Expand All @@ -294,8 +294,12 @@ async def main():
]
)
)
print(f"Anne allowed: {response.result[0].allowed}")
print(f"Bob allowed: {response.result[1].allowed}")

for result in response.result:
if result.correlation_id == anne_cor_id:
print(f"Anne allowed: {result.allowed}")
else:
print(f"{result.request.user} allowed: {result.allowed}")

# List objects with context
print("Listing objects for access with context")
Expand Down

0 comments on commit 36f5016

Please sign in to comment.