Skip to content

Commit

Permalink
Fix Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gemanor committed Jan 1, 2024
1 parent bfa4808 commit 4a6b1ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
24 changes: 19 additions & 5 deletions permit/permit.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ async def bulk_check(
Checks if a user is authorized to perform an action on a list of resources within the specified context.
Args:
user: The user object representing the user.
action: The action to be performed on the resource.
resources: The list of resource objects representing the resources.
checks: A list of check queries, each query contain user, action, and resource.
context: The context object representing the context in which the action is performed. Defaults to None.
Returns:
Expand All @@ -86,8 +84,24 @@ async def bulk_check(
Examples:
# can the user close any issue?
permit.bulk_check(user, 'close', ['issue'])
# Bulk query of multiple check conventions
await permit.bulk_check([
{
"user": user,
"action": "close",
"resource": {type: "issue", key: "1234"},
},
{
"user": {key: "user"},
"action": "close",
"resource": "issue:1235",
},
{
"user": "user_a",
"action": "close",
"resource": "issue",
},
])
"""
return await self._enforcer.bulk_check(checks, context)

Expand Down
31 changes: 19 additions & 12 deletions permit/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def bulk_check(
Checks if a user is authorized to perform an action on a list of resources within the specified context.
Args:
user: The user object representing the user.
action: The action to be performed on the resource.
resources: The list of resource objects representing the resources.
checks: A list of CheckQuery objects representing the authorization checks to be performed.
context: The context object representing the context in which the action is performed. Defaults to None.
Returns:
Expand All @@ -61,15 +59,24 @@ def bulk_check(
Examples:
# can the user close any issue?
permit.bulk_check(user, 'close', ['issue'])
# can the user close any issue who's id is 1234?
permit.bulk_check(user, 'close', ['issue:1234'])
# can the user close (any) issues belonging to the 't1' tenant?
# (in a multi tenant application)
permit.bulk_check(user, 'close', [{'type': 'issue', 'tenant': 't1'}])
# Bulk query of multiple check conventions
await permit.bulk_check([
{
"user": user,
"action": "close",
"resource": {type: "issue", key: "1234"},
},
{
"user": {key: "user"},
"action": "close",
"resource": "issue:1235",
},
{
"user": "user_a",
"action": "close",
"resource": "issue",
},
])
"""
return self._enforcer.bulk_check(checks, context)

Expand Down

0 comments on commit 4a6b1ec

Please sign in to comment.