API Reference - Models
Data Structs
pypermission.Policy
Represents a Role paired with a Permission.
Attributes:
| Name | Type | Description |
|---|---|---|
role |
str
|
The target RoleID. |
permission |
Permission
|
The target Permission. |
__init__(*, role: str, permission: Permission) -> None
Initialize the Policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
The target RoleID. |
required |
permission
|
Permission
|
The target Permission. |
required |
pypermission.Permission
Represents a Resource paired with an Action.
Attributes:
| Name | Type | Description |
|---|---|---|
resource_type |
str
|
The ResourceType (e.g., "document", "user"). |
resource_id |
str
|
The ResourceID. The star '*' acts as a wildcard matching all ResourceIDs of the same ResourceType. The empty string can be used for Actions on Resources that do not have an ResourceID. |
action |
str
|
The Action allowed on the Resource (e.g., "read", "write", "delete"). |
__init__(*, resource_type: str, resource_id: str, action: str) -> None
Initialize the Permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_type
|
str
|
The type of the resource (e.g., "document", "user"). |
required |
resource_id
|
str
|
The ID of the resource instance. The start '*' acts as a wildcard matching all IDs of the resource. The empty string can be used for actions on resources that do not have an ID. |
required |
action
|
str
|
The action allowed on the resource (e.g., "read", "write", "delete"). |
required |
Exceptions
pypermission.PyPermissionError
Bases: Exception
PyPermissionError is the standard error of PyPermission.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
str
|
A detailed description of the occurred error. |
pypermission.PermissionNotGrantedError
Bases: PyPermissionError
PermissionNotGrantedError will be thrown if an assert_permission() fails!
Attributes:
| Name | Type | Description |
|---|---|---|
message |
str
|
A constant error description. |