Roles
albert.collections.roles.RoleCollection
Bases: BaseCollection
Manage Roles in the Albert platform.
A Role defines a set of access permissions (policies) within a tenant.
Roles are assigned to users (User) to
govern what they can do, and are referenced by entity ACLs alongside the
users they apply to.
This collection is accessed as client.roles.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for role requests. |
Methods:
| Name | Description |
|---|---|
get_by_id |
Get a single role by its ID. |
get_all |
Get all available roles. |
create |
Create a new role. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/roles.py
get_by_id
Get a single role by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the role. Role IDs may contain |
required |
Returns:
| Type | Description |
|---|---|
Role
|
The fully populated role. |
Source code in src/albert/collections/roles.py
create
create(*, role: Role)
Create a new role.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
Role
|
The role to create. |
required |
Returns:
| Type | Description |
|---|---|
Role
|
The newly created role. |
Source code in src/albert/collections/roles.py
get_all
Get all available roles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict
|
Optional query parameters passed through to the API to filter or shape the results. Defaults to no parameters. |
None
|
Returns:
| Type | Description |
|---|---|
list[Role]
|
All roles available in the tenant. |