From a71171c4fcc0b20d7d9bd99621ba4e27d917ca75 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Wed, 18 Dec 2024 15:57:34 +0000 Subject: [PATCH] refactor(python-sdk): change example to use a for loop rather than direct acces --- .../template/example/example1/example1.py.mustache | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/config/clients/python/template/example/example1/example1.py.mustache b/config/clients/python/template/example/example1/example1.py.mustache index 106e262a..66e931fa 100644 --- a/config/clients/python/template/example/example1/example1.py.mustache +++ b/config/clients/python/template/example/example1/example1.py.mustache @@ -281,19 +281,23 @@ 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( + ClientBatchCheckItem( user="user:bob", relation="viewer", object="document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a", context=dict(ViewCount=100), - ) + ), ] ) ) - 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")