Skip to content

Role status

A database role discovered during RoleManager.check_roles.

Only roles that actually exist in PostgreSQL are represented.

Version Added

1.5.0

Source code in pum/role_manager.py
@dataclass
class RoleStatus:
    """A database role discovered during ``RoleManager.check_roles``.

    Only roles that actually exist in PostgreSQL are represented.

    Version Added:
        1.5.0
    """

    name: str
    """Role name in PostgreSQL."""
    role: Role | None = None
    """Configured role this maps to, or ``None`` for unknown roles."""
    suffix: str = ""
    """DB-specific suffix (e.g. ``"lausanne"``), empty for generic roles."""
    schema_permissions: list[SchemaPermissionStatus] = field(default_factory=list)
    """Per-schema permission details."""
    granted_to: list[str] = field(default_factory=list)
    """Roles that this role is a member of (i.e. ``GRANT parent TO this``)."""
    superuser: bool = False
    """Whether the role is a PostgreSQL superuser."""
    login: bool = False
    """Whether the role has the LOGIN attribute."""

    @property
    def is_unknown(self) -> bool:
        """``True`` when the role is not mapped to a configuration entry."""
        return self.role is None

    @property
    def is_suffixed(self) -> bool:
        """``True`` when the role is a DB-specific (suffixed) variant."""
        return self.suffix != ""

    @property
    def schemas(self) -> list[str]:
        """List of schema names from the permission details."""
        return [sp.schema for sp in self.schema_permissions]

granted_to class-attribute instance-attribute

granted_to: list[str] = field(default_factory=list)

Roles that this role is a member of (i.e. GRANT parent TO this).

is_suffixed property

is_suffixed: bool

True when the role is a DB-specific (suffixed) variant.

is_unknown property

is_unknown: bool

True when the role is not mapped to a configuration entry.

login class-attribute instance-attribute

login: bool = False

Whether the role has the LOGIN attribute.

name instance-attribute

name: str

Role name in PostgreSQL.

role class-attribute instance-attribute

role: Role | None = None

Configured role this maps to, or None for unknown roles.

schema_permissions class-attribute instance-attribute

schema_permissions: list[SchemaPermissionStatus] = field(default_factory=list)

Per-schema permission details.

schemas property

schemas: list[str]

List of schema names from the permission details.

suffix class-attribute instance-attribute

suffix: str = ''

DB-specific suffix (e.g. "lausanne"), empty for generic roles.

superuser class-attribute instance-attribute

superuser: bool = False

Whether the role is a PostgreSQL superuser.