Role Helper
- class AzuracastPy.models.administration.helpers.RoleHelper(_admin)
Provides a set of functions to interact with radio roles.
- __call__(id: int) Role
Retrieves a specific role from the radio.
- Parameters:
id – The numerical ID of the role to be retrieved.
- Returns:
A
Roleobject.
Usage:
role = admin.role(1)
- __init__(_admin)
Initializes a
RoleHelperobject.Note
This class should not be initialized directly. Instead, obtain an instance via:
role.
- create(name: str, global_permissions: List[GlobalPermissions] | None = None, station_permissions: Dict[str, List[StationPermissions]] | None = None) Role
Adds a new role to the radio.
- Parameters:
name – The name of the role.
global_permissions – (Optional) A list of radio-wide permissions. Each element in this list must be from the
GlobalPermissionsenum class. Default:None.station_permissions – (Optional) A structure representing the station permissions for stations on the radio. This can be generated by using the
generate_station_permissions()function. Default:None.
- Returns:
A
Roleobject for the newly created role.
Usage:
from AzuracastPy.enums import GlobalPermissions, StationPermissions station_permissions = admin.role.generate_station_permissions( ("name", 1, [StationPermissions.VIEW_STATION_LOGS]), (None, 2, [StationPermissions.ADMINISTER_ALL, StationPermissions.VIEW_STATION_LOGS]), ("name", None, [StationPermissions.ADMINISTER_ALL, StationPermissions.VIEW_STATION_LOGS]), (None, 3, None) ) role = admin.role.create( name="New role", global_permissions=[ GlobalPermissions.VIEW_ADMINISTRATION, GlobalPermissions.VIEW_SYSTEM_LOGS ], station_permissions=station_permissions )
- generate_station_permission(station_name: str | None = None, station_id: int | None = None, permissions: List[StationPermissions] | None = None) Dict[str, List[str]]
Generates a single station permissions for a role.
- Parameters:
station_name – (Optional) The name of the station where the permission will be assigned. Either provide this or the station_id param. Default:
None.station_id – (Optional) The id of the station where the permission will be assigned. Either provide this or the station_name param. Default:
None.permissions – (Optional) The list of permissions to assign to the station. Each element in this list must be from the
StationPermissionsenum class. IfNone, all permissions will be given by default. Default:None.
Usage:
from AzuracastPy.enums import StationPermissions station_permission = admin.role.generate_station_permission( station_name="station name", station_id=1, permissions=[ StationPermissions.ADMINISTER_ALL, StationPermissions.VIEW_STATION_LOGS ] )
- generate_station_permissions(*args) Dict[str, List[str]]
- Generates a list of station permissions for a role by using the
:meth:
.generate_station_permissionfunction on each argument.
- Parameters:
args – Tuples in the format of
(station_name, station_id, permission_list). Any of the tuple’s values can beNone.
Usage:
from AzuracastPy.enums import StationPermissions station_permissions = admin.role.generate_station_permissions( ("name", 1, [StationPermissions.VIEW_STATION_LOGS]), (None, 2, [StationPermissions.ADMINISTER_ALL, StationPermissions.VIEW_STATION_LOGS]), ("name", None, [StationPermissions.ADMINISTER_ALL, StationPermissions.VIEW_STATION_LOGS]), (None, 3, None) )