1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-17 23:53:49 +01:00
Files
core/homeassistant/components/proxmoxve/helpers.py

19 lines
568 B
Python

"""Helpers for Proxmox VE."""
from .const import ProxmoxPermission
def is_granted(
permissions: dict[str, dict[str, int]],
p_type: str = "vms",
p_id: str | int | None = None, # can be str for nodes
permission: ProxmoxPermission = ProxmoxPermission.POWER,
) -> bool:
"""Validate user permissions for the given type and permission."""
paths = [f"/{p_type}/{p_id}", f"/{p_type}", "/"]
for path in paths:
value = permissions.get(path, {}).get(permission)
if value is not None:
return value == 1
return False